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

V15 Metadata: Support accessing custom types #1042

Closed
jsdw opened this issue Jun 29, 2023 · 0 comments · Fixed by #1106
Closed

V15 Metadata: Support accessing custom types #1042

jsdw opened this issue Jun 29, 2023 · 0 comments · Fixed by #1106
Assignees

Comments

@jsdw
Copy link
Collaborator

jsdw commented Jun 29, 2023

V15 metadata introduces a new custom type map, something like BTreeMap<String, { type_id: u32, value: Vec<u8> }>.

Once this is stable, let's expose them; maybe with an API something like:

let custom_types = api.custom_types();

// Get some custom type "Foo", `None` if not found.
let ty = custom_types.get("Foo")?;

// Attempt to decode into a concrete type (Foo impls DecodeAsType):
// can use this to decode into `Value` too. `as_` because we have `as_event`,
// `as_extrinsic` or whatever. `decode_as_type` might be nicer.
let something: Foo = ty.as_type()?;

// Return the raw bytes:
let scale_bytes = ty.encoded();

// Return the raw type ID:
let ty_id = ty.type_id();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants