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 )*
}
}
}
})
+2 -2
View File
@@ -333,8 +333,8 @@ impl RuntimeGenerator {
pub struct TransactionApi;
impl TransactionApi {
#(
pub fn #pallets_with_calls(&self) -> #pallets_with_calls::calls::TransactionApi {
#pallets_with_calls::calls::TransactionApi
pub fn #pallets_with_calls(&self) -> #pallets_with_calls::calls::api::TransactionApi {
#pallets_with_calls::calls::api::TransactionApi
}
)*
}
+6 -6
View File
@@ -114,7 +114,7 @@ fn generate_storage_entry_fns(
.iter()
.map(|i| {
let ty = &i.type_alias;
quote!(#storage_entry_snake_case_ident::#ty)
quote!(#storage_entry_snake_case_ident::input::#ty)
})
.collect::<Vec<_>>();
@@ -142,12 +142,12 @@ fn generate_storage_entry_fns(
use super::root_mod;
use super::#types_mod_ident;
#(#storage_key_type_aliases)*
pub mod output {
pub mod input {
use super::#types_mod_ident;
pub type Output = #storage_value_type_path;
#(#storage_key_type_aliases)*
}
pub type Output = #storage_value_type_path;
}
);
@@ -155,7 +155,7 @@ fn generate_storage_entry_fns(
#docs
pub fn #storage_entry_snake_case_ident(&self) -> #crate_path::storage::StaticAddress<
(#(#storage_key_tuple_types,)*),
#storage_entry_snake_case_ident::output::Output,
#storage_entry_snake_case_ident::Output,
#is_plain
> {
#crate_path::storage::StaticAddress::new_static(