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:
@@ -48,7 +48,7 @@ pub type DispatchResult = Result<(), pezsp_runtime::DispatchError>;
|
||||
/// The error type contained in a `DispatchResultWithPostInfo`.
|
||||
pub type DispatchErrorWithPostInfo = pezsp_runtime::DispatchErrorWithPostInfo<PostDispatchInfo>;
|
||||
|
||||
/// Serializable version of pallet dispatchable.
|
||||
/// Serializable version of pezpallet dispatchable.
|
||||
pub trait Callable<T> {
|
||||
type RuntimeCall: UnfilteredDispatchable + Codec + Clone + PartialEq + Eq;
|
||||
}
|
||||
@@ -59,19 +59,19 @@ pub type CallableCallFor<A, R> = <A as Callable<R>>::RuntimeCall;
|
||||
|
||||
/// Means to checks if the dispatchable is feeless.
|
||||
///
|
||||
/// This is automatically implemented for all dispatchables during pallet expansion.
|
||||
/// If a call is marked by [`#[pallet::feeless_if]`](`macro@pezframe_support_procedural::feeless_if`)
|
||||
/// This is automatically implemented for all dispatchables during pezpallet expansion.
|
||||
/// If a call is marked by [`#[pezpallet::feeless_if]`](`macro@pezframe_support_procedural::feeless_if`)
|
||||
/// attribute, the corresponding closure is checked.
|
||||
pub trait CheckIfFeeless {
|
||||
/// The Origin type of the runtime.
|
||||
type Origin;
|
||||
|
||||
/// Checks if the dispatchable satisfies the feeless condition as defined by
|
||||
/// [`#[pallet::feeless_if]`](`macro@pezframe_support_procedural::feeless_if`)
|
||||
/// [`#[pezpallet::feeless_if]`](`macro@pezframe_support_procedural::feeless_if`)
|
||||
fn is_feeless(&self, origin: &Self::Origin) -> bool;
|
||||
}
|
||||
|
||||
/// Origin for the System pallet.
|
||||
/// Origin for the System pezpallet.
|
||||
#[derive(
|
||||
PartialEq, Eq, Clone, Debug, Encode, Decode, DecodeWithMemTracking, TypeInfo, MaxEncodedLen,
|
||||
)]
|
||||
@@ -82,7 +82,7 @@ pub enum RawOrigin<AccountId> {
|
||||
Signed(AccountId),
|
||||
/// It is signed by nobody, can be either:
|
||||
/// * included and agreed upon by the validators anyway,
|
||||
/// * or unsigned transaction validated by a pallet.
|
||||
/// * or unsigned transaction validated by a pezpallet.
|
||||
None,
|
||||
/// It is signed by nobody, the extrinsic is authorized by the runtime.
|
||||
///
|
||||
@@ -249,7 +249,7 @@ impl<'a> OneOrMany<DispatchClass> for &'a [DispatchClass] {
|
||||
}
|
||||
}
|
||||
|
||||
/// A bundle of static information collected from the `#[pallet::weight]` attributes.
|
||||
/// A bundle of static information collected from the `#[pezpallet::weight]` attributes.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Default, Debug, Encode, Decode, TypeInfo)]
|
||||
pub struct DispatchInfo {
|
||||
/// Weight of this transaction's call.
|
||||
@@ -270,7 +270,7 @@ impl DispatchInfo {
|
||||
}
|
||||
|
||||
/// A `Dispatchable` function (aka transaction) that can carry some static information along with
|
||||
/// it, using the `#[pallet::weight]` attribute.
|
||||
/// it, using the `#[pezpallet::weight]` attribute.
|
||||
pub trait GetDispatchInfo {
|
||||
/// Return a `DispatchInfo`, containing relevant information of this dispatch.
|
||||
///
|
||||
@@ -727,17 +727,17 @@ mod weight_tests {
|
||||
PostDispatchInfo { actual_weight: ref_time.map(|t| Weight::from_all(t)), pays_fee }
|
||||
}
|
||||
|
||||
#[crate::pallet(dev_mode)]
|
||||
#[crate::pezpallet(dev_mode)]
|
||||
pub mod pezframe_system {
|
||||
use super::{pezframe_system, pezframe_system::pezpallet_prelude::*};
|
||||
pub use crate::dispatch::RawOrigin;
|
||||
use crate::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pallet::disable_pezframe_system_supertrait_check]
|
||||
#[pezpallet::config]
|
||||
#[pezpallet::disable_pezframe_system_supertrait_check]
|
||||
pub trait Config: 'static {
|
||||
type Block: Parameter + pezsp_runtime::traits::Block;
|
||||
type AccountId;
|
||||
@@ -750,65 +750,65 @@ mod weight_tests {
|
||||
type DbWeight: Get<crate::weights::RuntimeDbWeight>;
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Required by construct_runtime
|
||||
CallFiltered,
|
||||
}
|
||||
|
||||
#[pallet::origin]
|
||||
#[pezpallet::origin]
|
||||
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
// no arguments, fixed weight
|
||||
#[pallet::weight(1000)]
|
||||
#[pezpallet::weight(1000)]
|
||||
pub fn f00(_origin: OriginFor<T>) -> DispatchResult {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[pallet::weight((1000, DispatchClass::Mandatory))]
|
||||
#[pezpallet::weight((1000, DispatchClass::Mandatory))]
|
||||
pub fn f01(_origin: OriginFor<T>) -> DispatchResult {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[pallet::weight((1000, Pays::No))]
|
||||
#[pezpallet::weight((1000, Pays::No))]
|
||||
pub fn f02(_origin: OriginFor<T>) -> DispatchResult {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[pallet::weight((1000, DispatchClass::Operational, Pays::No))]
|
||||
#[pezpallet::weight((1000, DispatchClass::Operational, Pays::No))]
|
||||
pub fn f03(_origin: OriginFor<T>) -> DispatchResult {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
// weight = a x 10 + b
|
||||
#[pallet::weight(((_a * 10 + _eb * 1) as u64, DispatchClass::Normal, Pays::Yes))]
|
||||
#[pezpallet::weight(((_a * 10 + _eb * 1) as u64, DispatchClass::Normal, Pays::Yes))]
|
||||
pub fn f11(_origin: OriginFor<T>, _a: u32, _eb: u32) -> DispatchResult {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[pallet::weight((0, DispatchClass::Operational, Pays::Yes))]
|
||||
#[pezpallet::weight((0, DispatchClass::Operational, Pays::Yes))]
|
||||
pub fn f12(_origin: OriginFor<T>, _a: u32, _eb: u32) -> DispatchResult {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[pallet::weight(T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + Weight::from_all(10_000))]
|
||||
#[pezpallet::weight(T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + Weight::from_all(10_000))]
|
||||
pub fn f20(_origin: OriginFor<T>) -> DispatchResult {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[pallet::weight(T::DbWeight::get().reads_writes(6, 5) + Weight::from_all(40_000))]
|
||||
#[pezpallet::weight(T::DbWeight::get().reads_writes(6, 5) + Weight::from_all(40_000))]
|
||||
pub fn f21(_origin: OriginFor<T>) -> DispatchResult {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[pallet::weight(1000)]
|
||||
#[pezpallet::weight(1000)]
|
||||
pub fn f99(_origin: OriginFor<T>) -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::weight(1000)]
|
||||
#[pezpallet::weight(1000)]
|
||||
pub fn f100(_origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
||||
Ok(crate::dispatch::PostDispatchInfo {
|
||||
actual_weight: Some(Weight::from_parts(500, 0)),
|
||||
@@ -862,50 +862,50 @@ mod weight_tests {
|
||||
|
||||
#[test]
|
||||
fn weights_are_correct() {
|
||||
// #[pallet::weight(1000)]
|
||||
// #[pezpallet::weight(1000)]
|
||||
let info = Call::<Runtime>::f00 {}.get_dispatch_info();
|
||||
assert_eq!(info.total_weight(), Weight::from_parts(1000, 0));
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[pallet::weight((1000, DispatchClass::Mandatory))]
|
||||
// #[pezpallet::weight((1000, DispatchClass::Mandatory))]
|
||||
let info = Call::<Runtime>::f01 {}.get_dispatch_info();
|
||||
assert_eq!(info.total_weight(), Weight::from_parts(1000, 0));
|
||||
assert_eq!(info.class, DispatchClass::Mandatory);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[pallet::weight((1000, Pays::No))]
|
||||
// #[pezpallet::weight((1000, Pays::No))]
|
||||
let info = Call::<Runtime>::f02 {}.get_dispatch_info();
|
||||
assert_eq!(info.total_weight(), Weight::from_parts(1000, 0));
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::No);
|
||||
|
||||
// #[pallet::weight((1000, DispatchClass::Operational, Pays::No))]
|
||||
// #[pezpallet::weight((1000, DispatchClass::Operational, Pays::No))]
|
||||
let info = Call::<Runtime>::f03 {}.get_dispatch_info();
|
||||
assert_eq!(info.total_weight(), Weight::from_parts(1000, 0));
|
||||
assert_eq!(info.class, DispatchClass::Operational);
|
||||
assert_eq!(info.pays_fee, Pays::No);
|
||||
|
||||
// #[pallet::weight(((_a * 10 + _eb * 1) as u64, DispatchClass::Normal, Pays::Yes))]
|
||||
// #[pezpallet::weight(((_a * 10 + _eb * 1) as u64, DispatchClass::Normal, Pays::Yes))]
|
||||
let info = Call::<Runtime>::f11 { a: 13, eb: 20 }.get_dispatch_info();
|
||||
assert_eq!(info.total_weight(), Weight::from_parts(150, 0)); // 13*10 + 20
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[pallet::weight((0, DispatchClass::Operational, Pays::Yes))]
|
||||
// #[pezpallet::weight((0, DispatchClass::Operational, Pays::Yes))]
|
||||
let info = Call::<Runtime>::f12 { a: 10, eb: 20 }.get_dispatch_info();
|
||||
assert_eq!(info.total_weight(), Weight::zero());
|
||||
assert_eq!(info.class, DispatchClass::Operational);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[pallet::weight(T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) +
|
||||
// #[pezpallet::weight(T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) +
|
||||
// Weight::from_all(10_000))]
|
||||
let info = Call::<Runtime>::f20 {}.get_dispatch_info();
|
||||
assert_eq!(info.total_weight(), Weight::from_parts(12300, 10000)); // 100*3 + 1000*2 + 10_1000
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[pallet::weight(T::DbWeight::get().reads_writes(6, 5) + Weight::from_all(40_000))]
|
||||
// #[pezpallet::weight(T::DbWeight::get().reads_writes(6, 5) + Weight::from_all(40_000))]
|
||||
let info = Call::<Runtime>::f21 {}.get_dispatch_info();
|
||||
assert_eq!(info.total_weight(), Weight::from_parts(45600, 40000)); // 100*6 + 1000*5 + 40_1000
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
//! # FRAME integration
|
||||
//!
|
||||
//! The FRAME macros implement
|
||||
//! [`UnfilteredDispatchable`](pezframe_support::traits::UnfilteredDispatchable) for each pallet `Call`
|
||||
//! [`UnfilteredDispatchable`](pezframe_support::traits::UnfilteredDispatchable) for each pezpallet `Call`
|
||||
//! enum. Part of this implementation is the call to [`run_in_context`], so that each call to
|
||||
//! [`UnfilteredDispatchable::dispatch_bypass_filter`](crate::traits::UnfilteredDispatchable::dispatch_bypass_filter)
|
||||
//! or [`Dispatchable::dispatch`](pezsp_runtime::traits::Dispatchable::dispatch) will run in a dispatch
|
||||
@@ -78,7 +78,7 @@
|
||||
//! });
|
||||
//! ```
|
||||
//!
|
||||
//! In your pallet you will only have to use [`with_context`], because as described above
|
||||
//! In your pezpallet you will only have to use [`with_context`], because as described above
|
||||
//! [`run_in_context`] will be handled by FRAME for you.
|
||||
|
||||
use alloc::{
|
||||
|
||||
@@ -19,14 +19,14 @@ pub use pezsp_inherents::{
|
||||
CheckInherentsResult, InherentData, InherentIdentifier, IsFatalError, MakeFatalError,
|
||||
};
|
||||
|
||||
/// A pallet that provides or verifies an inherent extrinsic will implement this trait.
|
||||
/// A pezpallet that provides or verifies an inherent extrinsic will implement this trait.
|
||||
///
|
||||
/// The pallet may provide an inherent, verify an inherent, or both provide and verify.
|
||||
/// The pezpallet may provide an inherent, verify an inherent, or both provide and verify.
|
||||
///
|
||||
/// Briefly, inherent extrinsics ("inherents") are extrinsics that are added to a block by the block
|
||||
/// producer. See [`pezsp_inherents`] for more documentation on inherents.
|
||||
pub trait ProvideInherent {
|
||||
/// The call type of the pallet.
|
||||
/// The call type of the pezpallet.
|
||||
type Call;
|
||||
/// The error returned by `check_inherent`.
|
||||
type Error: codec::Encode + IsFatalError;
|
||||
|
||||
@@ -15,99 +15,99 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Some instance placeholder to be used in [`pezframe_support::pallet`] attribute macro.
|
||||
//! Some instance placeholder to be used in [`pezframe_support::pezpallet`] attribute macro.
|
||||
//!
|
||||
//! [`pezframe_support::pallet`] attribute macro does only requires the instance generic `I` to be
|
||||
//! [`pezframe_support::pezpallet`] attribute macro does only requires the instance generic `I` to be
|
||||
//! static (contrary to `decl_*` macro which requires instance generic to implement
|
||||
//! [`pezframe_support::traits::Instance`]).
|
||||
//!
|
||||
//! Thus support provides some instance types to be used, This allow some instantiable pallet to
|
||||
//! Thus support provides some instance types to be used, This allow some instantiable pezpallet to
|
||||
//! depend on specific instance of another:
|
||||
//! ```
|
||||
//! # mod another_pallet { pub trait Config<I: 'static = ()> {} }
|
||||
//! pub trait Config<I: 'static = ()>: another_pallet::Config<I> {}
|
||||
//! ```
|
||||
//!
|
||||
//! NOTE: [`pezframe_support::pallet`] will reexport them inside the module, in order to make them
|
||||
//! NOTE: [`pezframe_support::pezpallet`] will reexport them inside the module, in order to make them
|
||||
//! accessible to [`pezframe_support::construct_runtime`].
|
||||
|
||||
/// `Instance1` to be used for instantiable pallets defined with the
|
||||
/// [`#[pallet]`](`pezframe_support::pallet`) macro. Instances 2-16 are also available but are hidden
|
||||
/// [`#[pezpallet]`](`pezframe_support::pezpallet`) macro. Instances 2-16 are also available but are hidden
|
||||
/// from docs.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance1;
|
||||
|
||||
/// `Instance2` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance2` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance2;
|
||||
|
||||
/// `Instance3` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance3` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance3;
|
||||
|
||||
/// `Instance4` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance4` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance4;
|
||||
|
||||
/// `Instance5` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance5` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance5;
|
||||
|
||||
/// `Instance6` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance6` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance6;
|
||||
|
||||
/// `Instance7` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance7` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance7;
|
||||
|
||||
/// `Instance8` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance8` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance8;
|
||||
|
||||
/// `Instance9` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance9` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance9;
|
||||
|
||||
/// `Instance10` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance10` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance10;
|
||||
|
||||
/// `Instance11` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance11` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance11;
|
||||
|
||||
/// `Instance12` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance12` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance12;
|
||||
|
||||
/// `Instance13` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance13` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance13;
|
||||
|
||||
/// `Instance14` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance14` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance14;
|
||||
|
||||
/// `Instance15` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance15` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance15;
|
||||
|
||||
/// `Instance16` to be used for instantiable pallets defined with the `#[pallet]` macro.
|
||||
/// `Instance16` to be used for instantiable pallets defined with the `#[pezpallet]` macro.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
|
||||
pub struct Instance16;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,7 @@ use pezsp_core::Get;
|
||||
use pezsp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult};
|
||||
use pezsp_runtime::traits::Zero;
|
||||
|
||||
/// Handles storage migration pallet versioning.
|
||||
/// Handles storage migration pezpallet versioning.
|
||||
///
|
||||
/// [`VersionedMigration`] allows developers to write migrations without worrying about checking and
|
||||
/// setting storage versions. Instead, the developer wraps their migration in this struct which
|
||||
@@ -43,11 +43,11 @@ use pezsp_runtime::traits::Zero;
|
||||
/// - `From`: The version being upgraded from.
|
||||
/// - `To`: The version being upgraded to.
|
||||
/// - `Inner`: An implementation of `UncheckedOnRuntimeUpgrade`.
|
||||
/// - `Pallet`: The Pallet being upgraded.
|
||||
/// - `Pezpallet`: The Pezpallet being upgraded.
|
||||
/// - `Weight`: The runtime's RuntimeDbWeight implementation.
|
||||
///
|
||||
/// When a [`VersionedMigration`] `on_runtime_upgrade`, `pre_upgrade`, or `post_upgrade` method is
|
||||
/// called, the on-chain version of the pallet is compared to `From`. If they match, the `Inner`
|
||||
/// called, the on-chain version of the pezpallet is compared to `From`. If they match, the `Inner`
|
||||
/// `UncheckedOnRuntimeUpgrade` is called and the pallets on-chain version is set to `To`
|
||||
/// after the migration. Otherwise, a warning is logged notifying the developer that the upgrade was
|
||||
/// a noop and should probably be removed.
|
||||
@@ -83,19 +83,19 @@ use pezsp_runtime::traits::Zero;
|
||||
/// 5,
|
||||
/// 6,
|
||||
/// VersionUncheckedMigrateV5ToV6<T, I>,
|
||||
/// crate::pallet::Pallet<T, I>,
|
||||
/// crate::pezpallet::Pezpallet<T, I>,
|
||||
/// <T as pezframe_system::Config>::DbWeight
|
||||
/// >;
|
||||
///
|
||||
/// // Migrations tuple to pass to the Executive pallet:
|
||||
/// // Migrations tuple to pass to the Executive pezpallet:
|
||||
/// pub type Migrations = (
|
||||
/// // other migrations...
|
||||
/// MigrateV5ToV6<T, ()>,
|
||||
/// // other migrations...
|
||||
/// );
|
||||
/// ```
|
||||
pub struct VersionedMigration<const FROM: u16, const TO: u16, Inner, Pallet, Weight> {
|
||||
_marker: PhantomData<(Inner, Pallet, Weight)>,
|
||||
pub struct VersionedMigration<const FROM: u16, const TO: u16, Inner, Pezpallet, Weight> {
|
||||
_marker: PhantomData<(Inner, Pezpallet, Weight)>,
|
||||
}
|
||||
|
||||
/// A helper enum to wrap the pre_upgrade bytes like an Option before passing them to post_upgrade.
|
||||
@@ -118,16 +118,16 @@ impl<
|
||||
const FROM: u16,
|
||||
const TO: u16,
|
||||
Inner: crate::traits::UncheckedOnRuntimeUpgrade,
|
||||
Pallet: GetStorageVersion<InCodeStorageVersion = StorageVersion> + PalletInfoAccess,
|
||||
Pezpallet: GetStorageVersion<InCodeStorageVersion = StorageVersion> + PalletInfoAccess,
|
||||
DbWeight: Get<RuntimeDbWeight>,
|
||||
> crate::traits::OnRuntimeUpgrade for VersionedMigration<FROM, TO, Inner, Pallet, DbWeight>
|
||||
> crate::traits::OnRuntimeUpgrade for VersionedMigration<FROM, TO, Inner, Pezpallet, DbWeight>
|
||||
{
|
||||
/// Executes pre_upgrade if the migration will run, and wraps the pre_upgrade bytes in
|
||||
/// [`VersionedPostUpgradeData`] before passing them to post_upgrade, so it knows whether the
|
||||
/// migration ran or not.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<alloc::vec::Vec<u8>, pezsp_runtime::TryRuntimeError> {
|
||||
let on_chain_version = Pallet::on_chain_storage_version();
|
||||
let on_chain_version = Pezpallet::on_chain_storage_version();
|
||||
if on_chain_version == FROM {
|
||||
Ok(VersionedPostUpgradeData::MigrationExecuted(Inner::pre_upgrade()?).encode())
|
||||
} else {
|
||||
@@ -142,11 +142,11 @@ impl<
|
||||
/// the weight. If it does not match, it writes a log notifying the developer that the migration
|
||||
/// is a noop.
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let on_chain_version = Pallet::on_chain_storage_version();
|
||||
let on_chain_version = Pezpallet::on_chain_storage_version();
|
||||
if on_chain_version == FROM {
|
||||
log::info!(
|
||||
"🚚 Pallet {:?} VersionedMigration migrating storage version from {:?} to {:?}.",
|
||||
Pallet::name(),
|
||||
"🚚 Pezpallet {:?} VersionedMigration migrating storage version from {:?} to {:?}.",
|
||||
Pezpallet::name(),
|
||||
FROM,
|
||||
TO
|
||||
);
|
||||
@@ -155,13 +155,13 @@ impl<
|
||||
let weight = Inner::on_runtime_upgrade();
|
||||
|
||||
// Update the on-chain version
|
||||
StorageVersion::new(TO).put::<Pallet>();
|
||||
StorageVersion::new(TO).put::<Pezpallet>();
|
||||
|
||||
weight.saturating_add(DbWeight::get().reads_writes(1, 1))
|
||||
} else {
|
||||
log::warn!(
|
||||
"🚚 Pallet {:?} VersionedMigration migration {}->{} can be removed; on-chain is already at {:?}.",
|
||||
Pallet::name(),
|
||||
"🚚 Pezpallet {:?} VersionedMigration migration {}->{} can be removed; on-chain is already at {:?}.",
|
||||
Pezpallet::name(),
|
||||
FROM,
|
||||
TO,
|
||||
on_chain_version
|
||||
@@ -189,7 +189,7 @@ impl<
|
||||
}
|
||||
}
|
||||
|
||||
/// Can store the in-code pallet version on-chain.
|
||||
/// Can store the in-code pezpallet version on-chain.
|
||||
pub trait StoreInCodeStorageVersion<T: GetStorageVersion + PalletInfoAccess> {
|
||||
/// Write the in-code storage version on-chain.
|
||||
fn store_in_code_storage_version();
|
||||
@@ -261,16 +261,16 @@ pub fn migrate_from_pallet_version_to_storage_version<
|
||||
}
|
||||
|
||||
/// `RemovePallet` is a utility struct used to remove all storage items associated with a specific
|
||||
/// pallet.
|
||||
/// pezpallet.
|
||||
///
|
||||
/// This struct is generic over two parameters:
|
||||
/// - `P` is a type that implements the `Get` trait for a static string, representing the pallet's
|
||||
/// - `P` is a type that implements the `Get` trait for a static string, representing the pezpallet's
|
||||
/// name.
|
||||
/// - `DbWeight` is a type that implements the `Get` trait for `RuntimeDbWeight`, providing the
|
||||
/// weight for database operations.
|
||||
///
|
||||
/// On runtime upgrade, the `on_runtime_upgrade` function will clear all storage items associated
|
||||
/// with the specified pallet, logging the number of keys removed. If the `try-runtime` feature is
|
||||
/// with the specified pezpallet, logging the number of keys removed. If the `try-runtime` feature is
|
||||
/// enabled, the `pre_upgrade` and `post_upgrade` functions can be used to verify the storage
|
||||
/// removal before and after the upgrade.
|
||||
///
|
||||
@@ -305,9 +305,9 @@ pub fn migrate_from_pallet_version_to_storage_version<
|
||||
/// ```
|
||||
///
|
||||
/// WARNING: `RemovePallet` has no guard rails preventing it from bricking the chain if the
|
||||
/// operation of removing storage for the given pallet would exceed the block weight limit.
|
||||
/// operation of removing storage for the given pezpallet would exceed the block weight limit.
|
||||
///
|
||||
/// If your pallet has too many keys to be removed in a single block, it is advised to wait for
|
||||
/// If your pezpallet has too many keys to be removed in a single block, it is advised to wait for
|
||||
/// a multi-block scheduler currently under development which will allow for removal of storage
|
||||
/// items (and performing other heavy migrations) over multiple blocks
|
||||
/// (see <https://github.com/pezkuwichain/kurdistan-sdk/issues/11>).
|
||||
@@ -366,10 +366,10 @@ impl<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>> pezframe_support::tra
|
||||
}
|
||||
}
|
||||
|
||||
/// `RemoveStorage` is a utility struct used to remove a storage item from a specific pallet.
|
||||
/// `RemoveStorage` is a utility struct used to remove a storage item from a specific pezpallet.
|
||||
///
|
||||
/// This struct is generic over three parameters:
|
||||
/// - `P` is a type that implements the [`Get`] trait for a static string, representing the pallet's
|
||||
/// - `P` is a type that implements the [`Get`] trait for a static string, representing the pezpallet's
|
||||
/// name.
|
||||
/// - `S` is a type that implements the [`Get`] trait for a static string, representing the storage
|
||||
/// name.
|
||||
@@ -412,7 +412,7 @@ impl<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>> pezframe_support::tra
|
||||
/// ```
|
||||
///
|
||||
/// WARNING: `RemoveStorage` has no guard rails preventing it from bricking the chain if the
|
||||
/// operation of removing storage for the given pallet would exceed the block weight limit.
|
||||
/// operation of removing storage for the given pezpallet would exceed the block weight limit.
|
||||
///
|
||||
/// If your storage has too many keys to be removed in a single block, it is advised to wait for
|
||||
/// a multi-block scheduler currently under development which will allow for removal of storage
|
||||
@@ -430,7 +430,7 @@ impl<P: Get<&'static str>, S: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>>
|
||||
KillStorageResult::AllRemoved(value) => value,
|
||||
KillStorageResult::SomeRemaining(value) => {
|
||||
log::error!(
|
||||
"`clear_prefix` failed to remove all keys for storage `{}` from pallet `{}`. THIS SHOULD NEVER HAPPEN! 🚨",
|
||||
"`clear_prefix` failed to remove all keys for storage `{}` from pezpallet `{}`. THIS SHOULD NEVER HAPPEN! 🚨",
|
||||
S::get(), P::get()
|
||||
);
|
||||
value
|
||||
|
||||
@@ -53,7 +53,7 @@ pub trait StorageDoubleMap<K1: FullEncode, K2: FullEncode, V: FullCodec> {
|
||||
/// Hasher for the second key.
|
||||
type Hasher2: StorageHasher;
|
||||
|
||||
/// Pallet prefix. Used for generating final key.
|
||||
/// Pezpallet prefix. Used for generating final key.
|
||||
fn pezpallet_prefix() -> &'static [u8];
|
||||
|
||||
/// Storage prefix. Used for generating final key.
|
||||
|
||||
@@ -41,7 +41,7 @@ pub trait StorageMap<K: FullEncode, V: FullCodec> {
|
||||
/// Hasher. Used for generating final key.
|
||||
type Hasher: StorageHasher;
|
||||
|
||||
/// Pallet prefix. Used for generating final key.
|
||||
/// Pezpallet prefix. Used for generating final key.
|
||||
fn pezpallet_prefix() -> &'static [u8];
|
||||
|
||||
/// Storage prefix. Used for generating final key.
|
||||
|
||||
@@ -46,18 +46,18 @@ mod tests {
|
||||
storage::{generator::StorageValue, unhashed},
|
||||
};
|
||||
|
||||
#[crate::pallet]
|
||||
#[crate::pezpallet]
|
||||
pub mod pezframe_system {
|
||||
#[allow(unused)]
|
||||
use super::{pezframe_system, pezframe_system::pezpallet_prelude::*};
|
||||
pub use crate::dispatch::RawOrigin;
|
||||
use crate::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pallet::disable_pezframe_system_supertrait_check]
|
||||
#[pezpallet::config]
|
||||
#[pezpallet::disable_pezframe_system_supertrait_check]
|
||||
pub trait Config: 'static {
|
||||
type Block: pezsp_runtime::traits::Block;
|
||||
type AccountId;
|
||||
@@ -69,32 +69,32 @@ mod tests {
|
||||
type DbWeight: Get<crate::weights::RuntimeDbWeight>;
|
||||
}
|
||||
|
||||
#[pallet::origin]
|
||||
#[pezpallet::origin]
|
||||
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Required by construct_runtime
|
||||
CallFiltered,
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {}
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Value<T> = StorageValue<_, (u64, u64), ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Map<T> = StorageMap<_, Blake2_128Concat, u16, u64, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type NumberMap<T> = StorageMap<_, Identity, u32, u64, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type DoubleMap<T> =
|
||||
StorageDoubleMap<_, Blake2_128Concat, u16, Twox64Concat, u32, u64, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type NMap<T> = StorageNMap<
|
||||
_,
|
||||
(storage::Key<Blake2_128Concat, u16>, storage::Key<Twox64Concat, u32>),
|
||||
|
||||
@@ -60,7 +60,7 @@ pub trait StorageNMap<K: KeyGenerator, V: FullCodec> {
|
||||
/// The type that get/take returns.
|
||||
type Query;
|
||||
|
||||
/// Pallet prefix. Used for generating final key.
|
||||
/// Pezpallet prefix. Used for generating final key.
|
||||
fn pezpallet_prefix() -> &'static [u8];
|
||||
|
||||
/// Storage prefix. Used for generating final key.
|
||||
|
||||
@@ -31,7 +31,7 @@ pub trait StorageValue<T: FullCodec> {
|
||||
/// The type that get/take returns.
|
||||
type Query;
|
||||
|
||||
/// Pallet prefix. Used for generating final key.
|
||||
/// Pezpallet prefix. Used for generating final key.
|
||||
fn pezpallet_prefix() -> &'static [u8];
|
||||
|
||||
/// Storage prefix. Used for generating final key.
|
||||
|
||||
@@ -300,9 +300,9 @@ pub fn take_storage_item<K: Encode + Sized, T: Decode + Sized, H: StorageHasher>
|
||||
take_storage_value(module, item, key.using_encoded(H::hash).as_ref())
|
||||
}
|
||||
|
||||
/// Move a storage from a pallet prefix to another pallet prefix.
|
||||
/// Move a storage from a pezpallet prefix to another pezpallet prefix.
|
||||
///
|
||||
/// Keys used in pallet storages always start with:
|
||||
/// Keys used in pezpallet storages always start with:
|
||||
/// `concat(twox_128(pezpallet_name), twox_128(storage_name))`.
|
||||
///
|
||||
/// This function will remove all value for which the key start with
|
||||
@@ -311,7 +311,7 @@ pub fn take_storage_item<K: Encode + Sized, T: Decode + Sized, H: StorageHasher>
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// If a pallet named "my_example" has 2 storages named "Foo" and "Bar" and the pallet is renamed
|
||||
/// If a pezpallet named "my_example" has 2 storages named "Foo" and "Bar" and the pezpallet is renamed
|
||||
/// "my_new_example_name", a migration can be:
|
||||
/// ```
|
||||
/// # use pezframe_support::storage::migration::move_storage_from_pallet;
|
||||
@@ -336,9 +336,9 @@ pub fn move_storage_from_pallet(
|
||||
}
|
||||
}
|
||||
|
||||
/// Move all storages from a pallet prefix to another pallet prefix.
|
||||
/// Move all storages from a pezpallet prefix to another pezpallet prefix.
|
||||
///
|
||||
/// Keys used in pallet storages always start with:
|
||||
/// Keys used in pezpallet storages always start with:
|
||||
/// `concat(twox_128(pezpallet_name), twox_128(storage_name))`.
|
||||
///
|
||||
/// This function will remove all value for which the key start with `twox_128(old_pallet_name)`
|
||||
@@ -348,7 +348,7 @@ pub fn move_storage_from_pallet(
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// If a pallet named "my_example" has some storages and the pallet is renamed
|
||||
/// If a pezpallet named "my_example" has some storages and the pezpallet is renamed
|
||||
/// "my_new_example_name", a migration can be:
|
||||
/// ```
|
||||
/// # use pezframe_support::storage::migration::move_pallet;
|
||||
|
||||
@@ -1343,7 +1343,7 @@ impl<T> Iterator for ChildTriePrefixIterator<T> {
|
||||
|
||||
/// Trait for storage types that store all its value after a unique prefix.
|
||||
pub trait StoragePrefixedContainer {
|
||||
/// Pallet prefix. Used for generating final key.
|
||||
/// Pezpallet prefix. Used for generating final key.
|
||||
fn pezpallet_prefix() -> &'static [u8];
|
||||
|
||||
/// Storage prefix. Used for generating final key.
|
||||
@@ -1362,7 +1362,7 @@ pub trait StoragePrefixedContainer {
|
||||
/// Twox128(pezpallet_prefix) ++ Twox128(storage_prefix)
|
||||
/// ```
|
||||
pub trait StoragePrefixedMap<Value: FullCodec> {
|
||||
/// Pallet prefix. Used for generating final key.
|
||||
/// Pezpallet prefix. Used for generating final key.
|
||||
fn pezpallet_prefix() -> &'static [u8]; // TODO move to StoragePrefixedContainer
|
||||
|
||||
/// Storage prefix. Used for generating final key.
|
||||
@@ -1733,7 +1733,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the storage prefix for a specific pallet name and storage name.
|
||||
/// Returns the storage prefix for a specific pezpallet name and storage name.
|
||||
///
|
||||
/// The storage prefix is `concat(twox_128(pezpallet_name), twox_128(storage_name))`.
|
||||
pub fn storage_prefix(pezpallet_name: &[u8], storage_name: &[u8]) -> [u8; 32] {
|
||||
|
||||
@@ -51,7 +51,7 @@ use pezsp_runtime::traits::Saturating;
|
||||
/// The total number of items currently stored in the map can be retrieved with the
|
||||
/// [`CountedStorageMap::count`] method.
|
||||
///
|
||||
/// For general information regarding the `#[pallet::storage]` attribute, refer to
|
||||
/// For general information regarding the `#[pezpallet::storage]` attribute, refer to
|
||||
/// [`crate::pezpallet_macros::storage`].
|
||||
///
|
||||
/// # Examples
|
||||
@@ -59,18 +59,18 @@ use pezsp_runtime::traits::Saturating;
|
||||
/// Declaring a counted map:
|
||||
///
|
||||
/// ```
|
||||
/// #[pezframe_support::pallet]
|
||||
/// mod pallet {
|
||||
/// #[pezframe_support::pezpallet]
|
||||
/// mod pezpallet {
|
||||
/// # use pezframe_support::pezpallet_prelude::*;
|
||||
/// # #[pallet::config]
|
||||
/// # #[pezpallet::config]
|
||||
/// # pub trait Config: pezframe_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// # #[pezpallet::pezpallet]
|
||||
/// # pub struct Pezpallet<T>(_);
|
||||
/// /// A kitchen-sink CountedStorageMap, with all possible additional attributes.
|
||||
/// #[pallet::storage]
|
||||
/// #[pallet::getter(fn foo)]
|
||||
/// #[pallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pallet::unbounded]
|
||||
/// #[pezpallet::storage]
|
||||
/// #[pezpallet::getter(fn foo)]
|
||||
/// #[pezpallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pezpallet::unbounded]
|
||||
/// pub type Foo<T> = CountedStorageMap<
|
||||
/// _,
|
||||
/// Blake2_128Concat,
|
||||
@@ -80,7 +80,7 @@ use pezsp_runtime::traits::Saturating;
|
||||
/// >;
|
||||
///
|
||||
/// /// Alternative named syntax.
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Bar<T> = CountedStorageMap<
|
||||
/// Hasher = Blake2_128Concat,
|
||||
/// Key = u32,
|
||||
|
||||
@@ -46,24 +46,24 @@ use pezsp_runtime::traits::Saturating;
|
||||
/// Whenever the counter needs to be updated, an additional read and write occurs to update that
|
||||
/// counter.
|
||||
///
|
||||
/// For general information regarding the `#[pallet::storage]` attribute, refer to
|
||||
/// For general information regarding the `#[pezpallet::storage]` attribute, refer to
|
||||
/// [`crate::pezpallet_macros::storage`].
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// #[pezframe_support::pallet]
|
||||
/// mod pallet {
|
||||
/// #[pezframe_support::pezpallet]
|
||||
/// mod pezpallet {
|
||||
/// # use pezframe_support::pezpallet_prelude::*;
|
||||
/// # #[pallet::config]
|
||||
/// # #[pezpallet::config]
|
||||
/// # pub trait Config: pezframe_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// # #[pezpallet::pezpallet]
|
||||
/// # pub struct Pezpallet<T>(_);
|
||||
/// /// A kitchen-sink CountedStorageNMap, with all possible additional attributes.
|
||||
/// #[pallet::storage]
|
||||
/// #[pallet::getter(fn foo)]
|
||||
/// #[pallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pallet::unbounded]
|
||||
/// #[pezpallet::storage]
|
||||
/// #[pezpallet::getter(fn foo)]
|
||||
/// #[pezpallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pezpallet::unbounded]
|
||||
/// pub type Foo<T> = CountedStorageNMap<
|
||||
/// _,
|
||||
/// (
|
||||
@@ -76,7 +76,7 @@ use pezsp_runtime::traits::Saturating;
|
||||
/// >;
|
||||
///
|
||||
/// /// Alternative named syntax.
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Bar<T> = CountedStorageNMap<
|
||||
/// Key = (
|
||||
/// NMapKey<Blake2_128Concat, u8>,
|
||||
|
||||
@@ -43,7 +43,7 @@ use pezsp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
|
||||
/// Also, conceptually, a double map is a special case of a
|
||||
/// [`StorageNMap`](pezframe_support::storage::types::StorageNMap) using two keys.
|
||||
///
|
||||
/// For general information regarding the `#[pallet::storage]` attribute, refer to
|
||||
/// For general information regarding the `#[pezpallet::storage]` attribute, refer to
|
||||
/// [`crate::pezpallet_macros::storage`].
|
||||
///
|
||||
/// # Examples
|
||||
@@ -51,18 +51,18 @@ use pezsp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
|
||||
/// ### Kitchen-sink
|
||||
///
|
||||
/// ```
|
||||
/// #[pezframe_support::pallet]
|
||||
/// mod pallet {
|
||||
/// #[pezframe_support::pezpallet]
|
||||
/// mod pezpallet {
|
||||
/// # use pezframe_support::pezpallet_prelude::*;
|
||||
/// # #[pallet::config]
|
||||
/// # #[pezpallet::config]
|
||||
/// # pub trait Config: pezframe_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// # #[pezpallet::pezpallet]
|
||||
/// # pub struct Pezpallet<T>(_);
|
||||
/// /// A kitchen-sink StorageDoubleMap, with all possible additional attributes.
|
||||
/// #[pallet::storage]
|
||||
/// #[pallet::getter(fn foo)]
|
||||
/// #[pallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pallet::unbounded]
|
||||
/// #[pezpallet::storage]
|
||||
/// #[pezpallet::getter(fn foo)]
|
||||
/// #[pezpallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pezpallet::unbounded]
|
||||
/// pub type Foo<T> = StorageDoubleMap<
|
||||
/// _,
|
||||
/// Blake2_128Concat,
|
||||
@@ -74,7 +74,7 @@ use pezsp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
|
||||
/// >;
|
||||
///
|
||||
/// /// Alternative named syntax.
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Bar<T> = StorageDoubleMap<
|
||||
/// Hasher1 = Blake2_128Concat,
|
||||
/// Key1 = u8,
|
||||
@@ -138,7 +138,7 @@ where
|
||||
Key2: MaxEncodedLen,
|
||||
{
|
||||
fn get() -> u32 {
|
||||
// The `max_len` of both key hashes plus the pallet prefix and storage prefix (which both
|
||||
// The `max_len` of both key hashes plus the pezpallet prefix and storage prefix (which both
|
||||
// are hashed with `Twox128`).
|
||||
let z =
|
||||
Hasher1::max_len::<Key1>() + Hasher2::max_len::<Key2>() + Twox128::max_len::<()>() * 2;
|
||||
|
||||
@@ -35,24 +35,24 @@ use pezsp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
|
||||
/// A type representing a *map* in storage. A *storage map* is a mapping of keys to values of a
|
||||
/// given type stored on-chain.
|
||||
///
|
||||
/// For general information regarding the `#[pallet::storage]` attribute, refer to
|
||||
/// For general information regarding the `#[pezpallet::storage]` attribute, refer to
|
||||
/// [`crate::pezpallet_macros::storage`].
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// #[pezframe_support::pallet]
|
||||
/// mod pallet {
|
||||
/// #[pezframe_support::pezpallet]
|
||||
/// mod pezpallet {
|
||||
/// # use pezframe_support::pezpallet_prelude::*;
|
||||
/// # #[pallet::config]
|
||||
/// # #[pezpallet::config]
|
||||
/// # pub trait Config: pezframe_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// # #[pezpallet::pezpallet]
|
||||
/// # pub struct Pezpallet<T>(_);
|
||||
/// /// A kitchen-sink StorageMap, with all possible additional attributes.
|
||||
/// #[pallet::storage]
|
||||
/// #[pallet::getter(fn foo)]
|
||||
/// #[pallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pallet::unbounded]
|
||||
/// #[pezpallet::storage]
|
||||
/// #[pezpallet::getter(fn foo)]
|
||||
/// #[pezpallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pezpallet::unbounded]
|
||||
/// pub type Foo<T> = StorageMap<
|
||||
/// _,
|
||||
/// Blake2_128Concat,
|
||||
@@ -62,7 +62,7 @@ use pezsp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
|
||||
/// >;
|
||||
///
|
||||
/// /// Alternative named syntax.
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Bar<T> = StorageMap<
|
||||
/// Hasher = Blake2_128Concat,
|
||||
/// Key = u32,
|
||||
@@ -89,7 +89,7 @@ where
|
||||
Key: FullCodec + MaxEncodedLen,
|
||||
{
|
||||
fn get() -> u32 {
|
||||
// The `max_len` of the key hash plus the pallet prefix and storage prefix (which both are
|
||||
// The `max_len` of the key hash plus the pezpallet prefix and storage prefix (which both are
|
||||
// hashed with `Twox128`).
|
||||
let z = Hasher::max_len::<Key>() + Twox128::max_len::<()>() * 2;
|
||||
z as u32
|
||||
|
||||
@@ -40,24 +40,24 @@ use pezsp_runtime::SaturatedConversion;
|
||||
/// For example, [`StorageDoubleMap`](pezframe_support::storage::types::StorageDoubleMap) is a special
|
||||
/// case of an *NMap* with N = 2.
|
||||
///
|
||||
/// For general information regarding the `#[pallet::storage]` attribute, refer to
|
||||
/// For general information regarding the `#[pezpallet::storage]` attribute, refer to
|
||||
/// [`crate::pezpallet_macros::storage`].
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// #[pezframe_support::pallet]
|
||||
/// mod pallet {
|
||||
/// #[pezframe_support::pezpallet]
|
||||
/// mod pezpallet {
|
||||
/// # use pezframe_support::pezpallet_prelude::*;
|
||||
/// # #[pallet::config]
|
||||
/// # #[pezpallet::config]
|
||||
/// # pub trait Config: pezframe_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// # #[pezpallet::pezpallet]
|
||||
/// # pub struct Pezpallet<T>(_);
|
||||
/// /// A kitchen-sink StorageNMap, with all possible additional attributes.
|
||||
/// #[pallet::storage]
|
||||
/// #[pallet::getter(fn foo)]
|
||||
/// #[pallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pallet::unbounded]
|
||||
/// #[pezpallet::storage]
|
||||
/// #[pezpallet::getter(fn foo)]
|
||||
/// #[pezpallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pezpallet::unbounded]
|
||||
/// pub type Foo<T> = StorageNMap<
|
||||
/// _,
|
||||
/// (
|
||||
@@ -70,7 +70,7 @@ use pezsp_runtime::SaturatedConversion;
|
||||
/// >;
|
||||
///
|
||||
/// /// Named alternative syntax.
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Bar<T> = StorageNMap<
|
||||
/// Key = (
|
||||
/// NMapKey<Blake2_128Concat, u8>,
|
||||
|
||||
@@ -34,28 +34,28 @@ use pezsp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
|
||||
/// A type representing a *value* in storage. A *storage value* is a single value of a given type
|
||||
/// stored on-chain.
|
||||
///
|
||||
/// For general information regarding the `#[pallet::storage]` attribute, refer to
|
||||
/// For general information regarding the `#[pezpallet::storage]` attribute, refer to
|
||||
/// [`crate::pezpallet_macros::storage`].
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// #[pezframe_support::pallet]
|
||||
/// mod pallet {
|
||||
/// #[pezframe_support::pezpallet]
|
||||
/// mod pezpallet {
|
||||
/// # use pezframe_support::pezpallet_prelude::*;
|
||||
/// # #[pallet::config]
|
||||
/// # #[pezpallet::config]
|
||||
/// # pub trait Config: pezframe_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// # #[pezpallet::pezpallet]
|
||||
/// # pub struct Pezpallet<T>(_);
|
||||
/// /// A kitchen-sink StorageValue, with all possible additional attributes.
|
||||
/// #[pallet::storage]
|
||||
/// #[pallet::getter(fn foo)]
|
||||
/// #[pallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pallet::unbounded]
|
||||
/// #[pezpallet::storage]
|
||||
/// #[pezpallet::getter(fn foo)]
|
||||
/// #[pezpallet::storage_prefix = "OtherFoo"]
|
||||
/// #[pezpallet::unbounded]
|
||||
/// pub type Foo<T> = StorageValue<_, u32,ValueQuery>;
|
||||
///
|
||||
/// /// Named alternative syntax.
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Bar<T> = StorageValue<
|
||||
/// Value = u32,
|
||||
/// QueryKind = ValueQuery
|
||||
|
||||
@@ -24,11 +24,11 @@ use pezsp_metadata_ir::{
|
||||
};
|
||||
use pezsp_runtime::{generic, traits::BlakeTwo256, BuildStorage};
|
||||
|
||||
pub use self::pezframe_system::{pezpallet_prelude::*, Config, Pallet};
|
||||
pub use self::pezframe_system::{pezpallet_prelude::*, Config, Pezpallet};
|
||||
|
||||
mod storage_alias;
|
||||
|
||||
#[pallet]
|
||||
#[pezpallet]
|
||||
pub mod pezframe_system {
|
||||
#[allow(unused)]
|
||||
use super::{pezframe_system, pezframe_system::pezpallet_prelude::*};
|
||||
@@ -55,34 +55,34 @@ pub mod pezframe_system {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config(with_default, pezframe_system_config)]
|
||||
#[pallet::disable_pezframe_system_supertrait_check]
|
||||
#[pezpallet::config(with_default, pezframe_system_config)]
|
||||
#[pezpallet::disable_pezframe_system_supertrait_check]
|
||||
pub trait Config: 'static {
|
||||
#[pallet::no_default]
|
||||
#[pezpallet::no_default]
|
||||
type Block: Parameter + pezsp_runtime::traits::Block;
|
||||
type AccountId;
|
||||
#[pallet::no_default_bounds]
|
||||
#[pezpallet::no_default_bounds]
|
||||
type BaseCallFilter: crate::traits::Contains<Self::RuntimeCall>;
|
||||
#[pallet::no_default_bounds]
|
||||
#[pezpallet::no_default_bounds]
|
||||
type RuntimeOrigin;
|
||||
#[pallet::no_default_bounds]
|
||||
#[pezpallet::no_default_bounds]
|
||||
type RuntimeCall;
|
||||
#[pallet::no_default_bounds]
|
||||
#[pezpallet::no_default_bounds]
|
||||
type RuntimeTask: crate::traits::tasks::Task;
|
||||
#[pallet::no_default_bounds]
|
||||
#[pezpallet::no_default_bounds]
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
type DbWeight: Get<crate::weights::RuntimeDbWeight>;
|
||||
#[pallet::constant]
|
||||
#[pallet::no_default]
|
||||
#[pezpallet::constant]
|
||||
#[pezpallet::no_default]
|
||||
#[deprecated = "this constant is deprecated"]
|
||||
#[allow(deprecated)]
|
||||
type ExampleConstant: Get<()>;
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Required by construct_runtime
|
||||
CallFiltered,
|
||||
@@ -94,13 +94,13 @@ pub mod pezframe_system {
|
||||
FailedTask,
|
||||
}
|
||||
|
||||
#[pallet::origin]
|
||||
#[pezpallet::origin]
|
||||
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(task.weight())]
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(task.weight())]
|
||||
pub fn do_task(_origin: OriginFor<T>, task: T::RuntimeTask) -> DispatchResultWithPostInfo {
|
||||
if !task.is_valid() {
|
||||
return Err(Error::<T>::InvalidTask.into());
|
||||
@@ -114,35 +114,35 @@ pub mod pezframe_system {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
#[deprecated]
|
||||
#[allow(deprecated)]
|
||||
pub type Data<T> = StorageMap<_, Twox64Concat, u32, u64, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
#[deprecated(note = "test")]
|
||||
#[allow(deprecated)]
|
||||
pub type OptionLinkedMap<T> = StorageMap<_, Blake2_128Concat, u32, u32, OptionQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn generic_data)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn generic_data)]
|
||||
#[deprecated(note = "test", since = "test")]
|
||||
#[allow(deprecated)]
|
||||
pub type GenericData<T: Config> =
|
||||
StorageMap<_, Identity, BlockNumberFor<T>, BlockNumberFor<T>, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn generic_data2)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn generic_data2)]
|
||||
#[deprecated = "test"]
|
||||
#[allow(deprecated)]
|
||||
pub type GenericData2<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, BlockNumberFor<T>, BlockNumberFor<T>, OptionQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type DataDM<T> =
|
||||
StorageDoubleMap<_, Twox64Concat, u32, Blake2_128Concat, u32, u64, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type GenericDataDM<T: Config> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -153,7 +153,7 @@ pub mod pezframe_system {
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type GenericData2DM<T: Config> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -164,8 +164,8 @@ pub mod pezframe_system {
|
||||
OptionQuery,
|
||||
>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::unbounded]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::unbounded]
|
||||
pub type AppendableDM<T: Config> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -176,7 +176,7 @@ pub mod pezframe_system {
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub data: Vec<(u32, u64)>,
|
||||
pub test_config: Vec<(u32, u32, u64)>,
|
||||
@@ -194,7 +194,7 @@ pub mod pezframe_system {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
#[allow(deprecated)]
|
||||
fn build(&self) {
|
||||
@@ -208,11 +208,11 @@ pub mod pezframe_system {
|
||||
}
|
||||
|
||||
/// Some running total.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Total<T: Config> = StorageValue<_, (u32, u32), ValueQuery>;
|
||||
|
||||
/// Numbers to be added into the total.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Numbers<T: Config> = StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
|
||||
|
||||
pub mod pezpallet_prelude {
|
||||
@@ -731,14 +731,14 @@ fn expected_metadata() -> PalletStorageMetadataIR {
|
||||
|
||||
#[test]
|
||||
fn store_metadata() {
|
||||
let metadata = Pallet::<Runtime>::storage_metadata();
|
||||
let metadata = Pezpallet::<Runtime>::storage_metadata();
|
||||
pretty_assertions::assert_eq!(expected_metadata(), metadata);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn constant_metadata() {
|
||||
let metadata: Vec<pezsp_metadata_ir::PalletConstantMetadataIR> =
|
||||
Pallet::<Runtime>::pezpallet_constants_metadata();
|
||||
Pezpallet::<Runtime>::pezpallet_constants_metadata();
|
||||
pretty_assertions::assert_eq!(
|
||||
metadata,
|
||||
vec![pezsp_metadata_ir::PalletConstantMetadataIR {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
use pezsp_core::Get;
|
||||
|
||||
use super::{new_test_ext, BlockNumberFor, Config, Pallet, Runtime};
|
||||
use super::{new_test_ext, BlockNumberFor, Config, Pezpallet, Runtime};
|
||||
use crate::{
|
||||
assert_noop, assert_ok, parameter_types, storage::generator::StorageValue, Blake2_128Concat,
|
||||
};
|
||||
@@ -29,9 +29,9 @@ fn storage_alias_works() {
|
||||
type GenericData2<T> =
|
||||
StorageMap<System, Blake2_128Concat, BlockNumberFor<T>, BlockNumberFor<T>>;
|
||||
|
||||
assert_eq!(Pallet::<Runtime>::generic_data2(5), None);
|
||||
assert_eq!(Pezpallet::<Runtime>::generic_data2(5), None);
|
||||
GenericData2::<Runtime>::insert(5, 5);
|
||||
assert_eq!(Pallet::<Runtime>::generic_data2(5), Some(5));
|
||||
assert_eq!(Pezpallet::<Runtime>::generic_data2(5), Some(5));
|
||||
|
||||
/// Some random docs that ensure that docs are accepted
|
||||
#[crate::storage_alias]
|
||||
@@ -40,7 +40,7 @@ fn storage_alias_works() {
|
||||
|
||||
#[crate::storage_alias]
|
||||
pub type GenericDataPallet<T: Config> =
|
||||
StorageMap<Pallet<T>, Blake2_128Concat, BlockNumberFor<T>, BlockNumberFor<T>>;
|
||||
StorageMap<Pezpallet<T>, Blake2_128Concat, BlockNumberFor<T>, BlockNumberFor<T>>;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,15 +120,15 @@ fn verbatim_attribute() {
|
||||
#[test]
|
||||
fn pezpallet_name_attribute() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Declare the alias that will use the pallet name as prefix.
|
||||
// Declare the alias that will use the pezpallet name as prefix.
|
||||
#[crate::storage_alias(pezpallet_name)]
|
||||
pub type Value<T: Config> = StorageValue<Pallet<T>, u32>;
|
||||
pub type Value<T: Config> = StorageValue<Pezpallet<T>, u32>;
|
||||
|
||||
// Check that it works as expected.
|
||||
Value::<Runtime>::put(1);
|
||||
assert_eq!(1, Value::<Runtime>::get().unwrap());
|
||||
|
||||
// The prefix is the pallet name. In this case the pallet name is `System` as declared in
|
||||
// The prefix is the pezpallet name. In this case the pezpallet name is `System` as declared in
|
||||
// `construct_runtime!`.
|
||||
assert_eq!(&b"System"[..], Value::<Runtime>::pezpallet_prefix());
|
||||
});
|
||||
@@ -168,9 +168,9 @@ fn storage_alias_guess() {
|
||||
|
||||
assert_eq!(&b"Test"[..], Value::pezpallet_prefix());
|
||||
|
||||
// The macro will use the pallet name as prefix.
|
||||
// The macro will use the pezpallet name as prefix.
|
||||
#[crate::storage_alias]
|
||||
pub type PalletValue<T: Config> = StorageValue<Pallet<T>, u32>;
|
||||
pub type PalletValue<T: Config> = StorageValue<Pezpallet<T>, u32>;
|
||||
|
||||
assert_eq!(&b"System"[..], PalletValue::<Runtime>::pezpallet_prefix());
|
||||
});
|
||||
|
||||
@@ -441,7 +441,7 @@ impl<
|
||||
|
||||
/// Type that can be dispatched with an origin but without checking the origin filter.
|
||||
///
|
||||
/// Implemented for pallet dispatchable type by `decl_module` and for runtime dispatchable by
|
||||
/// Implemented for pezpallet dispatchable type by `decl_module` and for runtime dispatchable by
|
||||
/// `construct_runtime`.
|
||||
pub trait UnfilteredDispatchable {
|
||||
/// The origin type of the runtime, (i.e. `pezframe_system::Config::RuntimeOrigin`).
|
||||
@@ -569,10 +569,10 @@ pub trait OriginTrait: Sized {
|
||||
|
||||
/// A trait to allow calls to authorize themselves from the origin `None`.
|
||||
///
|
||||
/// It is implemented by the [`crate::pallet`] macro and used by the
|
||||
/// It is implemented by the [`crate::pezpallet`] macro and used by the
|
||||
/// `pezframe_system::AuthorizeCall` transaction extension.
|
||||
///
|
||||
/// Pallet writers can declare the authorization logic for a call using the call attribute:
|
||||
/// Pezpallet writers can declare the authorization logic for a call using the call attribute:
|
||||
/// [`crate::pezpallet_macros::authorize`].
|
||||
pub trait Authorize {
|
||||
/// The authorize function.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//! Types and traits for dynamic parameters.
|
||||
//!
|
||||
//! Can be used by 3rd party macros to define dynamic parameters that are compatible with the the
|
||||
//! `parameters` pallet.
|
||||
//! `parameters` pezpallet.
|
||||
|
||||
use codec::MaxEncodedLen;
|
||||
use pezframe_support::Parameter;
|
||||
@@ -83,7 +83,7 @@ impl AggregatedKeyValue for () {
|
||||
|
||||
/// Allows to create a `ParameterStore` from a `RuntimeParameterStore`.
|
||||
///
|
||||
/// This concretization is useful when configuring pallets, since a pallet will require a parameter
|
||||
/// This concretization is useful when configuring pallets, since a pezpallet will require a parameter
|
||||
/// store for its own KV type and not the aggregated runtime-wide KV type.
|
||||
pub struct ParameterStoreAdapter<PS, KV>(core::marker::PhantomData<(PS, KV)>);
|
||||
|
||||
|
||||
@@ -15,24 +15,24 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Traits for describing and constraining pallet error types.
|
||||
//! Traits for describing and constraining pezpallet error types.
|
||||
use codec::{Compact, Decode, Encode};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Trait indicating that the implementing type is going to be included as a field in a variant of
|
||||
/// the `#[pallet::error]` enum type.
|
||||
/// the `#[pezpallet::error]` enum type.
|
||||
///
|
||||
/// ## Notes
|
||||
///
|
||||
/// The pallet error enum has a maximum encoded size as defined by
|
||||
/// [`pezframe_support::MAX_MODULE_ERROR_ENCODED_SIZE`]. If the pallet error type exceeds this size
|
||||
/// The pezpallet error enum has a maximum encoded size as defined by
|
||||
/// [`pezframe_support::MAX_MODULE_ERROR_ENCODED_SIZE`]. If the pezpallet error type exceeds this size
|
||||
/// limit, a static assertion during compilation will fail. The compilation error will be in the
|
||||
/// format of `error[E0080]: evaluation of constant value failed` due to the usage of
|
||||
/// const assertions.
|
||||
pub trait PalletError: Encode + Decode {
|
||||
/// The maximum encoded size for the implementing type.
|
||||
///
|
||||
/// This will be used to check whether the pallet error type is less than or equal to
|
||||
/// This will be used to check whether the pezpallet error type is less than or equal to
|
||||
/// [`pezframe_support::MAX_MODULE_ERROR_ENCODED_SIZE`], and if it is, a compilation error will be
|
||||
/// thrown.
|
||||
const MAX_ENCODED_SIZE: usize;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Traits relating to pallet hooks.
|
||||
//! Traits relating to pezpallet hooks.
|
||||
//!
|
||||
//! See [`Hooks`] as the main entry-point.
|
||||
|
||||
@@ -146,7 +146,7 @@ impl_for_tuples_attr! {
|
||||
impl_for_tuples_attr! {
|
||||
/// A trait that will be called at genesis.
|
||||
///
|
||||
/// Implementing this trait for a pallet let's you express operations that should
|
||||
/// Implementing this trait for a pezpallet let's you express operations that should
|
||||
/// happen at genesis. It will be called in an externalities provided environment and
|
||||
/// will set the genesis state after all pallets have written their genesis state.
|
||||
pub trait OnGenesis {
|
||||
@@ -332,7 +332,7 @@ impl_for_tuples_attr! {
|
||||
}
|
||||
|
||||
#[cfg_attr(doc, aquamarine::aquamarine)]
|
||||
/// The pallet hooks trait. This is merely an umbrella trait for:
|
||||
/// The pezpallet hooks trait. This is merely an umbrella trait for:
|
||||
///
|
||||
/// - [`OnInitialize`]
|
||||
/// - [`OnFinalize`]
|
||||
@@ -349,7 +349,7 @@ impl_for_tuples_attr! {
|
||||
///
|
||||
/// ## Summary
|
||||
///
|
||||
/// In short, the following diagram shows the flow of hooks in a pallet
|
||||
/// In short, the following diagram shows the flow of hooks in a pezpallet
|
||||
///
|
||||
/// ```mermaid
|
||||
/// graph LR
|
||||
@@ -397,7 +397,7 @@ impl_for_tuples_attr! {
|
||||
/// > because they are not part of the consensus/main block building logic. See
|
||||
/// > [`OffchainWorker`](crate::traits::misc::OffchainWorker) for more information.
|
||||
///
|
||||
/// To learn more about the execution of hooks see the FRAME `Executive` pallet which is in charge
|
||||
/// To learn more about the execution of hooks see the FRAME `Executive` pezpallet which is in charge
|
||||
/// of dispatching extrinsics and calling hooks in the correct order.
|
||||
pub trait Hooks<BlockNumber> {
|
||||
/// Block initialization hook. This is called at the very beginning of block execution.
|
||||
@@ -438,11 +438,11 @@ pub trait Hooks<BlockNumber> {
|
||||
/// [`Hooks::on_finalize`], which comes next, is also already accounted for via
|
||||
/// `on_initialize`), this hook consumes anything that is leftover.
|
||||
///
|
||||
/// Each pallet's `on_idle` is chosen to be the first to execute in a round-robin fashion
|
||||
/// Each pezpallet's `on_idle` is chosen to be the first to execute in a round-robin fashion
|
||||
/// indexed by the block number.
|
||||
///
|
||||
/// Return the weight used, the caller will use this to calculate the remaining weight and then
|
||||
/// call the next pallet `on_idle` hook if there is still weight left.
|
||||
/// call the next pezpallet `on_idle` hook if there is still weight left.
|
||||
///
|
||||
/// Any implementation should always respect `_remaining_weight` and never consume (and
|
||||
/// therefore return) more than this amount.
|
||||
@@ -459,10 +459,10 @@ pub trait Hooks<BlockNumber> {
|
||||
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter) {}
|
||||
|
||||
/// Hook executed when a code change (aka. a "runtime upgrade") is detected by the FRAME
|
||||
/// `Executive` pallet.
|
||||
/// `Executive` pezpallet.
|
||||
///
|
||||
/// Be aware that this is called before [`Hooks::on_initialize`] of any pallet; therefore, a lot
|
||||
/// of the critical storage items such as `block_number` in system pallet might have not been
|
||||
/// Be aware that this is called before [`Hooks::on_initialize`] of any pezpallet; therefore, a lot
|
||||
/// of the critical storage items such as `block_number` in system pezpallet might have not been
|
||||
/// set yet.
|
||||
///
|
||||
/// Similar to [`Hooks::on_initialize`], any code in this block is mandatory and MUST execute.
|
||||
@@ -477,7 +477,7 @@ pub trait Hooks<BlockNumber> {
|
||||
/// [`UncheckedOnRuntimeUpgrade`], passing it to [`crate::migrations::VersionedMigration`],
|
||||
/// which already implements [`OnRuntimeUpgrade`].
|
||||
///
|
||||
/// ## Implementation Note: Pallet Versioning
|
||||
/// ## Implementation Note: Pezpallet Versioning
|
||||
///
|
||||
/// Implementations of this hook are typically wrapped in
|
||||
/// [`crate::migrations::VersionedMigration`] to ensure the migration is executed exactly
|
||||
@@ -496,7 +496,7 @@ pub trait Hooks<BlockNumber> {
|
||||
Weight::zero()
|
||||
}
|
||||
|
||||
/// Execute the sanity checks of this pallet, per block.
|
||||
/// Execute the sanity checks of this pezpallet, per block.
|
||||
///
|
||||
/// It should focus on certain checks to ensure that the state is sensible. This is never
|
||||
/// executed in a consensus code-path, therefore it can consume as much weight as it needs.
|
||||
@@ -531,7 +531,7 @@ pub trait Hooks<BlockNumber> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Implementing this function on a pallet allows you to perform long-running tasks that are
|
||||
/// Implementing this function on a pezpallet allows you to perform long-running tasks that are
|
||||
/// dispatched as separate threads, and entirely independent of the main blockchain execution.
|
||||
///
|
||||
/// This function can freely read from the state, but any change it makes to the state is
|
||||
@@ -548,14 +548,14 @@ pub trait Hooks<BlockNumber> {
|
||||
/// flags related to offchain-workers to learn more.
|
||||
fn offchain_worker(_n: BlockNumber) {}
|
||||
|
||||
/// Check the integrity of this pallet's configuration.
|
||||
/// Check the integrity of this pezpallet's configuration.
|
||||
///
|
||||
/// Any code located in this hook is placed in an auto-generated test, and generated as a part
|
||||
/// of [`crate::construct_runtime`]'s expansion. Look for a test case with a name along the
|
||||
/// lines of: `__construct_runtime_integrity_test`.
|
||||
///
|
||||
/// This hook is the location where the values/types provided to the `Config` trait
|
||||
/// of the pallet can be tested for correctness. For example, if two `type Foo: Get<u32>` and
|
||||
/// of the pezpallet can be tested for correctness. For example, if two `type Foo: Get<u32>` and
|
||||
/// `type Bar: Get<u32>` where `Foo::get()` must always be greater than `Bar::get()`, such
|
||||
/// checks can be asserted upon here.
|
||||
///
|
||||
@@ -576,14 +576,14 @@ impl BuildGenesisConfig for () {
|
||||
fn build(&self) {}
|
||||
}
|
||||
|
||||
/// A trait to define the build function of a genesis config, T and I are placeholder for pallet
|
||||
/// trait and pallet instance.
|
||||
/// A trait to define the build function of a genesis config, T and I are placeholder for pezpallet
|
||||
/// trait and pezpallet instance.
|
||||
#[deprecated(
|
||||
note = "GenesisBuild is planned to be removed in December 2023. Use BuildGenesisConfig instead of it."
|
||||
)]
|
||||
pub trait GenesisBuild<T, I = ()>: pezsp_runtime::traits::MaybeSerializeDeserialize {
|
||||
/// The build function is called within an externalities allowing storage APIs.
|
||||
/// Thus one can write to storage using regular pallet storages.
|
||||
/// Thus one can write to storage using regular pezpallet storages.
|
||||
fn build(&self);
|
||||
|
||||
/// Build the storage using `build` inside default storage.
|
||||
|
||||
@@ -23,50 +23,50 @@ use core::ops::Add;
|
||||
use impl_trait_for_tuples::impl_for_tuples;
|
||||
use pezsp_runtime::RuntimeDebug;
|
||||
|
||||
/// Provides information about the pallet itself and its setup in the runtime.
|
||||
/// Provides information about the pezpallet itself and its setup in the runtime.
|
||||
///
|
||||
/// An implementor should be able to provide information about each pallet that
|
||||
/// An implementor should be able to provide information about each pezpallet that
|
||||
/// is configured in `construct_runtime!`.
|
||||
pub trait PalletInfo {
|
||||
/// Convert the given pallet `P` into its index as configured in the runtime.
|
||||
/// Convert the given pezpallet `P` into its index as configured in the runtime.
|
||||
fn index<P: 'static>() -> Option<usize>;
|
||||
/// Convert the given pallet `P` into its name as configured in the runtime.
|
||||
/// Convert the given pezpallet `P` into its name as configured in the runtime.
|
||||
fn name<P: 'static>() -> Option<&'static str>;
|
||||
/// The two128 hash of name.
|
||||
fn name_hash<P: 'static>() -> Option<[u8; 16]>;
|
||||
/// Convert the given pallet `P` into its Rust module name as used in `construct_runtime!`.
|
||||
/// Convert the given pezpallet `P` into its Rust module name as used in `construct_runtime!`.
|
||||
fn module_name<P: 'static>() -> Option<&'static str>;
|
||||
/// Convert the given pallet `P` into its containing crate version.
|
||||
/// Convert the given pezpallet `P` into its containing crate version.
|
||||
fn crate_version<P: 'static>() -> Option<CrateVersion>;
|
||||
}
|
||||
|
||||
/// Information regarding an instance of a pallet.
|
||||
/// Information regarding an instance of a pezpallet.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug)]
|
||||
pub struct PalletInfoData {
|
||||
/// Index of the pallet as configured in the runtime.
|
||||
/// Index of the pezpallet as configured in the runtime.
|
||||
pub index: usize,
|
||||
/// Name of the pallet as configured in the runtime.
|
||||
/// Name of the pezpallet as configured in the runtime.
|
||||
pub name: &'static str,
|
||||
/// Name of the Rust module containing the pallet.
|
||||
/// Name of the Rust module containing the pezpallet.
|
||||
pub module_name: &'static str,
|
||||
/// Version of the crate containing the pallet.
|
||||
/// Version of the crate containing the pezpallet.
|
||||
pub crate_version: CrateVersion,
|
||||
}
|
||||
|
||||
/// Provides information about the pallet itself and its setup in the runtime.
|
||||
/// Provides information about the pezpallet itself and its setup in the runtime.
|
||||
///
|
||||
/// Declare some information and access the information provided by [`PalletInfo`] for a specific
|
||||
/// pallet.
|
||||
/// pezpallet.
|
||||
pub trait PalletInfoAccess {
|
||||
/// Index of the pallet as configured in the runtime.
|
||||
/// Index of the pezpallet as configured in the runtime.
|
||||
fn index() -> usize;
|
||||
/// Name of the pallet as configured in the runtime.
|
||||
/// Name of the pezpallet as configured in the runtime.
|
||||
fn name() -> &'static str;
|
||||
/// Two128 hash of name.
|
||||
fn name_hash() -> [u8; 16];
|
||||
/// Name of the Rust module containing the pallet.
|
||||
/// Name of the Rust module containing the pezpallet.
|
||||
fn module_name() -> &'static str;
|
||||
/// Version of the crate containing the pallet.
|
||||
/// Version of the crate containing the pezpallet.
|
||||
fn crate_version() -> CrateVersion;
|
||||
}
|
||||
|
||||
@@ -95,12 +95,12 @@ impl PalletsInfoAccess for Tuple {
|
||||
}
|
||||
}
|
||||
|
||||
/// The function and pallet name of the Call.
|
||||
/// The function and pezpallet name of the Call.
|
||||
#[derive(Clone, Eq, PartialEq, Default, RuntimeDebug)]
|
||||
pub struct CallMetadata {
|
||||
/// Name of the function.
|
||||
pub function_name: &'static str,
|
||||
/// Name of the pallet to which the function belongs.
|
||||
/// Name of the pezpallet to which the function belongs.
|
||||
pub pezpallet_name: &'static str,
|
||||
}
|
||||
|
||||
@@ -120,13 +120,13 @@ pub trait GetCallIndex {
|
||||
fn get_call_index(&self) -> u8;
|
||||
}
|
||||
|
||||
/// Gets the metadata for the Call - function name and pallet name.
|
||||
/// Gets the metadata for the Call - function name and pezpallet name.
|
||||
pub trait GetCallMetadata {
|
||||
/// Return all module names.
|
||||
fn get_module_names() -> &'static [&'static str];
|
||||
/// Return all function names for the given `module`.
|
||||
fn get_call_names(module: &str) -> &'static [&'static str];
|
||||
/// Return a [`CallMetadata`], containing function and pallet name of the Call.
|
||||
/// Return a [`CallMetadata`], containing function and pezpallet name of the Call.
|
||||
fn get_call_metadata(&self) -> CallMetadata;
|
||||
}
|
||||
|
||||
@@ -161,15 +161,15 @@ impl PartialOrd for CrateVersion {
|
||||
}
|
||||
}
|
||||
|
||||
/// The storage key postfix that is used to store the [`StorageVersion`] per pallet.
|
||||
/// The storage key postfix that is used to store the [`StorageVersion`] per pezpallet.
|
||||
///
|
||||
/// The full storage key is built by using:
|
||||
/// Twox128([`PalletInfo::name`]) ++ Twox128([`STORAGE_VERSION_STORAGE_KEY_POSTFIX`])
|
||||
pub const STORAGE_VERSION_STORAGE_KEY_POSTFIX: &[u8] = b":__STORAGE_VERSION__:";
|
||||
|
||||
/// The storage version of a pallet.
|
||||
/// The storage version of a pezpallet.
|
||||
///
|
||||
/// Each storage version of a pallet is stored in the state under a fixed key. See
|
||||
/// Each storage version of a pezpallet is stored in the state under a fixed key. See
|
||||
/// [`STORAGE_VERSION_STORAGE_KEY_POSTFIX`] for how this key is built.
|
||||
#[derive(Debug, Eq, PartialEq, Encode, Decode, Ord, Clone, Copy, PartialOrd, Default)]
|
||||
pub struct StorageVersion(u16);
|
||||
@@ -188,13 +188,13 @@ impl StorageVersion {
|
||||
crate::storage::storage_prefix(pezpallet_name.as_bytes(), STORAGE_VERSION_STORAGE_KEY_POSTFIX)
|
||||
}
|
||||
|
||||
/// Put this storage version for the given pallet into the storage.
|
||||
/// Put this storage version for the given pezpallet into the storage.
|
||||
///
|
||||
/// It will use the storage key that is associated with the given `Pallet`.
|
||||
/// It will use the storage key that is associated with the given `Pezpallet`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This function will panic iff `Pallet` can not be found by `PalletInfo`.
|
||||
/// This function will panic iff `Pezpallet` can not be found by `PalletInfo`.
|
||||
/// In a runtime that is put together using
|
||||
/// [`construct_runtime!`](crate::construct_runtime) this should never happen.
|
||||
///
|
||||
@@ -206,13 +206,13 @@ impl StorageVersion {
|
||||
crate::storage::unhashed::put(&key, self);
|
||||
}
|
||||
|
||||
/// Get the storage version of the given pallet from the storage.
|
||||
/// Get the storage version of the given pezpallet from the storage.
|
||||
///
|
||||
/// It will use the storage key that is associated with the given `Pallet`.
|
||||
/// It will use the storage key that is associated with the given `Pezpallet`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This function will panic iff `Pallet` can not be found by `PalletInfo`.
|
||||
/// This function will panic iff `Pezpallet` can not be found by `PalletInfo`.
|
||||
/// In a runtime that is put together using
|
||||
/// [`construct_runtime!`](crate::construct_runtime) this should never happen.
|
||||
///
|
||||
@@ -224,13 +224,13 @@ impl StorageVersion {
|
||||
crate::storage::unhashed::get_or_default(&key)
|
||||
}
|
||||
|
||||
/// Returns if the storage version key for the given pallet exists in storage.
|
||||
/// Returns if the storage version key for the given pezpallet exists in storage.
|
||||
///
|
||||
/// See [`STORAGE_VERSION_STORAGE_KEY_POSTFIX`] on how this key is built.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This function will panic iff `Pallet` can not be found by `PalletInfo`.
|
||||
/// This function will panic iff `Pezpallet` can not be found by `PalletInfo`.
|
||||
/// In a runtime that is put together using
|
||||
/// [`construct_runtime!`](crate::construct_runtime) this should never happen.
|
||||
///
|
||||
@@ -263,33 +263,33 @@ impl Add<u16> for StorageVersion {
|
||||
}
|
||||
|
||||
/// Special marker struct used when [`storage_version`](crate::pezpallet_macros::storage_version) is
|
||||
/// not defined for a pallet.
|
||||
/// not defined for a pezpallet.
|
||||
///
|
||||
/// If you (the reader) end up here, it probably means that you tried to compare
|
||||
/// [`GetStorageVersion::on_chain_storage_version`] against
|
||||
/// [`GetStorageVersion::in_code_storage_version`]. This basically means that the
|
||||
/// [`storage_version`](crate::pezpallet_macros::storage_version) is missing from the pallet where the
|
||||
/// [`storage_version`](crate::pezpallet_macros::storage_version) is missing from the pezpallet where the
|
||||
/// mentioned functions are being called, and needs to be defined.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct NoStorageVersionSet;
|
||||
|
||||
/// Provides information about a pallet's storage versions.
|
||||
/// Provides information about a pezpallet's storage versions.
|
||||
///
|
||||
/// Every pallet has two storage versions:
|
||||
/// Every pezpallet has two storage versions:
|
||||
/// 1. An in-code storage version
|
||||
/// 2. An on-chain storage version
|
||||
///
|
||||
/// The in-code storage version is the version of the pallet as defined in the runtime blob, and the
|
||||
/// on-chain storage version is the version of the pallet stored on-chain.
|
||||
/// The in-code storage version is the version of the pezpallet as defined in the runtime blob, and the
|
||||
/// on-chain storage version is the version of the pezpallet stored on-chain.
|
||||
///
|
||||
/// Storage versions should be only ever be out of sync when a pallet has been updated to a new
|
||||
/// Storage versions should be only ever be out of sync when a pezpallet has been updated to a new
|
||||
/// version and the in-code version is incremented, but the migration has not yet been executed
|
||||
/// on-chain as part of a runtime upgrade.
|
||||
///
|
||||
/// It is the responsibility of the developer to ensure that the on-chain storage version is set
|
||||
/// correctly during a migration so that it matches the in-code storage version.
|
||||
pub trait GetStorageVersion {
|
||||
/// This type is generated by the [`pallet`](crate::pallet) macro.
|
||||
/// This type is generated by the [`pezpallet`](crate::pezpallet) macro.
|
||||
///
|
||||
/// If the [`storage_version`](crate::pezpallet_macros::storage_version) attribute isn't specified,
|
||||
/// this is set to [`NoStorageVersionSet`] to signify that it is missing.
|
||||
@@ -319,7 +319,7 @@ pub trait GetStorageVersion {
|
||||
/// [`storage_version`](crate::pezpallet_macros::storage_version) attribute, or
|
||||
/// [`NoStorageVersionSet`] if the attribute is missing.
|
||||
fn in_code_storage_version() -> Self::InCodeStorageVersion;
|
||||
/// Returns the storage version of the pallet as last set in the actual on-chain storage.
|
||||
/// Returns the storage version of the pezpallet as last set in the actual on-chain storage.
|
||||
fn on_chain_storage_version() -> StorageVersion;
|
||||
}
|
||||
|
||||
|
||||
@@ -796,7 +796,7 @@ impl<T> IsType<T> for T {
|
||||
/// you need access to these sub types.
|
||||
///
|
||||
/// For example, in FRAME, this trait is implemented for the runtime `Call` enum. Pallets use this
|
||||
/// to check if a certain call is an instance of the local pallet's `Call` enum.
|
||||
/// to check if a certain call is an instance of the local pezpallet's `Call` enum.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
@@ -1001,7 +1001,7 @@ where
|
||||
|
||||
/// Something that can estimate the fee of a (frame-based) call.
|
||||
///
|
||||
/// Typically, the same pallet that will charge transaction fees will implement this.
|
||||
/// Typically, the same pezpallet that will charge transaction fees will implement this.
|
||||
pub trait EstimateCallFee<Call, Balance> {
|
||||
/// Estimate the fee of this call.
|
||||
///
|
||||
|
||||
@@ -320,7 +320,7 @@ pub trait StatementOracle<RuntimeCall> {
|
||||
|
||||
/// Judge a `statement` and get a Judgement.
|
||||
///
|
||||
/// We only care about the pallet/call index of `callback`; it must take exactly three
|
||||
/// We only care about the pezpallet/call index of `callback`; it must take exactly three
|
||||
/// arguments:
|
||||
///
|
||||
/// - `Self::Ticket`: The ticket which was returned here to identify the judgement.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Traits for encoding data related to pallet's storage items.
|
||||
//! Traits for encoding data related to pezpallet's storage items.
|
||||
|
||||
use alloc::{collections::btree_set::BTreeSet, vec, vec::Vec};
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, FullCodec, MaxEncodedLen};
|
||||
@@ -30,9 +30,9 @@ use pezsp_runtime::{
|
||||
DispatchError, RuntimeDebug,
|
||||
};
|
||||
|
||||
/// An instance of a pallet in the storage.
|
||||
/// An instance of a pezpallet in the storage.
|
||||
///
|
||||
/// It is required that these instances are unique, to support multiple instances per pallet in the
|
||||
/// It is required that these instances are unique, to support multiple instances per pezpallet in the
|
||||
/// same runtime!
|
||||
///
|
||||
/// E.g. for module MyModule default instance will have prefix "MyModule" and other instances
|
||||
@@ -50,19 +50,19 @@ impl Instance for () {
|
||||
const INDEX: u8 = 0;
|
||||
}
|
||||
|
||||
/// An instance of a storage in a pallet.
|
||||
/// An instance of a storage in a pezpallet.
|
||||
///
|
||||
/// Define an instance for an individual storage inside a pallet.
|
||||
/// The pallet prefix is used to isolate the storage between pallets, and the storage prefix is
|
||||
/// used to isolate storages inside a pallet.
|
||||
/// Define an instance for an individual storage inside a pezpallet.
|
||||
/// The pezpallet prefix is used to isolate the storage between pallets, and the storage prefix is
|
||||
/// used to isolate storages inside a pezpallet.
|
||||
///
|
||||
/// NOTE: These information can be used to define storages in pallet such as a `StorageMap` which
|
||||
/// NOTE: These information can be used to define storages in pezpallet such as a `StorageMap` which
|
||||
/// can use keys after `twox_128(pezpallet_prefix())++twox_128(STORAGE_PREFIX)`
|
||||
pub trait StorageInstance {
|
||||
/// Prefix of a pallet to isolate it from other pallets.
|
||||
/// Prefix of a pezpallet to isolate it from other pallets.
|
||||
fn pezpallet_prefix() -> &'static str;
|
||||
|
||||
/// Return the prefix hash of pallet instance.
|
||||
/// Return the prefix hash of pezpallet instance.
|
||||
///
|
||||
/// NOTE: This hash must be `twox_128(pezpallet_prefix())`.
|
||||
/// Should not impl this function by hand. Only use the default or macro generated impls.
|
||||
@@ -70,7 +70,7 @@ pub trait StorageInstance {
|
||||
pezsp_io::hashing::twox_128(Self::pezpallet_prefix().as_bytes())
|
||||
}
|
||||
|
||||
/// Prefix given to a storage to isolate from other storages in the pallet.
|
||||
/// Prefix given to a storage to isolate from other storages in the pezpallet.
|
||||
const STORAGE_PREFIX: &'static str;
|
||||
|
||||
/// Return the prefix hash of storage instance.
|
||||
@@ -96,7 +96,7 @@ pub trait StorageInstance {
|
||||
/// Metadata about storage from the runtime.
|
||||
#[derive(Debug, codec::Encode, codec::Decode, Eq, PartialEq, Clone, scale_info::TypeInfo)]
|
||||
pub struct StorageInfo {
|
||||
/// Encoded string of pallet name.
|
||||
/// Encoded string of pezpallet name.
|
||||
pub pezpallet_name: Vec<u8>,
|
||||
/// Encoded string of storage name.
|
||||
pub storage_name: Vec<u8>,
|
||||
@@ -134,7 +134,7 @@ pub trait PartialStorageInfoTrait {
|
||||
fn partial_storage_info() -> Vec<StorageInfo>;
|
||||
}
|
||||
|
||||
/// Allows a pallet to specify storage keys to whitelist during benchmarking.
|
||||
/// Allows a pezpallet to specify storage keys to whitelist during benchmarking.
|
||||
/// This means those keys will be excluded from the benchmarking performance
|
||||
/// calculation.
|
||||
pub trait WhitelistedStorageKeys {
|
||||
|
||||
@@ -44,7 +44,7 @@ pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq {
|
||||
/// An [`Iterator`] over tasks of this type used as the return type for `enumerate`.
|
||||
type Enumeration: Iterator;
|
||||
|
||||
/// Inspects the pallet's state and enumerates tasks of this type.
|
||||
/// Inspects the pezpallet's state and enumerates tasks of this type.
|
||||
fn iter() -> Self::Enumeration;
|
||||
|
||||
/// Checks if a particular instance of this `Task` variant is a valid piece of work.
|
||||
@@ -60,10 +60,10 @@ pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq {
|
||||
/// Returns the weight of executing this `Task`.
|
||||
fn weight(&self) -> Weight;
|
||||
|
||||
/// A unique value representing this `Task` within the current pallet. Analogous to
|
||||
/// A unique value representing this `Task` within the current pezpallet. Analogous to
|
||||
/// `call_index`, but for tasks.'
|
||||
///
|
||||
/// This value should be unique within the current pallet and can overlap with task indices
|
||||
/// This value should be unique within the current pezpallet and can overlap with task indices
|
||||
/// in other pallets.
|
||||
fn task_index(&self) -> u32;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
//!
|
||||
//! ### Usage Example
|
||||
//!
|
||||
//! This example shows how to interact with pezpallet-uniques (assuming the pallet called Uniques in
|
||||
//! This example shows how to interact with pezpallet-uniques (assuming the pezpallet called Uniques in
|
||||
//! the chain’s Runtime) via the asset ops.
|
||||
//!
|
||||
//! If you are interested in the implementation example, you can look at the pezpallet-uniques
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
//! Adapter to use `fungibles::*` implementations as `fungible::*`.
|
||||
//!
|
||||
//! This allows for a `fungibles` asset, e.g. from the `pezpallet_assets` pallet, to be used when a
|
||||
//! This allows for a `fungibles` asset, e.g. from the `pezpallet_assets` pezpallet, to be used when a
|
||||
//! `fungible` asset is expected.
|
||||
//!
|
||||
//! See the [`crate::traits::fungible`] doc for more information about fungible traits.
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
//! transfer.
|
||||
//!
|
||||
//! - **Held Balance**: Held balance still belongs to the account holder, but is suspended — it
|
||||
//! cannot be transferred or used for most operations. It may be slashed by the pallet that placed
|
||||
//! cannot be transferred or used for most operations. It may be slashed by the pezpallet that placed
|
||||
//! the hold.
|
||||
//!
|
||||
//! Multiple holds stack rather than overlay. This means that if an account has
|
||||
@@ -130,7 +130,7 @@
|
||||
//! slashed.
|
||||
//!
|
||||
//! Every Hold and Freeze is accompanied by a unique `Reason`, making it clear for each instance
|
||||
//! what the originating pallet and purpose is. These reasons are amalgomated into a single enum
|
||||
//! what the originating pezpallet and purpose is. These reasons are amalgomated into a single enum
|
||||
//! `RuntimeHoldReason` and `RuntimeFreezeReason` respectively, when the runtime is compiled.
|
||||
//!
|
||||
//! Note that `Hold` and `Freeze` reasons should remain in your runtime for as long as storage
|
||||
|
||||
@@ -38,11 +38,11 @@ pub enum Select {
|
||||
RoundRobin(u32),
|
||||
/// Run only pallets who's name matches the given list.
|
||||
///
|
||||
/// Pallet names are obtained from [`super::PalletInfoAccess`].
|
||||
/// Pezpallet names are obtained from [`super::PalletInfoAccess`].
|
||||
Only(Vec<Vec<u8>>),
|
||||
/// Run all pallets except those whose names match the given list.
|
||||
///
|
||||
/// Pallet names are obtained from [`super::PalletInfoAccess`].
|
||||
/// Pezpallet names are obtained from [`super::PalletInfoAccess`].
|
||||
AllExcept(Vec<Vec<u8>>),
|
||||
}
|
||||
|
||||
@@ -158,10 +158,10 @@ impl core::str::FromStr for UpgradeCheckSelect {
|
||||
}
|
||||
}
|
||||
|
||||
/// Execute some checks to ensure the internal state of a pallet is consistent.
|
||||
/// Execute some checks to ensure the internal state of a pezpallet is consistent.
|
||||
///
|
||||
/// Usually, these checks should check all of the invariants that are expected to be held on all of
|
||||
/// the storage items of your pallet.
|
||||
/// the storage items of your pezpallet.
|
||||
///
|
||||
/// This hook should not alter any storage.
|
||||
pub trait TryState<BlockNumber> {
|
||||
@@ -237,7 +237,7 @@ impl<BlockNumber: Clone + core::fmt::Debug + AtLeast32BitUnsigned> TryState<Bloc
|
||||
result = result.and(try_state_fn(n.clone(), targets.clone()));
|
||||
} else {
|
||||
log::warn!(
|
||||
"Pallet {:?} not found",
|
||||
"Pezpallet {:?} not found",
|
||||
alloc::str::from_utf8(pezpallet_name).unwrap_or_default()
|
||||
);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ impl<BlockNumber: Clone + core::fmt::Debug + AtLeast32BitUnsigned> TryState<Bloc
|
||||
excluded_pallet_names.iter().for_each(|excluded_name| {
|
||||
if !try_state_fns.iter().any(|(name, _)| name.as_bytes() == excluded_name) {
|
||||
log::warn!(
|
||||
"Pallet {:?} not found while trying to filter it out in Select::AllExcept",
|
||||
"Pezpallet {:?} not found while trying to filter it out in Select::AllExcept",
|
||||
alloc::str::from_utf8(excluded_name).unwrap_or_default()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ pub trait VoteTally<Votes, Class> {
|
||||
/// A function that should be called before any use of the `runtime-benchmarks` gated functions
|
||||
/// of the `VoteTally` trait.
|
||||
///
|
||||
/// Should be used to set up any needed state in a Pallet which implements `VoteTally` so that
|
||||
/// Should be used to set up any needed state in a Pezpallet which implements `VoteTally` so that
|
||||
/// benchmarks that execute will complete successfully. `class` can be used to set up a
|
||||
/// particular class of voters, and `granularity` is used to determine the weight of one vote
|
||||
/// relative to total unanimity.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License fsor the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Traits for querying pallet view functions.
|
||||
//! Traits for querying pezpallet view functions.
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, DecodeAll, Encode, Output};
|
||||
@@ -28,7 +28,7 @@ pub struct ViewFunctionId {
|
||||
/// The part of the id for dispatching view functions from the top level of the runtime.
|
||||
///
|
||||
/// Specifies which view function grouping this view function belongs to. This could be a group
|
||||
/// of view functions associated with a pallet, or a pallet agnostic group of view functions.
|
||||
/// of view functions associated with a pezpallet, or a pezpallet agnostic group of view functions.
|
||||
pub prefix: [u8; 16],
|
||||
/// The part of the id for dispatching to a view function within a group.
|
||||
pub suffix: [u8; 16],
|
||||
@@ -61,14 +61,14 @@ impl From<codec::Error> for ViewFunctionDispatchError {
|
||||
}
|
||||
|
||||
/// Implemented by both pallets and the runtime. The runtime is dispatching by prefix using the
|
||||
/// pallet implementation of `ViewFunctionIdPrefix` then the pallet is dispatching by suffix using
|
||||
/// pezpallet implementation of `ViewFunctionIdPrefix` then the pezpallet is dispatching by suffix using
|
||||
/// the methods implementation of `ViewFunctionIdSuffix`.
|
||||
///
|
||||
/// In more details, `ViewFunctionId` = `ViewFunctionIdPrefix` ++ `ViewFunctionIdSuffix`, where
|
||||
/// `ViewFunctionIdPrefix=twox_128(pezpallet_name)` and
|
||||
/// `ViewFunctionIdSuffix=twox_128("fn_name(fnarg_types) -> return_ty")`. The prefix is the same as
|
||||
/// the storage prefix for pallets. The suffix is generated from the view function method type
|
||||
/// signature, so is guaranteed to be unique for that pallet implementation.
|
||||
/// signature, so is guaranteed to be unique for that pezpallet implementation.
|
||||
pub trait DispatchViewFunction {
|
||||
fn dispatch_view_function<O: Output>(
|
||||
id: &ViewFunctionId,
|
||||
@@ -87,19 +87,19 @@ impl DispatchViewFunction for () {
|
||||
}
|
||||
}
|
||||
|
||||
/// Automatically implemented for each pallet by the macro [`pallet`](crate::pallet).
|
||||
/// Automatically implemented for each pezpallet by the macro [`pezpallet`](crate::pezpallet).
|
||||
pub trait ViewFunctionIdPrefix {
|
||||
fn prefix() -> [u8; 16];
|
||||
}
|
||||
|
||||
/// Automatically implemented for each pallet view function method by the macro
|
||||
/// [`pallet`](crate::pallet).
|
||||
/// Automatically implemented for each pezpallet view function method by the macro
|
||||
/// [`pezpallet`](crate::pezpallet).
|
||||
pub trait ViewFunctionIdSuffix {
|
||||
const SUFFIX: [u8; 16];
|
||||
}
|
||||
|
||||
/// Automatically implemented for each pallet view function method by the macro
|
||||
/// [`pallet`](crate::pallet).
|
||||
/// Automatically implemented for each pezpallet view function method by the macro
|
||||
/// [`pezpallet`](crate::pezpallet).
|
||||
pub trait ViewFunction: DecodeAll {
|
||||
fn id() -> ViewFunctionId;
|
||||
type ReturnType: Encode;
|
||||
|
||||
Reference in New Issue
Block a user