mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
[Feature] Introduce storage_alias for CountedStorageMap (#13366)
* [Feature] Introduce storagage_alias for CountedStorageMap * bit more dry * bit more dry * address review comments * some tests and fixes * fix ui tests * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * compare metadata --------- Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -19,7 +19,7 @@ use frame_support::{
|
||||
dispatch::{
|
||||
DispatchClass, DispatchInfo, GetDispatchInfo, Parameter, Pays, UnfilteredDispatchable,
|
||||
},
|
||||
pallet_prelude::ValueQuery,
|
||||
pallet_prelude::{StorageInfoTrait, ValueQuery},
|
||||
storage::unhashed,
|
||||
traits::{
|
||||
ConstU32, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize,
|
||||
@@ -1906,14 +1906,30 @@ fn assert_type_all_pallets_without_system_reversed_is_correct() {
|
||||
|
||||
#[test]
|
||||
fn test_storage_alias() {
|
||||
use frame_support::Twox64Concat;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
type Value<T: pallet::Config>
|
||||
where
|
||||
<T as frame_system::Config>::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
= StorageValue<pallet::Pallet<T>, u32, ValueQuery>;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
type SomeCountedStorageMap<T: pallet2::Config>
|
||||
where
|
||||
<T as frame_system::Config>::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
= CountedStorageMap<pallet2::Pallet<T>, Twox64Concat, u8, u32>;
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
pallet::Value::<Runtime>::put(10);
|
||||
assert_eq!(10, Value::<Runtime>::get());
|
||||
|
||||
pallet2::SomeCountedStorageMap::<Runtime>::insert(10, 100);
|
||||
assert_eq!(Some(100), SomeCountedStorageMap::<Runtime>::get(10));
|
||||
assert_eq!(1, SomeCountedStorageMap::<Runtime>::count());
|
||||
assert_eq!(
|
||||
SomeCountedStorageMap::<Runtime>::storage_info(),
|
||||
pallet2::SomeCountedStorageMap::<Runtime>::storage_info()
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: expected one of: `StorageValue`, `StorageMap`, `StorageDoubleMap`, `StorageNMap`
|
||||
error: expected one of: `StorageValue`, `StorageMap`, `CountedStorageMap`, `StorageDoubleMap`, `StorageNMap`
|
||||
--> tests/storage_alias_ui/forbid_underscore_as_prefix.rs:2:14
|
||||
|
|
||||
2 | type Ident = CustomStorage<Hello, u32>;
|
||||
|
||||
Reference in New Issue
Block a user