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

RUNTIME_APIS is empty when expanded with wasm path #1858

Closed
ShoyuVanilla opened this issue Nov 8, 2024 · 5 comments · Fixed by #1859
Closed

RUNTIME_APIS is empty when expanded with wasm path #1858

ShoyuVanilla opened this issue Nov 8, 2024 · 5 comments · Fixed by #1859

Comments

@ShoyuVanilla
Copy link

ShoyuVanilla commented Nov 8, 2024

#1720 introduced a way to generate metadata from runtime wasm files, but when I try generate it like;

#[subxt_macro::subxt(
    runtime_path = "<my wasm path>"
)]
pub mod foo {}

The resulting code expanded with cargo-expand shows as

#[allow(dead_code, unused_imports, non_camel_case_types, unreachable_patterns)]
#[allow(clippy::all)]
#[allow(rustdoc::broken_intra_doc_links)]
pub mod foo {
    #[allow(unused_imports)]
    mod root_mod {
        pub use super::*;
    }
    pub static PALLETS: [&str; 63usize] = [
..
    ];
    // This is empty!
    pub static RUNTIME_APIS: [&str; 0usize] = [];

while expanding macros in previous ways like

#[subxt_macro::subxt(
    runtime_metadata_insecure_url = "wss://westend-rpc.polkadot.io")
]
pub mod foo {}

the RUNTIME_APIS is filled like

...
    pub static RUNTIME_APIS: [&str; 22usize] = [
        "Core",
        "Metadata",
        "BlockBuilder",
...

I've tried with wasm files from https://github.com/polkadot-fellows/runtimes/releases/ and https://github.com/paritytech/subxt/blob/master/artifacts/westend_runtime.wasm but all of them are expanded into empty RUNTIME_APIS

@niklasad1
Copy link
Member

/cc @pkhry any idea?

@pkhry
Copy link
Contributor

pkhry commented Nov 8, 2024

/cc @pkhry any idea?

Let me take a quick look

@jsdw
Copy link
Collaborator

jsdw commented Nov 8, 2024

The reason for this is that the WASM loader thing calls Metadata_metadata, which only returns V14 metadata. We should use Metadata_metadata_at_version and Metadata_versions to extract the appropriate metadata (V15 is possible, V14 if not)

pkhry added a commit that referenced this issue Nov 8, 2024
pkhry added a commit that referenced this issue Nov 12, 2024
@jsdw
Copy link
Collaborator

jsdw commented Nov 12, 2024

@ShoyuVanilla if you get the chance, would you be able to try again with the master branch of Subxt? Things should work properly for you now :)

@ShoyuVanilla
Copy link
Author

ShoyuVanilla commented Nov 12, 2024

@ShoyuVanilla if you get the chance, would you be able to try again with the master branch of Subxt? Things should work properly for you now :)

Actually, I've tried with pkhry's PR branch already and it worked nicely 😄 Thanks for your great work!

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.

4 participants