mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57: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:
@@ -25,8 +25,8 @@ use frame_support::{
|
||||
pallet_prelude::{StorageInfoTrait, ValueQuery},
|
||||
storage::unhashed,
|
||||
traits::{
|
||||
ConstU32, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize,
|
||||
OnRuntimeUpgrade, PalletError, PalletInfoAccess, StorageVersion,
|
||||
ConstU32, GetCallIndex, GetCallName, GetStorageVersion, OnFinalize, OnGenesis,
|
||||
OnInitialize, OnRuntimeUpgrade, PalletError, PalletInfoAccess, StorageVersion,
|
||||
},
|
||||
weights::{RuntimeDbWeight, Weight},
|
||||
};
|
||||
@@ -231,6 +231,12 @@ pub mod pallet {
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(1)]
|
||||
pub fn foo_index_out_of_order(_origin: OriginFor<T>) -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Test for DispatchResult return type
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(1)]
|
||||
@@ -728,8 +734,25 @@ fn call_expand() {
|
||||
assert_eq!(call_foo.get_call_name(), "foo");
|
||||
assert_eq!(
|
||||
pallet::Call::<Runtime>::get_call_names(),
|
||||
&["foo", "foo_storage_layer", "foo_no_post_info", "check_for_dispatch_context"],
|
||||
&[
|
||||
"foo",
|
||||
"foo_storage_layer",
|
||||
"foo_index_out_of_order",
|
||||
"foo_no_post_info",
|
||||
"check_for_dispatch_context"
|
||||
],
|
||||
);
|
||||
|
||||
assert_eq!(call_foo.get_call_index(), 0u8);
|
||||
assert_eq!(pallet::Call::<Runtime>::get_call_indices(), &[0u8, 1u8, 4u8, 2u8, 3u8])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_expand_index() {
|
||||
let call_foo = pallet::Call::<Runtime>::foo_index_out_of_order {};
|
||||
|
||||
assert_eq!(call_foo.get_call_index(), 4u8);
|
||||
assert_eq!(pallet::Call::<Runtime>::get_call_indices(), &[0u8, 1u8, 4u8, 2u8, 3u8])
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user