desub icon indicating copy to clipboard operation
desub copied to clipboard

Use trait for Metadata

Open insipx opened this issue 5 years ago • 1 comments

instead of a struct that older metadata versions are converted into, use a trait which older metadata versions implement

This will cause less future compilation issues, and create an easier api to use

Instead of converting each metadata version into one superstruct, we could define a trait with common functions such as module_by_index and impl trait

insipx avatar Mar 24 '20 15:03 insipx

This is difficult to accomplish without re-building the RuntimeMetadataPrefixed struct for each metadata version and implementing the trait on that. RuntimeMetadataPrefixed has many nested datastructures within it that are often wrapped in DecodeDifferent which makes simple traversing & querying difficult. Not sure of a good way around this, so sticking with From/Into conversions into the Desub Metadata structure is fine for now.

The chief reason for implementing Metadata as a trait is making the API nicer and also making it easier to port over different metadata versions.

One solution could be implementing a trait on DecodeDifferent itself that will always decode to one of the DecodeDifferent enum variants.

insipx avatar Sep 27 '20 15:09 insipx