Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Record pallet indices in CallMetadata
  • Loading branch information
KiChjang committed Sep 3, 2021
commit 6490874fd97fe9916d85e1de9363699ec6d3b4c1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub fn expand_outer_dispatch(
let mut variant_patterns = Vec::new();
let mut query_call_part_macros = Vec::new();
let mut pallet_names = Vec::new();
let mut pallet_indices = Vec::new();

let pallets_with_call = pallet_decls.iter().filter(|decl| decl.exists_part("Call"));

Expand All @@ -42,6 +43,7 @@ pub fn expand_outer_dispatch(
);
variant_patterns.push(quote!(Call::#name(call)));
pallet_names.push(name);
pallet_indices.push(index);
query_call_part_macros.push(quote! {
#path::__substrate_call_check::is_call_part_defined!(#name);
});
Expand Down Expand Up @@ -74,7 +76,8 @@ pub fn expand_outer_dispatch(
#variant_patterns => {
let function_name = call.get_call_name();
let pallet_name = stringify!(#pallet_names);
#scrate::dispatch::CallMetadata { function_name, pallet_name }
let index = #pallet_indices;
#scrate::dispatch::CallMetadata { function_name, pallet_name, index }
}
)*
}
Expand Down
2 changes: 2 additions & 0 deletions frame/support/src/traits/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub struct CallMetadata {
pub function_name: &'static str,
/// Name of the pallet to which the function belongs.
pub pallet_name: &'static str,
/// Index of the pallet specified in `construct_runtime`.
pub index: u8,
}

/// Gets the function name of the Call.
Expand Down