Simplify paths to extrinsic and storage types needed for .find

This commit is contained in:
James Wilson
2025-12-15 17:24:07 +00:00
parent 4d47acd24b
commit 853732550b
11 changed files with 418 additions and 27 deletions
+10 -14
View File
@@ -41,14 +41,14 @@ pub fn generate_calls(
CompositeIRKind::Named(named_fields) => named_fields
.iter()
.map(|(name, field)| {
// Note: fn_arg_type this is relative the type path of the type alias when prefixed with `types::`, e.g. `set_max_code_size::New`
// Note: fn_arg_type this is relative the type path of the type alias when prefixed with `super::`, e.g. `set_max_code_size::New`
let fn_arg_type = field.type_path.to_token_stream(type_gen.settings());
let call_arg = if field.is_boxed {
quote! { #name: #crate_path::alloc::boxed::Box::new(#name) }
} else {
quote! { #name }
};
(quote!( #name: types::#fn_arg_type ), call_arg)
(quote!( #name: super::#fn_arg_type ), call_arg)
})
.unzip(),
CompositeIRKind::NoFields => Default::default(),
@@ -97,11 +97,11 @@ pub fn generate_calls(
pub fn #fn_name(
&self,
#( #call_fn_args, )*
) -> #crate_path::transactions::StaticPayload<types::#struct_name> {
) -> #crate_path::transactions::StaticPayload<super::#struct_name> {
#crate_path::transactions::StaticPayload::new_static(
#pallet_name,
#call_name,
types::#struct_name { #( #call_args, )* },
super::#struct_name { #( #call_args, )* },
[#(#call_hash,)*]
)
}
@@ -128,18 +128,14 @@ pub fn generate_calls(
use super::root_mod;
use super::#types_mod_ident;
type DispatchError = #types_mod_ident::sp_runtime::DispatchError;
#( #call_structs )*
pub mod types {
use super::#types_mod_ident;
pub mod api {
pub struct TransactionApi;
#( #call_structs )*
}
pub struct TransactionApi;
impl TransactionApi {
#( #call_fns )*
impl TransactionApi {
#( #call_fns )*
}
}
}
})