Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use trait for Metadata #15

Open
insipx opened this issue Mar 24, 2020 · 1 comment
Open

Use trait for Metadata #15

insipx opened this issue Mar 24, 2020 · 1 comment

Comments

@insipx
Copy link
Contributor

insipx commented Mar 24, 2020

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
Copy link
Contributor Author

insipx commented Sep 27, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant