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

Add Runtime API to execute runtime calls #777

Merged
merged 8 commits into from
Jan 18, 2023
Merged

Conversation

lexnv
Copy link
Collaborator

@lexnv lexnv commented Jan 13, 2023

This PR adds the ability to call into the runtime API of the subxt.

At this moment, the subxt utilises the state_call method.
This work lays the ground for transitioning to the chainHead and archive methods of the RPC SpecV2.

The API is exposed both at the root level via, as well at the blocks level (block-centric approach).

Part of #732 .

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Comment on lines 119 to 127
async fn fetch_metadata(rpc: &Rpc<T>) -> Result<Metadata, Error> {
let bytes = rpc
.state_call("Metadata_metadata".into(), None, None)
.await?;
let cursor = &mut &*bytes;
let _ = <Compact<u32>>::decode(cursor)?;
let meta: RuntimeMetadataPrefixed = Decode::decode(cursor)?;
Ok(meta.try_into()?)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! :)

Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome! Just one wee comment :)

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks clean, one question regarding an expect :P

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
@lexnv lexnv merged commit b4bb176 into master Jan 18, 2023
@lexnv lexnv deleted the lexnv/rpc_blocks_runtime_api branch January 18, 2023 15:49
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 this pull request may close these issues.

3 participants