fix: Complete snowbridge pezpallet rebrand and critical bug fixes
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs) - pallet/ directories → pezpallet/ (4 locations) - Fixed pezpallet.rs self-include recursion bug - Fixed sc-chain-spec hardcoded crate name in derive macro - Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API) - Added BizinikiwiConfig type alias for zombienet tests - Deleted obsolete session state files Verified: pezsnowbridge-pezpallet-*, pezpallet-staking, pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
@@ -35,17 +35,17 @@ use pezsp_io::{
|
||||
};
|
||||
use pezsp_runtime::{DispatchError, ModuleError};
|
||||
|
||||
#[pezframe_support::pallet(dev_mode)]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet(dev_mode)]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
type BalanceOf<T, I> = <T as Config<I>>::Balance;
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config<I: 'static = ()>: pezframe_system::Config {
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MyGetParam: Get<u32>;
|
||||
type Balance: Parameter + Default + scale_info::StaticTypeInfo;
|
||||
#[allow(deprecated)]
|
||||
@@ -53,11 +53,11 @@ pub mod pallet {
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
|
||||
#[pezpallet::hooks]
|
||||
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pezpallet<T, I> {
|
||||
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
|
||||
if TypeId::of::<I>() == TypeId::of::<()>() {
|
||||
Self::deposit_event(Event::Something(10));
|
||||
@@ -86,14 +86,14 @@ pub mod pallet {
|
||||
fn integrity_test() {}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
|
||||
/// Doc comment put in metadata
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(Weight::from_parts(*foo as u64, 0))]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(Weight::from_parts(*foo as u64, 0))]
|
||||
pub fn foo(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] foo: u32,
|
||||
#[pezpallet::compact] foo: u32,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
let _ = origin;
|
||||
let _ = foo;
|
||||
@@ -102,18 +102,18 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Doc comment put in metadata
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(1)]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(1)]
|
||||
pub fn foo_storage_layer(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] _foo: u32,
|
||||
#[pezpallet::compact] _foo: u32,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
let _ = origin;
|
||||
Ok(().into())
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub enum Error<T, I = ()> {
|
||||
/// doc comment put into metadata
|
||||
@@ -121,8 +121,8 @@ pub mod pallet {
|
||||
NonExistentStorageValue,
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(fn deposit_event)]
|
||||
#[pezpallet::event]
|
||||
#[pezpallet::generate_deposit(fn deposit_event)]
|
||||
pub enum Event<T: Config<I>, I: 'static = ()> {
|
||||
/// doc comment put in metadata
|
||||
Proposed(<T as pezframe_system::Config>::AccountId),
|
||||
@@ -131,20 +131,20 @@ pub mod pallet {
|
||||
Something(u32),
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Value<T, I = ()> = StorageValue<_, u32>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Map<T, I = ()> = StorageMap<_, Blake2_128Concat, u8, u16>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Map2<T, I = ()> = StorageMap<_, Twox64Concat, u16, u32>;
|
||||
|
||||
parameter_types! {
|
||||
pub const Map3Default<T, I>: Result<u64, Error<T, I>> = Ok(1337);
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Map3<T, I = ()> = StorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -154,15 +154,15 @@ pub mod pallet {
|
||||
Map3Default<T, I>,
|
||||
>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type DoubleMap<T, I = ()> =
|
||||
StorageDoubleMap<_, Blake2_128Concat, u8, Twox64Concat, u16, u32>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type DoubleMap2<T, I = ()> =
|
||||
StorageDoubleMap<_, Twox64Concat, u16, Blake2_128Concat, u32, u64>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type DoubleMap3<T, I = ()> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -173,17 +173,17 @@ pub mod pallet {
|
||||
ResultQuery<Error<T, I>::NonExistentStorageValue>,
|
||||
>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn nmap)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn nmap)]
|
||||
pub type NMap<T, I = ()> = StorageNMap<_, storage::Key<Blake2_128Concat, u8>, u32>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn nmap2)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn nmap2)]
|
||||
pub type NMap2<T, I = ()> =
|
||||
StorageNMap<_, (storage::Key<Twox64Concat, u16>, storage::Key<Blake2_128Concat, u32>), u64>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn nmap3)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn nmap3)]
|
||||
pub type NMap3<T, I = ()> = StorageNMap<
|
||||
_,
|
||||
(NMapKey<Blake2_128Concat, u8>, NMapKey<Twox64Concat, u16>),
|
||||
@@ -191,7 +191,7 @@ pub mod pallet {
|
||||
ResultQuery<Error<T, I>::NonExistentStorageValue>,
|
||||
>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
#[derive(pezframe_support::DefaultNoBound)]
|
||||
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
|
||||
#[serde(skip)]
|
||||
@@ -199,12 +199,12 @@ pub mod pallet {
|
||||
_myfield: u32,
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
|
||||
fn build(&self) {}
|
||||
}
|
||||
|
||||
#[pallet::origin]
|
||||
#[pezpallet::origin]
|
||||
#[derive(
|
||||
EqNoBound,
|
||||
RuntimeDebugNoBound,
|
||||
@@ -221,8 +221,8 @@ pub mod pallet {
|
||||
#[scale_info(skip_type_params(T, I))]
|
||||
pub struct Origin<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
#[pallet::validate_unsigned]
|
||||
impl<T: Config<I>, I: 'static> ValidateUnsigned for Pallet<T, I> {
|
||||
#[pezpallet::validate_unsigned]
|
||||
impl<T: Config<I>, I: 'static> ValidateUnsigned for Pezpallet<T, I> {
|
||||
type Call = Call<T, I>;
|
||||
fn validate_unsigned(
|
||||
_source: TransactionSource,
|
||||
@@ -232,8 +232,8 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::inherent]
|
||||
impl<T: Config<I>, I: 'static> ProvideInherent for Pallet<T, I> {
|
||||
#[pezpallet::inherent]
|
||||
impl<T: Config<I>, I: 'static> ProvideInherent for Pezpallet<T, I> {
|
||||
type Call = Call<T, I>;
|
||||
type Error = InherentError;
|
||||
|
||||
@@ -261,28 +261,28 @@ pub mod pallet {
|
||||
pub const INHERENT_IDENTIFIER: pezframe_support::inherent::InherentIdentifier = *b"testpall";
|
||||
}
|
||||
|
||||
// Test that a instantiable pallet with a generic genesis_config is correctly handled
|
||||
#[pezframe_support::pallet]
|
||||
// Test that a instantiable pezpallet with a generic genesis_config is correctly handled
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pallet2 {
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config<I: 'static = ()>: pezframe_system::Config {
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self, I>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
#[pallet::event]
|
||||
#[pezpallet::event]
|
||||
pub enum Event<T: Config<I>, I: 'static = ()> {
|
||||
/// Something
|
||||
Something(u32),
|
||||
}
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
|
||||
phantom: PhantomData<(T, I)>,
|
||||
}
|
||||
@@ -293,7 +293,7 @@ pub mod pallet2 {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
|
||||
fn build(&self) {}
|
||||
}
|
||||
@@ -324,12 +324,12 @@ impl pezframe_system::Config for Runtime {
|
||||
type OnSetCode = ();
|
||||
type MaxConsumers = ConstU32<16>;
|
||||
}
|
||||
impl pallet::Config for Runtime {
|
||||
impl pezpallet::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type MyGetParam = ConstU32<10>;
|
||||
type Balance = u64;
|
||||
}
|
||||
impl pallet::Config<pallet::Instance1> for Runtime {
|
||||
impl pezpallet::Config<pezpallet::Instance1> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type MyGetParam = ConstU32<10>;
|
||||
type Balance = u64;
|
||||
@@ -337,7 +337,7 @@ impl pallet::Config<pallet::Instance1> for Runtime {
|
||||
impl pallet2::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
impl pallet2::Config<pallet::Instance1> for Runtime {
|
||||
impl pallet2::Config<pezpallet::Instance1> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
|
||||
@@ -350,8 +350,8 @@ pezframe_support::construct_runtime!(
|
||||
{
|
||||
// Exclude part `Storage` in order not to check its metadata in tests.
|
||||
System: pezframe_system exclude_parts { Storage },
|
||||
Example: pallet,
|
||||
Instance1Example: pallet::<Instance1>,
|
||||
Example: pezpallet,
|
||||
Instance1Example: pezpallet::<Instance1>,
|
||||
Example2: pallet2,
|
||||
Instance1Example2: pallet2::<Instance1>,
|
||||
}
|
||||
@@ -359,7 +359,7 @@ pezframe_support::construct_runtime!(
|
||||
|
||||
#[test]
|
||||
fn call_expand() {
|
||||
let call_foo = pallet::Call::<Runtime>::foo { foo: 3 };
|
||||
let call_foo = pezpallet::Call::<Runtime>::foo { foo: 3 };
|
||||
assert_eq!(
|
||||
call_foo.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
@@ -370,9 +370,9 @@ fn call_expand() {
|
||||
}
|
||||
);
|
||||
assert_eq!(call_foo.get_call_name(), "foo");
|
||||
assert_eq!(pallet::Call::<Runtime>::get_call_names(), &["foo", "foo_storage_layer"]);
|
||||
assert_eq!(pezpallet::Call::<Runtime>::get_call_names(), &["foo", "foo_storage_layer"]);
|
||||
|
||||
let call_foo = pallet::Call::<Runtime, pallet::Instance1>::foo { foo: 3 };
|
||||
let call_foo = pezpallet::Call::<Runtime, pezpallet::Instance1>::foo { foo: 3 };
|
||||
assert_eq!(
|
||||
call_foo.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
@@ -384,7 +384,7 @@ fn call_expand() {
|
||||
);
|
||||
assert_eq!(call_foo.get_call_name(), "foo");
|
||||
assert_eq!(
|
||||
pallet::Call::<Runtime, pallet::Instance1>::get_call_names(),
|
||||
pezpallet::Call::<Runtime, pezpallet::Instance1>::get_call_names(),
|
||||
&["foo", "foo_storage_layer"],
|
||||
);
|
||||
}
|
||||
@@ -392,15 +392,15 @@ fn call_expand() {
|
||||
#[test]
|
||||
fn error_expand() {
|
||||
assert_eq!(
|
||||
format!("{:?}", pallet::Error::<Runtime>::InsufficientProposersBalance),
|
||||
format!("{:?}", pezpallet::Error::<Runtime>::InsufficientProposersBalance),
|
||||
String::from("InsufficientProposersBalance"),
|
||||
);
|
||||
assert_eq!(
|
||||
<&'static str>::from(pallet::Error::<Runtime>::InsufficientProposersBalance),
|
||||
<&'static str>::from(pezpallet::Error::<Runtime>::InsufficientProposersBalance),
|
||||
"InsufficientProposersBalance",
|
||||
);
|
||||
assert_eq!(
|
||||
DispatchError::from(pallet::Error::<Runtime>::InsufficientProposersBalance),
|
||||
DispatchError::from(pezpallet::Error::<Runtime>::InsufficientProposersBalance),
|
||||
DispatchError::Module(ModuleError {
|
||||
index: 1,
|
||||
error: [0; 4],
|
||||
@@ -409,18 +409,18 @@ fn error_expand() {
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
format!("{:?}", pallet::Error::<Runtime, pallet::Instance1>::InsufficientProposersBalance),
|
||||
format!("{:?}", pezpallet::Error::<Runtime, pezpallet::Instance1>::InsufficientProposersBalance),
|
||||
String::from("InsufficientProposersBalance"),
|
||||
);
|
||||
assert_eq!(
|
||||
<&'static str>::from(
|
||||
pallet::Error::<Runtime, pallet::Instance1>::InsufficientProposersBalance
|
||||
pezpallet::Error::<Runtime, pezpallet::Instance1>::InsufficientProposersBalance
|
||||
),
|
||||
"InsufficientProposersBalance",
|
||||
);
|
||||
assert_eq!(
|
||||
DispatchError::from(
|
||||
pallet::Error::<Runtime, pallet::Instance1>::InsufficientProposersBalance
|
||||
pezpallet::Error::<Runtime, pezpallet::Instance1>::InsufficientProposersBalance
|
||||
),
|
||||
DispatchError::Module(ModuleError {
|
||||
index: 2,
|
||||
@@ -432,14 +432,14 @@ fn error_expand() {
|
||||
|
||||
#[test]
|
||||
fn module_error_outer_enum_expand() {
|
||||
// assert that all variants of the Example pallet are included into the
|
||||
// assert that all variants of the Example pezpallet are included into the
|
||||
// RuntimeError definition.
|
||||
match RuntimeError::Example(pallet::Error::InsufficientProposersBalance) {
|
||||
match RuntimeError::Example(pezpallet::Error::InsufficientProposersBalance) {
|
||||
RuntimeError::Example(example) => match example {
|
||||
pallet::Error::InsufficientProposersBalance => (),
|
||||
pallet::Error::NonExistentStorageValue => (),
|
||||
pezpallet::Error::InsufficientProposersBalance => (),
|
||||
pezpallet::Error::NonExistentStorageValue => (),
|
||||
// Extra pattern added by `construct_runtime`.
|
||||
pallet::Error::__Ignore(_, _) => (),
|
||||
pezpallet::Error::__Ignore(_, _) => (),
|
||||
},
|
||||
_ => (),
|
||||
};
|
||||
@@ -455,7 +455,7 @@ fn module_error_from_dispatch_error() {
|
||||
let err = RuntimeError::from_dispatch_error(dispatch_err).unwrap();
|
||||
|
||||
match err {
|
||||
RuntimeError::Example(pallet::Error::InsufficientProposersBalance) => (),
|
||||
RuntimeError::Example(pezpallet::Error::InsufficientProposersBalance) => (),
|
||||
_ => panic!("Module error constructed incorrectly"),
|
||||
};
|
||||
|
||||
@@ -466,30 +466,30 @@ fn module_error_from_dispatch_error() {
|
||||
#[test]
|
||||
fn instance_expand() {
|
||||
// assert same type
|
||||
let _: pallet::__InherentHiddenInstance = ();
|
||||
let _: pezpallet::__InherentHiddenInstance = ();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pezpallet_expand_deposit_event() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
pezframe_system::Pallet::<Runtime>::set_block_number(1);
|
||||
pallet::Call::<Runtime>::foo { foo: 3 }
|
||||
pezframe_system::Pezpallet::<Runtime>::set_block_number(1);
|
||||
pezpallet::Call::<Runtime>::foo { foo: 3 }
|
||||
.dispatch_bypass_filter(None.into())
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
pezframe_system::Pallet::<Runtime>::events()[0].event,
|
||||
RuntimeEvent::Example(pallet::Event::Something(3)),
|
||||
pezframe_system::Pezpallet::<Runtime>::events()[0].event,
|
||||
RuntimeEvent::Example(pezpallet::Event::Something(3)),
|
||||
);
|
||||
});
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
pezframe_system::Pallet::<Runtime>::set_block_number(1);
|
||||
pallet::Call::<Runtime, pallet::Instance1>::foo { foo: 3 }
|
||||
pezframe_system::Pezpallet::<Runtime>::set_block_number(1);
|
||||
pezpallet::Call::<Runtime, pezpallet::Instance1>::foo { foo: 3 }
|
||||
.dispatch_bypass_filter(None.into())
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
pezframe_system::Pallet::<Runtime>::events()[0].event,
|
||||
RuntimeEvent::Instance1Example(pallet::Event::Something(3)),
|
||||
pezframe_system::Pezpallet::<Runtime>::events()[0].event,
|
||||
RuntimeEvent::Instance1Example(pezpallet::Event::Something(3)),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -511,150 +511,150 @@ fn storage_expand() {
|
||||
}
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
<pallet::Value<Runtime>>::put(1);
|
||||
<pezpallet::Value<Runtime>>::put(1);
|
||||
let k = [twox_128(b"Example"), twox_128(b"Value")].concat();
|
||||
assert_eq!(unhashed::get::<u32>(&k), Some(1u32));
|
||||
|
||||
<pallet::Map<Runtime>>::insert(1, 2);
|
||||
<pezpallet::Map<Runtime>>::insert(1, 2);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"Map")].concat();
|
||||
k.extend(1u8.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u16>(&k), Some(2u16));
|
||||
assert_eq!(&k[..32], &<pallet::Map<Runtime>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::Map<Runtime>>::final_prefix());
|
||||
|
||||
<pallet::Map2<Runtime>>::insert(1, 2);
|
||||
<pezpallet::Map2<Runtime>>::insert(1, 2);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"Map2")].concat();
|
||||
k.extend(1u16.using_encoded(twox_64_concat));
|
||||
assert_eq!(unhashed::get::<u32>(&k), Some(2u32));
|
||||
assert_eq!(&k[..32], &<pallet::Map2<Runtime>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::Map2<Runtime>>::final_prefix());
|
||||
|
||||
<pallet::Map3<Runtime>>::insert(1, 2);
|
||||
<pezpallet::Map3<Runtime>>::insert(1, 2);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"Map3")].concat();
|
||||
k.extend(1u32.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u64>(&k), Some(2u64));
|
||||
assert_eq!(&k[..32], &<pallet::Map3<Runtime>>::final_prefix());
|
||||
assert_eq!(<pallet::Map3<Runtime>>::get(2), Ok(1337));
|
||||
assert_eq!(&k[..32], &<pezpallet::Map3<Runtime>>::final_prefix());
|
||||
assert_eq!(<pezpallet::Map3<Runtime>>::get(2), Ok(1337));
|
||||
|
||||
<pallet::DoubleMap<Runtime>>::insert(&1, &2, &3);
|
||||
<pezpallet::DoubleMap<Runtime>>::insert(&1, &2, &3);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"DoubleMap")].concat();
|
||||
k.extend(1u8.using_encoded(blake2_128_concat));
|
||||
k.extend(2u16.using_encoded(twox_64_concat));
|
||||
assert_eq!(unhashed::get::<u32>(&k), Some(3u32));
|
||||
assert_eq!(&k[..32], &<pallet::DoubleMap<Runtime>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::DoubleMap<Runtime>>::final_prefix());
|
||||
|
||||
<pallet::DoubleMap2<Runtime>>::insert(&1, &2, &3);
|
||||
<pezpallet::DoubleMap2<Runtime>>::insert(&1, &2, &3);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"DoubleMap2")].concat();
|
||||
k.extend(1u16.using_encoded(twox_64_concat));
|
||||
k.extend(2u32.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u64>(&k), Some(3u64));
|
||||
assert_eq!(&k[..32], &<pallet::DoubleMap2<Runtime>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::DoubleMap2<Runtime>>::final_prefix());
|
||||
|
||||
<pallet::DoubleMap3<Runtime>>::insert(&1, &2, &3);
|
||||
<pezpallet::DoubleMap3<Runtime>>::insert(&1, &2, &3);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"DoubleMap3")].concat();
|
||||
k.extend(1u32.using_encoded(blake2_128_concat));
|
||||
k.extend(2u64.using_encoded(twox_64_concat));
|
||||
assert_eq!(unhashed::get::<u128>(&k), Some(3u128));
|
||||
assert_eq!(&k[..32], &<pallet::DoubleMap3<Runtime>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::DoubleMap3<Runtime>>::final_prefix());
|
||||
assert_eq!(
|
||||
<pallet::DoubleMap3<Runtime>>::get(2, 3),
|
||||
Err(pallet::Error::<Runtime>::NonExistentStorageValue),
|
||||
<pezpallet::DoubleMap3<Runtime>>::get(2, 3),
|
||||
Err(pezpallet::Error::<Runtime>::NonExistentStorageValue),
|
||||
);
|
||||
|
||||
<pallet::NMap<Runtime>>::insert((&1,), &3);
|
||||
<pezpallet::NMap<Runtime>>::insert((&1,), &3);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"NMap")].concat();
|
||||
k.extend(1u8.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u32>(&k), Some(3u32));
|
||||
assert_eq!(&k[..32], &<pallet::NMap<Runtime>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::NMap<Runtime>>::final_prefix());
|
||||
|
||||
<pallet::NMap2<Runtime>>::insert((&1, &2), &3);
|
||||
<pezpallet::NMap2<Runtime>>::insert((&1, &2), &3);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"NMap2")].concat();
|
||||
k.extend(1u16.using_encoded(twox_64_concat));
|
||||
k.extend(2u32.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u64>(&k), Some(3u64));
|
||||
assert_eq!(&k[..32], &<pallet::NMap2<Runtime>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::NMap2<Runtime>>::final_prefix());
|
||||
|
||||
<pallet::NMap3<Runtime>>::insert((&1, &2), &3);
|
||||
<pezpallet::NMap3<Runtime>>::insert((&1, &2), &3);
|
||||
let mut k = [twox_128(b"Example"), twox_128(b"NMap3")].concat();
|
||||
k.extend(1u8.using_encoded(blake2_128_concat));
|
||||
k.extend(2u16.using_encoded(twox_64_concat));
|
||||
assert_eq!(unhashed::get::<u128>(&k), Some(3u128));
|
||||
assert_eq!(&k[..32], &<pallet::NMap3<Runtime>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::NMap3<Runtime>>::final_prefix());
|
||||
assert_eq!(
|
||||
<pallet::NMap3<Runtime>>::get((2, 3)),
|
||||
Err(pallet::Error::<Runtime>::NonExistentStorageValue),
|
||||
<pezpallet::NMap3<Runtime>>::get((2, 3)),
|
||||
Err(pezpallet::Error::<Runtime>::NonExistentStorageValue),
|
||||
);
|
||||
});
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
<pallet::Value<Runtime, pallet::Instance1>>::put(1);
|
||||
<pezpallet::Value<Runtime, pezpallet::Instance1>>::put(1);
|
||||
let k = [twox_128(b"Instance1Example"), twox_128(b"Value")].concat();
|
||||
assert_eq!(unhashed::get::<u32>(&k), Some(1u32));
|
||||
|
||||
<pallet::Map<Runtime, pallet::Instance1>>::insert(1, 2);
|
||||
<pezpallet::Map<Runtime, pezpallet::Instance1>>::insert(1, 2);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"Map")].concat();
|
||||
k.extend(1u8.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u16>(&k), Some(2u16));
|
||||
assert_eq!(&k[..32], &<pallet::Map<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::Map<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
|
||||
<pallet::Map2<Runtime, pallet::Instance1>>::insert(1, 2);
|
||||
<pezpallet::Map2<Runtime, pezpallet::Instance1>>::insert(1, 2);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"Map2")].concat();
|
||||
k.extend(1u16.using_encoded(twox_64_concat));
|
||||
assert_eq!(unhashed::get::<u32>(&k), Some(2u32));
|
||||
assert_eq!(&k[..32], &<pallet::Map2<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::Map2<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
|
||||
<pallet::Map3<Runtime, pallet::Instance1>>::insert(1, 2);
|
||||
<pezpallet::Map3<Runtime, pezpallet::Instance1>>::insert(1, 2);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"Map3")].concat();
|
||||
k.extend(1u32.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u64>(&k), Some(2u64));
|
||||
assert_eq!(&k[..32], &<pallet::Map3<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(<pallet::Map3<Runtime, pallet::Instance1>>::get(2), Ok(1337));
|
||||
assert_eq!(&k[..32], &<pezpallet::Map3<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
assert_eq!(<pezpallet::Map3<Runtime, pezpallet::Instance1>>::get(2), Ok(1337));
|
||||
|
||||
<pallet::DoubleMap<Runtime, pallet::Instance1>>::insert(&1, &2, &3);
|
||||
<pezpallet::DoubleMap<Runtime, pezpallet::Instance1>>::insert(&1, &2, &3);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"DoubleMap")].concat();
|
||||
k.extend(1u8.using_encoded(blake2_128_concat));
|
||||
k.extend(2u16.using_encoded(twox_64_concat));
|
||||
assert_eq!(unhashed::get::<u32>(&k), Some(3u32));
|
||||
assert_eq!(&k[..32], &<pallet::DoubleMap<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::DoubleMap<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
|
||||
<pallet::DoubleMap2<Runtime, pallet::Instance1>>::insert(&1, &2, &3);
|
||||
<pezpallet::DoubleMap2<Runtime, pezpallet::Instance1>>::insert(&1, &2, &3);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"DoubleMap2")].concat();
|
||||
k.extend(1u16.using_encoded(twox_64_concat));
|
||||
k.extend(2u32.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u64>(&k), Some(3u64));
|
||||
assert_eq!(&k[..32], &<pallet::DoubleMap2<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::DoubleMap2<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
|
||||
<pallet::DoubleMap3<Runtime, pallet::Instance1>>::insert(&1, &2, &3);
|
||||
<pezpallet::DoubleMap3<Runtime, pezpallet::Instance1>>::insert(&1, &2, &3);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"DoubleMap3")].concat();
|
||||
k.extend(1u32.using_encoded(blake2_128_concat));
|
||||
k.extend(2u64.using_encoded(twox_64_concat));
|
||||
assert_eq!(unhashed::get::<u128>(&k), Some(3u128));
|
||||
assert_eq!(&k[..32], &<pallet::DoubleMap3<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::DoubleMap3<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
assert_eq!(
|
||||
<pallet::DoubleMap3<Runtime, pallet::Instance1>>::get(2, 3),
|
||||
Err(pallet::Error::<Runtime, pallet::Instance1>::NonExistentStorageValue),
|
||||
<pezpallet::DoubleMap3<Runtime, pezpallet::Instance1>>::get(2, 3),
|
||||
Err(pezpallet::Error::<Runtime, pezpallet::Instance1>::NonExistentStorageValue),
|
||||
);
|
||||
|
||||
<pallet::NMap<Runtime, pallet::Instance1>>::insert((&1,), &3);
|
||||
<pezpallet::NMap<Runtime, pezpallet::Instance1>>::insert((&1,), &3);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"NMap")].concat();
|
||||
k.extend(1u8.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u32>(&k), Some(3u32));
|
||||
assert_eq!(&k[..32], &<pallet::NMap<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::NMap<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
|
||||
<pallet::NMap2<Runtime, pallet::Instance1>>::insert((&1, &2), &3);
|
||||
<pezpallet::NMap2<Runtime, pezpallet::Instance1>>::insert((&1, &2), &3);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"NMap2")].concat();
|
||||
k.extend(1u16.using_encoded(twox_64_concat));
|
||||
k.extend(2u32.using_encoded(blake2_128_concat));
|
||||
assert_eq!(unhashed::get::<u64>(&k), Some(3u64));
|
||||
assert_eq!(&k[..32], &<pallet::NMap2<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::NMap2<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
|
||||
<pallet::NMap3<Runtime, pallet::Instance1>>::insert((&1, &2), &3);
|
||||
<pezpallet::NMap3<Runtime, pezpallet::Instance1>>::insert((&1, &2), &3);
|
||||
let mut k = [twox_128(b"Instance1Example"), twox_128(b"NMap3")].concat();
|
||||
k.extend(1u8.using_encoded(blake2_128_concat));
|
||||
k.extend(2u16.using_encoded(twox_64_concat));
|
||||
assert_eq!(unhashed::get::<u128>(&k), Some(3u128));
|
||||
assert_eq!(&k[..32], &<pallet::NMap3<Runtime, pallet::Instance1>>::final_prefix());
|
||||
assert_eq!(&k[..32], &<pezpallet::NMap3<Runtime, pezpallet::Instance1>>::final_prefix());
|
||||
assert_eq!(
|
||||
<pallet::NMap3<Runtime, pallet::Instance1>>::get((2, 3)),
|
||||
Err(pallet::Error::<Runtime, pallet::Instance1>::NonExistentStorageValue),
|
||||
<pezpallet::NMap3<Runtime, pezpallet::Instance1>>::get((2, 3)),
|
||||
Err(pezpallet::Error::<Runtime, pezpallet::Instance1>::NonExistentStorageValue),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -671,11 +671,11 @@ fn pezpallet_metadata_expands() {
|
||||
|
||||
assert_eq!(infos[1].index, 1);
|
||||
assert_eq!(infos[1].name, "Example");
|
||||
assert_eq!(infos[1].module_name, "pallet");
|
||||
assert_eq!(infos[1].module_name, "pezpallet");
|
||||
|
||||
assert_eq!(infos[2].index, 2);
|
||||
assert_eq!(infos[2].name, "Instance1Example");
|
||||
assert_eq!(infos[2].module_name, "pallet");
|
||||
assert_eq!(infos[2].module_name, "pezpallet");
|
||||
|
||||
assert_eq!(infos[3].index, 3);
|
||||
assert_eq!(infos[3].name, "Example2");
|
||||
@@ -689,7 +689,7 @@ fn pezpallet_metadata_expands() {
|
||||
#[test]
|
||||
fn pezpallet_hooks_expand() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
pezframe_system::Pallet::<Runtime>::set_block_number(1);
|
||||
pezframe_system::Pezpallet::<Runtime>::set_block_number(1);
|
||||
|
||||
assert_eq!(AllPalletsWithoutSystem::on_initialize(1), Weight::from_parts(21, 0));
|
||||
AllPalletsWithoutSystem::on_finalize(1);
|
||||
@@ -697,28 +697,28 @@ fn pezpallet_hooks_expand() {
|
||||
assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), Weight::from_parts(61, 0));
|
||||
|
||||
assert_eq!(
|
||||
pezframe_system::Pallet::<Runtime>::events()[0].event,
|
||||
RuntimeEvent::Example(pallet::Event::Something(10)),
|
||||
pezframe_system::Pezpallet::<Runtime>::events()[0].event,
|
||||
RuntimeEvent::Example(pezpallet::Event::Something(10)),
|
||||
);
|
||||
assert_eq!(
|
||||
pezframe_system::Pallet::<Runtime>::events()[1].event,
|
||||
RuntimeEvent::Instance1Example(pallet::Event::Something(11)),
|
||||
pezframe_system::Pezpallet::<Runtime>::events()[1].event,
|
||||
RuntimeEvent::Instance1Example(pezpallet::Event::Something(11)),
|
||||
);
|
||||
assert_eq!(
|
||||
pezframe_system::Pallet::<Runtime>::events()[2].event,
|
||||
RuntimeEvent::Example(pallet::Event::Something(20)),
|
||||
pezframe_system::Pezpallet::<Runtime>::events()[2].event,
|
||||
RuntimeEvent::Example(pezpallet::Event::Something(20)),
|
||||
);
|
||||
assert_eq!(
|
||||
pezframe_system::Pallet::<Runtime>::events()[3].event,
|
||||
RuntimeEvent::Instance1Example(pallet::Event::Something(21)),
|
||||
pezframe_system::Pezpallet::<Runtime>::events()[3].event,
|
||||
RuntimeEvent::Instance1Example(pezpallet::Event::Something(21)),
|
||||
);
|
||||
assert_eq!(
|
||||
pezframe_system::Pallet::<Runtime>::events()[4].event,
|
||||
RuntimeEvent::Example(pallet::Event::Something(30)),
|
||||
pezframe_system::Pezpallet::<Runtime>::events()[4].event,
|
||||
RuntimeEvent::Example(pezpallet::Event::Something(30)),
|
||||
);
|
||||
assert_eq!(
|
||||
pezframe_system::Pallet::<Runtime>::events()[5].event,
|
||||
RuntimeEvent::Instance1Example(pallet::Event::Something(31)),
|
||||
pezframe_system::Pezpallet::<Runtime>::events()[5].event,
|
||||
RuntimeEvent::Instance1Example(pezpallet::Event::Something(31)),
|
||||
);
|
||||
})
|
||||
}
|
||||
@@ -726,9 +726,9 @@ fn pezpallet_hooks_expand() {
|
||||
#[test]
|
||||
fn pezpallet_on_genesis() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
pallet::Pallet::<Runtime>::on_genesis();
|
||||
pezpallet::Pezpallet::<Runtime>::on_genesis();
|
||||
|
||||
pallet::Pallet::<Runtime, pallet::Instance1>::on_genesis();
|
||||
pezpallet::Pezpallet::<Runtime, pezpallet::Instance1>::on_genesis();
|
||||
})
|
||||
}
|
||||
|
||||
@@ -901,15 +901,15 @@ fn metadata() {
|
||||
},
|
||||
],
|
||||
}),
|
||||
calls: Some(scale_info::meta_type::<pallet::Call<Runtime>>().into()),
|
||||
event: Some(PalletEventMetadata { ty: scale_info::meta_type::<pallet::Event<Runtime>>() }),
|
||||
calls: Some(scale_info::meta_type::<pezpallet::Call<Runtime>>().into()),
|
||||
event: Some(PalletEventMetadata { ty: scale_info::meta_type::<pezpallet::Event<Runtime>>() }),
|
||||
constants: vec![PalletConstantMetadata {
|
||||
name: "MyGetParam",
|
||||
ty: scale_info::meta_type::<u32>(),
|
||||
value: vec![10, 0, 0, 0],
|
||||
docs: vec![],
|
||||
}],
|
||||
error: Some(PalletErrorMetadata { ty: scale_info::meta_type::<pallet::Error<Runtime>>() }),
|
||||
error: Some(PalletErrorMetadata { ty: scale_info::meta_type::<pezpallet::Error<Runtime>>() }),
|
||||
};
|
||||
|
||||
let mut example_pallet_instance1_metadata = example_pallet_metadata.clone();
|
||||
@@ -917,19 +917,19 @@ fn metadata() {
|
||||
example_pallet_instance1_metadata.index = 2;
|
||||
match example_pallet_instance1_metadata.calls {
|
||||
Some(ref mut calls_meta) => {
|
||||
calls_meta.ty = scale_info::meta_type::<pallet::Call<Runtime, pallet::Instance1>>();
|
||||
calls_meta.ty = scale_info::meta_type::<pezpallet::Call<Runtime, pezpallet::Instance1>>();
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
match example_pallet_instance1_metadata.event {
|
||||
Some(ref mut event_meta) => {
|
||||
event_meta.ty = scale_info::meta_type::<pallet::Event<Runtime, pallet::Instance1>>();
|
||||
event_meta.ty = scale_info::meta_type::<pezpallet::Event<Runtime, pezpallet::Instance1>>();
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
match example_pallet_instance1_metadata.error {
|
||||
Some(ref mut error_meta) => {
|
||||
error_meta.ty = scale_info::meta_type::<pallet::Error<Runtime, pallet::Instance1>>();
|
||||
error_meta.ty = scale_info::meta_type::<pezpallet::Error<Runtime, pezpallet::Instance1>>();
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
@@ -994,11 +994,11 @@ fn test_pallet_info_access() {
|
||||
#[test]
|
||||
fn test_storage_alias() {
|
||||
#[pezframe_support::storage_alias]
|
||||
type Value<T: pallet::Config<I>, I: 'static> =
|
||||
StorageValue<pallet::Pallet<T, I>, u32, ValueQuery>;
|
||||
type Value<T: pezpallet::Config<I>, I: 'static> =
|
||||
StorageValue<pezpallet::Pezpallet<T, I>, u32, ValueQuery>;
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
pallet::Value::<Runtime, pallet::Instance1>::put(10);
|
||||
assert_eq!(10, Value::<Runtime, pallet::Instance1>::get());
|
||||
pezpallet::Value::<Runtime, pezpallet::Instance1>::put(10);
|
||||
assert_eq!(10, Value::<Runtime, pezpallet::Instance1>::get());
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user