mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
Extend PalletInfoAccess with module_name and crate_version method (#9690)
* Record pallet indices in CallMetadata * Resurrect PalletVersion infrastructure and rename as CrateVersion * cargo fmt * Add missing runtime generics to pallet struct * Fix path to instance * Fix test * Fix UI test expectations * Fix UI test expectations * Move crate_version function to PalletInfoAccess * Update UI test expectations * Add crate_name method to PalletInfo * Convert path to module name instead of exposing crate name * cargo fmt * Keep the double colons when constructing the module name * Remove unused import * Update UI test expectations * Update frame/support/src/traits/metadata.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update UI test expectations Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
#![recursion_limit = "128"]
|
||||
|
||||
use frame_support::traits::PalletInfo as _;
|
||||
use frame_support::traits::{CrateVersion, PalletInfo as _};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_core::{sr25519, H256};
|
||||
use sp_runtime::{
|
||||
@@ -739,40 +739,66 @@ fn test_metadata() {
|
||||
fn pallet_in_runtime_is_correct() {
|
||||
assert_eq!(PalletInfo::index::<System>().unwrap(), 30);
|
||||
assert_eq!(PalletInfo::name::<System>().unwrap(), "System");
|
||||
assert_eq!(PalletInfo::module_name::<System>().unwrap(), "system");
|
||||
assert_eq!(PalletInfo::crate_version::<System>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_1>().unwrap(), 31);
|
||||
assert_eq!(PalletInfo::name::<Module1_1>().unwrap(), "Module1_1");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_1>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_1>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module2>().unwrap(), 32);
|
||||
assert_eq!(PalletInfo::name::<Module2>().unwrap(), "Module2");
|
||||
assert_eq!(PalletInfo::module_name::<Module2>().unwrap(), "module2");
|
||||
assert_eq!(PalletInfo::crate_version::<Module2>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_2>().unwrap(), 33);
|
||||
assert_eq!(PalletInfo::name::<Module1_2>().unwrap(), "Module1_2");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_2>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_2>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<NestedModule3>().unwrap(), 34);
|
||||
assert_eq!(PalletInfo::name::<NestedModule3>().unwrap(), "NestedModule3");
|
||||
assert_eq!(PalletInfo::module_name::<NestedModule3>().unwrap(), "nested::module3");
|
||||
assert_eq!(PalletInfo::crate_version::<NestedModule3>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module3>().unwrap(), 35);
|
||||
assert_eq!(PalletInfo::name::<Module3>().unwrap(), "Module3");
|
||||
assert_eq!(PalletInfo::module_name::<Module3>().unwrap(), "self::module3");
|
||||
assert_eq!(PalletInfo::crate_version::<Module3>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_3>().unwrap(), 6);
|
||||
assert_eq!(PalletInfo::name::<Module1_3>().unwrap(), "Module1_3");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_3>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_3>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_4>().unwrap(), 3);
|
||||
assert_eq!(PalletInfo::name::<Module1_4>().unwrap(), "Module1_4");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_4>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_4>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_5>().unwrap(), 4);
|
||||
assert_eq!(PalletInfo::name::<Module1_5>().unwrap(), "Module1_5");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_5>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_5>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_6>().unwrap(), 1);
|
||||
assert_eq!(PalletInfo::name::<Module1_6>().unwrap(), "Module1_6");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_6>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_6>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_7>().unwrap(), 2);
|
||||
assert_eq!(PalletInfo::name::<Module1_7>().unwrap(), "Module1_7");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_7>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_7>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_8>().unwrap(), 12);
|
||||
assert_eq!(PalletInfo::name::<Module1_8>().unwrap(), "Module1_8");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_8>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_8>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
|
||||
assert_eq!(PalletInfo::index::<Module1_9>().unwrap(), 13);
|
||||
assert_eq!(PalletInfo::name::<Module1_9>().unwrap(), "Module1_9");
|
||||
assert_eq!(PalletInfo::module_name::<Module1_9>().unwrap(), "module1");
|
||||
assert_eq!(PalletInfo::crate_version::<Module1_9>().unwrap(), CrateVersion::new(3, 0, 0));
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied
|
||||
10 | #[pallet::generate_storage_info]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `MaxEncodedLen` is not implemented for `Bar`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `KeyGeneratorMaxEncodedLen` for `NMapKey<frame_support::Twox64Concat, Bar>`
|
||||
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageNMap<_GeneratedPrefixForStorageFoo<T>, NMapKey<frame_support::Twox64Concat, Bar>, u32>`
|
||||
= note: required because of the requirements on the impl of `KeyGeneratorMaxEncodedLen` for `Key<frame_support::Twox64Concat, Bar>`
|
||||
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageNMap<_GeneratedPrefixForStorageFoo<T>, Key<frame_support::Twox64Concat, Bar>, u32>`
|
||||
note: required by `storage_info`
|
||||
--> $DIR/storage.rs:71:2
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user