You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current compose_call! macro expects the full metadata and the pallet name as input. But in case multiple calls for one pallet are created, the current code is forced to get the PalletMetada each time for each call. That's not necessary.
Therefore I'm proposing to split it into two functions:
/// Generates the extrinsic's call field for a given module and call passed as &str/// # Arguments////// * 'node_metadata' - This crate's parsed node metadata as field of the API./// * 'pallet' - Pallet name as &str for which the call is composed./// * 'call_name' - Call name as &str/// * 'args' - Optional sequence of arguments of the call. They are not checked against the metadata./// As of now the user needs to check himself that the correct arguments are supplied.#[macro_export]macro_rules! compose_call {($node_metadata: expr, $pallet: expr, $call_name: expr $(, $args: expr)*) => {{let pallet_metadata = $node_metadata.pallet_by_name($pallet).unwrap();
$crate::compose_call_for_pallet_metadata !(pallet_metadata, $call $(,($args))*);}};}/// Generates the extrinsic's call field for the given PalletMetadata/// # Arguments////// * 'pallet_metadata' - This crate's parsed pallet metadata as field of the API./// * 'call_name' - Call name as &str/// * 'args' - Optional sequence of arguments of the call. They are not checked against the metadata./// As of now the user needs to check himself that the correct arguments are supplied.#[macro_export]macro_rules! compose_call_for_pallet_metadata {($pallet_metadata: expr, $call_name: expr $(, $args: expr)*) => {{let call_index = pallet.call_variant_by_name($call_name).unwrap().index;([pallet.index(), call_index asu8] $(,($args))*)}};}
The text was updated successfully, but these errors were encountered:
The current compose_call! macro expects the full metadata and the pallet name as input. But in case multiple calls for one pallet are created, the current code is forced to get the
PalletMetada
each time for each call. That's not necessary.Therefore I'm proposing to split it into two functions:
The text was updated successfully, but these errors were encountered: