difftreelog
Merge pull request #383 from UniqueNetwork/test/nesting-admin
in: master
11 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -96,7 +96,7 @@
permissions: Some(CollectionPermissions {
nesting: Some(NestingPermissions {
token_owner: false,
- admin: false,
+ collection_admin: false,
restricted: None,
permissive: true,
}),
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -1008,7 +1008,7 @@
nesting_budget,
)? {
// Pass
- } else if nesting.admin && handle.is_owner_or_admin(&sender) {
+ } else if nesting.collection_admin && handle.is_owner_or_admin(&sender) {
// Pass
} else {
fail!(<CommonError<T>>::UserIsNotAllowedToNest);
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use frame_support::{pallet_prelude::*, transactional, BoundedVec, dispatch::DispatchResult};20use frame_system::{pallet_prelude::*, ensure_signed};21use sp_runtime::{DispatchError, Permill, traits::StaticLookup};22use sp_std::vec::Vec;23use up_data_structs::{*, mapping::TokenAddressMapping};24use pallet_common::{25 Pallet as PalletCommon, Error as CommonError, CollectionHandle, CommonCollectionOperations,26};27use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle, TokenData};28use pallet_structure::{Pallet as PalletStructure, Error as StructureError};29use pallet_evm::account::CrossAccountId;30use core::convert::AsRef;3132pub use pallet::*;3334#[cfg(feature = "runtime-benchmarks")]35pub mod benchmarking;36pub mod misc;37pub mod property;38pub mod weights;3940pub type SelfWeightOf<T> = <T as Config>::WeightInfo;4142use weights::WeightInfo;43use misc::*;44pub use property::*;4546use RmrkProperty::*;4748pub const NESTING_BUDGET: u32 = 5;4950#[frame_support::pallet]51pub mod pallet {52 use super::*;53 use pallet_evm::account;5455 #[pallet::config]56 pub trait Config:57 frame_system::Config + pallet_common::Config + pallet_nonfungible::Config + account::Config58 {59 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;60 type WeightInfo: WeightInfo;61 }6263 #[pallet::storage]64 #[pallet::getter(fn collection_index)]65 pub type CollectionIndex<T: Config> = StorageValue<_, RmrkCollectionId, ValueQuery>;6667 #[pallet::storage]68 pub type UniqueCollectionId<T: Config> =69 StorageMap<_, Twox64Concat, RmrkCollectionId, CollectionId, ValueQuery>;7071 #[pallet::pallet]72 #[pallet::generate_store(pub(super) trait Store)]73 pub struct Pallet<T>(_);7475 #[pallet::event]76 #[pallet::generate_deposit(pub(super) fn deposit_event)]77 pub enum Event<T: Config> {78 CollectionCreated {79 issuer: T::AccountId,80 collection_id: RmrkCollectionId,81 },82 CollectionDestroyed {83 issuer: T::AccountId,84 collection_id: RmrkCollectionId,85 },86 IssuerChanged {87 old_issuer: T::AccountId,88 new_issuer: T::AccountId,89 collection_id: RmrkCollectionId,90 },91 CollectionLocked {92 issuer: T::AccountId,93 collection_id: RmrkCollectionId,94 },95 NftMinted {96 owner: T::AccountId,97 collection_id: RmrkCollectionId,98 nft_id: RmrkNftId,99 },100 NFTBurned {101 owner: T::AccountId,102 nft_id: RmrkNftId,103 },104 NFTSent {105 sender: T::AccountId,106 recipient: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,107 collection_id: RmrkCollectionId,108 nft_id: RmrkNftId,109 approval_required: bool,110 },111 NFTAccepted {112 sender: T::AccountId,113 recipient: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,114 collection_id: RmrkCollectionId,115 nft_id: RmrkNftId,116 },117 NFTRejected {118 sender: T::AccountId,119 collection_id: RmrkCollectionId,120 nft_id: RmrkNftId,121 },122 PropertySet {123 collection_id: RmrkCollectionId,124 maybe_nft_id: Option<RmrkNftId>,125 key: RmrkKeyString,126 value: RmrkValueString,127 },128 ResourceAdded {129 nft_id: RmrkNftId,130 resource_id: RmrkResourceId,131 },132 ResourceRemoval {133 nft_id: RmrkNftId,134 resource_id: RmrkResourceId,135 },136 ResourceAccepted {137 nft_id: RmrkNftId,138 resource_id: RmrkResourceId,139 },140 ResourceRemovalAccepted {141 nft_id: RmrkNftId,142 resource_id: RmrkResourceId,143 },144 PrioritySet {145 collection_id: RmrkCollectionId,146 nft_id: RmrkNftId,147 },148 }149150 #[pallet::error]151 pub enum Error<T> {152 /* Unique-specific events */153 CorruptedCollectionType,154 NftTypeEncodeError,155 RmrkPropertyKeyIsTooLong,156 RmrkPropertyValueIsTooLong,157 UnableToDecodeRmrkData,158159 /* RMRK compatible events */160 CollectionNotEmpty,161 NoAvailableCollectionId,162 NoAvailableNftId,163 CollectionUnknown,164 NoPermission,165 NonTransferable,166 CollectionFullOrLocked,167 ResourceDoesntExist,168 CannotSendToDescendentOrSelf,169 CannotAcceptNonOwnedNft,170 CannotRejectNonOwnedNft,171 ResourceNotPending,172 }173174 #[pallet::call]175 impl<T: Config> Pallet<T> {176 /// Create a collection177 #[transactional]178 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]179 pub fn create_collection(180 origin: OriginFor<T>,181 metadata: RmrkString,182 max: Option<u32>,183 symbol: RmrkCollectionSymbol,184 ) -> DispatchResult {185 let sender = ensure_signed(origin)?;186187 let limits = CollectionLimits {188 owner_can_transfer: Some(false),189 token_limit: max,190 ..Default::default()191 };192193 let data = CreateCollectionData {194 limits: Some(limits),195 token_prefix: symbol196 .into_inner()197 .try_into()198 .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,199 permissions: Some(CollectionPermissions {200 nesting: Some(NestingPermissions {201 token_owner: true,202 admin: false,203 restricted: None,204205 permissive: false,206 }),207 ..Default::default()208 }),209 ..Default::default()210 };211212 let unique_collection_id = Self::init_collection(213 T::CrossAccountId::from_sub(sender.clone()),214 data,215 [216 Self::rmrk_property(Metadata, &metadata)?,217 Self::rmrk_property(CollectionType, &misc::CollectionType::Regular)?,218 ]219 .into_iter(),220 )?;221 let rmrk_collection_id = <CollectionIndex<T>>::get();222223 <UniqueCollectionId<T>>::insert(rmrk_collection_id, unique_collection_id);224225 <PalletCommon<T>>::set_scoped_collection_property(226 unique_collection_id,227 PropertyScope::Rmrk,228 Self::rmrk_property(RmrkInternalCollectionId, &rmrk_collection_id)?,229 )?;230231 <CollectionIndex<T>>::mutate(|n| *n += 1);232233 Self::deposit_event(Event::CollectionCreated {234 issuer: sender,235 collection_id: rmrk_collection_id,236 });237238 Ok(())239 }240241 /// destroy collection242 #[transactional]243 #[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]244 pub fn destroy_collection(245 origin: OriginFor<T>,246 collection_id: RmrkCollectionId,247 ) -> DispatchResult {248 let sender = ensure_signed(origin)?;249 let cross_sender = T::CrossAccountId::from_sub(sender.clone());250251 let collection = Self::get_typed_nft_collection(252 Self::unique_collection_id(collection_id)?,253 misc::CollectionType::Regular,254 )?;255 collection.check_is_external()?;256257 <PalletNft<T>>::destroy_collection(collection, &cross_sender)258 .map_err(Self::map_unique_err_to_proxy)?;259260 Self::deposit_event(Event::CollectionDestroyed {261 issuer: sender,262 collection_id,263 });264265 Ok(())266 }267268 /// Change the issuer of a collection269 ///270 /// Parameters:271 /// - `origin`: sender of the transaction272 /// - `collection_id`: collection id of the nft to change issuer of273 /// - `new_issuer`: Collection's new issuer274 #[transactional]275 #[pallet::weight(<SelfWeightOf<T>>::change_collection_issuer())]276 pub fn change_collection_issuer(277 origin: OriginFor<T>,278 collection_id: RmrkCollectionId,279 new_issuer: <T::Lookup as StaticLookup>::Source,280 ) -> DispatchResult {281 let sender = ensure_signed(origin)?;282283 let collection = Self::get_nft_collection(Self::unique_collection_id(collection_id)?)?;284 collection.check_is_external()?;285286 let new_issuer = T::Lookup::lookup(new_issuer)?;287288 Self::change_collection_owner(289 Self::unique_collection_id(collection_id)?,290 misc::CollectionType::Regular,291 sender.clone(),292 new_issuer.clone(),293 )?;294295 Self::deposit_event(Event::IssuerChanged {296 old_issuer: sender,297 new_issuer,298 collection_id,299 });300301 Ok(())302 }303304 /// lock collection305 #[transactional]306 #[pallet::weight(<SelfWeightOf<T>>::lock_collection())]307 pub fn lock_collection(308 origin: OriginFor<T>,309 collection_id: RmrkCollectionId,310 ) -> DispatchResult {311 let sender = ensure_signed(origin)?;312 let cross_sender = T::CrossAccountId::from_sub(sender.clone());313314 let collection = Self::get_typed_nft_collection(315 Self::unique_collection_id(collection_id)?,316 misc::CollectionType::Regular,317 )?;318 collection.check_is_external()?;319320 Self::check_collection_owner(&collection, &cross_sender)?;321322 let token_count = collection.total_supply();323324 let mut collection = collection.into_inner();325 collection.limits.token_limit = Some(token_count);326 collection.save()?;327328 Self::deposit_event(Event::CollectionLocked {329 issuer: sender,330 collection_id,331 });332333 Ok(())334 }335336 /// Mints an NFT in the specified collection337 /// Sets metadata and the royalty attribute338 ///339 /// Parameters:340 /// - `collection_id`: The class of the asset to be minted.341 /// - `nft_id`: The nft value of the asset to be minted.342 /// - `recipient`: Receiver of the royalty343 /// - `royalty`: Permillage reward from each trade for the Recipient344 /// - `metadata`: Arbitrary data about an nft, e.g. IPFS hash345 /// - `transferable`: Ability to transfer this NFT346 #[transactional]347 #[pallet::weight(<SelfWeightOf<T>>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))]348 pub fn mint_nft(349 origin: OriginFor<T>,350 owner: T::AccountId,351 collection_id: RmrkCollectionId,352 recipient: Option<T::AccountId>,353 royalty_amount: Option<Permill>,354 metadata: RmrkString,355 transferable: bool,356 resources: Option<BoundedVec<RmrkResourceTypes, MaxResourcesOnMint>>,357 ) -> DispatchResult {358 let sender = ensure_signed(origin)?;359 let cross_sender = T::CrossAccountId::from_sub(sender.clone());360 let cross_owner = T::CrossAccountId::from_sub(owner.clone());361362 let collection = Self::get_typed_nft_collection(363 Self::unique_collection_id(collection_id)?,364 misc::CollectionType::Regular,365 )?;366 collection.check_is_external()?;367368 let royalty_info = royalty_amount.map(|amount| rmrk_traits::RoyaltyInfo {369 recipient: recipient.unwrap_or_else(|| owner.clone()),370 amount,371 });372373 let nft_id = Self::create_nft(374 &cross_sender,375 &cross_owner,376 &collection,377 [378 Self::rmrk_property(TokenType, &NftType::Regular)?,379 Self::rmrk_property(Transferable, &transferable)?,380 Self::rmrk_property(PendingNftAccept, &false)?,381 Self::rmrk_property(RoyaltyInfo, &royalty_info)?,382 Self::rmrk_property(Metadata, &metadata)?,383 Self::rmrk_property(Equipped, &false)?,384 Self::rmrk_property(ResourceCollection, &None::<CollectionId>)?,385 Self::rmrk_property(ResourcePriorities, &<Vec<u8>>::new())?,386 ]387 .into_iter(),388 )389 .map_err(|err| match err {390 DispatchError::Arithmetic(_) => <Error<T>>::NoAvailableNftId.into(),391 err => Self::map_unique_err_to_proxy(err),392 })?;393394 if let Some(resources) = resources {395 for resource in resources {396 Self::resource_add(sender.clone(), collection.id, nft_id, resource)?;397 }398 }399400 Self::deposit_event(Event::NftMinted {401 owner,402 collection_id,403 nft_id: nft_id.0,404 });405406 Ok(())407 }408409 /// burn nft410 #[transactional]411 #[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]412 pub fn burn_nft(413 origin: OriginFor<T>,414 collection_id: RmrkCollectionId,415 nft_id: RmrkNftId,416 max_burns: u32,417 ) -> DispatchResult {418 let sender = ensure_signed(origin)?;419 let cross_sender = T::CrossAccountId::from_sub(sender.clone());420421 let collection = Self::get_typed_nft_collection(422 Self::unique_collection_id(collection_id)?,423 misc::CollectionType::Regular,424 )?;425 collection.check_is_external()?;426427 Self::destroy_nft(428 cross_sender,429 Self::unique_collection_id(collection_id)?,430 nft_id.into(),431 max_burns,432 <Error<T>>::NoPermission,433 )434 .map_err(|err| Self::map_unique_err_to_proxy(err.error))?;435436 Self::deposit_event(Event::NFTBurned {437 owner: sender,438 nft_id,439 });440441 Ok(())442 }443444 /// Transfers a NFT from an Account or NFT A to another Account or NFT B445 ///446 /// Parameters:447 /// - `origin`: sender of the transaction448 /// - `rmrk_collection_id`: collection id of the nft to be transferred449 /// - `rmrk_nft_id`: nft id of the nft to be transferred450 /// - `new_owner`: new owner of the nft which can be either an account or a NFT451 #[transactional]452 #[pallet::weight(<SelfWeightOf<T>>::send())]453 pub fn send(454 origin: OriginFor<T>,455 rmrk_collection_id: RmrkCollectionId,456 rmrk_nft_id: RmrkNftId,457 new_owner: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,458 ) -> DispatchResult {459 let sender = ensure_signed(origin.clone())?;460 let cross_sender = T::CrossAccountId::from_sub(sender.clone());461462 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;463 let nft_id = rmrk_nft_id.into();464465 let collection =466 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;467 collection.check_is_external()?;468469 let token_data =470 <TokenData<T>>::get((collection_id, nft_id)).ok_or(<Error<T>>::NoAvailableNftId)?;471472 let from = token_data.owner;473474 ensure!(475 Self::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::Transferable)?,476 <Error<T>>::NonTransferable477 );478479 ensure!(480 !Self::get_nft_property_decoded(481 collection_id,482 nft_id,483 RmrkProperty::PendingNftAccept484 )?,485 <Error<T>>::NoPermission486 );487488 let target_owner;489 let approval_required;490491 match new_owner {492 RmrkAccountIdOrCollectionNftTuple::AccountId(ref account_id) => {493 target_owner = T::CrossAccountId::from_sub(account_id.clone());494 approval_required = false;495 }496 RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(497 target_collection_id,498 target_nft_id,499 ) => {500 let target_collection_id = Self::unique_collection_id(target_collection_id)?;501502 let target_nft_budget = budget::Value::new(NESTING_BUDGET);503504 let target_nft_owner = <PalletStructure<T>>::get_checked_topmost_owner(505 target_collection_id,506 target_nft_id.into(),507 Some((collection_id, nft_id)),508 &target_nft_budget,509 )510 .map_err(Self::map_unique_err_to_proxy)?;511512 approval_required = cross_sender != target_nft_owner;513514 if approval_required {515 target_owner = target_nft_owner;516517 <PalletNft<T>>::set_scoped_token_property(518 collection.id,519 nft_id,520 PropertyScope::Rmrk,521 Self::rmrk_property(PendingNftAccept, &approval_required)?,522 )?;523 } else {524 target_owner = T::CrossTokenAddressMapping::token_to_address(525 target_collection_id,526 target_nft_id.into(),527 );528 }529 }530 }531532 let src_nft_budget = budget::Value::new(NESTING_BUDGET);533534 <PalletNft<T>>::transfer_from(535 &collection,536 &cross_sender,537 &from,538 &target_owner,539 nft_id,540 &src_nft_budget,541 )542 .map_err(Self::map_unique_err_to_proxy)?;543544 Self::deposit_event(Event::NFTSent {545 sender,546 recipient: new_owner,547 collection_id: rmrk_collection_id,548 nft_id: rmrk_nft_id,549 approval_required,550 });551552 Ok(())553 }554555 /// Accepts an NFT sent from another account to self or owned NFT556 ///557 /// Parameters:558 /// - `origin`: sender of the transaction559 /// - `rmrk_collection_id`: collection id of the nft to be accepted560 /// - `rmrk_nft_id`: nft id of the nft to be accepted561 /// - `new_owner`: either origin's account ID or origin-owned NFT, whichever the NFT was562 /// sent to563 #[transactional]564 #[pallet::weight(<SelfWeightOf<T>>::accept_nft())]565 pub fn accept_nft(566 origin: OriginFor<T>,567 rmrk_collection_id: RmrkCollectionId,568 rmrk_nft_id: RmrkNftId,569 new_owner: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,570 ) -> DispatchResult {571 let sender = ensure_signed(origin.clone())?;572 let cross_sender = T::CrossAccountId::from_sub(sender.clone());573574 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;575 let nft_id = rmrk_nft_id.into();576577 let collection =578 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;579 collection.check_is_external()?;580581 let new_cross_owner = match new_owner {582 RmrkAccountIdOrCollectionNftTuple::AccountId(ref account_id) => {583 T::CrossAccountId::from_sub(account_id.clone())584 }585 RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(586 target_collection_id,587 target_nft_id,588 ) => {589 let target_collection_id = Self::unique_collection_id(target_collection_id)?;590591 T::CrossTokenAddressMapping::token_to_address(592 target_collection_id,593 TokenId(target_nft_id),594 )595 }596 };597598 let budget = budget::Value::new(NESTING_BUDGET);599600 <PalletNft<T>>::transfer(601 &collection,602 &cross_sender,603 &new_cross_owner,604 nft_id,605 &budget,606 )607 .map_err(|err| {608 if err == <CommonError<T>>::UserIsNotAllowedToNest.into() {609 <Error<T>>::CannotAcceptNonOwnedNft.into()610 } else {611 Self::map_unique_err_to_proxy(err)612 }613 })?;614615 <PalletNft<T>>::set_scoped_token_property(616 collection.id,617 nft_id,618 PropertyScope::Rmrk,619 Self::rmrk_property(PendingNftAccept, &false)?,620 )?;621622 Self::deposit_event(Event::NFTAccepted {623 sender,624 recipient: new_owner,625 collection_id: rmrk_collection_id,626 nft_id: rmrk_nft_id,627 });628629 Ok(())630 }631632 /// Rejects an NFT sent from another account to self or owned NFT633 ///634 /// Parameters:635 /// - `origin`: sender of the transaction636 /// - `rmrk_collection_id`: collection id of the nft to be accepted637 /// - `rmrk_nft_id`: nft id of the nft to be accepted638 #[transactional]639 #[pallet::weight(<SelfWeightOf<T>>::reject_nft())]640 pub fn reject_nft(641 origin: OriginFor<T>,642 rmrk_collection_id: RmrkCollectionId,643 rmrk_nft_id: RmrkNftId,644 ) -> DispatchResult {645 let sender = ensure_signed(origin)?;646 let cross_sender = T::CrossAccountId::from_sub(sender.clone());647648 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;649 let nft_id = rmrk_nft_id.into();650651 let collection =652 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;653 collection.check_is_external()?;654655 ensure!(656 Self::get_nft_property_decoded(657 collection_id,658 nft_id,659 RmrkProperty::PendingNftAccept660 )?,661 <Error<T>>::NoPermission662 );663664 Self::destroy_nft(665 cross_sender,666 collection_id,667 nft_id,668 NESTING_BUDGET,669 <Error<T>>::CannotRejectNonOwnedNft,670 )671 .map_err(|err| Self::map_unique_err_to_proxy(err.error))?;672673 Self::deposit_event(Event::NFTRejected {674 sender,675 collection_id: rmrk_collection_id,676 nft_id: rmrk_nft_id,677 });678679 Ok(())680 }681682 /// accept the addition of a new resource to an existing NFT683 #[transactional]684 #[pallet::weight(<SelfWeightOf<T>>::accept_resource())]685 pub fn accept_resource(686 origin: OriginFor<T>,687 rmrk_collection_id: RmrkCollectionId,688 rmrk_nft_id: RmrkNftId,689 rmrk_resource_id: RmrkResourceId,690 ) -> DispatchResult {691 let sender = ensure_signed(origin)?;692 let cross_sender = T::CrossAccountId::from_sub(sender);693694 let collection_id = Self::unique_collection_id(rmrk_collection_id)695 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;696 let collection =697 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;698 collection.check_is_external()?;699700 let nft_id = rmrk_nft_id.into();701 let resource_id = rmrk_resource_id.into();702703 let budget = budget::Value::new(NESTING_BUDGET);704705 let nft_owner =706 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)707 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;708709 let resource_collection_id: Option<CollectionId> =710 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)711 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;712713 let resource_collection_id =714 resource_collection_id.ok_or(<Error<T>>::ResourceDoesntExist)?;715716 let is_pending: bool = Self::get_nft_property_decoded(717 resource_collection_id,718 resource_id,719 PendingResourceAccept,720 )721 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;722723 ensure!(is_pending, <Error<T>>::ResourceNotPending);724725 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);726727 <PalletNft<T>>::set_scoped_token_property(728 resource_collection_id,729 rmrk_resource_id.into(),730 PropertyScope::Rmrk,731 Self::rmrk_property(PendingResourceAccept, &false)?,732 )?;733734 Self::deposit_event(Event::<T>::ResourceAccepted {735 nft_id: rmrk_nft_id,736 resource_id: rmrk_resource_id,737 });738739 Ok(())740 }741742 /// accept the removal of a resource of an existing NFT743 #[transactional]744 #[pallet::weight(<SelfWeightOf<T>>::accept_resource_removal())]745 pub fn accept_resource_removal(746 origin: OriginFor<T>,747 rmrk_collection_id: RmrkCollectionId,748 rmrk_nft_id: RmrkNftId,749 rmrk_resource_id: RmrkResourceId,750 ) -> DispatchResult {751 let sender = ensure_signed(origin)?;752 let cross_sender = T::CrossAccountId::from_sub(sender);753754 let collection_id = Self::unique_collection_id(rmrk_collection_id)755 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;756 let collection =757 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;758 collection.check_is_external()?;759760 let nft_id = rmrk_nft_id.into();761 let resource_id = rmrk_resource_id.into();762763 let budget = budget::Value::new(NESTING_BUDGET);764765 let nft_owner =766 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)767 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;768769 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);770771 let resource_collection_id: Option<CollectionId> =772 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)773 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;774775 let resource_collection_id =776 resource_collection_id.ok_or(<Error<T>>::ResourceDoesntExist)?;777778 let is_pending: bool = Self::get_nft_property_decoded(779 resource_collection_id,780 resource_id,781 PendingResourceRemoval,782 )783 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;784785 ensure!(is_pending, <Error<T>>::ResourceNotPending);786787 let resource_collection = Self::get_typed_nft_collection(788 resource_collection_id,789 misc::CollectionType::Resource,790 )?;791792 let resource_data = <TokenData<T>>::get((resource_collection_id, resource_id))793 .ok_or(<Error<T>>::ResourceDoesntExist)?;794795 let resource_owner = resource_data.owner;796797 <PalletNft<T>>::burn(798 &resource_collection,799 &resource_owner,800 rmrk_resource_id.into(),801 )802 .map_err(Self::map_unique_err_to_proxy)?;803804 Self::deposit_event(Event::<T>::ResourceRemovalAccepted {805 nft_id: rmrk_nft_id,806 resource_id: rmrk_resource_id,807 });808809 Ok(())810 }811812 /// set a custom value on an NFT813 #[transactional]814 #[pallet::weight(<SelfWeightOf<T>>::set_property())]815 pub fn set_property(816 origin: OriginFor<T>,817 #[pallet::compact] rmrk_collection_id: RmrkCollectionId,818 maybe_nft_id: Option<RmrkNftId>,819 key: RmrkKeyString,820 value: RmrkValueString,821 ) -> DispatchResult {822 let sender = ensure_signed(origin)?;823 let sender = T::CrossAccountId::from_sub(sender);824825 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;826 let collection =827 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;828 collection.check_is_external()?;829830 let budget = budget::Value::new(NESTING_BUDGET);831832 match maybe_nft_id {833 Some(nft_id) => {834 let token_id: TokenId = nft_id.into();835836 Self::ensure_nft_type(collection_id, token_id, NftType::Regular)?;837 Self::ensure_nft_owner(collection_id, token_id, &sender, &budget)?;838839 <PalletNft<T>>::set_scoped_token_property(840 collection_id,841 token_id,842 PropertyScope::Rmrk,843 Self::rmrk_property(UserProperty(key.as_slice()), &value)?,844 )?;845 }846 None => {847 let collection = Self::get_typed_nft_collection(848 collection_id,849 misc::CollectionType::Regular,850 )?;851852 Self::check_collection_owner(&collection, &sender)?;853854 <PalletCommon<T>>::set_scoped_collection_property(855 collection_id,856 PropertyScope::Rmrk,857 Self::rmrk_property(UserProperty(key.as_slice()), &value)?,858 )?;859 }860 }861862 Self::deposit_event(Event::PropertySet {863 collection_id: rmrk_collection_id,864 maybe_nft_id,865 key,866 value,867 });868869 Ok(())870 }871872 /// set a different order of resource priority873 #[transactional]874 #[pallet::weight(<SelfWeightOf<T>>::set_priority())]875 pub fn set_priority(876 origin: OriginFor<T>,877 rmrk_collection_id: RmrkCollectionId,878 rmrk_nft_id: RmrkNftId,879 priorities: BoundedVec<RmrkResourceId, RmrkMaxPriorities>,880 ) -> DispatchResult {881 let sender = ensure_signed(origin)?;882 let sender = T::CrossAccountId::from_sub(sender);883884 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;885 let nft_id = rmrk_nft_id.into();886887 let collection =888 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;889 collection.check_is_external()?;890891 let budget = budget::Value::new(NESTING_BUDGET);892893 Self::ensure_nft_type(collection_id, nft_id, NftType::Regular)?;894 Self::ensure_nft_owner(collection_id, nft_id, &sender, &budget)?;895896 <PalletNft<T>>::set_scoped_token_property(897 collection_id,898 nft_id,899 PropertyScope::Rmrk,900 Self::rmrk_property(ResourcePriorities, &priorities.into_inner())?,901 )?;902903 Self::deposit_event(Event::<T>::PrioritySet {904 collection_id: rmrk_collection_id,905 nft_id: rmrk_nft_id,906 });907908 Ok(())909 }910911 /// Create basic resource912 #[transactional]913 #[pallet::weight(<SelfWeightOf<T>>::add_basic_resource())]914 pub fn add_basic_resource(915 origin: OriginFor<T>,916 rmrk_collection_id: RmrkCollectionId,917 nft_id: RmrkNftId,918 resource: RmrkBasicResource,919 ) -> DispatchResult {920 let sender = ensure_signed(origin.clone())?;921922 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;923 let collection =924 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;925 collection.check_is_external()?;926927 let resource_id = Self::resource_add(928 sender,929 collection_id,930 nft_id.into(),931 RmrkResourceTypes::Basic(resource),932 )?;933934 Self::deposit_event(Event::ResourceAdded {935 nft_id,936 resource_id,937 });938 Ok(())939 }940941 /// Create composable resource942 #[transactional]943 #[pallet::weight(<SelfWeightOf<T>>::add_composable_resource())]944 pub fn add_composable_resource(945 origin: OriginFor<T>,946 rmrk_collection_id: RmrkCollectionId,947 nft_id: RmrkNftId,948 resource: RmrkComposableResource,949 ) -> DispatchResult {950 let sender = ensure_signed(origin.clone())?;951952 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;953 let collection =954 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;955 collection.check_is_external()?;956957 let resource_id = Self::resource_add(958 sender,959 collection_id,960 nft_id.into(),961 RmrkResourceTypes::Composable(resource),962 )?;963964 Self::deposit_event(Event::ResourceAdded {965 nft_id,966 resource_id,967 });968 Ok(())969 }970971 /// Create slot resource972 #[transactional]973 #[pallet::weight(<SelfWeightOf<T>>::add_slot_resource())]974 pub fn add_slot_resource(975 origin: OriginFor<T>,976 rmrk_collection_id: RmrkCollectionId,977 nft_id: RmrkNftId,978 resource: RmrkSlotResource,979 ) -> DispatchResult {980 let sender = ensure_signed(origin.clone())?;981982 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;983 let collection =984 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;985 collection.check_is_external()?;986987 let resource_id = Self::resource_add(988 sender,989 collection_id,990 nft_id.into(),991 RmrkResourceTypes::Slot(resource),992 )?;993994 Self::deposit_event(Event::ResourceAdded {995 nft_id,996 resource_id,997 });998 Ok(())999 }10001001 /// remove resource1002 #[transactional]1003 #[pallet::weight(<SelfWeightOf<T>>::remove_resource())]1004 pub fn remove_resource(1005 origin: OriginFor<T>,1006 rmrk_collection_id: RmrkCollectionId,1007 nft_id: RmrkNftId,1008 resource_id: RmrkResourceId,1009 ) -> DispatchResult {1010 let sender = ensure_signed(origin.clone())?;10111012 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;1013 let collection =1014 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1015 collection.check_is_external()?;10161017 Self::resource_remove(sender, collection_id, nft_id.into(), resource_id.into())?;10181019 Self::deposit_event(Event::ResourceRemoval {1020 nft_id,1021 resource_id,1022 });1023 Ok(())1024 }1025 }1026}10271028impl<T: Config> Pallet<T> {1029 pub fn rmrk_property_key(rmrk_key: RmrkProperty) -> Result<PropertyKey, DispatchError> {1030 let key = rmrk_key.to_key::<T>()?;10311032 let scoped_key = PropertyScope::Rmrk1033 .apply(key)1034 .map_err(|_| <Error<T>>::RmrkPropertyKeyIsTooLong)?;10351036 Ok(scoped_key)1037 }10381039 // todo think about renaming these1040 pub fn rmrk_property<E: Encode>(1041 rmrk_key: RmrkProperty,1042 value: &E,1043 ) -> Result<Property, DispatchError> {1044 let key = rmrk_key.to_key::<T>()?;10451046 let value = value1047 .encode()1048 .try_into()1049 .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong)?;10501051 let property = Property { key, value };10521053 Ok(property)1054 }10551056 pub fn decode_property<D: Decode>(vec: PropertyValue) -> Result<D, DispatchError> {1057 vec.decode()1058 .map_err(|_| <Error<T>>::UnableToDecodeRmrkData.into())1059 }10601061 pub fn rebind<L, S>(vec: &BoundedVec<u8, L>) -> Result<BoundedVec<u8, S>, DispatchError>1062 where1063 BoundedVec<u8, S>: TryFrom<Vec<u8>>,1064 {1065 vec.rebind()1066 .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong.into())1067 }10681069 fn init_collection(1070 sender: T::CrossAccountId,1071 data: CreateCollectionData<T::AccountId>,1072 properties: impl Iterator<Item = Property>,1073 ) -> Result<CollectionId, DispatchError> {1074 let collection_id = <PalletNft<T>>::init_collection(sender, data, true);10751076 if let Err(DispatchError::Arithmetic(_)) = &collection_id {1077 return Err(<Error<T>>::NoAvailableCollectionId.into());1078 }10791080 <PalletCommon<T>>::set_scoped_collection_properties(1081 collection_id?,1082 PropertyScope::Rmrk,1083 properties,1084 )?;10851086 collection_id1087 }10881089 pub fn create_nft(1090 sender: &T::CrossAccountId,1091 owner: &T::CrossAccountId,1092 collection: &NonfungibleHandle<T>,1093 properties: impl Iterator<Item = Property>,1094 ) -> Result<TokenId, DispatchError> {1095 let data = CreateNftExData {1096 properties: BoundedVec::default(),1097 owner: owner.clone(),1098 };10991100 let budget = budget::Value::new(NESTING_BUDGET);11011102 <PalletNft<T>>::create_item(collection, sender, data, &budget)?;11031104 let nft_id = <PalletNft<T>>::current_token_id(collection.id);11051106 <PalletNft<T>>::set_scoped_token_properties(1107 collection.id,1108 nft_id,1109 PropertyScope::Rmrk,1110 properties,1111 )?;11121113 Ok(nft_id)1114 }11151116 fn destroy_nft(1117 sender: T::CrossAccountId,1118 collection_id: CollectionId,1119 token_id: TokenId,1120 max_burns: u32,1121 error_if_not_owned: Error<T>,1122 ) -> DispatchResultWithPostInfo {1123 let collection =1124 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;11251126 let token_data =1127 <TokenData<T>>::get((collection_id, token_id)).ok_or(<Error<T>>::NoAvailableNftId)?;11281129 let from = token_data.owner;11301131 let owner_check_budget = budget::Value::new(NESTING_BUDGET);11321133 ensure!(1134 <PalletStructure<T>>::check_indirectly_owned(1135 sender.clone(),1136 collection_id,1137 token_id,1138 None,1139 &owner_check_budget1140 )?,1141 error_if_not_owned,1142 );11431144 let burns_budget = budget::Value::new(max_burns);1145 let breadth_budget = budget::Value::new(max_burns);11461147 <PalletNft<T>>::burn_recursively(1148 &collection,1149 &from,1150 token_id,1151 &burns_budget,1152 &breadth_budget,1153 )1154 }11551156 fn resource_add(1157 sender: T::AccountId,1158 collection_id: CollectionId,1159 nft_id: TokenId,1160 resource: RmrkResourceTypes,1161 ) -> Result<RmrkResourceId, DispatchError> {1162 match resource {1163 RmrkResourceTypes::Basic(resource) => Self::resource_add_helper(1164 sender,1165 collection_id,1166 nft_id,1167 [1168 Self::rmrk_property(TokenType, &NftType::Resource)?,1169 Self::rmrk_property(ResourceType, &misc::ResourceType::Basic)?,1170 Self::rmrk_property(Src, &resource.src)?,1171 Self::rmrk_property(Metadata, &resource.metadata)?,1172 Self::rmrk_property(License, &resource.license)?,1173 Self::rmrk_property(Thumb, &resource.thumb)?,1174 ]1175 .into_iter(),1176 ),1177 RmrkResourceTypes::Composable(resource) => Self::resource_add_helper(1178 sender,1179 collection_id,1180 nft_id.into(),1181 [1182 Self::rmrk_property(TokenType, &NftType::Resource)?,1183 Self::rmrk_property(ResourceType, &misc::ResourceType::Composable)?,1184 Self::rmrk_property(Parts, &resource.parts)?,1185 Self::rmrk_property(Base, &resource.base)?,1186 Self::rmrk_property(Src, &resource.src)?,1187 Self::rmrk_property(Metadata, &resource.metadata)?,1188 Self::rmrk_property(License, &resource.license)?,1189 Self::rmrk_property(Thumb, &resource.thumb)?,1190 ]1191 .into_iter(),1192 ),1193 RmrkResourceTypes::Slot(resource) => Self::resource_add_helper(1194 sender,1195 collection_id,1196 nft_id.into(),1197 [1198 Self::rmrk_property(TokenType, &NftType::Resource)?,1199 Self::rmrk_property(ResourceType, &misc::ResourceType::Slot)?,1200 Self::rmrk_property(Base, &resource.base)?,1201 Self::rmrk_property(Src, &resource.src)?,1202 Self::rmrk_property(Metadata, &resource.metadata)?,1203 Self::rmrk_property(Slot, &resource.slot)?,1204 Self::rmrk_property(License, &resource.license)?,1205 Self::rmrk_property(Thumb, &resource.thumb)?,1206 ]1207 .into_iter(),1208 ),1209 }1210 }12111212 fn resource_add_helper(1213 sender: T::AccountId,1214 collection_id: CollectionId,1215 token_id: TokenId,1216 resource_properties: impl Iterator<Item = Property>,1217 ) -> Result<RmrkResourceId, DispatchError> {1218 let collection =1219 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1220 ensure!(collection.owner == sender, Error::<T>::NoPermission);12211222 let sender = T::CrossAccountId::from_sub(sender);1223 let budget = budget::Value::new(NESTING_BUDGET);12241225 let nft_owner = <PalletStructure<T>>::find_topmost_owner(collection_id, token_id, &budget)1226 .map_err(Self::map_unique_err_to_proxy)?;12271228 let pending = sender != nft_owner;12291230 let resource_collection_id: Option<CollectionId> =1231 Self::get_nft_property_decoded(collection_id, token_id, ResourceCollection)?;12321233 let resource_collection_id = match resource_collection_id {1234 Some(id) => id,1235 None => {1236 let resource_collection_id = Self::init_collection(1237 sender.clone(),1238 CreateCollectionData {1239 ..Default::default()1240 },1241 [Self::rmrk_property(1242 CollectionType,1243 &misc::CollectionType::Resource,1244 )?]1245 .into_iter(),1246 )?;12471248 <PalletNft<T>>::set_scoped_token_property(1249 collection_id,1250 token_id,1251 PropertyScope::Rmrk,1252 Self::rmrk_property(ResourceCollection, &Some(resource_collection_id))?,1253 )?;12541255 resource_collection_id1256 }1257 };12581259 let resource_collection =1260 Self::get_typed_nft_collection(resource_collection_id, misc::CollectionType::Resource)?;12611262 // todo probably add extra connections to bases, slots, etc., when RMRK starts to use them12631264 let resource_id = Self::create_nft(1265 &sender,1266 &nft_owner,1267 &resource_collection,1268 resource_properties.chain(1269 [1270 Self::rmrk_property(PendingResourceAccept, &pending)?,1271 Self::rmrk_property(PendingResourceRemoval, &false)?,1272 ]1273 .into_iter(),1274 ),1275 )1276 .map_err(|err| match err {1277 DispatchError::Arithmetic(_) => <Error<T>>::NoAvailableNftId.into(),1278 err => Self::map_unique_err_to_proxy(err),1279 })?;12801281 Ok(resource_id.0)1282 }12831284 fn resource_remove(1285 sender: T::AccountId,1286 collection_id: CollectionId,1287 nft_id: TokenId,1288 resource_id: TokenId,1289 ) -> DispatchResult {1290 let collection =1291 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1292 ensure!(collection.owner == sender, Error::<T>::NoPermission);12931294 let resource_collection_id: Option<CollectionId> =1295 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)?;12961297 let resource_collection_id =1298 resource_collection_id.ok_or(Error::<T>::ResourceDoesntExist)?;12991300 let resource_collection =1301 Self::get_typed_nft_collection(resource_collection_id, misc::CollectionType::Resource)?;1302 ensure!(1303 <PalletNft<T>>::token_exists(&resource_collection, resource_id),1304 Error::<T>::ResourceDoesntExist1305 );13061307 let budget = up_data_structs::budget::Value::new(NESTING_BUDGET);1308 let topmost_owner =1309 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)?;13101311 let sender = T::CrossAccountId::from_sub(sender);1312 if topmost_owner == sender {1313 <PalletNft<T>>::burn(&resource_collection, &sender, resource_id)1314 .map_err(Self::map_unique_err_to_proxy)?;1315 } else {1316 <PalletNft<T>>::set_scoped_token_property(1317 resource_collection_id,1318 resource_id,1319 PropertyScope::Rmrk,1320 Self::rmrk_property(PendingResourceRemoval, &true)?,1321 )?;1322 }13231324 Ok(())1325 }13261327 fn change_collection_owner(1328 collection_id: CollectionId,1329 collection_type: misc::CollectionType,1330 sender: T::AccountId,1331 new_owner: T::AccountId,1332 ) -> DispatchResult {1333 let collection = Self::get_typed_nft_collection(collection_id, collection_type)?;1334 Self::check_collection_owner(&collection, &T::CrossAccountId::from_sub(sender))?;13351336 let mut collection = collection.into_inner();13371338 collection.owner = new_owner;1339 collection.save()1340 }13411342 fn check_collection_owner(1343 collection: &NonfungibleHandle<T>,1344 account: &T::CrossAccountId,1345 ) -> DispatchResult {1346 collection1347 .check_is_owner(account)1348 .map_err(Self::map_unique_err_to_proxy)1349 }13501351 pub fn last_collection_idx() -> RmrkCollectionId {1352 <CollectionIndex<T>>::get()1353 }13541355 pub fn unique_collection_id(1356 rmrk_collection_id: RmrkCollectionId,1357 ) -> Result<CollectionId, DispatchError> {1358 <UniqueCollectionId<T>>::try_get(rmrk_collection_id)1359 .map_err(|_| <Error<T>>::CollectionUnknown.into())1360 }13611362 pub fn rmrk_collection_id(1363 unique_collection_id: CollectionId,1364 ) -> Result<RmrkCollectionId, DispatchError> {1365 Self::get_collection_property_decoded(unique_collection_id, RmrkInternalCollectionId)1366 }13671368 pub fn get_nft_collection(1369 collection_id: CollectionId,1370 ) -> Result<NonfungibleHandle<T>, DispatchError> {1371 let collection = <CollectionHandle<T>>::try_get(collection_id)1372 .map_err(|_| <Error<T>>::CollectionUnknown)?;13731374 match collection.mode {1375 CollectionMode::NFT => Ok(NonfungibleHandle::cast(collection)),1376 _ => Err(<Error<T>>::CollectionUnknown.into()),1377 }1378 }13791380 pub fn collection_exists(collection_id: CollectionId) -> bool {1381 <CollectionHandle<T>>::try_get(collection_id).is_ok()1382 }13831384 pub fn get_collection_property(1385 collection_id: CollectionId,1386 key: RmrkProperty,1387 ) -> Result<PropertyValue, DispatchError> {1388 let collection_property = <PalletCommon<T>>::collection_properties(collection_id)1389 .get(&Self::rmrk_property_key(key)?)1390 .ok_or(<Error<T>>::CollectionUnknown)?1391 .clone();13921393 Ok(collection_property)1394 }13951396 pub fn get_collection_property_decoded<V: Decode>(1397 collection_id: CollectionId,1398 key: RmrkProperty,1399 ) -> Result<V, DispatchError> {1400 Self::decode_property(Self::get_collection_property(collection_id, key)?)1401 }14021403 pub fn get_collection_type(1404 collection_id: CollectionId,1405 ) -> Result<misc::CollectionType, DispatchError> {1406 Self::get_collection_property_decoded(collection_id, CollectionType)1407 .map_err(|_| <Error<T>>::CorruptedCollectionType.into())1408 }14091410 pub fn ensure_collection_type(1411 collection_id: CollectionId,1412 collection_type: misc::CollectionType,1413 ) -> DispatchResult {1414 let actual_type = Self::get_collection_type(collection_id)?;1415 ensure!(1416 actual_type == collection_type,1417 <CommonError<T>>::NoPermission1418 );14191420 Ok(())1421 }14221423 pub fn get_typed_nft_collection(1424 collection_id: CollectionId,1425 collection_type: misc::CollectionType,1426 ) -> Result<NonfungibleHandle<T>, DispatchError> {1427 Self::ensure_collection_type(collection_id, collection_type)?;14281429 Self::get_nft_collection(collection_id)1430 }14311432 pub fn get_typed_nft_collection_mapped(1433 rmrk_collection_id: RmrkCollectionId,1434 collection_type: misc::CollectionType,1435 ) -> Result<(NonfungibleHandle<T>, CollectionId), DispatchError> {1436 let unique_collection_id = match collection_type {1437 misc::CollectionType::Regular => Self::unique_collection_id(rmrk_collection_id)?,1438 _ => rmrk_collection_id.into(),1439 };14401441 let collection = Self::get_typed_nft_collection(unique_collection_id, collection_type)?;14421443 Ok((collection, unique_collection_id))1444 }14451446 pub fn get_nft_property(1447 collection_id: CollectionId,1448 nft_id: TokenId,1449 key: RmrkProperty,1450 ) -> Result<PropertyValue, DispatchError> {1451 let nft_property = <PalletNft<T>>::token_properties((collection_id, nft_id))1452 .get(&Self::rmrk_property_key(key)?)1453 .ok_or(<Error<T>>::NoAvailableNftId)? // todo replace with better error?1454 .clone();14551456 Ok(nft_property)1457 }14581459 pub fn get_nft_property_decoded<V: Decode>(1460 collection_id: CollectionId,1461 nft_id: TokenId,1462 key: RmrkProperty,1463 ) -> Result<V, DispatchError> {1464 Self::decode_property(Self::get_nft_property(collection_id, nft_id, key)?)1465 }14661467 pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {1468 <TokenData<T>>::contains_key((collection_id, nft_id))1469 }14701471 pub fn get_nft_type(1472 collection_id: CollectionId,1473 token_id: TokenId,1474 ) -> Result<NftType, DispatchError> {1475 Self::get_nft_property_decoded(collection_id, token_id, TokenType)1476 .map_err(|_| <Error<T>>::NoAvailableNftId.into())1477 }14781479 pub fn ensure_nft_type(1480 collection_id: CollectionId,1481 token_id: TokenId,1482 nft_type: NftType,1483 ) -> DispatchResult {1484 let actual_type = Self::get_nft_type(collection_id, token_id)?;1485 ensure!(actual_type == nft_type, <Error<T>>::NoPermission);14861487 Ok(())1488 }14891490 pub fn ensure_nft_owner(1491 collection_id: CollectionId,1492 token_id: TokenId,1493 possible_owner: &T::CrossAccountId,1494 nesting_budget: &dyn budget::Budget,1495 ) -> DispatchResult {1496 let is_owned = <PalletStructure<T>>::check_indirectly_owned(1497 possible_owner.clone(),1498 collection_id,1499 token_id,1500 None,1501 nesting_budget,1502 )1503 .map_err(Self::map_unique_err_to_proxy)?;15041505 ensure!(is_owned, <Error<T>>::NoPermission);15061507 Ok(())1508 }15091510 pub fn filter_user_properties<Key, Value, R, Mapper>(1511 collection_id: CollectionId,1512 token_id: Option<TokenId>,1513 filter_keys: Option<Vec<RmrkPropertyKey>>,1514 mapper: Mapper,1515 ) -> Result<Vec<R>, DispatchError>1516 where1517 Key: TryFrom<RmrkPropertyKey> + AsRef<[u8]>,1518 Value: Decode + Default,1519 Mapper: Fn(Key, Value) -> R,1520 {1521 filter_keys1522 .map(|keys| {1523 let properties = keys1524 .into_iter()1525 .filter_map(|key| {1526 let key: Key = key.try_into().ok()?;15271528 let value = match token_id {1529 Some(token_id) => Self::get_nft_property_decoded(1530 collection_id,1531 token_id,1532 UserProperty(key.as_ref()),1533 ),1534 None => Self::get_collection_property_decoded(1535 collection_id,1536 UserProperty(key.as_ref()),1537 ),1538 }1539 .ok()?;15401541 Some(mapper(key, value))1542 })1543 .collect();15441545 Ok(properties)1546 })1547 .unwrap_or_else(|| {1548 let properties =1549 Self::iterate_user_properties(collection_id, token_id, mapper)?.collect();15501551 Ok(properties)1552 })1553 }15541555 pub fn iterate_user_properties<Key, Value, R, Mapper>(1556 collection_id: CollectionId,1557 token_id: Option<TokenId>,1558 mapper: Mapper,1559 ) -> Result<impl Iterator<Item = R>, DispatchError>1560 where1561 Key: TryFrom<RmrkPropertyKey> + AsRef<[u8]>,1562 Value: Decode + Default,1563 Mapper: Fn(Key, Value) -> R,1564 {1565 let key_prefix = Self::rmrk_property_key(UserProperty(b""))?;15661567 let properties = match token_id {1568 Some(token_id) => <PalletNft<T>>::token_properties((collection_id, token_id)),1569 None => <PalletCommon<T>>::collection_properties(collection_id),1570 };15711572 let properties = properties.into_iter().filter_map(move |(key, value)| {1573 let key = key.as_slice().strip_prefix(key_prefix.as_slice())?;15741575 let key: Key = key.to_vec().try_into().ok()?;1576 let value: Value = value.decode().ok()?;15771578 Some(mapper(key, value))1579 });15801581 Ok(properties)1582 }15831584 fn map_unique_err_to_proxy(err: DispatchError) -> DispatchError {1585 map_unique_err_to_proxy! {1586 match err {1587 CommonError::NoPermission => NoPermission,1588 CommonError::CollectionTokenLimitExceeded => CollectionFullOrLocked,1589 CommonError::PublicMintingNotAllowed => NoPermission,1590 CommonError::TokenNotFound => NoAvailableNftId,1591 CommonError::ApprovedValueTooLow => NoPermission,1592 CommonError::CantDestroyNotEmptyCollection => CollectionNotEmpty,1593 StructureError::TokenNotFound => NoAvailableNftId,1594 StructureError::OuroborosDetected => CannotSendToDescendentOrSelf,1595 }1596 }1597 }1598}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use frame_support::{pallet_prelude::*, transactional, BoundedVec, dispatch::DispatchResult};20use frame_system::{pallet_prelude::*, ensure_signed};21use sp_runtime::{DispatchError, Permill, traits::StaticLookup};22use sp_std::vec::Vec;23use up_data_structs::{*, mapping::TokenAddressMapping};24use pallet_common::{25 Pallet as PalletCommon, Error as CommonError, CollectionHandle, CommonCollectionOperations,26};27use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle, TokenData};28use pallet_structure::{Pallet as PalletStructure, Error as StructureError};29use pallet_evm::account::CrossAccountId;30use core::convert::AsRef;3132pub use pallet::*;3334#[cfg(feature = "runtime-benchmarks")]35pub mod benchmarking;36pub mod misc;37pub mod property;38pub mod weights;3940pub type SelfWeightOf<T> = <T as Config>::WeightInfo;4142use weights::WeightInfo;43use misc::*;44pub use property::*;4546use RmrkProperty::*;4748pub const NESTING_BUDGET: u32 = 5;4950#[frame_support::pallet]51pub mod pallet {52 use super::*;53 use pallet_evm::account;5455 #[pallet::config]56 pub trait Config:57 frame_system::Config + pallet_common::Config + pallet_nonfungible::Config + account::Config58 {59 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;60 type WeightInfo: WeightInfo;61 }6263 #[pallet::storage]64 #[pallet::getter(fn collection_index)]65 pub type CollectionIndex<T: Config> = StorageValue<_, RmrkCollectionId, ValueQuery>;6667 #[pallet::storage]68 pub type UniqueCollectionId<T: Config> =69 StorageMap<_, Twox64Concat, RmrkCollectionId, CollectionId, ValueQuery>;7071 #[pallet::pallet]72 #[pallet::generate_store(pub(super) trait Store)]73 pub struct Pallet<T>(_);7475 #[pallet::event]76 #[pallet::generate_deposit(pub(super) fn deposit_event)]77 pub enum Event<T: Config> {78 CollectionCreated {79 issuer: T::AccountId,80 collection_id: RmrkCollectionId,81 },82 CollectionDestroyed {83 issuer: T::AccountId,84 collection_id: RmrkCollectionId,85 },86 IssuerChanged {87 old_issuer: T::AccountId,88 new_issuer: T::AccountId,89 collection_id: RmrkCollectionId,90 },91 CollectionLocked {92 issuer: T::AccountId,93 collection_id: RmrkCollectionId,94 },95 NftMinted {96 owner: T::AccountId,97 collection_id: RmrkCollectionId,98 nft_id: RmrkNftId,99 },100 NFTBurned {101 owner: T::AccountId,102 nft_id: RmrkNftId,103 },104 NFTSent {105 sender: T::AccountId,106 recipient: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,107 collection_id: RmrkCollectionId,108 nft_id: RmrkNftId,109 approval_required: bool,110 },111 NFTAccepted {112 sender: T::AccountId,113 recipient: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,114 collection_id: RmrkCollectionId,115 nft_id: RmrkNftId,116 },117 NFTRejected {118 sender: T::AccountId,119 collection_id: RmrkCollectionId,120 nft_id: RmrkNftId,121 },122 PropertySet {123 collection_id: RmrkCollectionId,124 maybe_nft_id: Option<RmrkNftId>,125 key: RmrkKeyString,126 value: RmrkValueString,127 },128 ResourceAdded {129 nft_id: RmrkNftId,130 resource_id: RmrkResourceId,131 },132 ResourceRemoval {133 nft_id: RmrkNftId,134 resource_id: RmrkResourceId,135 },136 ResourceAccepted {137 nft_id: RmrkNftId,138 resource_id: RmrkResourceId,139 },140 ResourceRemovalAccepted {141 nft_id: RmrkNftId,142 resource_id: RmrkResourceId,143 },144 PrioritySet {145 collection_id: RmrkCollectionId,146 nft_id: RmrkNftId,147 },148 }149150 #[pallet::error]151 pub enum Error<T> {152 /* Unique-specific events */153 CorruptedCollectionType,154 NftTypeEncodeError,155 RmrkPropertyKeyIsTooLong,156 RmrkPropertyValueIsTooLong,157 UnableToDecodeRmrkData,158159 /* RMRK compatible events */160 CollectionNotEmpty,161 NoAvailableCollectionId,162 NoAvailableNftId,163 CollectionUnknown,164 NoPermission,165 NonTransferable,166 CollectionFullOrLocked,167 ResourceDoesntExist,168 CannotSendToDescendentOrSelf,169 CannotAcceptNonOwnedNft,170 CannotRejectNonOwnedNft,171 ResourceNotPending,172 }173174 #[pallet::call]175 impl<T: Config> Pallet<T> {176 /// Create a collection177 #[transactional]178 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]179 pub fn create_collection(180 origin: OriginFor<T>,181 metadata: RmrkString,182 max: Option<u32>,183 symbol: RmrkCollectionSymbol,184 ) -> DispatchResult {185 let sender = ensure_signed(origin)?;186187 let limits = CollectionLimits {188 owner_can_transfer: Some(false),189 token_limit: max,190 ..Default::default()191 };192193 let data = CreateCollectionData {194 limits: Some(limits),195 token_prefix: symbol196 .into_inner()197 .try_into()198 .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,199 permissions: Some(CollectionPermissions {200 nesting: Some(NestingPermissions {201 token_owner: true,202 collection_admin: false,203 restricted: None,204205 permissive: false,206 }),207 ..Default::default()208 }),209 ..Default::default()210 };211212 let unique_collection_id = Self::init_collection(213 T::CrossAccountId::from_sub(sender.clone()),214 data,215 [216 Self::rmrk_property(Metadata, &metadata)?,217 Self::rmrk_property(CollectionType, &misc::CollectionType::Regular)?,218 ]219 .into_iter(),220 )?;221 let rmrk_collection_id = <CollectionIndex<T>>::get();222223 <UniqueCollectionId<T>>::insert(rmrk_collection_id, unique_collection_id);224225 <PalletCommon<T>>::set_scoped_collection_property(226 unique_collection_id,227 PropertyScope::Rmrk,228 Self::rmrk_property(RmrkInternalCollectionId, &rmrk_collection_id)?,229 )?;230231 <CollectionIndex<T>>::mutate(|n| *n += 1);232233 Self::deposit_event(Event::CollectionCreated {234 issuer: sender,235 collection_id: rmrk_collection_id,236 });237238 Ok(())239 }240241 /// destroy collection242 #[transactional]243 #[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]244 pub fn destroy_collection(245 origin: OriginFor<T>,246 collection_id: RmrkCollectionId,247 ) -> DispatchResult {248 let sender = ensure_signed(origin)?;249 let cross_sender = T::CrossAccountId::from_sub(sender.clone());250251 let collection = Self::get_typed_nft_collection(252 Self::unique_collection_id(collection_id)?,253 misc::CollectionType::Regular,254 )?;255 collection.check_is_external()?;256257 <PalletNft<T>>::destroy_collection(collection, &cross_sender)258 .map_err(Self::map_unique_err_to_proxy)?;259260 Self::deposit_event(Event::CollectionDestroyed {261 issuer: sender,262 collection_id,263 });264265 Ok(())266 }267268 /// Change the issuer of a collection269 ///270 /// Parameters:271 /// - `origin`: sender of the transaction272 /// - `collection_id`: collection id of the nft to change issuer of273 /// - `new_issuer`: Collection's new issuer274 #[transactional]275 #[pallet::weight(<SelfWeightOf<T>>::change_collection_issuer())]276 pub fn change_collection_issuer(277 origin: OriginFor<T>,278 collection_id: RmrkCollectionId,279 new_issuer: <T::Lookup as StaticLookup>::Source,280 ) -> DispatchResult {281 let sender = ensure_signed(origin)?;282283 let collection = Self::get_nft_collection(Self::unique_collection_id(collection_id)?)?;284 collection.check_is_external()?;285286 let new_issuer = T::Lookup::lookup(new_issuer)?;287288 Self::change_collection_owner(289 Self::unique_collection_id(collection_id)?,290 misc::CollectionType::Regular,291 sender.clone(),292 new_issuer.clone(),293 )?;294295 Self::deposit_event(Event::IssuerChanged {296 old_issuer: sender,297 new_issuer,298 collection_id,299 });300301 Ok(())302 }303304 /// lock collection305 #[transactional]306 #[pallet::weight(<SelfWeightOf<T>>::lock_collection())]307 pub fn lock_collection(308 origin: OriginFor<T>,309 collection_id: RmrkCollectionId,310 ) -> DispatchResult {311 let sender = ensure_signed(origin)?;312 let cross_sender = T::CrossAccountId::from_sub(sender.clone());313314 let collection = Self::get_typed_nft_collection(315 Self::unique_collection_id(collection_id)?,316 misc::CollectionType::Regular,317 )?;318 collection.check_is_external()?;319320 Self::check_collection_owner(&collection, &cross_sender)?;321322 let token_count = collection.total_supply();323324 let mut collection = collection.into_inner();325 collection.limits.token_limit = Some(token_count);326 collection.save()?;327328 Self::deposit_event(Event::CollectionLocked {329 issuer: sender,330 collection_id,331 });332333 Ok(())334 }335336 /// Mints an NFT in the specified collection337 /// Sets metadata and the royalty attribute338 ///339 /// Parameters:340 /// - `collection_id`: The class of the asset to be minted.341 /// - `nft_id`: The nft value of the asset to be minted.342 /// - `recipient`: Receiver of the royalty343 /// - `royalty`: Permillage reward from each trade for the Recipient344 /// - `metadata`: Arbitrary data about an nft, e.g. IPFS hash345 /// - `transferable`: Ability to transfer this NFT346 #[transactional]347 #[pallet::weight(<SelfWeightOf<T>>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))]348 pub fn mint_nft(349 origin: OriginFor<T>,350 owner: T::AccountId,351 collection_id: RmrkCollectionId,352 recipient: Option<T::AccountId>,353 royalty_amount: Option<Permill>,354 metadata: RmrkString,355 transferable: bool,356 resources: Option<BoundedVec<RmrkResourceTypes, MaxResourcesOnMint>>,357 ) -> DispatchResult {358 let sender = ensure_signed(origin)?;359 let cross_sender = T::CrossAccountId::from_sub(sender.clone());360 let cross_owner = T::CrossAccountId::from_sub(owner.clone());361362 let collection = Self::get_typed_nft_collection(363 Self::unique_collection_id(collection_id)?,364 misc::CollectionType::Regular,365 )?;366 collection.check_is_external()?;367368 let royalty_info = royalty_amount.map(|amount| rmrk_traits::RoyaltyInfo {369 recipient: recipient.unwrap_or_else(|| owner.clone()),370 amount,371 });372373 let nft_id = Self::create_nft(374 &cross_sender,375 &cross_owner,376 &collection,377 [378 Self::rmrk_property(TokenType, &NftType::Regular)?,379 Self::rmrk_property(Transferable, &transferable)?,380 Self::rmrk_property(PendingNftAccept, &false)?,381 Self::rmrk_property(RoyaltyInfo, &royalty_info)?,382 Self::rmrk_property(Metadata, &metadata)?,383 Self::rmrk_property(Equipped, &false)?,384 Self::rmrk_property(ResourceCollection, &None::<CollectionId>)?,385 Self::rmrk_property(ResourcePriorities, &<Vec<u8>>::new())?,386 ]387 .into_iter(),388 )389 .map_err(|err| match err {390 DispatchError::Arithmetic(_) => <Error<T>>::NoAvailableNftId.into(),391 err => Self::map_unique_err_to_proxy(err),392 })?;393394 if let Some(resources) = resources {395 for resource in resources {396 Self::resource_add(sender.clone(), collection.id, nft_id, resource)?;397 }398 }399400 Self::deposit_event(Event::NftMinted {401 owner,402 collection_id,403 nft_id: nft_id.0,404 });405406 Ok(())407 }408409 /// burn nft410 #[transactional]411 #[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]412 pub fn burn_nft(413 origin: OriginFor<T>,414 collection_id: RmrkCollectionId,415 nft_id: RmrkNftId,416 max_burns: u32,417 ) -> DispatchResult {418 let sender = ensure_signed(origin)?;419 let cross_sender = T::CrossAccountId::from_sub(sender.clone());420421 let collection = Self::get_typed_nft_collection(422 Self::unique_collection_id(collection_id)?,423 misc::CollectionType::Regular,424 )?;425 collection.check_is_external()?;426427 Self::destroy_nft(428 cross_sender,429 Self::unique_collection_id(collection_id)?,430 nft_id.into(),431 max_burns,432 <Error<T>>::NoPermission,433 )434 .map_err(|err| Self::map_unique_err_to_proxy(err.error))?;435436 Self::deposit_event(Event::NFTBurned {437 owner: sender,438 nft_id,439 });440441 Ok(())442 }443444 /// Transfers a NFT from an Account or NFT A to another Account or NFT B445 ///446 /// Parameters:447 /// - `origin`: sender of the transaction448 /// - `rmrk_collection_id`: collection id of the nft to be transferred449 /// - `rmrk_nft_id`: nft id of the nft to be transferred450 /// - `new_owner`: new owner of the nft which can be either an account or a NFT451 #[transactional]452 #[pallet::weight(<SelfWeightOf<T>>::send())]453 pub fn send(454 origin: OriginFor<T>,455 rmrk_collection_id: RmrkCollectionId,456 rmrk_nft_id: RmrkNftId,457 new_owner: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,458 ) -> DispatchResult {459 let sender = ensure_signed(origin.clone())?;460 let cross_sender = T::CrossAccountId::from_sub(sender.clone());461462 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;463 let nft_id = rmrk_nft_id.into();464465 let collection =466 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;467 collection.check_is_external()?;468469 let token_data =470 <TokenData<T>>::get((collection_id, nft_id)).ok_or(<Error<T>>::NoAvailableNftId)?;471472 let from = token_data.owner;473474 ensure!(475 Self::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::Transferable)?,476 <Error<T>>::NonTransferable477 );478479 ensure!(480 !Self::get_nft_property_decoded(481 collection_id,482 nft_id,483 RmrkProperty::PendingNftAccept484 )?,485 <Error<T>>::NoPermission486 );487488 let target_owner;489 let approval_required;490491 match new_owner {492 RmrkAccountIdOrCollectionNftTuple::AccountId(ref account_id) => {493 target_owner = T::CrossAccountId::from_sub(account_id.clone());494 approval_required = false;495 }496 RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(497 target_collection_id,498 target_nft_id,499 ) => {500 let target_collection_id = Self::unique_collection_id(target_collection_id)?;501502 let target_nft_budget = budget::Value::new(NESTING_BUDGET);503504 let target_nft_owner = <PalletStructure<T>>::get_checked_topmost_owner(505 target_collection_id,506 target_nft_id.into(),507 Some((collection_id, nft_id)),508 &target_nft_budget,509 )510 .map_err(Self::map_unique_err_to_proxy)?;511512 approval_required = cross_sender != target_nft_owner;513514 if approval_required {515 target_owner = target_nft_owner;516517 <PalletNft<T>>::set_scoped_token_property(518 collection.id,519 nft_id,520 PropertyScope::Rmrk,521 Self::rmrk_property(PendingNftAccept, &approval_required)?,522 )?;523 } else {524 target_owner = T::CrossTokenAddressMapping::token_to_address(525 target_collection_id,526 target_nft_id.into(),527 );528 }529 }530 }531532 let src_nft_budget = budget::Value::new(NESTING_BUDGET);533534 <PalletNft<T>>::transfer_from(535 &collection,536 &cross_sender,537 &from,538 &target_owner,539 nft_id,540 &src_nft_budget,541 )542 .map_err(Self::map_unique_err_to_proxy)?;543544 Self::deposit_event(Event::NFTSent {545 sender,546 recipient: new_owner,547 collection_id: rmrk_collection_id,548 nft_id: rmrk_nft_id,549 approval_required,550 });551552 Ok(())553 }554555 /// Accepts an NFT sent from another account to self or owned NFT556 ///557 /// Parameters:558 /// - `origin`: sender of the transaction559 /// - `rmrk_collection_id`: collection id of the nft to be accepted560 /// - `rmrk_nft_id`: nft id of the nft to be accepted561 /// - `new_owner`: either origin's account ID or origin-owned NFT, whichever the NFT was562 /// sent to563 #[transactional]564 #[pallet::weight(<SelfWeightOf<T>>::accept_nft())]565 pub fn accept_nft(566 origin: OriginFor<T>,567 rmrk_collection_id: RmrkCollectionId,568 rmrk_nft_id: RmrkNftId,569 new_owner: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,570 ) -> DispatchResult {571 let sender = ensure_signed(origin.clone())?;572 let cross_sender = T::CrossAccountId::from_sub(sender.clone());573574 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;575 let nft_id = rmrk_nft_id.into();576577 let collection =578 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;579 collection.check_is_external()?;580581 let new_cross_owner = match new_owner {582 RmrkAccountIdOrCollectionNftTuple::AccountId(ref account_id) => {583 T::CrossAccountId::from_sub(account_id.clone())584 }585 RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(586 target_collection_id,587 target_nft_id,588 ) => {589 let target_collection_id = Self::unique_collection_id(target_collection_id)?;590591 T::CrossTokenAddressMapping::token_to_address(592 target_collection_id,593 TokenId(target_nft_id),594 )595 }596 };597598 let budget = budget::Value::new(NESTING_BUDGET);599600 <PalletNft<T>>::transfer(601 &collection,602 &cross_sender,603 &new_cross_owner,604 nft_id,605 &budget,606 )607 .map_err(|err| {608 if err == <CommonError<T>>::UserIsNotAllowedToNest.into() {609 <Error<T>>::CannotAcceptNonOwnedNft.into()610 } else {611 Self::map_unique_err_to_proxy(err)612 }613 })?;614615 <PalletNft<T>>::set_scoped_token_property(616 collection.id,617 nft_id,618 PropertyScope::Rmrk,619 Self::rmrk_property(PendingNftAccept, &false)?,620 )?;621622 Self::deposit_event(Event::NFTAccepted {623 sender,624 recipient: new_owner,625 collection_id: rmrk_collection_id,626 nft_id: rmrk_nft_id,627 });628629 Ok(())630 }631632 /// Rejects an NFT sent from another account to self or owned NFT633 ///634 /// Parameters:635 /// - `origin`: sender of the transaction636 /// - `rmrk_collection_id`: collection id of the nft to be accepted637 /// - `rmrk_nft_id`: nft id of the nft to be accepted638 #[transactional]639 #[pallet::weight(<SelfWeightOf<T>>::reject_nft())]640 pub fn reject_nft(641 origin: OriginFor<T>,642 rmrk_collection_id: RmrkCollectionId,643 rmrk_nft_id: RmrkNftId,644 ) -> DispatchResult {645 let sender = ensure_signed(origin)?;646 let cross_sender = T::CrossAccountId::from_sub(sender.clone());647648 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;649 let nft_id = rmrk_nft_id.into();650651 let collection =652 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;653 collection.check_is_external()?;654655 ensure!(656 Self::get_nft_property_decoded(657 collection_id,658 nft_id,659 RmrkProperty::PendingNftAccept660 )?,661 <Error<T>>::NoPermission662 );663664 Self::destroy_nft(665 cross_sender,666 collection_id,667 nft_id,668 NESTING_BUDGET,669 <Error<T>>::CannotRejectNonOwnedNft,670 )671 .map_err(|err| Self::map_unique_err_to_proxy(err.error))?;672673 Self::deposit_event(Event::NFTRejected {674 sender,675 collection_id: rmrk_collection_id,676 nft_id: rmrk_nft_id,677 });678679 Ok(())680 }681682 /// accept the addition of a new resource to an existing NFT683 #[transactional]684 #[pallet::weight(<SelfWeightOf<T>>::accept_resource())]685 pub fn accept_resource(686 origin: OriginFor<T>,687 rmrk_collection_id: RmrkCollectionId,688 rmrk_nft_id: RmrkNftId,689 rmrk_resource_id: RmrkResourceId,690 ) -> DispatchResult {691 let sender = ensure_signed(origin)?;692 let cross_sender = T::CrossAccountId::from_sub(sender);693694 let collection_id = Self::unique_collection_id(rmrk_collection_id)695 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;696 let collection =697 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;698 collection.check_is_external()?;699700 let nft_id = rmrk_nft_id.into();701 let resource_id = rmrk_resource_id.into();702703 let budget = budget::Value::new(NESTING_BUDGET);704705 let nft_owner =706 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)707 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;708709 let resource_collection_id: Option<CollectionId> =710 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)711 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;712713 let resource_collection_id =714 resource_collection_id.ok_or(<Error<T>>::ResourceDoesntExist)?;715716 let is_pending: bool = Self::get_nft_property_decoded(717 resource_collection_id,718 resource_id,719 PendingResourceAccept,720 )721 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;722723 ensure!(is_pending, <Error<T>>::ResourceNotPending);724725 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);726727 <PalletNft<T>>::set_scoped_token_property(728 resource_collection_id,729 rmrk_resource_id.into(),730 PropertyScope::Rmrk,731 Self::rmrk_property(PendingResourceAccept, &false)?,732 )?;733734 Self::deposit_event(Event::<T>::ResourceAccepted {735 nft_id: rmrk_nft_id,736 resource_id: rmrk_resource_id,737 });738739 Ok(())740 }741742 /// accept the removal of a resource of an existing NFT743 #[transactional]744 #[pallet::weight(<SelfWeightOf<T>>::accept_resource_removal())]745 pub fn accept_resource_removal(746 origin: OriginFor<T>,747 rmrk_collection_id: RmrkCollectionId,748 rmrk_nft_id: RmrkNftId,749 rmrk_resource_id: RmrkResourceId,750 ) -> DispatchResult {751 let sender = ensure_signed(origin)?;752 let cross_sender = T::CrossAccountId::from_sub(sender);753754 let collection_id = Self::unique_collection_id(rmrk_collection_id)755 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;756 let collection =757 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;758 collection.check_is_external()?;759760 let nft_id = rmrk_nft_id.into();761 let resource_id = rmrk_resource_id.into();762763 let budget = budget::Value::new(NESTING_BUDGET);764765 let nft_owner =766 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)767 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;768769 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);770771 let resource_collection_id: Option<CollectionId> =772 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)773 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;774775 let resource_collection_id =776 resource_collection_id.ok_or(<Error<T>>::ResourceDoesntExist)?;777778 let is_pending: bool = Self::get_nft_property_decoded(779 resource_collection_id,780 resource_id,781 PendingResourceRemoval,782 )783 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;784785 ensure!(is_pending, <Error<T>>::ResourceNotPending);786787 let resource_collection = Self::get_typed_nft_collection(788 resource_collection_id,789 misc::CollectionType::Resource,790 )?;791792 let resource_data = <TokenData<T>>::get((resource_collection_id, resource_id))793 .ok_or(<Error<T>>::ResourceDoesntExist)?;794795 let resource_owner = resource_data.owner;796797 <PalletNft<T>>::burn(798 &resource_collection,799 &resource_owner,800 rmrk_resource_id.into(),801 )802 .map_err(Self::map_unique_err_to_proxy)?;803804 Self::deposit_event(Event::<T>::ResourceRemovalAccepted {805 nft_id: rmrk_nft_id,806 resource_id: rmrk_resource_id,807 });808809 Ok(())810 }811812 /// set a custom value on an NFT813 #[transactional]814 #[pallet::weight(<SelfWeightOf<T>>::set_property())]815 pub fn set_property(816 origin: OriginFor<T>,817 #[pallet::compact] rmrk_collection_id: RmrkCollectionId,818 maybe_nft_id: Option<RmrkNftId>,819 key: RmrkKeyString,820 value: RmrkValueString,821 ) -> DispatchResult {822 let sender = ensure_signed(origin)?;823 let sender = T::CrossAccountId::from_sub(sender);824825 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;826 let collection =827 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;828 collection.check_is_external()?;829830 let budget = budget::Value::new(NESTING_BUDGET);831832 match maybe_nft_id {833 Some(nft_id) => {834 let token_id: TokenId = nft_id.into();835836 Self::ensure_nft_type(collection_id, token_id, NftType::Regular)?;837 Self::ensure_nft_owner(collection_id, token_id, &sender, &budget)?;838839 <PalletNft<T>>::set_scoped_token_property(840 collection_id,841 token_id,842 PropertyScope::Rmrk,843 Self::rmrk_property(UserProperty(key.as_slice()), &value)?,844 )?;845 }846 None => {847 let collection = Self::get_typed_nft_collection(848 collection_id,849 misc::CollectionType::Regular,850 )?;851852 Self::check_collection_owner(&collection, &sender)?;853854 <PalletCommon<T>>::set_scoped_collection_property(855 collection_id,856 PropertyScope::Rmrk,857 Self::rmrk_property(UserProperty(key.as_slice()), &value)?,858 )?;859 }860 }861862 Self::deposit_event(Event::PropertySet {863 collection_id: rmrk_collection_id,864 maybe_nft_id,865 key,866 value,867 });868869 Ok(())870 }871872 /// set a different order of resource priority873 #[transactional]874 #[pallet::weight(<SelfWeightOf<T>>::set_priority())]875 pub fn set_priority(876 origin: OriginFor<T>,877 rmrk_collection_id: RmrkCollectionId,878 rmrk_nft_id: RmrkNftId,879 priorities: BoundedVec<RmrkResourceId, RmrkMaxPriorities>,880 ) -> DispatchResult {881 let sender = ensure_signed(origin)?;882 let sender = T::CrossAccountId::from_sub(sender);883884 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;885 let nft_id = rmrk_nft_id.into();886887 let collection =888 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;889 collection.check_is_external()?;890891 let budget = budget::Value::new(NESTING_BUDGET);892893 Self::ensure_nft_type(collection_id, nft_id, NftType::Regular)?;894 Self::ensure_nft_owner(collection_id, nft_id, &sender, &budget)?;895896 <PalletNft<T>>::set_scoped_token_property(897 collection_id,898 nft_id,899 PropertyScope::Rmrk,900 Self::rmrk_property(ResourcePriorities, &priorities.into_inner())?,901 )?;902903 Self::deposit_event(Event::<T>::PrioritySet {904 collection_id: rmrk_collection_id,905 nft_id: rmrk_nft_id,906 });907908 Ok(())909 }910911 /// Create basic resource912 #[transactional]913 #[pallet::weight(<SelfWeightOf<T>>::add_basic_resource())]914 pub fn add_basic_resource(915 origin: OriginFor<T>,916 rmrk_collection_id: RmrkCollectionId,917 nft_id: RmrkNftId,918 resource: RmrkBasicResource,919 ) -> DispatchResult {920 let sender = ensure_signed(origin.clone())?;921922 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;923 let collection =924 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;925 collection.check_is_external()?;926927 let resource_id = Self::resource_add(928 sender,929 collection_id,930 nft_id.into(),931 RmrkResourceTypes::Basic(resource),932 )?;933934 Self::deposit_event(Event::ResourceAdded {935 nft_id,936 resource_id,937 });938 Ok(())939 }940941 /// Create composable resource942 #[transactional]943 #[pallet::weight(<SelfWeightOf<T>>::add_composable_resource())]944 pub fn add_composable_resource(945 origin: OriginFor<T>,946 rmrk_collection_id: RmrkCollectionId,947 nft_id: RmrkNftId,948 resource: RmrkComposableResource,949 ) -> DispatchResult {950 let sender = ensure_signed(origin.clone())?;951952 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;953 let collection =954 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;955 collection.check_is_external()?;956957 let resource_id = Self::resource_add(958 sender,959 collection_id,960 nft_id.into(),961 RmrkResourceTypes::Composable(resource),962 )?;963964 Self::deposit_event(Event::ResourceAdded {965 nft_id,966 resource_id,967 });968 Ok(())969 }970971 /// Create slot resource972 #[transactional]973 #[pallet::weight(<SelfWeightOf<T>>::add_slot_resource())]974 pub fn add_slot_resource(975 origin: OriginFor<T>,976 rmrk_collection_id: RmrkCollectionId,977 nft_id: RmrkNftId,978 resource: RmrkSlotResource,979 ) -> DispatchResult {980 let sender = ensure_signed(origin.clone())?;981982 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;983 let collection =984 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;985 collection.check_is_external()?;986987 let resource_id = Self::resource_add(988 sender,989 collection_id,990 nft_id.into(),991 RmrkResourceTypes::Slot(resource),992 )?;993994 Self::deposit_event(Event::ResourceAdded {995 nft_id,996 resource_id,997 });998 Ok(())999 }10001001 /// remove resource1002 #[transactional]1003 #[pallet::weight(<SelfWeightOf<T>>::remove_resource())]1004 pub fn remove_resource(1005 origin: OriginFor<T>,1006 rmrk_collection_id: RmrkCollectionId,1007 nft_id: RmrkNftId,1008 resource_id: RmrkResourceId,1009 ) -> DispatchResult {1010 let sender = ensure_signed(origin.clone())?;10111012 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;1013 let collection =1014 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1015 collection.check_is_external()?;10161017 Self::resource_remove(sender, collection_id, nft_id.into(), resource_id.into())?;10181019 Self::deposit_event(Event::ResourceRemoval {1020 nft_id,1021 resource_id,1022 });1023 Ok(())1024 }1025 }1026}10271028impl<T: Config> Pallet<T> {1029 pub fn rmrk_property_key(rmrk_key: RmrkProperty) -> Result<PropertyKey, DispatchError> {1030 let key = rmrk_key.to_key::<T>()?;10311032 let scoped_key = PropertyScope::Rmrk1033 .apply(key)1034 .map_err(|_| <Error<T>>::RmrkPropertyKeyIsTooLong)?;10351036 Ok(scoped_key)1037 }10381039 // todo think about renaming these1040 pub fn rmrk_property<E: Encode>(1041 rmrk_key: RmrkProperty,1042 value: &E,1043 ) -> Result<Property, DispatchError> {1044 let key = rmrk_key.to_key::<T>()?;10451046 let value = value1047 .encode()1048 .try_into()1049 .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong)?;10501051 let property = Property { key, value };10521053 Ok(property)1054 }10551056 pub fn decode_property<D: Decode>(vec: PropertyValue) -> Result<D, DispatchError> {1057 vec.decode()1058 .map_err(|_| <Error<T>>::UnableToDecodeRmrkData.into())1059 }10601061 pub fn rebind<L, S>(vec: &BoundedVec<u8, L>) -> Result<BoundedVec<u8, S>, DispatchError>1062 where1063 BoundedVec<u8, S>: TryFrom<Vec<u8>>,1064 {1065 vec.rebind()1066 .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong.into())1067 }10681069 fn init_collection(1070 sender: T::CrossAccountId,1071 data: CreateCollectionData<T::AccountId>,1072 properties: impl Iterator<Item = Property>,1073 ) -> Result<CollectionId, DispatchError> {1074 let collection_id = <PalletNft<T>>::init_collection(sender, data, true);10751076 if let Err(DispatchError::Arithmetic(_)) = &collection_id {1077 return Err(<Error<T>>::NoAvailableCollectionId.into());1078 }10791080 <PalletCommon<T>>::set_scoped_collection_properties(1081 collection_id?,1082 PropertyScope::Rmrk,1083 properties,1084 )?;10851086 collection_id1087 }10881089 pub fn create_nft(1090 sender: &T::CrossAccountId,1091 owner: &T::CrossAccountId,1092 collection: &NonfungibleHandle<T>,1093 properties: impl Iterator<Item = Property>,1094 ) -> Result<TokenId, DispatchError> {1095 let data = CreateNftExData {1096 properties: BoundedVec::default(),1097 owner: owner.clone(),1098 };10991100 let budget = budget::Value::new(NESTING_BUDGET);11011102 <PalletNft<T>>::create_item(collection, sender, data, &budget)?;11031104 let nft_id = <PalletNft<T>>::current_token_id(collection.id);11051106 <PalletNft<T>>::set_scoped_token_properties(1107 collection.id,1108 nft_id,1109 PropertyScope::Rmrk,1110 properties,1111 )?;11121113 Ok(nft_id)1114 }11151116 fn destroy_nft(1117 sender: T::CrossAccountId,1118 collection_id: CollectionId,1119 token_id: TokenId,1120 max_burns: u32,1121 error_if_not_owned: Error<T>,1122 ) -> DispatchResultWithPostInfo {1123 let collection =1124 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;11251126 let token_data =1127 <TokenData<T>>::get((collection_id, token_id)).ok_or(<Error<T>>::NoAvailableNftId)?;11281129 let from = token_data.owner;11301131 let owner_check_budget = budget::Value::new(NESTING_BUDGET);11321133 ensure!(1134 <PalletStructure<T>>::check_indirectly_owned(1135 sender.clone(),1136 collection_id,1137 token_id,1138 None,1139 &owner_check_budget1140 )?,1141 error_if_not_owned,1142 );11431144 let burns_budget = budget::Value::new(max_burns);1145 let breadth_budget = budget::Value::new(max_burns);11461147 <PalletNft<T>>::burn_recursively(1148 &collection,1149 &from,1150 token_id,1151 &burns_budget,1152 &breadth_budget,1153 )1154 }11551156 fn resource_add(1157 sender: T::AccountId,1158 collection_id: CollectionId,1159 nft_id: TokenId,1160 resource: RmrkResourceTypes,1161 ) -> Result<RmrkResourceId, DispatchError> {1162 match resource {1163 RmrkResourceTypes::Basic(resource) => Self::resource_add_helper(1164 sender,1165 collection_id,1166 nft_id,1167 [1168 Self::rmrk_property(TokenType, &NftType::Resource)?,1169 Self::rmrk_property(ResourceType, &misc::ResourceType::Basic)?,1170 Self::rmrk_property(Src, &resource.src)?,1171 Self::rmrk_property(Metadata, &resource.metadata)?,1172 Self::rmrk_property(License, &resource.license)?,1173 Self::rmrk_property(Thumb, &resource.thumb)?,1174 ]1175 .into_iter(),1176 ),1177 RmrkResourceTypes::Composable(resource) => Self::resource_add_helper(1178 sender,1179 collection_id,1180 nft_id.into(),1181 [1182 Self::rmrk_property(TokenType, &NftType::Resource)?,1183 Self::rmrk_property(ResourceType, &misc::ResourceType::Composable)?,1184 Self::rmrk_property(Parts, &resource.parts)?,1185 Self::rmrk_property(Base, &resource.base)?,1186 Self::rmrk_property(Src, &resource.src)?,1187 Self::rmrk_property(Metadata, &resource.metadata)?,1188 Self::rmrk_property(License, &resource.license)?,1189 Self::rmrk_property(Thumb, &resource.thumb)?,1190 ]1191 .into_iter(),1192 ),1193 RmrkResourceTypes::Slot(resource) => Self::resource_add_helper(1194 sender,1195 collection_id,1196 nft_id.into(),1197 [1198 Self::rmrk_property(TokenType, &NftType::Resource)?,1199 Self::rmrk_property(ResourceType, &misc::ResourceType::Slot)?,1200 Self::rmrk_property(Base, &resource.base)?,1201 Self::rmrk_property(Src, &resource.src)?,1202 Self::rmrk_property(Metadata, &resource.metadata)?,1203 Self::rmrk_property(Slot, &resource.slot)?,1204 Self::rmrk_property(License, &resource.license)?,1205 Self::rmrk_property(Thumb, &resource.thumb)?,1206 ]1207 .into_iter(),1208 ),1209 }1210 }12111212 fn resource_add_helper(1213 sender: T::AccountId,1214 collection_id: CollectionId,1215 token_id: TokenId,1216 resource_properties: impl Iterator<Item = Property>,1217 ) -> Result<RmrkResourceId, DispatchError> {1218 let collection =1219 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1220 ensure!(collection.owner == sender, Error::<T>::NoPermission);12211222 let sender = T::CrossAccountId::from_sub(sender);1223 let budget = budget::Value::new(NESTING_BUDGET);12241225 let nft_owner = <PalletStructure<T>>::find_topmost_owner(collection_id, token_id, &budget)1226 .map_err(Self::map_unique_err_to_proxy)?;12271228 let pending = sender != nft_owner;12291230 let resource_collection_id: Option<CollectionId> =1231 Self::get_nft_property_decoded(collection_id, token_id, ResourceCollection)?;12321233 let resource_collection_id = match resource_collection_id {1234 Some(id) => id,1235 None => {1236 let resource_collection_id = Self::init_collection(1237 sender.clone(),1238 CreateCollectionData {1239 ..Default::default()1240 },1241 [Self::rmrk_property(1242 CollectionType,1243 &misc::CollectionType::Resource,1244 )?]1245 .into_iter(),1246 )?;12471248 <PalletNft<T>>::set_scoped_token_property(1249 collection_id,1250 token_id,1251 PropertyScope::Rmrk,1252 Self::rmrk_property(ResourceCollection, &Some(resource_collection_id))?,1253 )?;12541255 resource_collection_id1256 }1257 };12581259 let resource_collection =1260 Self::get_typed_nft_collection(resource_collection_id, misc::CollectionType::Resource)?;12611262 // todo probably add extra connections to bases, slots, etc., when RMRK starts to use them12631264 let resource_id = Self::create_nft(1265 &sender,1266 &nft_owner,1267 &resource_collection,1268 resource_properties.chain(1269 [1270 Self::rmrk_property(PendingResourceAccept, &pending)?,1271 Self::rmrk_property(PendingResourceRemoval, &false)?,1272 ]1273 .into_iter(),1274 ),1275 )1276 .map_err(|err| match err {1277 DispatchError::Arithmetic(_) => <Error<T>>::NoAvailableNftId.into(),1278 err => Self::map_unique_err_to_proxy(err),1279 })?;12801281 Ok(resource_id.0)1282 }12831284 fn resource_remove(1285 sender: T::AccountId,1286 collection_id: CollectionId,1287 nft_id: TokenId,1288 resource_id: TokenId,1289 ) -> DispatchResult {1290 let collection =1291 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1292 ensure!(collection.owner == sender, Error::<T>::NoPermission);12931294 let resource_collection_id: Option<CollectionId> =1295 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)?;12961297 let resource_collection_id =1298 resource_collection_id.ok_or(Error::<T>::ResourceDoesntExist)?;12991300 let resource_collection =1301 Self::get_typed_nft_collection(resource_collection_id, misc::CollectionType::Resource)?;1302 ensure!(1303 <PalletNft<T>>::token_exists(&resource_collection, resource_id),1304 Error::<T>::ResourceDoesntExist1305 );13061307 let budget = up_data_structs::budget::Value::new(NESTING_BUDGET);1308 let topmost_owner =1309 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)?;13101311 let sender = T::CrossAccountId::from_sub(sender);1312 if topmost_owner == sender {1313 <PalletNft<T>>::burn(&resource_collection, &sender, resource_id)1314 .map_err(Self::map_unique_err_to_proxy)?;1315 } else {1316 <PalletNft<T>>::set_scoped_token_property(1317 resource_collection_id,1318 resource_id,1319 PropertyScope::Rmrk,1320 Self::rmrk_property(PendingResourceRemoval, &true)?,1321 )?;1322 }13231324 Ok(())1325 }13261327 fn change_collection_owner(1328 collection_id: CollectionId,1329 collection_type: misc::CollectionType,1330 sender: T::AccountId,1331 new_owner: T::AccountId,1332 ) -> DispatchResult {1333 let collection = Self::get_typed_nft_collection(collection_id, collection_type)?;1334 Self::check_collection_owner(&collection, &T::CrossAccountId::from_sub(sender))?;13351336 let mut collection = collection.into_inner();13371338 collection.owner = new_owner;1339 collection.save()1340 }13411342 fn check_collection_owner(1343 collection: &NonfungibleHandle<T>,1344 account: &T::CrossAccountId,1345 ) -> DispatchResult {1346 collection1347 .check_is_owner(account)1348 .map_err(Self::map_unique_err_to_proxy)1349 }13501351 pub fn last_collection_idx() -> RmrkCollectionId {1352 <CollectionIndex<T>>::get()1353 }13541355 pub fn unique_collection_id(1356 rmrk_collection_id: RmrkCollectionId,1357 ) -> Result<CollectionId, DispatchError> {1358 <UniqueCollectionId<T>>::try_get(rmrk_collection_id)1359 .map_err(|_| <Error<T>>::CollectionUnknown.into())1360 }13611362 pub fn rmrk_collection_id(1363 unique_collection_id: CollectionId,1364 ) -> Result<RmrkCollectionId, DispatchError> {1365 Self::get_collection_property_decoded(unique_collection_id, RmrkInternalCollectionId)1366 }13671368 pub fn get_nft_collection(1369 collection_id: CollectionId,1370 ) -> Result<NonfungibleHandle<T>, DispatchError> {1371 let collection = <CollectionHandle<T>>::try_get(collection_id)1372 .map_err(|_| <Error<T>>::CollectionUnknown)?;13731374 match collection.mode {1375 CollectionMode::NFT => Ok(NonfungibleHandle::cast(collection)),1376 _ => Err(<Error<T>>::CollectionUnknown.into()),1377 }1378 }13791380 pub fn collection_exists(collection_id: CollectionId) -> bool {1381 <CollectionHandle<T>>::try_get(collection_id).is_ok()1382 }13831384 pub fn get_collection_property(1385 collection_id: CollectionId,1386 key: RmrkProperty,1387 ) -> Result<PropertyValue, DispatchError> {1388 let collection_property = <PalletCommon<T>>::collection_properties(collection_id)1389 .get(&Self::rmrk_property_key(key)?)1390 .ok_or(<Error<T>>::CollectionUnknown)?1391 .clone();13921393 Ok(collection_property)1394 }13951396 pub fn get_collection_property_decoded<V: Decode>(1397 collection_id: CollectionId,1398 key: RmrkProperty,1399 ) -> Result<V, DispatchError> {1400 Self::decode_property(Self::get_collection_property(collection_id, key)?)1401 }14021403 pub fn get_collection_type(1404 collection_id: CollectionId,1405 ) -> Result<misc::CollectionType, DispatchError> {1406 Self::get_collection_property_decoded(collection_id, CollectionType)1407 .map_err(|_| <Error<T>>::CorruptedCollectionType.into())1408 }14091410 pub fn ensure_collection_type(1411 collection_id: CollectionId,1412 collection_type: misc::CollectionType,1413 ) -> DispatchResult {1414 let actual_type = Self::get_collection_type(collection_id)?;1415 ensure!(1416 actual_type == collection_type,1417 <CommonError<T>>::NoPermission1418 );14191420 Ok(())1421 }14221423 pub fn get_typed_nft_collection(1424 collection_id: CollectionId,1425 collection_type: misc::CollectionType,1426 ) -> Result<NonfungibleHandle<T>, DispatchError> {1427 Self::ensure_collection_type(collection_id, collection_type)?;14281429 Self::get_nft_collection(collection_id)1430 }14311432 pub fn get_typed_nft_collection_mapped(1433 rmrk_collection_id: RmrkCollectionId,1434 collection_type: misc::CollectionType,1435 ) -> Result<(NonfungibleHandle<T>, CollectionId), DispatchError> {1436 let unique_collection_id = match collection_type {1437 misc::CollectionType::Regular => Self::unique_collection_id(rmrk_collection_id)?,1438 _ => rmrk_collection_id.into(),1439 };14401441 let collection = Self::get_typed_nft_collection(unique_collection_id, collection_type)?;14421443 Ok((collection, unique_collection_id))1444 }14451446 pub fn get_nft_property(1447 collection_id: CollectionId,1448 nft_id: TokenId,1449 key: RmrkProperty,1450 ) -> Result<PropertyValue, DispatchError> {1451 let nft_property = <PalletNft<T>>::token_properties((collection_id, nft_id))1452 .get(&Self::rmrk_property_key(key)?)1453 .ok_or(<Error<T>>::NoAvailableNftId)? // todo replace with better error?1454 .clone();14551456 Ok(nft_property)1457 }14581459 pub fn get_nft_property_decoded<V: Decode>(1460 collection_id: CollectionId,1461 nft_id: TokenId,1462 key: RmrkProperty,1463 ) -> Result<V, DispatchError> {1464 Self::decode_property(Self::get_nft_property(collection_id, nft_id, key)?)1465 }14661467 pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {1468 <TokenData<T>>::contains_key((collection_id, nft_id))1469 }14701471 pub fn get_nft_type(1472 collection_id: CollectionId,1473 token_id: TokenId,1474 ) -> Result<NftType, DispatchError> {1475 Self::get_nft_property_decoded(collection_id, token_id, TokenType)1476 .map_err(|_| <Error<T>>::NoAvailableNftId.into())1477 }14781479 pub fn ensure_nft_type(1480 collection_id: CollectionId,1481 token_id: TokenId,1482 nft_type: NftType,1483 ) -> DispatchResult {1484 let actual_type = Self::get_nft_type(collection_id, token_id)?;1485 ensure!(actual_type == nft_type, <Error<T>>::NoPermission);14861487 Ok(())1488 }14891490 pub fn ensure_nft_owner(1491 collection_id: CollectionId,1492 token_id: TokenId,1493 possible_owner: &T::CrossAccountId,1494 nesting_budget: &dyn budget::Budget,1495 ) -> DispatchResult {1496 let is_owned = <PalletStructure<T>>::check_indirectly_owned(1497 possible_owner.clone(),1498 collection_id,1499 token_id,1500 None,1501 nesting_budget,1502 )1503 .map_err(Self::map_unique_err_to_proxy)?;15041505 ensure!(is_owned, <Error<T>>::NoPermission);15061507 Ok(())1508 }15091510 pub fn filter_user_properties<Key, Value, R, Mapper>(1511 collection_id: CollectionId,1512 token_id: Option<TokenId>,1513 filter_keys: Option<Vec<RmrkPropertyKey>>,1514 mapper: Mapper,1515 ) -> Result<Vec<R>, DispatchError>1516 where1517 Key: TryFrom<RmrkPropertyKey> + AsRef<[u8]>,1518 Value: Decode + Default,1519 Mapper: Fn(Key, Value) -> R,1520 {1521 filter_keys1522 .map(|keys| {1523 let properties = keys1524 .into_iter()1525 .filter_map(|key| {1526 let key: Key = key.try_into().ok()?;15271528 let value = match token_id {1529 Some(token_id) => Self::get_nft_property_decoded(1530 collection_id,1531 token_id,1532 UserProperty(key.as_ref()),1533 ),1534 None => Self::get_collection_property_decoded(1535 collection_id,1536 UserProperty(key.as_ref()),1537 ),1538 }1539 .ok()?;15401541 Some(mapper(key, value))1542 })1543 .collect();15441545 Ok(properties)1546 })1547 .unwrap_or_else(|| {1548 let properties =1549 Self::iterate_user_properties(collection_id, token_id, mapper)?.collect();15501551 Ok(properties)1552 })1553 }15541555 pub fn iterate_user_properties<Key, Value, R, Mapper>(1556 collection_id: CollectionId,1557 token_id: Option<TokenId>,1558 mapper: Mapper,1559 ) -> Result<impl Iterator<Item = R>, DispatchError>1560 where1561 Key: TryFrom<RmrkPropertyKey> + AsRef<[u8]>,1562 Value: Decode + Default,1563 Mapper: Fn(Key, Value) -> R,1564 {1565 let key_prefix = Self::rmrk_property_key(UserProperty(b""))?;15661567 let properties = match token_id {1568 Some(token_id) => <PalletNft<T>>::token_properties((collection_id, token_id)),1569 None => <PalletCommon<T>>::collection_properties(collection_id),1570 };15711572 let properties = properties.into_iter().filter_map(move |(key, value)| {1573 let key = key.as_slice().strip_prefix(key_prefix.as_slice())?;15741575 let key: Key = key.to_vec().try_into().ok()?;1576 let value: Value = value.decode().ok()?;15771578 Some(mapper(key, value))1579 });15801581 Ok(properties)1582 }15831584 fn map_unique_err_to_proxy(err: DispatchError) -> DispatchError {1585 map_unique_err_to_proxy! {1586 match err {1587 CommonError::NoPermission => NoPermission,1588 CommonError::CollectionTokenLimitExceeded => CollectionFullOrLocked,1589 CommonError::PublicMintingNotAllowed => NoPermission,1590 CommonError::TokenNotFound => NoAvailableNftId,1591 CommonError::ApprovedValueTooLow => NoPermission,1592 CommonError::CantDestroyNotEmptyCollection => CollectionNotEmpty,1593 StructureError::TokenNotFound => NoAvailableNftId,1594 StructureError::OuroborosDetected => CannotSendToDescendentOrSelf,1595 }1596 }1597 }1598}primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -447,7 +447,7 @@
pub fn nesting(&self) -> &NestingPermissions {
static DEFAULT: NestingPermissions = NestingPermissions {
token_owner: false,
- admin: false,
+ collection_admin: false,
restricted: None,
permissive: false,
@@ -490,7 +490,7 @@
/// Owner of token can nest tokens under it
pub token_owner: bool,
/// Admin of token collection can nest tokens under token
- pub admin: bool,
+ pub collection_admin: bool,
/// If set - only tokens from specified collections can be nested
pub restricted: Option<OwnerRestrictedSet>,
tests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-errors.ts
+++ b/tests/src/interfaces/augment-api-errors.ts
@@ -458,6 +458,7 @@
ResourceNotPending: AugmentedError<ApiType>;
RmrkPropertyKeyIsTooLong: AugmentedError<ApiType>;
RmrkPropertyValueIsTooLong: AugmentedError<ApiType>;
+ UnableToDecodeRmrkData: AugmentedError<ApiType>;
/**
* Generic error
**/
tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -417,7 +417,6 @@
};
rmrkCore: {
collectionIndex: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
- rmrkInernalCollectionId: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
uniqueCollectionId: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
* Generic query
tests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -5,7 +5,7 @@
import type { Bytes, Compact, Option, U256, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, Call, H160, H256, MultiAddress, Perbill, Permill } from '@polkadot/types/interfaces/runtime';
-import type { CumulusPrimitivesParachainInherentParachainInherentData, EthereumTransactionTransactionV2, FrameSupportScheduleMaybeHashed, OrmlVestingVestingSchedule, PalletEvmAccountBasicCrossAccountIdRepr, RmrkTraitsNftAccountIdOrCollectionNftTuple, RmrkTraitsPartPartType, RmrkTraitsResourceBasicResource, RmrkTraitsResourceComposableResource, RmrkTraitsResourceSlotResource, RmrkTraitsTheme, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionPermissions, UpDataStructsCreateCollectionData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
+import type { CumulusPrimitivesParachainInherentParachainInherentData, EthereumTransactionTransactionV2, FrameSupportScheduleMaybeHashed, OrmlVestingVestingSchedule, PalletEvmAccountBasicCrossAccountIdRepr, RmrkTraitsNftAccountIdOrCollectionNftTuple, RmrkTraitsPartPartType, RmrkTraitsResourceBasicResource, RmrkTraitsResourceComposableResource, RmrkTraitsResourceResourceTypes, RmrkTraitsResourceSlotResource, RmrkTraitsTheme, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionPermissions, UpDataStructsCreateCollectionData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
declare module '@polkadot/api-base/types/submittable' {
export interface AugmentedSubmittables<ApiType extends ApiTypes> {
@@ -373,7 +373,7 @@
/**
* Create composable resource
**/
- addComposableResource: AugmentedSubmittable<(rmrkCollectionId: u32 | AnyNumber | Uint8Array, nftId: u32 | AnyNumber | Uint8Array, resourceId: Bytes | string | Uint8Array, resource: RmrkTraitsResourceComposableResource | { parts?: any; base?: any; src?: any; metadata?: any; license?: any; thumb?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, Bytes, RmrkTraitsResourceComposableResource]>;
+ addComposableResource: AugmentedSubmittable<(rmrkCollectionId: u32 | AnyNumber | Uint8Array, nftId: u32 | AnyNumber | Uint8Array, resource: RmrkTraitsResourceComposableResource | { parts?: any; base?: any; src?: any; metadata?: any; license?: any; thumb?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, RmrkTraitsResourceComposableResource]>;
/**
* Create slot resource
**/
@@ -381,7 +381,7 @@
/**
* burn nft
**/
- burnNft: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, nftId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
+ burnNft: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, nftId: u32 | AnyNumber | Uint8Array, maxBurns: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u32]>;
/**
* Change the issuer of a collection
*
@@ -415,7 +415,7 @@
* - `metadata`: Arbitrary data about an nft, e.g. IPFS hash
* - `transferable`: Ability to transfer this NFT
**/
- mintNft: AugmentedSubmittable<(owner: AccountId32 | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, recipient: Option<AccountId32> | null | object | string | Uint8Array, royaltyAmount: Option<Permill> | null | object | string | Uint8Array, metadata: Bytes | string | Uint8Array, transferable: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, u32, Option<AccountId32>, Option<Permill>, Bytes, bool]>;
+ mintNft: AugmentedSubmittable<(owner: AccountId32 | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, recipient: Option<AccountId32> | null | object | string | Uint8Array, royaltyAmount: Option<Permill> | null | object | string | Uint8Array, metadata: Bytes | string | Uint8Array, transferable: bool | boolean | Uint8Array, resources: Option<Vec<RmrkTraitsResourceResourceTypes>> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, u32, Option<AccountId32>, Option<Permill>, Bytes, bool, Option<Vec<RmrkTraitsResourceResourceTypes>>]>;
/**
* Rejects an NFT sent from another account to self or owned NFT
*
tests/src/interfaces/default/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -1214,11 +1214,13 @@
readonly royaltyAmount: Option<Permill>;
readonly metadata: Bytes;
readonly transferable: bool;
+ readonly resources: Option<Vec<RmrkTraitsResourceResourceTypes>>;
} & Struct;
readonly isBurnNft: boolean;
readonly asBurnNft: {
readonly collectionId: u32;
readonly nftId: u32;
+ readonly maxBurns: u32;
} & Struct;
readonly isSend: boolean;
readonly asSend: {
@@ -1272,7 +1274,6 @@
readonly asAddComposableResource: {
readonly rmrkCollectionId: u32;
readonly nftId: u32;
- readonly resourceId: Bytes;
readonly resource: RmrkTraitsResourceComposableResource;
} & Struct;
readonly isAddSlotResource: boolean;
@@ -1296,6 +1297,7 @@
readonly isNftTypeEncodeError: boolean;
readonly isRmrkPropertyKeyIsTooLong: boolean;
readonly isRmrkPropertyValueIsTooLong: boolean;
+ readonly isUnableToDecodeRmrkData: boolean;
readonly isCollectionNotEmpty: boolean;
readonly isNoAvailableCollectionId: boolean;
readonly isNoAvailableNftId: boolean;
@@ -1308,7 +1310,7 @@
readonly isCannotAcceptNonOwnedNft: boolean;
readonly isCannotRejectNonOwnedNft: boolean;
readonly isResourceNotPending: boolean;
- readonly type: 'CorruptedCollectionType' | 'NftTypeEncodeError' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'ResourceNotPending';
+ readonly type: 'CorruptedCollectionType' | 'NftTypeEncodeError' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'UnableToDecodeRmrkData' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'ResourceNotPending';
}
/** @name PalletRmrkCoreEvent */
@@ -2427,7 +2429,7 @@
/** @name UpDataStructsNestingPermissions */
export interface UpDataStructsNestingPermissions extends Struct {
readonly tokenOwner: bool;
- readonly admin: bool;
+ readonly collectionAdmin: bool;
readonly restricted: Option<UpDataStructsOwnerRestrictedSet>;
readonly permissive: bool;
}
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1432,7 +1432,7 @@
**/
UpDataStructsNestingPermissions: {
tokenOwner: 'bool',
- admin: 'bool',
+ collectionAdmin: 'bool',
restricted: 'Option<UpDataStructsOwnerRestrictedSet>',
permissive: 'bool'
},
@@ -1593,10 +1593,12 @@
royaltyAmount: 'Option<Permill>',
metadata: 'Bytes',
transferable: 'bool',
+ resources: 'Option<Vec<RmrkTraitsResourceResourceTypes>>',
},
burn_nft: {
collectionId: 'u32',
nftId: 'u32',
+ maxBurns: 'u32',
},
send: {
rmrkCollectionId: 'u32',
@@ -1641,7 +1643,6 @@
add_composable_resource: {
rmrkCollectionId: 'u32',
nftId: 'u32',
- resourceId: 'Bytes',
resource: 'RmrkTraitsResourceComposableResource',
},
add_slot_resource: {
@@ -1657,12 +1658,13 @@
}
},
/**
- * Lookup215: rmrk_traits::nft::AccountIdOrCollectionNftTuple<sp_core::crypto::AccountId32>
+ * Lookup217: rmrk_traits::resource::ResourceTypes<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
- RmrkTraitsNftAccountIdOrCollectionNftTuple: {
+ RmrkTraitsResourceResourceTypes: {
_enum: {
- AccountId: 'AccountId32',
- CollectionAndNftTuple: '(u32,u32)'
+ Basic: 'RmrkTraitsResourceBasicResource',
+ Composable: 'RmrkTraitsResourceComposableResource',
+ Slot: 'RmrkTraitsResourceSlotResource'
}
},
/**
@@ -1675,7 +1677,7 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup222: rmrk_traits::resource::ComposableResource<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup221: rmrk_traits::resource::ComposableResource<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsResourceComposableResource: {
parts: 'Vec<u32>',
@@ -1686,7 +1688,7 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup224: rmrk_traits::resource::SlotResource<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup222: rmrk_traits::resource::SlotResource<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsResourceSlotResource: {
base: 'u32',
@@ -1697,8 +1699,17 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup225: pallet_rmrk_equip::pallet::Call<T>
+ * Lookup224: rmrk_traits::nft::AccountIdOrCollectionNftTuple<sp_core::crypto::AccountId32>
**/
+ RmrkTraitsNftAccountIdOrCollectionNftTuple: {
+ _enum: {
+ AccountId: 'AccountId32',
+ CollectionAndNftTuple: '(u32,u32)'
+ }
+ },
+ /**
+ * Lookup228: pallet_rmrk_equip::pallet::Call<T>
+ **/
PalletRmrkEquipCall: {
_enum: {
create_base: {
@@ -1713,7 +1724,7 @@
}
},
/**
- * Lookup227: rmrk_traits::part::PartType<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup230: rmrk_traits::part::PartType<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPartPartType: {
_enum: {
@@ -1722,7 +1733,7 @@
}
},
/**
- * Lookup229: rmrk_traits::part::FixedPart<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup232: rmrk_traits::part::FixedPart<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPartFixedPart: {
id: 'u32',
@@ -1730,7 +1741,7 @@
src: 'Bytes'
},
/**
- * Lookup230: rmrk_traits::part::SlotPart<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup233: rmrk_traits::part::SlotPart<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPartSlotPart: {
id: 'u32',
@@ -1739,7 +1750,7 @@
z: 'u32'
},
/**
- * Lookup231: rmrk_traits::part::EquippableList<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup234: rmrk_traits::part::EquippableList<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPartEquippableList: {
_enum: {
@@ -1749,7 +1760,7 @@
}
},
/**
- * Lookup233: rmrk_traits::theme::Theme<frame_support::storage::bounded_vec::BoundedVec<T, S>, PropertyList>
+ * Lookup236: rmrk_traits::theme::Theme<frame_support::storage::bounded_vec::BoundedVec<T, S>, PropertyList>
**/
RmrkTraitsTheme: {
name: 'Bytes',
@@ -1757,14 +1768,14 @@
inherit: 'bool'
},
/**
- * Lookup235: rmrk_traits::theme::ThemeProperty<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup238: rmrk_traits::theme::ThemeProperty<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsThemeThemeProperty: {
key: 'Bytes',
value: 'Bytes'
},
/**
- * Lookup236: pallet_evm::pallet::Call<T>
+ * Lookup239: pallet_evm::pallet::Call<T>
**/
PalletEvmCall: {
_enum: {
@@ -1807,7 +1818,7 @@
}
},
/**
- * Lookup242: pallet_ethereum::pallet::Call<T>
+ * Lookup245: pallet_ethereum::pallet::Call<T>
**/
PalletEthereumCall: {
_enum: {
@@ -1817,7 +1828,7 @@
}
},
/**
- * Lookup243: ethereum::transaction::TransactionV2
+ * Lookup246: ethereum::transaction::TransactionV2
**/
EthereumTransactionTransactionV2: {
_enum: {
@@ -1827,7 +1838,7 @@
}
},
/**
- * Lookup244: ethereum::transaction::LegacyTransaction
+ * Lookup247: ethereum::transaction::LegacyTransaction
**/
EthereumTransactionLegacyTransaction: {
nonce: 'U256',
@@ -1839,7 +1850,7 @@
signature: 'EthereumTransactionTransactionSignature'
},
/**
- * Lookup245: ethereum::transaction::TransactionAction
+ * Lookup248: ethereum::transaction::TransactionAction
**/
EthereumTransactionTransactionAction: {
_enum: {
@@ -1848,7 +1859,7 @@
}
},
/**
- * Lookup246: ethereum::transaction::TransactionSignature
+ * Lookup249: ethereum::transaction::TransactionSignature
**/
EthereumTransactionTransactionSignature: {
v: 'u64',
@@ -1856,7 +1867,7 @@
s: 'H256'
},
/**
- * Lookup248: ethereum::transaction::EIP2930Transaction
+ * Lookup251: ethereum::transaction::EIP2930Transaction
**/
EthereumTransactionEip2930Transaction: {
chainId: 'u64',
@@ -1872,14 +1883,14 @@
s: 'H256'
},
/**
- * Lookup250: ethereum::transaction::AccessListItem
+ * Lookup253: ethereum::transaction::AccessListItem
**/
EthereumTransactionAccessListItem: {
address: 'H160',
storageKeys: 'Vec<H256>'
},
/**
- * Lookup251: ethereum::transaction::EIP1559Transaction
+ * Lookup254: ethereum::transaction::EIP1559Transaction
**/
EthereumTransactionEip1559Transaction: {
chainId: 'u64',
@@ -1896,7 +1907,7 @@
s: 'H256'
},
/**
- * Lookup252: pallet_evm_migration::pallet::Call<T>
+ * Lookup255: pallet_evm_migration::pallet::Call<T>
**/
PalletEvmMigrationCall: {
_enum: {
@@ -1914,7 +1925,7 @@
}
},
/**
- * Lookup255: pallet_sudo::pallet::Event<T>
+ * Lookup258: pallet_sudo::pallet::Event<T>
**/
PalletSudoEvent: {
_enum: {
@@ -1930,7 +1941,7 @@
}
},
/**
- * Lookup257: sp_runtime::DispatchError
+ * Lookup260: sp_runtime::DispatchError
**/
SpRuntimeDispatchError: {
_enum: {
@@ -1947,38 +1958,38 @@
}
},
/**
- * Lookup258: sp_runtime::ModuleError
+ * Lookup261: sp_runtime::ModuleError
**/
SpRuntimeModuleError: {
index: 'u8',
error: '[u8;4]'
},
/**
- * Lookup259: sp_runtime::TokenError
+ * Lookup262: sp_runtime::TokenError
**/
SpRuntimeTokenError: {
_enum: ['NoFunds', 'WouldDie', 'BelowMinimum', 'CannotCreate', 'UnknownAsset', 'Frozen', 'Unsupported']
},
/**
- * Lookup260: sp_runtime::ArithmeticError
+ * Lookup263: sp_runtime::ArithmeticError
**/
SpRuntimeArithmeticError: {
_enum: ['Underflow', 'Overflow', 'DivisionByZero']
},
/**
- * Lookup261: sp_runtime::TransactionalError
+ * Lookup264: sp_runtime::TransactionalError
**/
SpRuntimeTransactionalError: {
_enum: ['LimitReached', 'NoLayer']
},
/**
- * Lookup262: pallet_sudo::pallet::Error<T>
+ * Lookup265: pallet_sudo::pallet::Error<T>
**/
PalletSudoError: {
_enum: ['RequireSudo']
},
/**
- * Lookup263: frame_system::AccountInfo<Index, pallet_balances::AccountData<Balance>>
+ * Lookup266: frame_system::AccountInfo<Index, pallet_balances::AccountData<Balance>>
**/
FrameSystemAccountInfo: {
nonce: 'u32',
@@ -1988,7 +1999,7 @@
data: 'PalletBalancesAccountData'
},
/**
- * Lookup264: frame_support::weights::PerDispatchClass<T>
+ * Lookup267: frame_support::weights::PerDispatchClass<T>
**/
FrameSupportWeightsPerDispatchClassU64: {
normal: 'u64',
@@ -1996,13 +2007,13 @@
mandatory: 'u64'
},
/**
- * Lookup265: sp_runtime::generic::digest::Digest
+ * Lookup268: sp_runtime::generic::digest::Digest
**/
SpRuntimeDigest: {
logs: 'Vec<SpRuntimeDigestDigestItem>'
},
/**
- * Lookup267: sp_runtime::generic::digest::DigestItem
+ * Lookup270: sp_runtime::generic::digest::DigestItem
**/
SpRuntimeDigestDigestItem: {
_enum: {
@@ -2018,7 +2029,7 @@
}
},
/**
- * Lookup269: frame_system::EventRecord<opal_runtime::Event, primitive_types::H256>
+ * Lookup272: frame_system::EventRecord<opal_runtime::Event, primitive_types::H256>
**/
FrameSystemEventRecord: {
phase: 'FrameSystemPhase',
@@ -2026,7 +2037,7 @@
topics: 'Vec<H256>'
},
/**
- * Lookup271: frame_system::pallet::Event<T>
+ * Lookup274: frame_system::pallet::Event<T>
**/
FrameSystemEvent: {
_enum: {
@@ -2054,7 +2065,7 @@
}
},
/**
- * Lookup272: frame_support::weights::DispatchInfo
+ * Lookup275: frame_support::weights::DispatchInfo
**/
FrameSupportWeightsDispatchInfo: {
weight: 'u64',
@@ -2062,19 +2073,19 @@
paysFee: 'FrameSupportWeightsPays'
},
/**
- * Lookup273: frame_support::weights::DispatchClass
+ * Lookup276: frame_support::weights::DispatchClass
**/
FrameSupportWeightsDispatchClass: {
_enum: ['Normal', 'Operational', 'Mandatory']
},
/**
- * Lookup274: frame_support::weights::Pays
+ * Lookup277: frame_support::weights::Pays
**/
FrameSupportWeightsPays: {
_enum: ['Yes', 'No']
},
/**
- * Lookup275: orml_vesting::module::Event<T>
+ * Lookup278: orml_vesting::module::Event<T>
**/
OrmlVestingModuleEvent: {
_enum: {
@@ -2093,7 +2104,7 @@
}
},
/**
- * Lookup276: cumulus_pallet_xcmp_queue::pallet::Event<T>
+ * Lookup279: cumulus_pallet_xcmp_queue::pallet::Event<T>
**/
CumulusPalletXcmpQueueEvent: {
_enum: {
@@ -2108,7 +2119,7 @@
}
},
/**
- * Lookup277: pallet_xcm::pallet::Event<T>
+ * Lookup280: pallet_xcm::pallet::Event<T>
**/
PalletXcmEvent: {
_enum: {
@@ -2131,7 +2142,7 @@
}
},
/**
- * Lookup278: xcm::v2::traits::Outcome
+ * Lookup281: xcm::v2::traits::Outcome
**/
XcmV2TraitsOutcome: {
_enum: {
@@ -2141,7 +2152,7 @@
}
},
/**
- * Lookup280: cumulus_pallet_xcm::pallet::Event<T>
+ * Lookup283: cumulus_pallet_xcm::pallet::Event<T>
**/
CumulusPalletXcmEvent: {
_enum: {
@@ -2151,7 +2162,7 @@
}
},
/**
- * Lookup281: cumulus_pallet_dmp_queue::pallet::Event<T>
+ * Lookup284: cumulus_pallet_dmp_queue::pallet::Event<T>
**/
CumulusPalletDmpQueueEvent: {
_enum: {
@@ -2164,7 +2175,7 @@
}
},
/**
- * Lookup282: pallet_unique::RawEvent<sp_core::crypto::AccountId32, pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+ * Lookup285: pallet_unique::RawEvent<sp_core::crypto::AccountId32, pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
**/
PalletUniqueRawEvent: {
_enum: {
@@ -2181,7 +2192,7 @@
}
},
/**
- * Lookup283: pallet_unique_scheduler::pallet::Event<T>
+ * Lookup286: pallet_unique_scheduler::pallet::Event<T>
**/
PalletUniqueSchedulerEvent: {
_enum: {
@@ -2206,13 +2217,13 @@
}
},
/**
- * Lookup285: frame_support::traits::schedule::LookupError
+ * Lookup288: frame_support::traits::schedule::LookupError
**/
FrameSupportScheduleLookupError: {
_enum: ['Unknown', 'BadFormat']
},
/**
- * Lookup286: pallet_common::pallet::Event<T>
+ * Lookup289: pallet_common::pallet::Event<T>
**/
PalletCommonEvent: {
_enum: {
@@ -2230,7 +2241,7 @@
}
},
/**
- * Lookup287: pallet_structure::pallet::Event<T>
+ * Lookup290: pallet_structure::pallet::Event<T>
**/
PalletStructureEvent: {
_enum: {
@@ -2238,7 +2249,7 @@
}
},
/**
- * Lookup288: pallet_rmrk_core::pallet::Event<T>
+ * Lookup291: pallet_rmrk_core::pallet::Event<T>
**/
PalletRmrkCoreEvent: {
_enum: {
@@ -2315,7 +2326,7 @@
}
},
/**
- * Lookup289: pallet_rmrk_equip::pallet::Event<T>
+ * Lookup292: pallet_rmrk_equip::pallet::Event<T>
**/
PalletRmrkEquipEvent: {
_enum: {
@@ -2326,7 +2337,7 @@
}
},
/**
- * Lookup290: pallet_evm::pallet::Event<T>
+ * Lookup293: pallet_evm::pallet::Event<T>
**/
PalletEvmEvent: {
_enum: {
@@ -2340,7 +2351,7 @@
}
},
/**
- * Lookup291: ethereum::log::Log
+ * Lookup294: ethereum::log::Log
**/
EthereumLog: {
address: 'H160',
@@ -2348,7 +2359,7 @@
data: 'Bytes'
},
/**
- * Lookup292: pallet_ethereum::pallet::Event
+ * Lookup295: pallet_ethereum::pallet::Event
**/
PalletEthereumEvent: {
_enum: {
@@ -2356,7 +2367,7 @@
}
},
/**
- * Lookup293: evm_core::error::ExitReason
+ * Lookup296: evm_core::error::ExitReason
**/
EvmCoreErrorExitReason: {
_enum: {
@@ -2367,13 +2378,13 @@
}
},
/**
- * Lookup294: evm_core::error::ExitSucceed
+ * Lookup297: evm_core::error::ExitSucceed
**/
EvmCoreErrorExitSucceed: {
_enum: ['Stopped', 'Returned', 'Suicided']
},
/**
- * Lookup295: evm_core::error::ExitError
+ * Lookup298: evm_core::error::ExitError
**/
EvmCoreErrorExitError: {
_enum: {
@@ -2395,13 +2406,13 @@
}
},
/**
- * Lookup298: evm_core::error::ExitRevert
+ * Lookup301: evm_core::error::ExitRevert
**/
EvmCoreErrorExitRevert: {
_enum: ['Reverted']
},
/**
- * Lookup299: evm_core::error::ExitFatal
+ * Lookup302: evm_core::error::ExitFatal
**/
EvmCoreErrorExitFatal: {
_enum: {
@@ -2412,7 +2423,7 @@
}
},
/**
- * Lookup300: frame_system::Phase
+ * Lookup303: frame_system::Phase
**/
FrameSystemPhase: {
_enum: {
@@ -2422,14 +2433,14 @@
}
},
/**
- * Lookup302: frame_system::LastRuntimeUpgradeInfo
+ * Lookup305: frame_system::LastRuntimeUpgradeInfo
**/
FrameSystemLastRuntimeUpgradeInfo: {
specVersion: 'Compact<u32>',
specName: 'Text'
},
/**
- * Lookup303: frame_system::limits::BlockWeights
+ * Lookup306: frame_system::limits::BlockWeights
**/
FrameSystemLimitsBlockWeights: {
baseBlock: 'u64',
@@ -2437,7 +2448,7 @@
perClass: 'FrameSupportWeightsPerDispatchClassWeightsPerClass'
},
/**
- * Lookup304: frame_support::weights::PerDispatchClass<frame_system::limits::WeightsPerClass>
+ * Lookup307: frame_support::weights::PerDispatchClass<frame_system::limits::WeightsPerClass>
**/
FrameSupportWeightsPerDispatchClassWeightsPerClass: {
normal: 'FrameSystemLimitsWeightsPerClass',
@@ -2445,7 +2456,7 @@
mandatory: 'FrameSystemLimitsWeightsPerClass'
},
/**
- * Lookup305: frame_system::limits::WeightsPerClass
+ * Lookup308: frame_system::limits::WeightsPerClass
**/
FrameSystemLimitsWeightsPerClass: {
baseExtrinsic: 'u64',
@@ -2454,13 +2465,13 @@
reserved: 'Option<u64>'
},
/**
- * Lookup307: frame_system::limits::BlockLength
+ * Lookup310: frame_system::limits::BlockLength
**/
FrameSystemLimitsBlockLength: {
max: 'FrameSupportWeightsPerDispatchClassU32'
},
/**
- * Lookup308: frame_support::weights::PerDispatchClass<T>
+ * Lookup311: frame_support::weights::PerDispatchClass<T>
**/
FrameSupportWeightsPerDispatchClassU32: {
normal: 'u32',
@@ -2468,14 +2479,14 @@
mandatory: 'u32'
},
/**
- * Lookup309: frame_support::weights::RuntimeDbWeight
+ * Lookup312: frame_support::weights::RuntimeDbWeight
**/
FrameSupportWeightsRuntimeDbWeight: {
read: 'u64',
write: 'u64'
},
/**
- * Lookup310: sp_version::RuntimeVersion
+ * Lookup313: sp_version::RuntimeVersion
**/
SpVersionRuntimeVersion: {
specName: 'Text',
@@ -2488,19 +2499,19 @@
stateVersion: 'u8'
},
/**
- * Lookup314: frame_system::pallet::Error<T>
+ * Lookup317: frame_system::pallet::Error<T>
**/
FrameSystemError: {
_enum: ['InvalidSpecName', 'SpecVersionNeedsToIncrease', 'FailedToExtractRuntimeVersion', 'NonDefaultComposite', 'NonZeroRefCount', 'CallFiltered']
},
/**
- * Lookup316: orml_vesting::module::Error<T>
+ * Lookup319: orml_vesting::module::Error<T>
**/
OrmlVestingModuleError: {
_enum: ['ZeroVestingPeriod', 'ZeroVestingPeriodCount', 'InsufficientBalanceToLock', 'TooManyVestingSchedules', 'AmountLow', 'MaxVestingSchedulesExceeded']
},
/**
- * Lookup318: cumulus_pallet_xcmp_queue::InboundChannelDetails
+ * Lookup321: cumulus_pallet_xcmp_queue::InboundChannelDetails
**/
CumulusPalletXcmpQueueInboundChannelDetails: {
sender: 'u32',
@@ -2508,19 +2519,19 @@
messageMetadata: 'Vec<(u32,PolkadotParachainPrimitivesXcmpMessageFormat)>'
},
/**
- * Lookup319: cumulus_pallet_xcmp_queue::InboundState
+ * Lookup322: cumulus_pallet_xcmp_queue::InboundState
**/
CumulusPalletXcmpQueueInboundState: {
_enum: ['Ok', 'Suspended']
},
/**
- * Lookup322: polkadot_parachain::primitives::XcmpMessageFormat
+ * Lookup325: polkadot_parachain::primitives::XcmpMessageFormat
**/
PolkadotParachainPrimitivesXcmpMessageFormat: {
_enum: ['ConcatenatedVersionedXcm', 'ConcatenatedEncodedBlob', 'Signals']
},
/**
- * Lookup325: cumulus_pallet_xcmp_queue::OutboundChannelDetails
+ * Lookup328: cumulus_pallet_xcmp_queue::OutboundChannelDetails
**/
CumulusPalletXcmpQueueOutboundChannelDetails: {
recipient: 'u32',
@@ -2530,13 +2541,13 @@
lastIndex: 'u16'
},
/**
- * Lookup326: cumulus_pallet_xcmp_queue::OutboundState
+ * Lookup329: cumulus_pallet_xcmp_queue::OutboundState
**/
CumulusPalletXcmpQueueOutboundState: {
_enum: ['Ok', 'Suspended']
},
/**
- * Lookup328: cumulus_pallet_xcmp_queue::QueueConfigData
+ * Lookup331: cumulus_pallet_xcmp_queue::QueueConfigData
**/
CumulusPalletXcmpQueueQueueConfigData: {
suspendThreshold: 'u32',
@@ -2547,29 +2558,29 @@
xcmpMaxIndividualWeight: 'u64'
},
/**
- * Lookup330: cumulus_pallet_xcmp_queue::pallet::Error<T>
+ * Lookup333: cumulus_pallet_xcmp_queue::pallet::Error<T>
**/
CumulusPalletXcmpQueueError: {
_enum: ['FailedToSend', 'BadXcmOrigin', 'BadXcm', 'BadOverweightIndex', 'WeightOverLimit']
},
/**
- * Lookup331: pallet_xcm::pallet::Error<T>
+ * Lookup334: pallet_xcm::pallet::Error<T>
**/
PalletXcmError: {
_enum: ['Unreachable', 'SendFailure', 'Filtered', 'UnweighableMessage', 'DestinationNotInvertible', 'Empty', 'CannotReanchor', 'TooManyAssets', 'InvalidOrigin', 'BadVersion', 'BadLocation', 'NoSubscription', 'AlreadySubscribed']
},
/**
- * Lookup332: cumulus_pallet_xcm::pallet::Error<T>
+ * Lookup335: cumulus_pallet_xcm::pallet::Error<T>
**/
CumulusPalletXcmError: 'Null',
/**
- * Lookup333: cumulus_pallet_dmp_queue::ConfigData
+ * Lookup336: cumulus_pallet_dmp_queue::ConfigData
**/
CumulusPalletDmpQueueConfigData: {
maxIndividual: 'u64'
},
/**
- * Lookup334: cumulus_pallet_dmp_queue::PageIndexData
+ * Lookup337: cumulus_pallet_dmp_queue::PageIndexData
**/
CumulusPalletDmpQueuePageIndexData: {
beginUsed: 'u32',
@@ -2577,19 +2588,19 @@
overweightCount: 'u64'
},
/**
- * Lookup337: cumulus_pallet_dmp_queue::pallet::Error<T>
+ * Lookup340: cumulus_pallet_dmp_queue::pallet::Error<T>
**/
CumulusPalletDmpQueueError: {
_enum: ['Unknown', 'OverLimit']
},
/**
- * Lookup341: pallet_unique::Error<T>
+ * Lookup344: pallet_unique::Error<T>
**/
PalletUniqueError: {
_enum: ['CollectionDecimalPointLimitExceeded', 'ConfirmUnsetSponsorFail', 'EmptyArgument']
},
/**
- * Lookup344: pallet_unique_scheduler::ScheduledV3<frame_support::traits::schedule::MaybeHashed<opal_runtime::Call, primitive_types::H256>, BlockNumber, opal_runtime::OriginCaller, sp_core::crypto::AccountId32>
+ * Lookup347: pallet_unique_scheduler::ScheduledV3<frame_support::traits::schedule::MaybeHashed<opal_runtime::Call, primitive_types::H256>, BlockNumber, opal_runtime::OriginCaller, sp_core::crypto::AccountId32>
**/
PalletUniqueSchedulerScheduledV3: {
maybeId: 'Option<[u8;16]>',
@@ -2599,7 +2610,7 @@
origin: 'OpalRuntimeOriginCaller'
},
/**
- * Lookup345: opal_runtime::OriginCaller
+ * Lookup348: opal_runtime::OriginCaller
**/
OpalRuntimeOriginCaller: {
_enum: {
@@ -2708,7 +2719,7 @@
}
},
/**
- * Lookup346: frame_support::dispatch::RawOrigin<sp_core::crypto::AccountId32>
+ * Lookup349: frame_support::dispatch::RawOrigin<sp_core::crypto::AccountId32>
**/
FrameSupportDispatchRawOrigin: {
_enum: {
@@ -2718,7 +2729,7 @@
}
},
/**
- * Lookup347: pallet_xcm::pallet::Origin
+ * Lookup350: pallet_xcm::pallet::Origin
**/
PalletXcmOrigin: {
_enum: {
@@ -2727,7 +2738,7 @@
}
},
/**
- * Lookup348: cumulus_pallet_xcm::pallet::Origin
+ * Lookup351: cumulus_pallet_xcm::pallet::Origin
**/
CumulusPalletXcmOrigin: {
_enum: {
@@ -2736,7 +2747,7 @@
}
},
/**
- * Lookup349: pallet_ethereum::RawOrigin
+ * Lookup352: pallet_ethereum::RawOrigin
**/
PalletEthereumRawOrigin: {
_enum: {
@@ -2744,17 +2755,17 @@
}
},
/**
- * Lookup350: sp_core::Void
+ * Lookup353: sp_core::Void
**/
SpCoreVoid: 'Null',
/**
- * Lookup351: pallet_unique_scheduler::pallet::Error<T>
+ * Lookup354: pallet_unique_scheduler::pallet::Error<T>
**/
PalletUniqueSchedulerError: {
_enum: ['FailedToSchedule', 'NotFound', 'TargetBlockNumberInPast', 'RescheduleNoChange']
},
/**
- * Lookup352: up_data_structs::Collection<sp_core::crypto::AccountId32>
+ * Lookup355: up_data_structs::Collection<sp_core::crypto::AccountId32>
**/
UpDataStructsCollection: {
owner: 'AccountId32',
@@ -2768,7 +2779,7 @@
externalCollection: 'bool'
},
/**
- * Lookup353: up_data_structs::SponsorshipState<sp_core::crypto::AccountId32>
+ * Lookup356: up_data_structs::SponsorshipState<sp_core::crypto::AccountId32>
**/
UpDataStructsSponsorshipState: {
_enum: {
@@ -2778,7 +2789,7 @@
}
},
/**
- * Lookup354: up_data_structs::Properties
+ * Lookup357: up_data_structs::Properties
**/
UpDataStructsProperties: {
map: 'UpDataStructsPropertiesMapBoundedVec',
@@ -2786,15 +2797,15 @@
spaceLimit: 'u32'
},
/**
- * Lookup355: up_data_structs::PropertiesMap<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup358: up_data_structs::PropertiesMap<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsPropertiesMapBoundedVec: 'BTreeMap<Bytes, Bytes>',
/**
- * Lookup360: up_data_structs::PropertiesMap<up_data_structs::PropertyPermission>
+ * Lookup363: up_data_structs::PropertiesMap<up_data_structs::PropertyPermission>
**/
UpDataStructsPropertiesMapPropertyPermission: 'BTreeMap<Bytes, UpDataStructsPropertyPermission>',
/**
- * Lookup367: up_data_structs::CollectionStats
+ * Lookup370: up_data_structs::CollectionStats
**/
UpDataStructsCollectionStats: {
created: 'u32',
@@ -2802,25 +2813,25 @@
alive: 'u32'
},
/**
- * Lookup368: up_data_structs::TokenChild
+ * Lookup371: up_data_structs::TokenChild
**/
UpDataStructsTokenChild: {
token: 'u32',
collection: 'u32'
},
/**
- * Lookup369: PhantomType::up_data_structs<T>
+ * Lookup372: PhantomType::up_data_structs<T>
**/
PhantomTypeUpDataStructs: '[(UpDataStructsTokenData,UpDataStructsRpcCollection,RmrkTraitsCollectionCollectionInfo,RmrkTraitsNftNftInfo,RmrkTraitsResourceResourceInfo,RmrkTraitsPropertyPropertyInfo,RmrkTraitsBaseBaseInfo,RmrkTraitsPartPartType,RmrkTraitsTheme,RmrkTraitsNftNftChild);0]',
/**
- * Lookup371: up_data_structs::TokenData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+ * Lookup374: up_data_structs::TokenData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
**/
UpDataStructsTokenData: {
properties: 'Vec<UpDataStructsProperty>',
owner: 'Option<PalletEvmAccountBasicCrossAccountIdRepr>'
},
/**
- * Lookup373: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
+ * Lookup376: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
**/
UpDataStructsRpcCollection: {
owner: 'AccountId32',
@@ -2836,7 +2847,7 @@
readOnly: 'bool'
},
/**
- * Lookup374: rmrk_traits::collection::CollectionInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, sp_core::crypto::AccountId32>
+ * Lookup377: rmrk_traits::collection::CollectionInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, sp_core::crypto::AccountId32>
**/
RmrkTraitsCollectionCollectionInfo: {
issuer: 'AccountId32',
@@ -2846,7 +2857,7 @@
nftsCount: 'u32'
},
/**
- * Lookup375: rmrk_traits::nft::NftInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup378: rmrk_traits::nft::NftInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsNftNftInfo: {
owner: 'RmrkTraitsNftAccountIdOrCollectionNftTuple',
@@ -2856,14 +2867,14 @@
pending: 'bool'
},
/**
- * Lookup377: rmrk_traits::nft::RoyaltyInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill>
+ * Lookup380: rmrk_traits::nft::RoyaltyInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill>
**/
RmrkTraitsNftRoyaltyInfo: {
recipient: 'AccountId32',
amount: 'Permill'
},
/**
- * Lookup378: rmrk_traits::resource::ResourceInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup381: rmrk_traits::resource::ResourceInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsResourceResourceInfo: {
id: 'u32',
@@ -2872,24 +2883,14 @@
pendingRemoval: 'bool'
},
/**
- * Lookup379: rmrk_traits::resource::ResourceTypes<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
- **/
- RmrkTraitsResourceResourceTypes: {
- _enum: {
- Basic: 'RmrkTraitsResourceBasicResource',
- Composable: 'RmrkTraitsResourceComposableResource',
- Slot: 'RmrkTraitsResourceSlotResource'
- }
- },
- /**
- * Lookup380: rmrk_traits::property::PropertyInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup382: rmrk_traits::property::PropertyInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPropertyPropertyInfo: {
key: 'Bytes',
value: 'Bytes'
},
/**
- * Lookup381: rmrk_traits::base::BaseInfo<sp_core::crypto::AccountId32, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup383: rmrk_traits::base::BaseInfo<sp_core::crypto::AccountId32, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsBaseBaseInfo: {
issuer: 'AccountId32',
@@ -2897,74 +2898,74 @@
symbol: 'Bytes'
},
/**
- * Lookup382: rmrk_traits::nft::NftChild
+ * Lookup384: rmrk_traits::nft::NftChild
**/
RmrkTraitsNftNftChild: {
collectionId: 'u32',
nftId: 'u32'
},
/**
- * Lookup384: pallet_common::pallet::Error<T>
+ * Lookup386: pallet_common::pallet::Error<T>
**/
PalletCommonError: {
_enum: ['CollectionNotFound', 'MustBeTokenOwner', 'NoPermission', 'CantDestroyNotEmptyCollection', 'PublicMintingNotAllowed', 'AddressNotInAllowlist', 'CollectionNameLimitExceeded', 'CollectionDescriptionLimitExceeded', 'CollectionTokenPrefixLimitExceeded', 'TotalCollectionsLimitExceeded', 'CollectionAdminCountExceeded', 'CollectionLimitBoundsExceeded', 'OwnerPermissionsCantBeReverted', 'TransferNotAllowed', 'AccountTokenLimitExceeded', 'CollectionTokenLimitExceeded', 'MetadataFlagFrozen', 'TokenNotFound', 'TokenValueTooLow', 'ApprovedValueTooLow', 'CantApproveMoreThanOwned', 'AddressIsZero', 'UnsupportedOperation', 'NotSufficientFounds', 'UserIsNotAllowedToNest', 'SourceCollectionIsNotAllowedToNest', 'CollectionFieldSizeExceeded', 'NoSpaceForProperty', 'PropertyLimitReached', 'PropertyKeyIsTooLong', 'InvalidCharacterInPropertyKey', 'EmptyPropertyKey', 'CollectionIsExternal', 'CollectionIsInternal']
},
/**
- * Lookup386: pallet_fungible::pallet::Error<T>
+ * Lookup388: pallet_fungible::pallet::Error<T>
**/
PalletFungibleError: {
_enum: ['NotFungibleDataUsedToMintFungibleCollectionToken', 'FungibleItemsHaveNoId', 'FungibleItemsDontHaveData', 'FungibleDisallowsNesting', 'SettingPropertiesNotAllowed']
},
/**
- * Lookup387: pallet_refungible::ItemData
+ * Lookup389: pallet_refungible::ItemData
**/
PalletRefungibleItemData: {
constData: 'Bytes'
},
/**
- * Lookup391: pallet_refungible::pallet::Error<T>
+ * Lookup393: pallet_refungible::pallet::Error<T>
**/
PalletRefungibleError: {
_enum: ['NotRefungibleDataUsedToMintFungibleCollectionToken', 'WrongRefungiblePieces', 'RefungibleDisallowsNesting', 'SettingPropertiesNotAllowed']
},
/**
- * Lookup392: pallet_nonfungible::ItemData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+ * Lookup394: pallet_nonfungible::ItemData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
**/
PalletNonfungibleItemData: {
owner: 'PalletEvmAccountBasicCrossAccountIdRepr'
},
/**
- * Lookup394: pallet_nonfungible::pallet::Error<T>
+ * Lookup396: pallet_nonfungible::pallet::Error<T>
**/
PalletNonfungibleError: {
_enum: ['NotNonfungibleDataUsedToMintFungibleCollectionToken', 'NonfungibleItemsHaveNoAmount', 'CantBurnNftWithChildren']
},
/**
- * Lookup395: pallet_structure::pallet::Error<T>
+ * Lookup397: pallet_structure::pallet::Error<T>
**/
PalletStructureError: {
_enum: ['OuroborosDetected', 'DepthLimit', 'BreadthLimit', 'TokenNotFound']
},
/**
- * Lookup396: pallet_rmrk_core::pallet::Error<T>
+ * Lookup398: pallet_rmrk_core::pallet::Error<T>
**/
PalletRmrkCoreError: {
- _enum: ['CorruptedCollectionType', 'NftTypeEncodeError', 'RmrkPropertyKeyIsTooLong', 'RmrkPropertyValueIsTooLong', 'CollectionNotEmpty', 'NoAvailableCollectionId', 'NoAvailableNftId', 'CollectionUnknown', 'NoPermission', 'NonTransferable', 'CollectionFullOrLocked', 'ResourceDoesntExist', 'CannotSendToDescendentOrSelf', 'CannotAcceptNonOwnedNft', 'CannotRejectNonOwnedNft', 'ResourceNotPending']
+ _enum: ['CorruptedCollectionType', 'NftTypeEncodeError', 'RmrkPropertyKeyIsTooLong', 'RmrkPropertyValueIsTooLong', 'UnableToDecodeRmrkData', 'CollectionNotEmpty', 'NoAvailableCollectionId', 'NoAvailableNftId', 'CollectionUnknown', 'NoPermission', 'NonTransferable', 'CollectionFullOrLocked', 'ResourceDoesntExist', 'CannotSendToDescendentOrSelf', 'CannotAcceptNonOwnedNft', 'CannotRejectNonOwnedNft', 'ResourceNotPending']
},
/**
- * Lookup398: pallet_rmrk_equip::pallet::Error<T>
+ * Lookup400: pallet_rmrk_equip::pallet::Error<T>
**/
PalletRmrkEquipError: {
_enum: ['PermissionError', 'NoAvailableBaseId', 'NoAvailablePartId', 'BaseDoesntExist', 'NeedsDefaultThemeFirst']
},
/**
- * Lookup401: pallet_evm::pallet::Error<T>
+ * Lookup403: pallet_evm::pallet::Error<T>
**/
PalletEvmError: {
_enum: ['BalanceLow', 'FeeOverflow', 'PaymentOverflow', 'WithdrawFailed', 'GasPriceTooLow', 'InvalidNonce']
},
/**
- * Lookup404: fp_rpc::TransactionStatus
+ * Lookup406: fp_rpc::TransactionStatus
**/
FpRpcTransactionStatus: {
transactionHash: 'H256',
@@ -2976,11 +2977,11 @@
logsBloom: 'EthbloomBloom'
},
/**
- * Lookup406: ethbloom::Bloom
+ * Lookup408: ethbloom::Bloom
**/
EthbloomBloom: '[u8;256]',
/**
- * Lookup408: ethereum::receipt::ReceiptV3
+ * Lookup410: ethereum::receipt::ReceiptV3
**/
EthereumReceiptReceiptV3: {
_enum: {
@@ -2990,7 +2991,7 @@
}
},
/**
- * Lookup409: ethereum::receipt::EIP658ReceiptData
+ * Lookup411: ethereum::receipt::EIP658ReceiptData
**/
EthereumReceiptEip658ReceiptData: {
statusCode: 'u8',
@@ -2999,7 +3000,7 @@
logs: 'Vec<EthereumLog>'
},
/**
- * Lookup410: ethereum::block::Block<ethereum::transaction::TransactionV2>
+ * Lookup412: ethereum::block::Block<ethereum::transaction::TransactionV2>
**/
EthereumBlock: {
header: 'EthereumHeader',
@@ -3007,7 +3008,7 @@
ommers: 'Vec<EthereumHeader>'
},
/**
- * Lookup411: ethereum::header::Header
+ * Lookup413: ethereum::header::Header
**/
EthereumHeader: {
parentHash: 'H256',
@@ -3027,41 +3028,41 @@
nonce: 'EthereumTypesHashH64'
},
/**
- * Lookup412: ethereum_types::hash::H64
+ * Lookup414: ethereum_types::hash::H64
**/
EthereumTypesHashH64: '[u8;8]',
/**
- * Lookup417: pallet_ethereum::pallet::Error<T>
+ * Lookup419: pallet_ethereum::pallet::Error<T>
**/
PalletEthereumError: {
_enum: ['InvalidSignature', 'PreLogExists']
},
/**
- * Lookup418: pallet_evm_coder_substrate::pallet::Error<T>
+ * Lookup420: pallet_evm_coder_substrate::pallet::Error<T>
**/
PalletEvmCoderSubstrateError: {
_enum: ['OutOfGas', 'OutOfFund']
},
/**
- * Lookup419: pallet_evm_contract_helpers::SponsoringModeT
+ * Lookup421: pallet_evm_contract_helpers::SponsoringModeT
**/
PalletEvmContractHelpersSponsoringModeT: {
_enum: ['Disabled', 'Allowlisted', 'Generous']
},
/**
- * Lookup421: pallet_evm_contract_helpers::pallet::Error<T>
+ * Lookup423: pallet_evm_contract_helpers::pallet::Error<T>
**/
PalletEvmContractHelpersError: {
_enum: ['NoPermission']
},
/**
- * Lookup422: pallet_evm_migration::pallet::Error<T>
+ * Lookup424: pallet_evm_migration::pallet::Error<T>
**/
PalletEvmMigrationError: {
_enum: ['AccountNotEmpty', 'AccountIsNotMigrating']
},
/**
- * Lookup424: sp_runtime::MultiSignature
+ * Lookup426: sp_runtime::MultiSignature
**/
SpRuntimeMultiSignature: {
_enum: {
@@ -3071,43 +3072,43 @@
}
},
/**
- * Lookup425: sp_core::ed25519::Signature
+ * Lookup427: sp_core::ed25519::Signature
**/
SpCoreEd25519Signature: '[u8;64]',
/**
- * Lookup427: sp_core::sr25519::Signature
+ * Lookup429: sp_core::sr25519::Signature
**/
SpCoreSr25519Signature: '[u8;64]',
/**
- * Lookup428: sp_core::ecdsa::Signature
+ * Lookup430: sp_core::ecdsa::Signature
**/
SpCoreEcdsaSignature: '[u8;65]',
/**
- * Lookup431: frame_system::extensions::check_spec_version::CheckSpecVersion<T>
+ * Lookup433: frame_system::extensions::check_spec_version::CheckSpecVersion<T>
**/
FrameSystemExtensionsCheckSpecVersion: 'Null',
/**
- * Lookup432: frame_system::extensions::check_genesis::CheckGenesis<T>
+ * Lookup434: frame_system::extensions::check_genesis::CheckGenesis<T>
**/
FrameSystemExtensionsCheckGenesis: 'Null',
/**
- * Lookup435: frame_system::extensions::check_nonce::CheckNonce<T>
+ * Lookup437: frame_system::extensions::check_nonce::CheckNonce<T>
**/
FrameSystemExtensionsCheckNonce: 'Compact<u32>',
/**
- * Lookup436: frame_system::extensions::check_weight::CheckWeight<T>
+ * Lookup438: frame_system::extensions::check_weight::CheckWeight<T>
**/
FrameSystemExtensionsCheckWeight: 'Null',
/**
- * Lookup437: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
+ * Lookup439: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
**/
PalletTemplateTransactionPaymentChargeTransactionPayment: 'Compact<u128>',
/**
- * Lookup438: opal_runtime::Runtime
+ * Lookup440: opal_runtime::Runtime
**/
OpalRuntimeRuntime: 'Null',
/**
- * Lookup439: pallet_ethereum::FakeTransactionFinalizer<opal_runtime::Runtime>
+ * Lookup441: pallet_ethereum::FakeTransactionFinalizer<opal_runtime::Runtime>
**/
PalletEthereumFakeTransactionFinalizer: 'Null'
};
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1562,7 +1562,7 @@
/** @name UpDataStructsNestingPermissions (169) */
export interface UpDataStructsNestingPermissions extends Struct {
readonly tokenOwner: bool;
- readonly admin: bool;
+ readonly collectionAdmin: bool;
readonly restricted: Option<UpDataStructsOwnerRestrictedSet>;
readonly permissive: bool;
}
@@ -1719,11 +1719,13 @@
readonly royaltyAmount: Option<Permill>;
readonly metadata: Bytes;
readonly transferable: bool;
+ readonly resources: Option<Vec<RmrkTraitsResourceResourceTypes>>;
} & Struct;
readonly isBurnNft: boolean;
readonly asBurnNft: {
readonly collectionId: u32;
readonly nftId: u32;
+ readonly maxBurns: u32;
} & Struct;
readonly isSend: boolean;
readonly asSend: {
@@ -1777,7 +1779,6 @@
readonly asAddComposableResource: {
readonly rmrkCollectionId: u32;
readonly nftId: u32;
- readonly resourceId: Bytes;
readonly resource: RmrkTraitsResourceComposableResource;
} & Struct;
readonly isAddSlotResource: boolean;
@@ -1795,13 +1796,15 @@
readonly type: 'CreateCollection' | 'DestroyCollection' | 'ChangeCollectionIssuer' | 'LockCollection' | 'MintNft' | 'BurnNft' | 'Send' | 'AcceptNft' | 'RejectNft' | 'AcceptResource' | 'AcceptResourceRemoval' | 'SetProperty' | 'SetPriority' | 'AddBasicResource' | 'AddComposableResource' | 'AddSlotResource' | 'RemoveResource';
}
- /** @name RmrkTraitsNftAccountIdOrCollectionNftTuple (215) */
- export interface RmrkTraitsNftAccountIdOrCollectionNftTuple extends Enum {
- readonly isAccountId: boolean;
- readonly asAccountId: AccountId32;
- readonly isCollectionAndNftTuple: boolean;
- readonly asCollectionAndNftTuple: ITuple<[u32, u32]>;
- readonly type: 'AccountId' | 'CollectionAndNftTuple';
+ /** @name RmrkTraitsResourceResourceTypes (217) */
+ export interface RmrkTraitsResourceResourceTypes extends Enum {
+ readonly isBasic: boolean;
+ readonly asBasic: RmrkTraitsResourceBasicResource;
+ readonly isComposable: boolean;
+ readonly asComposable: RmrkTraitsResourceComposableResource;
+ readonly isSlot: boolean;
+ readonly asSlot: RmrkTraitsResourceSlotResource;
+ readonly type: 'Basic' | 'Composable' | 'Slot';
}
/** @name RmrkTraitsResourceBasicResource (219) */
@@ -1812,7 +1815,7 @@
readonly thumb: Option<Bytes>;
}
- /** @name RmrkTraitsResourceComposableResource (222) */
+ /** @name RmrkTraitsResourceComposableResource (221) */
export interface RmrkTraitsResourceComposableResource extends Struct {
readonly parts: Vec<u32>;
readonly base: u32;
@@ -1822,7 +1825,7 @@
readonly thumb: Option<Bytes>;
}
- /** @name RmrkTraitsResourceSlotResource (224) */
+ /** @name RmrkTraitsResourceSlotResource (222) */
export interface RmrkTraitsResourceSlotResource extends Struct {
readonly base: u32;
readonly src: Option<Bytes>;
@@ -1832,7 +1835,16 @@
readonly thumb: Option<Bytes>;
}
- /** @name PalletRmrkEquipCall (225) */
+ /** @name RmrkTraitsNftAccountIdOrCollectionNftTuple (224) */
+ export interface RmrkTraitsNftAccountIdOrCollectionNftTuple extends Enum {
+ readonly isAccountId: boolean;
+ readonly asAccountId: AccountId32;
+ readonly isCollectionAndNftTuple: boolean;
+ readonly asCollectionAndNftTuple: ITuple<[u32, u32]>;
+ readonly type: 'AccountId' | 'CollectionAndNftTuple';
+ }
+
+ /** @name PalletRmrkEquipCall (228) */
export interface PalletRmrkEquipCall extends Enum {
readonly isCreateBase: boolean;
readonly asCreateBase: {
@@ -1848,7 +1860,7 @@
readonly type: 'CreateBase' | 'ThemeAdd';
}
- /** @name RmrkTraitsPartPartType (227) */
+ /** @name RmrkTraitsPartPartType (230) */
export interface RmrkTraitsPartPartType extends Enum {
readonly isFixedPart: boolean;
readonly asFixedPart: RmrkTraitsPartFixedPart;
@@ -1857,14 +1869,14 @@
readonly type: 'FixedPart' | 'SlotPart';
}
- /** @name RmrkTraitsPartFixedPart (229) */
+ /** @name RmrkTraitsPartFixedPart (232) */
export interface RmrkTraitsPartFixedPart extends Struct {
readonly id: u32;
readonly z: u32;
readonly src: Bytes;
}
- /** @name RmrkTraitsPartSlotPart (230) */
+ /** @name RmrkTraitsPartSlotPart (233) */
export interface RmrkTraitsPartSlotPart extends Struct {
readonly id: u32;
readonly equippable: RmrkTraitsPartEquippableList;
@@ -1872,7 +1884,7 @@
readonly z: u32;
}
- /** @name RmrkTraitsPartEquippableList (231) */
+ /** @name RmrkTraitsPartEquippableList (234) */
export interface RmrkTraitsPartEquippableList extends Enum {
readonly isAll: boolean;
readonly isEmpty: boolean;
@@ -1881,20 +1893,20 @@
readonly type: 'All' | 'Empty' | 'Custom';
}
- /** @name RmrkTraitsTheme (233) */
+ /** @name RmrkTraitsTheme (236) */
export interface RmrkTraitsTheme extends Struct {
readonly name: Bytes;
readonly properties: Vec<RmrkTraitsThemeThemeProperty>;
readonly inherit: bool;
}
- /** @name RmrkTraitsThemeThemeProperty (235) */
+ /** @name RmrkTraitsThemeThemeProperty (238) */
export interface RmrkTraitsThemeThemeProperty extends Struct {
readonly key: Bytes;
readonly value: Bytes;
}
- /** @name PalletEvmCall (236) */
+ /** @name PalletEvmCall (239) */
export interface PalletEvmCall extends Enum {
readonly isWithdraw: boolean;
readonly asWithdraw: {
@@ -1939,7 +1951,7 @@
readonly type: 'Withdraw' | 'Call' | 'Create' | 'Create2';
}
- /** @name PalletEthereumCall (242) */
+ /** @name PalletEthereumCall (245) */
export interface PalletEthereumCall extends Enum {
readonly isTransact: boolean;
readonly asTransact: {
@@ -1948,7 +1960,7 @@
readonly type: 'Transact';
}
- /** @name EthereumTransactionTransactionV2 (243) */
+ /** @name EthereumTransactionTransactionV2 (246) */
export interface EthereumTransactionTransactionV2 extends Enum {
readonly isLegacy: boolean;
readonly asLegacy: EthereumTransactionLegacyTransaction;
@@ -1959,7 +1971,7 @@
readonly type: 'Legacy' | 'Eip2930' | 'Eip1559';
}
- /** @name EthereumTransactionLegacyTransaction (244) */
+ /** @name EthereumTransactionLegacyTransaction (247) */
export interface EthereumTransactionLegacyTransaction extends Struct {
readonly nonce: U256;
readonly gasPrice: U256;
@@ -1970,7 +1982,7 @@
readonly signature: EthereumTransactionTransactionSignature;
}
- /** @name EthereumTransactionTransactionAction (245) */
+ /** @name EthereumTransactionTransactionAction (248) */
export interface EthereumTransactionTransactionAction extends Enum {
readonly isCall: boolean;
readonly asCall: H160;
@@ -1978,14 +1990,14 @@
readonly type: 'Call' | 'Create';
}
- /** @name EthereumTransactionTransactionSignature (246) */
+ /** @name EthereumTransactionTransactionSignature (249) */
export interface EthereumTransactionTransactionSignature extends Struct {
readonly v: u64;
readonly r: H256;
readonly s: H256;
}
- /** @name EthereumTransactionEip2930Transaction (248) */
+ /** @name EthereumTransactionEip2930Transaction (251) */
export interface EthereumTransactionEip2930Transaction extends Struct {
readonly chainId: u64;
readonly nonce: U256;
@@ -2000,13 +2012,13 @@
readonly s: H256;
}
- /** @name EthereumTransactionAccessListItem (250) */
+ /** @name EthereumTransactionAccessListItem (253) */
export interface EthereumTransactionAccessListItem extends Struct {
readonly address: H160;
readonly storageKeys: Vec<H256>;
}
- /** @name EthereumTransactionEip1559Transaction (251) */
+ /** @name EthereumTransactionEip1559Transaction (254) */
export interface EthereumTransactionEip1559Transaction extends Struct {
readonly chainId: u64;
readonly nonce: U256;
@@ -2022,7 +2034,7 @@
readonly s: H256;
}
- /** @name PalletEvmMigrationCall (252) */
+ /** @name PalletEvmMigrationCall (255) */
export interface PalletEvmMigrationCall extends Enum {
readonly isBegin: boolean;
readonly asBegin: {
@@ -2041,7 +2053,7 @@
readonly type: 'Begin' | 'SetData' | 'Finish';
}
- /** @name PalletSudoEvent (255) */
+ /** @name PalletSudoEvent (258) */
export interface PalletSudoEvent extends Enum {
readonly isSudid: boolean;
readonly asSudid: {
@@ -2058,7 +2070,7 @@
readonly type: 'Sudid' | 'KeyChanged' | 'SudoAsDone';
}
- /** @name SpRuntimeDispatchError (257) */
+ /** @name SpRuntimeDispatchError (260) */
export interface SpRuntimeDispatchError extends Enum {
readonly isOther: boolean;
readonly isCannotLookup: boolean;
@@ -2077,13 +2089,13 @@
readonly type: 'Other' | 'CannotLookup' | 'BadOrigin' | 'Module' | 'ConsumerRemaining' | 'NoProviders' | 'TooManyConsumers' | 'Token' | 'Arithmetic' | 'Transactional';
}
- /** @name SpRuntimeModuleError (258) */
+ /** @name SpRuntimeModuleError (261) */
export interface SpRuntimeModuleError extends Struct {
readonly index: u8;
readonly error: U8aFixed;
}
- /** @name SpRuntimeTokenError (259) */
+ /** @name SpRuntimeTokenError (262) */
export interface SpRuntimeTokenError extends Enum {
readonly isNoFunds: boolean;
readonly isWouldDie: boolean;
@@ -2095,7 +2107,7 @@
readonly type: 'NoFunds' | 'WouldDie' | 'BelowMinimum' | 'CannotCreate' | 'UnknownAsset' | 'Frozen' | 'Unsupported';
}
- /** @name SpRuntimeArithmeticError (260) */
+ /** @name SpRuntimeArithmeticError (263) */
export interface SpRuntimeArithmeticError extends Enum {
readonly isUnderflow: boolean;
readonly isOverflow: boolean;
@@ -2103,20 +2115,20 @@
readonly type: 'Underflow' | 'Overflow' | 'DivisionByZero';
}
- /** @name SpRuntimeTransactionalError (261) */
+ /** @name SpRuntimeTransactionalError (264) */
export interface SpRuntimeTransactionalError extends Enum {
readonly isLimitReached: boolean;
readonly isNoLayer: boolean;
readonly type: 'LimitReached' | 'NoLayer';
}
- /** @name PalletSudoError (262) */
+ /** @name PalletSudoError (265) */
export interface PalletSudoError extends Enum {
readonly isRequireSudo: boolean;
readonly type: 'RequireSudo';
}
- /** @name FrameSystemAccountInfo (263) */
+ /** @name FrameSystemAccountInfo (266) */
export interface FrameSystemAccountInfo extends Struct {
readonly nonce: u32;
readonly consumers: u32;
@@ -2125,19 +2137,19 @@
readonly data: PalletBalancesAccountData;
}
- /** @name FrameSupportWeightsPerDispatchClassU64 (264) */
+ /** @name FrameSupportWeightsPerDispatchClassU64 (267) */
export interface FrameSupportWeightsPerDispatchClassU64 extends Struct {
readonly normal: u64;
readonly operational: u64;
readonly mandatory: u64;
}
- /** @name SpRuntimeDigest (265) */
+ /** @name SpRuntimeDigest (268) */
export interface SpRuntimeDigest extends Struct {
readonly logs: Vec<SpRuntimeDigestDigestItem>;
}
- /** @name SpRuntimeDigestDigestItem (267) */
+ /** @name SpRuntimeDigestDigestItem (270) */
export interface SpRuntimeDigestDigestItem extends Enum {
readonly isOther: boolean;
readonly asOther: Bytes;
@@ -2151,14 +2163,14 @@
readonly type: 'Other' | 'Consensus' | 'Seal' | 'PreRuntime' | 'RuntimeEnvironmentUpdated';
}
- /** @name FrameSystemEventRecord (269) */
+ /** @name FrameSystemEventRecord (272) */
export interface FrameSystemEventRecord extends Struct {
readonly phase: FrameSystemPhase;
readonly event: Event;
readonly topics: Vec<H256>;
}
- /** @name FrameSystemEvent (271) */
+ /** @name FrameSystemEvent (274) */
export interface FrameSystemEvent extends Enum {
readonly isExtrinsicSuccess: boolean;
readonly asExtrinsicSuccess: {
@@ -2186,14 +2198,14 @@
readonly type: 'ExtrinsicSuccess' | 'ExtrinsicFailed' | 'CodeUpdated' | 'NewAccount' | 'KilledAccount' | 'Remarked';
}
- /** @name FrameSupportWeightsDispatchInfo (272) */
+ /** @name FrameSupportWeightsDispatchInfo (275) */
export interface FrameSupportWeightsDispatchInfo extends Struct {
readonly weight: u64;
readonly class: FrameSupportWeightsDispatchClass;
readonly paysFee: FrameSupportWeightsPays;
}
- /** @name FrameSupportWeightsDispatchClass (273) */
+ /** @name FrameSupportWeightsDispatchClass (276) */
export interface FrameSupportWeightsDispatchClass extends Enum {
readonly isNormal: boolean;
readonly isOperational: boolean;
@@ -2201,14 +2213,14 @@
readonly type: 'Normal' | 'Operational' | 'Mandatory';
}
- /** @name FrameSupportWeightsPays (274) */
+ /** @name FrameSupportWeightsPays (277) */
export interface FrameSupportWeightsPays extends Enum {
readonly isYes: boolean;
readonly isNo: boolean;
readonly type: 'Yes' | 'No';
}
- /** @name OrmlVestingModuleEvent (275) */
+ /** @name OrmlVestingModuleEvent (278) */
export interface OrmlVestingModuleEvent extends Enum {
readonly isVestingScheduleAdded: boolean;
readonly asVestingScheduleAdded: {
@@ -2228,7 +2240,7 @@
readonly type: 'VestingScheduleAdded' | 'Claimed' | 'VestingSchedulesUpdated';
}
- /** @name CumulusPalletXcmpQueueEvent (276) */
+ /** @name CumulusPalletXcmpQueueEvent (279) */
export interface CumulusPalletXcmpQueueEvent extends Enum {
readonly isSuccess: boolean;
readonly asSuccess: Option<H256>;
@@ -2249,7 +2261,7 @@
readonly type: 'Success' | 'Fail' | 'BadVersion' | 'BadFormat' | 'UpwardMessageSent' | 'XcmpMessageSent' | 'OverweightEnqueued' | 'OverweightServiced';
}
- /** @name PalletXcmEvent (277) */
+ /** @name PalletXcmEvent (280) */
export interface PalletXcmEvent extends Enum {
readonly isAttempted: boolean;
readonly asAttempted: XcmV2TraitsOutcome;
@@ -2286,7 +2298,7 @@
readonly type: 'Attempted' | 'Sent' | 'UnexpectedResponse' | 'ResponseReady' | 'Notified' | 'NotifyOverweight' | 'NotifyDispatchError' | 'NotifyDecodeFailed' | 'InvalidResponder' | 'InvalidResponderVersion' | 'ResponseTaken' | 'AssetsTrapped' | 'VersionChangeNotified' | 'SupportedVersionChanged' | 'NotifyTargetSendFail' | 'NotifyTargetMigrationFail';
}
- /** @name XcmV2TraitsOutcome (278) */
+ /** @name XcmV2TraitsOutcome (281) */
export interface XcmV2TraitsOutcome extends Enum {
readonly isComplete: boolean;
readonly asComplete: u64;
@@ -2297,7 +2309,7 @@
readonly type: 'Complete' | 'Incomplete' | 'Error';
}
- /** @name CumulusPalletXcmEvent (280) */
+ /** @name CumulusPalletXcmEvent (283) */
export interface CumulusPalletXcmEvent extends Enum {
readonly isInvalidFormat: boolean;
readonly asInvalidFormat: U8aFixed;
@@ -2308,7 +2320,7 @@
readonly type: 'InvalidFormat' | 'UnsupportedVersion' | 'ExecutedDownward';
}
- /** @name CumulusPalletDmpQueueEvent (281) */
+ /** @name CumulusPalletDmpQueueEvent (284) */
export interface CumulusPalletDmpQueueEvent extends Enum {
readonly isInvalidFormat: boolean;
readonly asInvalidFormat: U8aFixed;
@@ -2325,7 +2337,7 @@
readonly type: 'InvalidFormat' | 'UnsupportedVersion' | 'ExecutedDownward' | 'WeightExhausted' | 'OverweightEnqueued' | 'OverweightServiced';
}
- /** @name PalletUniqueRawEvent (282) */
+ /** @name PalletUniqueRawEvent (285) */
export interface PalletUniqueRawEvent extends Enum {
readonly isCollectionSponsorRemoved: boolean;
readonly asCollectionSponsorRemoved: u32;
@@ -2350,7 +2362,7 @@
readonly type: 'CollectionSponsorRemoved' | 'CollectionAdminAdded' | 'CollectionOwnedChanged' | 'CollectionSponsorSet' | 'SponsorshipConfirmed' | 'CollectionAdminRemoved' | 'AllowListAddressRemoved' | 'AllowListAddressAdded' | 'CollectionLimitSet' | 'CollectionPermissionSet';
}
- /** @name PalletUniqueSchedulerEvent (283) */
+ /** @name PalletUniqueSchedulerEvent (286) */
export interface PalletUniqueSchedulerEvent extends Enum {
readonly isScheduled: boolean;
readonly asScheduled: {
@@ -2377,14 +2389,14 @@
readonly type: 'Scheduled' | 'Canceled' | 'Dispatched' | 'CallLookupFailed';
}
- /** @name FrameSupportScheduleLookupError (285) */
+ /** @name FrameSupportScheduleLookupError (288) */
export interface FrameSupportScheduleLookupError extends Enum {
readonly isUnknown: boolean;
readonly isBadFormat: boolean;
readonly type: 'Unknown' | 'BadFormat';
}
- /** @name PalletCommonEvent (286) */
+ /** @name PalletCommonEvent (289) */
export interface PalletCommonEvent extends Enum {
readonly isCollectionCreated: boolean;
readonly asCollectionCreated: ITuple<[u32, u8, AccountId32]>;
@@ -2411,14 +2423,14 @@
readonly type: 'CollectionCreated' | 'CollectionDestroyed' | 'ItemCreated' | 'ItemDestroyed' | 'Transfer' | 'Approved' | 'CollectionPropertySet' | 'CollectionPropertyDeleted' | 'TokenPropertySet' | 'TokenPropertyDeleted' | 'PropertyPermissionSet';
}
- /** @name PalletStructureEvent (287) */
+ /** @name PalletStructureEvent (290) */
export interface PalletStructureEvent extends Enum {
readonly isExecuted: boolean;
readonly asExecuted: Result<Null, SpRuntimeDispatchError>;
readonly type: 'Executed';
}
- /** @name PalletRmrkCoreEvent (288) */
+ /** @name PalletRmrkCoreEvent (291) */
export interface PalletRmrkCoreEvent extends Enum {
readonly isCollectionCreated: boolean;
readonly asCollectionCreated: {
@@ -2508,7 +2520,7 @@
readonly type: 'CollectionCreated' | 'CollectionDestroyed' | 'IssuerChanged' | 'CollectionLocked' | 'NftMinted' | 'NftBurned' | 'NftSent' | 'NftAccepted' | 'NftRejected' | 'PropertySet' | 'ResourceAdded' | 'ResourceRemoval' | 'ResourceAccepted' | 'ResourceRemovalAccepted' | 'PrioritySet';
}
- /** @name PalletRmrkEquipEvent (289) */
+ /** @name PalletRmrkEquipEvent (292) */
export interface PalletRmrkEquipEvent extends Enum {
readonly isBaseCreated: boolean;
readonly asBaseCreated: {
@@ -2518,7 +2530,7 @@
readonly type: 'BaseCreated';
}
- /** @name PalletEvmEvent (290) */
+ /** @name PalletEvmEvent (293) */
export interface PalletEvmEvent extends Enum {
readonly isLog: boolean;
readonly asLog: EthereumLog;
@@ -2537,21 +2549,21 @@
readonly type: 'Log' | 'Created' | 'CreatedFailed' | 'Executed' | 'ExecutedFailed' | 'BalanceDeposit' | 'BalanceWithdraw';
}
- /** @name EthereumLog (291) */
+ /** @name EthereumLog (294) */
export interface EthereumLog extends Struct {
readonly address: H160;
readonly topics: Vec<H256>;
readonly data: Bytes;
}
- /** @name PalletEthereumEvent (292) */
+ /** @name PalletEthereumEvent (295) */
export interface PalletEthereumEvent extends Enum {
readonly isExecuted: boolean;
readonly asExecuted: ITuple<[H160, H160, H256, EvmCoreErrorExitReason]>;
readonly type: 'Executed';
}
- /** @name EvmCoreErrorExitReason (293) */
+ /** @name EvmCoreErrorExitReason (296) */
export interface EvmCoreErrorExitReason extends Enum {
readonly isSucceed: boolean;
readonly asSucceed: EvmCoreErrorExitSucceed;
@@ -2564,7 +2576,7 @@
readonly type: 'Succeed' | 'Error' | 'Revert' | 'Fatal';
}
- /** @name EvmCoreErrorExitSucceed (294) */
+ /** @name EvmCoreErrorExitSucceed (297) */
export interface EvmCoreErrorExitSucceed extends Enum {
readonly isStopped: boolean;
readonly isReturned: boolean;
@@ -2572,7 +2584,7 @@
readonly type: 'Stopped' | 'Returned' | 'Suicided';
}
- /** @name EvmCoreErrorExitError (295) */
+ /** @name EvmCoreErrorExitError (298) */
export interface EvmCoreErrorExitError extends Enum {
readonly isStackUnderflow: boolean;
readonly isStackOverflow: boolean;
@@ -2593,13 +2605,13 @@
readonly type: 'StackUnderflow' | 'StackOverflow' | 'InvalidJump' | 'InvalidRange' | 'DesignatedInvalid' | 'CallTooDeep' | 'CreateCollision' | 'CreateContractLimit' | 'OutOfOffset' | 'OutOfGas' | 'OutOfFund' | 'PcUnderflow' | 'CreateEmpty' | 'Other' | 'InvalidCode';
}
- /** @name EvmCoreErrorExitRevert (298) */
+ /** @name EvmCoreErrorExitRevert (301) */
export interface EvmCoreErrorExitRevert extends Enum {
readonly isReverted: boolean;
readonly type: 'Reverted';
}
- /** @name EvmCoreErrorExitFatal (299) */
+ /** @name EvmCoreErrorExitFatal (302) */
export interface EvmCoreErrorExitFatal extends Enum {
readonly isNotSupported: boolean;
readonly isUnhandledInterrupt: boolean;
@@ -2610,7 +2622,7 @@
readonly type: 'NotSupported' | 'UnhandledInterrupt' | 'CallErrorAsFatal' | 'Other';
}
- /** @name FrameSystemPhase (300) */
+ /** @name FrameSystemPhase (303) */
export interface FrameSystemPhase extends Enum {
readonly isApplyExtrinsic: boolean;
readonly asApplyExtrinsic: u32;
@@ -2619,27 +2631,27 @@
readonly type: 'ApplyExtrinsic' | 'Finalization' | 'Initialization';
}
- /** @name FrameSystemLastRuntimeUpgradeInfo (302) */
+ /** @name FrameSystemLastRuntimeUpgradeInfo (305) */
export interface FrameSystemLastRuntimeUpgradeInfo extends Struct {
readonly specVersion: Compact<u32>;
readonly specName: Text;
}
- /** @name FrameSystemLimitsBlockWeights (303) */
+ /** @name FrameSystemLimitsBlockWeights (306) */
export interface FrameSystemLimitsBlockWeights extends Struct {
readonly baseBlock: u64;
readonly maxBlock: u64;
readonly perClass: FrameSupportWeightsPerDispatchClassWeightsPerClass;
}
- /** @name FrameSupportWeightsPerDispatchClassWeightsPerClass (304) */
+ /** @name FrameSupportWeightsPerDispatchClassWeightsPerClass (307) */
export interface FrameSupportWeightsPerDispatchClassWeightsPerClass extends Struct {
readonly normal: FrameSystemLimitsWeightsPerClass;
readonly operational: FrameSystemLimitsWeightsPerClass;
readonly mandatory: FrameSystemLimitsWeightsPerClass;
}
- /** @name FrameSystemLimitsWeightsPerClass (305) */
+ /** @name FrameSystemLimitsWeightsPerClass (308) */
export interface FrameSystemLimitsWeightsPerClass extends Struct {
readonly baseExtrinsic: u64;
readonly maxExtrinsic: Option<u64>;
@@ -2647,25 +2659,25 @@
readonly reserved: Option<u64>;
}
- /** @name FrameSystemLimitsBlockLength (307) */
+ /** @name FrameSystemLimitsBlockLength (310) */
export interface FrameSystemLimitsBlockLength extends Struct {
readonly max: FrameSupportWeightsPerDispatchClassU32;
}
- /** @name FrameSupportWeightsPerDispatchClassU32 (308) */
+ /** @name FrameSupportWeightsPerDispatchClassU32 (311) */
export interface FrameSupportWeightsPerDispatchClassU32 extends Struct {
readonly normal: u32;
readonly operational: u32;
readonly mandatory: u32;
}
- /** @name FrameSupportWeightsRuntimeDbWeight (309) */
+ /** @name FrameSupportWeightsRuntimeDbWeight (312) */
export interface FrameSupportWeightsRuntimeDbWeight extends Struct {
readonly read: u64;
readonly write: u64;
}
- /** @name SpVersionRuntimeVersion (310) */
+ /** @name SpVersionRuntimeVersion (313) */
export interface SpVersionRuntimeVersion extends Struct {
readonly specName: Text;
readonly implName: Text;
@@ -2677,7 +2689,7 @@
readonly stateVersion: u8;
}
- /** @name FrameSystemError (314) */
+ /** @name FrameSystemError (317) */
export interface FrameSystemError extends Enum {
readonly isInvalidSpecName: boolean;
readonly isSpecVersionNeedsToIncrease: boolean;
@@ -2688,7 +2700,7 @@
readonly type: 'InvalidSpecName' | 'SpecVersionNeedsToIncrease' | 'FailedToExtractRuntimeVersion' | 'NonDefaultComposite' | 'NonZeroRefCount' | 'CallFiltered';
}
- /** @name OrmlVestingModuleError (316) */
+ /** @name OrmlVestingModuleError (319) */
export interface OrmlVestingModuleError extends Enum {
readonly isZeroVestingPeriod: boolean;
readonly isZeroVestingPeriodCount: boolean;
@@ -2699,21 +2711,21 @@
readonly type: 'ZeroVestingPeriod' | 'ZeroVestingPeriodCount' | 'InsufficientBalanceToLock' | 'TooManyVestingSchedules' | 'AmountLow' | 'MaxVestingSchedulesExceeded';
}
- /** @name CumulusPalletXcmpQueueInboundChannelDetails (318) */
+ /** @name CumulusPalletXcmpQueueInboundChannelDetails (321) */
export interface CumulusPalletXcmpQueueInboundChannelDetails extends Struct {
readonly sender: u32;
readonly state: CumulusPalletXcmpQueueInboundState;
readonly messageMetadata: Vec<ITuple<[u32, PolkadotParachainPrimitivesXcmpMessageFormat]>>;
}
- /** @name CumulusPalletXcmpQueueInboundState (319) */
+ /** @name CumulusPalletXcmpQueueInboundState (322) */
export interface CumulusPalletXcmpQueueInboundState extends Enum {
readonly isOk: boolean;
readonly isSuspended: boolean;
readonly type: 'Ok' | 'Suspended';
}
- /** @name PolkadotParachainPrimitivesXcmpMessageFormat (322) */
+ /** @name PolkadotParachainPrimitivesXcmpMessageFormat (325) */
export interface PolkadotParachainPrimitivesXcmpMessageFormat extends Enum {
readonly isConcatenatedVersionedXcm: boolean;
readonly isConcatenatedEncodedBlob: boolean;
@@ -2721,7 +2733,7 @@
readonly type: 'ConcatenatedVersionedXcm' | 'ConcatenatedEncodedBlob' | 'Signals';
}
- /** @name CumulusPalletXcmpQueueOutboundChannelDetails (325) */
+ /** @name CumulusPalletXcmpQueueOutboundChannelDetails (328) */
export interface CumulusPalletXcmpQueueOutboundChannelDetails extends Struct {
readonly recipient: u32;
readonly state: CumulusPalletXcmpQueueOutboundState;
@@ -2730,14 +2742,14 @@
readonly lastIndex: u16;
}
- /** @name CumulusPalletXcmpQueueOutboundState (326) */
+ /** @name CumulusPalletXcmpQueueOutboundState (329) */
export interface CumulusPalletXcmpQueueOutboundState extends Enum {
readonly isOk: boolean;
readonly isSuspended: boolean;
readonly type: 'Ok' | 'Suspended';
}
- /** @name CumulusPalletXcmpQueueQueueConfigData (328) */
+ /** @name CumulusPalletXcmpQueueQueueConfigData (331) */
export interface CumulusPalletXcmpQueueQueueConfigData extends Struct {
readonly suspendThreshold: u32;
readonly dropThreshold: u32;
@@ -2747,7 +2759,7 @@
readonly xcmpMaxIndividualWeight: u64;
}
- /** @name CumulusPalletXcmpQueueError (330) */
+ /** @name CumulusPalletXcmpQueueError (333) */
export interface CumulusPalletXcmpQueueError extends Enum {
readonly isFailedToSend: boolean;
readonly isBadXcmOrigin: boolean;
@@ -2757,7 +2769,7 @@
readonly type: 'FailedToSend' | 'BadXcmOrigin' | 'BadXcm' | 'BadOverweightIndex' | 'WeightOverLimit';
}
- /** @name PalletXcmError (331) */
+ /** @name PalletXcmError (334) */
export interface PalletXcmError extends Enum {
readonly isUnreachable: boolean;
readonly isSendFailure: boolean;
@@ -2775,29 +2787,29 @@
readonly type: 'Unreachable' | 'SendFailure' | 'Filtered' | 'UnweighableMessage' | 'DestinationNotInvertible' | 'Empty' | 'CannotReanchor' | 'TooManyAssets' | 'InvalidOrigin' | 'BadVersion' | 'BadLocation' | 'NoSubscription' | 'AlreadySubscribed';
}
- /** @name CumulusPalletXcmError (332) */
+ /** @name CumulusPalletXcmError (335) */
export type CumulusPalletXcmError = Null;
- /** @name CumulusPalletDmpQueueConfigData (333) */
+ /** @name CumulusPalletDmpQueueConfigData (336) */
export interface CumulusPalletDmpQueueConfigData extends Struct {
readonly maxIndividual: u64;
}
- /** @name CumulusPalletDmpQueuePageIndexData (334) */
+ /** @name CumulusPalletDmpQueuePageIndexData (337) */
export interface CumulusPalletDmpQueuePageIndexData extends Struct {
readonly beginUsed: u32;
readonly endUsed: u32;
readonly overweightCount: u64;
}
- /** @name CumulusPalletDmpQueueError (337) */
+ /** @name CumulusPalletDmpQueueError (340) */
export interface CumulusPalletDmpQueueError extends Enum {
readonly isUnknown: boolean;
readonly isOverLimit: boolean;
readonly type: 'Unknown' | 'OverLimit';
}
- /** @name PalletUniqueError (341) */
+ /** @name PalletUniqueError (344) */
export interface PalletUniqueError extends Enum {
readonly isCollectionDecimalPointLimitExceeded: boolean;
readonly isConfirmUnsetSponsorFail: boolean;
@@ -2805,7 +2817,7 @@
readonly type: 'CollectionDecimalPointLimitExceeded' | 'ConfirmUnsetSponsorFail' | 'EmptyArgument';
}
- /** @name PalletUniqueSchedulerScheduledV3 (344) */
+ /** @name PalletUniqueSchedulerScheduledV3 (347) */
export interface PalletUniqueSchedulerScheduledV3 extends Struct {
readonly maybeId: Option<U8aFixed>;
readonly priority: u8;
@@ -2814,7 +2826,7 @@
readonly origin: OpalRuntimeOriginCaller;
}
- /** @name OpalRuntimeOriginCaller (345) */
+ /** @name OpalRuntimeOriginCaller (348) */
export interface OpalRuntimeOriginCaller extends Enum {
readonly isVoid: boolean;
readonly isSystem: boolean;
@@ -2828,7 +2840,7 @@
readonly type: 'Void' | 'System' | 'PolkadotXcm' | 'CumulusXcm' | 'Ethereum';
}
- /** @name FrameSupportDispatchRawOrigin (346) */
+ /** @name FrameSupportDispatchRawOrigin (349) */
export interface FrameSupportDispatchRawOrigin extends Enum {
readonly isRoot: boolean;
readonly isSigned: boolean;
@@ -2837,7 +2849,7 @@
readonly type: 'Root' | 'Signed' | 'None';
}
- /** @name PalletXcmOrigin (347) */
+ /** @name PalletXcmOrigin (350) */
export interface PalletXcmOrigin extends Enum {
readonly isXcm: boolean;
readonly asXcm: XcmV1MultiLocation;
@@ -2846,7 +2858,7 @@
readonly type: 'Xcm' | 'Response';
}
- /** @name CumulusPalletXcmOrigin (348) */
+ /** @name CumulusPalletXcmOrigin (351) */
export interface CumulusPalletXcmOrigin extends Enum {
readonly isRelay: boolean;
readonly isSiblingParachain: boolean;
@@ -2854,17 +2866,17 @@
readonly type: 'Relay' | 'SiblingParachain';
}
- /** @name PalletEthereumRawOrigin (349) */
+ /** @name PalletEthereumRawOrigin (352) */
export interface PalletEthereumRawOrigin extends Enum {
readonly isEthereumTransaction: boolean;
readonly asEthereumTransaction: H160;
readonly type: 'EthereumTransaction';
}
- /** @name SpCoreVoid (350) */
+ /** @name SpCoreVoid (353) */
export type SpCoreVoid = Null;
- /** @name PalletUniqueSchedulerError (351) */
+ /** @name PalletUniqueSchedulerError (354) */
export interface PalletUniqueSchedulerError extends Enum {
readonly isFailedToSchedule: boolean;
readonly isNotFound: boolean;
@@ -2873,7 +2885,7 @@
readonly type: 'FailedToSchedule' | 'NotFound' | 'TargetBlockNumberInPast' | 'RescheduleNoChange';
}
- /** @name UpDataStructsCollection (352) */
+ /** @name UpDataStructsCollection (355) */
export interface UpDataStructsCollection extends Struct {
readonly owner: AccountId32;
readonly mode: UpDataStructsCollectionMode;
@@ -2886,7 +2898,7 @@
readonly externalCollection: bool;
}
- /** @name UpDataStructsSponsorshipState (353) */
+ /** @name UpDataStructsSponsorshipState (356) */
export interface UpDataStructsSponsorshipState extends Enum {
readonly isDisabled: boolean;
readonly isUnconfirmed: boolean;
@@ -2896,42 +2908,42 @@
readonly type: 'Disabled' | 'Unconfirmed' | 'Confirmed';
}
- /** @name UpDataStructsProperties (354) */
+ /** @name UpDataStructsProperties (357) */
export interface UpDataStructsProperties extends Struct {
readonly map: UpDataStructsPropertiesMapBoundedVec;
readonly consumedSpace: u32;
readonly spaceLimit: u32;
}
- /** @name UpDataStructsPropertiesMapBoundedVec (355) */
+ /** @name UpDataStructsPropertiesMapBoundedVec (358) */
export interface UpDataStructsPropertiesMapBoundedVec extends BTreeMap<Bytes, Bytes> {}
- /** @name UpDataStructsPropertiesMapPropertyPermission (360) */
+ /** @name UpDataStructsPropertiesMapPropertyPermission (363) */
export interface UpDataStructsPropertiesMapPropertyPermission extends BTreeMap<Bytes, UpDataStructsPropertyPermission> {}
- /** @name UpDataStructsCollectionStats (367) */
+ /** @name UpDataStructsCollectionStats (370) */
export interface UpDataStructsCollectionStats extends Struct {
readonly created: u32;
readonly destroyed: u32;
readonly alive: u32;
}
- /** @name UpDataStructsTokenChild (368) */
+ /** @name UpDataStructsTokenChild (371) */
export interface UpDataStructsTokenChild extends Struct {
readonly token: u32;
readonly collection: u32;
}
- /** @name PhantomTypeUpDataStructs (369) */
+ /** @name PhantomTypeUpDataStructs (372) */
export interface PhantomTypeUpDataStructs extends Vec<ITuple<[UpDataStructsTokenData, UpDataStructsRpcCollection, RmrkTraitsCollectionCollectionInfo, RmrkTraitsNftNftInfo, RmrkTraitsResourceResourceInfo, RmrkTraitsPropertyPropertyInfo, RmrkTraitsBaseBaseInfo, RmrkTraitsPartPartType, RmrkTraitsTheme, RmrkTraitsNftNftChild]>> {}
- /** @name UpDataStructsTokenData (371) */
+ /** @name UpDataStructsTokenData (374) */
export interface UpDataStructsTokenData extends Struct {
readonly properties: Vec<UpDataStructsProperty>;
readonly owner: Option<PalletEvmAccountBasicCrossAccountIdRepr>;
}
- /** @name UpDataStructsRpcCollection (373) */
+ /** @name UpDataStructsRpcCollection (376) */
export interface UpDataStructsRpcCollection extends Struct {
readonly owner: AccountId32;
readonly mode: UpDataStructsCollectionMode;
@@ -2946,7 +2958,7 @@
readonly readOnly: bool;
}
- /** @name RmrkTraitsCollectionCollectionInfo (374) */
+ /** @name RmrkTraitsCollectionCollectionInfo (377) */
export interface RmrkTraitsCollectionCollectionInfo extends Struct {
readonly issuer: AccountId32;
readonly metadata: Bytes;
@@ -2955,7 +2967,7 @@
readonly nftsCount: u32;
}
- /** @name RmrkTraitsNftNftInfo (375) */
+ /** @name RmrkTraitsNftNftInfo (378) */
export interface RmrkTraitsNftNftInfo extends Struct {
readonly owner: RmrkTraitsNftAccountIdOrCollectionNftTuple;
readonly royalty: Option<RmrkTraitsNftRoyaltyInfo>;
@@ -2964,13 +2976,13 @@
readonly pending: bool;
}
- /** @name RmrkTraitsNftRoyaltyInfo (377) */
+ /** @name RmrkTraitsNftRoyaltyInfo (380) */
export interface RmrkTraitsNftRoyaltyInfo extends Struct {
readonly recipient: AccountId32;
readonly amount: Permill;
}
- /** @name RmrkTraitsResourceResourceInfo (378) */
+ /** @name RmrkTraitsResourceResourceInfo (381) */
export interface RmrkTraitsResourceResourceInfo extends Struct {
readonly id: u32;
readonly resource: RmrkTraitsResourceResourceTypes;
@@ -2978,37 +2990,26 @@
readonly pendingRemoval: bool;
}
- /** @name RmrkTraitsResourceResourceTypes (379) */
- export interface RmrkTraitsResourceResourceTypes extends Enum {
- readonly isBasic: boolean;
- readonly asBasic: RmrkTraitsResourceBasicResource;
- readonly isComposable: boolean;
- readonly asComposable: RmrkTraitsResourceComposableResource;
- readonly isSlot: boolean;
- readonly asSlot: RmrkTraitsResourceSlotResource;
- readonly type: 'Basic' | 'Composable' | 'Slot';
- }
-
- /** @name RmrkTraitsPropertyPropertyInfo (380) */
+ /** @name RmrkTraitsPropertyPropertyInfo (382) */
export interface RmrkTraitsPropertyPropertyInfo extends Struct {
readonly key: Bytes;
readonly value: Bytes;
}
- /** @name RmrkTraitsBaseBaseInfo (381) */
+ /** @name RmrkTraitsBaseBaseInfo (383) */
export interface RmrkTraitsBaseBaseInfo extends Struct {
readonly issuer: AccountId32;
readonly baseType: Bytes;
readonly symbol: Bytes;
}
- /** @name RmrkTraitsNftNftChild (382) */
+ /** @name RmrkTraitsNftNftChild (384) */
export interface RmrkTraitsNftNftChild extends Struct {
readonly collectionId: u32;
readonly nftId: u32;
}
- /** @name PalletCommonError (384) */
+ /** @name PalletCommonError (386) */
export interface PalletCommonError extends Enum {
readonly isCollectionNotFound: boolean;
readonly isMustBeTokenOwner: boolean;
@@ -3047,7 +3048,7 @@
readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'CantDestroyNotEmptyCollection' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds' | 'UserIsNotAllowedToNest' | 'SourceCollectionIsNotAllowedToNest' | 'CollectionFieldSizeExceeded' | 'NoSpaceForProperty' | 'PropertyLimitReached' | 'PropertyKeyIsTooLong' | 'InvalidCharacterInPropertyKey' | 'EmptyPropertyKey' | 'CollectionIsExternal' | 'CollectionIsInternal';
}
- /** @name PalletFungibleError (386) */
+ /** @name PalletFungibleError (388) */
export interface PalletFungibleError extends Enum {
readonly isNotFungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isFungibleItemsHaveNoId: boolean;
@@ -3057,12 +3058,12 @@
readonly type: 'NotFungibleDataUsedToMintFungibleCollectionToken' | 'FungibleItemsHaveNoId' | 'FungibleItemsDontHaveData' | 'FungibleDisallowsNesting' | 'SettingPropertiesNotAllowed';
}
- /** @name PalletRefungibleItemData (387) */
+ /** @name PalletRefungibleItemData (389) */
export interface PalletRefungibleItemData extends Struct {
readonly constData: Bytes;
}
- /** @name PalletRefungibleError (391) */
+ /** @name PalletRefungibleError (393) */
export interface PalletRefungibleError extends Enum {
readonly isNotRefungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isWrongRefungiblePieces: boolean;
@@ -3071,12 +3072,12 @@
readonly type: 'NotRefungibleDataUsedToMintFungibleCollectionToken' | 'WrongRefungiblePieces' | 'RefungibleDisallowsNesting' | 'SettingPropertiesNotAllowed';
}
- /** @name PalletNonfungibleItemData (392) */
+ /** @name PalletNonfungibleItemData (394) */
export interface PalletNonfungibleItemData extends Struct {
readonly owner: PalletEvmAccountBasicCrossAccountIdRepr;
}
- /** @name PalletNonfungibleError (394) */
+ /** @name PalletNonfungibleError (396) */
export interface PalletNonfungibleError extends Enum {
readonly isNotNonfungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isNonfungibleItemsHaveNoAmount: boolean;
@@ -3084,7 +3085,7 @@
readonly type: 'NotNonfungibleDataUsedToMintFungibleCollectionToken' | 'NonfungibleItemsHaveNoAmount' | 'CantBurnNftWithChildren';
}
- /** @name PalletStructureError (395) */
+ /** @name PalletStructureError (397) */
export interface PalletStructureError extends Enum {
readonly isOuroborosDetected: boolean;
readonly isDepthLimit: boolean;
@@ -3093,12 +3094,13 @@
readonly type: 'OuroborosDetected' | 'DepthLimit' | 'BreadthLimit' | 'TokenNotFound';
}
- /** @name PalletRmrkCoreError (396) */
+ /** @name PalletRmrkCoreError (398) */
export interface PalletRmrkCoreError extends Enum {
readonly isCorruptedCollectionType: boolean;
readonly isNftTypeEncodeError: boolean;
readonly isRmrkPropertyKeyIsTooLong: boolean;
readonly isRmrkPropertyValueIsTooLong: boolean;
+ readonly isUnableToDecodeRmrkData: boolean;
readonly isCollectionNotEmpty: boolean;
readonly isNoAvailableCollectionId: boolean;
readonly isNoAvailableNftId: boolean;
@@ -3111,10 +3113,10 @@
readonly isCannotAcceptNonOwnedNft: boolean;
readonly isCannotRejectNonOwnedNft: boolean;
readonly isResourceNotPending: boolean;
- readonly type: 'CorruptedCollectionType' | 'NftTypeEncodeError' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'ResourceNotPending';
+ readonly type: 'CorruptedCollectionType' | 'NftTypeEncodeError' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'UnableToDecodeRmrkData' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'ResourceNotPending';
}
- /** @name PalletRmrkEquipError (398) */
+ /** @name PalletRmrkEquipError (400) */
export interface PalletRmrkEquipError extends Enum {
readonly isPermissionError: boolean;
readonly isNoAvailableBaseId: boolean;
@@ -3124,7 +3126,7 @@
readonly type: 'PermissionError' | 'NoAvailableBaseId' | 'NoAvailablePartId' | 'BaseDoesntExist' | 'NeedsDefaultThemeFirst';
}
- /** @name PalletEvmError (401) */
+ /** @name PalletEvmError (403) */
export interface PalletEvmError extends Enum {
readonly isBalanceLow: boolean;
readonly isFeeOverflow: boolean;
@@ -3135,7 +3137,7 @@
readonly type: 'BalanceLow' | 'FeeOverflow' | 'PaymentOverflow' | 'WithdrawFailed' | 'GasPriceTooLow' | 'InvalidNonce';
}
- /** @name FpRpcTransactionStatus (404) */
+ /** @name FpRpcTransactionStatus (406) */
export interface FpRpcTransactionStatus extends Struct {
readonly transactionHash: H256;
readonly transactionIndex: u32;
@@ -3146,10 +3148,10 @@
readonly logsBloom: EthbloomBloom;
}
- /** @name EthbloomBloom (406) */
+ /** @name EthbloomBloom (408) */
export interface EthbloomBloom extends U8aFixed {}
- /** @name EthereumReceiptReceiptV3 (408) */
+ /** @name EthereumReceiptReceiptV3 (410) */
export interface EthereumReceiptReceiptV3 extends Enum {
readonly isLegacy: boolean;
readonly asLegacy: EthereumReceiptEip658ReceiptData;
@@ -3160,7 +3162,7 @@
readonly type: 'Legacy' | 'Eip2930' | 'Eip1559';
}
- /** @name EthereumReceiptEip658ReceiptData (409) */
+ /** @name EthereumReceiptEip658ReceiptData (411) */
export interface EthereumReceiptEip658ReceiptData extends Struct {
readonly statusCode: u8;
readonly usedGas: U256;
@@ -3168,14 +3170,14 @@
readonly logs: Vec<EthereumLog>;
}
- /** @name EthereumBlock (410) */
+ /** @name EthereumBlock (412) */
export interface EthereumBlock extends Struct {
readonly header: EthereumHeader;
readonly transactions: Vec<EthereumTransactionTransactionV2>;
readonly ommers: Vec<EthereumHeader>;
}
- /** @name EthereumHeader (411) */
+ /** @name EthereumHeader (413) */
export interface EthereumHeader extends Struct {
readonly parentHash: H256;
readonly ommersHash: H256;
@@ -3194,24 +3196,24 @@
readonly nonce: EthereumTypesHashH64;
}
- /** @name EthereumTypesHashH64 (412) */
+ /** @name EthereumTypesHashH64 (414) */
export interface EthereumTypesHashH64 extends U8aFixed {}
- /** @name PalletEthereumError (417) */
+ /** @name PalletEthereumError (419) */
export interface PalletEthereumError extends Enum {
readonly isInvalidSignature: boolean;
readonly isPreLogExists: boolean;
readonly type: 'InvalidSignature' | 'PreLogExists';
}
- /** @name PalletEvmCoderSubstrateError (418) */
+ /** @name PalletEvmCoderSubstrateError (420) */
export interface PalletEvmCoderSubstrateError extends Enum {
readonly isOutOfGas: boolean;
readonly isOutOfFund: boolean;
readonly type: 'OutOfGas' | 'OutOfFund';
}
- /** @name PalletEvmContractHelpersSponsoringModeT (419) */
+ /** @name PalletEvmContractHelpersSponsoringModeT (421) */
export interface PalletEvmContractHelpersSponsoringModeT extends Enum {
readonly isDisabled: boolean;
readonly isAllowlisted: boolean;
@@ -3219,20 +3221,20 @@
readonly type: 'Disabled' | 'Allowlisted' | 'Generous';
}
- /** @name PalletEvmContractHelpersError (421) */
+ /** @name PalletEvmContractHelpersError (423) */
export interface PalletEvmContractHelpersError extends Enum {
readonly isNoPermission: boolean;
readonly type: 'NoPermission';
}
- /** @name PalletEvmMigrationError (422) */
+ /** @name PalletEvmMigrationError (424) */
export interface PalletEvmMigrationError extends Enum {
readonly isAccountNotEmpty: boolean;
readonly isAccountIsNotMigrating: boolean;
readonly type: 'AccountNotEmpty' | 'AccountIsNotMigrating';
}
- /** @name SpRuntimeMultiSignature (424) */
+ /** @name SpRuntimeMultiSignature (426) */
export interface SpRuntimeMultiSignature extends Enum {
readonly isEd25519: boolean;
readonly asEd25519: SpCoreEd25519Signature;
@@ -3243,34 +3245,34 @@
readonly type: 'Ed25519' | 'Sr25519' | 'Ecdsa';
}
- /** @name SpCoreEd25519Signature (425) */
+ /** @name SpCoreEd25519Signature (427) */
export interface SpCoreEd25519Signature extends U8aFixed {}
- /** @name SpCoreSr25519Signature (427) */
+ /** @name SpCoreSr25519Signature (429) */
export interface SpCoreSr25519Signature extends U8aFixed {}
- /** @name SpCoreEcdsaSignature (428) */
+ /** @name SpCoreEcdsaSignature (430) */
export interface SpCoreEcdsaSignature extends U8aFixed {}
- /** @name FrameSystemExtensionsCheckSpecVersion (431) */
+ /** @name FrameSystemExtensionsCheckSpecVersion (433) */
export type FrameSystemExtensionsCheckSpecVersion = Null;
- /** @name FrameSystemExtensionsCheckGenesis (432) */
+ /** @name FrameSystemExtensionsCheckGenesis (434) */
export type FrameSystemExtensionsCheckGenesis = Null;
- /** @name FrameSystemExtensionsCheckNonce (435) */
+ /** @name FrameSystemExtensionsCheckNonce (437) */
export interface FrameSystemExtensionsCheckNonce extends Compact<u32> {}
- /** @name FrameSystemExtensionsCheckWeight (436) */
+ /** @name FrameSystemExtensionsCheckWeight (438) */
export type FrameSystemExtensionsCheckWeight = Null;
- /** @name PalletTemplateTransactionPaymentChargeTransactionPayment (437) */
+ /** @name PalletTemplateTransactionPaymentChargeTransactionPayment (439) */
export interface PalletTemplateTransactionPaymentChargeTransactionPayment extends Compact<u128> {}
- /** @name OpalRuntimeRuntime (438) */
+ /** @name OpalRuntimeRuntime (440) */
export type OpalRuntimeRuntime = Null;
- /** @name PalletEthereumFakeTransactionFinalizer (439) */
+ /** @name PalletEthereumFakeTransactionFinalizer (441) */
export type PalletEthereumFakeTransactionFinalizer = Null;
} // declare module
tests/src/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -2,6 +2,7 @@
import {tokenIdToAddress} from '../eth/util/helpers';
import usingApi, {executeTransaction} from '../substrate/substrate-api';
import {
+ addCollectionAdminExpectSuccess,
addToAllowListExpectSuccess,
createCollectionExpectSuccess,
createItemExpectSuccess,
@@ -20,10 +21,11 @@
let alice: IKeyringPair;
let bob: IKeyringPair;
+let charlie: IKeyringPair;
-describe('Integration Test: Nesting', () => {
+describe('Integration Test: Composite nesting tests', () => {
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
+ await usingApi(async (_, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
bob = privateKeyWrapper('//Bob');
});
@@ -145,7 +147,79 @@
], 'Children contents check at deeper nesting');
});
});
+});
+describe('Integration Test: Various token type nesting', async () => {
+ before(async () => {
+ await usingApi(async (_, privateKeyWrapper) => {
+ alice = privateKeyWrapper('//Alice');
+ bob = privateKeyWrapper('//Bob');
+ charlie = privateKeyWrapper('//Charlie');
+ });
+ });
+
+ it('Admin (NFT): allows an Admin to nest a token', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {collectionAdmin: true}});
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+ const targetToken = await createItemExpectSuccess(alice, collection, 'NFT', charlie.address);
+
+ // Create a nested token
+ const nestedToken = await createItemExpectSuccess(bob, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});
+ expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});
+
+ // Create a token to be nested and nest
+ const newToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ await transferExpectSuccess(collection, newToken, bob, {Ethereum: tokenIdToAddress(collection, targetToken)});
+ expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});
+ });
+ });
+
+ it('Admin (NFT): Admin and Token Owner can operate together', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true, collectionAdmin: true}});
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+ const targetToken = await createItemExpectSuccess(alice, collection, 'NFT', charlie.address);
+
+ // Create a nested token by an administrator
+ const nestedToken = await createItemExpectSuccess(bob, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});
+ expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});
+
+ // Create a token and allow the owner to nest too
+ const newToken = await createItemExpectSuccess(alice, collection, 'NFT', charlie.address);
+ await transferExpectSuccess(collection, newToken, charlie, {Ethereum: tokenIdToAddress(collection, nestedToken)});
+ expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, nestedToken).toLowerCase()});
+ });
+ });
+
+ it('Admin (NFT): allows an Admin to nest a token (Restricted nesting)', async () => {
+ await usingApi(async api => {
+ const collectionA = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionA, bob.address);
+ const collectionB = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionB, bob.address);
+ await setCollectionPermissionsExpectSuccess(alice, collectionA, {nesting: {collectionAdmin: true, restricted:[collectionA, collectionB]}});
+ const targetToken = await createItemExpectSuccess(alice, collectionA, 'NFT', charlie.address);
+
+ // Create a nested token
+ const nestedToken = await createItemExpectSuccess(bob, collectionB, 'NFT', {Ethereum: tokenIdToAddress(collectionA, targetToken)});
+ expect(await getTopmostTokenOwner(api, collectionB, nestedToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collectionB, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collectionA, targetToken).toLowerCase()});
+
+ // Create a token to be nested and nest
+ const newToken = await createItemExpectSuccess(bob, collectionB, 'NFT');
+ await transferExpectSuccess(collectionB, newToken, bob, {Ethereum: tokenIdToAddress(collectionA, targetToken)});
+ expect(await getTopmostTokenOwner(api, collectionB, newToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collectionB, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collectionA, targetToken).toLowerCase()});
+ });
+ });
+
// ---------- Non-Fungible ----------
it('NFT: allows an Owner to nest/unnest their token', async () => {
@@ -248,7 +322,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
))).to.not.be.rejected;
// Nest a new token
@@ -271,7 +345,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
))).to.not.be.rejected;
// Nest a new token
@@ -283,7 +357,7 @@
describe('Negative Test: Nesting', async() => {
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
+ await usingApi(async (_, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
bob = privateKeyWrapper('//Bob');
});
@@ -314,13 +388,121 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, prevToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/^structure\.DepthLimit$/);
expect(await getTopmostTokenOwner(api, collection, prevToken)).to.be.deep.equal({Substrate: alice.address});
});
});
+ // ---------- Admin ------------
+
+ it('Admin (NFT): disallows an Admin to operate nesting when only TokenOwner is allowed', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true}});
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+ const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
+
+ // Try to create a nested token as collection admin when it's disallowed
+ await expect(executeTransaction(api, bob, api.tx.unique.createItem(
+ collection,
+ {Ethereum: tokenIdToAddress(collection, targetToken)},
+ {nft: {}} as any,
+ )), 'while creating nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
+
+ // Try to create and nest a token in the wrong collection
+ const newToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.transfer({Ethereum: tokenIdToAddress(collection, targetToken)}, collection, newToken, 1),
+ ), 'while nesting new token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});
+ });
+ });
+
+ it('Admin (NFT): disallows a Token Owner to operate nesting when only Admin is allowed', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {collectionAdmin: true}});
+ await addToAllowListExpectSuccess(alice, collection, bob.address);
+ await enableAllowListExpectSuccess(alice, collection);
+ await enablePublicMintingExpectSuccess(alice, collection);
+ const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
+
+ // Try to create a nested token as collection admin when it's disallowed
+ await expect(executeTransaction(api, bob, api.tx.unique.createItem(
+ collection,
+ {Ethereum: tokenIdToAddress(collection, targetToken)},
+ {nft: {}} as any,
+ )), 'while creating nested token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);
+
+ // Try to create and nest a token in the wrong collection
+ const newToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.transfer({Ethereum: tokenIdToAddress(collection, targetToken)}, collection, newToken, 1),
+ ), 'while nesting new token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});
+ });
+ });
+
+ it('Admin (NFT): disallows an Admin to nest and unnest someone else\'s token', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {collectionAdmin: true}});
+
+ await addToAllowListExpectSuccess(alice, collection, bob.address);
+ await enableAllowListExpectSuccess(alice, collection);
+ await enablePublicMintingExpectSuccess(alice, collection);
+
+ // Create a token to attempt to be nested into
+ const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()};
+
+ // Try to nest somebody else's token
+ const newToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ await expect(executeTransaction(
+ api,
+ alice,
+ api.tx.unique.transfer(targetAddress, collection, newToken, 1),
+ ), 'while nesting another\'s token token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});
+
+ // Nest a token as admin and try to unnest it, now belonging to someone else
+ const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', targetAddress);
+ await expect(executeTransaction(
+ api,
+ alice,
+ api.tx.unique.transferFrom(targetAddress, normalizeAccountId(alice), collection, nestedToken, 1),
+ ), 'while unnesting another\'s token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);
+ expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal(targetAddress);
+ expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: bob.address});
+ });
+ });
+
+ it('Admin (NFT): disallows an Admin to nest a token from an unlisted collection (Restricted nesting)', async () => {
+ await usingApi(async api => {
+ const collectionA = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ const collectionB = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionA, {nesting: {collectionAdmin: true, restricted:[collectionA]}});
+
+ // Create a token to attempt to be nested into
+ const targetToken = await createItemExpectSuccess(alice, collectionA, 'NFT');
+
+ // Try to create and nest a token in the wrong collection
+ const newToken = await createItemExpectSuccess(alice, collectionB, 'NFT');
+ await expect(executeTransaction(
+ api,
+ alice,
+ api.tx.unique.transfer({Ethereum: tokenIdToAddress(collectionA, targetToken)}, collectionB, newToken, 1),
+ ), 'while nesting a foreign token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
+ expect(await getTokenOwner(api, collectionB, newToken)).to.be.deep.equal({Substrate: alice.address});
+ });
+ });
+
// ---------- Non-Fungible ----------
it('NFT: disallows to nest token if nesting is disabled', async () => {
@@ -333,7 +515,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, targetToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/^common\.UserIsNotAllowedToNest$/);
// Create a token to be nested
@@ -361,7 +543,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, targetToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -387,7 +569,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, targetToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -409,7 +591,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, targetToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -543,7 +725,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
)), 'while creating a nested token').to.be.rejectedWith(/^common\.UserIsNotAllowedToNest$/);
// Create a token to be nested
@@ -579,7 +761,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
)), 'while creating a nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -606,7 +788,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
)), 'while creating a nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -630,7 +812,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
)), 'while creating a nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection