mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 09:17:58 +00:00
GetCallIndex trait (#13558)
* GetCallIndex trait * final impl * ".git/.scripts/commands/fmt/fmt.sh" * Docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * One more test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Doc Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -984,7 +984,8 @@ pub fn compact(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
///
|
||||
/// The macro creates an enum `Call` with one variant per dispatchable. This enum implements:
|
||||
/// [`Clone`], [`Eq`], [`PartialEq`], [`Debug`] (with stripped implementation in `not("std")`),
|
||||
/// `Encode`, `Decode`, `GetDispatchInfo`, `GetCallName`, and `UnfilteredDispatchable`.
|
||||
/// `Encode`, `Decode`, `GetDispatchInfo`, `GetCallName`, `GetCallIndex` and
|
||||
/// `UnfilteredDispatchable`.
|
||||
///
|
||||
/// The macro implements the `Callable` trait on `Pallet` and a function `call_functions`
|
||||
/// which returns the dispatchable metadata.
|
||||
|
||||
@@ -324,6 +324,21 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
impl<#type_impl_gen> #frame_support::dispatch::GetCallIndex for #call_ident<#type_use_gen>
|
||||
#where_clause
|
||||
{
|
||||
fn get_call_index(&self) -> u8 {
|
||||
match *self {
|
||||
#( Self::#fn_name { .. } => #call_index, )*
|
||||
Self::__Ignore(_, _) => unreachable!("__PhantomItem cannot be used."),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_call_indices() -> &'static [u8] {
|
||||
&[ #( #call_index, )* ]
|
||||
}
|
||||
}
|
||||
|
||||
impl<#type_impl_gen> #frame_support::traits::UnfilteredDispatchable
|
||||
for #call_ident<#type_use_gen>
|
||||
#where_clause
|
||||
|
||||
Reference in New Issue
Block a user