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:
2025-12-16 09:57:23 +03:00
parent eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME derivatives pallet"
description = "FRAME derivatives pezpallet"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-derivatives"
+7 -7
View File
@@ -15,10 +15,10 @@ The motivation differs depending on the scenario in question.
### The first scenario
The `pezpallet-derivatives` can be helpful when another pallet, which hosts the derivative assets,
The `pezpallet-derivatives` can be helpful when another pezpallet, which hosts the derivative assets,
doesn't provide a good enough way to create new assets in the context of them being derivatives.
For instance, the asset hosting pallet might have an asset class (NFT collection or fungible currency) creation extrinsic,
For instance, the asset hosting pezpallet might have an asset class (NFT collection or fungible currency) creation extrinsic,
but among its parameters, there could be things like some admin account, currency decimals, various permissions, etc.
When creating a regular (i.e., non-derivative) asset class via such an extrinsic,
@@ -31,7 +31,7 @@ or we could provide an alternative API where the sensitive parameters are omitte
The first approach dominates in the ecosystem at the moment since:
1. It is simple
2. There was no pallet to make such an alternative API without rewriting individual
2. There was no pezpallet to make such an alternative API without rewriting individual
asset-hosting pallets
3. Only fungible derivatives were ever made (with rare exceptions like an NFT derivative
collection on Karura).
@@ -54,7 +54,7 @@ So, providing an API for unprivileged derivative registration is a preferable ch
Moreover, the future data communication via XCM can benefit both fungible and non-fungible
derivative collections registration.
1. The `create_derivative` extrinsic of this pallet can be configured to initiate the
1. The `create_derivative` extrinsic of this pezpallet can be configured to initiate the
registration process
by sending the `ReportMetadata` instruction to the reserve chain. It can be configured such that
this can be done by anyone.
@@ -72,13 +72,13 @@ This situation can arise in the following cases:
`CollectionId` (the derivative ID type) to XCM `AssetId` (the original ID type)
because `pezpallet-nfts` requires `CollectionId` to be incrementable.
* It is desired to have a continuous ID space for all objects, both derivative and local.
For instance, one might want to reuse the existing pallet combinations (like `pezpallet-nfts`
instance + `pezpallet-nfts-fractionalization` instance) without adding new pallet instances between
For instance, one might want to reuse the existing pezpallet combinations (like `pezpallet-nfts`
instance + `pezpallet-nfts-fractionalization` instance) without adding new pezpallet instances between
the one hosting NFTs and many special logic pallets. In this case, the original ID type would be
`(AssetId, AssetInstance)`, and the derivative ID type can be anything.
## Usage examples
The `src/mock/mod.rs` contains a mock runtime declaration that contains several instances of the pallet
The `src/mock/mod.rs` contains a mock runtime declaration that contains several instances of the pezpallet
to test the scenarios mentioned above.
This test configuration can be viewed as a usage example alongside the tests in the `src/tests.rs`.
@@ -15,10 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use super::{Pallet as Derivatives, *};
use super::{Pezpallet as Derivatives, *};
use pezframe_benchmarking::v2::*;
pub struct Pallet<T: Config<I>, I: 'static = ()>(Derivatives<T, I>);
pub struct Pezpallet<T: Config<I>, I: 'static = ()>(Derivatives<T, I>);
pub trait Config<I: 'static = ()>: super::Config<I> {
fn max_original() -> OriginalOf<Self, I>;
+31 -31
View File
@@ -29,10 +29,10 @@
//!
//! #### The first scenario
//!
//! The `pezpallet-derivatives` can be helpful when another pallet, which hosts the derivative assets,
//! The `pezpallet-derivatives` can be helpful when another pezpallet, which hosts the derivative assets,
//! doesn't provide a good enough way to create new assets in the context of them being derivatives.
//!
//! For instance, the asset hosting pallet might have an asset class (NFT collection or fungible
//! For instance, the asset hosting pezpallet might have an asset class (NFT collection or fungible
//! currency) creation extrinsic, but among its parameters, there could be things like some admin
//! account, currency decimals, various permissions, etc. When creating a regular (i.e.,
//! non-derivative) asset class via such an extrinsic, these parameters allow one to conveniently
@@ -45,7 +45,7 @@
//!
//! The first approach dominates in the ecosystem at the moment since:
//! 1. It is simple
//! 2. There was no pallet to make such an alternative API without rewriting individual
//! 2. There was no pezpallet to make such an alternative API without rewriting individual
//! asset-hosting pallets
//! 3. Only fungible derivatives were ever made (with rare exceptions like an NFT derivative
//! collection on Karura).
@@ -70,7 +70,7 @@
//!
//! Moreover, the future data communication via XCM can benefit both fungible and non-fungible
//! derivative collections registration.
//! 1. The `create_derivative` extrinsic of this pallet can be configured to initiate the
//! 1. The `create_derivative` extrinsic of this pezpallet can be configured to initiate the
//! registration process
//! by sending the `ReportMetadata` instruction to the reserve chain. It can be configured such that
//! this can be done by anyone.
@@ -89,8 +89,8 @@
//! `CollectionId` (the derivative ID type) to XCM `AssetId` (the original ID type)
//! because `pezpallet-nfts` requires `CollectionId` to be incrementable.
//! * It is desired to have a continuous ID space for all objects, both derivative and local.
//! For instance, one might want to reuse the existing pallet combinations (like `pezpallet-nfts`
//! instance + `pezpallet-nfts-fractionalization` instance) without adding new pallet instances between
//! For instance, one might want to reuse the existing pezpallet combinations (like `pezpallet-nfts`
//! instance + `pezpallet-nfts-fractionalization` instance) without adding new pezpallet instances between
//! the one hosting NFTs and many special logic pallets. In this case, the original ID type would be
//! `(AssetId, AssetInstance)`, and the derivative ID type can be anything.
@@ -108,7 +108,7 @@ use pezframe_support::{
use pezframe_system::pezpallet_prelude::*;
use pezsp_runtime::DispatchResult;
pub use pallet::*;
pub use pezpallet::*;
pub mod misc;
@@ -123,7 +123,7 @@ mod mock;
#[cfg(test)]
mod tests;
/// The log target of this pallet.
/// The log target of this pezpallet.
pub const LOG_TARGET: &'static str = "runtime::xcm::derivatives";
/// A helper type representing the intention to store
@@ -134,14 +134,14 @@ type OriginalOf<T, I> = <T as Config<I>>::Original;
type DerivativeOf<T, I> = <T as Config<I>>::Derivative;
type DerivativeExtraOf<T, I> = <T as Config<I>>::DerivativeExtra;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::pallet]
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
#[pezpallet::pezpallet]
pub struct Pezpallet<T, I = ()>(PhantomData<(T, I)>);
#[pallet::config]
#[pezpallet::config]
pub trait Config<I: 'static = ()>: pezframe_system::Config {
type WeightInfo: WeightInfo;
@@ -180,23 +180,23 @@ pub mod pallet {
type DestroyOp: AssetDefinition<Id = Self::Original> + Destroy<NoParams>;
}
#[pallet::storage]
#[pallet::getter(fn original_to_derivative)]
#[pezpallet::storage]
#[pezpallet::getter(fn original_to_derivative)]
pub type OriginalToDerivative<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, OriginalOf<T, I>, DerivativeOf<T, I>, OptionQuery>;
#[pallet::storage]
#[pallet::getter(fn derivative_to_original)]
#[pezpallet::storage]
#[pezpallet::getter(fn derivative_to_original)]
pub type DerivativeToOriginal<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, DerivativeOf<T, I>, OriginalOf<T, I>, OptionQuery>;
#[pallet::storage]
#[pallet::getter(fn derivative_extra)]
#[pezpallet::storage]
#[pezpallet::getter(fn derivative_extra)]
pub type DerivativeExtra<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, DerivativeOf<T, I>, DerivativeExtraOf<T, I>, OptionQuery>;
#[pallet::event]
#[pallet::generate_deposit(pub(crate) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(crate) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> {
/// A derivative is created.
DerivativeCreated { original: OriginalOf<T, I> },
@@ -208,7 +208,7 @@ pub mod pallet {
DerivativeDestroyed { original: OriginalOf<T, I> },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
/// A derivative already exists.
DerivativeAlreadyExists,
@@ -229,9 +229,9 @@ pub mod pallet {
InvalidAsset,
}
#[pallet::call(weight(T::WeightInfo))]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::call_index(0)]
#[pezpallet::call(weight(T::WeightInfo))]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::call_index(0)]
pub fn create_derivative(
origin: OriginFor<T>,
original: OriginalOf<T, I>,
@@ -250,7 +250,7 @@ pub mod pallet {
Ok(())
}
#[pallet::call_index(1)]
#[pezpallet::call_index(1)]
pub fn destroy_derivative(
origin: OriginFor<T>,
original: OriginalOf<T, I>,
@@ -269,7 +269,7 @@ pub mod pallet {
}
impl<T: Config<I>, I: 'static> DerivativesRegistry<OriginalOf<T, I>, DerivativeOf<T, I>>
for Pallet<T, I>
for Pezpallet<T, I>
{
fn try_register_derivative(
original: &OriginalOf<T, I>,
@@ -310,7 +310,7 @@ impl<T: Config<I>, I: 'static> DerivativesRegistry<OriginalOf<T, I>, DerivativeO
}
impl<T: Config<I>, I: 'static> IterDerivativesRegistry<OriginalOf<T, I>, DerivativeOf<T, I>>
for Pallet<T, I>
for Pezpallet<T, I>
{
fn iter_originals() -> impl Iterator<Item = OriginalOf<T, I>> {
<OriginalToDerivative<T, I>>::iter_keys()
@@ -326,7 +326,7 @@ impl<T: Config<I>, I: 'static> IterDerivativesRegistry<OriginalOf<T, I>, Derivat
}
impl<T: Config<I>, I: 'static> DerivativesExtra<DerivativeOf<T, I>, DerivativeExtraOf<T, I>>
for Pallet<T, I>
for Pezpallet<T, I>
{
fn get_derivative_extra(derivative: &DerivativeOf<T, I>) -> Option<DerivativeExtraOf<T, I>> {
<DerivativeExtra<T, I>>::get(derivative)
@@ -409,8 +409,8 @@ where
}
/// Gets the `InvalidAsset` error from the given `pezpallet-derivatives` instance.
pub struct InvalidAssetError<Pallet>(PhantomData<Pallet>);
impl<T: Config<I>, I: 'static> TypedGet for InvalidAssetError<Pallet<T, I>> {
pub struct InvalidAssetError<Pezpallet>(PhantomData<Pezpallet>);
impl<T: Config<I>, I: 'static> TypedGet for InvalidAssetError<Pezpallet<T, I>> {
type Type = Error<T, I>;
fn get() -> Self::Type {
+1 -1
View File
@@ -233,7 +233,7 @@ impl<Registry: DerivativesRegistry<NonFungibleAsset, DerivativeId>, DerivativeId
/// NonFungible(Index(<InClassInstanceId>))`. So, this chain is the reserve location for all
/// instances matching the above identification.
///
/// However, if some of the instances within Pallet #111 could be derivatives as well,
/// However, if some of the instances within Pezpallet #111 could be derivatives as well,
/// we need to ensure that this chain won't act as the reserve location for these instances.
/// If we allow this, this chain could send a derivative as if it were the original NFT on this
/// chain. The other chain can't know that this instance isn't the original.
+21 -21
View File
@@ -17,33 +17,33 @@
//! Test environment for `pezpallet-derivatives`.
//!
//! It contains a simple NFT-like `unique_items` pallet that emulate both NFT collections and their
//! tokens (depending on the pallet instance). This test pallet is instatiated three times in the
//! It contains a simple NFT-like `unique_items` pezpallet that emulate both NFT collections and their
//! tokens (depending on the pezpallet instance). This test pezpallet is instatiated three times in the
//! test environment to cover the usage scenarios of `pezpallet-derivatives` described in it's crate
//! doc comment.
//!
//! * The first instance, called `PredefinedIdCollections`, emulates NFT collections that are
//! created with a predefined ID.
//! The ID is set to XCM `AssetId`, so a derivative collection can be created directly using the
//! foreign collection's ID. This pallet instance illustrates and tests the `pezpallet-derivatives`
//! foreign collection's ID. This pezpallet instance illustrates and tests the `pezpallet-derivatives`
//! usage scenario #1 (i.e., when no suitable way of directly creating a derivative collection is
//! provided by the hosting pallet). The configuration of this instance can be found in the
//! provided by the hosting pezpallet). The configuration of this instance can be found in the
//! [predefined_id_collections] module. The corresponding `pezpallet-derivatives` instance is called
//! `PredefinedIdDerivativeCollections`.
//!
//! * The second instance, called `AutoIdCollections`, emulates NFT collections that are created
//! with an automatically assigned ID (e.g., an incremental one).
//! The ID is set to `u64`, so a mapping between the foreign collection's ID and the derivative
//! collection ID is needed. This pallet instance illustrates and tests the `pezpallet-derivatives`
//! collection ID is needed. This pezpallet instance illustrates and tests the `pezpallet-derivatives`
//! usage scenario #2 combined with scenario #1 (since we also test manual collection creation and
//! destruction). The configuration of this instance can be found in the [auto_id_collections]
//! module. The corresponding `pezpallet-derivatives` instance is called `AutoIdDerivativeCollections`.
//!
//! * The third instance, called `PredefinedIdNfts`, emulates non-fungible tokens within collections
//! from the pallet's second instance.
//! from the pezpallet's second instance.
//! The full NFT ID is a tuple consisting of the collection ID and a token ID, both of which are of
//! the `u64` type. Since a foreign NFT is identified by `(AssetId, AssetInstance)`, we need the
//! mapping between it and the derivative NFT ID. This pallet instance illustrates and tests the
//! mapping between it and the derivative NFT ID. This pezpallet instance illustrates and tests the
//! `pezpallet-derivatives` usage scenario #2 without scenario #1 (the manual creation and destruction
//! of derivative NFTs is forbidden). The configuration of this instance can be found in the
//! [auto_id_nfts] module. The corresponding `pezpallet-derivatives` instance is called
@@ -84,32 +84,32 @@ type AccountId = u64;
type Block = pezframe_system::mocking::MockBlock<Test>;
type Balance = u64;
#[pezframe_support::pallet]
#[pezframe_support::pezpallet]
pub mod unique_items {
use pezframe_support::pezpallet_prelude::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config<I: 'static = ()>: pezframe_system::Config {
type ItemId: Member + Parameter + MaxEncodedLen + TypeInfo;
}
#[pallet::pallet]
pub struct Pallet<T, I = ()>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T, I = ()>(_);
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
AlreadyExists,
NoPermission,
UnknownItem,
}
#[pallet::event]
#[pezpallet::event]
pub enum Event<T: Config<I>, I: 'static = ()> {}
#[pallet::storage]
#[pezpallet::storage]
pub type CurrentItemId<T: Config<I>, I: 'static = ()> = StorageValue<_, T::ItemId, OptionQuery>;
#[pallet::storage]
#[pezpallet::storage]
pub type ItemOwner<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, T::ItemId, T::AccountId, OptionQuery>;
}
@@ -234,7 +234,7 @@ pub type CreateDerivativeOwnedBySovAcc<IdAssignment, CreateOp, InvalidAssetErr>
>;
/// The `pezpallet-derivatives` instance corresponding to the `PredefinedIdCollections` instance of the
/// `unique_items` mock pallet.
/// `unique_items` mock pezpallet.
pub type PredefinedIdDerivativeCollectionsInstance = pezpallet_derivatives::Instance1;
impl pezpallet_derivatives::Config<PredefinedIdDerivativeCollectionsInstance> for Test {
type WeightInfo = pezpallet_derivatives::TestWeightInfo;
@@ -246,7 +246,7 @@ impl pezpallet_derivatives::Config<PredefinedIdDerivativeCollectionsInstance> fo
type CreateOrigin = EnsureSigned<AccountId>;
// `NoStoredMapping` tells the pallet not to store the mapping between the `Original` and the
// `NoStoredMapping` tells the pezpallet not to store the mapping between the `Original` and the
// `Derivative`
type CreateOp = pezpallet_derivatives::NoStoredMapping<
CreateDerivativeOwnedBySovAcc<
@@ -261,7 +261,7 @@ impl pezpallet_derivatives::Config<PredefinedIdDerivativeCollectionsInstance> fo
}
/// The `pezpallet-derivatives` instance corresponding to the `AutoIdCollections` instance of the
/// `unique_items` mock pallet.
/// `unique_items` mock pezpallet.
pub type AutoIdDerivativeCollectionsInstance = pezpallet_derivatives::Instance2;
impl pezpallet_derivatives::Config<AutoIdDerivativeCollectionsInstance> for Test {
type WeightInfo = pezpallet_derivatives::TestWeightInfo;
@@ -274,7 +274,7 @@ impl pezpallet_derivatives::Config<AutoIdDerivativeCollectionsInstance> for Test
type CreateOrigin = EnsureSigned<AccountId>;
// `StoreMapping` tells the pallet to store the mapping between the `Original` and the
// `StoreMapping` tells the pezpallet to store the mapping between the `Original` and the
// `Derivative`
type CreateOp = pezpallet_derivatives::StoreMapping<
CreateDerivativeOwnedBySovAcc<
@@ -300,7 +300,7 @@ impl pezpallet_derivatives::Config<AutoIdDerivativeCollectionsInstance> for Test
}
/// The `pezpallet-derivatives` instance corresponding to the `PredefinedIdNfts` instance of the
/// `unique_items` mock pallet.
/// `unique_items` mock pezpallet.
pub type DerivativeNftsInstance = pezpallet_derivatives::Instance3;
impl pezpallet_derivatives::Config<DerivativeNftsInstance> for Test {
type WeightInfo = pezpallet_derivatives::TestWeightInfo;
@@ -319,7 +319,7 @@ impl pezpallet_derivatives::Config<DerivativeNftsInstance> for Test {
type DestroyOp = DisabledOps<Self::Original>;
}
/// Matches NFTs within the `PredefinedIdNfts` pallet.
/// Matches NFTs within the `PredefinedIdNfts` pezpallet.
/// These NFTs are considered "local" since they are minted on this chain.
pub type LocalNftsMatcher = MatchInClassInstances<
MatchedConvertedConcreteId<