diff --git a/codegen/src/api/errors.rs b/codegen/src/api/errors.rs index 625e94d40b..f9f860f42a 100644 --- a/codegen/src/api/errors.rs +++ b/codegen/src/api/errors.rs @@ -18,7 +18,140 @@ use frame_metadata::v14::RuntimeMetadataV14; use proc_macro2::TokenStream as TokenStream2; use proc_macro_error::abort_call_site; use quote::quote; -use scale_info::TypeDef; +use scale_info::{ + form::PortableForm, + Field, + TypeDef, + TypeDefPrimitive, +}; + +/// Different substrate versions will have a different `DispatchError::Module`. +/// The following cases are ordered by versions. +enum ModuleErrorType { + /// Case 1: `DispatchError::Module { index: u8, error: u8 }` + /// + /// This is the first supported `DispatchError::Module` format. + NamedField, + /// Case 2: `DispatchError::Module ( sp_runtime::ModuleError { index: u8, error: u8 } )` + /// + /// Substrate introduced `sp_runtime::ModuleError`, while keeping the error `u8`. + LegacyError, + /// Case 3: `DispatchError::Module ( sp_runtime::ModuleError { index: u8, error: [u8; 4] } )` + /// + /// The substrate error evolved into `[u8; 4]`. + ArrayError, +} + +impl quote::ToTokens for ModuleErrorType { + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { + let trait_fn_body = match self { + ModuleErrorType::NamedField => { + quote! { + if let &Self::Module { index, error } = self { + Some(::subxt::ModuleErrorData { pallet_index: index, error: [error, 0, 0, 0] }) + } else { + None + } + } + } + ModuleErrorType::LegacyError => { + quote! { + if let Self::Module (module_error) = self { + Some(::subxt::ModuleErrorData { pallet_index: module_error.index, error: [module_error.error, 0, 0, 0] }) + } else { + None + } + } + } + ModuleErrorType::ArrayError => { + quote! { + if let Self::Module (module_error) = self { + Some(::subxt::ModuleErrorData { pallet_index: module_error.index, error: module_error.error }) + } else { + None + } + } + } + }; + + tokens.extend(trait_fn_body); + } +} + +/// Determine the `ModuleError` type for the `ModuleErrorType::LegacyError` and +/// `ModuleErrorType::ErrorArray` cases. +fn module_error_type( + module_field: &Field, + metadata: &RuntimeMetadataV14, +) -> ModuleErrorType { + // Fields are named. + if module_field.name().is_some() { + return ModuleErrorType::NamedField + } + + // Get the `sp_runtime::ModuleError` structure. + let module_err = metadata + .types + .resolve(module_field.ty().id()) + .unwrap_or_else(|| { + abort_call_site!("sp_runtime::ModuleError type expected in metadata") + }); + + let error_type_def = match module_err.type_def() { + TypeDef::Composite(composite) => composite, + _ => abort_call_site!("sp_runtime::ModuleError type should be a composite type"), + }; + + // Get the error field from the `sp_runtime::ModuleError` structure. + let error_field = error_type_def + .fields() + .iter() + .find(|field| field.name() == Some(&"error".to_string())) + .unwrap_or_else(|| { + abort_call_site!("sp_runtime::ModuleError expected to contain error field") + }); + + // Resolve the error type from the metadata. + let error_field_ty = metadata + .types + .resolve(error_field.ty().id()) + .unwrap_or_else(|| { + abort_call_site!("sp_runtime::ModuleError::error type expected in metadata") + }); + + match error_field_ty.type_def() { + // Check for legacy error type. + TypeDef::Primitive(TypeDefPrimitive::U8) => ModuleErrorType::LegacyError, + TypeDef::Array(array) => { + // Check new error type of len 4 and type u8. + if array.len() != 4 { + abort_call_site!("sp_runtime::ModuleError::error array length is not 4"); + } + + let array_ty = metadata + .types + .resolve(array.type_param().id()) + .unwrap_or_else(|| { + abort_call_site!( + "sp_runtime::ModuleError::error array type expected in metadata" + ) + }); + + if let TypeDef::Primitive(TypeDefPrimitive::U8) = array_ty.type_def() { + ModuleErrorType::ArrayError + } else { + abort_call_site!( + "sp_runtime::ModuleError::error array type expected to be u8" + ) + } + } + _ => { + abort_call_site!( + "sp_runtime::ModuleError::error array type or primitive expected" + ) + } + } +} /// The aim of this is to implement the `::subxt::HasModuleError` trait for /// the generated `DispatchError`, so that we can obtain the module error details, @@ -27,7 +160,7 @@ pub fn generate_has_module_error_impl( metadata: &RuntimeMetadataV14, types_mod_ident: &syn::Ident, ) -> TokenStream2 { - let dispatch_error_def = metadata + let dispatch_error = metadata .types .types() .iter() @@ -38,55 +171,30 @@ pub fn generate_has_module_error_impl( .ty() .type_def(); - // Slightly older versions of substrate have a `DispatchError::Module { index, error }` - // variant. Newer versions have something like a `DispatchError::Module (Details)` variant. - // We check to see which type of variant we're dealing with based on the metadata, and - // generate the correct code to handle either older or newer substrate versions. - let module_variant_is_struct = if let TypeDef::Variant(details) = dispatch_error_def { - let module_variant = details - .variants() - .iter() - .find(|variant| variant.name() == "Module") - .unwrap_or_else(|| { - abort_call_site!("DispatchError::Module variant expected in metadata") - }); - let are_fields_named = module_variant - .fields() - .get(0) - .unwrap_or_else(|| { - abort_call_site!( - "DispatchError::Module expected to contain 1 or more fields" - ) - }) - .name() - .is_some(); - are_fields_named - } else { - false - }; - - let trait_fn_body = if module_variant_is_struct { - quote! { - if let &Self::Module { index, error } = self { - Some((index, error)) - } else { - None - } - } - } else { - quote! { - if let Self::Module (module_error) = self { - Some((module_error.index, module_error.error)) - } else { - None - } + // Get the `DispatchError::Module` variant (either struct or named fields). + let module_variant = match dispatch_error { + TypeDef::Variant(variant) => { + variant + .variants() + .iter() + .find(|variant| variant.name() == "Module") + .unwrap_or_else(|| { + abort_call_site!("DispatchError::Module variant expected in metadata") + }) } + _ => abort_call_site!("DispatchError expected to contain variant in metadata"), }; + let module_field = module_variant.fields().get(0).unwrap_or_else(|| { + abort_call_site!("DispatchError::Module expected to contain 1 or more fields") + }); + + let error_type = module_error_type(module_field, metadata); + quote! { impl ::subxt::HasModuleError for #types_mod_ident::sp_runtime::DispatchError { - fn module_error_indices(&self) -> Option<(u8,u8)> { - #trait_fn_body + fn module_error_data(&self) -> Option<::subxt::ModuleErrorData> { + #error_type } } } diff --git a/subxt/src/error.rs b/subxt/src/error.rs index 4d2bebeacd..50d1c1cbca 100644 --- a/subxt/src/error.rs +++ b/subxt/src/error.rs @@ -182,6 +182,28 @@ pub struct ModuleError { pub error: String, /// A description of the error. pub description: Vec, + /// A byte representation of the error. + pub error_data: ModuleErrorData, +} + +/// The error details about a module error that has occurred. +/// +/// **Note**: Structure used to obtain the underlying bytes of a ModuleError. +#[derive(Clone, Debug, thiserror::Error)] +#[error("Pallet index {pallet_index}: raw error: {error:?}")] +pub struct ModuleErrorData { + /// Index of the pallet that the error came from. + pub pallet_index: u8, + /// Raw error bytes. + pub error: [u8; 4], +} + +impl ModuleErrorData { + /// Obtain the error index from the underlying byte data. + pub fn error_index(&self) -> u8 { + // Error index is utilized as the first byte from the error array. + self.error[0] + } } /// This trait is automatically implemented for the generated `DispatchError`, @@ -190,5 +212,5 @@ pub struct ModuleError { pub trait HasModuleError { /// If the error has a `Module` variant, return a tuple of the /// pallet index and error index. Else, return `None`. - fn module_error_indices(&self) -> Option<(u8, u8)>; + fn module_error_data(&self) -> Option; } diff --git a/subxt/src/lib.rs b/subxt/src/lib.rs index 0e808387b8..8e655a21be 100644 --- a/subxt/src/lib.rs +++ b/subxt/src/lib.rs @@ -81,6 +81,7 @@ pub use crate::{ Error, GenericError, HasModuleError, + ModuleErrorData, RuntimeError, TransactionError, }, diff --git a/subxt/src/transaction.rs b/subxt/src/transaction.rs index e0a781287d..1b1bedd15a 100644 --- a/subxt/src/transaction.rs +++ b/subxt/src/transaction.rs @@ -389,14 +389,17 @@ impl<'client, T: Config, E: Decode + HasModuleError, Evs: Decode> let ev = ev?; if &ev.pallet == "System" && &ev.variant == "ExtrinsicFailed" { let dispatch_error = E::decode(&mut &*ev.data)?; - if let Some((pallet_idx, error_idx)) = - dispatch_error.module_error_indices() - { - let details = self.client.metadata().error(pallet_idx, error_idx)?; + if let Some(error_data) = dispatch_error.module_error_data() { + // Error index is utilized as the first byte from the error array. + let details = self + .client + .metadata() + .error(error_data.pallet_index, error_data.error_index())?; return Err(Error::Module(ModuleError { pallet: details.pallet().to_string(), error: details.error().to_string(), description: details.description().to_vec(), + error_data, })) } else { return Err(Error::Runtime(RuntimeError(dispatch_error))) diff --git a/subxt/tests/integration/codegen/polkadot.rs b/subxt/tests/integration/codegen/polkadot.rs index 2cf0c7c8ea..d98c635280 100644 --- a/subxt/tests/integration/codegen/polkadot.rs +++ b/subxt/tests/integration/codegen/polkadot.rs @@ -1,4 +1,3 @@ -// NOTE [jsdw]: generated from polkadot 0.9.18-f6d6ab005d-aarch64-macos #[allow(dead_code, unused_imports, non_camel_case_types)] pub mod api { use super::api as root_mod; @@ -80,11 +79,15 @@ pub mod api { XcmPallet(xcm_pallet::Event), } pub mod system { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct FillBlock { @@ -847,11 +850,15 @@ pub mod api { } } pub mod scheduler { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Schedule { @@ -1259,11 +1266,15 @@ pub mod api { } } pub mod preimage { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct NotePreimage { @@ -1490,11 +1501,15 @@ pub mod api { } } pub mod babe { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ReportEquivocation { @@ -1960,11 +1975,15 @@ pub mod api { } } pub mod timestamp { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Set { @@ -2067,11 +2086,15 @@ pub mod api { } } pub mod indices { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive( :: subxt :: codec :: Encode, @@ -2326,11 +2349,15 @@ pub mod api { } } pub mod balances { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Transfer { @@ -2833,8 +2860,10 @@ pub mod api { } } pub mod transaction_payment { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod storage { use super::runtime_types; pub struct NextFeeMultiplier; @@ -2926,11 +2955,15 @@ pub mod api { } } pub mod authorship { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct SetUncles { @@ -3075,11 +3108,15 @@ pub mod api { } } pub mod staking { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Bond { @@ -4999,8 +5036,10 @@ pub mod api { } } pub mod offences { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub type Event = runtime_types::pallet_offences::pallet::Event; pub mod events { use super::runtime_types; @@ -5153,15 +5192,21 @@ pub mod api { } } pub mod historical { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; } pub mod session { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct SetKeys { @@ -5418,11 +5463,15 @@ pub mod api { } } pub mod grandpa { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ReportEquivocation { @@ -5721,11 +5770,15 @@ pub mod api { } } pub mod im_online { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Heartbeat { @@ -5952,15 +6005,21 @@ pub mod api { } } pub mod authority_discovery { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; } pub mod democracy { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Propose { @@ -7267,11 +7326,15 @@ pub mod api { } } pub mod council { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct SetMembers { @@ -7706,11 +7769,15 @@ pub mod api { } } pub mod technical_committee { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct SetMembers { @@ -8145,11 +8212,15 @@ pub mod api { } } pub mod phragmen_election { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Vote { @@ -8602,11 +8673,15 @@ pub mod api { } } pub mod technical_membership { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct AddMember { @@ -8869,11 +8944,15 @@ pub mod api { } } pub mod treasury { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ProposeSpend { @@ -9227,11 +9306,15 @@ pub mod api { } } pub mod claims { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Claim { @@ -9622,11 +9705,15 @@ pub mod api { } } pub mod vesting { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Vest; @@ -9926,11 +10013,15 @@ pub mod api { } } pub mod utility { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Batch { @@ -10098,11 +10189,15 @@ pub mod api { } } pub mod identity { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct AddRegistrar { @@ -10853,11 +10948,15 @@ pub mod api { } } pub mod proxy { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Proxy { @@ -11211,17 +11310,6 @@ pub mod api { const PALLET: &'static str = "Proxy"; const EVENT: &'static str = "ProxyAdded"; } - #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] - pub struct ProxyRemoved { - pub delegator: ::subxt::sp_core::crypto::AccountId32, - pub delegatee: ::subxt::sp_core::crypto::AccountId32, - pub proxy_type: runtime_types::polkadot_runtime::ProxyType, - pub delay: ::core::primitive::u32, - } - impl ::subxt::Event for ProxyRemoved { - const PALLET: &'static str = "Proxy"; - const EVENT: &'static str = "ProxyRemoved"; - } } pub mod storage { use super::runtime_types; @@ -11402,11 +11490,15 @@ pub mod api { } } pub mod multisig { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct AsMultiThreshold1 { @@ -11777,11 +11869,15 @@ pub mod api { } } pub mod bounties { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ProposeBounty { @@ -12329,11 +12425,15 @@ pub mod api { } } pub mod child_bounties { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct AddChildBounty { @@ -12839,11 +12939,15 @@ pub mod api { } } pub mod tips { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ReportAwesome { @@ -13197,11 +13301,15 @@ pub mod api { } } pub mod election_provider_multi_phase { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct SubmitUnsigned { pub raw_solution : :: std :: boxed :: Box < runtime_types :: pallet_election_provider_multi_phase :: RawSolution < runtime_types :: polkadot_runtime :: NposCompactSolution16 > > , pub witness : runtime_types :: pallet_election_provider_multi_phase :: SolutionOrSnapshotSize , } @@ -13750,11 +13858,15 @@ pub mod api { } } pub mod bags_list { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Rebag { @@ -14110,15 +14222,21 @@ pub mod api { } } pub mod parachains_origin { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; } pub mod configuration { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive( :: subxt :: codec :: Encode, @@ -15413,11 +15531,15 @@ pub mod api { } } pub mod paras_shared { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; pub struct TransactionApi<'a, T: ::subxt::Config, X> { client: &'a ::subxt::Client, @@ -15512,11 +15634,15 @@ pub mod api { } } pub mod para_inclusion { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; pub struct TransactionApi<'a, T: ::subxt::Config, X> { client: &'a ::subxt::Client, @@ -15683,11 +15809,15 @@ pub mod api { } } pub mod para_inherent { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Enter { @@ -15793,8 +15923,10 @@ pub mod api { } } pub mod para_scheduler { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod storage { use super::runtime_types; pub struct ValidatorGroups; @@ -15925,11 +16057,15 @@ pub mod api { } } pub mod paras { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ForceSetCurrentCode { @@ -16850,11 +16986,15 @@ pub mod api { } } pub mod initializer { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive( :: subxt :: codec :: Encode, @@ -16942,11 +17082,15 @@ pub mod api { } } pub mod dmp { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; pub struct TransactionApi<'a, T: ::subxt::Config, X> { client: &'a ::subxt::Client, @@ -17052,11 +17196,15 @@ pub mod api { } } pub mod ump { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ServiceOverweight { @@ -17344,11 +17492,15 @@ pub mod api { } } pub mod hrmp { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct HrmpInitOpenChannel { @@ -18002,8 +18154,10 @@ pub mod api { } } pub mod para_session_info { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod storage { use super::runtime_types; pub struct AssignmentKeysUnsafe; @@ -18091,11 +18245,15 @@ pub mod api { } } pub mod paras_disputes { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ForceUnfreeze; @@ -18348,11 +18506,15 @@ pub mod api { } } pub mod registrar { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Register { @@ -18696,11 +18858,15 @@ pub mod api { } } pub mod slots { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct ForceLease { @@ -18906,11 +19072,15 @@ pub mod api { } } pub mod auctions { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct NewAuction { @@ -19261,11 +19431,15 @@ pub mod api { } } pub mod crowdloan { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Create { @@ -19789,11 +19963,15 @@ pub mod api { } } pub mod xcm_pallet { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; pub mod calls { - use super::root_mod; - use super::runtime_types; + use super::{ + root_mod, + runtime_types, + }; type DispatchError = runtime_types::sp_runtime::DispatchError; #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] pub struct Send { @@ -23234,13 +23412,6 @@ pub mod api { proxy_type: runtime_types::polkadot_runtime::ProxyType, delay: ::core::primitive::u32, }, - #[codec(index = 4)] - ProxyRemoved { - delegator: ::subxt::sp_core::crypto::AccountId32, - delegatee: ::subxt::sp_core::crypto::AccountId32, - proxy_type: runtime_types::polkadot_runtime::ProxyType, - delay: ::core::primitive::u32, - }, } } #[derive(:: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug)] @@ -28351,9 +28522,12 @@ pub mod api { #[doc = r" The default error type returned when there is a runtime issue."] pub type DispatchError = runtime_types::sp_runtime::DispatchError; impl ::subxt::HasModuleError for runtime_types::sp_runtime::DispatchError { - fn module_error_indices(&self) -> Option<(u8, u8)> { + fn module_error_data(&self) -> Option<::subxt::ModuleErrorData> { if let Self::Module(module_error) = self { - Some((module_error.index, module_error.error)) + Some(::subxt::ModuleErrorData { + pallet_index: module_error.index, + error: [module_error.error, 0, 0, 0], + }) } else { None }