From fca3261b56617632fb4ff69bceff574718818ca1 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 10 May 2023 12:31:10 +0200 Subject: [PATCH 01/17] add cli command to explore metadata --- cli/Cargo.toml | 3 + cli/src/commands/mod.rs | 1 + cli/src/commands/show.rs | 221 ++++++++++++++++++++++ cli/src/main.rs | 2 + cli/src/utils.rs | 4 + cli/src/utils/type_description.rs | 262 +++++++++++++++++++++++++ cli/src/utils/type_example.rs | 304 ++++++++++++++++++++++++++++++ 7 files changed, 797 insertions(+) create mode 100644 cli/src/commands/show.rs create mode 100644 cli/src/utils/type_description.rs create mode 100644 cli/src/utils/type_example.rs diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 718b3df7af..136cab5dba 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -19,6 +19,7 @@ path = "src/main.rs" [dependencies] subxt-codegen = { workspace = true } subxt-metadata = { workspace = true } +subxt = { workspace = true } clap = { workspace = true } serde = { workspace = true, features = ["derive"] } color-eyre = { workspace = true } @@ -26,6 +27,8 @@ serde_json = { workspace = true } hex = { workspace = true } frame-metadata = { workspace = true } codec = { package = "parity-scale-codec", workspace = true } +scale-info = { workspace = true } +scale-value = { workspace = true } syn = { workspace = true } jsonrpsee = { workspace = true, features = ["async-client", "client-ws-transport", "http-client"] } tokio = { workspace = true } diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 15660ac122..6aff4330ba 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -5,4 +5,5 @@ pub mod codegen; pub mod compatibility; pub mod metadata; +pub mod show; pub mod version; diff --git a/cli/src/commands/show.rs b/cli/src/commands/show.rs new file mode 100644 index 0000000000..95485a710c --- /dev/null +++ b/cli/src/commands/show.rs @@ -0,0 +1,221 @@ +use crate::utils::type_description::{format_type_description, TypeDescription}; +use crate::utils::type_example::TypeExample; +use crate::utils::FileOrUrl; +use clap::Parser as ClapParser; +use clap::Subcommand; +use codec::Decode; +use color_eyre::eyre::eyre; +use frame_metadata::v15::RuntimeMetadataV15; +use frame_metadata::{PalletMetadata, RuntimeMetadata, RuntimeMetadataPrefixed}; +use scale_info::form::PortableForm; +use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant, Variant}; +use scale_value::{Composite, Value, ValueDef}; +use subxt::utils::H256; +use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; +use subxt::{tx, PolkadotConfig}; + +/// Shows the pallets and calls available for a node and lets you build unsigned extrinsics. +/// +/// # Example +/// +/// Show the pallets that are available: +/// ``` +/// subxt show --file=../artifacts/polkadot_metadata.scale +/// ``` +/// Show the calls in a pallet: +/// ``` +/// subxt show --file=../artifacts/polkadot_metadata.scale Balances +/// ``` +/// Show the call parameters a call expects: +/// ``` +/// subxt show --file=../artifacts/polkadot_metadata.scale Balances transfer +/// ``` +/// Create an unsigned extrinsic from a scale value, validate it and output its hex representation +/// ``` +/// subxt show --file=../artifacts/polkadot_metadata.scale Grandpa note_stalled { "delay": 5, "best_finalized_block_number": 5 } +/// ``` +/// +#[derive(Debug, ClapParser)] +pub struct Opts { + #[command(flatten)] + file_or_url: FileOrUrl, + + pallet: Option, + call: Option, + #[clap(required = false)] + trailing_args: Vec, +} + +/// cargo run -- show --file=../artifacts/polkadot_metadata.scale mom cook apple banana +pub async fn run(opts: Opts) -> color_eyre::Result<()> { + // get the metadata + let bytes = opts.file_or_url.fetch().await?; + let metadata_prefixed = ::decode(&mut &bytes[..])?; + let metadata = Metadata::try_from(metadata_prefixed)?; + + // if no pallet specified, show user the pallets to choose from: + let Some(pallet_name) = opts.pallet else { + println!("If you want to explore a pallet: subxt show \n{}", print_available_pallets(metadata.runtime_metadata())); + return Ok(()); + }; + + // if specified pallet is wrong, show user the pallets to choose from (but this time as an error): + let Some(pallet) = metadata.runtime_metadata().pallets.iter().find(|pallet| pallet.name == pallet_name)else { + return Err(eyre!("pallet \"{}\" not found in metadata!\n{}", pallet_name, print_available_pallets(metadata.runtime_metadata()))); + }; + + // get the enum that stores the possible calls: + let (calls_enum_type_def, calls_enum_type, calls_type_id) = + get_calls_enum_type(pallet, &metadata.runtime_metadata().types)?; + + // if no call specified, show user the calls to choose from: + let Some(call_name) = opts.call else { + println!("If you want to explore a pallet: subxt show {pallet_name} \n{}", print_available_calls(&calls_enum_type_def)); + return Ok(()); + }; + + // if specified call is wrong, show user the calls to choose from (but this time as an error): + let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name == call_name) else { + return Err(eyre!("call \"{}\" not found in pallet \"{}\"!\n{}", call_name, pallet_name, print_available_calls(&calls_enum_type_def))); + }; + + // collect all the trailing arguments into a single string that is later into a scale_value::Value + let trailing_args = opts.trailing_args.join(" "); + + // if no trailing arguments specified show user the expected type of arguments with examples: + if trailing_args.is_empty() { + let call_description = print_call_description(call, &metadata.runtime_metadata().types)?; + println!( + "If you want to create an unsigned extrinsic for {pallet_name}/{call_name} representing a scale value of the type {}::{call_name}:\nsubxt show {pallet_name} {call_name} \n{call_description}", + calls_enum_type.path + ); + return Ok(()); + } + + // parse scale_value from trailing arguments and try to create an unsigned extrinsic with it: + let value = scale_value::stringify::from_str(&trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; + let value_as_composite = value_into_composite(value); + let offline_client = new_offline_client(metadata); + let payload = tx::dynamic(pallet_name, call_name, value_as_composite); + let unsigned_extrinsic = offline_client.tx().create_unsigned(&payload)?; + let hex_bytes = format!("0x{}", hex::encode(unsigned_extrinsic.encoded())); + + println!("Encoded call data:"); + println!("{hex_bytes}"); + + Ok(()) +} + +fn print_available_pallets(metadata_v15: &RuntimeMetadataV15) -> String { + if metadata_v15.pallets.is_empty() { + "There are no pallets in this node.".to_string() + } else { + let mut output = "Available pallets are:".to_string(); + for pallet in metadata_v15.pallets.iter() { + output.push_str(format!("\n- {}", pallet.name).as_str()) + } + output + } +} + +fn get_calls_enum_type<'a>( + pallet: &'a frame_metadata::v15::PalletMetadata, + registry: &'a PortableRegistry, +) -> color_eyre::Result<( + &'a TypeDefVariant, + &'a Type, + u32, +)> { + let calls = pallet + .calls + .as_ref() + .ok_or(eyre!("pallet {} has no calls.", pallet.name))?; + let calls_enum_type = registry + .resolve(calls.ty.id) + .ok_or(eyre!("calls type with id {} not found.", calls.ty.id))?; + // should always be a variant type, where each variant corresponds to one call. + let calls_enum_type_def = match &calls_enum_type.type_def { + TypeDef::Variant(variant) => variant, + _ => { + return Err(eyre!("calls type is not a variant")); + } + }; + Ok((calls_enum_type_def, calls_enum_type, calls.ty.id)) +} + +fn print_available_calls(pallet: &TypeDefVariant) -> String { + if pallet.variants.is_empty() { + "There are no calls in this pallet.".to_string() + } else { + let mut output = "Available calls are:".to_string(); + for variant in pallet.variants.iter() { + output.push_str(format!("\n- {}", variant.name).as_str()) + } + output + } +} + +fn print_call_description( + call_variant: &Variant, + registry: &PortableRegistry, +) -> color_eyre::Result { + let type_description = call_variant.fields.type_description(registry)?; + let type_description = format_type_description(&type_description); + let type_examples = call_variant + .fields + .type_example(registry) + .unwrap_or(Vec::new()); + + let mut output = String::new(); + output.push_str("The type looks like this:\n"); + output.push_str(type_description.as_str()); + + output.push_str("\n\n"); + match type_examples.len() { + 0 => { + output.push_str(format!("There are no examples available for this type.").as_str()); + } + 1 => { + output.push_str(format!("Here is an example of this type:").as_str()); + } + i => { + output.push_str(format!("Here are {i} examples of this type:").as_str()); + } + }; + + for composite in type_examples { + let value = scale_value::Value { + value: ValueDef::Composite(composite), + context: (), + }; + let example_str = scale_value::stringify::to_string(&value); + output.push_str("\n"); + output.push_str(example_str.as_str()); + } + + Ok(output) +} + +/// composites stay composites, all other types are converted into a 1-fielded unnamed composite +fn value_into_composite(value: scale_value::Value) -> scale_value::Composite<()> { + match value.value { + ValueDef::Composite(composite) => composite, + _ => Composite::Unnamed(vec![value]), + } +} + +fn new_offline_client(metadata: Metadata) -> OfflineClient { + let genesis_hash = { + let h = "91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"; + let bytes = hex::decode(h).unwrap(); + H256::from_slice(&bytes) + }; + + let runtime_version = subxt::rpc::types::RuntimeVersion { + spec_version: 9370, + transaction_version: 20, + other: Default::default(), + }; + + OfflineClient::::new(genesis_hash, runtime_version, metadata) +} diff --git a/cli/src/main.rs b/cli/src/main.rs index 4ad786f7b8..3b47cf5000 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -15,6 +15,7 @@ enum Command { Codegen(commands::codegen::Opts), Compatibility(commands::compatibility::Opts), Version(commands::version::Opts), + Show(commands::show::Opts), } #[tokio::main] @@ -27,5 +28,6 @@ async fn main() -> color_eyre::Result<()> { Command::Codegen(opts) => commands::codegen::run(opts).await, Command::Compatibility(opts) => commands::compatibility::run(opts).await, Command::Version(opts) => commands::version::run(opts), + Command::Show(opts) => commands::show::run(opts).await, } } diff --git a/cli/src/utils.rs b/cli/src/utils.rs index 9a8b6edf82..da09a01c58 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -4,9 +4,13 @@ use clap::Args; use color_eyre::eyre; +use scale_info::PortableRegistry; use std::{fs, io::Read, path::PathBuf}; use subxt_codegen::utils::{MetadataVersion, Uri}; +pub mod type_description; +pub mod type_example; + /// The source of the metadata. #[derive(Debug, Args)] pub struct FileOrUrl { diff --git a/cli/src/utils/type_description.rs b/cli/src/utils/type_description.rs new file mode 100644 index 0000000000..3a4a4c008c --- /dev/null +++ b/cli/src/utils/type_description.rs @@ -0,0 +1,262 @@ +use color_eyre::eyre::eyre; +use std::{fs, process::Output}; + +use frame_metadata::RuntimeMetadataPrefixed; +use scale_info::{ + form::PortableForm, + scale::{Decode, Encode}, + Field, PortableRegistry, Type, TypeDef, TypeDefArray, TypeDefBitSequence, TypeDefCompact, + TypeDefComposite, TypeDefPrimitive, TypeDefSequence, TypeDefTuple, TypeDefVariant, TypeInfo, + Variant, +}; +use scale_value::Value; + +pub trait TypeDescription { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result; +} + +impl TypeDescription for u32 { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + let ty = registry + .resolve(*self) + .ok_or(eyre!("Type with id {} not found in registry", *self))?; + let ident = ty.path.ident(); + let prefix = type_def_prefix(&ty.type_def); + let mut type_def_description = ty.type_def.type_description(registry)?; + if let Some(ident) = ident { + type_def_description = format!("{} {}", ident, type_def_description) + } + if let Some(prefix) = prefix { + type_def_description = format!("{} {}", prefix, type_def_description) + } + Ok(type_def_description) + } +} + +fn type_def_prefix(type_def: &TypeDef) -> Option<&str> { + match type_def { + TypeDef::Composite(_) => Some("struct"), + TypeDef::Variant(_) => Some("enum"), + _ => None, + } +} + +impl TypeDescription for TypeDef { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + match self { + TypeDef::Composite(composite) => composite.fields.type_description(registry), + TypeDef::Variant(variant) => variant.type_description(registry), + TypeDef::Sequence(sequence) => sequence.type_description(registry), + TypeDef::Array(array) => array.type_description(registry), + TypeDef::Tuple(tuple) => tuple.type_description(registry), + TypeDef::Primitive(primitive) => primitive.type_description(registry), + TypeDef::Compact(compact) => compact.type_description(registry), + TypeDef::BitSequence(bit_sequence) => bit_sequence.type_description(registry), + } + } +} + +impl TypeDescription for TypeDefTuple { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + let mut output = String::new(); + output.push('('); + for (is_last, ty) in mark_last(self.fields.iter(), self.fields.len()) { + let type_description = ty.id.type_description(registry)?; + output.push_str(&type_description); + if !is_last { + output.push(',') + } + } + output.push(')'); + Ok(output) + } +} + +impl TypeDescription for TypeDefBitSequence { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + let bit_order_type = self.bit_order_type.id.type_description(registry)?; + let bit_store_type = self.bit_store_type.id.type_description(registry)?; + Ok(format!("BitSequence({bit_order_type}, {bit_store_type})")) + } +} + +impl TypeDescription for TypeDefSequence { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + let type_description = self.type_param.id.type_description(registry)?; + Ok(format!("Sequence({type_description})")) + } +} + +impl TypeDescription for TypeDefCompact { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + let type_description = self.type_param.id.type_description(registry)?; + Ok(format!("Compact({type_description})")) + } +} + +impl TypeDescription for TypeDefArray { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + let type_description = self.type_param.id.type_description(registry)?; + Ok(format!("[{type_description}; {}]", self.len)) + } +} + +impl TypeDescription for TypeDefPrimitive { + fn type_description(&self, _registry: &PortableRegistry) -> color_eyre::Result { + Ok(match &self { + TypeDefPrimitive::Bool => "bool", + TypeDefPrimitive::Char => "char", + TypeDefPrimitive::Str => "String", + TypeDefPrimitive::U8 => "u8", + TypeDefPrimitive::U16 => "u16", + TypeDefPrimitive::U32 => "u32", + TypeDefPrimitive::U64 => "u64", + TypeDefPrimitive::U128 => "u128", + TypeDefPrimitive::U256 => "u256", + TypeDefPrimitive::I8 => "i8", + TypeDefPrimitive::I16 => "i16", + TypeDefPrimitive::I32 => "i32", + TypeDefPrimitive::I64 => "i64", + TypeDefPrimitive::I128 => "i128", + TypeDefPrimitive::I256 => "i256", + } + .into()) + } +} + +impl TypeDescription for TypeDefVariant { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + const MIN_VARIANT_COUNT_FOR_TRAILING_COMMA: usize = 100; + let add_trailing_comma = self.variants.len() >= MIN_VARIANT_COUNT_FOR_TRAILING_COMMA; + + let mut variants_string = String::new(); + variants_string.push('{'); + for (is_last, variant) in mark_last(self.variants.iter(), self.variants.len()) { + let variant_string = variant.type_description(registry)?; + variants_string.push_str(&variant_string); + + if !is_last || add_trailing_comma { + variants_string.push(','); + } + } + variants_string.push('}'); + Ok(variants_string) + } +} + +impl TypeDescription for Variant { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + let fields_string = self.fields.type_description(registry)?; + let output = if fields_string.is_empty() { + self.name.to_string() + } else if fields_string.starts_with("(") { + format!("{}{}", &self.name, fields_string) + } else { + format!("{} {}", &self.name, fields_string) + }; + Ok(output) + } +} + +impl TypeDescription for Vec> { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + if self.is_empty() { + return Ok("()".to_string()); + } + + const MIN_FIELD_COUNT_FOR_TRAILING_COMMA: usize = 100; + let add_trailing_comma = self.len() >= MIN_FIELD_COUNT_FOR_TRAILING_COMMA; + + let all_fields_named = self.iter().all(|f| f.name.is_some()); + let all_fields_unnamed = self.iter().all(|f| f.name.is_none()); + let brackets = match (all_fields_named, all_fields_unnamed) { + (true, false) => ('{', '}'), + (false, true) => ('(', ')'), + _ => { + return Err(eyre!( + "combination of named and unnamed fields in compound type" + )); + } + }; + + let mut fields_string = String::new(); + fields_string.push(brackets.0); + for (is_last, field) in mark_last(self.iter(), self.len()) { + let field_description = field.type_description(registry)?; + fields_string.push_str(&field_description); + + if !is_last || add_trailing_comma { + fields_string.push(',') + } + } + fields_string.push(brackets.1); + Ok(fields_string) + } +} + +impl TypeDescription for Field { + fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { + let type_description = self.ty.id.type_description(registry)?; + let type_description_maybe_named = if let Some(name) = &self.name { + format!("{}: {}", name, type_description) + } else { + type_description + }; + Ok(type_description_maybe_named) + } +} + +pub fn format_type_description(input: &str) -> String { + fn add_indentation(output: &mut String, indent_level: i32) { + for _ in 0..indent_level { + output.push_str(" "); + } + } + + let mut output = String::new(); + let mut indent_level = 0; + // in a tuple we will not set line breaks on comma, so we keep track of it here: + let mut in_tuple = 0; + for ch in input.chars() { + match ch { + '{' => { + indent_level += 1; + output.push(ch); + output.push('\n'); + add_indentation(&mut output, indent_level); + } + '}' => { + indent_level -= 1; + output.push('\n'); + add_indentation(&mut output, indent_level); + output.push(ch); + } + ',' => { + output.push(ch); + if in_tuple > 0 { + output.push(' '); + } else { + output.push('\n'); + add_indentation(&mut output, indent_level); + } + } + + '(' => { + output.push(ch); + in_tuple += 1; + } + ')' => { + output.push(ch); + in_tuple -= 1; + } + _ => { + output.push(ch); + } + } + } + output +} + +fn mark_last(items: impl Iterator, len: usize) -> impl Iterator { + items.enumerate().map(move |(i, e)| (i == len - 1, e)) +} diff --git a/cli/src/utils/type_example.rs b/cli/src/utils/type_example.rs new file mode 100644 index 0000000000..b3f5d19872 --- /dev/null +++ b/cli/src/utils/type_example.rs @@ -0,0 +1,304 @@ +use color_eyre::eyre::eyre; +use std::{fs, process::Output}; + +use frame_metadata::RuntimeMetadataPrefixed; +use scale_info::{ + form::PortableForm, + scale::{Decode, Encode}, + Field, PortableRegistry, Type, TypeDef, TypeDefArray, TypeDefBitSequence, TypeDefCompact, + TypeDefComposite, TypeDefPrimitive, TypeDefSequence, TypeDefTuple, TypeDefVariant, TypeInfo, + Variant, +}; +use scale_value::Value; + +pub trait TypeExample { + type Value; + fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result>; +} + +impl TypeExample for u32 { + type Value = scale_value::Value; + + fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result> { + let ty = registry + .resolve(*self) + .ok_or(eyre!("Type with id {} not found in registry", *self))?; + + let examples = match &ty.type_def { + TypeDef::Composite(composite) => composite + .fields + .type_example(registry)? + .into_iter() + .map(|e| scale_value::Value { + value: scale_value::ValueDef::Composite(e), + context: (), + }) + .collect(), + TypeDef::Variant(variant) => variant + .type_example(registry)? + .into_iter() + .map(|e| scale_value::Value { + value: scale_value::ValueDef::Variant(e), + context: (), + }) + .collect(), + TypeDef::Array(array) => array + .type_example(registry)? + .into_iter() + .map(|e| scale_value::Value { + value: scale_value::ValueDef::Composite(e), + context: (), + }) + .collect(), + TypeDef::Tuple(tuple) => tuple + .type_example(registry)? + .into_iter() + .map(|e| scale_value::Value { + value: scale_value::ValueDef::Composite(e), + context: (), + }) + .collect(), + TypeDef::Primitive(primitive) => primitive + .type_example(registry)? + .into_iter() + .map(scale_value::Value::primitive) + .collect(), + TypeDef::Compact(compact) => compact.type_param.id.type_example(registry)?, + TypeDef::BitSequence(_) => { + return Err(eyre!("no examples for BitSequence available")); + } + TypeDef::Sequence(sequence) => { + // for sequences we just give an example of an array with 3 elements: + TypeDefArray { + len: 3, + type_param: sequence.type_param, + } + .type_example(registry)? + .into_iter() + .map(|e| scale_value::Value { + value: scale_value::ValueDef::Composite(e), + context: (), + }) + .collect() + } + }; + Ok(examples) + } +} + +impl TypeExample for TypeDefVariant { + type Value = scale_value::Variant<()>; + + fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result> { + let mut examples: Vec> = Vec::new(); + + // returns one example for each variant + for variant in &self.variants { + // get the first example for the variant's data and use it + let mut variant_value_examples = variant.fields.type_example(registry)?; + let Some(values) = variant_value_examples.pop() else { + return Err(eyre!("no example element for variant {}", variant.name)); + }; + + examples.push(scale_value::Variant { + name: variant.name.clone(), + values, + }); + } + + Ok(examples) + } +} + +impl TypeExample for TypeDefArray { + type Value = scale_value::Composite<()>; + + fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result> { + // take the first example value and set it to each element of the array + let mut value_examples = self.type_param.id.type_example(registry)?; + let Some(first_value_example) = value_examples.pop() else { + return Err(eyre!("no example element for array")); + }; + + let one_example = { + let mut values = Vec::with_capacity(self.len as usize); + for _ in 0..self.len as usize { + values.push(first_value_example.clone()); + } + scale_value::Composite::<()>::Unnamed(values) + }; + Ok(vec![one_example]) + } +} + +impl TypeExample for TypeDefTuple { + type Value = scale_value::Composite<()>; + + fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result> { + // create unnamed fields to use the same logic already used for struct example generation + let fields_vector: Vec> = self + .fields + .iter() + .map(|ty| Field { + name: None, + ty: *ty, + type_name: None, + docs: Vec::new(), + }) + .collect(); + fields_vector.type_example(registry) + } +} + +impl TypeExample for Vec> { + type Value = scale_value::Composite<()>; + + fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result> { + let all_fields_named = self.iter().all(|f| f.name.is_some()); + let all_fields_unnamed = self.iter().all(|f| f.name.is_none()); + // composite apparently has no fields: + if all_fields_named && all_fields_unnamed { + let one_empty_example = scale_value::Composite::Unnamed(Vec::new()); + return Ok(vec![one_empty_example]); + } + + // composite apparently has mix of named and unnamed fields: + if !all_fields_named && !all_fields_unnamed { + return Err(eyre!( + "combination of named and unnamed fields in compound type" + )); + } + + // for each field get all the examples the type of that field can offer: + let mut field_examples: Vec<(&Field, Vec)> = Vec::new(); + for field in self.iter() { + let examples = field.ty.id.type_example(registry)?; + field_examples.push((field, examples)); + } + + // Let N be the mininum number of examples any field has. + // Return N examples for the Compound type, by choosing the ith example for each of the 0..N examples for that field. + let n = field_examples + .iter() + .map(|(_, examples)| examples.len()) + .min() + .unwrap(); // safe to unwrap, because min could only be None if there are no fields. But in that case we already return an error above. + let mut composite_examples: Vec, scale_value::Value)>> = + Vec::new(); + for _ in 0..n { + let composite_example: Vec<(&Field, scale_value::Value)> = field_examples + .iter_mut() + .map(|(field, examples)| (*field, examples.pop().unwrap())) + .collect(); // the pop() is safe to unwrap because of the minimum we checked before + composite_examples.push(composite_example); + } + + // create the vector of composite scale values. Distingiush between named and unnamed here. + let composite_examples = composite_examples + .into_iter() + .map(|composite_example| { + if all_fields_named { + let composite_example = composite_example + .into_iter() + .map(|(field, value)| (field.name.as_ref().unwrap().clone(), value)) + .collect(); + scale_value::Composite::Named(composite_example) + } else { + let composite_example = composite_example + .into_iter() + .map(|(_, value)| (value)) + .collect(); + scale_value::Composite::Unnamed(composite_example) + } + }) + .collect(); + Ok(composite_examples) + } +} + +/// 3-4 example values for each primitive +impl TypeExample for TypeDefPrimitive { + type Value = scale_value::Primitive; + + fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result> { + let value = match &self { + TypeDefPrimitive::Bool => vec![ + scale_value::Primitive::Bool(true), + scale_value::Primitive::Bool(false), + ], + TypeDefPrimitive::Char => vec![ + scale_value::Primitive::Char('r'), + scale_value::Primitive::Char('u'), + scale_value::Primitive::Char('s'), + scale_value::Primitive::Char('t'), + ], + TypeDefPrimitive::Str => vec![ + scale_value::Primitive::String("Alice".into()), + scale_value::Primitive::String("Bob".into()), + scale_value::Primitive::String("Foo".into()), + scale_value::Primitive::String("Bar".into()), + ], + TypeDefPrimitive::U8 => vec![ + scale_value::Primitive::U128(u8::MIN as u128), + scale_value::Primitive::U128(69), + scale_value::Primitive::U128(u8::MAX as u128), + ], + TypeDefPrimitive::U16 => vec![ + scale_value::Primitive::U128(u16::MIN as u128), + scale_value::Primitive::U128(420), + scale_value::Primitive::U128(u16::MAX as u128), + ], + TypeDefPrimitive::U32 => vec![ + scale_value::Primitive::U128(u32::MIN as u128), + scale_value::Primitive::U128(99000), + scale_value::Primitive::U128(u32::MAX as u128), + ], + TypeDefPrimitive::U64 => vec![ + scale_value::Primitive::U128(u64::MIN as u128), + scale_value::Primitive::U128(99000), + scale_value::Primitive::U128(u64::MAX as u128), + ], + TypeDefPrimitive::U128 => vec![ + scale_value::Primitive::U128(u128::MIN), + scale_value::Primitive::U128(99000), + scale_value::Primitive::U128(u128::MAX), + ], + TypeDefPrimitive::U256 => vec![ + scale_value::Primitive::U256([u8::MIN; 32]), + scale_value::Primitive::U256([3; 32]), + scale_value::Primitive::U256([u8::MAX; 32]), + ], + TypeDefPrimitive::I8 => vec![ + scale_value::Primitive::I128(i8::MIN as i128), + scale_value::Primitive::I128(69), + scale_value::Primitive::I128(i8::MAX as i128), + ], + TypeDefPrimitive::I16 => vec![ + scale_value::Primitive::I128(i16::MIN as i128), + scale_value::Primitive::I128(420), + scale_value::Primitive::I128(i16::MAX as i128), + ], + TypeDefPrimitive::I32 => vec![ + scale_value::Primitive::I128(i32::MIN as i128), + scale_value::Primitive::I128(99000), + scale_value::Primitive::I128(i32::MAX as i128), + ], + TypeDefPrimitive::I64 => vec![ + scale_value::Primitive::I128(i64::MIN as i128), + scale_value::Primitive::I128(99000), + scale_value::Primitive::I128(i64::MAX as i128), + ], + TypeDefPrimitive::I128 => vec![ + scale_value::Primitive::I128(i128::MIN), + scale_value::Primitive::I128(99000), + scale_value::Primitive::I128(i128::MAX), + ], + TypeDefPrimitive::I256 => vec![ + scale_value::Primitive::I256([u8::MIN; 32]), + scale_value::Primitive::I256([3; 32]), + scale_value::Primitive::I256([u8::MAX; 32]), + ], + }; + Ok(value) + } +} From 8f31b154713cc4939ef264789491cc85f44c1af8 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 10 May 2023 12:41:57 +0200 Subject: [PATCH 02/17] fmt and clippy --- cli/src/commands/show.rs | 24 ++++++++++++++---------- cli/src/utils.rs | 2 +- cli/src/utils/type_description.rs | 12 +++--------- cli/src/utils/type_example.rs | 26 ++++++++++---------------- 4 files changed, 28 insertions(+), 36 deletions(-) diff --git a/cli/src/commands/show.rs b/cli/src/commands/show.rs index 95485a710c..d224c7affb 100644 --- a/cli/src/commands/show.rs +++ b/cli/src/commands/show.rs @@ -2,17 +2,17 @@ use crate::utils::type_description::{format_type_description, TypeDescription}; use crate::utils::type_example::TypeExample; use crate::utils::FileOrUrl; use clap::Parser as ClapParser; -use clap::Subcommand; + use codec::Decode; use color_eyre::eyre::eyre; use frame_metadata::v15::RuntimeMetadataV15; -use frame_metadata::{PalletMetadata, RuntimeMetadata, RuntimeMetadataPrefixed}; +use frame_metadata::RuntimeMetadataPrefixed; use scale_info::form::PortableForm; use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant, Variant}; -use scale_value::{Composite, Value, ValueDef}; +use scale_value::{Composite, ValueDef}; +use subxt::tx; use subxt::utils::H256; use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; -use subxt::{tx, PolkadotConfig}; /// Shows the pallets and calls available for a node and lets you build unsigned extrinsics. /// @@ -65,18 +65,18 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { }; // get the enum that stores the possible calls: - let (calls_enum_type_def, calls_enum_type, calls_type_id) = + let (calls_enum_type_def, calls_enum_type, _calls_type_id) = get_calls_enum_type(pallet, &metadata.runtime_metadata().types)?; // if no call specified, show user the calls to choose from: let Some(call_name) = opts.call else { - println!("If you want to explore a pallet: subxt show {pallet_name} \n{}", print_available_calls(&calls_enum_type_def)); + println!("If you want to explore a pallet: subxt show {pallet_name} \n{}", print_available_calls(calls_enum_type_def)); return Ok(()); }; // if specified call is wrong, show user the calls to choose from (but this time as an error): let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name == call_name) else { - return Err(eyre!("call \"{}\" not found in pallet \"{}\"!\n{}", call_name, pallet_name, print_available_calls(&calls_enum_type_def))); + return Err(eyre!("call \"{}\" not found in pallet \"{}\"!\n{}", call_name, pallet_name, print_available_calls(calls_enum_type_def))); }; // collect all the trailing arguments into a single string that is later into a scale_value::Value @@ -173,10 +173,14 @@ fn print_call_description( output.push_str("\n\n"); match type_examples.len() { 0 => { - output.push_str(format!("There are no examples available for this type.").as_str()); + output.push_str( + "There are no examples available for this type." + .to_string() + .as_str(), + ); } 1 => { - output.push_str(format!("Here is an example of this type:").as_str()); + output.push_str("Here is an example of this type:".to_string().as_str()); } i => { output.push_str(format!("Here are {i} examples of this type:").as_str()); @@ -189,7 +193,7 @@ fn print_call_description( context: (), }; let example_str = scale_value::stringify::to_string(&value); - output.push_str("\n"); + output.push('\n'); output.push_str(example_str.as_str()); } diff --git a/cli/src/utils.rs b/cli/src/utils.rs index da09a01c58..877d231da9 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -4,7 +4,7 @@ use clap::Args; use color_eyre::eyre; -use scale_info::PortableRegistry; + use std::{fs, io::Read, path::PathBuf}; use subxt_codegen::utils::{MetadataVersion, Uri}; diff --git a/cli/src/utils/type_description.rs b/cli/src/utils/type_description.rs index 3a4a4c008c..b886e22f5e 100644 --- a/cli/src/utils/type_description.rs +++ b/cli/src/utils/type_description.rs @@ -1,15 +1,9 @@ use color_eyre::eyre::eyre; -use std::{fs, process::Output}; -use frame_metadata::RuntimeMetadataPrefixed; use scale_info::{ - form::PortableForm, - scale::{Decode, Encode}, - Field, PortableRegistry, Type, TypeDef, TypeDefArray, TypeDefBitSequence, TypeDefCompact, - TypeDefComposite, TypeDefPrimitive, TypeDefSequence, TypeDefTuple, TypeDefVariant, TypeInfo, - Variant, + form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefArray, TypeDefBitSequence, + TypeDefCompact, TypeDefPrimitive, TypeDefSequence, TypeDefTuple, TypeDefVariant, Variant, }; -use scale_value::Value; pub trait TypeDescription { fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result; @@ -149,7 +143,7 @@ impl TypeDescription for Variant { let fields_string = self.fields.type_description(registry)?; let output = if fields_string.is_empty() { self.name.to_string() - } else if fields_string.starts_with("(") { + } else if fields_string.starts_with('(') { format!("{}{}", &self.name, fields_string) } else { format!("{} {}", &self.name, fields_string) diff --git a/cli/src/utils/type_example.rs b/cli/src/utils/type_example.rs index b3f5d19872..285f1da1ee 100644 --- a/cli/src/utils/type_example.rs +++ b/cli/src/utils/type_example.rs @@ -1,15 +1,9 @@ use color_eyre::eyre::eyre; -use std::{fs, process::Output}; -use frame_metadata::RuntimeMetadataPrefixed; use scale_info::{ - form::PortableForm, - scale::{Decode, Encode}, - Field, PortableRegistry, Type, TypeDef, TypeDefArray, TypeDefBitSequence, TypeDefCompact, - TypeDefComposite, TypeDefPrimitive, TypeDefSequence, TypeDefTuple, TypeDefVariant, TypeInfo, - Variant, + form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefArray, TypeDefPrimitive, + TypeDefTuple, TypeDefVariant, }; -use scale_value::Value; pub trait TypeExample { type Value; @@ -73,13 +67,13 @@ impl TypeExample for u32 { len: 3, type_param: sequence.type_param, } - .type_example(registry)? - .into_iter() - .map(|e| scale_value::Value { - value: scale_value::ValueDef::Composite(e), - context: (), - }) - .collect() + .type_example(registry)? + .into_iter() + .map(|e| scale_value::Value { + value: scale_value::ValueDef::Composite(e), + context: (), + }) + .collect() } }; Ok(examples) @@ -220,7 +214,7 @@ impl TypeExample for Vec> { impl TypeExample for TypeDefPrimitive { type Value = scale_value::Primitive; - fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result> { + fn type_example(&self, _registry: &PortableRegistry) -> color_eyre::Result> { let value = match &self { TypeDefPrimitive::Bool => vec![ scale_value::Primitive::Bool(true), From 6db225f1da0ecf9922c12c14784601192908ffd4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 11:03:45 +0200 Subject: [PATCH 03/17] Bump serde from 1.0.160 to 1.0.162 (#948) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.160 to 1.0.162. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.160...1.0.162) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1bbec594c..42af107e56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2923,18 +2923,18 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 71c7eb4d4d..caf7c49579 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ scale-value = "0.7.0" scale-bits = "0.3" scale-decode = "0.5.0" scale-encode = "0.1.0" -serde = { version = "1.0.159" } +serde = { version = "1.0.162" } serde_json = { version = "1.0.96" } syn = { version = "2.0.15", features = ["full", "extra-traits"] } thiserror = "1.0.40" From 26c5fd020e648a5ae80dd887ddd2c7568e8dc01e Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Wed, 10 May 2023 13:18:39 +0300 Subject: [PATCH 04/17] extrinsics: Decode extrinsics from blocks (#929) * Update polkadot.scale Signed-off-by: Alexandru Vasile * extrinsics: Add extrinsics client Signed-off-by: Alexandru Vasile * extrinsics: Decode extrinsics Signed-off-by: Alexandru Vasile * subxt: Add extrinsic error Signed-off-by: Alexandru Vasile * blocks: Expose extrinsics Signed-off-by: Alexandru Vasile * examples: Fetch and decode block extrinsics Signed-off-by: Alexandru Vasile * Fix clippy Signed-off-by: Alexandru Vasile * extrinsics: Fetch pallet and variant index Signed-off-by: Alexandru Vasile * subxt: Move extrinsics on the subxt::blocks Signed-off-by: Alexandru Vasile * example: Adjust example Signed-off-by: Alexandru Vasile * metadata: Collect ExtrinsicMetadata Signed-off-by: Alexandru Vasile * subxt: Implement StaticExtrinsic for the calls Signed-off-by: Alexandru Vasile * Adjust examples Signed-off-by: Alexandru Vasile * codegen: Add root level Call enum Signed-off-by: Alexandru Vasile * Adjust testing Signed-off-by: Alexandru Vasile * subxt: Add new decode interface Signed-off-by: Alexandru Vasile * subxt: Merge ExtrinsicError with BlockError Signed-off-by: Alexandru Vasile * examples: Find first extrinsic Signed-off-by: Alexandru Vasile * Move code to extrinsic_types Signed-off-by: Alexandru Vasile * Add Extrinsic struct Signed-off-by: Alexandru Vasile * Adjust examples Signed-off-by: Alexandru Vasile * test: Decode extinsics Signed-off-by: Alexandru Vasile * extrinsics/test: Add fake metadata for static decoding Signed-off-by: Alexandru Vasile * extrinsics/test: Decode from insufficient bytes Signed-off-by: Alexandru Vasile * extrinsics/test: Check unsupported versions Signed-off-by: Alexandru Vasile * extrinsics/test: Statically decode to root and pallet enums Signed-off-by: Alexandru Vasile * extrinsics/tests: Remove clones Signed-off-by: Alexandru Vasile * blocks: Fetch block body inline Signed-off-by: Alexandru Vasile * blocks: Rename ExtrinsicIds to ExtrinsicPartTypeIds Signed-off-by: Alexandru Vasile * extrinsics/test: Check decode as_extrinsic Signed-off-by: Alexandru Vasile * blocks: Remove InsufficientData error Signed-off-by: Alexandru Vasile * blocks: Return error from extrinsic_metadata Signed-off-by: Alexandru Vasile * extrinsics: Postpone decoding of call bytes Signed-off-by: Alexandru Vasile * metadata_type: Rename variables Signed-off-by: Alexandru Vasile * Adjust calls path for example and tests Signed-off-by: Alexandru Vasile * examples: Remove traces Signed-off-by: Alexandru Vasile * book: Add extrinsics documentation Signed-off-by: Alexandru Vasile * book: Improve extrinsics docs Signed-off-by: Alexandru Vasile --------- Signed-off-by: Alexandru Vasile Co-authored-by: James Wilson --- Cargo.lock | 1 + codegen/src/api/calls.rs | 7 + codegen/src/api/mod.rs | 49 + codegen/src/error.rs | 5 + examples/examples/block_extrinsics.rs | 99 + examples/examples/blocks_subscribing.rs | 3 +- subxt/Cargo.toml | 1 + subxt/src/blocks/block_types.rs | 176 +- subxt/src/blocks/extrinsic_types.rs | 919 +++ subxt/src/blocks/mod.rs | 6 +- subxt/src/book/usage/extrinsics.rs | 49 + subxt/src/config/mod.rs | 2 +- subxt/src/error/mod.rs | 10 + subxt/src/events/events_type.rs | 26 +- subxt/src/metadata/metadata_type.rs | 133 +- subxt/src/metadata/mod.rs | 4 +- testing/integration-tests/src/blocks/mod.rs | 72 +- .../integration-tests/src/codegen/polkadot.rs | 5179 ++++++++++++++++- .../src/metadata/validation.rs | 26 +- 19 files changed, 6548 insertions(+), 219 deletions(-) create mode 100644 examples/examples/block_extrinsics.rs create mode 100644 subxt/src/blocks/extrinsic_types.rs diff --git a/Cargo.lock b/Cargo.lock index 42af107e56..4aebdc9e6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3537,6 +3537,7 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" name = "subxt" version = "0.28.0" dependencies = [ + "assert_matches", "base58", "bitvec", "blake2", diff --git a/codegen/src/api/calls.rs b/codegen/src/api/calls.rs index 4df5ca637c..23b579ed89 100644 --- a/codegen/src/api/calls.rs +++ b/codegen/src/api/calls.rs @@ -83,6 +83,11 @@ pub fn generate_calls( // The call structure's documentation was stripped above. let call_struct = quote! { #struct_def + + impl #crate_path::blocks::StaticExtrinsic for #struct_name { + const PALLET: &'static str = #pallet_name; + const CALL: &'static str = #call_name; + } }; let client_fn = quote! { @@ -106,6 +111,7 @@ pub fn generate_calls( .into_iter() .unzip(); + let call_type = type_gen.resolve_type_path(call.ty.id); let call_ty = type_gen.resolve_type(call.ty.id); let docs = &call_ty.docs; let docs = should_gen_docs @@ -114,6 +120,7 @@ pub fn generate_calls( Ok(quote! { #docs + pub type Call = #call_type; pub mod calls { use super::root_mod; use super::#types_mod_ident; diff --git a/codegen/src/api/mod.rs b/codegen/src/api/mod.rs index 2421e711f1..9a0f395e71 100644 --- a/codegen/src/api/mod.rs +++ b/codegen/src/api/mod.rs @@ -367,6 +367,26 @@ impl RuntimeGenerator { } }; + let outer_extrinsic_variants = self.metadata.pallets.iter().filter_map(|p| { + let variant_name = format_ident!("{}", p.name); + let mod_name = format_ident!("{}", p.name.to_string().to_snake_case()); + let index = proc_macro2::Literal::u8_unsuffixed(p.index); + + p.calls.as_ref().map(|_| { + quote! { + #[codec(index = #index)] + #variant_name(#mod_name::Call), + } + }) + }); + + let outer_extrinsic = quote! { + #default_derives + pub enum Call { + #( #outer_extrinsic_variants )* + } + }; + let root_event_if_arms = self.metadata.pallets.iter().filter_map(|p| { let variant_name_str = &p.name; let variant_name = format_ident!("{}", variant_name_str); @@ -385,6 +405,24 @@ impl RuntimeGenerator { }) }); + let root_extrinsic_if_arms = self.metadata.pallets.iter().filter_map(|p| { + let variant_name_str = &p.name; + let variant_name = format_ident!("{}", variant_name_str); + let mod_name = format_ident!("{}", variant_name_str.to_string().to_snake_case()); + p.calls.as_ref().map(|_| { + // An 'if' arm for the RootExtrinsic impl to match this variant name: + quote! { + if pallet_name == #variant_name_str { + return Ok(Call::#variant_name(#mod_name::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata + )?)); + } + } + }) + }); + let outer_error_variants = self.metadata.pallets.iter().filter_map(|p| { let variant_name = format_ident!("{}", p.name); let mod_name = format_ident!("{}", p.name.to_string().to_snake_case()); @@ -483,7 +521,18 @@ impl RuntimeGenerator { } } + #outer_extrinsic + + impl #crate_path::blocks::RootExtrinsic for Call { + fn root_extrinsic(pallet_bytes: &[u8], pallet_name: &str, pallet_ty: u32, metadata: &#crate_path::Metadata) -> Result { + use #crate_path::metadata::DecodeWithMetadata; + #( #root_extrinsic_if_arms )* + Err(#crate_path::ext::scale_decode::Error::custom(format!("Pallet name '{}' not found in root Call enum", pallet_name)).into()) + } + } + #outer_error + impl #crate_path::error::RootError for Error { fn root_error(pallet_bytes: &[u8], pallet_name: &str, metadata: &#crate_path::Metadata) -> Result { use #crate_path::metadata::DecodeWithMetadata; diff --git a/codegen/src/error.rs b/codegen/src/error.rs index 43bb88c612..9a3d977332 100644 --- a/codegen/src/error.rs +++ b/codegen/src/error.rs @@ -53,6 +53,11 @@ pub enum CodegenError { "{0} type should be an variant/enum type. Make sure you are providing a valid substrate-based metadata" )] InvalidType(String), + /// Extrinsic call type could not be found. + #[error( + "Extrinsic call type could not be found. Make sure you are providing a valid substrate-based metadata" + )] + MissingCallType, } impl CodegenError { diff --git a/examples/examples/block_extrinsics.rs b/examples/examples/block_extrinsics.rs new file mode 100644 index 0000000000..e71182c421 --- /dev/null +++ b/examples/examples/block_extrinsics.rs @@ -0,0 +1,99 @@ +// Copyright 2019-2023 Parity Technologies (UK) Ltd. +// This file is dual-licensed as Apache-2.0 or GPL-3.0. +// see LICENSE for license details. + +//! To run this example, a local polkadot node should be running. Example verified against polkadot v0.9.28-9ffe6e9e3da. +//! +//! E.g. +//! ```bash +//! curl "https://github.com/paritytech/polkadot/releases/download/v0.9.28/polkadot" --output /usr/local/bin/polkadot --location +//! polkadot --dev --tmp +//! ``` + +use futures::StreamExt; +use sp_keyring::AccountKeyring; +use std::time::Duration; +use subxt::{tx::PairSigner, OnlineClient, PolkadotConfig}; + +#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")] +pub mod polkadot {} + +/// Subscribe to all events, and then manually look through them and +/// pluck out the events that we care about. +#[tokio::main] +async fn main() -> Result<(), Box> { + // Create a client to use: + let api = OnlineClient::::new().await?; + + // Subscribe to (in this case, finalized) blocks. + let mut block_sub = api.blocks().subscribe_finalized().await?; + + // While this subscription is active, balance transfers are made somewhere: + tokio::task::spawn({ + let api = api.clone(); + async move { + let signer = PairSigner::new(AccountKeyring::Alice.pair()); + let mut transfer_amount = 1_000_000_000; + + // Make small balance transfers from Alice to Bob in a loop: + loop { + let transfer_tx = polkadot::tx() + .balances() + .transfer(AccountKeyring::Bob.to_account_id().into(), transfer_amount); + api.tx() + .sign_and_submit_default(&transfer_tx, &signer) + .await + .unwrap(); + + tokio::time::sleep(Duration::from_secs(10)).await; + transfer_amount += 100_000_000; + } + } + }); + + // Get each finalized block as it arrives. + while let Some(block) = block_sub.next().await { + let block = block?; + + let block_hash = block.hash(); + println!(" Block {:?}", block_hash); + + // Ask for the extrinsics for this block. + let extrinsics = block.body().await?.extrinsics(); + + let transfer_tx = extrinsics.find_first::(); + println!(" Transfer tx: {:?}", transfer_tx); + + // Ask for the extrinsics for this block. + for extrinsic in extrinsics.iter() { + let extrinsic = extrinsic?; + + println!( + " Extrinsic block index {:?}, pallet index {:?}, variant index {:?}", + extrinsic.index(), + extrinsic.pallet_index(), + extrinsic.variant_index() + ); + + let root_extrinsic = extrinsic.as_root_extrinsic::(); + println!(" As root extrinsic {:?}\n", root_extrinsic); + + let pallet_extrinsic = extrinsic + .as_pallet_extrinsic::(); + println!( + " Extrinsic as Balances Pallet call: {:?}\n", + pallet_extrinsic + ); + + let call = extrinsic.as_extrinsic::()?; + println!( + " Extrinsic as polkadot::balances::calls::Transfer: {:?}\n\n", + call + ); + } + + println!("\n"); + } + + Ok(()) +} diff --git a/examples/examples/blocks_subscribing.rs b/examples/examples/blocks_subscribing.rs index 4c8cdb6cff..a5b585e612 100644 --- a/examples/examples/blocks_subscribing.rs +++ b/examples/examples/blocks_subscribing.rs @@ -25,7 +25,8 @@ async fn main() -> Result<(), Box> { // Log each of the extrinsic with it's associated events: let body = block.body().await?; - for ext in body.extrinsics() { + for ext in body.extrinsics().iter() { + let ext = ext?; let idx = ext.index(); let events = ext.events().await?; let bytes_hex = format!("0x{}", hex::encode(ext.bytes())); diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml index 1a0ebc7977..f32ce34947 100644 --- a/subxt/Cargo.toml +++ b/subxt/Cargo.toml @@ -90,3 +90,4 @@ sp-core = { workspace = true } sp-runtime = { workspace = true } sp-keyring = { workspace = true } sp-version = { workspace = true } +assert_matches = { workspace = true } diff --git a/subxt/src/blocks/block_types.rs b/subxt/src/blocks/block_types.rs index 3c98e40d39..37830973ee 100644 --- a/subxt/src/blocks/block_types.rs +++ b/subxt/src/blocks/block_types.rs @@ -3,15 +3,16 @@ // see LICENSE for license details. use crate::{ + blocks::{extrinsic_types::ExtrinsicPartTypeIds, Extrinsics}, client::{OfflineClientT, OnlineClientT}, - config::{Config, Hasher, Header}, + config::{Config, Header}, error::{BlockError, Error}, events, rpc::types::ChainBlockResponse, runtime_api::RuntimeApi, storage::Storage, }; -use derivative::Derivative; + use futures::lock::Mutex as AsyncMutex; use std::sync::Arc; @@ -26,7 +27,7 @@ pub struct Block { // A cache for our events so we don't fetch them more than once when // iterating over events for extrinsics. -type CachedEvents = Arc>>>; +pub(crate) type CachedEvents = Arc>>>; impl Block where @@ -69,16 +70,17 @@ where /// Fetch and return the block body. pub async fn body(&self) -> Result, Error> { + let ids = ExtrinsicPartTypeIds::new(self.client.metadata().runtime_metadata())?; let block_hash = self.header.hash(); - let block_details = match self.client.rpc().block(Some(block_hash)).await? { - Some(block) => block, - None => return Err(BlockError::not_found(block_hash).into()), + let Some(block_details) = self.client.rpc().block(Some(block_hash)).await? else { + return Err(BlockError::not_found(block_hash).into()); }; Ok(BlockBody::new( self.client.clone(), block_details, self.cached_events.clone(), + ids, )) } @@ -99,6 +101,7 @@ pub struct BlockBody { details: ChainBlockResponse, client: C, cached_events: CachedEvents, + ids: ExtrinsicPartTypeIds, } impl BlockBody @@ -110,167 +113,32 @@ where client: C, details: ChainBlockResponse, cached_events: CachedEvents, + ids: ExtrinsicPartTypeIds, ) -> Self { Self { details, client, cached_events, + ids, } } /// Returns an iterator over the extrinsics in the block body. - pub fn extrinsics(&self) -> impl Iterator> { - self.details - .block - .extrinsics - .iter() - .enumerate() - .map(|(idx, e)| Extrinsic { - index: idx as u32, - bytes: &e.0, - client: self.client.clone(), - block_hash: self.details.block.header.hash(), - cached_events: self.cached_events.clone(), - _marker: std::marker::PhantomData, - }) - } -} - -/// A single extrinsic in a block. -pub struct Extrinsic<'a, T: Config, C> { - index: u32, - bytes: &'a [u8], - client: C, - block_hash: T::Hash, - cached_events: CachedEvents, - _marker: std::marker::PhantomData, -} - -impl<'a, T, C> Extrinsic<'a, T, C> -where - T: Config, - C: OfflineClientT, -{ - /// The index of the extrinsic in the block. - pub fn index(&self) -> u32 { - self.index - } - - /// The bytes of the extrinsic. - pub fn bytes(&self) -> &'a [u8] { - self.bytes - } -} - -impl<'a, T, C> Extrinsic<'a, T, C> -where - T: Config, - C: OnlineClientT, -{ - /// The events associated with the extrinsic. - pub async fn events(&self) -> Result, Error> { - let events = get_events(&self.client, self.block_hash, &self.cached_events).await?; - let ext_hash = T::Hasher::hash_of(&self.bytes); - Ok(ExtrinsicEvents::new(ext_hash, self.index, events)) - } -} - -/// The events associated with a given extrinsic. -#[derive(Derivative)] -#[derivative(Debug(bound = ""))] -pub struct ExtrinsicEvents { - // The hash of the extrinsic (handy to expose here because - // this type is returned from TxProgress things in the most - // basic flows, so it's the only place people can access it - // without complicating things for themselves). - ext_hash: T::Hash, - // The index of the extrinsic: - idx: u32, - // All of the events in the block: - events: events::Events, -} - -impl ExtrinsicEvents { - pub(crate) fn new(ext_hash: T::Hash, idx: u32, events: events::Events) -> Self { - Self { - ext_hash, - idx, - events, - } - } - - /// Return the hash of the block that the extrinsic is in. - pub fn block_hash(&self) -> T::Hash { - self.events.block_hash() - } - - /// The index of the extrinsic that these events are produced from. - pub fn extrinsic_index(&self) -> u32 { - self.idx - } - - /// Return the hash of the extrinsic. - pub fn extrinsic_hash(&self) -> T::Hash { - self.ext_hash - } - - /// Return all of the events in the block that the extrinsic is in. - pub fn all_events_in_block(&self) -> &events::Events { - &self.events - } - - /// Iterate over all of the raw events associated with this transaction. - /// - /// This works in the same way that [`events::Events::iter()`] does, with the - /// exception that it filters out events not related to the submitted extrinsic. - pub fn iter(&self) -> impl Iterator> + '_ { - self.events.iter().filter(|ev| { - ev.as_ref() - .map(|ev| ev.phase() == events::Phase::ApplyExtrinsic(self.idx)) - .unwrap_or(true) // Keep any errors. - }) - } - - /// Find all of the transaction events matching the event type provided as a generic parameter. - /// - /// This works in the same way that [`events::Events::find()`] does, with the - /// exception that it filters out events not related to the submitted extrinsic. - pub fn find(&self) -> impl Iterator> + '_ { - self.iter().filter_map(|ev| { - ev.and_then(|ev| ev.as_event::().map_err(Into::into)) - .transpose() - }) - } - - /// Iterate through the transaction events using metadata to dynamically decode and skip - /// them, and return the first event found which decodes to the provided `Ev` type. - /// - /// This works in the same way that [`events::Events::find_first()`] does, with the - /// exception that it ignores events not related to the submitted extrinsic. - pub fn find_first(&self) -> Result, Error> { - self.find::().next().transpose() - } - - /// Iterate through the transaction events using metadata to dynamically decode and skip - /// them, and return the last event found which decodes to the provided `Ev` type. - /// - /// This works in the same way that [`events::Events::find_last()`] does, with the - /// exception that it ignores events not related to the submitted extrinsic. - pub fn find_last(&self) -> Result, Error> { - self.find::().last().transpose() - } - - /// Find an event in those associated with this transaction. Returns true if it was found. - /// - /// This works in the same way that [`events::Events::has()`] does, with the - /// exception that it ignores events not related to the submitted extrinsic. - pub fn has(&self) -> Result { - Ok(self.find::().next().transpose()?.is_some()) + // Dev note: The returned iterator is 'static + Send so that we can box it up and make + // use of it with our `FilterExtrinsic` stuff. + pub fn extrinsics(&self) -> Extrinsics { + Extrinsics::new( + self.client.clone(), + self.details.block.extrinsics.clone(), + self.cached_events.clone(), + self.ids, + self.details.block.header.hash(), + ) } } // Return Events from the cache, or fetch from the node if needed. -async fn get_events( +pub(crate) async fn get_events( client: &C, block_hash: T::Hash, cached_events: &AsyncMutex>>, diff --git a/subxt/src/blocks/extrinsic_types.rs b/subxt/src/blocks/extrinsic_types.rs new file mode 100644 index 0000000000..ac090c7092 --- /dev/null +++ b/subxt/src/blocks/extrinsic_types.rs @@ -0,0 +1,919 @@ +// Copyright 2019-2023 Parity Technologies (UK) Ltd. +// This file is dual-licensed as Apache-2.0 or GPL-3.0. +// see LICENSE for license details. + +use crate::{ + blocks::block_types::{get_events, CachedEvents}, + client::{OfflineClientT, OnlineClientT}, + config::{Config, Hasher}, + error::{BlockError, Error}, + events, + metadata::{DecodeWithMetadata, ExtrinsicMetadata}, + rpc::types::ChainBlockExtrinsic, + Metadata, +}; + +use codec::Decode; +use derivative::Derivative; +use frame_metadata::v15::RuntimeMetadataV15; +use scale_decode::DecodeAsFields; +use std::{collections::HashMap, sync::Arc}; + +/// Trait to uniquely identify the extrinsic's identity from the runtime metadata. +/// +/// Generated API structures that represent an extrinsic implement this trait. +/// +/// The trait is utilized to decode emitted extrinsics from a block, via obtaining the +/// form of the `Extrinsic` from the metadata. +pub trait StaticExtrinsic: DecodeAsFields { + /// Pallet name. + const PALLET: &'static str; + /// Call name. + const CALL: &'static str; + + /// Returns true if the given pallet and call names match this extrinsic. + fn is_extrinsic(pallet: &str, call: &str) -> bool { + Self::PALLET == pallet && Self::CALL == call + } +} + +/// This trait is implemented on the statically generated root extrinsic type, so that we're able +/// to decode it properly via a pallet that impls `DecodeAsMetadata`. This is necessary +/// because the "root extrinsic" type is generated using pallet info but doesn't actually exist in the +/// metadata types, so we have no easy way to decode things into it via type information and need a +/// little help via codegen. +#[doc(hidden)] +pub trait RootExtrinsic: Sized { + /// Given details of the pallet extrinsic we want to decode, and the name of the pallet, try to hand + /// back a "root extrinsic". + fn root_extrinsic( + pallet_bytes: &[u8], + pallet_name: &str, + pallet_extrinsic_ty: u32, + metadata: &Metadata, + ) -> Result; +} + +/// The body of a block. +pub struct Extrinsics { + client: C, + extrinsics: Vec, + cached_events: CachedEvents, + ids: ExtrinsicPartTypeIds, + hash: T::Hash, +} + +impl Extrinsics +where + T: Config, + C: OfflineClientT, +{ + pub(crate) fn new( + client: C, + extrinsics: Vec, + cached_events: CachedEvents, + ids: ExtrinsicPartTypeIds, + hash: T::Hash, + ) -> Self { + Self { + client, + extrinsics, + cached_events, + ids, + hash, + } + } + + /// The number of extrinsics. + pub fn len(&self) -> usize { + self.extrinsics.len() + } + + /// Are there no extrinsics in this block? + // Note: mainly here to satisfy clippy. + pub fn is_empty(&self) -> bool { + self.extrinsics.is_empty() + } + + /// Return the block hash that these extrinsics are from. + pub fn block_hash(&self) -> T::Hash { + self.hash + } + + /// Returns an iterator over the extrinsics in the block body. + // Dev note: The returned iterator is 'static + Send so that we can box it up and make + // use of it with our `FilterExtrinsic` stuff. + pub fn iter( + &self, + ) -> impl Iterator, Error>> + Send + Sync + 'static { + let extrinsics = self.extrinsics.clone(); + let num_extrinsics = self.extrinsics.len(); + let client = self.client.clone(); + let hash = self.hash; + let cached_events = self.cached_events.clone(); + let ids = self.ids; + let mut index = 0; + + std::iter::from_fn(move || { + if index == num_extrinsics { + None + } else { + match ExtrinsicDetails::decode_from( + index as u32, + extrinsics[index].0.clone().into(), + client.clone(), + hash, + cached_events.clone(), + ids, + ) { + Ok(extrinsic_details) => { + index += 1; + Some(Ok(extrinsic_details)) + } + Err(e) => { + index = num_extrinsics; + Some(Err(e)) + } + } + } + }) + } + + /// Iterate through the extrinsics using metadata to dynamically decode and skip + /// them, and return only those which should decode to the provided `E` type. + /// If an error occurs, all subsequent iterations return `None`. + pub fn find(&self) -> impl Iterator> + '_ { + self.iter().filter_map(|e| { + e.and_then(|e| e.as_extrinsic::().map_err(Into::into)) + .transpose() + }) + } + + /// Iterate through the extrinsics using metadata to dynamically decode and skip + /// them, and return the first extrinsic found which decodes to the provided `E` type. + pub fn find_first(&self) -> Result, Error> { + self.find::().next().transpose() + } + + /// Iterate through the extrinsics using metadata to dynamically decode and skip + /// them, and return the last extrinsic found which decodes to the provided `Ev` type. + pub fn find_last(&self) -> Result, Error> { + self.find::().last().transpose() + } + + /// Find an extrinsics that decodes to the type provided. Returns true if it was found. + pub fn has(&self) -> Result { + Ok(self.find::().next().transpose()?.is_some()) + } +} + +/// A single extrinsic in a block. +pub struct ExtrinsicDetails { + /// The index of the extrinsic in the block. + index: u32, + /// Extrinsic bytes. + bytes: Arc<[u8]>, + /// True if the extrinsic payload is signed. + is_signed: bool, + /// The start index in the `bytes` from which the address is encoded. + address_start_idx: usize, + /// The end index of the address in the encoded `bytes`. + address_end_idx: usize, + /// The start index in the `bytes` from which the call is encoded. + call_start_idx: usize, + /// The pallet index. + pallet_index: u8, + /// The variant index. + variant_index: u8, + /// The block hash of this extrinsic (needed to fetch events). + block_hash: T::Hash, + /// Subxt client. + client: C, + /// Cached events. + cached_events: CachedEvents, + /// Subxt metadata to fetch the extrinsic metadata. + metadata: Metadata, + _marker: std::marker::PhantomData, +} + +impl ExtrinsicDetails +where + T: Config, + C: OfflineClientT, +{ + // Attempt to dynamically decode a single extrinsic from the given input. + pub(crate) fn decode_from( + index: u32, + extrinsic_bytes: Arc<[u8]>, + client: C, + block_hash: T::Hash, + cached_events: CachedEvents, + ids: ExtrinsicPartTypeIds, + ) -> Result, Error> { + const SIGNATURE_MASK: u8 = 0b1000_0000; + const VERSION_MASK: u8 = 0b0111_1111; + const LATEST_EXTRINSIC_VERSION: u8 = 4; + + let metadata = client.metadata(); + + // Extrinsic are encoded in memory in the following way: + // - first byte: abbbbbbb (a = 0 for unsigned, 1 for signed, b = version) + // - signature: [unknown TBD with metadata]. + // - extrinsic data + let first_byte: u8 = Decode::decode(&mut &extrinsic_bytes[..])?; + + let version = first_byte & VERSION_MASK; + if version != LATEST_EXTRINSIC_VERSION { + return Err(BlockError::UnsupportedVersion(version).into()); + } + + let is_signed = first_byte & SIGNATURE_MASK != 0; + + // Skip over the first byte which denotes the version and signing. + let cursor = &mut &extrinsic_bytes[1..]; + + let mut address_start_idx = 0; + let mut address_end_idx = 0; + + if is_signed { + address_start_idx = extrinsic_bytes.len() - cursor.len(); + + // Skip over the address, signature and extra fields. + scale_decode::visitor::decode_with_visitor( + cursor, + ids.address, + &metadata.runtime_metadata().types, + scale_decode::visitor::IgnoreVisitor, + ) + .map_err(scale_decode::Error::from)?; + address_end_idx = extrinsic_bytes.len() - cursor.len(); + + scale_decode::visitor::decode_with_visitor( + cursor, + ids.signature, + &metadata.runtime_metadata().types, + scale_decode::visitor::IgnoreVisitor, + ) + .map_err(scale_decode::Error::from)?; + + scale_decode::visitor::decode_with_visitor( + cursor, + ids.extra, + &metadata.runtime_metadata().types, + scale_decode::visitor::IgnoreVisitor, + ) + .map_err(scale_decode::Error::from)?; + } + + let call_start_idx = extrinsic_bytes.len() - cursor.len(); + + // Decode the pallet index, then the call variant. + let cursor = &mut &extrinsic_bytes[call_start_idx..]; + + let pallet_index: u8 = Decode::decode(cursor)?; + let variant_index: u8 = Decode::decode(cursor)?; + + Ok(ExtrinsicDetails { + index, + bytes: extrinsic_bytes, + is_signed, + address_start_idx, + address_end_idx, + call_start_idx, + pallet_index, + variant_index, + block_hash, + client, + cached_events, + metadata, + _marker: std::marker::PhantomData, + }) + } + + /// Is the extrinsic signed? + pub fn is_signed(&self) -> bool { + self.is_signed + } + + /// The index of the extrinsic in the block. + pub fn index(&self) -> u32 { + self.index + } + + /// Return _all_ of the bytes representing this extrinsic, which include, in order: + /// - First byte: abbbbbbb (a = 0 for unsigned, 1 for signed, b = version) + /// - SignatureType (if the payload is signed) + /// - Address + /// - Signature + /// - Extra fields + /// - Extrinsic call bytes + pub fn bytes(&self) -> &[u8] { + &self.bytes + } + + /// Return only the bytes representing this extrinsic call: + /// - First byte is the pallet index + /// - Second byte is the variant (call) index + /// - Followed by field bytes. + /// + /// # Note + /// + /// Please use [`Self::bytes`] if you want to get all extrinsic bytes. + pub fn call_bytes(&self) -> &[u8] { + &self.bytes[self.call_start_idx..] + } + + /// Return the bytes representing the fields stored in this extrinsic. + /// + /// # Note + /// + /// This is a subset of [`Self::call_bytes`] that does not include the + /// first two bytes that denote the pallet index and the variant index. + pub fn field_bytes(&self) -> &[u8] { + // Note: this cannot panic because we checked the extrinsic bytes + // to contain at least two bytes. + &self.call_bytes()[2..] + } + + /// Return only the bytes of the address that signed this extrinsic. + /// + /// # Note + /// + /// Returns `None` if the extrinsic is not signed. + pub fn address_bytes(&self) -> Option<&[u8]> { + self.is_signed + .then(|| &self.bytes[self.address_start_idx..self.address_end_idx]) + } + + /// The index of the pallet that the extrinsic originated from. + pub fn pallet_index(&self) -> u8 { + self.pallet_index + } + + /// The index of the extrinsic variant that the extrinsic originated from. + pub fn variant_index(&self) -> u8 { + self.variant_index + } + + /// The name of the pallet from whence the extrinsic originated. + pub fn pallet_name(&self) -> Result<&str, Error> { + Ok(self.extrinsic_metadata()?.pallet()) + } + + /// The name of the call (ie the name of the variant that it corresponds to). + pub fn variant_name(&self) -> Result<&str, Error> { + Ok(self.extrinsic_metadata()?.call()) + } + + /// Fetch the metadata for this extrinsic. + pub fn extrinsic_metadata(&self) -> Result<&ExtrinsicMetadata, Error> { + Ok(self + .metadata + .extrinsic(self.pallet_index(), self.variant_index())?) + } + + /// Decode and provide the extrinsic fields back in the form of a [`scale_value::Composite`] + /// type which represents the named or unnamed fields that were + /// present in the extrinsic. + pub fn field_values( + &self, + ) -> Result, Error> { + let bytes = &mut self.field_bytes(); + let extrinsic_metadata = self.extrinsic_metadata()?; + + let decoded = >::decode_as_fields( + bytes, + extrinsic_metadata.fields(), + &self.metadata.runtime_metadata().types, + )?; + + Ok(decoded) + } + + /// Attempt to statically decode these [`ExtrinsicDetails`] into a type representing the extrinsic + /// fields. This leans directly on [`codec::Decode`]. You can also attempt to decode the entirety + /// of the extrinsic using [`Self::as_root_extrinsic()`], which is more lenient because it's able + /// to lean on [`scale_decode::DecodeAsType`]. + pub fn as_extrinsic(&self) -> Result, Error> { + let extrinsic_metadata = self.extrinsic_metadata()?; + if extrinsic_metadata.pallet() == E::PALLET && extrinsic_metadata.call() == E::CALL { + let decoded = E::decode_as_fields( + &mut self.field_bytes(), + extrinsic_metadata.fields(), + self.metadata.types(), + )?; + Ok(Some(decoded)) + } else { + Ok(None) + } + } + + /// Attempt to decode these [`ExtrinsicDetails`] into a pallet extrinsic type (which includes + /// the pallet enum variants as well as the extrinsic fields). These extrinsics can be found in + /// the static codegen under a path like `pallet_name::Call`. + pub fn as_pallet_extrinsic(&self) -> Result { + let pallet = self.metadata.pallet(self.pallet_name()?)?; + let extrinsic_ty = pallet.call_ty_id().ok_or_else(|| { + Error::Metadata(crate::metadata::MetadataError::ExtrinsicNotFound( + pallet.index(), + self.variant_index(), + )) + })?; + + // Ignore the root enum index, so start 1 byte after that: + let decoded = + E::decode_with_metadata(&mut &self.call_bytes()[1..], extrinsic_ty, &self.metadata)?; + Ok(decoded) + } + + /// Attempt to decode these [`ExtrinsicDetails`] into a root extrinsic type (which includes + /// the pallet and extrinsic enum variants as well as the extrinsic fields). A compatible + /// type for this is exposed via static codegen as a root level `Call` type. + pub fn as_root_extrinsic(&self) -> Result { + let pallet = self.metadata.pallet(self.pallet_name()?)?; + let pallet_extrinsic_ty = pallet.call_ty_id().ok_or_else(|| { + Error::Metadata(crate::metadata::MetadataError::ExtrinsicNotFound( + pallet.index(), + self.variant_index(), + )) + })?; + + // Ignore root enum index. + E::root_extrinsic( + &self.call_bytes()[1..], + self.pallet_name()?, + pallet_extrinsic_ty, + &self.metadata, + ) + } +} + +impl ExtrinsicDetails +where + T: Config, + C: OnlineClientT, +{ + /// The events associated with the extrinsic. + pub async fn events(&self) -> Result, Error> { + let events = get_events(&self.client, self.block_hash, &self.cached_events).await?; + let ext_hash = T::Hasher::hash_of(&self.bytes); + Ok(ExtrinsicEvents::new(ext_hash, self.index, events)) + } +} + +/// The type IDs extracted from the metadata that represent the +/// generic type parameters passed to the `UncheckedExtrinsic` from +/// the substrate-based chain. +#[derive(Debug, Copy, Clone)] +pub(crate) struct ExtrinsicPartTypeIds { + /// The address (source) of the extrinsic. + address: u32, + /// The extrinsic call type. + // Note: the call type can be used to skip over the extrinsic bytes to check + // they are in line with our metadata. This operation is currently postponed. + _call: u32, + /// The signature of the extrinsic. + signature: u32, + /// The extra parameters of the extrinsic. + extra: u32, +} + +impl ExtrinsicPartTypeIds { + /// Extract the generic type parameters IDs from the extrinsic type. + pub(crate) fn new(metadata: &RuntimeMetadataV15) -> Result { + const ADDRESS: &str = "Address"; + const CALL: &str = "Call"; + const SIGNATURE: &str = "Signature"; + const EXTRA: &str = "Extra"; + + let id = metadata.extrinsic.ty.id; + + let Some(ty) = metadata.types.resolve(id) else { + return Err(BlockError::MissingType); + }; + + let params: HashMap<_, _> = ty + .type_params + .iter() + .map(|ty_param| { + let Some(ty) = ty_param.ty else { + return Err(BlockError::MissingType); + }; + + Ok((ty_param.name.as_str(), ty.id)) + }) + .collect::>()?; + + let Some(address) = params.get(ADDRESS) else { + return Err(BlockError::MissingType); + }; + let Some(call) = params.get(CALL) else { + return Err(BlockError::MissingType); + }; + let Some(signature) = params.get(SIGNATURE) else { + return Err(BlockError::MissingType); + }; + let Some(extra) = params.get(EXTRA) else { + return Err(BlockError::MissingType); + }; + + Ok(ExtrinsicPartTypeIds { + address: *address, + _call: *call, + signature: *signature, + extra: *extra, + }) + } +} + +/// The events associated with a given extrinsic. +#[derive(Derivative)] +#[derivative(Debug(bound = ""))] +pub struct ExtrinsicEvents { + // The hash of the extrinsic (handy to expose here because + // this type is returned from TxProgress things in the most + // basic flows, so it's the only place people can access it + // without complicating things for themselves). + ext_hash: T::Hash, + // The index of the extrinsic: + idx: u32, + // All of the events in the block: + events: events::Events, +} + +impl ExtrinsicEvents { + pub(crate) fn new(ext_hash: T::Hash, idx: u32, events: events::Events) -> Self { + Self { + ext_hash, + idx, + events, + } + } + + /// Return the hash of the block that the extrinsic is in. + pub fn block_hash(&self) -> T::Hash { + self.events.block_hash() + } + + /// The index of the extrinsic that these events are produced from. + pub fn extrinsic_index(&self) -> u32 { + self.idx + } + + /// Return the hash of the extrinsic. + pub fn extrinsic_hash(&self) -> T::Hash { + self.ext_hash + } + + /// Return all of the events in the block that the extrinsic is in. + pub fn all_events_in_block(&self) -> &events::Events { + &self.events + } + + /// Iterate over all of the raw events associated with this transaction. + /// + /// This works in the same way that [`events::Events::iter()`] does, with the + /// exception that it filters out events not related to the submitted extrinsic. + pub fn iter(&self) -> impl Iterator> + '_ { + self.events.iter().filter(|ev| { + ev.as_ref() + .map(|ev| ev.phase() == events::Phase::ApplyExtrinsic(self.idx)) + .unwrap_or(true) // Keep any errors. + }) + } + + /// Find all of the transaction events matching the event type provided as a generic parameter. + /// + /// This works in the same way that [`events::Events::find()`] does, with the + /// exception that it filters out events not related to the submitted extrinsic. + pub fn find(&self) -> impl Iterator> + '_ { + self.iter().filter_map(|ev| { + ev.and_then(|ev| ev.as_event::().map_err(Into::into)) + .transpose() + }) + } + + /// Iterate through the transaction events using metadata to dynamically decode and skip + /// them, and return the first event found which decodes to the provided `Ev` type. + /// + /// This works in the same way that [`events::Events::find_first()`] does, with the + /// exception that it ignores events not related to the submitted extrinsic. + pub fn find_first(&self) -> Result, Error> { + self.find::().next().transpose() + } + + /// Iterate through the transaction events using metadata to dynamically decode and skip + /// them, and return the last event found which decodes to the provided `Ev` type. + /// + /// This works in the same way that [`events::Events::find_last()`] does, with the + /// exception that it ignores events not related to the submitted extrinsic. + pub fn find_last(&self) -> Result, Error> { + self.find::().last().transpose() + } + + /// Find an event in those associated with this transaction. Returns true if it was found. + /// + /// This works in the same way that [`events::Events::has()`] does, with the + /// exception that it ignores events not related to the submitted extrinsic. + pub fn has(&self) -> Result { + Ok(self.find::().next().transpose()?.is_some()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{rpc::types::RuntimeVersion, OfflineClient, PolkadotConfig}; + use assert_matches::assert_matches; + use codec::{Decode, Encode}; + use frame_metadata::{ + v15::{ExtrinsicMetadata, PalletCallMetadata, PalletMetadata, RuntimeMetadataV15}, + RuntimeMetadataPrefixed, + }; + use primitive_types::H256; + use scale_info::{meta_type, TypeInfo}; + use scale_value::Value; + + // Extrinsic needs to contain at least the generic type parameter "Call" + // for the metadata to be valid. + // The "Call" type from the metadata is used to decode extrinsics. + #[allow(unused)] + #[derive(TypeInfo)] + struct ExtrinsicType { + pub signature: Option<(Address, Signature, Extra)>, + pub function: Call, + } + + // Because this type is used to decode extrinsics, we expect this to be a TypeDefVariant. + // Each pallet must contain one single variant. + #[allow(unused)] + #[derive( + Encode, + Decode, + TypeInfo, + Clone, + Debug, + PartialEq, + Eq, + scale_encode::EncodeAsType, + scale_decode::DecodeAsType, + )] + enum RuntimeCall { + Test(Pallet), + } + + // We need this in order to be able to decode into a root extrinsic type: + impl RootExtrinsic for RuntimeCall { + fn root_extrinsic( + mut pallet_bytes: &[u8], + pallet_name: &str, + pallet_extrinsic_ty: u32, + metadata: &Metadata, + ) -> Result { + if pallet_name == "Test" { + return Ok(RuntimeCall::Test(Pallet::decode_with_metadata( + &mut pallet_bytes, + pallet_extrinsic_ty, + metadata, + )?)); + } + panic!( + "Asked for pallet name '{pallet_name}', which isn't in our test RuntimeCall type" + ) + } + } + + // The calls of the pallet. + #[allow(unused)] + #[derive( + Encode, + Decode, + TypeInfo, + Clone, + Debug, + PartialEq, + Eq, + scale_encode::EncodeAsType, + scale_decode::DecodeAsType, + )] + enum Pallet { + #[allow(unused)] + #[codec(index = 2)] + TestCall { + value: u128, + signed: bool, + name: String, + }, + } + + #[allow(unused)] + #[derive( + Encode, + Decode, + TypeInfo, + Clone, + Debug, + PartialEq, + Eq, + scale_encode::EncodeAsType, + scale_decode::DecodeAsType, + )] + struct TestCallExtrinsic { + value: u128, + signed: bool, + name: String, + } + impl StaticExtrinsic for TestCallExtrinsic { + const PALLET: &'static str = "Test"; + const CALL: &'static str = "TestCall"; + } + + /// Build fake metadata consisting the types needed to represent an extrinsic. + fn metadata() -> Metadata { + let pallets = vec![PalletMetadata { + name: "Test", + storage: None, + calls: Some(PalletCallMetadata { + ty: meta_type::(), + }), + event: None, + constants: vec![], + error: None, + index: 0, + docs: vec![], + }]; + + let extrinsic = ExtrinsicMetadata { + ty: meta_type::>(), + version: 4, + signed_extensions: vec![], + }; + + let meta = RuntimeMetadataV15::new(pallets, extrinsic, meta_type::<()>(), vec![]); + let runtime_metadata: RuntimeMetadataPrefixed = meta.into(); + + Metadata::try_from(runtime_metadata).unwrap() + } + + /// Build an offline client to work with the test metadata. + fn client(metadata: Metadata) -> OfflineClient { + // Create the encoded extrinsic bytes. + let rt_version = RuntimeVersion { + spec_version: 1, + transaction_version: 4, + other: Default::default(), + }; + let block_hash = H256::random(); + OfflineClient::new(block_hash, rt_version, metadata) + } + + #[test] + fn extrinsic_metadata_consistency() { + let metadata = metadata(); + + // Except our metadata to contain the registered types. + let extrinsic = metadata + .extrinsic(0, 2) + .expect("metadata contains the RuntimeCall enum with this pallet"); + assert_eq!(extrinsic.pallet(), "Test"); + assert_eq!(extrinsic.call(), "TestCall"); + } + + #[test] + fn insufficient_extrinsic_bytes() { + let metadata = metadata(); + let client = client(metadata.clone()); + let ids = ExtrinsicPartTypeIds::new(metadata.runtime_metadata()).unwrap(); + + // Decode with empty bytes. + let result = ExtrinsicDetails::decode_from( + 1, + vec![].into(), + client, + H256::random(), + Default::default(), + ids, + ); + assert_matches!(result.err(), Some(crate::Error::Codec(_))); + } + + #[test] + fn unsupported_version_extrinsic() { + let metadata = metadata(); + let client = client(metadata.clone()); + let ids = ExtrinsicPartTypeIds::new(metadata.runtime_metadata()).unwrap(); + + // Decode with invalid version. + let result = ExtrinsicDetails::decode_from( + 1, + 3u8.encode().into(), + client, + H256::random(), + Default::default(), + ids, + ); + + assert_matches!( + result.err(), + Some(crate::Error::Block( + crate::error::BlockError::UnsupportedVersion(3) + )) + ); + } + + #[test] + fn statically_decode_extrinsic() { + let metadata = metadata(); + let client = client(metadata.clone()); + let ids = ExtrinsicPartTypeIds::new(metadata.runtime_metadata()).unwrap(); + + let tx = crate::tx::dynamic( + "Test", + "TestCall", + vec![ + Value::u128(10), + Value::bool(true), + Value::string("SomeValue"), + ], + ); + let tx_encoded = client + .tx() + .create_unsigned(&tx) + .expect("Valid dynamic parameters are provided"); + + // Note: `create_unsigned` produces the extrinsic bytes by prefixing the extrinsic length. + // The length is handled deserializing `ChainBlockExtrinsic`, therefore the first byte is not needed. + let extrinsic = ExtrinsicDetails::decode_from( + 1, + tx_encoded.encoded()[1..].into(), + client, + H256::random(), + Default::default(), + ids, + ) + .expect("Valid extrinsic"); + + assert!(!extrinsic.is_signed()); + + assert_eq!(extrinsic.index(), 1); + + assert_eq!(extrinsic.pallet_index(), 0); + assert_eq!( + extrinsic + .pallet_name() + .expect("Valid metadata contains pallet name"), + "Test" + ); + + assert_eq!(extrinsic.variant_index(), 2); + assert_eq!( + extrinsic + .variant_name() + .expect("Valid metadata contains variant name"), + "TestCall" + ); + + // Decode the extrinsic to the root enum. + let decoded_extrinsic = extrinsic + .as_root_extrinsic::() + .expect("can decode extrinsic to root enum"); + + assert_eq!( + decoded_extrinsic, + RuntimeCall::Test(Pallet::TestCall { + value: 10, + signed: true, + name: "SomeValue".into(), + }) + ); + + // Decode the extrinsic to the pallet enum. + let decoded_extrinsic = extrinsic + .as_pallet_extrinsic::() + .expect("can decode extrinsic to pallet enum"); + + assert_eq!( + decoded_extrinsic, + Pallet::TestCall { + value: 10, + signed: true, + name: "SomeValue".into(), + } + ); + + // Decode the extrinsic to the extrinsic variant. + let decoded_extrinsic = extrinsic + .as_extrinsic::() + .expect("can decode extrinsic to extrinsic variant") + .expect("value cannot be None"); + + assert_eq!( + decoded_extrinsic, + TestCallExtrinsic { + value: 10, + signed: true, + name: "SomeValue".into(), + } + ); + } +} diff --git a/subxt/src/blocks/mod.rs b/subxt/src/blocks/mod.rs index 9d6e62d8b3..3cb404a496 100644 --- a/subxt/src/blocks/mod.rs +++ b/subxt/src/blocks/mod.rs @@ -6,6 +6,10 @@ mod block_types; mod blocks_client; +mod extrinsic_types; -pub use block_types::{Block, BlockBody, Extrinsic, ExtrinsicEvents}; +pub use block_types::{Block, BlockBody}; pub use blocks_client::{subscribe_to_block_headers_filling_in_gaps, BlocksClient}; +pub use extrinsic_types::{ + ExtrinsicDetails, ExtrinsicEvents, Extrinsics, RootExtrinsic, StaticExtrinsic, +}; diff --git a/subxt/src/book/usage/extrinsics.rs b/subxt/src/book/usage/extrinsics.rs index 3d409f5772..314ee252dc 100644 --- a/subxt/src/book/usage/extrinsics.rs +++ b/subxt/src/book/usage/extrinsics.rs @@ -19,6 +19,8 @@ //! > can construct unsigned extrinsics, but overwhelmingly you'll need to sign them, and so the //! > documentation tends to use the terms _extrinsic_ and _transaction_ interchangeably. //! +//! Furthermore, Subxt is capable of decoding extrinsics included in blocks. +//! //! ## Constructing an extrinsic payload //! //! We can use the statically generated interface to build extrinsic payloads: @@ -173,3 +175,50 @@ //! Take a look at the API docs for [`crate::tx::TxProgress`], [`crate::tx::TxStatus`] and //! [`crate::tx::TxInBlock`] for more options. //! +//! ## Decoding Extrinsics +//! +//! The block body is made up of extrinsics representing the generalization of the concept of transactions. +//! Extrinsics can contain any external data the underlying chain wishes to validate and track. +//! +//! The process of decoding extrinsics generally involves the following steps: +//! +//! 1. Retrieve a block from the chain: This can be done directly by providing a specific hash using [crate::blocks::BlocksClient::at()] +//! and [crate::blocks::BlocksClient::at_latest()], or indirectly by subscribing to the latest produced blocks of the chain using +//! [crate::blocks::BlocksClient::subscribe_finalized()]. +//! +//! 2. Fetch the block's body using [crate::blocks::Block::body()]. +//! +//! 3. Obtain the extrinsics from the block's body using [crate::blocks::BlockBody::extrinsics()]. +//! +//! ```rust,no_run +//! # #[tokio::main] +//! # async fn main() -> Result<(), Box> { +//! use subxt::client::OnlineClient; +//! use subxt::config::PolkadotConfig; +//! +//! // Create client: +//! let client = OnlineClient::::new().await?; +//! +//! // Get the lastest block (or use .at() to specify a block hash): +//! let block = client.blocks().at_latest().await?; +//! +//! // Get the block's body which contains the extrinsics. +//! let body = block.body().await?; +//! +//! // Fetch the extrinsics of the block's body. +//! let extrinsics = block.body().await?.extrinsics(); +//! # Ok(()) +//! # } +//! ``` +//! +//! Once the extrinsics are loaded, similar to events, you can iterate through the extrinsics or search for specific extrinsics using methods +//! such as [crate::blocks::Extrinsics::iter()] and [crate::blocks::Extrinsics::find()]. For more information, refer to [crate::blocks::ExtrinsicDetails]. +//! +//! ### Example +//! +//! Here's an example that demonstrates the usage of these concepts: +//! +//! ```rust,ignore +#![doc = include_str!("../../../../examples/examples/block_extrinsics.rs")] +//! ``` +//! diff --git a/subxt/src/config/mod.rs b/subxt/src/config/mod.rs index 702a90eb07..b776689c3c 100644 --- a/subxt/src/config/mod.rs +++ b/subxt/src/config/mod.rs @@ -54,7 +54,7 @@ pub trait Config: 'static { type Hasher: Debug + Hasher; /// The block header. - type Header: Debug + Header + Send + DeserializeOwned; + type Header: Debug + Header + Sync + Send + DeserializeOwned; /// This type defines the extrinsic extra and additional parameters. type ExtrinsicParams: extrinsic_params::ExtrinsicParams; diff --git a/subxt/src/error/mod.rs b/subxt/src/error/mod.rs index 9884e4e1d3..96fb6dfad2 100644 --- a/subxt/src/error/mod.rs +++ b/subxt/src/error/mod.rs @@ -102,6 +102,16 @@ pub enum BlockError { /// An error containing the hash of the block that was not found. #[error("Could not find a block with hash {0} (perhaps it was on a non-finalized fork?)")] NotFound(String), + /// Extrinsic type ID cannot be resolved with the provided metadata. + #[error("Extrinsic type ID cannot be resolved with the provided metadata. Make sure this is a valid metadata")] + MissingType, + /// Unsupported signature. + #[error("Unsupported extrinsic version, only version 4 is supported currently")] + /// The extrinsic has an unsupported version. + UnsupportedVersion(u8), + /// Decoding error. + #[error("Cannot decode extrinsic: {0}")] + DecodingError(codec::Error), } impl BlockError { diff --git a/subxt/src/events/events_type.rs b/subxt/src/events/events_type.rs index 1de8b31917..cf43cea162 100644 --- a/subxt/src/events/events_type.rs +++ b/subxt/src/events/events_type.rs @@ -493,6 +493,30 @@ pub(crate) mod test_utils { /// Build fake metadata consisting of a single pallet that knows /// about the event type provided. pub fn metadata() -> Metadata { + // Extrinsic needs to contain at least the generic type parameter "Call" + // for the metadata to be valid. + // The "Call" type from the metadata is used to decode extrinsics. + // In reality, the extrinsic type has "Call", "Address", "Extra", "Signature" generic types. + #[allow(unused)] + #[derive(TypeInfo)] + struct ExtrinsicType { + call: Call, + } + // Because this type is used to decode extrinsics, we expect this to be a TypeDefVariant. + // Each pallet must contain one single variant. + #[allow(unused)] + #[derive(TypeInfo)] + enum RuntimeCall { + PalletName(Pallet), + } + // The calls of the pallet. + #[allow(unused)] + #[derive(TypeInfo)] + enum Pallet { + #[allow(unused)] + SomeCall, + } + let pallets = vec![PalletMetadata { name: "Test", storage: None, @@ -507,7 +531,7 @@ pub(crate) mod test_utils { }]; let extrinsic = ExtrinsicMetadata { - ty: meta_type::<()>(), + ty: meta_type::>(), version: 0, signed_extensions: vec![], }; diff --git a/subxt/src/metadata/metadata_type.rs b/subxt/src/metadata/metadata_type.rs index cc400310b0..c24065c1b6 100644 --- a/subxt/src/metadata/metadata_type.rs +++ b/subxt/src/metadata/metadata_type.rs @@ -27,6 +27,9 @@ pub enum MetadataError { /// Event is not in metadata. #[error("Pallet {0}, Event {0} not found")] EventNotFound(u8, u8), + /// Extrinsic is not in metadata. + #[error("Pallet {0}, Extrinsic {0} not found")] + ExtrinsicNotFound(u8, u8), /// Event is not in metadata. #[error("Pallet {0}, Error {0} not found")] ErrorNotFound(u8, u8), @@ -75,6 +78,8 @@ struct MetadataInner { // Events are hashed by pallet an error index (decode oriented) events: HashMap<(u8, u8), EventMetadata>, + // Extrinsics are hashed by pallet an error index (decode oriented) + extrinsics: HashMap<(u8, u8), ExtrinsicMetadata>, // Errors are hashed by pallet and error index (decode oriented) errors: HashMap<(u8, u8), ErrorMetadata>, @@ -135,6 +140,20 @@ impl Metadata { Ok(event) } + /// Returns the metadata for the extrinsic at the given pallet and call indices. + pub fn extrinsic( + &self, + pallet_index: u8, + call_index: u8, + ) -> Result<&ExtrinsicMetadata, MetadataError> { + let event = self + .inner + .extrinsics + .get(&(pallet_index, call_index)) + .ok_or(MetadataError::ExtrinsicNotFound(pallet_index, call_index))?; + Ok(event) + } + /// Returns the metadata for the error at the given pallet and error indices. pub fn error( &self, @@ -386,6 +405,39 @@ impl EventMetadata { } } +/// Metadata for specific extrinsics. +#[derive(Clone, Debug)] +pub struct ExtrinsicMetadata { + // The pallet name is shared across every extrinsic, so put it + // behind an Arc to avoid lots of needless clones of it existing. + pallet: Arc, + call: String, + fields: Vec>, + docs: Vec, +} + +impl ExtrinsicMetadata { + /// Get the name of the pallet from which the extrinsic was emitted. + pub fn pallet(&self) -> &str { + &self.pallet + } + + /// Get the name of the extrinsic call. + pub fn call(&self) -> &str { + &self.call + } + + /// The names, type names & types of each field in the extrinsic. + pub fn fields(&self) -> &[scale_info::Field] { + &self.fields + } + + /// Documentation for this extrinsic. + pub fn docs(&self) -> &[String] { + &self.docs + } +} + /// Details about a specific runtime error. #[derive(Clone, Debug)] pub struct ErrorMetadata { @@ -426,6 +478,12 @@ pub enum InvalidMetadataError { /// Type missing from type registry #[error("Type {0} missing from type registry")] MissingType(u32), + /// Type missing extrinsic "Call" type + #[error("Missing extrinsic Call type")] + MissingCallType, + /// The extrinsic variant expected to contain a single field. + #[error("Extrinsic variant at index {0} expected to contain a single field")] + InvalidExtrinsicVariant(u8), /// Type was not a variant/enum type #[error("Type {0} was not a variant/enum type")] TypeDefNotVariant(u32), @@ -596,11 +654,60 @@ impl TryFrom for Metadata { .find(|ty| ty.ty.path.segments == ["sp_runtime", "DispatchError"]) .map(|ty| ty.id); + let extrinsic_ty = metadata + .types + .resolve(metadata.extrinsic.ty.id) + .ok_or(InvalidMetadataError::MissingType(metadata.extrinsic.ty.id))?; + + let Some(call_id) = extrinsic_ty.type_params + .iter() + .find(|ty| ty.name == "Call") + .and_then(|ty| ty.ty) + .map(|ty| ty.id) else { + return Err(InvalidMetadataError::MissingCallType); + }; + + let call_type_variants = get_type_def_variant(call_id)?; + + let mut extrinsics = HashMap::<(u8, u8), ExtrinsicMetadata>::new(); + for variant in &call_type_variants.variants { + let pallet_name: Arc = variant.name.to_string().into(); + let pallet_index = variant.index; + + // Pallet variants must contain one single call variant. + // In the following form: + // + // enum RuntimeCall { + // Pallet(pallet_call) + // } + if variant.fields.len() != 1 { + return Err(InvalidMetadataError::InvalidExtrinsicVariant(pallet_index)); + } + let Some(ty) = variant.fields.first() else { + return Err(InvalidMetadataError::InvalidExtrinsicVariant(pallet_index)); + }; + + // Get the call variant. + let call_type_variant = get_type_def_variant(ty.ty.id)?; + for variant in &call_type_variant.variants { + extrinsics.insert( + (pallet_index, variant.index), + ExtrinsicMetadata { + pallet: pallet_name.clone(), + call: variant.name.to_string(), + fields: variant.fields.clone(), + docs: variant.docs.clone(), + }, + ); + } + } + Ok(Metadata { inner: Arc::new(MetadataInner { metadata, pallets, events, + extrinsics, errors, dispatch_error_ty, runtime_apis, @@ -624,6 +731,30 @@ mod tests { use scale_info::{meta_type, TypeInfo}; fn load_metadata() -> Metadata { + // Extrinsic needs to contain at least the generic type parameter "Call" + // for the metadata to be valid. + // The "Call" type from the metadata is used to decode extrinsics. + // In reality, the extrinsic type has "Call", "Address", "Extra", "Signature" generic types. + #[allow(unused)] + #[derive(TypeInfo)] + struct ExtrinsicType { + call: Call, + } + // Because this type is used to decode extrinsics, we expect this to be a TypeDefVariant. + // Each pallet must contain one single variant. + #[allow(unused)] + #[derive(TypeInfo)] + enum RuntimeCall { + PalletName(Pallet), + } + // The calls of the pallet. + #[allow(unused)] + #[derive(TypeInfo)] + enum Pallet { + #[allow(unused)] + SomeCall, + } + #[allow(dead_code)] #[allow(non_camel_case_types)] #[derive(TypeInfo)] @@ -662,7 +793,7 @@ mod tests { let metadata = RuntimeMetadataV15::new( vec![pallet], ExtrinsicMetadata { - ty: meta_type::<()>(), + ty: meta_type::>(), version: 0, signed_extensions: vec![], }, diff --git a/subxt/src/metadata/mod.rs b/subxt/src/metadata/mod.rs index 7ada3e62b7..d46793ee40 100644 --- a/subxt/src/metadata/mod.rs +++ b/subxt/src/metadata/mod.rs @@ -12,8 +12,8 @@ mod metadata_type; pub use metadata_location::MetadataLocation; pub use metadata_type::{ - ErrorMetadata, EventMetadata, InvalidMetadataError, Metadata, MetadataError, PalletMetadata, - RuntimeFnMetadata, + ErrorMetadata, EventMetadata, ExtrinsicMetadata, InvalidMetadataError, Metadata, MetadataError, + PalletMetadata, RuntimeFnMetadata, }; pub use decode_encode_traits::{DecodeWithMetadata, EncodeWithMetadata}; diff --git a/testing/integration-tests/src/blocks/mod.rs b/testing/integration-tests/src/blocks/mod.rs index ab14d2202a..bf9e707997 100644 --- a/testing/integration-tests/src/blocks/mod.rs +++ b/testing/integration-tests/src/blocks/mod.rs @@ -2,10 +2,12 @@ // This file is dual-licensed as Apache-2.0 or GPL-3.0. // see LICENSE for license details. -use crate::test_context; +use crate::{pair_signer, test_context, utils::node_runtime}; use codec::Compact; use frame_metadata::RuntimeMetadataPrefixed; use futures::StreamExt; +use sp_keyring::AccountKeyring; +use subxt::blocks::BlocksClient; // Check that we can subscribe to non-finalized blocks. #[tokio::test] @@ -118,3 +120,71 @@ async fn runtime_api_call() -> Result<(), subxt::Error> { assert_eq!(&metadata_call, metadata); Ok(()) } + +#[tokio::test] +async fn decode_extrinsics() { + let ctx = test_context().await; + let api = ctx.client(); + + let alice = pair_signer(AccountKeyring::Alice.pair()); + let bob = pair_signer(AccountKeyring::Bob.pair()); + + // Generate a block that has unsigned and signed transactions. + let tx = node_runtime::tx() + .balances() + .transfer(bob.account_id().clone().into(), 10_000); + + let signed_extrinsic = api + .tx() + .create_signed(&tx, &alice, Default::default()) + .await + .unwrap(); + + let in_block = signed_extrinsic + .submit_and_watch() + .await + .unwrap() + .wait_for_in_block() + .await + .unwrap(); + + let block_hash = in_block.block_hash(); + + let block = BlocksClient::new(api).at(block_hash).await.unwrap(); + let extrinsics = block.body().await.unwrap().extrinsics(); + assert_eq!(extrinsics.len(), 2); + assert_eq!(extrinsics.block_hash(), block_hash); + + assert!(extrinsics + .has::() + .unwrap()); + + assert!(extrinsics + .find_first::() + .unwrap() + .is_some()); + + let block_extrinsics = extrinsics + .iter() + .map(|res| res.unwrap()) + .collect::>(); + + assert_eq!(block_extrinsics.len(), 2); + let timestamp = block_extrinsics.get(0).unwrap(); + timestamp.as_root_extrinsic::().unwrap(); + timestamp + .as_pallet_extrinsic::() + .unwrap(); + timestamp + .as_extrinsic::() + .unwrap(); + assert!(!timestamp.is_signed()); + + let tx = block_extrinsics.get(1).unwrap(); + tx.as_root_extrinsic::().unwrap(); + tx.as_pallet_extrinsic::() + .unwrap(); + tx.as_extrinsic::() + .unwrap(); + assert!(tx.is_signed()); +} diff --git a/testing/integration-tests/src/codegen/polkadot.rs b/testing/integration-tests/src/codegen/polkadot.rs index 81b49af334..2a4335ec3b 100644 --- a/testing/integration-tests/src/codegen/polkadot.rs +++ b/testing/integration-tests/src/codegen/polkadot.rs @@ -511,6 +511,487 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum Call { + #[codec(index = 0)] + System(system::Call), + #[codec(index = 1)] + Scheduler(scheduler::Call), + #[codec(index = 10)] + Preimage(preimage::Call), + #[codec(index = 2)] + Babe(babe::Call), + #[codec(index = 3)] + Timestamp(timestamp::Call), + #[codec(index = 4)] + Indices(indices::Call), + #[codec(index = 5)] + Balances(balances::Call), + #[codec(index = 7)] + Staking(staking::Call), + #[codec(index = 9)] + Session(session::Call), + #[codec(index = 11)] + Grandpa(grandpa::Call), + #[codec(index = 12)] + ImOnline(im_online::Call), + #[codec(index = 14)] + Democracy(democracy::Call), + #[codec(index = 15)] + Council(council::Call), + #[codec(index = 16)] + TechnicalCommittee(technical_committee::Call), + #[codec(index = 17)] + PhragmenElection(phragmen_election::Call), + #[codec(index = 18)] + TechnicalMembership(technical_membership::Call), + #[codec(index = 19)] + Treasury(treasury::Call), + #[codec(index = 20)] + ConvictionVoting(conviction_voting::Call), + #[codec(index = 21)] + Referenda(referenda::Call), + #[codec(index = 23)] + Whitelist(whitelist::Call), + #[codec(index = 24)] + Claims(claims::Call), + #[codec(index = 25)] + Vesting(vesting::Call), + #[codec(index = 26)] + Utility(utility::Call), + #[codec(index = 28)] + Identity(identity::Call), + #[codec(index = 29)] + Proxy(proxy::Call), + #[codec(index = 30)] + Multisig(multisig::Call), + #[codec(index = 34)] + Bounties(bounties::Call), + #[codec(index = 38)] + ChildBounties(child_bounties::Call), + #[codec(index = 35)] + Tips(tips::Call), + #[codec(index = 36)] + ElectionProviderMultiPhase(election_provider_multi_phase::Call), + #[codec(index = 37)] + VoterList(voter_list::Call), + #[codec(index = 39)] + NominationPools(nomination_pools::Call), + #[codec(index = 40)] + FastUnstake(fast_unstake::Call), + #[codec(index = 51)] + Configuration(configuration::Call), + #[codec(index = 52)] + ParasShared(paras_shared::Call), + #[codec(index = 53)] + ParaInclusion(para_inclusion::Call), + #[codec(index = 54)] + ParaInherent(para_inherent::Call), + #[codec(index = 56)] + Paras(paras::Call), + #[codec(index = 57)] + Initializer(initializer::Call), + #[codec(index = 58)] + Dmp(dmp::Call), + #[codec(index = 59)] + Ump(ump::Call), + #[codec(index = 60)] + Hrmp(hrmp::Call), + #[codec(index = 62)] + ParasDisputes(paras_disputes::Call), + #[codec(index = 70)] + Registrar(registrar::Call), + #[codec(index = 71)] + Slots(slots::Call), + #[codec(index = 72)] + Auctions(auctions::Call), + #[codec(index = 73)] + Crowdloan(crowdloan::Call), + #[codec(index = 99)] + XcmPallet(xcm_pallet::Call), + } + impl ::subxt::blocks::RootExtrinsic for Call { + fn root_extrinsic( + pallet_bytes: &[u8], + pallet_name: &str, + pallet_ty: u32, + metadata: &::subxt::Metadata, + ) -> Result { + use subxt::metadata::DecodeWithMetadata; + if pallet_name == "System" { + return Ok(Call::System(system::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Scheduler" { + return Ok(Call::Scheduler(scheduler::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Preimage" { + return Ok(Call::Preimage(preimage::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Babe" { + return Ok(Call::Babe(babe::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Timestamp" { + return Ok(Call::Timestamp(timestamp::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Indices" { + return Ok(Call::Indices(indices::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Balances" { + return Ok(Call::Balances(balances::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Staking" { + return Ok(Call::Staking(staking::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Session" { + return Ok(Call::Session(session::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Grandpa" { + return Ok(Call::Grandpa(grandpa::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "ImOnline" { + return Ok(Call::ImOnline(im_online::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Democracy" { + return Ok(Call::Democracy(democracy::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Council" { + return Ok(Call::Council(council::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "TechnicalCommittee" { + return Ok(Call::TechnicalCommittee( + technical_committee::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "PhragmenElection" { + return Ok(Call::PhragmenElection( + phragmen_election::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "TechnicalMembership" { + return Ok(Call::TechnicalMembership( + technical_membership::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "Treasury" { + return Ok(Call::Treasury(treasury::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "ConvictionVoting" { + return Ok(Call::ConvictionVoting( + conviction_voting::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "Referenda" { + return Ok(Call::Referenda(referenda::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Whitelist" { + return Ok(Call::Whitelist(whitelist::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Claims" { + return Ok(Call::Claims(claims::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Vesting" { + return Ok(Call::Vesting(vesting::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Utility" { + return Ok(Call::Utility(utility::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Identity" { + return Ok(Call::Identity(identity::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Proxy" { + return Ok(Call::Proxy(proxy::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Multisig" { + return Ok(Call::Multisig(multisig::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Bounties" { + return Ok(Call::Bounties(bounties::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "ChildBounties" { + return Ok(Call::ChildBounties( + child_bounties::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "Tips" { + return Ok(Call::Tips(tips::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "ElectionProviderMultiPhase" { + return Ok(Call::ElectionProviderMultiPhase( + election_provider_multi_phase::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "VoterList" { + return Ok(Call::VoterList(voter_list::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "NominationPools" { + return Ok(Call::NominationPools( + nomination_pools::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "FastUnstake" { + return Ok(Call::FastUnstake(fast_unstake::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Configuration" { + return Ok(Call::Configuration( + configuration::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "ParasShared" { + return Ok(Call::ParasShared(paras_shared::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "ParaInclusion" { + return Ok(Call::ParaInclusion( + para_inclusion::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "ParaInherent" { + return Ok(Call::ParaInherent( + para_inherent::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "Paras" { + return Ok(Call::Paras(paras::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Initializer" { + return Ok(Call::Initializer(initializer::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Dmp" { + return Ok(Call::Dmp(dmp::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Ump" { + return Ok(Call::Ump(ump::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Hrmp" { + return Ok(Call::Hrmp(hrmp::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "ParasDisputes" { + return Ok(Call::ParasDisputes( + paras_disputes::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?, + )); + } + if pallet_name == "Registrar" { + return Ok(Call::Registrar(registrar::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Slots" { + return Ok(Call::Slots(slots::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Auctions" { + return Ok(Call::Auctions(auctions::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "Crowdloan" { + return Ok(Call::Crowdloan(crowdloan::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + if pallet_name == "XcmPallet" { + return Ok(Call::XcmPallet(xcm_pallet::Call::decode_with_metadata( + &mut &*pallet_bytes, + pallet_ty, + metadata, + )?)); + } + Err(::subxt::ext::scale_decode::Error::custom(format!( + "Pallet name '{}' not found in root Call enum", + pallet_name + )) + .into()) + } + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub enum Error { #[codec(index = 0)] System(system::Error), @@ -773,73 +1254,2675 @@ pub mod api { para_inherent::Error::decode_with_metadata(cursor, 727u32, metadata)?; return Ok(Error::ParaInherent(variant_error)); } - if pallet_name == "Paras" { - let variant_error = paras::Error::decode_with_metadata(cursor, 754u32, metadata)?; - return Ok(Error::Paras(variant_error)); + if pallet_name == "Paras" { + let variant_error = paras::Error::decode_with_metadata(cursor, 754u32, metadata)?; + return Ok(Error::Paras(variant_error)); + } + if pallet_name == "Ump" { + let variant_error = ump::Error::decode_with_metadata(cursor, 760u32, metadata)?; + return Ok(Error::Ump(variant_error)); + } + if pallet_name == "Hrmp" { + let variant_error = hrmp::Error::decode_with_metadata(cursor, 768u32, metadata)?; + return Ok(Error::Hrmp(variant_error)); + } + if pallet_name == "ParasDisputes" { + let variant_error = + paras_disputes::Error::decode_with_metadata(cursor, 777u32, metadata)?; + return Ok(Error::ParasDisputes(variant_error)); + } + if pallet_name == "Registrar" { + let variant_error = + registrar::Error::decode_with_metadata(cursor, 779u32, metadata)?; + return Ok(Error::Registrar(variant_error)); + } + if pallet_name == "Slots" { + let variant_error = slots::Error::decode_with_metadata(cursor, 781u32, metadata)?; + return Ok(Error::Slots(variant_error)); + } + if pallet_name == "Auctions" { + let variant_error = + auctions::Error::decode_with_metadata(cursor, 786u32, metadata)?; + return Ok(Error::Auctions(variant_error)); + } + if pallet_name == "Crowdloan" { + let variant_error = + crowdloan::Error::decode_with_metadata(cursor, 789u32, metadata)?; + return Ok(Error::Crowdloan(variant_error)); + } + if pallet_name == "XcmPallet" { + let variant_error = + xcm_pallet::Error::decode_with_metadata(cursor, 808u32, metadata)?; + return Ok(Error::XcmPallet(variant_error)); + } + Err(::subxt::ext::scale_decode::Error::custom(format!( + "Pallet name '{}' not found in root Error enum", + pallet_name + )) + .into()) + } + } + pub fn constants() -> ConstantsApi { + ConstantsApi + } + pub fn storage() -> StorageApi { + StorageApi + } + pub fn tx() -> TransactionApi { + TransactionApi + } + pub fn apis() -> runtime_apis::RuntimeApi { + runtime_apis::RuntimeApi + } + pub mod runtime_apis { + use super::root_mod; + use super::runtime_types; + use subxt::ext::codec::Encode; + pub struct RuntimeApi; + impl RuntimeApi { + pub fn core(&self) -> core::Core { + core::Core + } + pub fn metadata(&self) -> metadata::Metadata { + metadata::Metadata + } + pub fn block_builder(&self) -> block_builder::BlockBuilder { + block_builder::BlockBuilder + } + pub fn nomination_pools_api(&self) -> nomination_pools_api::NominationPoolsApi { + nomination_pools_api::NominationPoolsApi + } + pub fn staking_api(&self) -> staking_api::StakingApi { + staking_api::StakingApi + } + pub fn tagged_transaction_queue( + &self, + ) -> tagged_transaction_queue::TaggedTransactionQueue { + tagged_transaction_queue::TaggedTransactionQueue + } + pub fn offchain_worker_api(&self) -> offchain_worker_api::OffchainWorkerApi { + offchain_worker_api::OffchainWorkerApi + } + pub fn parachain_host(&self) -> parachain_host::ParachainHost { + parachain_host::ParachainHost + } + pub fn beefy_api(&self) -> beefy_api::BeefyApi { + beefy_api::BeefyApi + } + pub fn mmr_api(&self) -> mmr_api::MmrApi { + mmr_api::MmrApi + } + pub fn grandpa_api(&self) -> grandpa_api::GrandpaApi { + grandpa_api::GrandpaApi + } + pub fn babe_api(&self) -> babe_api::BabeApi { + babe_api::BabeApi + } + pub fn authority_discovery_api( + &self, + ) -> authority_discovery_api::AuthorityDiscoveryApi { + authority_discovery_api::AuthorityDiscoveryApi + } + pub fn session_keys(&self) -> session_keys::SessionKeys { + session_keys::SessionKeys + } + pub fn account_nonce_api(&self) -> account_nonce_api::AccountNonceApi { + account_nonce_api::AccountNonceApi + } + pub fn transaction_payment_api( + &self, + ) -> transaction_payment_api::TransactionPaymentApi { + transaction_payment_api::TransactionPaymentApi + } + pub fn transaction_payment_call_api( + &self, + ) -> transaction_payment_call_api::TransactionPaymentCallApi { + transaction_payment_call_api::TransactionPaymentCallApi + } + } + pub mod core { + use super::root_mod; + use super::runtime_types; + #[doc = " The `Core` runtime api that every Substrate runtime needs to implement."] + pub struct Core; + impl Core { + #[doc = " Returns the version of the runtime."] + pub fn version( + &self, + ) -> ::subxt::runtime_api::Payload< + types::Version, + runtime_types::sp_version::RuntimeVersion, + > { + ::subxt::runtime_api::Payload::new_static( + "Core_version", + types::Version {}, + [ + 209u8, 59u8, 156u8, 128u8, 14u8, 210u8, 96u8, 63u8, 140u8, 0u8, 65u8, + 211u8, 118u8, 177u8, 9u8, 208u8, 105u8, 124u8, 132u8, 203u8, 157u8, + 207u8, 186u8, 177u8, 91u8, 170u8, 22u8, 224u8, 88u8, 56u8, 56u8, 13u8, + ], + ) + } + #[doc = " Execute the given block."] + pub fn execute_block( + &self, + block : runtime_types :: sp_runtime :: generic :: block :: Block < runtime_types :: sp_runtime :: generic :: header :: Header < :: core :: primitive :: u32 , runtime_types :: sp_runtime :: traits :: BlakeTwo256 > , runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > >, + ) -> ::subxt::runtime_api::Payload { + ::subxt::runtime_api::Payload::new_static( + "Core_execute_block", + types::ExecuteBlock { block }, + [ + 199u8, 164u8, 96u8, 78u8, 188u8, 134u8, 19u8, 247u8, 63u8, 58u8, 93u8, + 227u8, 122u8, 157u8, 93u8, 196u8, 16u8, 7u8, 20u8, 17u8, 178u8, 152u8, + 211u8, 185u8, 56u8, 153u8, 118u8, 241u8, 118u8, 105u8, 85u8, 3u8, + ], + ) + } + #[doc = " Initialize a block with the given header."] + pub fn initialize_block( + &self, + header: runtime_types::sp_runtime::generic::header::Header< + ::core::primitive::u32, + runtime_types::sp_runtime::traits::BlakeTwo256, + >, + ) -> ::subxt::runtime_api::Payload { + ::subxt::runtime_api::Payload::new_static( + "Core_initialize_block", + types::InitializeBlock { header }, + [ + 45u8, 232u8, 143u8, 132u8, 33u8, 211u8, 71u8, 186u8, 169u8, 91u8, + 143u8, 156u8, 174u8, 156u8, 10u8, 25u8, 203u8, 16u8, 208u8, 226u8, + 12u8, 233u8, 145u8, 228u8, 63u8, 118u8, 66u8, 247u8, 71u8, 48u8, 44u8, + 243u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Version {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ExecuteBlock { pub block : runtime_types :: sp_runtime :: generic :: block :: Block < runtime_types :: sp_runtime :: generic :: header :: Header < :: core :: primitive :: u32 , runtime_types :: sp_runtime :: traits :: BlakeTwo256 > , runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > > , } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct InitializeBlock { + pub header: runtime_types::sp_runtime::generic::header::Header< + ::core::primitive::u32, + runtime_types::sp_runtime::traits::BlakeTwo256, + >, + } + } + } + pub mod metadata { + use super::root_mod; + use super::runtime_types; + #[doc = " The `Metadata` api trait that returns metadata for the runtime."] + pub struct Metadata; + impl Metadata { + #[doc = " Returns the metadata of a runtime."] + pub fn metadata( + &self, + ) -> ::subxt::runtime_api::Payload< + types::Metadata, + runtime_types::sp_core::OpaqueMetadata, + > { + ::subxt::runtime_api::Payload::new_static( + "Metadata_metadata", + types::Metadata {}, + [ + 158u8, 223u8, 229u8, 177u8, 228u8, 49u8, 24u8, 219u8, 143u8, 82u8, + 255u8, 132u8, 245u8, 210u8, 160u8, 197u8, 218u8, 10u8, 63u8, 165u8, + 115u8, 91u8, 70u8, 151u8, 246u8, 51u8, 18u8, 235u8, 91u8, 143u8, 27u8, + 127u8, + ], + ) + } + #[doc = " Returns the metadata at a given version."] + #[doc = ""] + #[doc = " If the given `version` isn't supported, this will return `None`."] + #[doc = " Use [`Self::metadata_versions`] to find out about supported metadata version of the runtime."] + pub fn metadata_at_version( + &self, + version: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload< + types::MetadataAtVersion, + ::core::option::Option, + > { + ::subxt::runtime_api::Payload::new_static( + "Metadata_metadata_at_version", + types::MetadataAtVersion { version }, + [ + 50u8, 164u8, 234u8, 88u8, 65u8, 62u8, 176u8, 66u8, 188u8, 114u8, 205u8, + 29u8, 137u8, 173u8, 194u8, 54u8, 237u8, 48u8, 221u8, 46u8, 166u8, 44u8, + 220u8, 137u8, 97u8, 128u8, 204u8, 137u8, 29u8, 229u8, 31u8, 134u8, + ], + ) + } + #[doc = " Returns the supported metadata versions."] + #[doc = ""] + #[doc = " This can be used to call `metadata_at_version`."] + pub fn metadata_versions( + &self, + ) -> ::subxt::runtime_api::Payload< + types::MetadataVersions, + ::std::vec::Vec<::core::primitive::u32>, + > { + ::subxt::runtime_api::Payload::new_static( + "Metadata_metadata_versions", + types::MetadataVersions {}, + [ + 255u8, 234u8, 86u8, 244u8, 238u8, 175u8, 175u8, 54u8, 181u8, 181u8, + 23u8, 185u8, 231u8, 242u8, 153u8, 246u8, 205u8, 142u8, 184u8, 21u8, + 240u8, 217u8, 195u8, 231u8, 32u8, 163u8, 127u8, 3u8, 51u8, 130u8, 68u8, + 124u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Metadata {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct MetadataAtVersion { + pub version: ::core::primitive::u32, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct MetadataVersions {} + } + } + pub mod block_builder { + use super::root_mod; + use super::runtime_types; + #[doc = " The `BlockBuilder` api trait that provides the required functionality for building a block."] + pub struct BlockBuilder; + impl BlockBuilder { + #[doc = " Apply the given extrinsic."] + #[doc = ""] + #[doc = " Returns an inclusion outcome which specifies if this extrinsic is included in"] + #[doc = " this block or not."] + pub fn apply_extrinsic( + &self, + extrinsic : runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) >, + ) -> ::subxt::runtime_api::Payload< + types::ApplyExtrinsic, + ::core::result::Result< + ::core::result::Result<(), runtime_types::sp_runtime::DispatchError>, + runtime_types::sp_runtime::transaction_validity::TransactionValidityError, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "BlockBuilder_apply_extrinsic", + types::ApplyExtrinsic { extrinsic }, + [ + 151u8, 89u8, 106u8, 151u8, 95u8, 29u8, 10u8, 68u8, 85u8, 149u8, 144u8, + 132u8, 47u8, 46u8, 164u8, 91u8, 225u8, 219u8, 85u8, 120u8, 101u8, + 105u8, 45u8, 79u8, 171u8, 133u8, 121u8, 170u8, 197u8, 248u8, 24u8, + 10u8, + ], + ) + } + #[doc = " Finish the current block."] + pub fn finalize_block( + &self, + ) -> ::subxt::runtime_api::Payload< + types::FinalizeBlock, + runtime_types::sp_runtime::generic::header::Header< + ::core::primitive::u32, + runtime_types::sp_runtime::traits::BlakeTwo256, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "BlockBuilder_finalize_block", + types::FinalizeBlock {}, + [ + 78u8, 179u8, 67u8, 170u8, 213u8, 230u8, 122u8, 98u8, 76u8, 244u8, + 225u8, 219u8, 83u8, 115u8, 94u8, 229u8, 93u8, 142u8, 120u8, 172u8, + 87u8, 99u8, 120u8, 41u8, 143u8, 184u8, 71u8, 49u8, 126u8, 55u8, 240u8, + 125u8, + ], + ) + } + #[doc = " Generate inherent extrinsics. The inherent data will vary from chain to chain."] pub fn inherent_extrinsics (& self , inherent : runtime_types :: sp_inherents :: InherentData ,) -> :: subxt :: runtime_api :: Payload < types :: InherentExtrinsics , :: std :: vec :: Vec < runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > > >{ + ::subxt::runtime_api::Payload::new_static( + "BlockBuilder_inherent_extrinsics", + types::InherentExtrinsics { inherent }, + [ + 75u8, 86u8, 85u8, 104u8, 125u8, 169u8, 23u8, 92u8, 162u8, 73u8, 65u8, + 223u8, 100u8, 24u8, 201u8, 157u8, 145u8, 208u8, 238u8, 11u8, 255u8, + 98u8, 0u8, 211u8, 189u8, 94u8, 5u8, 123u8, 25u8, 1u8, 88u8, 234u8, + ], + ) + } + #[doc = " Check that the inherents are valid. The inherent data will vary from chain to chain."] + pub fn check_inherents( + &self, + block : runtime_types :: sp_runtime :: generic :: block :: Block < runtime_types :: sp_runtime :: generic :: header :: Header < :: core :: primitive :: u32 , runtime_types :: sp_runtime :: traits :: BlakeTwo256 > , runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > >, + data: runtime_types::sp_inherents::InherentData, + ) -> ::subxt::runtime_api::Payload< + types::CheckInherents, + runtime_types::sp_inherents::CheckInherentsResult, + > { + ::subxt::runtime_api::Payload::new_static( + "BlockBuilder_check_inherents", + types::CheckInherents { block, data }, + [ + 162u8, 99u8, 46u8, 228u8, 124u8, 158u8, 224u8, 212u8, 90u8, 101u8, + 133u8, 173u8, 82u8, 61u8, 131u8, 131u8, 254u8, 209u8, 17u8, 181u8, + 87u8, 190u8, 80u8, 165u8, 172u8, 179u8, 121u8, 202u8, 126u8, 48u8, + 254u8, 112u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ApplyExtrinsic { pub extrinsic : runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > , } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct FinalizeBlock {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct InherentExtrinsics { + pub inherent: runtime_types::sp_inherents::InherentData, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct CheckInherents { pub block : runtime_types :: sp_runtime :: generic :: block :: Block < runtime_types :: sp_runtime :: generic :: header :: Header < :: core :: primitive :: u32 , runtime_types :: sp_runtime :: traits :: BlakeTwo256 > , runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > > , pub data : runtime_types :: sp_inherents :: InherentData , } + } + } + pub mod nomination_pools_api { + use super::root_mod; + use super::runtime_types; + #[doc = " Runtime api for accessing information about nomination pools."] + pub struct NominationPoolsApi; + impl NominationPoolsApi { + #[doc = " Returns the pending rewards for the member that the AccountId was given for."] + pub fn pending_rewards( + &self, + who: ::subxt::utils::AccountId32, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "NominationPoolsApi_pending_rewards", + types::PendingRewards { who }, + [ + 235u8, 64u8, 57u8, 70u8, 111u8, 27u8, 62u8, 236u8, 36u8, 192u8, 103u8, + 89u8, 221u8, 194u8, 46u8, 223u8, 71u8, 249u8, 33u8, 135u8, 43u8, 42u8, + 147u8, 57u8, 130u8, 44u8, 35u8, 132u8, 163u8, 153u8, 201u8, 105u8, + ], + ) + } + #[doc = " Returns the equivalent balance of `points` for a given pool."] + pub fn points_to_balance( + &self, + pool_id: ::core::primitive::u32, + points: ::core::primitive::u128, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "NominationPoolsApi_points_to_balance", + types::PointsToBalance { pool_id, points }, + [ + 30u8, 7u8, 5u8, 95u8, 146u8, 43u8, 110u8, 21u8, 148u8, 160u8, 74u8, + 92u8, 168u8, 188u8, 74u8, 41u8, 129u8, 172u8, 138u8, 30u8, 232u8, + 214u8, 154u8, 18u8, 52u8, 87u8, 71u8, 127u8, 141u8, 177u8, 216u8, + 158u8, + ], + ) + } + #[doc = " Returns the equivalent points of `new_funds` for a given pool."] + pub fn balance_to_points( + &self, + pool_id: ::core::primitive::u32, + new_funds: ::core::primitive::u128, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "NominationPoolsApi_balance_to_points", + types::BalanceToPoints { pool_id, new_funds }, + [ + 152u8, 165u8, 227u8, 129u8, 31u8, 108u8, 224u8, 174u8, 74u8, 192u8, + 102u8, 139u8, 17u8, 119u8, 173u8, 220u8, 52u8, 157u8, 125u8, 107u8, + 110u8, 236u8, 9u8, 93u8, 239u8, 3u8, 18u8, 140u8, 203u8, 136u8, 183u8, + 215u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct PendingRewards { + pub who: ::subxt::utils::AccountId32, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct PointsToBalance { + pub pool_id: ::core::primitive::u32, + pub points: ::core::primitive::u128, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct BalanceToPoints { + pub pool_id: ::core::primitive::u32, + pub new_funds: ::core::primitive::u128, + } + } + } + pub mod staking_api { + use super::root_mod; + use super::runtime_types; + pub struct StakingApi; + impl StakingApi { + #[doc = " Returns the nominations quota for a nominator with a given balance."] + pub fn nominations_quota( + &self, + balance: ::core::primitive::u128, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "StakingApi_nominations_quota", + types::NominationsQuota { balance }, + [ + 181u8, 19u8, 6u8, 134u8, 234u8, 67u8, 127u8, 210u8, 53u8, 38u8, 175u8, + 160u8, 243u8, 71u8, 187u8, 206u8, 178u8, 91u8, 26u8, 115u8, 18u8, + 214u8, 50u8, 208u8, 161u8, 197u8, 81u8, 13u8, 98u8, 53u8, 124u8, 62u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct NominationsQuota { + pub balance: ::core::primitive::u128, + } + } + } + pub mod tagged_transaction_queue { + use super::root_mod; + use super::runtime_types; + #[doc = " The `TaggedTransactionQueue` api trait for interfering with the transaction queue."] + pub struct TaggedTransactionQueue; + impl TaggedTransactionQueue { + #[doc = " Validate the transaction."] + #[doc = ""] + #[doc = " This method is invoked by the transaction pool to learn details about given transaction."] + #[doc = " The implementation should make sure to verify the correctness of the transaction"] + #[doc = " against current state. The given `block_hash` corresponds to the hash of the block"] + #[doc = " that is used as current state."] + #[doc = ""] + #[doc = " Note that this call may be performed by the pool multiple times and transactions"] + #[doc = " might be verified in any possible order."] + pub fn validate_transaction( + &self, + source: runtime_types::sp_runtime::transaction_validity::TransactionSource, + tx : runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) >, + block_hash: ::subxt::utils::H256, + ) -> ::subxt::runtime_api::Payload< + types::ValidateTransaction, + ::core::result::Result< + runtime_types::sp_runtime::transaction_validity::ValidTransaction, + runtime_types::sp_runtime::transaction_validity::TransactionValidityError, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "TaggedTransactionQueue_validate_transaction", + types::ValidateTransaction { + source, + tx, + block_hash, + }, + [ + 93u8, 180u8, 253u8, 37u8, 212u8, 54u8, 180u8, 214u8, 33u8, 5u8, 113u8, + 181u8, 25u8, 48u8, 153u8, 221u8, 78u8, 6u8, 115u8, 191u8, 72u8, 75u8, + 203u8, 171u8, 129u8, 75u8, 56u8, 60u8, 243u8, 92u8, 173u8, 12u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ValidateTransaction { pub source : runtime_types :: sp_runtime :: transaction_validity :: TransactionSource , pub tx : runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > , pub block_hash : :: subxt :: utils :: H256 , } + } + } + pub mod offchain_worker_api { + use super::root_mod; + use super::runtime_types; + #[doc = " The offchain worker api."] + pub struct OffchainWorkerApi; + impl OffchainWorkerApi { + #[doc = " Starts the off-chain task for given block header."] + pub fn offchain_worker( + &self, + header: runtime_types::sp_runtime::generic::header::Header< + ::core::primitive::u32, + runtime_types::sp_runtime::traits::BlakeTwo256, + >, + ) -> ::subxt::runtime_api::Payload { + ::subxt::runtime_api::Payload::new_static( + "OffchainWorkerApi_offchain_worker", + types::OffchainWorker { header }, + [ + 187u8, 145u8, 211u8, 0u8, 200u8, 151u8, 231u8, 42u8, 187u8, 128u8, + 157u8, 64u8, 191u8, 64u8, 31u8, 158u8, 13u8, 159u8, 227u8, 120u8, + 155u8, 215u8, 228u8, 215u8, 44u8, 8u8, 206u8, 116u8, 241u8, 133u8, 2u8, + 234u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct OffchainWorker { + pub header: runtime_types::sp_runtime::generic::header::Header< + ::core::primitive::u32, + runtime_types::sp_runtime::traits::BlakeTwo256, + >, + } + } + } + pub mod parachain_host { + use super::root_mod; + use super::runtime_types; + #[doc = " The API for querying the state of parachains on-chain."] + pub struct ParachainHost; + impl ParachainHost { + #[doc = " Get the current validators."] + pub fn validators( + &self, + ) -> ::subxt::runtime_api::Payload< + types::Validators, + ::std::vec::Vec, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_validators", + types::Validators {}, + [ + 105u8, 23u8, 110u8, 209u8, 38u8, 112u8, 199u8, 134u8, 145u8, 131u8, + 38u8, 221u8, 254u8, 147u8, 242u8, 149u8, 94u8, 76u8, 197u8, 67u8, + 228u8, 113u8, 196u8, 50u8, 122u8, 1u8, 121u8, 225u8, 163u8, 210u8, + 66u8, 68u8, + ], + ) + } + #[doc = " Returns the validator groups and rotation info localized based on the hypothetical child"] + #[doc = " of a block whose state this is invoked on. Note that `now` in the `GroupRotationInfo`"] + #[doc = " should be the successor of the number of the block."] + pub fn validator_groups( + &self, + ) -> ::subxt::runtime_api::Payload< + types::ValidatorGroups, + ( + ::std::vec::Vec< + ::std::vec::Vec, + >, + runtime_types::polkadot_primitives::v4::GroupRotationInfo< + ::core::primitive::u32, + >, + ), + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_validator_groups", + types::ValidatorGroups {}, + [ + 185u8, 206u8, 229u8, 10u8, 93u8, 19u8, 23u8, 44u8, 159u8, 13u8, 235u8, + 236u8, 78u8, 153u8, 144u8, 82u8, 106u8, 248u8, 8u8, 92u8, 250u8, 54u8, + 153u8, 53u8, 183u8, 60u8, 67u8, 216u8, 201u8, 88u8, 217u8, 120u8, + ], + ) + } + #[doc = " Yields information on all availability cores as relevant to the child block."] + #[doc = " Cores are either free or occupied. Free cores can have paras assigned to them."] + pub fn availability_cores( + &self, + ) -> ::subxt::runtime_api::Payload< + types::AvailabilityCores, + ::std::vec::Vec< + runtime_types::polkadot_primitives::v4::CoreState< + ::subxt::utils::H256, + ::core::primitive::u32, + >, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_availability_cores", + types::AvailabilityCores {}, + [ + 107u8, 20u8, 115u8, 26u8, 118u8, 211u8, 207u8, 122u8, 134u8, 174u8, + 98u8, 237u8, 216u8, 175u8, 39u8, 176u8, 211u8, 78u8, 142u8, 29u8, + 127u8, 56u8, 160u8, 249u8, 174u8, 244u8, 146u8, 181u8, 4u8, 166u8, + 93u8, 13u8, + ], + ) + } + #[doc = " Yields the persisted validation data for the given `ParaId` along with an assumption that"] + #[doc = " should be used if the para currently occupies a core."] + #[doc = ""] + #[doc = " Returns `None` if either the para is not registered or the assumption is `Freed`"] + #[doc = " and the para already occupies a core."] + pub fn persisted_validation_data( + &self, + para_id: runtime_types::polkadot_parachain::primitives::Id, + assumption: runtime_types::polkadot_primitives::v4::OccupiedCoreAssumption, + ) -> ::subxt::runtime_api::Payload< + types::PersistedValidationData, + ::core::option::Option< + runtime_types::polkadot_primitives::v4::PersistedValidationData< + ::subxt::utils::H256, + ::core::primitive::u32, + >, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_persisted_validation_data", + types::PersistedValidationData { + para_id, + assumption, + }, + [ + 230u8, 186u8, 57u8, 116u8, 47u8, 20u8, 186u8, 89u8, 108u8, 211u8, 22u8, + 57u8, 124u8, 234u8, 140u8, 3u8, 104u8, 89u8, 89u8, 188u8, 156u8, 130u8, + 146u8, 77u8, 129u8, 66u8, 227u8, 157u8, 4u8, 134u8, 7u8, 237u8, + ], + ) + } + #[doc = " Returns the persisted validation data for the given `ParaId` along with the corresponding"] + #[doc = " validation code hash. Instead of accepting assumption about the para, matches the validation"] + #[doc = " data hash against an expected one and yields `None` if they're not equal."] + pub fn assumed_validation_data( + &self, + para_id: runtime_types::polkadot_parachain::primitives::Id, + expected_persisted_validation_data_hash: ::subxt::utils::H256, + ) -> ::subxt::runtime_api::Payload< + types::AssumedValidationData, + ::core::option::Option<( + runtime_types::polkadot_primitives::v4::PersistedValidationData< + ::subxt::utils::H256, + ::core::primitive::u32, + >, + runtime_types::polkadot_parachain::primitives::ValidationCodeHash, + )>, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_assumed_validation_data", + types::AssumedValidationData { + para_id, + expected_persisted_validation_data_hash, + }, + [ + 53u8, 137u8, 220u8, 72u8, 155u8, 9u8, 200u8, 207u8, 158u8, 108u8, + 204u8, 15u8, 188u8, 162u8, 129u8, 158u8, 62u8, 200u8, 13u8, 0u8, 217u8, + 195u8, 19u8, 151u8, 187u8, 231u8, 197u8, 235u8, 128u8, 244u8, 51u8, + 85u8, + ], + ) + } + #[doc = " Checks if the given validation outputs pass the acceptance criteria."] + pub fn check_validation_outputs( + &self, + para_id: runtime_types::polkadot_parachain::primitives::Id, + outputs: runtime_types::polkadot_primitives::v4::CandidateCommitments< + ::core::primitive::u32, + >, + ) -> ::subxt::runtime_api::Payload< + types::CheckValidationOutputs, + ::core::primitive::bool, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_check_validation_outputs", + types::CheckValidationOutputs { para_id, outputs }, + [ + 99u8, 191u8, 194u8, 26u8, 245u8, 216u8, 224u8, 232u8, 26u8, 184u8, + 120u8, 64u8, 32u8, 134u8, 215u8, 138u8, 195u8, 30u8, 220u8, 111u8, + 119u8, 182u8, 62u8, 72u8, 5u8, 144u8, 87u8, 157u8, 125u8, 125u8, 237u8, + 34u8, + ], + ) + } + #[doc = " Returns the session index expected at a child of the block."] + #[doc = ""] + #[doc = " This can be used to instantiate a `SigningContext`."] + pub fn session_index_for_child( + &self, + ) -> ::subxt::runtime_api::Payload< + types::SessionIndexForChild, + ::core::primitive::u32, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_session_index_for_child", + types::SessionIndexForChild {}, + [ + 224u8, 173u8, 95u8, 16u8, 57u8, 180u8, 35u8, 148u8, 243u8, 77u8, 123u8, + 242u8, 212u8, 122u8, 27u8, 32u8, 44u8, 166u8, 66u8, 124u8, 1u8, 190u8, + 93u8, 124u8, 57u8, 127u8, 249u8, 141u8, 173u8, 92u8, 137u8, 165u8, + ], + ) + } + #[doc = " Fetch the validation code used by a para, making the given `OccupiedCoreAssumption`."] + #[doc = ""] + #[doc = " Returns `None` if either the para is not registered or the assumption is `Freed`"] + #[doc = " and the para already occupies a core."] + pub fn validation_code( + &self, + para_id: runtime_types::polkadot_parachain::primitives::Id, + assumption: runtime_types::polkadot_primitives::v4::OccupiedCoreAssumption, + ) -> ::subxt::runtime_api::Payload< + types::ValidationCode, + ::core::option::Option< + runtime_types::polkadot_parachain::primitives::ValidationCode, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_validation_code", + types::ValidationCode { + para_id, + assumption, + }, + [ + 231u8, 64u8, 145u8, 133u8, 197u8, 196u8, 177u8, 229u8, 152u8, 70u8, + 16u8, 159u8, 65u8, 66u8, 172u8, 58u8, 60u8, 50u8, 232u8, 28u8, 36u8, + 211u8, 161u8, 28u8, 192u8, 153u8, 89u8, 186u8, 9u8, 246u8, 228u8, 84u8, + ], + ) + } + #[doc = " Get the receipt of a candidate pending availability. This returns `Some` for any paras"] + #[doc = " assigned to occupied cores in `availability_cores` and `None` otherwise."] + pub fn candidate_pending_availability( + &self, + para_id: runtime_types::polkadot_parachain::primitives::Id, + ) -> ::subxt::runtime_api::Payload< + types::CandidatePendingAvailability, + ::core::option::Option< + runtime_types::polkadot_primitives::v4::CommittedCandidateReceipt< + ::subxt::utils::H256, + >, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_candidate_pending_availability", + types::CandidatePendingAvailability { para_id }, + [ + 175u8, 68u8, 187u8, 74u8, 138u8, 129u8, 153u8, 251u8, 216u8, 70u8, + 251u8, 151u8, 169u8, 252u8, 31u8, 16u8, 61u8, 242u8, 169u8, 15u8, + 123u8, 58u8, 177u8, 131u8, 6u8, 79u8, 30u8, 105u8, 51u8, 67u8, 19u8, + 208u8, + ], + ) + } + #[doc = " Get a vector of events concerning candidates that occurred within a block."] + pub fn candidate_events( + &self, + ) -> ::subxt::runtime_api::Payload< + types::CandidateEvents, + ::std::vec::Vec< + runtime_types::polkadot_primitives::v4::CandidateEvent< + ::subxt::utils::H256, + >, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_candidate_events", + types::CandidateEvents {}, + [ + 50u8, 177u8, 192u8, 138u8, 139u8, 179u8, 76u8, 167u8, 238u8, 92u8, + 255u8, 249u8, 223u8, 61u8, 112u8, 7u8, 0u8, 6u8, 43u8, 71u8, 209u8, + 21u8, 14u8, 184u8, 19u8, 68u8, 106u8, 193u8, 38u8, 251u8, 19u8, 208u8, + ], + ) + } + #[doc = " Get all the pending inbound messages in the downward message queue for a para."] + pub fn dmq_contents( + &self, + recipient: runtime_types::polkadot_parachain::primitives::Id, + ) -> ::subxt::runtime_api::Payload< + types::DmqContents, + ::std::vec::Vec< + runtime_types::polkadot_core_primitives::InboundDownwardMessage< + ::core::primitive::u32, + >, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_dmq_contents", + types::DmqContents { recipient }, + [ + 34u8, 66u8, 1u8, 92u8, 223u8, 240u8, 222u8, 128u8, 190u8, 242u8, 160u8, + 140u8, 60u8, 57u8, 155u8, 105u8, 10u8, 162u8, 212u8, 72u8, 1u8, 192u8, + 36u8, 26u8, 127u8, 86u8, 8u8, 255u8, 57u8, 210u8, 148u8, 254u8, + ], + ) + } + #[doc = " Get the contents of all channels addressed to the given recipient. Channels that have no"] + #[doc = " messages in them are also included."] + pub fn inbound_hrmp_channels_contents( + &self, + recipient: runtime_types::polkadot_parachain::primitives::Id, + ) -> ::subxt::runtime_api::Payload< + types::InboundHrmpChannelsContents, + ::subxt::utils::KeyedVec< + runtime_types::polkadot_parachain::primitives::Id, + ::std::vec::Vec< + runtime_types::polkadot_core_primitives::InboundHrmpMessage< + ::core::primitive::u32, + >, + >, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_inbound_hrmp_channels_contents", + types::InboundHrmpChannelsContents { recipient }, + [ + 209u8, 72u8, 244u8, 143u8, 167u8, 234u8, 8u8, 33u8, 80u8, 154u8, 132u8, + 22u8, 62u8, 174u8, 3u8, 89u8, 78u8, 115u8, 119u8, 77u8, 169u8, 80u8, + 98u8, 164u8, 8u8, 8u8, 50u8, 120u8, 58u8, 12u8, 114u8, 57u8, + ], + ) + } + #[doc = " Get the validation code from its hash."] + pub fn validation_code_by_hash( + &self, + hash: runtime_types::polkadot_parachain::primitives::ValidationCodeHash, + ) -> ::subxt::runtime_api::Payload< + types::ValidationCodeByHash, + ::core::option::Option< + runtime_types::polkadot_parachain::primitives::ValidationCode, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_validation_code_by_hash", + types::ValidationCodeByHash { hash }, + [ + 143u8, 146u8, 97u8, 197u8, 138u8, 122u8, 186u8, 0u8, 86u8, 105u8, + 207u8, 55u8, 53u8, 47u8, 131u8, 101u8, 24u8, 71u8, 204u8, 71u8, 96u8, + 100u8, 252u8, 127u8, 21u8, 248u8, 70u8, 187u8, 111u8, 112u8, 77u8, + 208u8, + ], + ) + } + #[doc = " Scrape dispute relevant from on-chain, backing votes and resolved disputes."] + pub fn on_chain_votes( + &self, + ) -> ::subxt::runtime_api::Payload< + types::OnChainVotes, + ::core::option::Option< + runtime_types::polkadot_primitives::v4::ScrapedOnChainVotes< + ::subxt::utils::H256, + >, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_on_chain_votes", + types::OnChainVotes {}, + [ + 37u8, 2u8, 32u8, 215u8, 117u8, 137u8, 242u8, 168u8, 57u8, 175u8, 59u8, + 243u8, 132u8, 133u8, 246u8, 37u8, 154u8, 205u8, 191u8, 114u8, 114u8, + 167u8, 104u8, 27u8, 144u8, 56u8, 61u8, 159u8, 9u8, 79u8, 190u8, 239u8, + ], + ) + } + #[doc = " Get the session info for the given session, if stored."] + #[doc = ""] + #[doc = " NOTE: This function is only available since parachain host version 2."] + pub fn session_info( + &self, + index: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload< + types::SessionInfo, + ::core::option::Option, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_session_info", + types::SessionInfo { index }, + [ + 107u8, 247u8, 186u8, 88u8, 134u8, 234u8, 251u8, 220u8, 134u8, 138u8, + 130u8, 168u8, 253u8, 101u8, 235u8, 126u8, 190u8, 37u8, 77u8, 182u8, + 195u8, 100u8, 63u8, 173u8, 147u8, 98u8, 217u8, 235u8, 220u8, 87u8, + 83u8, 198u8, + ], + ) + } + #[doc = " Submits a PVF pre-checking statement into the transaction pool."] + #[doc = ""] + #[doc = " NOTE: This function is only available since parachain host version 2."] + pub fn submit_pvf_check_statement( + &self, + stmt: runtime_types::polkadot_primitives::v4::PvfCheckStatement, + signature: runtime_types::polkadot_primitives::v4::validator_app::Signature, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_submit_pvf_check_statement", + types::SubmitPvfCheckStatement { stmt, signature }, + [ + 228u8, 45u8, 8u8, 229u8, 69u8, 35u8, 3u8, 231u8, 235u8, 184u8, 19u8, + 96u8, 72u8, 62u8, 15u8, 218u8, 27u8, 134u8, 19u8, 179u8, 239u8, 1u8, + 207u8, 39u8, 50u8, 171u8, 59u8, 204u8, 143u8, 247u8, 27u8, 179u8, + ], + ) + } + #[doc = " Returns code hashes of PVFs that require pre-checking by validators in the active set."] + #[doc = ""] + #[doc = " NOTE: This function is only available since parachain host version 2."] + pub fn pvfs_require_precheck( + &self, + ) -> ::subxt::runtime_api::Payload< + types::PvfsRequirePrecheck, + ::std::vec::Vec< + runtime_types::polkadot_parachain::primitives::ValidationCodeHash, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_pvfs_require_precheck", + types::PvfsRequirePrecheck {}, + [ + 58u8, 208u8, 110u8, 249u8, 77u8, 56u8, 39u8, 46u8, 196u8, 209u8, 189u8, + 200u8, 147u8, 235u8, 247u8, 235u8, 125u8, 230u8, 11u8, 151u8, 137u8, + 118u8, 110u8, 179u8, 72u8, 53u8, 127u8, 149u8, 252u8, 20u8, 165u8, + 239u8, + ], + ) + } + #[doc = " Fetch the hash of the validation code used by a para, making the given `OccupiedCoreAssumption`."] + #[doc = ""] + #[doc = " NOTE: This function is only available since parachain host version 2."] + pub fn validation_code_hash( + &self, + para_id: runtime_types::polkadot_parachain::primitives::Id, + assumption: runtime_types::polkadot_primitives::v4::OccupiedCoreAssumption, + ) -> ::subxt::runtime_api::Payload< + types::ValidationCodeHash, + ::core::option::Option< + runtime_types::polkadot_parachain::primitives::ValidationCodeHash, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_validation_code_hash", + types::ValidationCodeHash { + para_id, + assumption, + }, + [ + 232u8, 173u8, 117u8, 125u8, 245u8, 188u8, 20u8, 124u8, 255u8, 219u8, + 2u8, 95u8, 131u8, 3u8, 122u8, 190u8, 240u8, 184u8, 8u8, 239u8, 85u8, + 107u8, 59u8, 105u8, 206u8, 130u8, 65u8, 142u8, 130u8, 193u8, 143u8, + 199u8, + ], + ) + } + #[doc = " Returns all onchain disputes."] + pub fn disputes( + &self, + ) -> ::subxt::runtime_api::Payload< + types::Disputes, + ::std::vec::Vec<( + ::core::primitive::u32, + runtime_types::polkadot_core_primitives::CandidateHash, + runtime_types::polkadot_primitives::v4::DisputeState< + ::core::primitive::u32, + >, + )>, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_disputes", + types::Disputes {}, + [ + 90u8, 171u8, 12u8, 104u8, 109u8, 92u8, 149u8, 72u8, 109u8, 39u8, 75u8, + 241u8, 239u8, 78u8, 46u8, 134u8, 139u8, 200u8, 144u8, 213u8, 218u8, + 64u8, 98u8, 102u8, 159u8, 211u8, 154u8, 178u8, 187u8, 146u8, 193u8, + 34u8, + ], + ) + } + #[doc = " Returns execution parameters for the session."] + pub fn session_executor_params( + &self, + session_index: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload< + types::SessionExecutorParams, + ::core::option::Option< + runtime_types::polkadot_primitives::v4::executor_params::ExecutorParams, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "ParachainHost_session_executor_params", + types::SessionExecutorParams { session_index }, + [ + 129u8, 198u8, 157u8, 37u8, 138u8, 132u8, 5u8, 183u8, 233u8, 119u8, + 99u8, 173u8, 22u8, 240u8, 182u8, 246u8, 101u8, 3u8, 149u8, 130u8, + 107u8, 60u8, 152u8, 217u8, 86u8, 150u8, 253u8, 170u8, 10u8, 86u8, + 183u8, 33u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Validators {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ValidatorGroups {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct AvailabilityCores {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct PersistedValidationData { + pub para_id: runtime_types::polkadot_parachain::primitives::Id, + pub assumption: runtime_types::polkadot_primitives::v4::OccupiedCoreAssumption, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct AssumedValidationData { + pub para_id: runtime_types::polkadot_parachain::primitives::Id, + pub expected_persisted_validation_data_hash: ::subxt::utils::H256, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct CheckValidationOutputs { + pub para_id: runtime_types::polkadot_parachain::primitives::Id, + pub outputs: runtime_types::polkadot_primitives::v4::CandidateCommitments< + ::core::primitive::u32, + >, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct SessionIndexForChild {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ValidationCode { + pub para_id: runtime_types::polkadot_parachain::primitives::Id, + pub assumption: runtime_types::polkadot_primitives::v4::OccupiedCoreAssumption, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct CandidatePendingAvailability { + pub para_id: runtime_types::polkadot_parachain::primitives::Id, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct CandidateEvents {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct DmqContents { + pub recipient: runtime_types::polkadot_parachain::primitives::Id, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct InboundHrmpChannelsContents { + pub recipient: runtime_types::polkadot_parachain::primitives::Id, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ValidationCodeByHash { + pub hash: runtime_types::polkadot_parachain::primitives::ValidationCodeHash, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct OnChainVotes {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct SessionInfo { + pub index: ::core::primitive::u32, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct SubmitPvfCheckStatement { + pub stmt: runtime_types::polkadot_primitives::v4::PvfCheckStatement, + pub signature: runtime_types::polkadot_primitives::v4::validator_app::Signature, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct PvfsRequirePrecheck {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ValidationCodeHash { + pub para_id: runtime_types::polkadot_parachain::primitives::Id, + pub assumption: runtime_types::polkadot_primitives::v4::OccupiedCoreAssumption, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Disputes {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct SessionExecutorParams { + pub session_index: ::core::primitive::u32, + } + } + } + pub mod beefy_api { + use super::root_mod; + use super::runtime_types; + #[doc = " API necessary for BEEFY voters."] + pub struct BeefyApi; + impl BeefyApi { + #[doc = " Return the block number where BEEFY consensus is enabled/started"] + pub fn beefy_genesis( + &self, + ) -> ::subxt::runtime_api::Payload< + types::BeefyGenesis, + ::core::option::Option<::core::primitive::u32>, + > { + ::subxt::runtime_api::Payload::new_static( + "BeefyApi_beefy_genesis", + types::BeefyGenesis {}, + [ + 80u8, 47u8, 5u8, 126u8, 16u8, 213u8, 203u8, 179u8, 124u8, 14u8, 227u8, + 61u8, 164u8, 158u8, 115u8, 127u8, 132u8, 90u8, 222u8, 87u8, 249u8, + 214u8, 100u8, 13u8, 201u8, 186u8, 229u8, 217u8, 21u8, 152u8, 197u8, + 60u8, + ], + ) + } + #[doc = " Return the current active BEEFY validator set"] + pub fn validator_set( + &self, + ) -> ::subxt::runtime_api::Payload< + types::ValidatorSet, + ::core::option::Option< + runtime_types::sp_consensus_beefy::ValidatorSet< + runtime_types::sp_consensus_beefy::crypto::Public, + >, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "BeefyApi_validator_set", + types::ValidatorSet {}, + [ + 49u8, 44u8, 188u8, 42u8, 35u8, 233u8, 181u8, 44u8, 232u8, 88u8, 1u8, + 100u8, 90u8, 42u8, 139u8, 239u8, 25u8, 44u8, 183u8, 164u8, 161u8, + 129u8, 12u8, 158u8, 41u8, 39u8, 218u8, 43u8, 78u8, 70u8, 156u8, 159u8, + ], + ) + } + #[doc = " Submits an unsigned extrinsic to report an equivocation. The caller"] + #[doc = " must provide the equivocation proof and a key ownership proof"] + #[doc = " (should be obtained using `generate_key_ownership_proof`). The"] + #[doc = " extrinsic will be unsigned and should only be accepted for local"] + #[doc = " authorship (not to be broadcast to the network). This method returns"] + #[doc = " `None` when creation of the extrinsic fails, e.g. if equivocation"] + #[doc = " reporting is disabled for the given runtime (i.e. this method is"] + #[doc = " hardcoded to return `None`). Only useful in an offchain context."] + pub fn submit_report_equivocation_unsigned_extrinsic( + &self, + equivocation_proof: runtime_types::sp_consensus_beefy::EquivocationProof< + ::core::primitive::u32, + runtime_types::sp_consensus_beefy::crypto::Public, + runtime_types::sp_consensus_beefy::crypto::Signature, + >, + key_owner_proof: runtime_types::sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> ::subxt::runtime_api::Payload< + types::SubmitReportEquivocationUnsignedExtrinsic, + ::core::option::Option<()>, + > { + ::subxt::runtime_api::Payload::new_static( + "BeefyApi_submit_report_equivocation_unsigned_extrinsic", + types::SubmitReportEquivocationUnsignedExtrinsic { + equivocation_proof, + key_owner_proof, + }, + [ + 232u8, 114u8, 155u8, 57u8, 178u8, 76u8, 154u8, 140u8, 49u8, 60u8, 71u8, + 98u8, 167u8, 4u8, 248u8, 159u8, 0u8, 36u8, 119u8, 102u8, 188u8, 10u8, + 137u8, 252u8, 249u8, 124u8, 208u8, 173u8, 252u8, 185u8, 117u8, 35u8, + ], + ) + } + #[doc = " Generates a proof of key ownership for the given authority in the"] + #[doc = " given set. An example usage of this module is coupled with the"] + #[doc = " session historical module to prove that a given authority key is"] + #[doc = " tied to a given staking identity during a specific session. Proofs"] + #[doc = " of key ownership are necessary for submitting equivocation reports."] + #[doc = " NOTE: even though the API takes a `set_id` as parameter the current"] + #[doc = " implementations ignores this parameter and instead relies on this"] + #[doc = " method being called at the correct block height, i.e. any point at"] + #[doc = " which the given set id is live on-chain. Future implementations will"] + #[doc = " instead use indexed data through an offchain worker, not requiring"] + #[doc = " older states to be available."] + pub fn generate_key_ownership_proof( + &self, + set_id: ::core::primitive::u64, + authority_id: runtime_types::sp_consensus_beefy::crypto::Public, + ) -> ::subxt::runtime_api::Payload< + types::GenerateKeyOwnershipProof, + ::core::option::Option< + runtime_types::sp_consensus_beefy::OpaqueKeyOwnershipProof, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "BeefyApi_generate_key_ownership_proof", + types::GenerateKeyOwnershipProof { + set_id, + authority_id, + }, + [ + 219u8, 146u8, 168u8, 108u8, 180u8, 133u8, 182u8, 104u8, 153u8, 14u8, + 209u8, 207u8, 32u8, 226u8, 81u8, 196u8, 243u8, 208u8, 0u8, 94u8, 197u8, + 232u8, 181u8, 251u8, 182u8, 12u8, 245u8, 231u8, 198u8, 76u8, 59u8, + 53u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct BeefyGenesis {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ValidatorSet {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct SubmitReportEquivocationUnsignedExtrinsic { + pub equivocation_proof: runtime_types::sp_consensus_beefy::EquivocationProof< + ::core::primitive::u32, + runtime_types::sp_consensus_beefy::crypto::Public, + runtime_types::sp_consensus_beefy::crypto::Signature, + >, + pub key_owner_proof: runtime_types::sp_consensus_beefy::OpaqueKeyOwnershipProof, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct GenerateKeyOwnershipProof { + pub set_id: ::core::primitive::u64, + pub authority_id: runtime_types::sp_consensus_beefy::crypto::Public, + } + } + } + pub mod mmr_api { + use super::root_mod; + use super::runtime_types; + #[doc = " API to interact with MMR pallet."] + pub struct MmrApi; + impl MmrApi { + #[doc = " Return the on-chain MMR root hash."] + pub fn mmr_root( + &self, + ) -> ::subxt::runtime_api::Payload< + types::MmrRoot, + ::core::result::Result< + ::subxt::utils::H256, + runtime_types::sp_mmr_primitives::Error, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "MmrApi_mmr_root", + types::MmrRoot {}, + [ + 83u8, 202u8, 15u8, 77u8, 255u8, 136u8, 129u8, 210u8, 154u8, 178u8, + 197u8, 94u8, 231u8, 151u8, 68u8, 172u8, 112u8, 116u8, 30u8, 138u8, + 142u8, 166u8, 16u8, 4u8, 24u8, 204u8, 18u8, 48u8, 43u8, 103u8, 30u8, + 96u8, + ], + ) + } + #[doc = " Return the number of MMR blocks in the chain."] + pub fn mmr_leaf_count( + &self, + ) -> ::subxt::runtime_api::Payload< + types::MmrLeafCount, + ::core::result::Result< + ::core::primitive::u64, + runtime_types::sp_mmr_primitives::Error, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "MmrApi_mmr_leaf_count", + types::MmrLeafCount {}, + [ + 81u8, 145u8, 75u8, 170u8, 197u8, 235u8, 92u8, 81u8, 54u8, 16u8, 239u8, + 136u8, 174u8, 255u8, 90u8, 27u8, 24u8, 51u8, 152u8, 130u8, 249u8, + 247u8, 44u8, 173u8, 4u8, 21u8, 72u8, 44u8, 198u8, 145u8, 94u8, 77u8, + ], + ) + } + #[doc = " Generate MMR proof for a series of block numbers. If `best_known_block_number = Some(n)`,"] + #[doc = " use historical MMR state at given block height `n`. Else, use current MMR state."] + pub fn generate_proof( + &self, + block_numbers: ::std::vec::Vec<::core::primitive::u32>, + best_known_block_number: ::core::option::Option<::core::primitive::u32>, + ) -> ::subxt::runtime_api::Payload< + types::GenerateProof, + ::core::result::Result< + ( + ::std::vec::Vec, + runtime_types::sp_mmr_primitives::Proof<::subxt::utils::H256>, + ), + runtime_types::sp_mmr_primitives::Error, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "MmrApi_generate_proof", + types::GenerateProof { + block_numbers, + best_known_block_number, + }, + [ + 180u8, 123u8, 115u8, 227u8, 101u8, 119u8, 103u8, 230u8, 66u8, 255u8, + 15u8, 197u8, 60u8, 180u8, 27u8, 47u8, 73u8, 121u8, 179u8, 219u8, 161u8, + 37u8, 57u8, 131u8, 104u8, 106u8, 206u8, 230u8, 168u8, 185u8, 206u8, + 32u8, + ], + ) + } + #[doc = " Verify MMR proof against on-chain MMR for a batch of leaves."] + #[doc = ""] + #[doc = " Note this function will use on-chain MMR root hash and check if the proof matches the hash."] + #[doc = " Note, the leaves should be sorted such that corresponding leaves and leaf indices have the"] + #[doc = " same position in both the `leaves` vector and the `leaf_indices` vector contained in the [Proof]"] + pub fn verify_proof( + &self, + leaves: ::std::vec::Vec, + proof: runtime_types::sp_mmr_primitives::Proof<::subxt::utils::H256>, + ) -> ::subxt::runtime_api::Payload< + types::VerifyProof, + ::core::result::Result<(), runtime_types::sp_mmr_primitives::Error>, + > { + ::subxt::runtime_api::Payload::new_static( + "MmrApi_verify_proof", + types::VerifyProof { leaves, proof }, + [ + 118u8, 13u8, 68u8, 159u8, 27u8, 144u8, 229u8, 72u8, 88u8, 106u8, 193u8, + 86u8, 228u8, 243u8, 28u8, 243u8, 99u8, 241u8, 153u8, 169u8, 121u8, + 139u8, 60u8, 244u8, 153u8, 110u8, 239u8, 149u8, 122u8, 164u8, 53u8, + 9u8, + ], + ) + } + #[doc = " Verify MMR proof against given root hash for a batch of leaves."] + #[doc = ""] + #[doc = " Note this function does not require any on-chain storage - the"] + #[doc = " proof is verified against given MMR root hash."] + #[doc = ""] + #[doc = " Note, the leaves should be sorted such that corresponding leaves and leaf indices have the"] + #[doc = " same position in both the `leaves` vector and the `leaf_indices` vector contained in the [Proof]"] + pub fn verify_proof_stateless( + &self, + root: ::subxt::utils::H256, + leaves: ::std::vec::Vec, + proof: runtime_types::sp_mmr_primitives::Proof<::subxt::utils::H256>, + ) -> ::subxt::runtime_api::Payload< + types::VerifyProofStateless, + ::core::result::Result<(), runtime_types::sp_mmr_primitives::Error>, + > { + ::subxt::runtime_api::Payload::new_static( + "MmrApi_verify_proof_stateless", + types::VerifyProofStateless { + root, + leaves, + proof, + }, + [ + 152u8, 237u8, 225u8, 199u8, 238u8, 151u8, 87u8, 236u8, 210u8, 38u8, + 168u8, 160u8, 166u8, 27u8, 186u8, 227u8, 160u8, 154u8, 120u8, 127u8, + 98u8, 247u8, 111u8, 99u8, 211u8, 236u8, 39u8, 221u8, 250u8, 110u8, + 232u8, 0u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct MmrRoot {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct MmrLeafCount {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct GenerateProof { + pub block_numbers: ::std::vec::Vec<::core::primitive::u32>, + pub best_known_block_number: ::core::option::Option<::core::primitive::u32>, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct VerifyProof { + pub leaves: + ::std::vec::Vec, + pub proof: runtime_types::sp_mmr_primitives::Proof<::subxt::utils::H256>, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct VerifyProofStateless { + pub root: ::subxt::utils::H256, + pub leaves: + ::std::vec::Vec, + pub proof: runtime_types::sp_mmr_primitives::Proof<::subxt::utils::H256>, + } + } + } + pub mod grandpa_api { + use super::root_mod; + use super::runtime_types; + #[doc = " APIs for integrating the GRANDPA finality gadget into runtimes."] + #[doc = " This should be implemented on the runtime side."] + #[doc = ""] + #[doc = " This is primarily used for negotiating authority-set changes for the"] + #[doc = " gadget. GRANDPA uses a signaling model of changing authority sets:"] + #[doc = " changes should be signaled with a delay of N blocks, and then automatically"] + #[doc = " applied in the runtime after those N blocks have passed."] + #[doc = ""] + #[doc = " The consensus protocol will coordinate the handoff externally."] + pub struct GrandpaApi; + impl GrandpaApi { + #[doc = " Get the current GRANDPA authorities and weights. This should not change except"] + #[doc = " for when changes are scheduled and the corresponding delay has passed."] + #[doc = ""] + #[doc = " When called at block B, it will return the set of authorities that should be"] + #[doc = " used to finalize descendants of this block (B+1, B+2, ...). The block B itself"] + #[doc = " is finalized by the authorities from block B-1."] + pub fn grandpa_authorities( + &self, + ) -> ::subxt::runtime_api::Payload< + types::GrandpaAuthorities, + ::std::vec::Vec<( + runtime_types::sp_consensus_grandpa::app::Public, + ::core::primitive::u64, + )>, + > { + ::subxt::runtime_api::Payload::new_static( + "GrandpaApi_grandpa_authorities", + types::GrandpaAuthorities {}, + [ + 78u8, 213u8, 85u8, 178u8, 49u8, 70u8, 10u8, 221u8, 93u8, 91u8, 250u8, + 59u8, 80u8, 141u8, 62u8, 126u8, 55u8, 235u8, 163u8, 12u8, 21u8, 199u8, + 240u8, 209u8, 95u8, 63u8, 65u8, 73u8, 141u8, 42u8, 78u8, 154u8, + ], + ) + } + #[doc = " Submits an unsigned extrinsic to report an equivocation. The caller"] + #[doc = " must provide the equivocation proof and a key ownership proof"] + #[doc = " (should be obtained using `generate_key_ownership_proof`). The"] + #[doc = " extrinsic will be unsigned and should only be accepted for local"] + #[doc = " authorship (not to be broadcast to the network). This method returns"] + #[doc = " `None` when creation of the extrinsic fails, e.g. if equivocation"] + #[doc = " reporting is disabled for the given runtime (i.e. this method is"] + #[doc = " hardcoded to return `None`). Only useful in an offchain context."] + pub fn submit_report_equivocation_unsigned_extrinsic( + &self, + equivocation_proof: runtime_types::sp_consensus_grandpa::EquivocationProof< + ::subxt::utils::H256, + ::core::primitive::u32, + >, + key_owner_proof: runtime_types::sp_consensus_grandpa::OpaqueKeyOwnershipProof, + ) -> ::subxt::runtime_api::Payload< + types::SubmitReportEquivocationUnsignedExtrinsic, + ::core::option::Option<()>, + > { + ::subxt::runtime_api::Payload::new_static( + "GrandpaApi_submit_report_equivocation_unsigned_extrinsic", + types::SubmitReportEquivocationUnsignedExtrinsic { + equivocation_proof, + key_owner_proof, + }, + [ + 226u8, 83u8, 137u8, 173u8, 45u8, 138u8, 210u8, 202u8, 113u8, 196u8, + 110u8, 68u8, 31u8, 192u8, 127u8, 100u8, 125u8, 225u8, 30u8, 252u8, + 160u8, 109u8, 251u8, 96u8, 52u8, 214u8, 38u8, 91u8, 158u8, 71u8, 125u8, + 220u8, + ], + ) + } + #[doc = " Generates a proof of key ownership for the given authority in the"] + #[doc = " given set. An example usage of this module is coupled with the"] + #[doc = " session historical module to prove that a given authority key is"] + #[doc = " tied to a given staking identity during a specific session. Proofs"] + #[doc = " of key ownership are necessary for submitting equivocation reports."] + #[doc = " NOTE: even though the API takes a `set_id` as parameter the current"] + #[doc = " implementations ignore this parameter and instead rely on this"] + #[doc = " method being called at the correct block height, i.e. any point at"] + #[doc = " which the given set id is live on-chain. Future implementations will"] + #[doc = " instead use indexed data through an offchain worker, not requiring"] + #[doc = " older states to be available."] + pub fn generate_key_ownership_proof( + &self, + set_id: ::core::primitive::u64, + authority_id: runtime_types::sp_consensus_grandpa::app::Public, + ) -> ::subxt::runtime_api::Payload< + types::GenerateKeyOwnershipProof, + ::core::option::Option< + runtime_types::sp_consensus_grandpa::OpaqueKeyOwnershipProof, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "GrandpaApi_generate_key_ownership_proof", + types::GenerateKeyOwnershipProof { + set_id, + authority_id, + }, + [ + 149u8, 80u8, 146u8, 102u8, 63u8, 184u8, 111u8, 153u8, 143u8, 71u8, + 109u8, 162u8, 117u8, 45u8, 139u8, 245u8, 154u8, 252u8, 117u8, 224u8, + 10u8, 6u8, 143u8, 137u8, 58u8, 213u8, 215u8, 110u8, 180u8, 142u8, + 234u8, 182u8, + ], + ) + } + #[doc = " Get current GRANDPA authority set id."] + pub fn current_set_id( + &self, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "GrandpaApi_current_set_id", + types::CurrentSetId {}, + [ + 39u8, 245u8, 166u8, 229u8, 239u8, 200u8, 179u8, 64u8, 193u8, 93u8, + 41u8, 40u8, 208u8, 231u8, 75u8, 197u8, 45u8, 119u8, 131u8, 245u8, 84u8, + 249u8, 60u8, 7u8, 180u8, 176u8, 119u8, 130u8, 247u8, 134u8, 211u8, + 240u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct GrandpaAuthorities {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct SubmitReportEquivocationUnsignedExtrinsic { + pub equivocation_proof: runtime_types::sp_consensus_grandpa::EquivocationProof< + ::subxt::utils::H256, + ::core::primitive::u32, + >, + pub key_owner_proof: + runtime_types::sp_consensus_grandpa::OpaqueKeyOwnershipProof, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct GenerateKeyOwnershipProof { + pub set_id: ::core::primitive::u64, + pub authority_id: runtime_types::sp_consensus_grandpa::app::Public, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct CurrentSetId {} + } + } + pub mod babe_api { + use super::root_mod; + use super::runtime_types; + #[doc = " API necessary for block authorship with BABE."] + pub struct BabeApi; + impl BabeApi { + #[doc = " Return the configuration for BABE."] + pub fn configuration( + &self, + ) -> ::subxt::runtime_api::Payload< + types::Configuration, + runtime_types::sp_consensus_babe::BabeConfiguration, + > { + ::subxt::runtime_api::Payload::new_static( + "BabeApi_configuration", + types::Configuration {}, + [ + 101u8, 27u8, 68u8, 108u8, 36u8, 12u8, 205u8, 58u8, 238u8, 195u8, 171u8, + 167u8, 248u8, 76u8, 92u8, 226u8, 241u8, 192u8, 151u8, 31u8, 6u8, 200u8, + 69u8, 180u8, 107u8, 134u8, 221u8, 99u8, 237u8, 223u8, 50u8, 175u8, + ], + ) + } + #[doc = " Returns the slot that started the current epoch."] + pub fn current_epoch_start( + &self, + ) -> ::subxt::runtime_api::Payload< + types::CurrentEpochStart, + runtime_types::sp_consensus_slots::Slot, + > { + ::subxt::runtime_api::Payload::new_static( + "BabeApi_current_epoch_start", + types::CurrentEpochStart {}, + [ + 67u8, 178u8, 67u8, 242u8, 228u8, 74u8, 93u8, 166u8, 160u8, 9u8, 109u8, + 174u8, 12u8, 82u8, 239u8, 200u8, 96u8, 54u8, 235u8, 184u8, 159u8, + 221u8, 72u8, 244u8, 83u8, 24u8, 239u8, 24u8, 152u8, 177u8, 211u8, + 205u8, + ], + ) + } + #[doc = " Returns information regarding the current epoch."] + pub fn current_epoch( + &self, + ) -> ::subxt::runtime_api::Payload< + types::CurrentEpoch, + runtime_types::sp_consensus_babe::Epoch, + > { + ::subxt::runtime_api::Payload::new_static( + "BabeApi_current_epoch", + types::CurrentEpoch {}, + [ + 166u8, 104u8, 201u8, 148u8, 149u8, 137u8, 223u8, 165u8, 82u8, 4u8, + 130u8, 58u8, 52u8, 193u8, 201u8, 80u8, 120u8, 212u8, 76u8, 221u8, 11u8, + 131u8, 115u8, 8u8, 9u8, 59u8, 191u8, 165u8, 148u8, 24u8, 194u8, 162u8, + ], + ) + } + #[doc = " Returns information regarding the next epoch (which was already"] + #[doc = " previously announced)."] + pub fn next_epoch( + &self, + ) -> ::subxt::runtime_api::Payload< + types::NextEpoch, + runtime_types::sp_consensus_babe::Epoch, + > { + ::subxt::runtime_api::Payload::new_static( + "BabeApi_next_epoch", + types::NextEpoch {}, + [ + 251u8, 29u8, 230u8, 254u8, 174u8, 38u8, 55u8, 30u8, 93u8, 42u8, 254u8, + 172u8, 183u8, 250u8, 104u8, 211u8, 79u8, 211u8, 55u8, 98u8, 253u8, + 73u8, 137u8, 185u8, 116u8, 94u8, 20u8, 232u8, 224u8, 136u8, 86u8, + 182u8, + ], + ) + } + #[doc = " Generates a proof of key ownership for the given authority in the"] + #[doc = " current epoch. An example usage of this module is coupled with the"] + #[doc = " session historical module to prove that a given authority key is"] + #[doc = " tied to a given staking identity during a specific session. Proofs"] + #[doc = " of key ownership are necessary for submitting equivocation reports."] + #[doc = " NOTE: even though the API takes a `slot` as parameter the current"] + #[doc = " implementations ignores this parameter and instead relies on this"] + #[doc = " method being called at the correct block height, i.e. any point at"] + #[doc = " which the epoch for the given slot is live on-chain. Future"] + #[doc = " implementations will instead use indexed data through an offchain"] + #[doc = " worker, not requiring older states to be available."] + pub fn generate_key_ownership_proof( + &self, + slot: runtime_types::sp_consensus_slots::Slot, + authority_id: runtime_types::sp_consensus_babe::app::Public, + ) -> ::subxt::runtime_api::Payload< + types::GenerateKeyOwnershipProof, + ::core::option::Option< + runtime_types::sp_consensus_babe::OpaqueKeyOwnershipProof, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "BabeApi_generate_key_ownership_proof", + types::GenerateKeyOwnershipProof { slot, authority_id }, + [ + 16u8, 78u8, 1u8, 172u8, 172u8, 253u8, 240u8, 175u8, 90u8, 130u8, 90u8, + 69u8, 249u8, 12u8, 192u8, 134u8, 131u8, 248u8, 186u8, 166u8, 240u8, + 182u8, 177u8, 0u8, 107u8, 151u8, 200u8, 41u8, 157u8, 150u8, 162u8, + 244u8, + ], + ) + } + #[doc = " Submits an unsigned extrinsic to report an equivocation. The caller"] + #[doc = " must provide the equivocation proof and a key ownership proof"] + #[doc = " (should be obtained using `generate_key_ownership_proof`). The"] + #[doc = " extrinsic will be unsigned and should only be accepted for local"] + #[doc = " authorship (not to be broadcast to the network). This method returns"] + #[doc = " `None` when creation of the extrinsic fails, e.g. if equivocation"] + #[doc = " reporting is disabled for the given runtime (i.e. this method is"] + #[doc = " hardcoded to return `None`). Only useful in an offchain context."] + pub fn submit_report_equivocation_unsigned_extrinsic( + &self, + equivocation_proof: runtime_types::sp_consensus_slots::EquivocationProof< + runtime_types::sp_runtime::generic::header::Header< + ::core::primitive::u32, + runtime_types::sp_runtime::traits::BlakeTwo256, + >, + runtime_types::sp_consensus_babe::app::Public, + >, + key_owner_proof: runtime_types::sp_consensus_babe::OpaqueKeyOwnershipProof, + ) -> ::subxt::runtime_api::Payload< + types::SubmitReportEquivocationUnsignedExtrinsic, + ::core::option::Option<()>, + > { + ::subxt::runtime_api::Payload::new_static( + "BabeApi_submit_report_equivocation_unsigned_extrinsic", + types::SubmitReportEquivocationUnsignedExtrinsic { + equivocation_proof, + key_owner_proof, + }, + [ + 255u8, 136u8, 248u8, 244u8, 155u8, 51u8, 20u8, 157u8, 93u8, 19u8, 24u8, + 170u8, 72u8, 199u8, 222u8, 111u8, 164u8, 126u8, 159u8, 209u8, 198u8, + 37u8, 113u8, 12u8, 36u8, 117u8, 131u8, 7u8, 130u8, 85u8, 177u8, 109u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Configuration {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct CurrentEpochStart {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct CurrentEpoch {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct NextEpoch {} + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct GenerateKeyOwnershipProof { + pub slot: runtime_types::sp_consensus_slots::Slot, + pub authority_id: runtime_types::sp_consensus_babe::app::Public, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct SubmitReportEquivocationUnsignedExtrinsic { + pub equivocation_proof: runtime_types::sp_consensus_slots::EquivocationProof< + runtime_types::sp_runtime::generic::header::Header< + ::core::primitive::u32, + runtime_types::sp_runtime::traits::BlakeTwo256, + >, + runtime_types::sp_consensus_babe::app::Public, + >, + pub key_owner_proof: runtime_types::sp_consensus_babe::OpaqueKeyOwnershipProof, + } + } + } + pub mod authority_discovery_api { + use super::root_mod; + use super::runtime_types; + #[doc = " The authority discovery api."] + #[doc = ""] + #[doc = " This api is used by the `client/authority-discovery` module to retrieve identifiers"] + #[doc = " of the current and next authority set."] + pub struct AuthorityDiscoveryApi; + impl AuthorityDiscoveryApi { + #[doc = " Retrieve authority identifiers of the current and next authority set."] + pub fn authorities( + &self, + ) -> ::subxt::runtime_api::Payload< + types::Authorities, + ::std::vec::Vec, + > { + ::subxt::runtime_api::Payload::new_static( + "AuthorityDiscoveryApi_authorities", + types::Authorities {}, + [ + 104u8, 50u8, 187u8, 116u8, 97u8, 112u8, 203u8, 212u8, 27u8, 108u8, + 253u8, 8u8, 103u8, 104u8, 63u8, 176u8, 178u8, 179u8, 154u8, 104u8, + 167u8, 241u8, 76u8, 136u8, 102u8, 130u8, 88u8, 115u8, 104u8, 64u8, + 224u8, 98u8, + ], + ) + } + } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Authorities {} } - if pallet_name == "Ump" { - let variant_error = ump::Error::decode_with_metadata(cursor, 760u32, metadata)?; - return Ok(Error::Ump(variant_error)); + } + pub mod session_keys { + use super::root_mod; + use super::runtime_types; + #[doc = " Session keys runtime api."] + pub struct SessionKeys; + impl SessionKeys { + #[doc = " Generate a set of session keys with optionally using the given seed."] + #[doc = " The keys should be stored within the keystore exposed via runtime"] + #[doc = " externalities."] + #[doc = ""] + #[doc = " The seed needs to be a valid `utf8` string."] + #[doc = ""] + #[doc = " Returns the concatenated SCALE encoded public keys."] + pub fn generate_session_keys( + &self, + seed: ::core::option::Option<::std::vec::Vec<::core::primitive::u8>>, + ) -> ::subxt::runtime_api::Payload< + types::GenerateSessionKeys, + ::std::vec::Vec<::core::primitive::u8>, + > { + ::subxt::runtime_api::Payload::new_static( + "SessionKeys_generate_session_keys", + types::GenerateSessionKeys { seed }, + [ + 238u8, 35u8, 56u8, 56u8, 5u8, 183u8, 237u8, 233u8, 220u8, 77u8, 245u8, + 218u8, 120u8, 21u8, 3u8, 95u8, 106u8, 140u8, 212u8, 37u8, 14u8, 180u8, + 24u8, 11u8, 137u8, 193u8, 111u8, 91u8, 235u8, 127u8, 202u8, 230u8, + ], + ) + } + #[doc = " Decode the given public session keys."] + #[doc = ""] + #[doc = " Returns the list of public raw public keys + key type."] + pub fn decode_session_keys( + &self, + encoded: ::std::vec::Vec<::core::primitive::u8>, + ) -> ::subxt::runtime_api::Payload< + types::DecodeSessionKeys, + ::core::option::Option< + ::std::vec::Vec<( + ::std::vec::Vec<::core::primitive::u8>, + runtime_types::sp_core::crypto::KeyTypeId, + )>, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "SessionKeys_decode_session_keys", + types::DecodeSessionKeys { encoded }, + [ + 134u8, 106u8, 224u8, 190u8, 133u8, 212u8, 253u8, 184u8, 222u8, 76u8, + 44u8, 75u8, 168u8, 18u8, 3u8, 169u8, 32u8, 8u8, 46u8, 5u8, 155u8, 45u8, + 149u8, 144u8, 41u8, 174u8, 130u8, 133u8, 22u8, 150u8, 89u8, 196u8, + ], + ) + } } - if pallet_name == "Hrmp" { - let variant_error = hrmp::Error::decode_with_metadata(cursor, 768u32, metadata)?; - return Ok(Error::Hrmp(variant_error)); + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct GenerateSessionKeys { + pub seed: ::core::option::Option<::std::vec::Vec<::core::primitive::u8>>, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct DecodeSessionKeys { + pub encoded: ::std::vec::Vec<::core::primitive::u8>, + } } - if pallet_name == "ParasDisputes" { - let variant_error = - paras_disputes::Error::decode_with_metadata(cursor, 777u32, metadata)?; - return Ok(Error::ParasDisputes(variant_error)); + } + pub mod account_nonce_api { + use super::root_mod; + use super::runtime_types; + #[doc = " The API to query account nonce (aka transaction index)."] + pub struct AccountNonceApi; + impl AccountNonceApi { + #[doc = " Get current account nonce of given `AccountId`."] + pub fn account_nonce( + &self, + account: ::subxt::utils::AccountId32, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "AccountNonceApi_account_nonce", + types::AccountNonce { account }, + [ + 115u8, 50u8, 18u8, 201u8, 220u8, 171u8, 244u8, 16u8, 58u8, 183u8, + 173u8, 196u8, 253u8, 239u8, 241u8, 100u8, 246u8, 179u8, 50u8, 32u8, + 22u8, 245u8, 109u8, 191u8, 232u8, 76u8, 152u8, 87u8, 156u8, 187u8, + 175u8, 202u8, + ], + ) + } } - if pallet_name == "Registrar" { - let variant_error = - registrar::Error::decode_with_metadata(cursor, 779u32, metadata)?; - return Ok(Error::Registrar(variant_error)); + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct AccountNonce { + pub account: ::subxt::utils::AccountId32, + } } - if pallet_name == "Slots" { - let variant_error = slots::Error::decode_with_metadata(cursor, 781u32, metadata)?; - return Ok(Error::Slots(variant_error)); + } + pub mod transaction_payment_api { + use super::root_mod; + use super::runtime_types; + pub struct TransactionPaymentApi; + impl TransactionPaymentApi { + pub fn query_info( + &self, + uxt : runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) >, + len: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload< + types::QueryInfo, + runtime_types::pallet_transaction_payment::types::RuntimeDispatchInfo< + ::core::primitive::u128, + runtime_types::sp_weights::weight_v2::Weight, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "TransactionPaymentApi_query_info", + types::QueryInfo { uxt, len }, + [ + 157u8, 139u8, 132u8, 17u8, 44u8, 153u8, 215u8, 139u8, 196u8, 107u8, + 225u8, 39u8, 78u8, 134u8, 147u8, 168u8, 134u8, 89u8, 51u8, 144u8, + 101u8, 117u8, 35u8, 131u8, 108u8, 17u8, 74u8, 1u8, 167u8, 7u8, 165u8, + 98u8, + ], + ) + } + pub fn query_fee_details( + &self, + uxt : runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) >, + len: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload< + types::QueryFeeDetails, + runtime_types::pallet_transaction_payment::types::FeeDetails< + ::core::primitive::u128, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "TransactionPaymentApi_query_fee_details", + types::QueryFeeDetails { uxt, len }, + [ + 113u8, 100u8, 16u8, 128u8, 108u8, 95u8, 91u8, 255u8, 46u8, 255u8, 52u8, + 225u8, 92u8, 186u8, 175u8, 126u8, 96u8, 25u8, 206u8, 207u8, 16u8, 94u8, + 204u8, 138u8, 227u8, 38u8, 125u8, 14u8, 38u8, 58u8, 84u8, 71u8, + ], + ) + } + pub fn query_weight_to_fee( + &self, + weight: runtime_types::sp_weights::weight_v2::Weight, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "TransactionPaymentApi_query_weight_to_fee", + types::QueryWeightToFee { weight }, + [ + 179u8, 108u8, 155u8, 39u8, 134u8, 220u8, 72u8, 45u8, 230u8, 232u8, + 150u8, 146u8, 61u8, 198u8, 145u8, 250u8, 19u8, 157u8, 204u8, 217u8, + 111u8, 171u8, 197u8, 21u8, 75u8, 6u8, 16u8, 26u8, 244u8, 101u8, 134u8, + 95u8, + ], + ) + } + pub fn query_length_to_fee( + &self, + length: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "TransactionPaymentApi_query_length_to_fee", + types::QueryLengthToFee { length }, + [ + 228u8, 141u8, 164u8, 186u8, 169u8, 249u8, 75u8, 2u8, 160u8, 73u8, 73u8, + 214u8, 141u8, 76u8, 180u8, 222u8, 230u8, 161u8, 131u8, 88u8, 25u8, + 192u8, 77u8, 124u8, 158u8, 113u8, 72u8, 147u8, 13u8, 11u8, 42u8, 30u8, + ], + ) + } } - if pallet_name == "Auctions" { - let variant_error = - auctions::Error::decode_with_metadata(cursor, 786u32, metadata)?; - return Ok(Error::Auctions(variant_error)); + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct QueryInfo { pub uxt : runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > , pub len : :: core :: primitive :: u32 , } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct QueryFeeDetails { pub uxt : runtime_types :: sp_runtime :: generic :: unchecked_extrinsic :: UncheckedExtrinsic < :: subxt :: utils :: MultiAddress < :: subxt :: utils :: AccountId32 , () > , runtime_types :: polkadot_runtime :: RuntimeCall , runtime_types :: sp_runtime :: MultiSignature , (runtime_types :: frame_system :: extensions :: check_non_zero_sender :: CheckNonZeroSender , runtime_types :: frame_system :: extensions :: check_spec_version :: CheckSpecVersion , runtime_types :: frame_system :: extensions :: check_tx_version :: CheckTxVersion , runtime_types :: frame_system :: extensions :: check_genesis :: CheckGenesis , runtime_types :: frame_system :: extensions :: check_mortality :: CheckMortality , runtime_types :: frame_system :: extensions :: check_nonce :: CheckNonce , runtime_types :: frame_system :: extensions :: check_weight :: CheckWeight , runtime_types :: pallet_transaction_payment :: ChargeTransactionPayment , runtime_types :: polkadot_runtime_common :: claims :: PrevalidateAttests ,) > , pub len : :: core :: primitive :: u32 , } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct QueryWeightToFee { + pub weight: runtime_types::sp_weights::weight_v2::Weight, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct QueryLengthToFee { + pub length: ::core::primitive::u32, + } } - if pallet_name == "Crowdloan" { - let variant_error = - crowdloan::Error::decode_with_metadata(cursor, 789u32, metadata)?; - return Ok(Error::Crowdloan(variant_error)); + } + pub mod transaction_payment_call_api { + use super::root_mod; + use super::runtime_types; + pub struct TransactionPaymentCallApi; + impl TransactionPaymentCallApi { + #[doc = " Query information of a dispatch class, weight, and fee of a given encoded `Call`."] + pub fn query_call_info( + &self, + call: runtime_types::polkadot_runtime::RuntimeCall, + len: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload< + types::QueryCallInfo, + runtime_types::pallet_transaction_payment::types::RuntimeDispatchInfo< + ::core::primitive::u128, + runtime_types::sp_weights::weight_v2::Weight, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "TransactionPaymentCallApi_query_call_info", + types::QueryCallInfo { call, len }, + [ + 151u8, 40u8, 199u8, 73u8, 193u8, 248u8, 30u8, 24u8, 71u8, 196u8, 235u8, + 10u8, 211u8, 120u8, 228u8, 29u8, 101u8, 175u8, 200u8, 196u8, 70u8, + 44u8, 112u8, 209u8, 175u8, 246u8, 148u8, 118u8, 84u8, 127u8, 185u8, + 163u8, + ], + ) + } + #[doc = " Query fee details of a given encoded `Call`."] + pub fn query_call_fee_details( + &self, + call: runtime_types::polkadot_runtime::RuntimeCall, + len: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload< + types::QueryCallFeeDetails, + runtime_types::pallet_transaction_payment::types::FeeDetails< + ::core::primitive::u128, + >, + > { + ::subxt::runtime_api::Payload::new_static( + "TransactionPaymentCallApi_query_call_fee_details", + types::QueryCallFeeDetails { call, len }, + [ + 56u8, 220u8, 173u8, 0u8, 48u8, 27u8, 228u8, 70u8, 139u8, 236u8, 142u8, + 142u8, 192u8, 147u8, 216u8, 185u8, 152u8, 219u8, 185u8, 189u8, 166u8, + 110u8, 224u8, 32u8, 94u8, 53u8, 248u8, 216u8, 90u8, 152u8, 63u8, 148u8, + ], + ) + } + #[doc = " Query the output of the current `WeightToFee` given some input."] + pub fn query_weight_to_fee( + &self, + weight: runtime_types::sp_weights::weight_v2::Weight, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "TransactionPaymentCallApi_query_weight_to_fee", + types::QueryWeightToFee { weight }, + [ + 235u8, 177u8, 255u8, 102u8, 0u8, 237u8, 63u8, 37u8, 144u8, 142u8, 86u8, + 43u8, 82u8, 41u8, 25u8, 149u8, 75u8, 238u8, 118u8, 216u8, 84u8, 241u8, + 54u8, 157u8, 81u8, 246u8, 140u8, 240u8, 210u8, 208u8, 235u8, 172u8, + ], + ) + } + #[doc = " Query the output of the current `LengthToFee` given some input."] + pub fn query_length_to_fee( + &self, + length: ::core::primitive::u32, + ) -> ::subxt::runtime_api::Payload + { + ::subxt::runtime_api::Payload::new_static( + "TransactionPaymentCallApi_query_length_to_fee", + types::QueryLengthToFee { length }, + [ + 188u8, 80u8, 192u8, 251u8, 47u8, 200u8, 60u8, 10u8, 214u8, 47u8, 137u8, + 111u8, 226u8, 163u8, 60u8, 177u8, 190u8, 210u8, 57u8, 89u8, 34u8, + 154u8, 190u8, 244u8, 132u8, 129u8, 212u8, 121u8, 43u8, 190u8, 71u8, + 237u8, + ], + ) + } } - if pallet_name == "XcmPallet" { - let variant_error = - xcm_pallet::Error::decode_with_metadata(cursor, 808u32, metadata)?; - return Ok(Error::XcmPallet(variant_error)); + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct QueryCallInfo { + pub call: runtime_types::polkadot_runtime::RuntimeCall, + pub len: ::core::primitive::u32, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct QueryCallFeeDetails { + pub call: runtime_types::polkadot_runtime::RuntimeCall, + pub len: ::core::primitive::u32, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct QueryWeightToFee { + pub weight: runtime_types::sp_weights::weight_v2::Weight, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct QueryLengthToFee { + pub length: ::core::primitive::u32, + } } - Err(::subxt::ext::scale_decode::Error::custom(format!( - "Pallet name '{}' not found in root Error enum", - pallet_name - )) - .into()) } } - pub fn constants() -> ConstantsApi { - ConstantsApi - } - pub fn storage() -> StorageApi { - StorageApi - } - pub fn tx() -> TransactionApi { - TransactionApi - } - pub fn apis() -> runtime_apis::RuntimeApi { - runtime_apis::RuntimeApi - } - pub mod runtime_apis { - use super::root_mod; - use super::runtime_types; - use subxt::ext::codec::Encode; - pub struct RuntimeApi; - impl RuntimeApi {} - } pub struct ConstantsApi; impl ConstantsApi { pub fn system(&self) -> system::constants::ConstantsApi { @@ -1283,6 +4366,7 @@ pub mod api { #[doc = "Error for the System pallet"] pub type Error = runtime_types::frame_system::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::frame_system::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -1302,6 +4386,10 @@ pub mod api { pub struct Remark { pub remark: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for Remark { + const PALLET: &'static str = "System"; + const CALL: &'static str = "remark"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -1316,6 +4404,10 @@ pub mod api { pub struct SetHeapPages { pub pages: ::core::primitive::u64, } + impl ::subxt::blocks::StaticExtrinsic for SetHeapPages { + const PALLET: &'static str = "System"; + const CALL: &'static str = "set_heap_pages"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -1329,6 +4421,10 @@ pub mod api { pub struct SetCode { pub code: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for SetCode { + const PALLET: &'static str = "System"; + const CALL: &'static str = "set_code"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -1342,6 +4438,10 @@ pub mod api { pub struct SetCodeWithoutChecks { pub code: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for SetCodeWithoutChecks { + const PALLET: &'static str = "System"; + const CALL: &'static str = "set_code_without_checks"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -1358,6 +4458,10 @@ pub mod api { ::std::vec::Vec<::core::primitive::u8>, )>, } + impl ::subxt::blocks::StaticExtrinsic for SetStorage { + const PALLET: &'static str = "System"; + const CALL: &'static str = "set_storage"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -1371,6 +4475,10 @@ pub mod api { pub struct KillStorage { pub keys: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, } + impl ::subxt::blocks::StaticExtrinsic for KillStorage { + const PALLET: &'static str = "System"; + const CALL: &'static str = "kill_storage"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -1385,6 +4493,10 @@ pub mod api { pub prefix: ::std::vec::Vec<::core::primitive::u8>, pub subkeys: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for KillPrefix { + const PALLET: &'static str = "System"; + const CALL: &'static str = "kill_prefix"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -1398,6 +4510,10 @@ pub mod api { pub struct RemarkWithEvent { pub remark: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for RemarkWithEvent { + const PALLET: &'static str = "System"; + const CALL: &'static str = "remark_with_event"; + } } pub struct TransactionApi; impl TransactionApi { @@ -2259,6 +5375,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_scheduler::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_scheduler::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -2282,6 +5399,10 @@ pub mod api { pub priority: ::core::primitive::u8, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for Schedule { + const PALLET: &'static str = "Scheduler"; + const CALL: &'static str = "schedule"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -2296,6 +5417,10 @@ pub mod api { pub when: ::core::primitive::u32, pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Cancel { + const PALLET: &'static str = "Scheduler"; + const CALL: &'static str = "cancel"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -2314,6 +5439,10 @@ pub mod api { pub priority: ::core::primitive::u8, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for ScheduleNamed { + const PALLET: &'static str = "Scheduler"; + const CALL: &'static str = "schedule_named"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -2327,6 +5456,10 @@ pub mod api { pub struct CancelNamed { pub id: [::core::primitive::u8; 32usize], } + impl ::subxt::blocks::StaticExtrinsic for CancelNamed { + const PALLET: &'static str = "Scheduler"; + const CALL: &'static str = "cancel_named"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -2344,6 +5477,10 @@ pub mod api { pub priority: ::core::primitive::u8, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for ScheduleAfter { + const PALLET: &'static str = "Scheduler"; + const CALL: &'static str = "schedule_after"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -2362,6 +5499,10 @@ pub mod api { pub priority: ::core::primitive::u8, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for ScheduleNamedAfter { + const PALLET: &'static str = "Scheduler"; + const CALL: &'static str = "schedule_named_after"; + } } pub struct TransactionApi; impl TransactionApi { @@ -2834,6 +5975,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_preimage::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_preimage::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -2853,6 +5995,10 @@ pub mod api { pub struct NotePreimage { pub bytes: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for NotePreimage { + const PALLET: &'static str = "Preimage"; + const CALL: &'static str = "note_preimage"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -2866,6 +6012,10 @@ pub mod api { pub struct UnnotePreimage { pub hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for UnnotePreimage { + const PALLET: &'static str = "Preimage"; + const CALL: &'static str = "unnote_preimage"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -2879,6 +6029,10 @@ pub mod api { pub struct RequestPreimage { pub hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for RequestPreimage { + const PALLET: &'static str = "Preimage"; + const CALL: &'static str = "request_preimage"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -2892,6 +6046,10 @@ pub mod api { pub struct UnrequestPreimage { pub hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for UnrequestPreimage { + const PALLET: &'static str = "Preimage"; + const CALL: &'static str = "unrequest_preimage"; + } } pub struct TransactionApi; impl TransactionApi { @@ -3146,6 +6304,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_babe::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_babe::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -3174,6 +6333,10 @@ pub mod api { >, pub key_owner_proof: runtime_types::sp_session::MembershipProof, } + impl ::subxt::blocks::StaticExtrinsic for ReportEquivocation { + const PALLET: &'static str = "Babe"; + const CALL: &'static str = "report_equivocation"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -3196,6 +6359,10 @@ pub mod api { >, pub key_owner_proof: runtime_types::sp_session::MembershipProof, } + impl ::subxt::blocks::StaticExtrinsic for ReportEquivocationUnsigned { + const PALLET: &'static str = "Babe"; + const CALL: &'static str = "report_equivocation_unsigned"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -3209,6 +6376,10 @@ pub mod api { pub struct PlanConfigChange { pub config: runtime_types::sp_consensus_babe::digests::NextConfigDescriptor, } + impl ::subxt::blocks::StaticExtrinsic for PlanConfigChange { + const PALLET: &'static str = "Babe"; + const CALL: &'static str = "plan_config_change"; + } } pub struct TransactionApi; impl TransactionApi { @@ -3807,6 +6978,7 @@ pub mod api { use super::root_mod; use super::runtime_types; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_timestamp::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -3827,6 +6999,10 @@ pub mod api { #[codec(compact)] pub now: ::core::primitive::u64, } + impl ::subxt::blocks::StaticExtrinsic for Set { + const PALLET: &'static str = "Timestamp"; + const CALL: &'static str = "set"; + } } pub struct TransactionApi; impl TransactionApi { @@ -3938,6 +7114,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_indices::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_indices::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -3958,6 +7135,10 @@ pub mod api { pub struct Claim { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Claim { + const PALLET: &'static str = "Indices"; + const CALL: &'static str = "claim"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -3972,6 +7153,10 @@ pub mod api { pub new: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Transfer { + const PALLET: &'static str = "Indices"; + const CALL: &'static str = "transfer"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -3986,6 +7171,10 @@ pub mod api { pub struct Free { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Free { + const PALLET: &'static str = "Indices"; + const CALL: &'static str = "free"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4001,6 +7190,10 @@ pub mod api { pub index: ::core::primitive::u32, pub freeze: ::core::primitive::bool, } + impl ::subxt::blocks::StaticExtrinsic for ForceTransfer { + const PALLET: &'static str = "Indices"; + const CALL: &'static str = "force_transfer"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -4015,6 +7208,10 @@ pub mod api { pub struct Freeze { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Freeze { + const PALLET: &'static str = "Indices"; + const CALL: &'static str = "freeze"; + } } pub struct TransactionApi; impl TransactionApi { @@ -4309,6 +7506,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_balances::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_balances::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -4330,6 +7528,10 @@ pub mod api { #[codec(compact)] pub value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for TransferAllowDeath { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "transfer_allow_death"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4347,6 +7549,10 @@ pub mod api { #[codec(compact)] pub old_reserved: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for SetBalanceDeprecated { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "set_balance_deprecated"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4363,6 +7569,10 @@ pub mod api { #[codec(compact)] pub value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for ForceTransfer { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "force_transfer"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4378,6 +7588,10 @@ pub mod api { #[codec(compact)] pub value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for TransferKeepAlive { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "transfer_keep_alive"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4392,6 +7606,10 @@ pub mod api { pub dest: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub keep_alive: ::core::primitive::bool, } + impl ::subxt::blocks::StaticExtrinsic for TransferAll { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "transfer_all"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4406,6 +7624,10 @@ pub mod api { pub who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub amount: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for ForceUnreserve { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "force_unreserve"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4419,6 +7641,10 @@ pub mod api { pub struct UpgradeAccounts { pub who: ::std::vec::Vec<::subxt::utils::AccountId32>, } + impl ::subxt::blocks::StaticExtrinsic for UpgradeAccounts { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "upgrade_accounts"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4434,6 +7660,10 @@ pub mod api { #[codec(compact)] pub value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Transfer { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "transfer"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -4449,6 +7679,10 @@ pub mod api { #[codec(compact)] pub new_free: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for ForceSetBalance { + const PALLET: &'static str = "Balances"; + const CALL: &'static str = "force_set_balance"; + } } pub struct TransactionApi; impl TransactionApi { @@ -5632,6 +8866,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_staking::pallet::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_staking::pallet::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -5656,6 +8891,10 @@ pub mod api { ::subxt::utils::AccountId32, >, } + impl ::subxt::blocks::StaticExtrinsic for Bond { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "bond"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5670,6 +8909,10 @@ pub mod api { #[codec(compact)] pub max_additional: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for BondExtra { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "bond_extra"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5684,6 +8927,10 @@ pub mod api { #[codec(compact)] pub value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Unbond { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "unbond"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -5698,6 +8945,10 @@ pub mod api { pub struct WithdrawUnbonded { pub num_slashing_spans: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for WithdrawUnbonded { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "withdraw_unbonded"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5711,6 +8962,10 @@ pub mod api { pub struct Validate { pub prefs: runtime_types::pallet_staking::ValidatorPrefs, } + impl ::subxt::blocks::StaticExtrinsic for Validate { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "validate"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5726,6 +8981,10 @@ pub mod api { ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, >, } + impl ::subxt::blocks::StaticExtrinsic for Nominate { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "nominate"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5737,6 +8996,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct Chill; + impl ::subxt::blocks::StaticExtrinsic for Chill { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "chill"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5752,6 +9015,10 @@ pub mod api { ::subxt::utils::AccountId32, >, } + impl ::subxt::blocks::StaticExtrinsic for SetPayee { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "set_payee"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5765,6 +9032,10 @@ pub mod api { pub struct SetController { pub controller: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for SetController { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "set_controller"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5779,6 +9050,10 @@ pub mod api { #[codec(compact)] pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetValidatorCount { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "set_validator_count"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5793,6 +9068,10 @@ pub mod api { #[codec(compact)] pub additional: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for IncreaseValidatorCount { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "increase_validator_count"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5806,6 +9085,10 @@ pub mod api { pub struct ScaleValidatorCount { pub factor: runtime_types::sp_arithmetic::per_things::Percent, } + impl ::subxt::blocks::StaticExtrinsic for ScaleValidatorCount { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "scale_validator_count"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5817,6 +9100,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ForceNoEras; + impl ::subxt::blocks::StaticExtrinsic for ForceNoEras { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "force_no_eras"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5828,6 +9115,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ForceNewEra; + impl ::subxt::blocks::StaticExtrinsic for ForceNewEra { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "force_new_era"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5841,6 +9132,10 @@ pub mod api { pub struct SetInvulnerables { pub invulnerables: ::std::vec::Vec<::subxt::utils::AccountId32>, } + impl ::subxt::blocks::StaticExtrinsic for SetInvulnerables { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "set_invulnerables"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5855,6 +9150,10 @@ pub mod api { pub stash: ::subxt::utils::AccountId32, pub num_slashing_spans: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceUnstake { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "force_unstake"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5866,6 +9165,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ForceNewEraAlways; + impl ::subxt::blocks::StaticExtrinsic for ForceNewEraAlways { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "force_new_era_always"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5880,6 +9183,10 @@ pub mod api { pub era: ::core::primitive::u32, pub slash_indices: ::std::vec::Vec<::core::primitive::u32>, } + impl ::subxt::blocks::StaticExtrinsic for CancelDeferredSlash { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "cancel_deferred_slash"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5894,6 +9201,10 @@ pub mod api { pub validator_stash: ::subxt::utils::AccountId32, pub era: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for PayoutStakers { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "payout_stakers"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5908,6 +9219,10 @@ pub mod api { #[codec(compact)] pub value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Rebond { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "rebond"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5922,6 +9237,10 @@ pub mod api { pub stash: ::subxt::utils::AccountId32, pub num_slashing_spans: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ReapStash { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "reap_stash"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5937,6 +9256,10 @@ pub mod api { ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, >, } + impl ::subxt::blocks::StaticExtrinsic for Kick { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "kick"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5969,6 +9292,10 @@ pub mod api { runtime_types::sp_arithmetic::per_things::Perbill, >, } + impl ::subxt::blocks::StaticExtrinsic for SetStakingConfigs { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "set_staking_configs"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5982,6 +9309,10 @@ pub mod api { pub struct ChillOther { pub controller: ::subxt::utils::AccountId32, } + impl ::subxt::blocks::StaticExtrinsic for ChillOther { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "chill_other"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -5995,6 +9326,10 @@ pub mod api { pub struct ForceApplyMinCommission { pub validator_stash: ::subxt::utils::AccountId32, } + impl ::subxt::blocks::StaticExtrinsic for ForceApplyMinCommission { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "force_apply_min_commission"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -6008,6 +9343,10 @@ pub mod api { pub struct SetMinCommission { pub new: runtime_types::sp_arithmetic::per_things::Perbill, } + impl ::subxt::blocks::StaticExtrinsic for SetMinCommission { + const PALLET: &'static str = "Staking"; + const CALL: &'static str = "set_min_commission"; + } } pub struct TransactionApi; impl TransactionApi { @@ -8760,6 +12099,7 @@ pub mod api { #[doc = "Error for the session pallet."] pub type Error = runtime_types::pallet_session::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_session::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -8780,6 +12120,10 @@ pub mod api { pub keys: runtime_types::polkadot_runtime::SessionKeys, pub proof: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for SetKeys { + const PALLET: &'static str = "Session"; + const CALL: &'static str = "set_keys"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -8791,6 +12135,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct PurgeKeys; + impl ::subxt::blocks::StaticExtrinsic for PurgeKeys { + const PALLET: &'static str = "Session"; + const CALL: &'static str = "purge_keys"; + } } pub struct TransactionApi; impl TransactionApi { @@ -9095,6 +12443,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_grandpa::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_grandpa::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -9120,6 +12469,10 @@ pub mod api { >, pub key_owner_proof: runtime_types::sp_session::MembershipProof, } + impl ::subxt::blocks::StaticExtrinsic for ReportEquivocation { + const PALLET: &'static str = "Grandpa"; + const CALL: &'static str = "report_equivocation"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9139,6 +12492,10 @@ pub mod api { >, pub key_owner_proof: runtime_types::sp_session::MembershipProof, } + impl ::subxt::blocks::StaticExtrinsic for ReportEquivocationUnsigned { + const PALLET: &'static str = "Grandpa"; + const CALL: &'static str = "report_equivocation_unsigned"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9153,6 +12510,10 @@ pub mod api { pub delay: ::core::primitive::u32, pub best_finalized_block_number: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for NoteStalled { + const PALLET: &'static str = "Grandpa"; + const CALL: &'static str = "note_stalled"; + } } pub struct TransactionApi; impl TransactionApi { @@ -9534,6 +12895,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_im_online::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_im_online::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -9555,6 +12917,10 @@ pub mod api { runtime_types::pallet_im_online::Heartbeat<::core::primitive::u32>, pub signature: runtime_types::pallet_im_online::sr25519::app_sr25519::Signature, } + impl ::subxt::blocks::StaticExtrinsic for Heartbeat { + const PALLET: &'static str = "ImOnline"; + const CALL: &'static str = "heartbeat"; + } } pub struct TransactionApi; impl TransactionApi { @@ -9851,6 +13217,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_democracy::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_democracy::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -9874,6 +13241,10 @@ pub mod api { #[codec(compact)] pub value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Propose { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "propose"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9888,6 +13259,10 @@ pub mod api { #[codec(compact)] pub proposal: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Second { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "second"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9904,6 +13279,10 @@ pub mod api { pub vote: runtime_types::pallet_democracy::vote::AccountVote<::core::primitive::u128>, } + impl ::subxt::blocks::StaticExtrinsic for Vote { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "vote"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -9918,6 +13297,10 @@ pub mod api { pub struct EmergencyCancel { pub ref_index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for EmergencyCancel { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "emergency_cancel"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9933,6 +13316,10 @@ pub mod api { runtime_types::polkadot_runtime::RuntimeCall, >, } + impl ::subxt::blocks::StaticExtrinsic for ExternalPropose { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "external_propose"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9948,6 +13335,10 @@ pub mod api { runtime_types::polkadot_runtime::RuntimeCall, >, } + impl ::subxt::blocks::StaticExtrinsic for ExternalProposeMajority { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "external_propose_majority"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9963,6 +13354,10 @@ pub mod api { runtime_types::polkadot_runtime::RuntimeCall, >, } + impl ::subxt::blocks::StaticExtrinsic for ExternalProposeDefault { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "external_propose_default"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9978,6 +13373,10 @@ pub mod api { pub voting_period: ::core::primitive::u32, pub delay: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for FastTrack { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "fast_track"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -9991,6 +13390,10 @@ pub mod api { pub struct VetoExternal { pub proposal_hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for VetoExternal { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "veto_external"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10005,6 +13408,10 @@ pub mod api { #[codec(compact)] pub ref_index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for CancelReferendum { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "cancel_referendum"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10020,6 +13427,10 @@ pub mod api { pub conviction: runtime_types::pallet_democracy::conviction::Conviction, pub balance: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Delegate { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "delegate"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10031,6 +13442,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct Undelegate; + impl ::subxt::blocks::StaticExtrinsic for Undelegate { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "undelegate"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10042,6 +13457,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ClearPublicProposals; + impl ::subxt::blocks::StaticExtrinsic for ClearPublicProposals { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "clear_public_proposals"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10055,6 +13474,10 @@ pub mod api { pub struct Unlock { pub target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for Unlock { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "unlock"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -10069,6 +13492,10 @@ pub mod api { pub struct RemoveVote { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RemoveVote { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "remove_vote"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10083,6 +13510,10 @@ pub mod api { pub target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RemoveOtherVote { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "remove_other_vote"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10097,6 +13528,10 @@ pub mod api { pub proposal_hash: ::subxt::utils::H256, pub maybe_ref_index: ::core::option::Option<::core::primitive::u32>, } + impl ::subxt::blocks::StaticExtrinsic for Blacklist { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "blacklist"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10111,6 +13546,10 @@ pub mod api { #[codec(compact)] pub prop_index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for CancelProposal { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "cancel_proposal"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -10125,6 +13564,10 @@ pub mod api { pub owner: runtime_types::pallet_democracy::types::MetadataOwner, pub maybe_hash: ::core::option::Option<::subxt::utils::H256>, } + impl ::subxt::blocks::StaticExtrinsic for SetMetadata { + const PALLET: &'static str = "Democracy"; + const CALL: &'static str = "set_metadata"; + } } pub struct TransactionApi; impl TransactionApi { @@ -11682,6 +15125,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_collective::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_collective::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -11703,6 +15147,10 @@ pub mod api { pub prime: ::core::option::Option<::subxt::utils::AccountId32>, pub old_count: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMembers { + const PALLET: &'static str = "Council"; + const CALL: &'static str = "set_members"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -11718,6 +15166,10 @@ pub mod api { #[codec(compact)] pub length_bound: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Execute { + const PALLET: &'static str = "Council"; + const CALL: &'static str = "execute"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -11735,6 +15187,10 @@ pub mod api { #[codec(compact)] pub length_bound: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Propose { + const PALLET: &'static str = "Council"; + const CALL: &'static str = "propose"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -11751,6 +15207,10 @@ pub mod api { pub index: ::core::primitive::u32, pub approve: ::core::primitive::bool, } + impl ::subxt::blocks::StaticExtrinsic for Vote { + const PALLET: &'static str = "Council"; + const CALL: &'static str = "vote"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -11764,6 +15224,10 @@ pub mod api { pub struct DisapproveProposal { pub proposal_hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for DisapproveProposal { + const PALLET: &'static str = "Council"; + const CALL: &'static str = "disapprove_proposal"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -11782,6 +15246,10 @@ pub mod api { #[codec(compact)] pub length_bound: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Close { + const PALLET: &'static str = "Council"; + const CALL: &'static str = "close"; + } } pub struct TransactionApi; impl TransactionApi { @@ -12366,6 +15834,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_collective::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_collective::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -12387,6 +15856,10 @@ pub mod api { pub prime: ::core::option::Option<::subxt::utils::AccountId32>, pub old_count: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMembers { + const PALLET: &'static str = "TechnicalCommittee"; + const CALL: &'static str = "set_members"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -12402,6 +15875,10 @@ pub mod api { #[codec(compact)] pub length_bound: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Execute { + const PALLET: &'static str = "TechnicalCommittee"; + const CALL: &'static str = "execute"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -12419,6 +15896,10 @@ pub mod api { #[codec(compact)] pub length_bound: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Propose { + const PALLET: &'static str = "TechnicalCommittee"; + const CALL: &'static str = "propose"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -12435,6 +15916,10 @@ pub mod api { pub index: ::core::primitive::u32, pub approve: ::core::primitive::bool, } + impl ::subxt::blocks::StaticExtrinsic for Vote { + const PALLET: &'static str = "TechnicalCommittee"; + const CALL: &'static str = "vote"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -12448,6 +15933,10 @@ pub mod api { pub struct DisapproveProposal { pub proposal_hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for DisapproveProposal { + const PALLET: &'static str = "TechnicalCommittee"; + const CALL: &'static str = "disapprove_proposal"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -12466,6 +15955,10 @@ pub mod api { #[codec(compact)] pub length_bound: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Close { + const PALLET: &'static str = "TechnicalCommittee"; + const CALL: &'static str = "close"; + } } pub struct TransactionApi; impl TransactionApi { @@ -13050,6 +16543,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_elections_phragmen::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_elections_phragmen::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -13071,6 +16565,10 @@ pub mod api { #[codec(compact)] pub value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Vote { + const PALLET: &'static str = "PhragmenElection"; + const CALL: &'static str = "vote"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13082,6 +16580,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct RemoveVoter; + impl ::subxt::blocks::StaticExtrinsic for RemoveVoter { + const PALLET: &'static str = "PhragmenElection"; + const CALL: &'static str = "remove_voter"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13096,6 +16598,10 @@ pub mod api { #[codec(compact)] pub candidate_count: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SubmitCandidacy { + const PALLET: &'static str = "PhragmenElection"; + const CALL: &'static str = "submit_candidacy"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13109,6 +16615,10 @@ pub mod api { pub struct RenounceCandidacy { pub renouncing: runtime_types::pallet_elections_phragmen::Renouncing, } + impl ::subxt::blocks::StaticExtrinsic for RenounceCandidacy { + const PALLET: &'static str = "PhragmenElection"; + const CALL: &'static str = "renounce_candidacy"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13124,6 +16634,10 @@ pub mod api { pub slash_bond: ::core::primitive::bool, pub rerun_election: ::core::primitive::bool, } + impl ::subxt::blocks::StaticExtrinsic for RemoveMember { + const PALLET: &'static str = "PhragmenElection"; + const CALL: &'static str = "remove_member"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13138,6 +16652,10 @@ pub mod api { pub num_voters: ::core::primitive::u32, pub num_defunct: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for CleanDefunctVoters { + const PALLET: &'static str = "PhragmenElection"; + const CALL: &'static str = "clean_defunct_voters"; + } } pub struct TransactionApi; impl TransactionApi { @@ -13809,6 +17327,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_membership::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_membership::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -13828,6 +17347,10 @@ pub mod api { pub struct AddMember { pub who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for AddMember { + const PALLET: &'static str = "TechnicalMembership"; + const CALL: &'static str = "add_member"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13841,6 +17364,10 @@ pub mod api { pub struct RemoveMember { pub who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for RemoveMember { + const PALLET: &'static str = "TechnicalMembership"; + const CALL: &'static str = "remove_member"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13855,6 +17382,10 @@ pub mod api { pub remove: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub add: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for SwapMember { + const PALLET: &'static str = "TechnicalMembership"; + const CALL: &'static str = "swap_member"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13868,6 +17399,10 @@ pub mod api { pub struct ResetMembers { pub members: ::std::vec::Vec<::subxt::utils::AccountId32>, } + impl ::subxt::blocks::StaticExtrinsic for ResetMembers { + const PALLET: &'static str = "TechnicalMembership"; + const CALL: &'static str = "reset_members"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13881,6 +17416,10 @@ pub mod api { pub struct ChangeKey { pub new: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for ChangeKey { + const PALLET: &'static str = "TechnicalMembership"; + const CALL: &'static str = "change_key"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13894,6 +17433,10 @@ pub mod api { pub struct SetPrime { pub who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for SetPrime { + const PALLET: &'static str = "TechnicalMembership"; + const CALL: &'static str = "set_prime"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -13905,6 +17448,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ClearPrime; + impl ::subxt::blocks::StaticExtrinsic for ClearPrime { + const PALLET: &'static str = "TechnicalMembership"; + const CALL: &'static str = "clear_prime"; + } } pub struct TransactionApi; impl TransactionApi { @@ -14201,6 +17748,7 @@ pub mod api { #[doc = "Error for the treasury pallet."] pub type Error = runtime_types::pallet_treasury::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_treasury::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -14222,6 +17770,10 @@ pub mod api { pub value: ::core::primitive::u128, pub beneficiary: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for ProposeSpend { + const PALLET: &'static str = "Treasury"; + const CALL: &'static str = "propose_spend"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -14236,6 +17788,10 @@ pub mod api { #[codec(compact)] pub proposal_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RejectProposal { + const PALLET: &'static str = "Treasury"; + const CALL: &'static str = "reject_proposal"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -14250,6 +17806,10 @@ pub mod api { #[codec(compact)] pub proposal_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ApproveProposal { + const PALLET: &'static str = "Treasury"; + const CALL: &'static str = "approve_proposal"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -14265,6 +17825,10 @@ pub mod api { pub amount: ::core::primitive::u128, pub beneficiary: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for Spend { + const PALLET: &'static str = "Treasury"; + const CALL: &'static str = "spend"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -14279,6 +17843,10 @@ pub mod api { #[codec(compact)] pub proposal_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RemoveApproval { + const PALLET: &'static str = "Treasury"; + const CALL: &'static str = "remove_approval"; + } } pub struct TransactionApi; impl TransactionApi { @@ -14824,6 +18392,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_conviction_voting::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_conviction_voting::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -14847,6 +18416,10 @@ pub mod api { ::core::primitive::u128, >, } + impl ::subxt::blocks::StaticExtrinsic for Vote { + const PALLET: &'static str = "ConvictionVoting"; + const CALL: &'static str = "vote"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -14863,6 +18436,10 @@ pub mod api { pub conviction: runtime_types::pallet_conviction_voting::conviction::Conviction, pub balance: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Delegate { + const PALLET: &'static str = "ConvictionVoting"; + const CALL: &'static str = "delegate"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -14877,6 +18454,10 @@ pub mod api { pub struct Undelegate { pub class: ::core::primitive::u16, } + impl ::subxt::blocks::StaticExtrinsic for Undelegate { + const PALLET: &'static str = "ConvictionVoting"; + const CALL: &'static str = "undelegate"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -14891,6 +18472,10 @@ pub mod api { pub class: ::core::primitive::u16, pub target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for Unlock { + const PALLET: &'static str = "ConvictionVoting"; + const CALL: &'static str = "unlock"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -14905,6 +18490,10 @@ pub mod api { pub class: ::core::option::Option<::core::primitive::u16>, pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RemoveVote { + const PALLET: &'static str = "ConvictionVoting"; + const CALL: &'static str = "remove_vote"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -14920,6 +18509,10 @@ pub mod api { pub class: ::core::primitive::u16, pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RemoveOtherVote { + const PALLET: &'static str = "ConvictionVoting"; + const CALL: &'static str = "remove_other_vote"; + } } pub struct TransactionApi; impl TransactionApi { @@ -15344,6 +18937,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_referenda::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_referenda::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -15371,6 +18965,10 @@ pub mod api { ::core::primitive::u32, >, } + impl ::subxt::blocks::StaticExtrinsic for Submit { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "submit"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -15385,6 +18983,10 @@ pub mod api { pub struct PlaceDecisionDeposit { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for PlaceDecisionDeposit { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "place_decision_deposit"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -15399,6 +19001,10 @@ pub mod api { pub struct RefundDecisionDeposit { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RefundDecisionDeposit { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "refund_decision_deposit"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -15413,6 +19019,10 @@ pub mod api { pub struct Cancel { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Cancel { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "cancel"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -15427,6 +19037,10 @@ pub mod api { pub struct Kill { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Kill { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "kill"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -15441,6 +19055,10 @@ pub mod api { pub struct NudgeReferendum { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for NudgeReferendum { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "nudge_referendum"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -15455,6 +19073,10 @@ pub mod api { pub struct OneFewerDeciding { pub track: ::core::primitive::u16, } + impl ::subxt::blocks::StaticExtrinsic for OneFewerDeciding { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "one_fewer_deciding"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -15469,6 +19091,10 @@ pub mod api { pub struct RefundSubmissionDeposit { pub index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RefundSubmissionDeposit { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "refund_submission_deposit"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -15483,6 +19109,10 @@ pub mod api { pub index: ::core::primitive::u32, pub maybe_hash: ::core::option::Option<::subxt::utils::H256>, } + impl ::subxt::blocks::StaticExtrinsic for SetMetadata { + const PALLET: &'static str = "Referenda"; + const CALL: &'static str = "set_metadata"; + } } pub struct TransactionApi; impl TransactionApi { @@ -16381,6 +20011,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_whitelist::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_whitelist::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -16400,6 +20031,10 @@ pub mod api { pub struct WhitelistCall { pub call_hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for WhitelistCall { + const PALLET: &'static str = "Whitelist"; + const CALL: &'static str = "whitelist_call"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -16413,6 +20048,10 @@ pub mod api { pub struct RemoveWhitelistedCall { pub call_hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for RemoveWhitelistedCall { + const PALLET: &'static str = "Whitelist"; + const CALL: &'static str = "remove_whitelisted_call"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -16428,6 +20067,10 @@ pub mod api { pub call_encoded_len: ::core::primitive::u32, pub call_weight_witness: runtime_types::sp_weights::weight_v2::Weight, } + impl ::subxt::blocks::StaticExtrinsic for DispatchWhitelistedCall { + const PALLET: &'static str = "Whitelist"; + const CALL: &'static str = "dispatch_whitelisted_call"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -16441,6 +20084,10 @@ pub mod api { pub struct DispatchWhitelistedCallWithPreimage { pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for DispatchWhitelistedCallWithPreimage { + const PALLET: &'static str = "Whitelist"; + const CALL: &'static str = "dispatch_whitelisted_call_with_preimage"; + } } pub struct TransactionApi; impl TransactionApi { @@ -16635,6 +20282,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_common::claims::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_common::claims::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -16656,6 +20304,10 @@ pub mod api { pub ethereum_signature: runtime_types::polkadot_runtime_common::claims::EcdsaSignature, } + impl ::subxt::blocks::StaticExtrinsic for Claim { + const PALLET: &'static str = "Claims"; + const CALL: &'static str = "claim"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -16678,6 +20330,10 @@ pub mod api { runtime_types::polkadot_runtime_common::claims::StatementKind, >, } + impl ::subxt::blocks::StaticExtrinsic for MintClaim { + const PALLET: &'static str = "Claims"; + const CALL: &'static str = "mint_claim"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -16694,6 +20350,10 @@ pub mod api { runtime_types::polkadot_runtime_common::claims::EcdsaSignature, pub statement: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for ClaimAttest { + const PALLET: &'static str = "Claims"; + const CALL: &'static str = "claim_attest"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -16707,6 +20367,10 @@ pub mod api { pub struct Attest { pub statement: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for Attest { + const PALLET: &'static str = "Claims"; + const CALL: &'static str = "attest"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -16722,6 +20386,10 @@ pub mod api { pub new: runtime_types::polkadot_runtime_common::claims::EthereumAddress, pub maybe_preclaim: ::core::option::Option<::subxt::utils::AccountId32>, } + impl ::subxt::blocks::StaticExtrinsic for MoveClaim { + const PALLET: &'static str = "Claims"; + const CALL: &'static str = "move_claim"; + } } pub struct TransactionApi; impl TransactionApi { @@ -17197,6 +20865,7 @@ pub mod api { #[doc = "Error for the vesting pallet."] pub type Error = runtime_types::pallet_vesting::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_vesting::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -17214,6 +20883,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct Vest; + impl ::subxt::blocks::StaticExtrinsic for Vest { + const PALLET: &'static str = "Vesting"; + const CALL: &'static str = "vest"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17227,6 +20900,10 @@ pub mod api { pub struct VestOther { pub target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for VestOther { + const PALLET: &'static str = "Vesting"; + const CALL: &'static str = "vest_other"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17244,6 +20921,10 @@ pub mod api { ::core::primitive::u32, >, } + impl ::subxt::blocks::StaticExtrinsic for VestedTransfer { + const PALLET: &'static str = "Vesting"; + const CALL: &'static str = "vested_transfer"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17262,6 +20943,10 @@ pub mod api { ::core::primitive::u32, >, } + impl ::subxt::blocks::StaticExtrinsic for ForceVestedTransfer { + const PALLET: &'static str = "Vesting"; + const CALL: &'static str = "force_vested_transfer"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17276,6 +20961,10 @@ pub mod api { pub schedule1_index: ::core::primitive::u32, pub schedule2_index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for MergeSchedules { + const PALLET: &'static str = "Vesting"; + const CALL: &'static str = "merge_schedules"; + } } pub struct TransactionApi; impl TransactionApi { @@ -17608,6 +21297,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_utility::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_utility::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -17627,6 +21317,10 @@ pub mod api { pub struct Batch { pub calls: ::std::vec::Vec, } + impl ::subxt::blocks::StaticExtrinsic for Batch { + const PALLET: &'static str = "Utility"; + const CALL: &'static str = "batch"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17641,6 +21335,10 @@ pub mod api { pub index: ::core::primitive::u16, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for AsDerivative { + const PALLET: &'static str = "Utility"; + const CALL: &'static str = "as_derivative"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17654,6 +21352,10 @@ pub mod api { pub struct BatchAll { pub calls: ::std::vec::Vec, } + impl ::subxt::blocks::StaticExtrinsic for BatchAll { + const PALLET: &'static str = "Utility"; + const CALL: &'static str = "batch_all"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17668,6 +21370,10 @@ pub mod api { pub as_origin: ::std::boxed::Box, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for DispatchAs { + const PALLET: &'static str = "Utility"; + const CALL: &'static str = "dispatch_as"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17681,6 +21387,10 @@ pub mod api { pub struct ForceBatch { pub calls: ::std::vec::Vec, } + impl ::subxt::blocks::StaticExtrinsic for ForceBatch { + const PALLET: &'static str = "Utility"; + const CALL: &'static str = "force_batch"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -17695,6 +21405,10 @@ pub mod api { pub call: ::std::boxed::Box, pub weight: runtime_types::sp_weights::weight_v2::Weight, } + impl ::subxt::blocks::StaticExtrinsic for WithWeight { + const PALLET: &'static str = "Utility"; + const CALL: &'static str = "with_weight"; + } } pub struct TransactionApi; impl TransactionApi { @@ -18008,6 +21722,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_identity::pallet::Error; #[doc = "Identity pallet declaration."] + pub type Call = runtime_types::pallet_identity::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -18027,6 +21742,10 @@ pub mod api { pub struct AddRegistrar { pub account: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for AddRegistrar { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "add_registrar"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18041,6 +21760,10 @@ pub mod api { pub info: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for SetIdentity { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "set_identity"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18057,6 +21780,10 @@ pub mod api { runtime_types::pallet_identity::types::Data, )>, } + impl ::subxt::blocks::StaticExtrinsic for SetSubs { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "set_subs"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18068,6 +21795,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ClearIdentity; + impl ::subxt::blocks::StaticExtrinsic for ClearIdentity { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "clear_identity"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18084,6 +21815,10 @@ pub mod api { #[codec(compact)] pub max_fee: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for RequestJudgement { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "request_judgement"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -18098,6 +21833,10 @@ pub mod api { pub struct CancelRequest { pub reg_index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for CancelRequest { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "cancel_request"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18114,6 +21853,10 @@ pub mod api { #[codec(compact)] pub fee: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for SetFee { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "set_fee"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18129,6 +21872,10 @@ pub mod api { pub index: ::core::primitive::u32, pub new: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for SetAccountId { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "set_account_id"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18146,6 +21893,10 @@ pub mod api { runtime_types::pallet_identity::types::IdentityField, >, } + impl ::subxt::blocks::StaticExtrinsic for SetFields { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "set_fields"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18164,6 +21915,10 @@ pub mod api { runtime_types::pallet_identity::types::Judgement<::core::primitive::u128>, pub identity: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for ProvideJudgement { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "provide_judgement"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18177,6 +21932,10 @@ pub mod api { pub struct KillIdentity { pub target: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for KillIdentity { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "kill_identity"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18191,6 +21950,10 @@ pub mod api { pub sub: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub data: runtime_types::pallet_identity::types::Data, } + impl ::subxt::blocks::StaticExtrinsic for AddSub { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "add_sub"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18205,6 +21968,10 @@ pub mod api { pub sub: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub data: runtime_types::pallet_identity::types::Data, } + impl ::subxt::blocks::StaticExtrinsic for RenameSub { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "rename_sub"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18218,6 +21985,10 @@ pub mod api { pub struct RemoveSub { pub sub: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for RemoveSub { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "remove_sub"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -18229,6 +22000,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct QuitSub; + impl ::subxt::blocks::StaticExtrinsic for QuitSub { + const PALLET: &'static str = "Identity"; + const CALL: &'static str = "quit_sub"; + } } pub struct TransactionApi; impl TransactionApi { @@ -19175,6 +22950,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_proxy::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_proxy::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -19197,6 +22973,10 @@ pub mod api { ::core::option::Option, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for Proxy { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "proxy"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19212,6 +22992,10 @@ pub mod api { pub proxy_type: runtime_types::polkadot_runtime::ProxyType, pub delay: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for AddProxy { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "add_proxy"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19227,6 +23011,10 @@ pub mod api { pub proxy_type: runtime_types::polkadot_runtime::ProxyType, pub delay: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for RemoveProxy { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "remove_proxy"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19238,6 +23026,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct RemoveProxies; + impl ::subxt::blocks::StaticExtrinsic for RemoveProxies { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "remove_proxies"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19253,6 +23045,10 @@ pub mod api { pub delay: ::core::primitive::u32, pub index: ::core::primitive::u16, } + impl ::subxt::blocks::StaticExtrinsic for CreatePure { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "create_pure"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19272,6 +23068,10 @@ pub mod api { #[codec(compact)] pub ext_index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for KillPure { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "kill_pure"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19286,6 +23086,10 @@ pub mod api { pub real: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub call_hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for Announce { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "announce"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19300,6 +23104,10 @@ pub mod api { pub real: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub call_hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for RemoveAnnouncement { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "remove_announcement"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19314,6 +23122,10 @@ pub mod api { pub delegate: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub call_hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for RejectAnnouncement { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "reject_announcement"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -19331,6 +23143,10 @@ pub mod api { ::core::option::Option, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for ProxyAnnounced { + const PALLET: &'static str = "Proxy"; + const CALL: &'static str = "proxy_announced"; + } } pub struct TransactionApi; impl TransactionApi { @@ -20002,6 +23818,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_multisig::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_multisig::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -20022,6 +23839,10 @@ pub mod api { pub other_signatories: ::std::vec::Vec<::subxt::utils::AccountId32>, pub call: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for AsMultiThreshold1 { + const PALLET: &'static str = "Multisig"; + const CALL: &'static str = "as_multi_threshold_1"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20041,6 +23862,10 @@ pub mod api { pub call: ::std::boxed::Box, pub max_weight: runtime_types::sp_weights::weight_v2::Weight, } + impl ::subxt::blocks::StaticExtrinsic for AsMulti { + const PALLET: &'static str = "Multisig"; + const CALL: &'static str = "as_multi"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20060,6 +23885,10 @@ pub mod api { pub call_hash: [::core::primitive::u8; 32usize], pub max_weight: runtime_types::sp_weights::weight_v2::Weight, } + impl ::subxt::blocks::StaticExtrinsic for ApproveAsMulti { + const PALLET: &'static str = "Multisig"; + const CALL: &'static str = "approve_as_multi"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20077,6 +23906,10 @@ pub mod api { runtime_types::pallet_multisig::Timepoint<::core::primitive::u32>, pub call_hash: [::core::primitive::u8; 32usize], } + impl ::subxt::blocks::StaticExtrinsic for CancelAsMulti { + const PALLET: &'static str = "Multisig"; + const CALL: &'static str = "cancel_as_multi"; + } } pub struct TransactionApi; impl TransactionApi { @@ -20493,6 +24326,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_bounties::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_bounties::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -20514,6 +24348,10 @@ pub mod api { pub value: ::core::primitive::u128, pub description: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for ProposeBounty { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "propose_bounty"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20528,6 +24366,10 @@ pub mod api { #[codec(compact)] pub bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ApproveBounty { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "approve_bounty"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20545,6 +24387,10 @@ pub mod api { #[codec(compact)] pub fee: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for ProposeCurator { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "propose_curator"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20559,6 +24405,10 @@ pub mod api { #[codec(compact)] pub bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for UnassignCurator { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "unassign_curator"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20573,6 +24423,10 @@ pub mod api { #[codec(compact)] pub bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for AcceptCurator { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "accept_curator"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20588,6 +24442,10 @@ pub mod api { pub bounty_id: ::core::primitive::u32, pub beneficiary: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for AwardBounty { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "award_bounty"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20602,6 +24460,10 @@ pub mod api { #[codec(compact)] pub bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ClaimBounty { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "claim_bounty"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20616,6 +24478,10 @@ pub mod api { #[codec(compact)] pub bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for CloseBounty { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "close_bounty"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -20631,6 +24497,10 @@ pub mod api { pub bounty_id: ::core::primitive::u32, pub remark: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for ExtendBountyExpiry { + const PALLET: &'static str = "Bounties"; + const CALL: &'static str = "extend_bounty_expiry"; + } } pub struct TransactionApi; impl TransactionApi { @@ -21318,6 +25188,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_child_bounties::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_child_bounties::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -21341,6 +25212,10 @@ pub mod api { pub value: ::core::primitive::u128, pub description: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for AddChildBounty { + const PALLET: &'static str = "ChildBounties"; + const CALL: &'static str = "add_child_bounty"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -21360,6 +25235,10 @@ pub mod api { #[codec(compact)] pub fee: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for ProposeCurator { + const PALLET: &'static str = "ChildBounties"; + const CALL: &'static str = "propose_curator"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -21376,6 +25255,10 @@ pub mod api { #[codec(compact)] pub child_bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for AcceptCurator { + const PALLET: &'static str = "ChildBounties"; + const CALL: &'static str = "accept_curator"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -21392,6 +25275,10 @@ pub mod api { #[codec(compact)] pub child_bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for UnassignCurator { + const PALLET: &'static str = "ChildBounties"; + const CALL: &'static str = "unassign_curator"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -21409,6 +25296,10 @@ pub mod api { pub child_bounty_id: ::core::primitive::u32, pub beneficiary: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for AwardChildBounty { + const PALLET: &'static str = "ChildBounties"; + const CALL: &'static str = "award_child_bounty"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -21425,6 +25316,10 @@ pub mod api { #[codec(compact)] pub child_bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ClaimChildBounty { + const PALLET: &'static str = "ChildBounties"; + const CALL: &'static str = "claim_child_bounty"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -21441,6 +25336,10 @@ pub mod api { #[codec(compact)] pub child_bounty_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for CloseChildBounty { + const PALLET: &'static str = "ChildBounties"; + const CALL: &'static str = "close_child_bounty"; + } } pub struct TransactionApi; impl TransactionApi { @@ -22088,6 +25987,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_tips::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_tips::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -22108,6 +26008,10 @@ pub mod api { pub reason: ::std::vec::Vec<::core::primitive::u8>, pub who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for ReportAwesome { + const PALLET: &'static str = "Tips"; + const CALL: &'static str = "report_awesome"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22121,6 +26025,10 @@ pub mod api { pub struct RetractTip { pub hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for RetractTip { + const PALLET: &'static str = "Tips"; + const CALL: &'static str = "retract_tip"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22137,6 +26045,10 @@ pub mod api { #[codec(compact)] pub tip_value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for TipNew { + const PALLET: &'static str = "Tips"; + const CALL: &'static str = "tip_new"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22152,6 +26064,10 @@ pub mod api { #[codec(compact)] pub tip_value: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Tip { + const PALLET: &'static str = "Tips"; + const CALL: &'static str = "tip"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22165,6 +26081,10 @@ pub mod api { pub struct CloseTip { pub hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for CloseTip { + const PALLET: &'static str = "Tips"; + const CALL: &'static str = "close_tip"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22178,6 +26098,10 @@ pub mod api { pub struct SlashTip { pub hash: ::subxt::utils::H256, } + impl ::subxt::blocks::StaticExtrinsic for SlashTip { + const PALLET: &'static str = "Tips"; + const CALL: &'static str = "slash_tip"; + } } pub struct TransactionApi; impl TransactionApi { @@ -22676,6 +26600,7 @@ pub mod api { #[doc = "Error of the pallet that can be returned in response to dispatches."] pub type Error = runtime_types::pallet_election_provider_multi_phase::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_election_provider_multi_phase::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -22701,6 +26626,10 @@ pub mod api { pub witness: runtime_types::pallet_election_provider_multi_phase::SolutionOrSnapshotSize, } + impl ::subxt::blocks::StaticExtrinsic for SubmitUnsigned { + const PALLET: &'static str = "ElectionProviderMultiPhase"; + const CALL: &'static str = "submit_unsigned"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22715,6 +26644,10 @@ pub mod api { pub maybe_next_score: ::core::option::Option, } + impl ::subxt::blocks::StaticExtrinsic for SetMinimumUntrustedScore { + const PALLET: &'static str = "ElectionProviderMultiPhase"; + const CALL: &'static str = "set_minimum_untrusted_score"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22731,6 +26664,10 @@ pub mod api { runtime_types::sp_npos_elections::Support<::subxt::utils::AccountId32>, )>, } + impl ::subxt::blocks::StaticExtrinsic for SetEmergencyElectionResult { + const PALLET: &'static str = "ElectionProviderMultiPhase"; + const CALL: &'static str = "set_emergency_election_result"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22748,6 +26685,10 @@ pub mod api { >, >, } + impl ::subxt::blocks::StaticExtrinsic for Submit { + const PALLET: &'static str = "ElectionProviderMultiPhase"; + const CALL: &'static str = "submit"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -22762,6 +26703,10 @@ pub mod api { pub maybe_max_voters: ::core::option::Option<::core::primitive::u32>, pub maybe_max_targets: ::core::option::Option<::core::primitive::u32>, } + impl ::subxt::blocks::StaticExtrinsic for GovernanceFallback { + const PALLET: &'static str = "ElectionProviderMultiPhase"; + const CALL: &'static str = "governance_fallback"; + } } pub struct TransactionApi; impl TransactionApi { @@ -23661,6 +27606,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_bags_list::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_bags_list::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -23680,6 +27626,10 @@ pub mod api { pub struct Rebag { pub dislocated: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for Rebag { + const PALLET: &'static str = "VoterList"; + const CALL: &'static str = "rebag"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -23693,6 +27643,10 @@ pub mod api { pub struct PutInFrontOf { pub lighter: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for PutInFrontOf { + const PALLET: &'static str = "VoterList"; + const CALL: &'static str = "put_in_front_of"; + } } pub struct TransactionApi; impl TransactionApi { @@ -23987,6 +27941,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_nomination_pools::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_nomination_pools::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -24008,6 +27963,10 @@ pub mod api { pub amount: ::core::primitive::u128, pub pool_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Join { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "join"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24022,6 +27981,10 @@ pub mod api { pub extra: runtime_types::pallet_nomination_pools::BondExtra<::core::primitive::u128>, } + impl ::subxt::blocks::StaticExtrinsic for BondExtra { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "bond_extra"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24033,6 +27996,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ClaimPayout; + impl ::subxt::blocks::StaticExtrinsic for ClaimPayout { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "claim_payout"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24049,6 +28016,10 @@ pub mod api { #[codec(compact)] pub unbonding_points: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Unbond { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "unbond"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24063,6 +28034,10 @@ pub mod api { pub pool_id: ::core::primitive::u32, pub num_slashing_spans: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for PoolWithdrawUnbonded { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "pool_withdraw_unbonded"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24078,6 +28053,10 @@ pub mod api { ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub num_slashing_spans: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for WithdrawUnbonded { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "withdraw_unbonded"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24095,6 +28074,10 @@ pub mod api { pub nominator: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub bouncer: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, } + impl ::subxt::blocks::StaticExtrinsic for Create { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "create"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24113,6 +28096,10 @@ pub mod api { pub bouncer: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, pub pool_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for CreateWithPoolId { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "create_with_pool_id"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24127,6 +28114,10 @@ pub mod api { pub pool_id: ::core::primitive::u32, pub validators: ::std::vec::Vec<::subxt::utils::AccountId32>, } + impl ::subxt::blocks::StaticExtrinsic for Nominate { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "nominate"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24141,6 +28132,10 @@ pub mod api { pub pool_id: ::core::primitive::u32, pub state: runtime_types::pallet_nomination_pools::PoolState, } + impl ::subxt::blocks::StaticExtrinsic for SetState { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "set_state"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24155,6 +28150,10 @@ pub mod api { pub pool_id: ::core::primitive::u32, pub metadata: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for SetMetadata { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "set_metadata"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24180,6 +28179,10 @@ pub mod api { runtime_types::sp_arithmetic::per_things::Perbill, >, } + impl ::subxt::blocks::StaticExtrinsic for SetConfigs { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "set_configs"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24202,6 +28205,10 @@ pub mod api { ::subxt::utils::AccountId32, >, } + impl ::subxt::blocks::StaticExtrinsic for UpdateRoles { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "update_roles"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -24216,6 +28223,10 @@ pub mod api { pub struct Chill { pub pool_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Chill { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "chill"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24231,6 +28242,10 @@ pub mod api { pub extra: runtime_types::pallet_nomination_pools::BondExtra<::core::primitive::u128>, } + impl ::subxt::blocks::StaticExtrinsic for BondExtraOther { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "bond_extra_other"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24244,6 +28259,10 @@ pub mod api { pub struct SetClaimPermission { pub permission: runtime_types::pallet_nomination_pools::ClaimPermission, } + impl ::subxt::blocks::StaticExtrinsic for SetClaimPermission { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "set_claim_permission"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24257,6 +28276,10 @@ pub mod api { pub struct ClaimPayoutOther { pub other: ::subxt::utils::AccountId32, } + impl ::subxt::blocks::StaticExtrinsic for ClaimPayoutOther { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "claim_payout_other"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24274,6 +28297,10 @@ pub mod api { ::subxt::utils::AccountId32, )>, } + impl ::subxt::blocks::StaticExtrinsic for SetCommission { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "set_commission"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24288,6 +28315,10 @@ pub mod api { pub pool_id: ::core::primitive::u32, pub max_commission: runtime_types::sp_arithmetic::per_things::Perbill, } + impl ::subxt::blocks::StaticExtrinsic for SetCommissionMax { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "set_commission_max"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -24304,6 +28335,10 @@ pub mod api { ::core::primitive::u32, >, } + impl ::subxt::blocks::StaticExtrinsic for SetCommissionChangeRate { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "set_commission_change_rate"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -24318,6 +28353,10 @@ pub mod api { pub struct ClaimCommission { pub pool_id: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ClaimCommission { + const PALLET: &'static str = "NominationPools"; + const CALL: &'static str = "claim_commission"; + } } pub struct TransactionApi; impl TransactionApi { @@ -25956,6 +29995,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_fast_unstake::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_fast_unstake::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -25973,6 +30013,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct RegisterFastUnstake; + impl ::subxt::blocks::StaticExtrinsic for RegisterFastUnstake { + const PALLET: &'static str = "FastUnstake"; + const CALL: &'static str = "register_fast_unstake"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -25984,6 +30028,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct Deregister; + impl ::subxt::blocks::StaticExtrinsic for Deregister { + const PALLET: &'static str = "FastUnstake"; + const CALL: &'static str = "deregister"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -25998,6 +30046,10 @@ pub mod api { pub struct Control { pub eras_to_check: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for Control { + const PALLET: &'static str = "FastUnstake"; + const CALL: &'static str = "control"; + } } pub struct TransactionApi; impl TransactionApi { @@ -26330,6 +30382,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_parachains::configuration::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::configuration::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -26350,6 +30403,10 @@ pub mod api { pub struct SetValidationUpgradeCooldown { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetValidationUpgradeCooldown { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_validation_upgrade_cooldown"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26364,6 +30421,10 @@ pub mod api { pub struct SetValidationUpgradeDelay { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetValidationUpgradeDelay { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_validation_upgrade_delay"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26378,6 +30439,10 @@ pub mod api { pub struct SetCodeRetentionPeriod { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetCodeRetentionPeriod { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_code_retention_period"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26392,6 +30457,10 @@ pub mod api { pub struct SetMaxCodeSize { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxCodeSize { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_code_size"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26406,6 +30475,10 @@ pub mod api { pub struct SetMaxPovSize { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxPovSize { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_pov_size"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26420,6 +30493,10 @@ pub mod api { pub struct SetMaxHeadDataSize { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxHeadDataSize { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_head_data_size"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26434,6 +30511,10 @@ pub mod api { pub struct SetParathreadCores { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetParathreadCores { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_parathread_cores"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26448,6 +30529,10 @@ pub mod api { pub struct SetParathreadRetries { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetParathreadRetries { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_parathread_retries"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26462,6 +30547,10 @@ pub mod api { pub struct SetGroupRotationFrequency { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetGroupRotationFrequency { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_group_rotation_frequency"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26476,6 +30565,10 @@ pub mod api { pub struct SetChainAvailabilityPeriod { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetChainAvailabilityPeriod { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_chain_availability_period"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26490,6 +30583,10 @@ pub mod api { pub struct SetThreadAvailabilityPeriod { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetThreadAvailabilityPeriod { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_thread_availability_period"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26504,6 +30601,10 @@ pub mod api { pub struct SetSchedulingLookahead { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetSchedulingLookahead { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_scheduling_lookahead"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -26517,6 +30618,10 @@ pub mod api { pub struct SetMaxValidatorsPerCore { pub new: ::core::option::Option<::core::primitive::u32>, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxValidatorsPerCore { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_validators_per_core"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -26530,6 +30635,10 @@ pub mod api { pub struct SetMaxValidators { pub new: ::core::option::Option<::core::primitive::u32>, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxValidators { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_validators"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26544,6 +30653,10 @@ pub mod api { pub struct SetDisputePeriod { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetDisputePeriod { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_dispute_period"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26558,6 +30671,10 @@ pub mod api { pub struct SetDisputePostConclusionAcceptancePeriod { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetDisputePostConclusionAcceptancePeriod { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_dispute_post_conclusion_acceptance_period"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26572,6 +30689,10 @@ pub mod api { pub struct SetNoShowSlots { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetNoShowSlots { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_no_show_slots"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26586,6 +30707,10 @@ pub mod api { pub struct SetNDelayTranches { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetNDelayTranches { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_n_delay_tranches"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26600,6 +30725,10 @@ pub mod api { pub struct SetZerothDelayTrancheWidth { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetZerothDelayTrancheWidth { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_zeroth_delay_tranche_width"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26614,6 +30743,10 @@ pub mod api { pub struct SetNeededApprovals { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetNeededApprovals { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_needed_approvals"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26628,6 +30761,10 @@ pub mod api { pub struct SetRelayVrfModuloSamples { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetRelayVrfModuloSamples { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_relay_vrf_modulo_samples"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26642,6 +30779,10 @@ pub mod api { pub struct SetMaxUpwardQueueCount { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxUpwardQueueCount { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_upward_queue_count"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26656,6 +30797,10 @@ pub mod api { pub struct SetMaxUpwardQueueSize { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxUpwardQueueSize { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_upward_queue_size"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26670,6 +30815,10 @@ pub mod api { pub struct SetMaxDownwardMessageSize { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxDownwardMessageSize { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_downward_message_size"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -26683,6 +30832,10 @@ pub mod api { pub struct SetUmpServiceTotalWeight { pub new: runtime_types::sp_weights::weight_v2::Weight, } + impl ::subxt::blocks::StaticExtrinsic for SetUmpServiceTotalWeight { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_ump_service_total_weight"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26697,6 +30850,10 @@ pub mod api { pub struct SetMaxUpwardMessageSize { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxUpwardMessageSize { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_upward_message_size"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26711,6 +30868,10 @@ pub mod api { pub struct SetMaxUpwardMessageNumPerCandidate { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMaxUpwardMessageNumPerCandidate { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_max_upward_message_num_per_candidate"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26725,6 +30886,10 @@ pub mod api { pub struct SetHrmpOpenRequestTtl { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpOpenRequestTtl { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_open_request_ttl"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26739,6 +30904,10 @@ pub mod api { pub struct SetHrmpSenderDeposit { pub new: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpSenderDeposit { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_sender_deposit"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26753,6 +30922,10 @@ pub mod api { pub struct SetHrmpRecipientDeposit { pub new: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpRecipientDeposit { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_recipient_deposit"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26767,6 +30940,10 @@ pub mod api { pub struct SetHrmpChannelMaxCapacity { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpChannelMaxCapacity { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_channel_max_capacity"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26781,6 +30958,10 @@ pub mod api { pub struct SetHrmpChannelMaxTotalSize { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpChannelMaxTotalSize { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_channel_max_total_size"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26795,6 +30976,10 @@ pub mod api { pub struct SetHrmpMaxParachainInboundChannels { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpMaxParachainInboundChannels { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_max_parachain_inbound_channels"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26809,6 +30994,10 @@ pub mod api { pub struct SetHrmpMaxParathreadInboundChannels { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpMaxParathreadInboundChannels { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_max_parathread_inbound_channels"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26823,6 +31012,10 @@ pub mod api { pub struct SetHrmpChannelMaxMessageSize { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpChannelMaxMessageSize { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_channel_max_message_size"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26837,6 +31030,10 @@ pub mod api { pub struct SetHrmpMaxParachainOutboundChannels { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpMaxParachainOutboundChannels { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_max_parachain_outbound_channels"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26851,6 +31048,10 @@ pub mod api { pub struct SetHrmpMaxParathreadOutboundChannels { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpMaxParathreadOutboundChannels { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_max_parathread_outbound_channels"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26865,6 +31066,10 @@ pub mod api { pub struct SetHrmpMaxMessageNumPerCandidate { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetHrmpMaxMessageNumPerCandidate { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_hrmp_max_message_num_per_candidate"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -26878,6 +31083,10 @@ pub mod api { pub struct SetUmpMaxIndividualWeight { pub new: runtime_types::sp_weights::weight_v2::Weight, } + impl ::subxt::blocks::StaticExtrinsic for SetUmpMaxIndividualWeight { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_ump_max_individual_weight"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -26891,6 +31100,10 @@ pub mod api { pub struct SetPvfCheckingEnabled { pub new: ::core::primitive::bool, } + impl ::subxt::blocks::StaticExtrinsic for SetPvfCheckingEnabled { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_pvf_checking_enabled"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26905,6 +31118,10 @@ pub mod api { pub struct SetPvfVotingTtl { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetPvfVotingTtl { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_pvf_voting_ttl"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -26919,6 +31136,10 @@ pub mod api { pub struct SetMinimumValidationUpgradeDelay { pub new: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for SetMinimumValidationUpgradeDelay { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_minimum_validation_upgrade_delay"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -26932,6 +31153,10 @@ pub mod api { pub struct SetBypassConsistencyCheck { pub new: ::core::primitive::bool, } + impl ::subxt::blocks::StaticExtrinsic for SetBypassConsistencyCheck { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_bypass_consistency_check"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -26945,6 +31170,10 @@ pub mod api { pub struct SetAsyncBackingParams { pub new: runtime_types::polkadot_primitives::vstaging::AsyncBackingParams, } + impl ::subxt::blocks::StaticExtrinsic for SetAsyncBackingParams { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_async_backing_params"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -26959,6 +31188,10 @@ pub mod api { pub new: runtime_types::polkadot_primitives::v4::executor_params::ExecutorParams, } + impl ::subxt::blocks::StaticExtrinsic for SetExecutorParams { + const PALLET: &'static str = "Configuration"; + const CALL: &'static str = "set_executor_params"; + } } pub struct TransactionApi; impl TransactionApi { @@ -27794,6 +32027,7 @@ pub mod api { use super::root_mod; use super::runtime_types; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::shared::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -27883,6 +32117,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_parachains::inclusion::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -28076,6 +32311,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_parachains::paras_inherent::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::paras_inherent::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -28100,6 +32336,10 @@ pub mod api { >, >, } + impl ::subxt::blocks::StaticExtrinsic for Enter { + const PALLET: &'static str = "ParaInherent"; + const CALL: &'static str = "enter"; + } } pub struct TransactionApi; impl TransactionApi { @@ -28365,6 +32605,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_parachains::paras::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::paras::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -28385,6 +32626,10 @@ pub mod api { pub para: runtime_types::polkadot_parachain::primitives::Id, pub new_code: runtime_types::polkadot_parachain::primitives::ValidationCode, } + impl ::subxt::blocks::StaticExtrinsic for ForceSetCurrentCode { + const PALLET: &'static str = "Paras"; + const CALL: &'static str = "force_set_current_code"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -28399,6 +32644,10 @@ pub mod api { pub para: runtime_types::polkadot_parachain::primitives::Id, pub new_head: runtime_types::polkadot_parachain::primitives::HeadData, } + impl ::subxt::blocks::StaticExtrinsic for ForceSetCurrentHead { + const PALLET: &'static str = "Paras"; + const CALL: &'static str = "force_set_current_head"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -28414,6 +32663,10 @@ pub mod api { pub new_code: runtime_types::polkadot_parachain::primitives::ValidationCode, pub relay_parent_number: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceScheduleCodeUpgrade { + const PALLET: &'static str = "Paras"; + const CALL: &'static str = "force_schedule_code_upgrade"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -28428,6 +32681,10 @@ pub mod api { pub para: runtime_types::polkadot_parachain::primitives::Id, pub new_head: runtime_types::polkadot_parachain::primitives::HeadData, } + impl ::subxt::blocks::StaticExtrinsic for ForceNoteNewHead { + const PALLET: &'static str = "Paras"; + const CALL: &'static str = "force_note_new_head"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -28441,6 +32698,10 @@ pub mod api { pub struct ForceQueueAction { pub para: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for ForceQueueAction { + const PALLET: &'static str = "Paras"; + const CALL: &'static str = "force_queue_action"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -28455,6 +32716,10 @@ pub mod api { pub validation_code: runtime_types::polkadot_parachain::primitives::ValidationCode, } + impl ::subxt::blocks::StaticExtrinsic for AddTrustedValidationCode { + const PALLET: &'static str = "Paras"; + const CALL: &'static str = "add_trusted_validation_code"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -28469,6 +32734,10 @@ pub mod api { pub validation_code_hash: runtime_types::polkadot_parachain::primitives::ValidationCodeHash, } + impl ::subxt::blocks::StaticExtrinsic for PokeUnusedValidationCode { + const PALLET: &'static str = "Paras"; + const CALL: &'static str = "poke_unused_validation_code"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -28483,6 +32752,10 @@ pub mod api { pub stmt: runtime_types::polkadot_primitives::v4::PvfCheckStatement, pub signature: runtime_types::polkadot_primitives::v4::validator_app::Signature, } + impl ::subxt::blocks::StaticExtrinsic for IncludePvfCheckStatement { + const PALLET: &'static str = "Paras"; + const CALL: &'static str = "include_pvf_check_statement"; + } } pub struct TransactionApi; impl TransactionApi { @@ -29694,6 +33967,7 @@ pub mod api { use super::root_mod; use super::runtime_types; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::initializer::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -29714,6 +33988,10 @@ pub mod api { pub struct ForceApprove { pub up_to: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceApprove { + const PALLET: &'static str = "Initializer"; + const CALL: &'static str = "force_approve"; + } } pub struct TransactionApi; impl TransactionApi { @@ -29796,6 +34074,7 @@ pub mod api { use super::root_mod; use super::runtime_types; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::dmp::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -29931,6 +34210,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_parachains::ump::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::ump::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -29951,6 +34231,10 @@ pub mod api { pub index: ::core::primitive::u64, pub weight_limit: runtime_types::sp_weights::weight_v2::Weight, } + impl ::subxt::blocks::StaticExtrinsic for ServiceOverweight { + const PALLET: &'static str = "Ump"; + const CALL: &'static str = "service_overweight"; + } } pub struct TransactionApi; impl TransactionApi { @@ -30421,6 +34705,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_parachains::hrmp::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::hrmp::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -30442,6 +34727,10 @@ pub mod api { pub proposed_max_capacity: ::core::primitive::u32, pub proposed_max_message_size: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for HrmpInitOpenChannel { + const PALLET: &'static str = "Hrmp"; + const CALL: &'static str = "hrmp_init_open_channel"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -30455,6 +34744,10 @@ pub mod api { pub struct HrmpAcceptOpenChannel { pub sender: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for HrmpAcceptOpenChannel { + const PALLET: &'static str = "Hrmp"; + const CALL: &'static str = "hrmp_accept_open_channel"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -30468,6 +34761,10 @@ pub mod api { pub struct HrmpCloseChannel { pub channel_id: runtime_types::polkadot_parachain::primitives::HrmpChannelId, } + impl ::subxt::blocks::StaticExtrinsic for HrmpCloseChannel { + const PALLET: &'static str = "Hrmp"; + const CALL: &'static str = "hrmp_close_channel"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -30483,6 +34780,10 @@ pub mod api { pub inbound: ::core::primitive::u32, pub outbound: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceCleanHrmp { + const PALLET: &'static str = "Hrmp"; + const CALL: &'static str = "force_clean_hrmp"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -30497,6 +34798,10 @@ pub mod api { pub struct ForceProcessHrmpOpen { pub channels: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceProcessHrmpOpen { + const PALLET: &'static str = "Hrmp"; + const CALL: &'static str = "force_process_hrmp_open"; + } #[derive( :: subxt :: ext :: codec :: CompactAs, :: subxt :: ext :: codec :: Decode, @@ -30511,6 +34816,10 @@ pub mod api { pub struct ForceProcessHrmpClose { pub channels: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceProcessHrmpClose { + const PALLET: &'static str = "Hrmp"; + const CALL: &'static str = "force_process_hrmp_close"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -30525,6 +34834,10 @@ pub mod api { pub channel_id: runtime_types::polkadot_parachain::primitives::HrmpChannelId, pub open_requests: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for HrmpCancelOpenRequest { + const PALLET: &'static str = "Hrmp"; + const CALL: &'static str = "hrmp_cancel_open_request"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -30541,6 +34854,10 @@ pub mod api { pub max_capacity: ::core::primitive::u32, pub max_message_size: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceOpenHrmpChannel { + const PALLET: &'static str = "Hrmp"; + const CALL: &'static str = "force_open_hrmp_channel"; + } } pub struct TransactionApi; impl TransactionApi { @@ -31655,6 +35972,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_parachains::disputes::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_parachains::disputes::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -31672,6 +35990,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ForceUnfreeze; + impl ::subxt::blocks::StaticExtrinsic for ForceUnfreeze { + const PALLET: &'static str = "ParasDisputes"; + const CALL: &'static str = "force_unfreeze"; + } } pub struct TransactionApi; impl TransactionApi { @@ -31969,6 +36291,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_common::paras_registrar::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_common::paras_registrar::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -31991,6 +36314,10 @@ pub mod api { pub validation_code: runtime_types::polkadot_parachain::primitives::ValidationCode, } + impl ::subxt::blocks::StaticExtrinsic for Register { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "register"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32009,6 +36336,10 @@ pub mod api { pub validation_code: runtime_types::polkadot_parachain::primitives::ValidationCode, } + impl ::subxt::blocks::StaticExtrinsic for ForceRegister { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "force_register"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32022,6 +36353,10 @@ pub mod api { pub struct Deregister { pub id: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for Deregister { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "deregister"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32036,6 +36371,10 @@ pub mod api { pub id: runtime_types::polkadot_parachain::primitives::Id, pub other: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for Swap { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "swap"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32049,6 +36388,10 @@ pub mod api { pub struct RemoveLock { pub para: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for RemoveLock { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "remove_lock"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32060,6 +36403,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct Reserve; + impl ::subxt::blocks::StaticExtrinsic for Reserve { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "reserve"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32073,6 +36420,10 @@ pub mod api { pub struct AddLock { pub para: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for AddLock { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "add_lock"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32087,6 +36438,10 @@ pub mod api { pub para: runtime_types::polkadot_parachain::primitives::Id, pub new_code: runtime_types::polkadot_parachain::primitives::ValidationCode, } + impl ::subxt::blocks::StaticExtrinsic for ScheduleCodeUpgrade { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "schedule_code_upgrade"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32101,6 +36456,10 @@ pub mod api { pub para: runtime_types::polkadot_parachain::primitives::Id, pub new_head: runtime_types::polkadot_parachain::primitives::HeadData, } + impl ::subxt::blocks::StaticExtrinsic for SetCurrentHead { + const PALLET: &'static str = "Registrar"; + const CALL: &'static str = "set_current_head"; + } } pub struct TransactionApi; impl TransactionApi { @@ -32550,6 +36909,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_common::slots::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_common::slots::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -32573,6 +36933,10 @@ pub mod api { pub period_begin: ::core::primitive::u32, pub period_count: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceLease { + const PALLET: &'static str = "Slots"; + const CALL: &'static str = "force_lease"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32586,6 +36950,10 @@ pub mod api { pub struct ClearAllLeases { pub para: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for ClearAllLeases { + const PALLET: &'static str = "Slots"; + const CALL: &'static str = "clear_all_leases"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32599,6 +36967,10 @@ pub mod api { pub struct TriggerOnboard { pub para: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for TriggerOnboard { + const PALLET: &'static str = "Slots"; + const CALL: &'static str = "trigger_onboard"; + } } pub struct TransactionApi; impl TransactionApi { @@ -32852,6 +37224,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_common::auctions::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_common::auctions::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -32874,6 +37247,10 @@ pub mod api { #[codec(compact)] pub lease_period_index: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for NewAuction { + const PALLET: &'static str = "Auctions"; + const CALL: &'static str = "new_auction"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32896,6 +37273,10 @@ pub mod api { #[codec(compact)] pub amount: ::core::primitive::u128, } + impl ::subxt::blocks::StaticExtrinsic for Bid { + const PALLET: &'static str = "Auctions"; + const CALL: &'static str = "bid"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -32907,6 +37288,10 @@ pub mod api { #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct CancelAuction; + impl ::subxt::blocks::StaticExtrinsic for CancelAuction { + const PALLET: &'static str = "Auctions"; + const CALL: &'static str = "cancel_auction"; + } } pub struct TransactionApi; impl TransactionApi { @@ -33370,6 +37755,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::polkadot_runtime_common::crowdloan::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::polkadot_runtime_common::crowdloan::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -33399,6 +37785,10 @@ pub mod api { pub end: ::core::primitive::u32, pub verifier: ::core::option::Option, } + impl ::subxt::blocks::StaticExtrinsic for Create { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "create"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -33417,6 +37807,10 @@ pub mod api { pub signature: ::core::option::Option, } + impl ::subxt::blocks::StaticExtrinsic for Contribute { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "contribute"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -33432,6 +37826,10 @@ pub mod api { #[codec(compact)] pub index: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for Withdraw { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "withdraw"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -33446,6 +37844,10 @@ pub mod api { #[codec(compact)] pub index: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for Refund { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "refund"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -33460,6 +37862,10 @@ pub mod api { #[codec(compact)] pub index: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for Dissolve { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "dissolve"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -33483,6 +37889,10 @@ pub mod api { pub end: ::core::primitive::u32, pub verifier: ::core::option::Option, } + impl ::subxt::blocks::StaticExtrinsic for Edit { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "edit"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -33497,6 +37907,10 @@ pub mod api { pub index: runtime_types::polkadot_parachain::primitives::Id, pub memo: ::std::vec::Vec<::core::primitive::u8>, } + impl ::subxt::blocks::StaticExtrinsic for AddMemo { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "add_memo"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -33510,6 +37924,10 @@ pub mod api { pub struct Poke { pub index: runtime_types::polkadot_parachain::primitives::Id, } + impl ::subxt::blocks::StaticExtrinsic for Poke { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "poke"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -33526,6 +37944,10 @@ pub mod api { pub signature: ::core::option::Option, } + impl ::subxt::blocks::StaticExtrinsic for ContributeAll { + const PALLET: &'static str = "Crowdloan"; + const CALL: &'static str = "contribute_all"; + } } pub struct TransactionApi; impl TransactionApi { @@ -34121,6 +38543,7 @@ pub mod api { #[doc = "\n\t\t\tCustom [dispatch errors](https://docs.substrate.io/main-docs/build/events-errors/)\n\t\t\tof this pallet.\n\t\t\t"] pub type Error = runtime_types::pallet_xcm::pallet::Error; #[doc = "Contains one variant per dispatchable that can be called by an extrinsic."] + pub type Call = runtime_types::pallet_xcm::pallet::Call; pub mod calls { use super::root_mod; use super::runtime_types; @@ -34141,6 +38564,10 @@ pub mod api { pub dest: ::std::boxed::Box, pub message: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for Send { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "send"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34157,6 +38584,10 @@ pub mod api { pub assets: ::std::boxed::Box, pub fee_asset_item: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for TeleportAssets { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "teleport_assets"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34173,6 +38604,10 @@ pub mod api { pub assets: ::std::boxed::Box, pub fee_asset_item: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ReserveTransferAssets { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "reserve_transfer_assets"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34187,6 +38622,10 @@ pub mod api { pub message: ::std::boxed::Box, pub max_weight: runtime_types::sp_weights::weight_v2::Weight, } + impl ::subxt::blocks::StaticExtrinsic for Execute { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "execute"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34202,6 +38641,10 @@ pub mod api { ::std::boxed::Box, pub xcm_version: ::core::primitive::u32, } + impl ::subxt::blocks::StaticExtrinsic for ForceXcmVersion { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "force_xcm_version"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34215,6 +38658,10 @@ pub mod api { pub struct ForceDefaultXcmVersion { pub maybe_xcm_version: ::core::option::Option<::core::primitive::u32>, } + impl ::subxt::blocks::StaticExtrinsic for ForceDefaultXcmVersion { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "force_default_xcm_version"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34228,6 +38675,10 @@ pub mod api { pub struct ForceSubscribeVersionNotify { pub location: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for ForceSubscribeVersionNotify { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "force_subscribe_version_notify"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34241,6 +38692,10 @@ pub mod api { pub struct ForceUnsubscribeVersionNotify { pub location: ::std::boxed::Box, } + impl ::subxt::blocks::StaticExtrinsic for ForceUnsubscribeVersionNotify { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "force_unsubscribe_version_notify"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34258,6 +38713,10 @@ pub mod api { pub fee_asset_item: ::core::primitive::u32, pub weight_limit: runtime_types::xcm::v3::WeightLimit, } + impl ::subxt::blocks::StaticExtrinsic for LimitedReserveTransferAssets { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "limited_reserve_transfer_assets"; + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -34275,6 +38734,10 @@ pub mod api { pub fee_asset_item: ::core::primitive::u32, pub weight_limit: runtime_types::xcm::v3::WeightLimit, } + impl ::subxt::blocks::StaticExtrinsic for LimitedTeleportAssets { + const PALLET: &'static str = "XcmPallet"; + const CALL: &'static str = "limited_teleport_assets"; + } } pub struct TransactionApi; impl TransactionApi { @@ -44250,6 +48713,55 @@ pub mod api { }, } } + pub mod types { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct FeeDetails<_0> { + pub inclusion_fee: ::core::option::Option< + runtime_types::pallet_transaction_payment::types::InclusionFee<_0>, + >, + pub tip: _0, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct InclusionFee<_0> { + pub base_fee: _0, + pub len_fee: _0, + pub adjusted_weight_fee: _0, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct RuntimeDispatchInfo<_0, _1> { + pub weight: _1, + pub class: runtime_types::frame_support::dispatch::DispatchClass, + pub partial_fee: _0, + } + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, @@ -45863,6 +50375,38 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum CandidateEvent<_0> { + #[codec(index = 0)] + CandidateBacked( + runtime_types::polkadot_primitives::v4::CandidateReceipt<_0>, + runtime_types::polkadot_parachain::primitives::HeadData, + runtime_types::polkadot_primitives::v4::CoreIndex, + runtime_types::polkadot_primitives::v4::GroupIndex, + ), + #[codec(index = 1)] + CandidateIncluded( + runtime_types::polkadot_primitives::v4::CandidateReceipt<_0>, + runtime_types::polkadot_parachain::primitives::HeadData, + runtime_types::polkadot_primitives::v4::CoreIndex, + runtime_types::polkadot_primitives::v4::GroupIndex, + ), + #[codec(index = 2)] + CandidateTimedOut( + runtime_types::polkadot_primitives::v4::CandidateReceipt<_0>, + runtime_types::polkadot_parachain::primitives::HeadData, + runtime_types::polkadot_primitives::v4::CoreIndex, + ), + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct CandidateReceipt<_0> { pub descriptor: runtime_types::polkadot_primitives::v4::CandidateDescriptor<_0>, pub commitments_hash: _0, @@ -45921,6 +50465,24 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum CoreState<_0, _1> { + #[codec(index = 0)] + Occupied(runtime_types::polkadot_primitives::v4::OccupiedCore<_0, _1>), + #[codec(index = 1)] + Scheduled(runtime_types::polkadot_primitives::v4::ScheduledCore), + #[codec(index = 2)] + Free, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct DisputeState<_0> { pub validators_for: ::subxt::utils::bits::DecodedBits< ::core::primitive::u8, @@ -45990,6 +50552,21 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct GroupRotationInfo<_0> { + pub session_start_block: _0, + pub group_rotation_frequency: _0, + pub now: _0, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct IndexedVec<_0, _1>( pub ::std::vec::Vec<_1>, #[codec(skip)] pub ::core::marker::PhantomData<_0>, @@ -46045,6 +50622,52 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct OccupiedCore<_0, _1> { + pub next_up_on_available: ::core::option::Option< + runtime_types::polkadot_primitives::v4::ScheduledCore, + >, + pub occupied_since: _1, + pub time_out_at: _1, + pub next_up_on_time_out: ::core::option::Option< + runtime_types::polkadot_primitives::v4::ScheduledCore, + >, + pub availability: ::subxt::utils::bits::DecodedBits< + ::core::primitive::u8, + ::subxt::utils::bits::Lsb0, + >, + pub group_responsible: runtime_types::polkadot_primitives::v4::GroupIndex, + pub candidate_hash: runtime_types::polkadot_core_primitives::CandidateHash, + pub candidate_descriptor: + runtime_types::polkadot_primitives::v4::CandidateDescriptor<_0>, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum OccupiedCoreAssumption { + #[codec(index = 0)] + Included, + #[codec(index = 1)] + TimedOut, + #[codec(index = 2)] + Free, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ParathreadClaim( pub runtime_types::polkadot_parachain::primitives::Id, pub runtime_types::polkadot_primitives::v4::collator_app::Public, @@ -46073,6 +50696,22 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct PersistedValidationData<_0, _1> { + pub parent_head: runtime_types::polkadot_parachain::primitives::HeadData, + pub relay_parent_number: _1, + pub relay_parent_storage_root: _0, + pub max_pov_size: _1, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct PvfCheckStatement { pub accept: ::core::primitive::bool, pub subject: runtime_types::polkadot_parachain::primitives::ValidationCodeHash, @@ -46121,6 +50760,22 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ScheduledCore { + pub para_id: runtime_types::polkadot_parachain::primitives::Id, + pub collator: ::core::option::Option< + runtime_types::polkadot_primitives::v4::collator_app::Public, + >, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct ScrapedOnChainVotes<_0> { pub session: ::core::primitive::u32, pub backing_validators_per_candidate: ::std::vec::Vec<( @@ -49410,10 +54065,182 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct BabeConfiguration { + pub slot_duration: ::core::primitive::u64, + pub epoch_length: ::core::primitive::u64, + pub c: (::core::primitive::u64, ::core::primitive::u64), + pub authorities: ::std::vec::Vec<( + runtime_types::sp_consensus_babe::app::Public, + ::core::primitive::u64, + )>, + pub randomness: [::core::primitive::u8; 32usize], + pub allowed_slots: runtime_types::sp_consensus_babe::AllowedSlots, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct BabeEpochConfiguration { pub c: (::core::primitive::u64, ::core::primitive::u64), pub allowed_slots: runtime_types::sp_consensus_babe::AllowedSlots, } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Epoch { + pub epoch_index: ::core::primitive::u64, + pub start_slot: runtime_types::sp_consensus_slots::Slot, + pub duration: ::core::primitive::u64, + pub authorities: ::std::vec::Vec<( + runtime_types::sp_consensus_babe::app::Public, + ::core::primitive::u64, + )>, + pub randomness: [::core::primitive::u8; 32usize], + pub config: runtime_types::sp_consensus_babe::BabeEpochConfiguration, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct OpaqueKeyOwnershipProof(pub ::std::vec::Vec<::core::primitive::u8>); + } + pub mod sp_consensus_beefy { + use super::runtime_types; + pub mod commitment { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Commitment<_0> { + pub payload: runtime_types::sp_consensus_beefy::payload::Payload, + pub block_number: _0, + pub validator_set_id: ::core::primitive::u64, + } + } + pub mod crypto { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Public(pub runtime_types::sp_core::ecdsa::Public); + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Signature(pub runtime_types::sp_core::ecdsa::Signature); + } + pub mod payload { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Payload( + pub ::std::vec::Vec<( + [::core::primitive::u8; 2usize], + ::std::vec::Vec<::core::primitive::u8>, + )>, + ); + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct EquivocationProof<_0, _1, _2> { + pub first: runtime_types::sp_consensus_beefy::VoteMessage<_0, _1, _2>, + pub second: runtime_types::sp_consensus_beefy::VoteMessage<_0, _1, _2>, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct OpaqueKeyOwnershipProof(pub ::std::vec::Vec<::core::primitive::u8>); + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ValidatorSet<_0> { + pub validators: ::std::vec::Vec<_0>, + pub id: ::core::primitive::u64, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct VoteMessage<_0, _1, _2> { + pub commitment: runtime_types::sp_consensus_beefy::commitment::Commitment<_0>, + pub id: _1, + pub signature: _2, + } } pub mod sp_consensus_grandpa { use super::runtime_types; @@ -49484,6 +54311,17 @@ pub mod api { pub set_id: ::core::primitive::u64, pub equivocation: runtime_types::sp_consensus_grandpa::Equivocation<_0, _1>, } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct OpaqueKeyOwnershipProof(pub ::std::vec::Vec<::core::primitive::u8>); } pub mod sp_consensus_slots { use super::runtime_types; @@ -49663,6 +54501,17 @@ pub mod api { # [codec (crate = :: subxt :: ext :: codec)] #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct OpaqueMetadata(pub ::std::vec::Vec<::core::primitive::u8>); + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct OpaquePeerId(pub ::std::vec::Vec<::core::primitive::u8>); #[derive( :: subxt :: ext :: codec :: Decode, @@ -49676,6 +54525,101 @@ pub mod api { #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub enum Void {} } + pub mod sp_inherents { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct CheckInherentsResult { + pub okay: ::core::primitive::bool, + pub fatal_error: ::core::primitive::bool, + pub errors: runtime_types::sp_inherents::InherentData, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct InherentData { + pub data: ::subxt::utils::KeyedVec< + [::core::primitive::u8; 8usize], + ::std::vec::Vec<::core::primitive::u8>, + >, + } + } + pub mod sp_mmr_primitives { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct EncodableOpaqueLeaf(pub ::std::vec::Vec<::core::primitive::u8>); + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum Error { + #[codec(index = 0)] + InvalidNumericOp, + #[codec(index = 1)] + Push, + #[codec(index = 2)] + GetRoot, + #[codec(index = 3)] + Commit, + #[codec(index = 4)] + GenerateProof, + #[codec(index = 5)] + Verify, + #[codec(index = 6)] + LeafNotFound, + #[codec(index = 7)] + PalletNotIncluded, + #[codec(index = 8)] + InvalidLeafIndex, + #[codec(index = 9)] + InvalidBestKnownBlock, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Proof<_0> { + pub leaf_indices: ::std::vec::Vec<::core::primitive::u64>, + pub leaf_count: ::core::primitive::u64, + pub items: ::std::vec::Vec<_0>, + } + } pub mod sp_npos_elections { use super::runtime_types; #[derive( @@ -49712,6 +54656,23 @@ pub mod api { use super::runtime_types; pub mod generic { use super::runtime_types; + pub mod block { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct Block<_0, _1> { + pub header: _0, + pub extrinsics: ::std::vec::Vec<_1>, + } + } pub mod digest { use super::runtime_types; #[derive( @@ -50342,6 +55303,112 @@ pub mod api { #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] pub struct BlakeTwo256; } + pub mod transaction_validity { + use super::runtime_types; + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum InvalidTransaction { + #[codec(index = 0)] + Call, + #[codec(index = 1)] + Payment, + #[codec(index = 2)] + Future, + #[codec(index = 3)] + Stale, + #[codec(index = 4)] + BadProof, + #[codec(index = 5)] + AncientBirthBlock, + #[codec(index = 6)] + ExhaustsResources, + #[codec(index = 7)] + Custom(::core::primitive::u8), + #[codec(index = 8)] + BadMandatory, + #[codec(index = 9)] + MandatoryValidation, + #[codec(index = 10)] + BadSigner, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum TransactionSource { + #[codec(index = 0)] + InBlock, + #[codec(index = 1)] + Local, + #[codec(index = 2)] + External, + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum TransactionValidityError { + #[codec(index = 0)] + Invalid(runtime_types::sp_runtime::transaction_validity::InvalidTransaction), + #[codec(index = 1)] + Unknown(runtime_types::sp_runtime::transaction_validity::UnknownTransaction), + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub enum UnknownTransaction { + #[codec(index = 0)] + CannotLookup, + #[codec(index = 1)] + NoUnsignedValidator, + #[codec(index = 2)] + Custom(::core::primitive::u8), + } + #[derive( + :: subxt :: ext :: codec :: Decode, + :: subxt :: ext :: codec :: Encode, + :: subxt :: ext :: scale_decode :: DecodeAsType, + :: subxt :: ext :: scale_encode :: EncodeAsType, + Debug, + )] + # [codec (crate = :: subxt :: ext :: codec)] + #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] + #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] + pub struct ValidTransaction { + pub priority: ::core::primitive::u64, + pub requires: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, + pub provides: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, + pub longevity: ::core::primitive::u64, + pub propagate: ::core::primitive::bool, + } + } #[derive( :: subxt :: ext :: codec :: Decode, :: subxt :: ext :: codec :: Encode, diff --git a/testing/integration-tests/src/metadata/validation.rs b/testing/integration-tests/src/metadata/validation.rs index c8d30d6418..d5a8642bc9 100644 --- a/testing/integration-tests/src/metadata/validation.rs +++ b/testing/integration-tests/src/metadata/validation.rs @@ -96,10 +96,34 @@ fn default_pallet() -> PalletMetadata { } fn pallets_to_metadata(pallets: Vec) -> RuntimeMetadataV15 { + // Extrinsic needs to contain at least the generic type parameter "Call" + // for the metadata to be valid. + // The "Call" type from the metadata is used to decode extrinsics. + // In reality, the extrinsic type has "Call", "Address", "Extra", "Signature" generic types. + #[allow(unused)] + #[derive(TypeInfo)] + struct ExtrinsicType { + call: Call, + } + // Because this type is used to decode extrinsics, we expect this to be a TypeDefVariant. + // Each pallet must contain one single variant. + #[allow(unused)] + #[derive(TypeInfo)] + enum RuntimeCall { + PalletName(Pallet), + } + // The calls of the pallet. + #[allow(unused)] + #[derive(TypeInfo)] + enum Pallet { + #[allow(unused)] + SomeCall, + } + RuntimeMetadataV15::new( pallets, ExtrinsicMetadata { - ty: meta_type::<()>(), + ty: meta_type::>(), version: 0, signed_extensions: vec![], }, From c3d868641e2322f6252550b372e2d9c66afabe3f Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 10 May 2023 13:02:34 +0200 Subject: [PATCH 05/17] change doc comments --- cli/src/commands/show.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/src/commands/show.rs b/cli/src/commands/show.rs index d224c7affb..6427af5387 100644 --- a/cli/src/commands/show.rs +++ b/cli/src/commands/show.rs @@ -20,19 +20,19 @@ use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; /// /// Show the pallets that are available: /// ``` -/// subxt show --file=../artifacts/polkadot_metadata.scale +/// subxt show --file=polkadot_metadata.scale /// ``` /// Show the calls in a pallet: /// ``` -/// subxt show --file=../artifacts/polkadot_metadata.scale Balances +/// subxt show Balances /// ``` /// Show the call parameters a call expects: /// ``` -/// subxt show --file=../artifacts/polkadot_metadata.scale Balances transfer +/// subxt show Balances transfer /// ``` /// Create an unsigned extrinsic from a scale value, validate it and output its hex representation /// ``` -/// subxt show --file=../artifacts/polkadot_metadata.scale Grandpa note_stalled { "delay": 5, "best_finalized_block_number": 5 } +/// subxt show Grandpa note_stalled { "delay": 5, "best_finalized_block_number": 5 } /// ``` /// #[derive(Debug, ClapParser)] @@ -86,7 +86,7 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { if trailing_args.is_empty() { let call_description = print_call_description(call, &metadata.runtime_metadata().types)?; println!( - "If you want to create an unsigned extrinsic for {pallet_name}/{call_name} representing a scale value of the type {}::{call_name}:\nsubxt show {pallet_name} {call_name} \n{call_description}", + "If you want to create an unsigned extrinsic for {pallet_name}/{call_name}\nrepresenting a scale value of the type {}::{call_name}:\nsubxt show {pallet_name} {call_name} \n{call_description}", calls_enum_type.path ); return Ok(()); From 301dcc29706eca2713d039272284c163a1e16309 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Thu, 11 May 2023 17:24:38 +0200 Subject: [PATCH 06/17] add constants exploration --- Cargo.lock | 3 + cli/src/commands/{show.rs => explore.rs} | 144 +++++++++++++++++++---- cli/src/commands/mod.rs | 2 +- cli/src/main.rs | 4 +- 4 files changed, 129 insertions(+), 24 deletions(-) rename cli/src/commands/{show.rs => explore.rs} (61%) diff --git a/Cargo.lock b/Cargo.lock index 4aebdc9e6e..ef31394c3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3581,8 +3581,11 @@ dependencies = [ "hex", "jsonrpsee", "parity-scale-codec", + "scale-info", + "scale-value", "serde", "serde_json", + "subxt", "subxt-codegen", "subxt-metadata", "syn 2.0.15", diff --git a/cli/src/commands/show.rs b/cli/src/commands/explore.rs similarity index 61% rename from cli/src/commands/show.rs rename to cli/src/commands/explore.rs index 6427af5387..4c59d81b3d 100644 --- a/cli/src/commands/show.rs +++ b/cli/src/commands/explore.rs @@ -1,11 +1,12 @@ use crate::utils::type_description::{format_type_description, TypeDescription}; use crate::utils::type_example::TypeExample; use crate::utils::FileOrUrl; -use clap::Parser as ClapParser; +use clap::ValueEnum; +use clap::{Args, Parser as ClapParser, Subcommand}; use codec::Decode; use color_eyre::eyre::eyre; -use frame_metadata::v15::RuntimeMetadataV15; +use frame_metadata::v15::{PalletMetadata, RuntimeMetadataV15}; use frame_metadata::RuntimeMetadataPrefixed; use scale_info::form::PortableForm; use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant, Variant}; @@ -13,40 +14,73 @@ use scale_value::{Composite, ValueDef}; use subxt::tx; use subxt::utils::H256; use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; +use subxt::dynamic::constant; /// Shows the pallets and calls available for a node and lets you build unsigned extrinsics. /// /// # Example /// +/// ## Pallets +/// /// Show the pallets that are available: /// ``` -/// subxt show --file=polkadot_metadata.scale +/// subxt explore --file=polkadot_metadata.scale /// ``` +/// +/// ## Calls +/// /// Show the calls in a pallet: /// ``` -/// subxt show Balances +/// subxt explore Balances calls /// ``` /// Show the call parameters a call expects: /// ``` -/// subxt show Balances transfer +/// subxt explore Balances calls transfer /// ``` /// Create an unsigned extrinsic from a scale value, validate it and output its hex representation /// ``` -/// subxt show Grandpa note_stalled { "delay": 5, "best_finalized_block_number": 5 } +/// subxt explore Grandpa calls note_stalled { "delay": 5, "best_finalized_block_number": 5 } /// ``` +/// ## Constants +/// +/// Show the constants in a pallet: +/// ``` +/// subxt explore Balances constants +/// ``` +/// ## Storage +/// /// #[derive(Debug, ClapParser)] pub struct Opts { #[command(flatten)] file_or_url: FileOrUrl, - pallet: Option, + #[command(subcommand)] + pallet_subcommand: Option, +} + +#[derive(Debug, Clone, Subcommand)] +pub enum PalletSubcommand { + Calls(CallsSubcommand), + Constants, + Storage(StorageSubcommand), +} + +#[derive(Debug, Clone, Args)] +pub struct CallsSubcommand { call: Option, #[clap(required = false)] trailing_args: Vec, } -/// cargo run -- show --file=../artifacts/polkadot_metadata.scale mom cook apple banana +#[derive(Debug, Clone, Args)] +pub struct StorageSubcommand { + storage_item: Option, + #[clap(required = false)] + trailing_args: Vec, +} + +/// cargo run -- explore --file=../artifacts/polkadot_metadata.scale pub async fn run(opts: Opts) -> color_eyre::Result<()> { // get the metadata let bytes = opts.file_or_url.fetch().await?; @@ -55,21 +89,43 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { // if no pallet specified, show user the pallets to choose from: let Some(pallet_name) = opts.pallet else { - println!("If you want to explore a pallet: subxt show \n{}", print_available_pallets(metadata.runtime_metadata())); + println!("If you want to explore a pallet: subxt explore \n{}", print_available_pallets(metadata.runtime_metadata())); return Ok(()); }; // if specified pallet is wrong, show user the pallets to choose from (but this time as an error): - let Some(pallet) = metadata.runtime_metadata().pallets.iter().find(|pallet| pallet.name == pallet_name)else { + let Some(pallet_metadata) = metadata.runtime_metadata().pallets.iter().find(|pallet| pallet.name == pallet_name)else { return Err(eyre!("pallet \"{}\" not found in metadata!\n{}", pallet_name, print_available_pallets(metadata.runtime_metadata()))); }; + // if correct pallet was specified but no subcommand, instruct the user how to proceed: + let Some(pallet_subcomand) = opts.pallet_subcommand else { + println!("To explore the \"{pallet_name}\" pallet further, use one of the following:\n\ + subxt explore {pallet_name} calls\n\ + subxt explore {pallet_name} constants\n\ + "); + return Ok(()); + }; + + match pallet_subcomand { + PalletSubcommand::Calls(calls_subcommand) => explore_calls(calls_subcommand, &metadata, pallet_name, pallet_metadata), + PalletSubcommand::Constants => explore_constants(&metadata, pallet_name, pallet_metadata), + PalletSubcommand::Storage(storage_subcommand) => explore_storage(storage_subcommand, &metadata, pallet_name, pallet_metadata) + } +} + +fn explore_calls( + calls_subcommand: CallsSubcommand, + metadata: &Metadata, + pallet_name: String, + pallet_metadata: &PalletMetadata, +) -> color_eyre::Result<()> { // get the enum that stores the possible calls: - let (calls_enum_type_def, calls_enum_type, _calls_type_id) = - get_calls_enum_type(pallet, &metadata.runtime_metadata().types)?; + let (calls_enum_type_def, calls_enum_type) = + get_calls_enum_type(pallet_metadata, &metadata.runtime_metadata().types)?; // if no call specified, show user the calls to choose from: - let Some(call_name) = opts.call else { + let Some(call_name) = calls_subcommand.call else { println!("If you want to explore a pallet: subxt show {pallet_name} \n{}", print_available_calls(calls_enum_type_def)); return Ok(()); }; @@ -80,7 +136,7 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { }; // collect all the trailing arguments into a single string that is later into a scale_value::Value - let trailing_args = opts.trailing_args.join(" "); + let trailing_args = calls_subcommand.trailing_args.join(" "); // if no trailing arguments specified show user the expected type of arguments with examples: if trailing_args.is_empty() { @@ -95,7 +151,7 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { // parse scale_value from trailing arguments and try to create an unsigned extrinsic with it: let value = scale_value::stringify::from_str(&trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; let value_as_composite = value_into_composite(value); - let offline_client = new_offline_client(metadata); + let offline_client = new_offline_client(metadata.clone()); let payload = tx::dynamic(pallet_name, call_name, value_as_composite); let unsigned_extrinsic = offline_client.tx().create_unsigned(&payload)?; let hex_bytes = format!("0x{}", hex::encode(unsigned_extrinsic.encoded())); @@ -124,7 +180,6 @@ fn get_calls_enum_type<'a>( ) -> color_eyre::Result<( &'a TypeDefVariant, &'a Type, - u32, )> { let calls = pallet .calls @@ -140,16 +195,16 @@ fn get_calls_enum_type<'a>( return Err(eyre!("calls type is not a variant")); } }; - Ok((calls_enum_type_def, calls_enum_type, calls.ty.id)) + Ok((calls_enum_type_def, calls_enum_type)) } -fn print_available_calls(pallet: &TypeDefVariant) -> String { - if pallet.variants.is_empty() { +fn print_available_calls(pallet_calls: &TypeDefVariant) -> String { + if pallet_calls.variants.is_empty() { "There are no calls in this pallet.".to_string() } else { let mut output = "Available calls are:".to_string(); - for variant in pallet.variants.iter() { - output.push_str(format!("\n- {}", variant.name).as_str()) + for variant in pallet_calls.variants.iter() { + output.push_str(format!(" \n{}", variant.name).as_str()) } output } @@ -223,3 +278,50 @@ fn new_offline_client(metadata: Metadata) -> OfflineClient { OfflineClient::::new(genesis_hash, runtime_version, metadata) } + + +fn explore_constants( + metadata: &Metadata, + pallet_name: String, + pallet_metadata: &PalletMetadata, +) -> color_eyre::Result<()> { + // print all constants in this pallet together with their type, value and the docs as an explanation: + let output = if pallet_metadata.constants.is_empty() { + format!("There are no constants for the \"{pallet_name}\" pallet.") + } else { + let mut output = format!("The \"{pallet_name}\" pallet has the following constants:"); + for constant in pallet_metadata.constants.iter() { + let type_description = constant.ty.id.type_description(metadata.types())?; + let scale_val = scale_value::scale::decode_as_type(&mut &constant.value[..], constant.ty.id, metadata.types())?; + let name_and_type = format!("\n\n {}: {} = {}", constant.name, type_description, scale_value::stringify::to_string(&scale_val)); + output.push_str(name_and_type.as_str()); + for doc in constant.docs.iter().filter_map(|e| + { + let trimmed = e.trim(); + if trimmed.is_empty() { + None + } else { + Some(format!("\n {trimmed}")) + } + } + ) { + dbg!(&doc); + output.push_str(doc.as_str()); + } + } + output + }; + println!("{output}"); + Ok(()) +} + + +fn explore_storage( + storage_subcommand: StorageSubcommand, + metadata: &Metadata, + pallet_name: String, + pallet_metadata: &PalletMetadata, +) -> color_eyre::Result<()> { + Ok(()) +} + diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 6aff4330ba..69542ad40d 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -4,6 +4,6 @@ pub mod codegen; pub mod compatibility; +pub mod explore; pub mod metadata; -pub mod show; pub mod version; diff --git a/cli/src/main.rs b/cli/src/main.rs index 3b47cf5000..956fd5e0b7 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -15,7 +15,7 @@ enum Command { Codegen(commands::codegen::Opts), Compatibility(commands::compatibility::Opts), Version(commands::version::Opts), - Show(commands::show::Opts), + Explore(commands::explore::Opts), } #[tokio::main] @@ -28,6 +28,6 @@ async fn main() -> color_eyre::Result<()> { Command::Codegen(opts) => commands::codegen::run(opts).await, Command::Compatibility(opts) => commands::compatibility::run(opts).await, Command::Version(opts) => commands::version::run(opts), - Command::Show(opts) => commands::show::run(opts).await, + Command::Explore(opts) => commands::explore::run(opts).await, } } From 12bbfc1d4232a8ed981727fe5533d18e4f611ce0 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Fri, 12 May 2023 18:52:32 +0200 Subject: [PATCH 07/17] add storage access interface but not done yet --- cli/src/commands/explore.rs | 297 ++++++++++++++++++++++++++-------- cli/src/utils.rs | 4 +- cli/src/utils/type_example.rs | 41 +++++ 3 files changed, 271 insertions(+), 71 deletions(-) diff --git a/cli/src/commands/explore.rs b/cli/src/commands/explore.rs index 4c59d81b3d..24ab3b7042 100644 --- a/cli/src/commands/explore.rs +++ b/cli/src/commands/explore.rs @@ -1,20 +1,23 @@ use crate::utils::type_description::{format_type_description, TypeDescription}; use crate::utils::type_example::TypeExample; use crate::utils::FileOrUrl; -use clap::ValueEnum; use clap::{Args, Parser as ClapParser, Subcommand}; +use std::fmt::format; +use std::io::Write; use codec::Decode; use color_eyre::eyre::eyre; -use frame_metadata::v15::{PalletMetadata, RuntimeMetadataV15}; +use frame_metadata::v15::{ + PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, +}; use frame_metadata::RuntimeMetadataPrefixed; use scale_info::form::PortableForm; use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant, Variant}; use scale_value::{Composite, ValueDef}; -use subxt::tx; +use subxt::storage::DynamicAddress; use subxt::utils::H256; use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; -use subxt::dynamic::constant; +use subxt::{tx, OnlineClient}; /// Shows the pallets and calls available for a node and lets you build unsigned extrinsics. /// @@ -75,7 +78,7 @@ pub struct CallsSubcommand { #[derive(Debug, Clone, Args)] pub struct StorageSubcommand { - storage_item: Option, + storage_entry: Option, #[clap(required = false)] trailing_args: Vec, } @@ -89,7 +92,8 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { // if no pallet specified, show user the pallets to choose from: let Some(pallet_name) = opts.pallet else { - println!("If you want to explore a pallet: subxt explore \n{}", print_available_pallets(metadata.runtime_metadata())); + println!("If you want to explore a pallet: subxt explore "); + println!("{}", print_available_pallets(metadata.runtime_metadata())); return Ok(()); }; @@ -100,39 +104,51 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { // if correct pallet was specified but no subcommand, instruct the user how to proceed: let Some(pallet_subcomand) = opts.pallet_subcommand else { + let docs_string = print_docs_with_indent(&pallet_metadata.docs, 4); + if !docs_string.is_empty(){ + println!("Pallet \"{pallet_name}\":{docs_string}"); + } println!("To explore the \"{pallet_name}\" pallet further, use one of the following:\n\ subxt explore {pallet_name} calls\n\ subxt explore {pallet_name} constants\n\ - "); + subxt explore {pallet_name} storage"); return Ok(()); }; match pallet_subcomand { - PalletSubcommand::Calls(calls_subcommand) => explore_calls(calls_subcommand, &metadata, pallet_name, pallet_metadata), - PalletSubcommand::Constants => explore_constants(&metadata, pallet_name, pallet_metadata), - PalletSubcommand::Storage(storage_subcommand) => explore_storage(storage_subcommand, &metadata, pallet_name, pallet_metadata) + PalletSubcommand::Calls(calls_subcommand) => { + explore_calls(calls_subcommand, &metadata, pallet_metadata) + } + PalletSubcommand::Constants => explore_constants(&metadata, pallet_metadata), + PalletSubcommand::Storage(storage_subcommand) => { + // if the metadata came from some url, we use that same url to make storage calls against. + let node_url = opts.file_or_url.url.map(|url| url.to_string()); + explore_storage(storage_subcommand, &metadata, pallet_metadata, node_url).await + } } } fn explore_calls( calls_subcommand: CallsSubcommand, metadata: &Metadata, - pallet_name: String, pallet_metadata: &PalletMetadata, ) -> color_eyre::Result<()> { + let pallet_name = pallet_metadata.name.as_str(); + // get the enum that stores the possible calls: let (calls_enum_type_def, calls_enum_type) = get_calls_enum_type(pallet_metadata, &metadata.runtime_metadata().types)?; // if no call specified, show user the calls to choose from: let Some(call_name) = calls_subcommand.call else { - println!("If you want to explore a pallet: subxt show {pallet_name} \n{}", print_available_calls(calls_enum_type_def)); + println!("If you want to explore a call: subxt explore {pallet_name} call "); + println!("{}", print_available_calls(calls_enum_type_def, pallet_name)); return Ok(()); }; // if specified call is wrong, show user the calls to choose from (but this time as an error): let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name == call_name) else { - return Err(eyre!("call \"{}\" not found in pallet \"{}\"!\n{}", call_name, pallet_name, print_available_calls(calls_enum_type_def))); + return Err(eyre!("call \"{}\" not found in pallet \"{}\"!\n{}", call_name, pallet_name, print_available_calls(calls_enum_type_def, pallet_name))); }; // collect all the trailing arguments into a single string that is later into a scale_value::Value @@ -140,11 +156,12 @@ fn explore_calls( // if no trailing arguments specified show user the expected type of arguments with examples: if trailing_args.is_empty() { - let call_description = print_call_description(call, &metadata.runtime_metadata().types)?; - println!( - "If you want to create an unsigned extrinsic for {pallet_name}/{call_name}\nrepresenting a scale value of the type {}::{call_name}:\nsubxt show {pallet_name} {call_name} \n{call_description}", - calls_enum_type.path - ); + let type_and_examples = + print_type_and_examples(&call.fields, &metadata.runtime_metadata().types)?; + println!("The call \"{call_name}\" of pallet \"{pallet_name}\" expects a value of type {}::{call_name}\n", calls_enum_type.path); + println!("You can create an unsigned extrinsic, by providing a scale value of this type to:\n subxt explore {pallet_name} calls {call_name} \n"); + println!("{type_and_examples}"); + return Ok(()); } @@ -168,7 +185,7 @@ fn print_available_pallets(metadata_v15: &RuntimeMetadataV15) -> String { } else { let mut output = "Available pallets are:".to_string(); for pallet in metadata_v15.pallets.iter() { - output.push_str(format!("\n- {}", pallet.name).as_str()) + output.push_str(format!("\n {}", pallet.name).as_str()) } output } @@ -177,14 +194,11 @@ fn print_available_pallets(metadata_v15: &RuntimeMetadataV15) -> String { fn get_calls_enum_type<'a>( pallet: &'a frame_metadata::v15::PalletMetadata, registry: &'a PortableRegistry, -) -> color_eyre::Result<( - &'a TypeDefVariant, - &'a Type, -)> { +) -> color_eyre::Result<(&'a TypeDefVariant, &'a Type)> { let calls = pallet .calls .as_ref() - .ok_or(eyre!("pallet {} has no calls.", pallet.name))?; + .ok_or(eyre!("The \"{}\" pallet has no calls.", pallet.name))?; let calls_enum_type = registry .resolve(calls.ty.id) .ok_or(eyre!("calls type with id {} not found.", calls.ty.id))?; @@ -198,28 +212,24 @@ fn get_calls_enum_type<'a>( Ok((calls_enum_type_def, calls_enum_type)) } -fn print_available_calls(pallet_calls: &TypeDefVariant) -> String { +fn print_available_calls(pallet_calls: &TypeDefVariant, pallet_name: &str) -> String { if pallet_calls.variants.is_empty() { - "There are no calls in this pallet.".to_string() - } else { - let mut output = "Available calls are:".to_string(); - for variant in pallet_calls.variants.iter() { - output.push_str(format!(" \n{}", variant.name).as_str()) - } - output + return format!("The \"{}\" pallet has no calls.", pallet_name); + } + let mut output = "Available calls are:".to_string(); + for variant in pallet_calls.variants.iter() { + output.push_str(format!("\n {}", variant.name).as_str()) } + output } -fn print_call_description( - call_variant: &Variant, - registry: &PortableRegistry, -) -> color_eyre::Result { - let type_description = call_variant.fields.type_description(registry)?; +fn print_type_and_examples(ty: &T, registry: &PortableRegistry) -> color_eyre::Result +where + T: TypeExample + TypeDescription, +{ + let type_description = ty.type_description(registry)?; let type_description = format_type_description(&type_description); - let type_examples = call_variant - .fields - .type_example(registry) - .unwrap_or(Vec::new()); + let type_examples = ty.type_example(registry).unwrap_or(Vec::new()); let mut output = String::new(); output.push_str("The type looks like this:\n"); @@ -235,18 +245,20 @@ fn print_call_description( ); } 1 => { - output.push_str("Here is an example of this type:".to_string().as_str()); + output.push_str( + "Here is an example of this type as a scale value:" + .to_string() + .as_str(), + ); } i => { - output.push_str(format!("Here are {i} examples of this type:").as_str()); + output + .push_str(format!("Here are {i} examples of this type as a scale value:").as_str()); } }; - for composite in type_examples { - let value = scale_value::Value { - value: ValueDef::Composite(composite), - context: (), - }; + for self_value in type_examples { + let value = ::upcast(self_value); let example_str = scale_value::stringify::to_string(&value); output.push('\n'); output.push_str(example_str.as_str()); @@ -279,35 +291,31 @@ fn new_offline_client(metadata: Metadata) -> OfflineClient { OfflineClient::::new(genesis_hash, runtime_version, metadata) } - fn explore_constants( metadata: &Metadata, - pallet_name: String, pallet_metadata: &PalletMetadata, ) -> color_eyre::Result<()> { // print all constants in this pallet together with their type, value and the docs as an explanation: + let pallet_name = pallet_metadata.name.as_str(); let output = if pallet_metadata.constants.is_empty() { - format!("There are no constants for the \"{pallet_name}\" pallet.") + format!("The \"{pallet_name}\" pallet has no constants.") } else { let mut output = format!("The \"{pallet_name}\" pallet has the following constants:"); for constant in pallet_metadata.constants.iter() { let type_description = constant.ty.id.type_description(metadata.types())?; - let scale_val = scale_value::scale::decode_as_type(&mut &constant.value[..], constant.ty.id, metadata.types())?; - let name_and_type = format!("\n\n {}: {} = {}", constant.name, type_description, scale_value::stringify::to_string(&scale_val)); + let scale_val = scale_value::scale::decode_as_type( + &mut &constant.value[..], + constant.ty.id, + metadata.types(), + )?; + let name_and_type = format!( + "\n\n {}: {} = {}", + constant.name, + type_description, + scale_value::stringify::to_string(&scale_val) + ); output.push_str(name_and_type.as_str()); - for doc in constant.docs.iter().filter_map(|e| - { - let trimmed = e.trim(); - if trimmed.is_empty() { - None - } else { - Some(format!("\n {trimmed}")) - } - } - ) { - dbg!(&doc); - output.push_str(doc.as_str()); - } + output.push_str(print_docs_with_indent(&constant.docs, 8).as_str()); } output }; @@ -315,13 +323,164 @@ fn explore_constants( Ok(()) } - -fn explore_storage( +async fn explore_storage( storage_subcommand: StorageSubcommand, metadata: &Metadata, - pallet_name: String, pallet_metadata: &PalletMetadata, + custom_online_client_url: Option, ) -> color_eyre::Result<()> { + let pallet_name = pallet_metadata.name.as_str(); + let trailing_args = storage_subcommand.trailing_args.join(" "); + let trailing_args = trailing_args.trim(); + + let Some(storage_metadata) = &pallet_metadata.storage else{ + println!("The \"{pallet_name}\" pallet has no storage entries."); + return Ok(()); + }; + + // if no storage entry specified, show user the calls to choose from: + let Some(entry_name) = storage_subcommand.storage_entry else{ + println!("If you want to explore a storage entry: subxt explore {pallet_name} storage \n{}", print_available_storage_entries(storage_metadata, pallet_name)); + return Ok(()); + }; + + // if specified call storage entry wrong, show user the storage entries to choose from (but this time as an error): + let Some(storage) = storage_metadata.entries.iter().find(|entry| entry.name == entry_name) else { + return Err(eyre!("Storage entry \"{entry_name}\" not found in the \"{pallet_name}\" pallet!\n{}", print_available_storage_entries(storage_metadata, pallet_name))); + }; + + let (return_ty_id, key_ty_id) = match storage.ty { + StorageEntryType::Plain(value) => (value.id, None), + StorageEntryType::Map { value, key, .. } => (value.id, Some(key.id)), + }; + + // get the type and type description for the return and key type: + let mut output = + format!("Storage entry \"{entry_name}\" in the \"{pallet_name}\" pallet can be accessed "); + if let Some(key_ty_id) = key_ty_id { + let key_ty_description_and_example = print_type_and_examples(&key_ty_id, metadata.types())?; + let key_ty = metadata + .types() + .resolve(key_ty_id) + .ok_or(eyre!("type with id {key_ty_id} not found."))?; + output.push_str( + format!( + "by providing a key of type {}.\n{}", + key_ty.path, key_ty_description_and_example + ) + .as_str(), + ); + } else { + output.push_str("without providing a key."); + } + + let return_ty = metadata + .types() + .resolve(return_ty_id) + .ok_or(eyre!("type with id {return_ty_id} not found."))?; + let return_ty_description_and_example = + print_type_and_examples(&return_ty_id, metadata.types())?; + output.push_str( + format!( + "\nIt returns a value of type {}\n{}", + return_ty.path, return_ty_description_and_example + ) + .as_str(), + ); + + // print docs at the end if there are some: + let docs_string = print_docs_with_indent(&storage.docs, 4); + if !docs_string.is_empty() { + output.push_str( + format!( + "Here is some more information about this storage entry:{}", + docs_string + ) + .as_str(), + ); + } + + // construct the scale_value that should be used as a key to the storage (often empty) + let key_scale_val: scale_value::Value = if trailing_args.is_empty() || key_ty_id.is_none() { + scale_value::Value { + value: ValueDef::Composite(scale_value::Composite::Unnamed(Vec::new())), + context: (), + } + } else { + scale_value::stringify::from_str(trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))? + }; + + if key_ty_id.is_none() { + if !trailing_args.is_empty() { + output.push_str(format!("\nWarning: You submitted the following value as a key, but it will be ignored, because the storage entry does not require a key: \"{}\"\n", trailing_args).as_str()) + } + } else { + let stringified_key = scale_value::stringify::to_string(&key_scale_val); + output.push_str( + format!("You submitted the following value as a key: {stringified_key}").as_str(), + ); + } + + println!("{output}"); + println!( + "...communicating with node at {}", + custom_online_client_url + .as_ref() + .map(|e| e.as_str()) + .unwrap_or("ws://127.0.0.1:9944") + ); + + // construct and submit the storage query + let online_client = match custom_online_client_url { + None => OnlineClient::::new().await?, + Some(url) => OnlineClient::::from_url(url).await?, + }; + let storage_query = subxt::dynamic::storage(pallet_name, entry_name, vec![key_scale_val]); + let result = online_client + .storage() + .at_latest() + .await? + .fetch(&storage_query) + .await?; + let value = result.unwrap().to_value()?; + dbg!(value); + Ok(()) } +fn print_available_storage_entries( + storage_metadata: &PalletStorageMetadata, + pallet_name: &str, +) -> String { + if storage_metadata.entries.is_empty() { + format!("The \"{}\" pallet has no storage entries.", pallet_name) + } else { + let mut output = format!( + "The \"{}\" pallet has the following storage entries:", + pallet_name + ); + for entry in storage_metadata.entries.iter() { + output.push_str(format!("\n {}", entry.name).as_str()) + } + output + } +} + +fn print_docs_with_indent(docs: &[String], indent: usize) -> String { + let indent = { + let mut s = String::new(); + for _ in 0..indent { + s.push(' '); + } + s + }; + + let mut output = String::new(); + for doc in docs.iter() { + let trimmed = doc.trim(); + if !trimmed.is_empty() { + output.push_str(format!("\n{indent}{trimmed}").as_str()); + } + } + output +} diff --git a/cli/src/utils.rs b/cli/src/utils.rs index 877d231da9..4c60413ecb 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -16,10 +16,10 @@ pub mod type_example; pub struct FileOrUrl { /// The url of the substrate node to query for metadata for codegen. #[clap(long, value_parser)] - url: Option, + pub(crate) url: Option, /// The path to the encoded metadata file. #[clap(long, value_parser)] - file: Option, + pub(crate) file: Option, /// Specify the metadata version. /// /// - unstable: diff --git a/cli/src/utils/type_example.rs b/cli/src/utils/type_example.rs index 285f1da1ee..8b353f8b4b 100644 --- a/cli/src/utils/type_example.rs +++ b/cli/src/utils/type_example.rs @@ -4,10 +4,12 @@ use scale_info::{ form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefArray, TypeDefPrimitive, TypeDefTuple, TypeDefVariant, }; +use scale_value::{Value, ValueDef}; pub trait TypeExample { type Value; fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result>; + fn upcast(self_value: Self::Value) -> scale_value::Value; } impl TypeExample for u32 { @@ -78,6 +80,10 @@ impl TypeExample for u32 { }; Ok(examples) } + + fn upcast(self_value: Self::Value) -> Value { + self_value + } } impl TypeExample for TypeDefVariant { @@ -102,6 +108,13 @@ impl TypeExample for TypeDefVariant { Ok(examples) } + + fn upcast(self_value: Self::Value) -> Value { + Value { + value: ValueDef::Variant(self_value), + context: (), + } + } } impl TypeExample for TypeDefArray { @@ -123,6 +136,13 @@ impl TypeExample for TypeDefArray { }; Ok(vec![one_example]) } + + fn upcast(self_value: Self::Value) -> Value { + Value { + value: ValueDef::Composite(self_value), + context: (), + } + } } impl TypeExample for TypeDefTuple { @@ -142,6 +162,13 @@ impl TypeExample for TypeDefTuple { .collect(); fields_vector.type_example(registry) } + + fn upcast(self_value: Self::Value) -> Value { + Value { + value: ValueDef::Composite(self_value), + context: (), + } + } } impl TypeExample for Vec> { @@ -208,6 +235,13 @@ impl TypeExample for Vec> { .collect(); Ok(composite_examples) } + + fn upcast(self_value: Self::Value) -> Value { + Value { + value: ValueDef::Composite(self_value), + context: (), + } + } } /// 3-4 example values for each primitive @@ -295,4 +329,11 @@ impl TypeExample for TypeDefPrimitive { }; Ok(value) } + + fn upcast(self_value: Self::Value) -> Value { + Value { + value: ValueDef::Primitive(self_value), + context: (), + } + } } From cfa8cf3329de2002f631dca9db8a240c85cc661d Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Mon, 15 May 2023 16:43:55 +0200 Subject: [PATCH 08/17] add storage exploration --- cli/src/commands/explore.rs | 449 +++++++++++++++--------------- cli/src/utils/type_description.rs | 17 +- cli/src/utils/type_example.rs | 30 ++ 3 files changed, 263 insertions(+), 233 deletions(-) diff --git a/cli/src/commands/explore.rs b/cli/src/commands/explore.rs index 24ab3b7042..fb887e734b 100644 --- a/cli/src/commands/explore.rs +++ b/cli/src/commands/explore.rs @@ -1,9 +1,10 @@ -use crate::utils::type_description::{format_type_description, TypeDescription}; -use crate::utils::type_example::TypeExample; +use crate::utils::type_description::{print_description, TypeDescription}; +use crate::utils::type_example::{print_examples, TypeExample}; use crate::utils::FileOrUrl; use clap::{Args, Parser as ClapParser, Subcommand}; use std::fmt::format; -use std::io::Write; +use std::fmt::Write; +use std::write; use codec::Decode; use color_eyre::eyre::eyre; @@ -43,6 +44,11 @@ use subxt::{tx, OnlineClient}; /// Create an unsigned extrinsic from a scale value, validate it and output its hex representation /// ``` /// subxt explore Grandpa calls note_stalled { "delay": 5, "best_finalized_block_number": 5 } +/// # Encoded call data: +/// # 0x2c0411020500000005000000 +/// subxt explore Balances calls transfer "{ \"dest\": v\"Raw\"((255, 255, 255)), \"value\": 0 }" +/// # Encoded call data: +/// # 0x24040607020cffffff00 /// ``` /// ## Constants /// @@ -92,8 +98,8 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { // if no pallet specified, show user the pallets to choose from: let Some(pallet_name) = opts.pallet else { - println!("If you want to explore a pallet: subxt explore "); - println!("{}", print_available_pallets(metadata.runtime_metadata())); + let available_pallets = print_available_pallets(metadata.runtime_metadata()); + println!("{available_pallets}\n\nIf you want to explore a pallet:\n - subxt explore ", ); return Ok(()); }; @@ -105,13 +111,14 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> { // if correct pallet was specified but no subcommand, instruct the user how to proceed: let Some(pallet_subcomand) = opts.pallet_subcommand else { let docs_string = print_docs_with_indent(&pallet_metadata.docs, 4); - if !docs_string.is_empty(){ - println!("Pallet \"{pallet_name}\":{docs_string}"); + if !docs_string.is_empty() { + // currently it seems like all doc strings are empty + println!("Pallet \"{pallet_name}\":\n{docs_string}"); } println!("To explore the \"{pallet_name}\" pallet further, use one of the following:\n\ - subxt explore {pallet_name} calls\n\ - subxt explore {pallet_name} constants\n\ - subxt explore {pallet_name} storage"); + - subxt explore {pallet_name} calls\n\ + - subxt explore {pallet_name} constants\n\ + - subxt explore {pallet_name} storage"); return Ok(()); }; @@ -141,14 +148,14 @@ fn explore_calls( // if no call specified, show user the calls to choose from: let Some(call_name) = calls_subcommand.call else { - println!("If you want to explore a call: subxt explore {pallet_name} call "); - println!("{}", print_available_calls(calls_enum_type_def, pallet_name)); + let available_calls = print_available_calls(calls_enum_type_def, pallet_name); + println!("{available_calls}\n\nIf you want to explore a call: \n - subxt explore {pallet_name} calls ", ); return Ok(()); }; // if specified call is wrong, show user the calls to choose from (but this time as an error): let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name == call_name) else { - return Err(eyre!("call \"{}\" not found in pallet \"{}\"!\n{}", call_name, pallet_name, print_available_calls(calls_enum_type_def, pallet_name))); + return Err(eyre!("\"{call_name}\" call not found in \"{pallet_name}\" pallet!\n{}", print_available_calls(calls_enum_type_def, pallet_name))); }; // collect all the trailing arguments into a single string that is later into a scale_value::Value @@ -156,11 +163,19 @@ fn explore_calls( // if no trailing arguments specified show user the expected type of arguments with examples: if trailing_args.is_empty() { - let type_and_examples = - print_type_and_examples(&call.fields, &metadata.runtime_metadata().types)?; - println!("The call \"{call_name}\" of pallet \"{pallet_name}\" expects a value of type {}::{call_name}\n", calls_enum_type.path); - println!("You can create an unsigned extrinsic, by providing a scale value of this type to:\n subxt explore {pallet_name} calls {call_name} \n"); - println!("{type_and_examples}"); + let mut type_description = + print_description(&call.fields, &metadata.runtime_metadata().types)?; + type_description = with_indent(type_description, 4); + let mut type_examples = print_examples(&call.fields, &metadata.runtime_metadata().types)?; + type_examples = with_indent(type_examples, 4); + let mut output = String::new(); + write!(output, "Call \"{call_name}\" in \"{pallet_name}\" pallet:\n - expects a value of type {}::{call_name}\n", calls_enum_type.path)?; + write!( + output, + " - The type looks like this:\n{type_description}\n{type_examples}" + )?; + write!(output, "\n\nYou can create an unsigned extrinsic, by providing a scale value of this type to:\n - subxt explore {pallet_name} calls {call_name} \n")?; + println!("{output}"); return Ok(()); } @@ -179,118 +194,6 @@ fn explore_calls( Ok(()) } -fn print_available_pallets(metadata_v15: &RuntimeMetadataV15) -> String { - if metadata_v15.pallets.is_empty() { - "There are no pallets in this node.".to_string() - } else { - let mut output = "Available pallets are:".to_string(); - for pallet in metadata_v15.pallets.iter() { - output.push_str(format!("\n {}", pallet.name).as_str()) - } - output - } -} - -fn get_calls_enum_type<'a>( - pallet: &'a frame_metadata::v15::PalletMetadata, - registry: &'a PortableRegistry, -) -> color_eyre::Result<(&'a TypeDefVariant, &'a Type)> { - let calls = pallet - .calls - .as_ref() - .ok_or(eyre!("The \"{}\" pallet has no calls.", pallet.name))?; - let calls_enum_type = registry - .resolve(calls.ty.id) - .ok_or(eyre!("calls type with id {} not found.", calls.ty.id))?; - // should always be a variant type, where each variant corresponds to one call. - let calls_enum_type_def = match &calls_enum_type.type_def { - TypeDef::Variant(variant) => variant, - _ => { - return Err(eyre!("calls type is not a variant")); - } - }; - Ok((calls_enum_type_def, calls_enum_type)) -} - -fn print_available_calls(pallet_calls: &TypeDefVariant, pallet_name: &str) -> String { - if pallet_calls.variants.is_empty() { - return format!("The \"{}\" pallet has no calls.", pallet_name); - } - let mut output = "Available calls are:".to_string(); - for variant in pallet_calls.variants.iter() { - output.push_str(format!("\n {}", variant.name).as_str()) - } - output -} - -fn print_type_and_examples(ty: &T, registry: &PortableRegistry) -> color_eyre::Result -where - T: TypeExample + TypeDescription, -{ - let type_description = ty.type_description(registry)?; - let type_description = format_type_description(&type_description); - let type_examples = ty.type_example(registry).unwrap_or(Vec::new()); - - let mut output = String::new(); - output.push_str("The type looks like this:\n"); - output.push_str(type_description.as_str()); - - output.push_str("\n\n"); - match type_examples.len() { - 0 => { - output.push_str( - "There are no examples available for this type." - .to_string() - .as_str(), - ); - } - 1 => { - output.push_str( - "Here is an example of this type as a scale value:" - .to_string() - .as_str(), - ); - } - i => { - output - .push_str(format!("Here are {i} examples of this type as a scale value:").as_str()); - } - }; - - for self_value in type_examples { - let value = ::upcast(self_value); - let example_str = scale_value::stringify::to_string(&value); - output.push('\n'); - output.push_str(example_str.as_str()); - } - - Ok(output) -} - -/// composites stay composites, all other types are converted into a 1-fielded unnamed composite -fn value_into_composite(value: scale_value::Value) -> scale_value::Composite<()> { - match value.value { - ValueDef::Composite(composite) => composite, - _ => Composite::Unnamed(vec![value]), - } -} - -fn new_offline_client(metadata: Metadata) -> OfflineClient { - let genesis_hash = { - let h = "91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"; - let bytes = hex::decode(h).unwrap(); - H256::from_slice(&bytes) - }; - - let runtime_version = subxt::rpc::types::RuntimeVersion { - spec_version: 9370, - transaction_version: 20, - other: Default::default(), - }; - - OfflineClient::::new(genesis_hash, runtime_version, metadata) -} - fn explore_constants( metadata: &Metadata, pallet_metadata: &PalletMetadata, @@ -309,13 +212,17 @@ fn explore_constants( metadata.types(), )?; let name_and_type = format!( - "\n\n {}: {} = {}", + "\n - {}: {} = {}", constant.name, type_description, scale_value::stringify::to_string(&scale_val) ); - output.push_str(name_and_type.as_str()); - output.push_str(print_docs_with_indent(&constant.docs, 8).as_str()); + write!( + output, + "{}\n{}", + name_and_type, + print_docs_with_indent(&constant.docs, 8) + )?; } output }; @@ -333,20 +240,21 @@ async fn explore_storage( let trailing_args = storage_subcommand.trailing_args.join(" "); let trailing_args = trailing_args.trim(); - let Some(storage_metadata) = &pallet_metadata.storage else{ + let Some(storage_metadata) = &pallet_metadata.storage else { println!("The \"{pallet_name}\" pallet has no storage entries."); return Ok(()); }; // if no storage entry specified, show user the calls to choose from: - let Some(entry_name) = storage_subcommand.storage_entry else{ - println!("If you want to explore a storage entry: subxt explore {pallet_name} storage \n{}", print_available_storage_entries(storage_metadata, pallet_name)); + let Some(entry_name) = storage_subcommand.storage_entry else { + let storage_entries = print_available_storage_entries(storage_metadata, pallet_name); + println!("{storage_entries}\n\nIf you want to explore a storage entry:\n - subxt explore {pallet_name} storage ", ); return Ok(()); }; // if specified call storage entry wrong, show user the storage entries to choose from (but this time as an error): let Some(storage) = storage_metadata.entries.iter().find(|entry| entry.name == entry_name) else { - return Err(eyre!("Storage entry \"{entry_name}\" not found in the \"{pallet_name}\" pallet!\n{}", print_available_storage_entries(storage_metadata, pallet_name))); + return Err(eyre!("Storage entry \"{entry_name}\" not found in \"{pallet_name}\" pallet!\n{}", print_available_storage_entries(storage_metadata, pallet_name))); }; let (return_ty_id, key_ty_id) = match storage.ty { @@ -355,99 +263,111 @@ async fn explore_storage( }; // get the type and type description for the return and key type: - let mut output = - format!("Storage entry \"{entry_name}\" in the \"{pallet_name}\" pallet can be accessed "); - if let Some(key_ty_id) = key_ty_id { - let key_ty_description_and_example = print_type_and_examples(&key_ty_id, metadata.types())?; - let key_ty = metadata - .types() - .resolve(key_ty_id) - .ok_or(eyre!("type with id {key_ty_id} not found."))?; - output.push_str( - format!( - "by providing a key of type {}.\n{}", - key_ty.path, key_ty_description_and_example - ) - .as_str(), - ); - } else { - output.push_str("without providing a key."); - } + let mut output = format!("Storage entry \"{entry_name}\" in \"{pallet_name}\" pallet:"); - let return_ty = metadata - .types() - .resolve(return_ty_id) - .ok_or(eyre!("type with id {return_ty_id} not found."))?; - let return_ty_description_and_example = - print_type_and_examples(&return_ty_id, metadata.types())?; - output.push_str( - format!( - "\nIt returns a value of type {}\n{}", - return_ty.path, return_ty_description_and_example - ) - .as_str(), - ); - - // print docs at the end if there are some: let docs_string = print_docs_with_indent(&storage.docs, 4); if !docs_string.is_empty() { - output.push_str( - format!( - "Here is some more information about this storage entry:{}", - docs_string - ) - .as_str(), - ); + write!(output, "\n{docs_string}")?; } - // construct the scale_value that should be used as a key to the storage (often empty) - let key_scale_val: scale_value::Value = if trailing_args.is_empty() || key_ty_id.is_none() { - scale_value::Value { - value: ValueDef::Composite(scale_value::Composite::Unnamed(Vec::new())), - context: (), - } + if let Some(key_ty_id) = key_ty_id { + let key_ty_description = print_description(&key_ty_id, metadata.types())?; + write!( + output, + "\n - Can be accessed by providing a key of type: {}", + key_ty_description + )?; + let mut key_ty_examples = print_examples(&key_ty_id, metadata.types())?; + key_ty_examples = with_indent_and_first_dash(key_ty_examples, 4); + write!(output, "\n{}", key_ty_examples)?; } else { - scale_value::stringify::from_str(trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))? - }; + write!(output, "\n - Can be accessed without providing a key.")?; + } - if key_ty_id.is_none() { - if !trailing_args.is_empty() { - output.push_str(format!("\nWarning: You submitted the following value as a key, but it will be ignored, because the storage entry does not require a key: \"{}\"\n", trailing_args).as_str()) - } + let mut return_ty_description = print_description(&return_ty_id, metadata.types())?; + return_ty_description = if return_ty_description.contains('\n') { + format!("\n{}", with_indent(return_ty_description, 4)) } else { - let stringified_key = scale_value::stringify::to_string(&key_scale_val); - output.push_str( - format!("You submitted the following value as a key: {stringified_key}").as_str(), - ); - } + return_ty_description + }; + write!( + output, + "\n - The storage entry \"{entry_name}\" has a value of type: {}", + return_ty_description + )?; + + // construct the vector of scale_values that should be used as a key to the storage (often empty) + let key_scale_values: Vec = if trailing_args.is_empty() + || key_ty_id.is_none() + { + Vec::new() + } else { + let key_scale_value = scale_value::stringify::from_str(trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; + let stringified_key = scale_value::stringify::to_string(&key_scale_value); + write!( + output, + "\nYou submitted the following value as a key: {stringified_key}" + )?; + let scale_val_as_composite = value_into_composite(key_scale_value); + match scale_val_as_composite { + Composite::Named(e) => e.into_iter().map(|(s, v)| v).collect(), + Composite::Unnamed(e) => e, + } + }; + if key_ty_id.is_none() && !trailing_args.is_empty() { + write!(output, "\nWarning: You submitted the following value as a key, but it will be ignored, because the storage entry does not require a key: \"{}\"\n", trailing_args)?; + } println!("{output}"); - println!( - "...communicating with node at {}", - custom_online_client_url - .as_ref() - .map(|e| e.as_str()) - .unwrap_or("ws://127.0.0.1:9944") - ); - - // construct and submit the storage query - let online_client = match custom_online_client_url { - None => OnlineClient::::new().await?, - Some(url) => OnlineClient::::from_url(url).await?, - }; - let storage_query = subxt::dynamic::storage(pallet_name, entry_name, vec![key_scale_val]); - let result = online_client - .storage() - .at_latest() - .await? - .fetch(&storage_query) - .await?; - let value = result.unwrap().to_value()?; - dbg!(value); + // construct and submit the storage query if either no key is needed or som key was provided as a scale value + + if key_ty_id.is_none() || !key_scale_values.is_empty() { + let online_client = match custom_online_client_url { + None => OnlineClient::::new().await?, + Some(url) => OnlineClient::::from_url(url).await?, + }; + let storage_query = subxt::dynamic::storage(pallet_name, entry_name, key_scale_values); + let result = online_client + .storage() + .at_latest() + .await? + .fetch(&storage_query) + .await? + .ok_or(eyre!("Decoding ValueThunk failed"))?; + + let value = result.to_value()?; + let value_string = scale_value::stringify::to_string(&value); + println!("\nValue in storage: {value_string}"); + } else { + println!("\nIf you want to get the value of storage entry \"{entry_name}\" in pallet \"{pallet_name}\":\n - subxt explore {pallet_name} storage {entry_name} ", ); + } Ok(()) } +fn print_available_pallets(metadata_v15: &RuntimeMetadataV15) -> String { + if metadata_v15.pallets.is_empty() { + "There are no pallets in this node.".to_string() + } else { + let mut output = "Available pallets are:".to_string(); + for pallet in metadata_v15.pallets.iter() { + write!(output, "\n - {}", pallet.name).unwrap(); + } + output + } +} + +fn print_available_calls(pallet_calls: &TypeDefVariant, pallet_name: &str) -> String { + if pallet_calls.variants.is_empty() { + return format!("The \"{}\" pallet has no calls.", pallet_name); + } + let mut output = format!("Calls in \"{pallet_name}\" pallet:"); + for variant in pallet_calls.variants.iter() { + write!(output, "\n - {}", variant.name).unwrap(); + } + output +} + fn print_available_storage_entries( storage_metadata: &PalletStorageMetadata, pallet_name: &str, @@ -460,27 +380,96 @@ fn print_available_storage_entries( pallet_name ); for entry in storage_metadata.entries.iter() { - output.push_str(format!("\n {}", entry.name).as_str()) + write!(output, "\n - {}", entry.name).unwrap(); } output } } -fn print_docs_with_indent(docs: &[String], indent: usize) -> String { - let indent = { - let mut s = String::new(); - for _ in 0..indent { - s.push(' '); +fn get_calls_enum_type<'a>( + pallet: &'a frame_metadata::v15::PalletMetadata, + registry: &'a PortableRegistry, +) -> color_eyre::Result<(&'a TypeDefVariant, &'a Type)> { + let calls = pallet + .calls + .as_ref() + .ok_or(eyre!("The \"{}\" pallet has no calls.", pallet.name))?; + let calls_enum_type = registry + .resolve(calls.ty.id) + .ok_or(eyre!("calls type with id {} not found.", calls.ty.id))?; + // should always be a variant type, where each variant corresponds to one call. + let calls_enum_type_def = match &calls_enum_type.type_def { + TypeDef::Variant(variant) => variant, + _ => { + return Err(eyre!("calls type is not a variant")); } - s }; + Ok((calls_enum_type_def, calls_enum_type)) +} - let mut output = String::new(); - for doc in docs.iter() { - let trimmed = doc.trim(); - if !trimmed.is_empty() { - output.push_str(format!("\n{indent}{trimmed}").as_str()); - } +/// composites stay composites, all other types are converted into a 1-fielded unnamed composite +fn value_into_composite(value: scale_value::Value) -> scale_value::Composite<()> { + match value.value { + ValueDef::Composite(composite) => composite, + _ => Composite::Unnamed(vec![value]), } - output +} + +fn new_offline_client(metadata: Metadata) -> OfflineClient { + let genesis_hash = { + let h = "91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"; + let bytes = hex::decode(h).unwrap(); + H256::from_slice(&bytes) + }; + + let runtime_version = subxt::rpc::types::RuntimeVersion { + spec_version: 9370, + transaction_version: 20, + other: Default::default(), + }; + + OfflineClient::::new(genesis_hash, runtime_version, metadata) +} + +fn print_docs_with_indent(docs: &[String], indent: usize) -> String { + // take at most the first paragraph of documentation, such that it does not get too long. + let docs_str = docs + .iter() + .map(|e| e.trim()) + .take_while(|e| !e.is_empty()) + .collect::>() + .join("\n"); + with_indent_and_first_dash(docs_str, indent) +} + +fn with_indent(s: String, indent: usize) -> String { + let indent = make_indent(indent); + s.lines() + .map(|line| format!("{indent}{line}")) + .collect::>() + .join("\n") +} + +fn with_indent_and_first_dash(s: String, indent: usize) -> String { + let blank_indent = make_indent(indent); + s.lines() + .enumerate() + .map(|(i, line)| { + if i == 0 { + dbg!(&line); + format!("{}- {line}", make_indent(indent - 2)) + } else { + format!("{blank_indent}{line}") + } + }) + .collect::>() + .join("\n") +} + +fn make_indent(indent: usize) -> String { + let mut s = String::new(); + for _ in 0..indent { + s.push(' '); + } + s } diff --git a/cli/src/utils/type_description.rs b/cli/src/utils/type_description.rs index b886e22f5e..8a700307aa 100644 --- a/cli/src/utils/type_description.rs +++ b/cli/src/utils/type_description.rs @@ -1,10 +1,22 @@ use color_eyre::eyre::eyre; +use std::fmt::Write; +use std::write; use scale_info::{ form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefArray, TypeDefBitSequence, TypeDefCompact, TypeDefPrimitive, TypeDefSequence, TypeDefTuple, TypeDefVariant, Variant, }; +/// pretty formatted type description +pub fn print_description(ty: &T, registry: &PortableRegistry) -> color_eyre::Result +where + T: TypeDescription, +{ + let type_description = ty.type_description(registry)?; + let type_description = format_type_description(&type_description); + Ok(type_description) +} + pub trait TypeDescription { fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result; } @@ -52,8 +64,7 @@ impl TypeDescription for TypeDef { impl TypeDescription for TypeDefTuple { fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { - let mut output = String::new(); - output.push('('); + let mut output = "(".to_string(); for (is_last, ty) in mark_last(self.fields.iter(), self.fields.len()) { let type_description = ty.id.type_description(registry)?; output.push_str(&type_description); @@ -200,7 +211,7 @@ impl TypeDescription for Field { } } -pub fn format_type_description(input: &str) -> String { +fn format_type_description(input: &str) -> String { fn add_indentation(output: &mut String, indent_level: i32) { for _ in 0..indent_level { output.push_str(" "); diff --git a/cli/src/utils/type_example.rs b/cli/src/utils/type_example.rs index 8b353f8b4b..e1b2130a5c 100644 --- a/cli/src/utils/type_example.rs +++ b/cli/src/utils/type_example.rs @@ -5,6 +5,36 @@ use scale_info::{ TypeDefTuple, TypeDefVariant, }; use scale_value::{Value, ValueDef}; +use std::fmt::Write; +use std::write; + +pub fn print_examples(ty: &T, registry: &PortableRegistry) -> color_eyre::Result +where + T: TypeExample, +{ + let type_examples = ty.type_example(registry)?; + let mut output = String::new(); + match type_examples.len() { + 0 => { + write!(output, "There are no examples available for this type.")?; + } + 1 => { + write!(output, "Here is an example of this type as a scale value:")?; + } + i => { + write!( + output, + "Here are {i} examples of this type as a scale value:" + )?; + } + }; + for self_value in type_examples { + let value = ::upcast(self_value); + let example_str = scale_value::stringify::to_string(&value); + write!(output, "\n{}", example_str)?; + } + Ok(output) +} pub trait TypeExample { type Value; From 21577ea5bbeecb92a1fe7a5d8bf2a382a8fc4664 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Mon, 15 May 2023 16:57:27 +0200 Subject: [PATCH 09/17] formatting --- cli/src/commands/explore.rs | 10 +++++----- cli/src/utils/type_description.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/src/commands/explore.rs b/cli/src/commands/explore.rs index fb887e734b..21087d6cd2 100644 --- a/cli/src/commands/explore.rs +++ b/cli/src/commands/explore.rs @@ -1,8 +1,8 @@ use crate::utils::type_description::{print_description, TypeDescription}; -use crate::utils::type_example::{print_examples, TypeExample}; +use crate::utils::type_example::{print_examples}; use crate::utils::FileOrUrl; use clap::{Args, Parser as ClapParser, Subcommand}; -use std::fmt::format; + use std::fmt::Write; use std::write; @@ -13,9 +13,9 @@ use frame_metadata::v15::{ }; use frame_metadata::RuntimeMetadataPrefixed; use scale_info::form::PortableForm; -use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant, Variant}; +use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; use scale_value::{Composite, ValueDef}; -use subxt::storage::DynamicAddress; + use subxt::utils::H256; use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; use subxt::{tx, OnlineClient}; @@ -310,7 +310,7 @@ async fn explore_storage( )?; let scale_val_as_composite = value_into_composite(key_scale_value); match scale_val_as_composite { - Composite::Named(e) => e.into_iter().map(|(s, v)| v).collect(), + Composite::Named(e) => e.into_iter().map(|(_s, v)| v).collect(), Composite::Unnamed(e) => e, } }; diff --git a/cli/src/utils/type_description.rs b/cli/src/utils/type_description.rs index 8a700307aa..57574295d7 100644 --- a/cli/src/utils/type_description.rs +++ b/cli/src/utils/type_description.rs @@ -1,6 +1,6 @@ use color_eyre::eyre::eyre; -use std::fmt::Write; -use std::write; + + use scale_info::{ form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefArray, TypeDefBitSequence, From 791f2b8879d190d60ef601eda534a1c27641f10e Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Mon, 15 May 2023 17:43:18 +0200 Subject: [PATCH 10/17] remove dbg --- cli/src/commands/explore.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cli/src/commands/explore.rs b/cli/src/commands/explore.rs index 21087d6cd2..40c0a71a22 100644 --- a/cli/src/commands/explore.rs +++ b/cli/src/commands/explore.rs @@ -327,15 +327,15 @@ async fn explore_storage( Some(url) => OnlineClient::::from_url(url).await?, }; let storage_query = subxt::dynamic::storage(pallet_name, entry_name, key_scale_values); - let result = online_client + let decoded_value_thunk_or_none = online_client .storage() .at_latest() .await? .fetch(&storage_query) - .await? - .ok_or(eyre!("Decoding ValueThunk failed"))?; + .await?; + let decoded_value_thunk = decoded_value_thunk_or_none.ok_or(eyre!("DecodedValueThunk was None"))?; - let value = result.to_value()?; + let value = decoded_value_thunk.to_value()?; let value_string = scale_value::stringify::to_string(&value); println!("\nValue in storage: {value_string}"); } else { @@ -456,7 +456,6 @@ fn with_indent_and_first_dash(s: String, indent: usize) -> String { .enumerate() .map(|(i, line)| { if i == 0 { - dbg!(&line); format!("{}- {line}", make_indent(indent - 2)) } else { format!("{blank_indent}{line}") From 2f993d29c1c3331ba7cffae451005046f1a3079c Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Mon, 15 May 2023 18:01:26 +0200 Subject: [PATCH 11/17] some small tweaks --- cli/src/commands/explore.rs | 30 ++++++++++++++++++++---------- cli/src/utils/type_description.rs | 5 ++--- cli/src/utils/type_example.rs | 3 ++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/cli/src/commands/explore.rs b/cli/src/commands/explore.rs index 40c0a71a22..f8b3ba292d 100644 --- a/cli/src/commands/explore.rs +++ b/cli/src/commands/explore.rs @@ -1,5 +1,5 @@ -use crate::utils::type_description::{print_description, TypeDescription}; -use crate::utils::type_example::{print_examples}; +use crate::utils::type_description::print_type_description; +use crate::utils::type_example::print_type_examples; use crate::utils::FileOrUrl; use clap::{Args, Parser as ClapParser, Subcommand}; @@ -20,7 +20,7 @@ use subxt::utils::H256; use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; use subxt::{tx, OnlineClient}; -/// Shows the pallets and calls available for a node and lets you build unsigned extrinsics. +/// Explore pallets, calls, call parameters, storage entries and constants. Also allows for creating (unsigned) extrinsics. /// /// # Example /// @@ -58,6 +58,14 @@ use subxt::{tx, OnlineClient}; /// ``` /// ## Storage /// +/// Show the storage entries in a pallet +/// ``` +/// subxt explore Alliance storage +/// ``` +/// Show the types and value of a specific storage entry +/// ``` +/// subxt explore Alliance storage Announcements [KEY_SCALE_VALUE] +/// ``` /// #[derive(Debug, ClapParser)] pub struct Opts { @@ -164,9 +172,10 @@ fn explore_calls( // if no trailing arguments specified show user the expected type of arguments with examples: if trailing_args.is_empty() { let mut type_description = - print_description(&call.fields, &metadata.runtime_metadata().types)?; + print_type_description(&call.fields, &metadata.runtime_metadata().types)?; type_description = with_indent(type_description, 4); - let mut type_examples = print_examples(&call.fields, &metadata.runtime_metadata().types)?; + let mut type_examples = + print_type_examples(&call.fields, &metadata.runtime_metadata().types)?; type_examples = with_indent(type_examples, 4); let mut output = String::new(); write!(output, "Call \"{call_name}\" in \"{pallet_name}\" pallet:\n - expects a value of type {}::{call_name}\n", calls_enum_type.path)?; @@ -205,7 +214,7 @@ fn explore_constants( } else { let mut output = format!("The \"{pallet_name}\" pallet has the following constants:"); for constant in pallet_metadata.constants.iter() { - let type_description = constant.ty.id.type_description(metadata.types())?; + let type_description = print_type_description(&constant.ty.id, metadata.types())?; let scale_val = scale_value::scale::decode_as_type( &mut &constant.value[..], constant.ty.id, @@ -271,20 +280,20 @@ async fn explore_storage( } if let Some(key_ty_id) = key_ty_id { - let key_ty_description = print_description(&key_ty_id, metadata.types())?; + let key_ty_description = print_type_description(&key_ty_id, metadata.types())?; write!( output, "\n - Can be accessed by providing a key of type: {}", key_ty_description )?; - let mut key_ty_examples = print_examples(&key_ty_id, metadata.types())?; + let mut key_ty_examples = print_type_examples(&key_ty_id, metadata.types())?; key_ty_examples = with_indent_and_first_dash(key_ty_examples, 4); write!(output, "\n{}", key_ty_examples)?; } else { write!(output, "\n - Can be accessed without providing a key.")?; } - let mut return_ty_description = print_description(&return_ty_id, metadata.types())?; + let mut return_ty_description = print_type_description(&return_ty_id, metadata.types())?; return_ty_description = if return_ty_description.contains('\n') { format!("\n{}", with_indent(return_ty_description, 4)) } else { @@ -333,7 +342,8 @@ async fn explore_storage( .await? .fetch(&storage_query) .await?; - let decoded_value_thunk = decoded_value_thunk_or_none.ok_or(eyre!("DecodedValueThunk was None"))?; + let decoded_value_thunk = + decoded_value_thunk_or_none.ok_or(eyre!("DecodedValueThunk was None"))?; let value = decoded_value_thunk.to_value()?; let value_string = scale_value::stringify::to_string(&value); diff --git a/cli/src/utils/type_description.rs b/cli/src/utils/type_description.rs index 57574295d7..c9fa451982 100644 --- a/cli/src/utils/type_description.rs +++ b/cli/src/utils/type_description.rs @@ -1,14 +1,12 @@ use color_eyre::eyre::eyre; - - use scale_info::{ form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefArray, TypeDefBitSequence, TypeDefCompact, TypeDefPrimitive, TypeDefSequence, TypeDefTuple, TypeDefVariant, Variant, }; /// pretty formatted type description -pub fn print_description(ty: &T, registry: &PortableRegistry) -> color_eyre::Result +pub fn print_type_description(ty: &T, registry: &PortableRegistry) -> color_eyre::Result where T: TypeDescription, { @@ -17,6 +15,7 @@ where Ok(type_description) } +/// a trait for producing human readable type descriptions with a rust-like syntax. pub trait TypeDescription { fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result; } diff --git a/cli/src/utils/type_example.rs b/cli/src/utils/type_example.rs index e1b2130a5c..d487107940 100644 --- a/cli/src/utils/type_example.rs +++ b/cli/src/utils/type_example.rs @@ -8,7 +8,7 @@ use scale_value::{Value, ValueDef}; use std::fmt::Write; use std::write; -pub fn print_examples(ty: &T, registry: &PortableRegistry) -> color_eyre::Result +pub fn print_type_examples(ty: &T, registry: &PortableRegistry) -> color_eyre::Result where T: TypeExample, { @@ -36,6 +36,7 @@ where Ok(output) } +/// a trait for producing scale value examples for a type. pub trait TypeExample { type Value; fn type_example(&self, registry: &PortableRegistry) -> color_eyre::Result>; From 49f9ecea07199a0ab59f338b86bb6fa03d15856f Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 16 May 2023 13:30:33 +0200 Subject: [PATCH 12/17] fix formatting and scale value for storage --- cli/src/commands/explore.rs | 29 +++++++++++++++++------------ cli/src/utils/type_description.rs | 12 ++++++++++-- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/cli/src/commands/explore.rs b/cli/src/commands/explore.rs index f8b3ba292d..60150644f9 100644 --- a/cli/src/commands/explore.rs +++ b/cli/src/commands/explore.rs @@ -306,22 +306,26 @@ async fn explore_storage( )?; // construct the vector of scale_values that should be used as a key to the storage (often empty) - let key_scale_values: Vec = if trailing_args.is_empty() - || key_ty_id.is_none() + + let key_scale_values = if let Some(key_ty_id) = key_ty_id.filter(|_| !trailing_args.is_empty()) { - Vec::new() - } else { let key_scale_value = scale_value::stringify::from_str(trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; - let stringified_key = scale_value::stringify::to_string(&key_scale_value); write!( output, - "\nYou submitted the following value as a key: {stringified_key}" + "\nYou submitted the following value as a key: {}", + scale_value::stringify::to_string(&key_scale_value) )?; - let scale_val_as_composite = value_into_composite(key_scale_value); - match scale_val_as_composite { - Composite::Named(e) => e.into_iter().map(|(_s, v)| v).collect(), - Composite::Unnamed(e) => e, - } + let mut key_bytes: Vec = Vec::new(); + scale_value::scale::encode_as_type( + &key_scale_value, + key_ty_id, + metadata.types(), + &mut key_bytes, + )?; + let bytes_composite = scale_value::Value::from_bytes(&key_bytes); + vec![bytes_composite] + } else { + Vec::new() }; if key_ty_id.is_none() && !trailing_args.is_empty() { @@ -342,8 +346,9 @@ async fn explore_storage( .await? .fetch(&storage_query) .await?; + let decoded_value_thunk = - decoded_value_thunk_or_none.ok_or(eyre!("DecodedValueThunk was None"))?; + decoded_value_thunk_or_none.ok_or(eyre!("Value not found in storage."))?; let value = decoded_value_thunk.to_value()?; let value_string = scale_value::stringify::to_string(&value); diff --git a/cli/src/utils/type_description.rs b/cli/src/utils/type_description.rs index c9fa451982..400e96bdd7 100644 --- a/cli/src/utils/type_description.rs +++ b/cli/src/utils/type_description.rs @@ -221,7 +221,9 @@ fn format_type_description(input: &str) -> String { let mut indent_level = 0; // in a tuple we will not set line breaks on comma, so we keep track of it here: let mut in_tuple = 0; + let mut tokens_since_last_bracket_or_comma: usize = 0; for ch in input.chars() { + let mut token_is_bracket_or_comma = true; match ch { '{' => { indent_level += 1; @@ -237,14 +239,14 @@ fn format_type_description(input: &str) -> String { } ',' => { output.push(ch); - if in_tuple > 0 { + // makes small tuples e.g. (u8, u16, u8, u8) not cause line breaks. + if in_tuple > 0 && tokens_since_last_bracket_or_comma < 5 { output.push(' '); } else { output.push('\n'); add_indentation(&mut output, indent_level); } } - '(' => { output.push(ch); in_tuple += 1; @@ -254,9 +256,15 @@ fn format_type_description(input: &str) -> String { in_tuple -= 1; } _ => { + token_is_bracket_or_comma = false; output.push(ch); } } + if token_is_bracket_or_comma { + tokens_since_last_bracket_or_comma = 0; + } else { + tokens_since_last_bracket_or_comma += 1; + } } output } From 21cb26eff4616ee37b97f902076bbb2cf3406e70 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 16 May 2023 19:37:18 +0200 Subject: [PATCH 13/17] split up files, sort entries, change formatting --- cli/src/commands/explore.rs | 489 -------------------------- cli/src/commands/explore/calls.rs | 148 ++++++++ cli/src/commands/explore/constants.rs | 92 +++++ cli/src/commands/explore/mod.rs | 154 ++++++++ cli/src/commands/explore/storage.rs | 182 ++++++++++ cli/src/utils.rs | 22 ++ cli/src/utils/type_example.rs | 18 +- 7 files changed, 612 insertions(+), 493 deletions(-) delete mode 100644 cli/src/commands/explore.rs create mode 100644 cli/src/commands/explore/calls.rs create mode 100644 cli/src/commands/explore/constants.rs create mode 100644 cli/src/commands/explore/mod.rs create mode 100644 cli/src/commands/explore/storage.rs diff --git a/cli/src/commands/explore.rs b/cli/src/commands/explore.rs deleted file mode 100644 index 60150644f9..0000000000 --- a/cli/src/commands/explore.rs +++ /dev/null @@ -1,489 +0,0 @@ -use crate::utils::type_description::print_type_description; -use crate::utils::type_example::print_type_examples; -use crate::utils::FileOrUrl; -use clap::{Args, Parser as ClapParser, Subcommand}; - -use std::fmt::Write; -use std::write; - -use codec::Decode; -use color_eyre::eyre::eyre; -use frame_metadata::v15::{ - PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, -}; -use frame_metadata::RuntimeMetadataPrefixed; -use scale_info::form::PortableForm; -use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; -use scale_value::{Composite, ValueDef}; - -use subxt::utils::H256; -use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; -use subxt::{tx, OnlineClient}; - -/// Explore pallets, calls, call parameters, storage entries and constants. Also allows for creating (unsigned) extrinsics. -/// -/// # Example -/// -/// ## Pallets -/// -/// Show the pallets that are available: -/// ``` -/// subxt explore --file=polkadot_metadata.scale -/// ``` -/// -/// ## Calls -/// -/// Show the calls in a pallet: -/// ``` -/// subxt explore Balances calls -/// ``` -/// Show the call parameters a call expects: -/// ``` -/// subxt explore Balances calls transfer -/// ``` -/// Create an unsigned extrinsic from a scale value, validate it and output its hex representation -/// ``` -/// subxt explore Grandpa calls note_stalled { "delay": 5, "best_finalized_block_number": 5 } -/// # Encoded call data: -/// # 0x2c0411020500000005000000 -/// subxt explore Balances calls transfer "{ \"dest\": v\"Raw\"((255, 255, 255)), \"value\": 0 }" -/// # Encoded call data: -/// # 0x24040607020cffffff00 -/// ``` -/// ## Constants -/// -/// Show the constants in a pallet: -/// ``` -/// subxt explore Balances constants -/// ``` -/// ## Storage -/// -/// Show the storage entries in a pallet -/// ``` -/// subxt explore Alliance storage -/// ``` -/// Show the types and value of a specific storage entry -/// ``` -/// subxt explore Alliance storage Announcements [KEY_SCALE_VALUE] -/// ``` -/// -#[derive(Debug, ClapParser)] -pub struct Opts { - #[command(flatten)] - file_or_url: FileOrUrl, - pallet: Option, - #[command(subcommand)] - pallet_subcommand: Option, -} - -#[derive(Debug, Clone, Subcommand)] -pub enum PalletSubcommand { - Calls(CallsSubcommand), - Constants, - Storage(StorageSubcommand), -} - -#[derive(Debug, Clone, Args)] -pub struct CallsSubcommand { - call: Option, - #[clap(required = false)] - trailing_args: Vec, -} - -#[derive(Debug, Clone, Args)] -pub struct StorageSubcommand { - storage_entry: Option, - #[clap(required = false)] - trailing_args: Vec, -} - -/// cargo run -- explore --file=../artifacts/polkadot_metadata.scale -pub async fn run(opts: Opts) -> color_eyre::Result<()> { - // get the metadata - let bytes = opts.file_or_url.fetch().await?; - let metadata_prefixed = ::decode(&mut &bytes[..])?; - let metadata = Metadata::try_from(metadata_prefixed)?; - - // if no pallet specified, show user the pallets to choose from: - let Some(pallet_name) = opts.pallet else { - let available_pallets = print_available_pallets(metadata.runtime_metadata()); - println!("{available_pallets}\n\nIf you want to explore a pallet:\n - subxt explore ", ); - return Ok(()); - }; - - // if specified pallet is wrong, show user the pallets to choose from (but this time as an error): - let Some(pallet_metadata) = metadata.runtime_metadata().pallets.iter().find(|pallet| pallet.name == pallet_name)else { - return Err(eyre!("pallet \"{}\" not found in metadata!\n{}", pallet_name, print_available_pallets(metadata.runtime_metadata()))); - }; - - // if correct pallet was specified but no subcommand, instruct the user how to proceed: - let Some(pallet_subcomand) = opts.pallet_subcommand else { - let docs_string = print_docs_with_indent(&pallet_metadata.docs, 4); - if !docs_string.is_empty() { - // currently it seems like all doc strings are empty - println!("Pallet \"{pallet_name}\":\n{docs_string}"); - } - println!("To explore the \"{pallet_name}\" pallet further, use one of the following:\n\ - - subxt explore {pallet_name} calls\n\ - - subxt explore {pallet_name} constants\n\ - - subxt explore {pallet_name} storage"); - return Ok(()); - }; - - match pallet_subcomand { - PalletSubcommand::Calls(calls_subcommand) => { - explore_calls(calls_subcommand, &metadata, pallet_metadata) - } - PalletSubcommand::Constants => explore_constants(&metadata, pallet_metadata), - PalletSubcommand::Storage(storage_subcommand) => { - // if the metadata came from some url, we use that same url to make storage calls against. - let node_url = opts.file_or_url.url.map(|url| url.to_string()); - explore_storage(storage_subcommand, &metadata, pallet_metadata, node_url).await - } - } -} - -fn explore_calls( - calls_subcommand: CallsSubcommand, - metadata: &Metadata, - pallet_metadata: &PalletMetadata, -) -> color_eyre::Result<()> { - let pallet_name = pallet_metadata.name.as_str(); - - // get the enum that stores the possible calls: - let (calls_enum_type_def, calls_enum_type) = - get_calls_enum_type(pallet_metadata, &metadata.runtime_metadata().types)?; - - // if no call specified, show user the calls to choose from: - let Some(call_name) = calls_subcommand.call else { - let available_calls = print_available_calls(calls_enum_type_def, pallet_name); - println!("{available_calls}\n\nIf you want to explore a call: \n - subxt explore {pallet_name} calls ", ); - return Ok(()); - }; - - // if specified call is wrong, show user the calls to choose from (but this time as an error): - let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name == call_name) else { - return Err(eyre!("\"{call_name}\" call not found in \"{pallet_name}\" pallet!\n{}", print_available_calls(calls_enum_type_def, pallet_name))); - }; - - // collect all the trailing arguments into a single string that is later into a scale_value::Value - let trailing_args = calls_subcommand.trailing_args.join(" "); - - // if no trailing arguments specified show user the expected type of arguments with examples: - if trailing_args.is_empty() { - let mut type_description = - print_type_description(&call.fields, &metadata.runtime_metadata().types)?; - type_description = with_indent(type_description, 4); - let mut type_examples = - print_type_examples(&call.fields, &metadata.runtime_metadata().types)?; - type_examples = with_indent(type_examples, 4); - let mut output = String::new(); - write!(output, "Call \"{call_name}\" in \"{pallet_name}\" pallet:\n - expects a value of type {}::{call_name}\n", calls_enum_type.path)?; - write!( - output, - " - The type looks like this:\n{type_description}\n{type_examples}" - )?; - write!(output, "\n\nYou can create an unsigned extrinsic, by providing a scale value of this type to:\n - subxt explore {pallet_name} calls {call_name} \n")?; - println!("{output}"); - - return Ok(()); - } - - // parse scale_value from trailing arguments and try to create an unsigned extrinsic with it: - let value = scale_value::stringify::from_str(&trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; - let value_as_composite = value_into_composite(value); - let offline_client = new_offline_client(metadata.clone()); - let payload = tx::dynamic(pallet_name, call_name, value_as_composite); - let unsigned_extrinsic = offline_client.tx().create_unsigned(&payload)?; - let hex_bytes = format!("0x{}", hex::encode(unsigned_extrinsic.encoded())); - - println!("Encoded call data:"); - println!("{hex_bytes}"); - - Ok(()) -} - -fn explore_constants( - metadata: &Metadata, - pallet_metadata: &PalletMetadata, -) -> color_eyre::Result<()> { - // print all constants in this pallet together with their type, value and the docs as an explanation: - let pallet_name = pallet_metadata.name.as_str(); - let output = if pallet_metadata.constants.is_empty() { - format!("The \"{pallet_name}\" pallet has no constants.") - } else { - let mut output = format!("The \"{pallet_name}\" pallet has the following constants:"); - for constant in pallet_metadata.constants.iter() { - let type_description = print_type_description(&constant.ty.id, metadata.types())?; - let scale_val = scale_value::scale::decode_as_type( - &mut &constant.value[..], - constant.ty.id, - metadata.types(), - )?; - let name_and_type = format!( - "\n - {}: {} = {}", - constant.name, - type_description, - scale_value::stringify::to_string(&scale_val) - ); - write!( - output, - "{}\n{}", - name_and_type, - print_docs_with_indent(&constant.docs, 8) - )?; - } - output - }; - println!("{output}"); - Ok(()) -} - -async fn explore_storage( - storage_subcommand: StorageSubcommand, - metadata: &Metadata, - pallet_metadata: &PalletMetadata, - custom_online_client_url: Option, -) -> color_eyre::Result<()> { - let pallet_name = pallet_metadata.name.as_str(); - let trailing_args = storage_subcommand.trailing_args.join(" "); - let trailing_args = trailing_args.trim(); - - let Some(storage_metadata) = &pallet_metadata.storage else { - println!("The \"{pallet_name}\" pallet has no storage entries."); - return Ok(()); - }; - - // if no storage entry specified, show user the calls to choose from: - let Some(entry_name) = storage_subcommand.storage_entry else { - let storage_entries = print_available_storage_entries(storage_metadata, pallet_name); - println!("{storage_entries}\n\nIf you want to explore a storage entry:\n - subxt explore {pallet_name} storage ", ); - return Ok(()); - }; - - // if specified call storage entry wrong, show user the storage entries to choose from (but this time as an error): - let Some(storage) = storage_metadata.entries.iter().find(|entry| entry.name == entry_name) else { - return Err(eyre!("Storage entry \"{entry_name}\" not found in \"{pallet_name}\" pallet!\n{}", print_available_storage_entries(storage_metadata, pallet_name))); - }; - - let (return_ty_id, key_ty_id) = match storage.ty { - StorageEntryType::Plain(value) => (value.id, None), - StorageEntryType::Map { value, key, .. } => (value.id, Some(key.id)), - }; - - // get the type and type description for the return and key type: - let mut output = format!("Storage entry \"{entry_name}\" in \"{pallet_name}\" pallet:"); - - let docs_string = print_docs_with_indent(&storage.docs, 4); - if !docs_string.is_empty() { - write!(output, "\n{docs_string}")?; - } - - if let Some(key_ty_id) = key_ty_id { - let key_ty_description = print_type_description(&key_ty_id, metadata.types())?; - write!( - output, - "\n - Can be accessed by providing a key of type: {}", - key_ty_description - )?; - let mut key_ty_examples = print_type_examples(&key_ty_id, metadata.types())?; - key_ty_examples = with_indent_and_first_dash(key_ty_examples, 4); - write!(output, "\n{}", key_ty_examples)?; - } else { - write!(output, "\n - Can be accessed without providing a key.")?; - } - - let mut return_ty_description = print_type_description(&return_ty_id, metadata.types())?; - return_ty_description = if return_ty_description.contains('\n') { - format!("\n{}", with_indent(return_ty_description, 4)) - } else { - return_ty_description - }; - write!( - output, - "\n - The storage entry \"{entry_name}\" has a value of type: {}", - return_ty_description - )?; - - // construct the vector of scale_values that should be used as a key to the storage (often empty) - - let key_scale_values = if let Some(key_ty_id) = key_ty_id.filter(|_| !trailing_args.is_empty()) - { - let key_scale_value = scale_value::stringify::from_str(trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; - write!( - output, - "\nYou submitted the following value as a key: {}", - scale_value::stringify::to_string(&key_scale_value) - )?; - let mut key_bytes: Vec = Vec::new(); - scale_value::scale::encode_as_type( - &key_scale_value, - key_ty_id, - metadata.types(), - &mut key_bytes, - )?; - let bytes_composite = scale_value::Value::from_bytes(&key_bytes); - vec![bytes_composite] - } else { - Vec::new() - }; - - if key_ty_id.is_none() && !trailing_args.is_empty() { - write!(output, "\nWarning: You submitted the following value as a key, but it will be ignored, because the storage entry does not require a key: \"{}\"\n", trailing_args)?; - } - println!("{output}"); - // construct and submit the storage query if either no key is needed or som key was provided as a scale value - - if key_ty_id.is_none() || !key_scale_values.is_empty() { - let online_client = match custom_online_client_url { - None => OnlineClient::::new().await?, - Some(url) => OnlineClient::::from_url(url).await?, - }; - let storage_query = subxt::dynamic::storage(pallet_name, entry_name, key_scale_values); - let decoded_value_thunk_or_none = online_client - .storage() - .at_latest() - .await? - .fetch(&storage_query) - .await?; - - let decoded_value_thunk = - decoded_value_thunk_or_none.ok_or(eyre!("Value not found in storage."))?; - - let value = decoded_value_thunk.to_value()?; - let value_string = scale_value::stringify::to_string(&value); - println!("\nValue in storage: {value_string}"); - } else { - println!("\nIf you want to get the value of storage entry \"{entry_name}\" in pallet \"{pallet_name}\":\n - subxt explore {pallet_name} storage {entry_name} ", ); - } - - Ok(()) -} - -fn print_available_pallets(metadata_v15: &RuntimeMetadataV15) -> String { - if metadata_v15.pallets.is_empty() { - "There are no pallets in this node.".to_string() - } else { - let mut output = "Available pallets are:".to_string(); - for pallet in metadata_v15.pallets.iter() { - write!(output, "\n - {}", pallet.name).unwrap(); - } - output - } -} - -fn print_available_calls(pallet_calls: &TypeDefVariant, pallet_name: &str) -> String { - if pallet_calls.variants.is_empty() { - return format!("The \"{}\" pallet has no calls.", pallet_name); - } - let mut output = format!("Calls in \"{pallet_name}\" pallet:"); - for variant in pallet_calls.variants.iter() { - write!(output, "\n - {}", variant.name).unwrap(); - } - output -} - -fn print_available_storage_entries( - storage_metadata: &PalletStorageMetadata, - pallet_name: &str, -) -> String { - if storage_metadata.entries.is_empty() { - format!("The \"{}\" pallet has no storage entries.", pallet_name) - } else { - let mut output = format!( - "The \"{}\" pallet has the following storage entries:", - pallet_name - ); - for entry in storage_metadata.entries.iter() { - write!(output, "\n - {}", entry.name).unwrap(); - } - output - } -} - -fn get_calls_enum_type<'a>( - pallet: &'a frame_metadata::v15::PalletMetadata, - registry: &'a PortableRegistry, -) -> color_eyre::Result<(&'a TypeDefVariant, &'a Type)> { - let calls = pallet - .calls - .as_ref() - .ok_or(eyre!("The \"{}\" pallet has no calls.", pallet.name))?; - let calls_enum_type = registry - .resolve(calls.ty.id) - .ok_or(eyre!("calls type with id {} not found.", calls.ty.id))?; - // should always be a variant type, where each variant corresponds to one call. - let calls_enum_type_def = match &calls_enum_type.type_def { - TypeDef::Variant(variant) => variant, - _ => { - return Err(eyre!("calls type is not a variant")); - } - }; - Ok((calls_enum_type_def, calls_enum_type)) -} - -/// composites stay composites, all other types are converted into a 1-fielded unnamed composite -fn value_into_composite(value: scale_value::Value) -> scale_value::Composite<()> { - match value.value { - ValueDef::Composite(composite) => composite, - _ => Composite::Unnamed(vec![value]), - } -} - -fn new_offline_client(metadata: Metadata) -> OfflineClient { - let genesis_hash = { - let h = "91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"; - let bytes = hex::decode(h).unwrap(); - H256::from_slice(&bytes) - }; - - let runtime_version = subxt::rpc::types::RuntimeVersion { - spec_version: 9370, - transaction_version: 20, - other: Default::default(), - }; - - OfflineClient::::new(genesis_hash, runtime_version, metadata) -} - -fn print_docs_with_indent(docs: &[String], indent: usize) -> String { - // take at most the first paragraph of documentation, such that it does not get too long. - let docs_str = docs - .iter() - .map(|e| e.trim()) - .take_while(|e| !e.is_empty()) - .collect::>() - .join("\n"); - with_indent_and_first_dash(docs_str, indent) -} - -fn with_indent(s: String, indent: usize) -> String { - let indent = make_indent(indent); - s.lines() - .map(|line| format!("{indent}{line}")) - .collect::>() - .join("\n") -} - -fn with_indent_and_first_dash(s: String, indent: usize) -> String { - let blank_indent = make_indent(indent); - s.lines() - .enumerate() - .map(|(i, line)| { - if i == 0 { - format!("{}- {line}", make_indent(indent - 2)) - } else { - format!("{blank_indent}{line}") - } - }) - .collect::>() - .join("\n") -} - -fn make_indent(indent: usize) -> String { - let mut s = String::new(); - for _ in 0..indent { - s.push(' '); - } - s -} diff --git a/cli/src/commands/explore/calls.rs b/cli/src/commands/explore/calls.rs new file mode 100644 index 0000000000..3d6386933e --- /dev/null +++ b/cli/src/commands/explore/calls.rs @@ -0,0 +1,148 @@ +use crate::utils::type_description::print_type_description; +use crate::utils::type_example::print_type_examples; +use crate::utils::{with_indent, FileOrUrl}; +use clap::{Args, Parser as ClapParser, Subcommand}; + +use std::fmt::Write; +use std::write; + +use codec::Decode; +use color_eyre::eyre::eyre; +use frame_metadata::v15::{ + PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, +}; +use frame_metadata::RuntimeMetadataPrefixed; +use scale_info::form::PortableForm; +use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; +use scale_value::{Composite, ValueDef}; + +use subxt::utils::H256; +use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; +use subxt::{tx, OnlineClient}; + +#[derive(Debug, Clone, Args)] +pub struct CallsSubcommand { + call: Option, + #[clap(required = false)] + trailing_args: Vec, +} + +pub(crate) fn explore_calls( + command: CallsSubcommand, + metadata: &Metadata, + pallet_metadata: &PalletMetadata, +) -> color_eyre::Result<()> { + let pallet_name = pallet_metadata.name.as_str(); + + // get the enum that stores the possible calls: + let (calls_enum_type_def, calls_enum_type) = + get_calls_enum_type(pallet_metadata, &metadata.runtime_metadata().types)?; + + // if no call specified, show user the calls to choose from: + let Some(call_name) = command.call else { + let available_calls = print_available_calls(calls_enum_type_def, pallet_name); + println!("Usage:\n subxt explore {pallet_name} calls \n explore a specific call within this pallet\n\n{available_calls}", ); + return Ok(()); + }; + + // if specified call is wrong, show user the calls to choose from (but this time as an error): + let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name.to_lowercase() == call_name.to_lowercase()) else { + let available_calls = print_available_calls(calls_enum_type_def, pallet_name); + let description = format!("Usage:\n subxt explore {pallet_name} calls \n explore a specific call within this pallet\n\n{available_calls}", ); + return Err(eyre!("\"{call_name}\" call not found in \"{pallet_name}\" pallet!\n\n{description}")); + }; + + // collect all the trailing arguments into a single string that is later into a scale_value::Value + let trailing_args = command.trailing_args.join(" "); + + // if no trailing arguments specified show user the expected type of arguments with examples: + if trailing_args.is_empty() { + let mut type_description = + print_type_description(&call.fields, &metadata.runtime_metadata().types)?; + type_description = with_indent(type_description, 4); + let mut type_examples = print_type_examples( + &call.fields, + &metadata.runtime_metadata().types, + "SCALE_VALUE", + )?; + type_examples = with_indent(type_examples, 4); + let mut output = String::new(); + write!(output, "Usage:\n subxt explore {pallet_name} calls {call_name} \n construct the call by providing a valid argument\n\n")?; + write!( + output, + "The call expect expects a with this shape:\n{type_description}\n\n{}\n\nYou may need to surround the value in single quotes when providing it as an argument." + , &type_examples[4..])?; + println!("{output}"); + return Ok(()); + } + + // parse scale_value from trailing arguments and try to create an unsigned extrinsic with it: + let value = scale_value::stringify::from_str(&trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; + let value_as_composite = value_into_composite(value); + let offline_client = new_offline_client(metadata.clone()); + let payload = tx::dynamic(pallet_name, call_name, value_as_composite); + let unsigned_extrinsic = offline_client.tx().create_unsigned(&payload)?; + let hex_bytes = format!("0x{}", hex::encode(unsigned_extrinsic.encoded())); + println!("Encoded call data:\n {hex_bytes}"); + + Ok(()) +} + +fn print_available_calls(pallet_calls: &TypeDefVariant, pallet_name: &str) -> String { + if pallet_calls.variants.is_empty() { + return format!("No 's available in the \"{pallet_name}\" pallet."); + } + let mut output = format!("Available 's in the \"{pallet_name}\" pallet:"); + + let mut strings: Vec<_> = pallet_calls.variants.iter().map(|c| &c.name).collect(); + strings.sort(); + for variant in strings { + write!(output, "\n {}", variant).unwrap(); + } + output +} + +fn get_calls_enum_type<'a>( + pallet: &'a frame_metadata::v15::PalletMetadata, + registry: &'a PortableRegistry, +) -> color_eyre::Result<(&'a TypeDefVariant, &'a Type)> { + let calls = pallet + .calls + .as_ref() + .ok_or(eyre!("The \"{}\" pallet has no calls.", pallet.name))?; + let calls_enum_type = registry + .resolve(calls.ty.id) + .ok_or(eyre!("calls type with id {} not found.", calls.ty.id))?; + // should always be a variant type, where each variant corresponds to one call. + let calls_enum_type_def = match &calls_enum_type.type_def { + TypeDef::Variant(variant) => variant, + _ => { + return Err(eyre!("calls type is not a variant")); + } + }; + Ok((calls_enum_type_def, calls_enum_type)) +} + +fn new_offline_client(metadata: Metadata) -> OfflineClient { + let genesis_hash = { + let h = "91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"; + let bytes = hex::decode(h).unwrap(); + H256::from_slice(&bytes) + }; + + let runtime_version = subxt::rpc::types::RuntimeVersion { + spec_version: 9370, + transaction_version: 20, + other: Default::default(), + }; + + OfflineClient::::new(genesis_hash, runtime_version, metadata) +} + +/// composites stay composites, all other types are converted into a 1-fielded unnamed composite +fn value_into_composite(value: scale_value::Value) -> scale_value::Composite<()> { + match value.value { + ValueDef::Composite(composite) => composite, + _ => Composite::Unnamed(vec![value]), + } +} diff --git a/cli/src/commands/explore/constants.rs b/cli/src/commands/explore/constants.rs new file mode 100644 index 0000000000..ad06bdf263 --- /dev/null +++ b/cli/src/commands/explore/constants.rs @@ -0,0 +1,92 @@ +use crate::utils::type_description::print_type_description; +use crate::utils::{print_docs_with_indent, with_indent}; +use clap::{Args, Parser as ClapParser, Subcommand}; + +use std::fmt::Write; +use std::write; + +use codec::Decode; +use color_eyre::eyre::eyre; +use frame_metadata::v15::{ + PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, +}; +use frame_metadata::RuntimeMetadataPrefixed; +use scale_info::form::PortableForm; +use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; +use scale_value::{Composite, ValueDef}; + +use subxt::utils::H256; +use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; +use subxt::{tx, OnlineClient}; + +#[derive(Debug, Clone, Args)] +pub struct ConstantsSubcommand { + constant: Option, +} + +pub(crate) fn explore_constants( + command: ConstantsSubcommand, + metadata: &Metadata, + pallet_metadata: &PalletMetadata, +) -> color_eyre::Result<()> { + let pallet_name = pallet_metadata.name.as_str(); + let Some(constant_name) = command.constant else { + let available_constants = print_available_constants(&pallet_metadata, pallet_name); + println!("Usage:\n subxt explore {pallet_name} constants \n explore a specific call within this pallet\n\n{available_constants}", ); + return Ok(()); + }; + + // if specified constant is wrong, show user the constants to choose from (but this time as an error): + let Some(constant) = pallet_metadata.constants.iter().find(|constant| constant.name.to_lowercase() == constant_name.to_lowercase()) else { + let available_constants = print_available_constants(&pallet_metadata, pallet_name); + let description = format!("Usage:\n subxt explore {pallet_name} constants \n explore a specific call within this pallet\n\n{available_constants}", ); + let err = eyre!("constant \"{constant_name}\" not found in \"{pallet_name}\" pallet!\n\n{description}"); + return Err(err); + }; + + // docs + let mut output = String::new(); + let doc_string = print_docs_with_indent(&constant.docs, 4); + if !doc_string.is_empty() { + write!(output, "Description:\n{doc_string}")?; + } + + // shape + let mut type_description = print_type_description(&constant.ty.id, metadata.types())?; + type_description = with_indent(type_description, 4); + write!( + output, + "\n\nThe constant has the following shape:\n{type_description}" + )?; + + // value + let scale_val = scale_value::scale::decode_as_type( + &mut &constant.value[..], + constant.ty.id, + metadata.types(), + )?; + write!( + output, + "\n\nThe value of the constant is:\n {}", + scale_value::stringify::to_string(&scale_val) + )?; + + println!("{output}"); + Ok(()) +} + +fn print_available_constants( + pallet_metadata: &PalletMetadata, + pallet_name: &str, +) -> String { + if pallet_metadata.constants.is_empty() { + return format!("No 's available in the \"{pallet_name}\" pallet."); + } + let mut output = format!("Available 's in the \"{pallet_name}\" pallet:"); + let mut strings: Vec<_> = pallet_metadata.constants.iter().map(|c| &c.name).collect(); + strings.sort(); + for constant in strings { + write!(output, "\n {}", constant).unwrap(); + } + output +} diff --git a/cli/src/commands/explore/mod.rs b/cli/src/commands/explore/mod.rs new file mode 100644 index 0000000000..db84d08ebf --- /dev/null +++ b/cli/src/commands/explore/mod.rs @@ -0,0 +1,154 @@ +use crate::utils::type_description::print_type_description; +use crate::utils::type_example::print_type_examples; +use crate::utils::{print_docs_with_indent, FileOrUrl}; +use clap::{Args, Parser as ClapParser, Subcommand}; + +use std::fmt::Write; +use std::ptr::write; +use std::write; + +use codec::Decode; +use color_eyre::eyre::eyre; +use frame_metadata::v15::{ + PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, +}; +use frame_metadata::RuntimeMetadataPrefixed; +use scale_info::form::PortableForm; +use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; +use scale_value::{Composite, ValueDef}; +use syn::__private::str; + +use crate::commands::explore::calls::{explore_calls, CallsSubcommand}; +use crate::commands::explore::constants::{explore_constants, ConstantsSubcommand}; +use crate::commands::explore::storage::{explore_storage, StorageSubcommand}; +use subxt::utils::H256; +use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; +use subxt::{tx, OnlineClient}; + +mod calls; +mod constants; +mod storage; + +/// Explore pallets, calls, call parameters, storage entries and constants. Also allows for creating (unsigned) extrinsics. +/// +/// # Example +/// +/// ## Pallets +/// +/// Show the pallets that are available: +/// ``` +/// subxt explore --file=polkadot_metadata.scale +/// ``` +/// +/// ## Calls +/// +/// Show the calls in a pallet: +/// ``` +/// subxt explore Balances calls +/// ``` +/// Show the call parameters a call expects: +/// ``` +/// subxt explore Balances calls transfer +/// ``` +/// Create an unsigned extrinsic from a scale value, validate it and output its hex representation +/// ``` +/// subxt explore Grandpa calls note_stalled { "delay": 5, "best_finalized_block_number": 5 } +/// # Encoded call data: +/// # 0x2c0411020500000005000000 +/// subxt explore Balances calls transfer "{ \"dest\": v\"Raw\"((255, 255, 255)), \"value\": 0 }" +/// # Encoded call data: +/// # 0x24040607020cffffff00 +/// ``` +/// ## Constants +/// +/// Show the constants in a pallet: +/// ``` +/// subxt explore Balances constants +/// ``` +/// ## Storage +/// +/// Show the storage entries in a pallet +/// ``` +/// subxt explore Alliance storage +/// ``` +/// Show the types and value of a specific storage entry +/// ``` +/// subxt explore Alliance storage Announcements [KEY_SCALE_VALUE] +/// ``` +/// +#[derive(Debug, ClapParser)] +pub struct Opts { + #[command(flatten)] + file_or_url: FileOrUrl, + pallet: Option, + #[command(subcommand)] + pallet_subcommand: Option, +} + +#[derive(Debug, Clone, Subcommand)] +pub enum PalletSubcommand { + Calls(CallsSubcommand), + Constants(ConstantsSubcommand), + Storage(StorageSubcommand), +} + +/// cargo run -- explore --file=../artifacts/polkadot_metadata.scale +pub async fn run(opts: Opts) -> color_eyre::Result<()> { + // get the metadata + let bytes = opts.file_or_url.fetch().await?; + let metadata_prefixed = ::decode(&mut &bytes[..])?; + let metadata = Metadata::try_from(metadata_prefixed)?; + + // if no pallet specified, show user the pallets to choose from: + let Some(pallet_name) = opts.pallet else { + let available_pallets = print_available_pallets(metadata.runtime_metadata()); + println!("Usage:\n subxt explore \n explore a specific pallet\n\n{available_pallets}", ); + return Ok(()); + }; + + // if specified pallet is wrong, show user the pallets to choose from (but this time as an error): + let Some(pallet_metadata) = metadata.runtime_metadata().pallets.iter().find(|pallet| pallet.name.to_lowercase() == pallet_name.to_lowercase())else { + return Err(eyre!("pallet \"{}\" not found in metadata!\n{}", pallet_name, print_available_pallets(metadata.runtime_metadata()))); + }; + + // if correct pallet was specified but no subcommand, instruct the user how to proceed: + let Some(pallet_subcomand) = opts.pallet_subcommand else { + let docs_string = print_docs_with_indent(&pallet_metadata.docs, 4); + let mut output = String::new(); + if !docs_string.is_empty() { + write!(output, "Description:\n{docs_string}")?; + } + write!(output, "Usage:")?; + write!(output, "\n subxt explore {pallet_name} calls\n explore the calls that can be made into this pallet")?; + write!(output, "\n subxt explore {pallet_name} constants\n explore the constants held in this pallet")?; + write!(output, "\n subxt explore {pallet_name} storage\n explore the storage values held in this pallet")?; + println!("{output}"); + return Ok(()); + }; + + match pallet_subcomand { + PalletSubcommand::Calls(command) => explore_calls(command, &metadata, pallet_metadata), + PalletSubcommand::Constants(command) => { + explore_constants(command, &metadata, pallet_metadata) + } + PalletSubcommand::Storage(command) => { + // if the metadata came from some url, we use that same url to make storage calls against. + let node_url = opts.file_or_url.url.map(|url| url.to_string()); + explore_storage(command, &metadata, pallet_metadata, node_url).await + } + } +} + +fn print_available_pallets(metadata_v15: &RuntimeMetadataV15) -> String { + if metadata_v15.pallets.is_empty() { + "There are no values available.".to_string() + } else { + let mut output = "Available values are:".to_string(); + let mut strings: Vec<_> = metadata_v15.pallets.iter().map(|p| &p.name).collect(); + strings.sort(); + for pallet in strings { + write!(output, "\n {}", pallet).unwrap(); + } + output + } +} diff --git a/cli/src/commands/explore/storage.rs b/cli/src/commands/explore/storage.rs new file mode 100644 index 0000000000..7d0d9610dd --- /dev/null +++ b/cli/src/commands/explore/storage.rs @@ -0,0 +1,182 @@ +use crate::utils::type_description::print_type_description; +use crate::utils::type_example::print_type_examples; +use crate::utils::{print_docs_with_indent, with_indent, FileOrUrl}; +use clap::{Args, Parser as ClapParser, Subcommand}; + +use std::fmt::Write; +use std::write; + +use codec::Decode; +use color_eyre::eyre::eyre; +use frame_metadata::v15::{ + PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, +}; +use frame_metadata::RuntimeMetadataPrefixed; +use scale_info::form::PortableForm; +use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; +use scale_value::{Composite, ValueDef}; + +use subxt::utils::H256; +use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; +use subxt::{tx, OnlineClient}; + +#[derive(Debug, Clone, Args)] +pub struct StorageSubcommand { + storage_entry: Option, + #[clap(required = false)] + trailing_args: Vec, +} + +pub(crate) async fn explore_storage( + command: StorageSubcommand, + metadata: &Metadata, + pallet_metadata: &PalletMetadata, + custom_online_client_url: Option, +) -> color_eyre::Result<()> { + let pallet_name = pallet_metadata.name.as_str(); + let trailing_args = command.trailing_args.join(" "); + let trailing_args = trailing_args.trim(); + + let Some(storage_metadata) = &pallet_metadata.storage else { + println!("The \"{pallet_name}\" pallet has no storage entries."); + return Ok(()); + }; + + // if no storage entry specified, show user the calls to choose from: + let Some(entry_name) = command.storage_entry else { + let storage_entries = print_available_storage_entries(storage_metadata, pallet_name); + println!("Usage:\n subxt explore {pallet_name} storage \n view details for a specific storage entry\n\n{storage_entries}"); + return Ok(()); + }; + + // if specified call storage entry wrong, show user the storage entries to choose from (but this time as an error): + let Some(storage) = storage_metadata.entries.iter().find(|entry| entry.name.to_lowercase() == entry_name.to_lowercase()) else { + let storage_entries = print_available_storage_entries(storage_metadata, pallet_name); + let description = format!("Usage:\n subxt explore {pallet_name} storage \n view details for a specific storage entry\n\n{storage_entries}"); + return Err(eyre!("Storage entry \"{entry_name}\" not found in \"{pallet_name}\" pallet!\n\n{description}")); + }; + + let (return_ty_id, key_ty_id) = match storage.ty { + StorageEntryType::Plain(value) => (value.id, None), + StorageEntryType::Map { value, key, .. } => (value.id, Some(key.id)), + }; + + // get the type and type description for the return and key type: + let mut output = String::new(); + + // only inform user about usage if a key can be provided: + if key_ty_id.is_some() { + write!( + output, + "Usage:\n subxt explore {pallet_name} storage {entry_name} " + )?; + } + + let docs_string = print_docs_with_indent(&storage.docs, 4); + if !docs_string.is_empty() { + write!(output, "\n\nDescription:\n{docs_string}")?; + } + + // inform user about shape of key if it can be provided: + if let Some(key_ty_id) = key_ty_id { + let mut key_ty_description = print_type_description(&key_ty_id, metadata.types())?; + key_ty_description = with_indent(key_ty_description, 4); + let mut key_ty_examples = print_type_examples(&key_ty_id, metadata.types(), "")?; + key_ty_examples = with_indent(key_ty_examples, 4); + write!( + output, + "\n\nThe has the following shape:\n {key_ty_description}\n\n{}", + &key_ty_examples[4..] + )?; + } else { + write!( + output, + "\n\nThe constant can be accessed without providing a key." + )?; + } + + let mut return_ty_description = print_type_description(&return_ty_id, metadata.types())?; + return_ty_description = if return_ty_description.contains('\n') { + format!("\n{}", with_indent(return_ty_description, 4)) + } else { + return_ty_description + }; + write!( + output, + "\n\nThe storage entry has the following shape: {}", + return_ty_description + )?; + + // construct the vector of scale_values that should be used as a key to the storage (often empty) + + let key_scale_values = if let Some(key_ty_id) = key_ty_id.filter(|_| !trailing_args.is_empty()) + { + let key_scale_value = scale_value::stringify::from_str(trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; + write!( + output, + "\n\nYou submitted the following value as a key:\n{}", + with_indent(scale_value::stringify::to_string(&key_scale_value), 4) + )?; + let mut key_bytes: Vec = Vec::new(); + scale_value::scale::encode_as_type( + &key_scale_value, + key_ty_id, + metadata.types(), + &mut key_bytes, + )?; + let bytes_composite = scale_value::Value::from_bytes(&key_bytes); + vec![bytes_composite] + } else { + Vec::new() + }; + + if key_ty_id.is_none() && !trailing_args.is_empty() { + write!(output, "\n\nWarning: You submitted the following value as a key, but it will be ignored, because the storage entry does not require a key: \"{}\"", trailing_args)?; + } + println!("{output}"); + + // construct and submit the storage entry request if either no key is needed or som key was provided as a scale value + if key_ty_id.is_none() || !key_scale_values.is_empty() { + let online_client = match custom_online_client_url { + None => OnlineClient::::new().await?, + Some(url) => OnlineClient::::from_url(url).await?, + }; + let storage_query = subxt::dynamic::storage(pallet_name, entry_name, key_scale_values); + let decoded_value_thunk_or_none = online_client + .storage() + .at_latest() + .await? + .fetch(&storage_query) + .await?; + + let decoded_value_thunk = + decoded_value_thunk_or_none.ok_or(eyre!("Value not found in storage."))?; + + let value = decoded_value_thunk.to_value()?; + let mut value_string = scale_value::stringify::to_string(&value); + value_string = with_indent(value_string, 4); + println!("\nThe value of the storage entry is:\n{value_string}"); + } + + Ok(()) +} + +fn print_available_storage_entries( + storage_metadata: &PalletStorageMetadata, + pallet_name: &str, +) -> String { + if storage_metadata.entries.is_empty() { + format!("No 's available in the \"{pallet_name}\" pallet.") + } else { + let mut output = format!( + "Available 's in the \"{}\" pallet:", + pallet_name + ); + let mut strings: Vec<_> = storage_metadata.entries.iter().map(|s| &s.name).collect(); + strings.sort(); + for entry in strings { + write!(output, "\n {}", entry).unwrap(); + } + output + } +} diff --git a/cli/src/utils.rs b/cli/src/utils.rs index abf4da24ec..84e3ef28e7 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -75,3 +75,25 @@ impl FileOrUrl { } } } + +pub(crate) fn print_docs_with_indent(docs: &[String], indent: usize) -> String { + // take at most the first paragraph of documentation, such that it does not get too long. + let docs_str = docs + .iter() + .map(|e| e.trim()) + .take_while(|e| !e.is_empty()) + .collect::>() + .join("\n"); + with_indent(docs_str, indent) +} + +pub(crate) fn with_indent(s: String, indent: usize) -> String { + let mut indent_str = String::new(); + for _ in 0..indent { + indent_str.push(' '); + } + s.lines() + .map(|line| format!("{indent_str}{line}")) + .collect::>() + .join("\n") +} diff --git a/cli/src/utils/type_example.rs b/cli/src/utils/type_example.rs index d487107940..eeb9c66731 100644 --- a/cli/src/utils/type_example.rs +++ b/cli/src/utils/type_example.rs @@ -8,7 +8,11 @@ use scale_value::{Value, ValueDef}; use std::fmt::Write; use std::write; -pub fn print_type_examples(ty: &T, registry: &PortableRegistry) -> color_eyre::Result +pub fn print_type_examples( + ty: &T, + registry: &PortableRegistry, + type_placeholder: &str, +) -> color_eyre::Result where T: TypeExample, { @@ -16,15 +20,21 @@ where let mut output = String::new(); match type_examples.len() { 0 => { - write!(output, "There are no examples available for this type.")?; + write!( + output, + "There are no examples available for a {type_placeholder} matching this shape:" + )?; } 1 => { - write!(output, "Here is an example of this type as a scale value:")?; + write!( + output, + "Here is an example of a {type_placeholder} matching this shape:" + )?; } i => { write!( output, - "Here are {i} examples of this type as a scale value:" + "Here are {i} examples of a {type_placeholder} matching this shape:" )?; } }; From 884c2d962a8b1dc2760ed6a0b481e5e91324bc54 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 16 May 2023 19:39:04 +0200 Subject: [PATCH 14/17] fmt and clippy fix --- cli/src/commands/explore/calls.rs | 15 ++++++--------- cli/src/commands/explore/constants.rs | 19 ++++++------------- cli/src/commands/explore/mod.rs | 19 ++++++------------- cli/src/commands/explore/storage.rs | 18 ++++++------------ 4 files changed, 24 insertions(+), 47 deletions(-) diff --git a/cli/src/commands/explore/calls.rs b/cli/src/commands/explore/calls.rs index 3d6386933e..29d5e37feb 100644 --- a/cli/src/commands/explore/calls.rs +++ b/cli/src/commands/explore/calls.rs @@ -1,24 +1,21 @@ use crate::utils::type_description::print_type_description; use crate::utils::type_example::print_type_examples; -use crate::utils::{with_indent, FileOrUrl}; -use clap::{Args, Parser as ClapParser, Subcommand}; +use crate::utils::with_indent; +use clap::Args; use std::fmt::Write; use std::write; -use codec::Decode; use color_eyre::eyre::eyre; -use frame_metadata::v15::{ - PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, -}; -use frame_metadata::RuntimeMetadataPrefixed; +use frame_metadata::v15::PalletMetadata; + use scale_info::form::PortableForm; use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; use scale_value::{Composite, ValueDef}; +use subxt::tx; use subxt::utils::H256; use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; -use subxt::{tx, OnlineClient}; #[derive(Debug, Clone, Args)] pub struct CallsSubcommand { @@ -35,7 +32,7 @@ pub(crate) fn explore_calls( let pallet_name = pallet_metadata.name.as_str(); // get the enum that stores the possible calls: - let (calls_enum_type_def, calls_enum_type) = + let (calls_enum_type_def, _calls_enum_type) = get_calls_enum_type(pallet_metadata, &metadata.runtime_metadata().types)?; // if no call specified, show user the calls to choose from: diff --git a/cli/src/commands/explore/constants.rs b/cli/src/commands/explore/constants.rs index ad06bdf263..266bc0fb35 100644 --- a/cli/src/commands/explore/constants.rs +++ b/cli/src/commands/explore/constants.rs @@ -1,23 +1,16 @@ use crate::utils::type_description::print_type_description; use crate::utils::{print_docs_with_indent, with_indent}; -use clap::{Args, Parser as ClapParser, Subcommand}; +use clap::Args; use std::fmt::Write; use std::write; -use codec::Decode; use color_eyre::eyre::eyre; -use frame_metadata::v15::{ - PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, -}; -use frame_metadata::RuntimeMetadataPrefixed; +use frame_metadata::v15::PalletMetadata; + use scale_info::form::PortableForm; -use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; -use scale_value::{Composite, ValueDef}; -use subxt::utils::H256; -use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; -use subxt::{tx, OnlineClient}; +use subxt::Metadata; #[derive(Debug, Clone, Args)] pub struct ConstantsSubcommand { @@ -31,14 +24,14 @@ pub(crate) fn explore_constants( ) -> color_eyre::Result<()> { let pallet_name = pallet_metadata.name.as_str(); let Some(constant_name) = command.constant else { - let available_constants = print_available_constants(&pallet_metadata, pallet_name); + let available_constants = print_available_constants(pallet_metadata, pallet_name); println!("Usage:\n subxt explore {pallet_name} constants \n explore a specific call within this pallet\n\n{available_constants}", ); return Ok(()); }; // if specified constant is wrong, show user the constants to choose from (but this time as an error): let Some(constant) = pallet_metadata.constants.iter().find(|constant| constant.name.to_lowercase() == constant_name.to_lowercase()) else { - let available_constants = print_available_constants(&pallet_metadata, pallet_name); + let available_constants = print_available_constants(pallet_metadata, pallet_name); let description = format!("Usage:\n subxt explore {pallet_name} constants \n explore a specific call within this pallet\n\n{available_constants}", ); let err = eyre!("constant \"{constant_name}\" not found in \"{pallet_name}\" pallet!\n\n{description}"); return Err(err); diff --git a/cli/src/commands/explore/mod.rs b/cli/src/commands/explore/mod.rs index db84d08ebf..c35cf01f89 100644 --- a/cli/src/commands/explore/mod.rs +++ b/cli/src/commands/explore/mod.rs @@ -1,29 +1,22 @@ -use crate::utils::type_description::print_type_description; -use crate::utils::type_example::print_type_examples; use crate::utils::{print_docs_with_indent, FileOrUrl}; -use clap::{Args, Parser as ClapParser, Subcommand}; +use clap::{Parser as ClapParser, Subcommand}; use std::fmt::Write; -use std::ptr::write; + use std::write; use codec::Decode; use color_eyre::eyre::eyre; -use frame_metadata::v15::{ - PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, -}; +use frame_metadata::v15::RuntimeMetadataV15; use frame_metadata::RuntimeMetadataPrefixed; -use scale_info::form::PortableForm; -use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; -use scale_value::{Composite, ValueDef}; + use syn::__private::str; use crate::commands::explore::calls::{explore_calls, CallsSubcommand}; use crate::commands::explore::constants::{explore_constants, ConstantsSubcommand}; use crate::commands::explore::storage::{explore_storage, StorageSubcommand}; -use subxt::utils::H256; -use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; -use subxt::{tx, OnlineClient}; + +use subxt::Metadata; mod calls; mod constants; diff --git a/cli/src/commands/explore/storage.rs b/cli/src/commands/explore/storage.rs index 7d0d9610dd..da4d5e71b6 100644 --- a/cli/src/commands/explore/storage.rs +++ b/cli/src/commands/explore/storage.rs @@ -1,24 +1,18 @@ use crate::utils::type_description::print_type_description; use crate::utils::type_example::print_type_examples; -use crate::utils::{print_docs_with_indent, with_indent, FileOrUrl}; -use clap::{Args, Parser as ClapParser, Subcommand}; +use crate::utils::{print_docs_with_indent, with_indent}; +use clap::Args; use std::fmt::Write; use std::write; -use codec::Decode; use color_eyre::eyre::eyre; -use frame_metadata::v15::{ - PalletMetadata, PalletStorageMetadata, RuntimeMetadataV15, StorageEntryType, -}; -use frame_metadata::RuntimeMetadataPrefixed; +use frame_metadata::v15::{PalletMetadata, PalletStorageMetadata, StorageEntryType}; + use scale_info::form::PortableForm; -use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant}; -use scale_value::{Composite, ValueDef}; -use subxt::utils::H256; -use subxt::{config::SubstrateConfig, Metadata, OfflineClient}; -use subxt::{tx, OnlineClient}; +use subxt::OnlineClient; +use subxt::{config::SubstrateConfig, Metadata}; #[derive(Debug, Clone, Args)] pub struct StorageSubcommand { From 194ca4f073935e1cac60dda65ed90e917a57b85a Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 17 May 2023 09:48:13 +0200 Subject: [PATCH 15/17] fix minor formatting issue --- cli/src/commands/explore/storage.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/explore/storage.rs b/cli/src/commands/explore/storage.rs index da4d5e71b6..e942e6d8e9 100644 --- a/cli/src/commands/explore/storage.rs +++ b/cli/src/commands/explore/storage.rs @@ -59,16 +59,16 @@ pub(crate) async fn explore_storage( let mut output = String::new(); // only inform user about usage if a key can be provided: - if key_ty_id.is_some() { + if key_ty_id.is_some() && trailing_args.is_empty() { write!( output, - "Usage:\n subxt explore {pallet_name} storage {entry_name} " + "Usage:\n subxt explore {pallet_name} storage {entry_name} \n\n" )?; } let docs_string = print_docs_with_indent(&storage.docs, 4); if !docs_string.is_empty() { - write!(output, "\n\nDescription:\n{docs_string}")?; + write!(output, "Description:\n{docs_string}")?; } // inform user about shape of key if it can be provided: From 2127e0fdc6d6a05277c03baaa68539af3bef3bde Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Mon, 22 May 2023 09:34:00 +0200 Subject: [PATCH 16/17] implement suggestions --- cli/src/commands/explore/calls.rs | 14 +++++++------- cli/src/commands/explore/constants.rs | 3 ++- cli/src/utils.rs | 5 +---- cli/src/utils/type_description.rs | 19 +++++++++---------- cli/src/utils/type_example.rs | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/cli/src/commands/explore/calls.rs b/cli/src/commands/explore/calls.rs index 29d5e37feb..d882b16bc2 100644 --- a/cli/src/commands/explore/calls.rs +++ b/cli/src/commands/explore/calls.rs @@ -4,6 +4,7 @@ use crate::utils::with_indent; use clap::Args; use std::fmt::Write; +use std::str::FromStr; use std::write; use color_eyre::eyre::eyre; @@ -43,7 +44,7 @@ pub(crate) fn explore_calls( }; // if specified call is wrong, show user the calls to choose from (but this time as an error): - let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name.to_lowercase() == call_name.to_lowercase()) else { + let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name.to_lowercase() == call_name.to_lowercase()) else { let available_calls = print_available_calls(calls_enum_type_def, pallet_name); let description = format!("Usage:\n subxt explore {pallet_name} calls \n explore a specific call within this pallet\n\n{available_calls}", ); return Err(eyre!("\"{call_name}\" call not found in \"{pallet_name}\" pallet!\n\n{description}")); @@ -94,7 +95,8 @@ fn print_available_calls(pallet_calls: &TypeDefVariant, pallet_nam let mut strings: Vec<_> = pallet_calls.variants.iter().map(|c| &c.name).collect(); strings.sort(); for variant in strings { - write!(output, "\n {}", variant).unwrap(); + output.push_str("\n {"); + output.push_str(variant); } output } @@ -121,11 +123,9 @@ fn get_calls_enum_type<'a>( } fn new_offline_client(metadata: Metadata) -> OfflineClient { - let genesis_hash = { - let h = "91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"; - let bytes = hex::decode(h).unwrap(); - H256::from_slice(&bytes) - }; + let genesis_hash = + H256::from_str("91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3") + .expect("Valid hash; qed"); let runtime_version = subxt::rpc::types::RuntimeVersion { spec_version: 9370, diff --git a/cli/src/commands/explore/constants.rs b/cli/src/commands/explore/constants.rs index 266bc0fb35..36c3c32ea1 100644 --- a/cli/src/commands/explore/constants.rs +++ b/cli/src/commands/explore/constants.rs @@ -79,7 +79,8 @@ fn print_available_constants( let mut strings: Vec<_> = pallet_metadata.constants.iter().map(|c| &c.name).collect(); strings.sort(); for constant in strings { - write!(output, "\n {}", constant).unwrap(); + output.push_str("\n "); + output.push_str(constant); } output } diff --git a/cli/src/utils.rs b/cli/src/utils.rs index 84e3ef28e7..ec2e224a08 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -88,10 +88,7 @@ pub(crate) fn print_docs_with_indent(docs: &[String], indent: usize) -> String { } pub(crate) fn with_indent(s: String, indent: usize) -> String { - let mut indent_str = String::new(); - for _ in 0..indent { - indent_str.push(' '); - } + let indent_str = " ".repeat(indent); s.lines() .map(|line| format!("{indent_str}{line}")) .collect::>() diff --git a/cli/src/utils/type_description.rs b/cli/src/utils/type_description.rs index 400e96bdd7..5575ab52b2 100644 --- a/cli/src/utils/type_description.rs +++ b/cli/src/utils/type_description.rs @@ -64,10 +64,11 @@ impl TypeDescription for TypeDef { impl TypeDescription for TypeDefTuple { fn type_description(&self, registry: &PortableRegistry) -> color_eyre::Result { let mut output = "(".to_string(); - for (is_last, ty) in mark_last(self.fields.iter(), self.fields.len()) { + let mut iter = self.fields.iter().peekable(); + while let Some(ty) = iter.next() { let type_description = ty.id.type_description(registry)?; output.push_str(&type_description); - if !is_last { + if iter.peek().is_some() { output.push(',') } } @@ -135,11 +136,12 @@ impl TypeDescription for TypeDefVariant { let mut variants_string = String::new(); variants_string.push('{'); - for (is_last, variant) in mark_last(self.variants.iter(), self.variants.len()) { + let mut iter = self.variants.iter().peekable(); + while let Some(variant) = iter.next() { let variant_string = variant.type_description(registry)?; variants_string.push_str(&variant_string); - if !is_last || add_trailing_comma { + if iter.peek().is_some() || add_trailing_comma { variants_string.push(','); } } @@ -185,11 +187,12 @@ impl TypeDescription for Vec> { let mut fields_string = String::new(); fields_string.push(brackets.0); - for (is_last, field) in mark_last(self.iter(), self.len()) { + let mut iter = self.iter().peekable(); + while let Some(field) = iter.next() { let field_description = field.type_description(registry)?; fields_string.push_str(&field_description); - if !is_last || add_trailing_comma { + if iter.peek().is_some() || add_trailing_comma { fields_string.push(',') } } @@ -268,7 +271,3 @@ fn format_type_description(input: &str) -> String { } output } - -fn mark_last(items: impl Iterator, len: usize) -> impl Iterator { - items.enumerate().map(move |(i, e)| (i == len - 1, e)) -} diff --git a/cli/src/utils/type_example.rs b/cli/src/utils/type_example.rs index eeb9c66731..f14e1f7cf0 100644 --- a/cli/src/utils/type_example.rs +++ b/cli/src/utils/type_example.rs @@ -244,7 +244,7 @@ impl TypeExample for Vec> { .iter() .map(|(_, examples)| examples.len()) .min() - .unwrap(); // safe to unwrap, because min could only be None if there are no fields. But in that case we already return an error above. + .expect("Iterator is not non-empty checked above; qed"); let mut composite_examples: Vec, scale_value::Value)>> = Vec::new(); for _ in 0..n { From 153cb84785b5f6de87339229aa10f77bfbea737a Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Mon, 22 May 2023 14:42:06 +0200 Subject: [PATCH 17/17] implement other suggestion, fix bug --- cli/src/commands/explore/calls.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/explore/calls.rs b/cli/src/commands/explore/calls.rs index d882b16bc2..14e37f79fa 100644 --- a/cli/src/commands/explore/calls.rs +++ b/cli/src/commands/explore/calls.rs @@ -77,7 +77,7 @@ pub(crate) fn explore_calls( // parse scale_value from trailing arguments and try to create an unsigned extrinsic with it: let value = scale_value::stringify::from_str(&trailing_args).0.map_err(|err| eyre!("scale_value::stringify::from_str led to a ParseError.\n\ntried parsing: \"{}\"\n\n{}", trailing_args, err))?; let value_as_composite = value_into_composite(value); - let offline_client = new_offline_client(metadata.clone()); + let offline_client = mocked_offline_client(metadata.clone()); let payload = tx::dynamic(pallet_name, call_name, value_as_composite); let unsigned_extrinsic = offline_client.tx().create_unsigned(&payload)?; let hex_bytes = format!("0x{}", hex::encode(unsigned_extrinsic.encoded())); @@ -95,7 +95,7 @@ fn print_available_calls(pallet_calls: &TypeDefVariant, pallet_nam let mut strings: Vec<_> = pallet_calls.variants.iter().map(|c| &c.name).collect(); strings.sort(); for variant in strings { - output.push_str("\n {"); + output.push_str("\n "); output.push_str(variant); } output @@ -122,7 +122,8 @@ fn get_calls_enum_type<'a>( Ok((calls_enum_type_def, calls_enum_type)) } -fn new_offline_client(metadata: Metadata) -> OfflineClient { +/// The specific values used for construction do not matter too much, we just need any OfflineClient to create unsigned extrinsics +fn mocked_offline_client(metadata: Metadata) -> OfflineClient { let genesis_hash = H256::from_str("91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3") .expect("Valid hash; qed");