mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
generate_storage_alias: Rewrite as proc macro attribute (#11387)
* generate_storage_alias: Rewrite as proc macro attribute
This rewrites the `generate_storage_alias!` declarative macro as proc-macro attribute. While doing
this the name is changed to `storage_alias`. The prefix can now also be the name of a pallet. This
makes storage aliases work in migrations for all kind of chains and not just for the ones that use
predefined prefixes.
* Fix compilation and FMT
* Moare fixes
* 🤦
* ......
* Rework the syntax and support instancing
* FMT
* Prefix variants with `Storage`
* Make it compile
* Fix where clause on rust stable
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
use frame_support::{
|
||||
dispatch::{Parameter, UnfilteredDispatchable},
|
||||
pallet_prelude::ValueQuery,
|
||||
storage::unhashed,
|
||||
traits::{
|
||||
ConstU32, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize,
|
||||
@@ -1631,3 +1632,17 @@ fn assert_type_all_pallets_without_system_reversed_is_correct() {
|
||||
_a(t)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_storage_alias() {
|
||||
#[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>;
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
pallet::Value::<Runtime>::put(10);
|
||||
assert_eq!(10, Value::<Runtime>::get());
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
use frame_support::{
|
||||
dispatch::UnfilteredDispatchable,
|
||||
pallet_prelude::ValueQuery,
|
||||
storage::unhashed,
|
||||
traits::{ConstU32, GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade},
|
||||
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays},
|
||||
@@ -821,3 +822,15 @@ fn test_pallet_info_access() {
|
||||
assert_eq!(<Example2 as frame_support::traits::PalletInfoAccess>::index(), 3);
|
||||
assert_eq!(<Instance1Example2 as frame_support::traits::PalletInfoAccess>::index(), 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_storage_alias() {
|
||||
#[frame_support::storage_alias]
|
||||
type Value<T: pallet::Config<I>, I: 'static> =
|
||||
StorageValue<pallet::Pallet<T, I>, u32, ValueQuery>;
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
pallet::Value::<Runtime, pallet::Instance1>::put(10);
|
||||
assert_eq!(10, Value::<Runtime, pallet::Instance1>::get());
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user