-
Notifications
You must be signed in to change notification settings - Fork 10
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
Expose types for the overarching Call, Error, Event types #43
Comments
I can think of two ways to approach this:
Possibly you could start with |
We deal with this in Subxt at the moment by generating the relevant root impl ::subxt::events::RootEvent for Event {
fn root_event(
pallet_bytes: &[u8],
pallet_name: &str,
pallet_ty: u32,
metadata: &::subxt::Metadata,
) -> Result<Self, ::subxt::Error> {
use subxt::metadata::DecodeWithMetadata;
if pallet_name == "System" {
return Ok(Event::System(system::Event::decode_with_metadata(
&mut &*pallet_bytes,
pallet_ty,
metadata,
)?));
}
if pallet_name == "Scheduler" {
return Ok(Event::Scheduler(scheduler::Event::decode_with_metadata(
&mut &*pallet_bytes,
pallet_ty,
metadata,
)?));
}
if pallet_name == "Preimage" {
return Ok(Event::Preimage(preimage::Event::decode_with_metadata(
&mut &*pallet_bytes,
pallet_ty,
metadata,
)?));
}
// ...
}
} This exists to work around the fact that the type Id for the generated type isn't in the type info, and lets us instead use the pallet name to, in the above case, encode arbitrary events. All that to say, I think exposing the |
This issue has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/stablising-v15-metadata/2819/1 |
The paritytech/substrate#14143 PR closes this |
Currently, using these with e.g. https://github.com/paritytech/scale-value requires doing manual decoding of the first byte, hunting down the pallet index in
RuntimeMetadataV14::pallets
, and then decoding the remainder of the payload with the types exposed inPalletMetadata
. TheRuntimeMetadataV14
should expose all of these overarching types.The text was updated successfully, but these errors were encountered: