git.delta.rocks / unique-network / refs/commits / 4950cbc3976b

difftreelog

source

pallets/unique/src/lib.rs45.5 KiBsourcehistory
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//! # Unique Pallet18//!19//! A pallet governing Unique transactions.20//!21//! - [`Config`]22//! - [`Call`]23//! - [`Pallet`]24//!25//! ## Overview26//!27//! The Unique pallet's purpose is to be the primary interface between28//! external users and the inner structure of the Unique chains.29//!30//! It also contains an implementation of [`CollectionHelpers`][`eth`],31//! an Ethereum contract dealing with collection operations.32//!33//! ## Interface34//!35//! ### Dispatchables36//!37//! - `create_collection` - Create a collection of tokens. **Deprecated**, use `create_collection_ex`.38//! - `create_collection_ex` - Create a collection of tokens with explicit parameters.39//! - `destroy_collection` - Destroy a collection if no tokens exist within.40//! - `add_to_allow_list` - Add an address to allow list.41//! - `remove_from_allow_list` - Remove an address from allow list.42//! - `change_collection_owner` - Change the owner of the collection.43//! - `add_collection_admin` - Add an admin to a collection.44//! - `remove_collection_admin` - Remove admin of a collection.45//! - `set_collection_sponsor` - Invite a new collection sponsor.46//! - `confirm_sponsorship` - Confirm own sponsorship of a collection, becoming the sponsor.47//! - `remove_collection_sponsor` - Remove a sponsor from a collection.48//! - `create_item` - Create an item within a collection.49//! - `create_multiple_items` - Create multiple items within a collection.50//! - `set_collection_properties` - Add or change collection properties.51//! - `delete_collection_properties` - Delete specified collection properties.52//! - `set_token_properties` - Add or change token properties.53//! - `delete_token_properties` - Delete token properties.54//! - `set_token_property_permissions` - Add or change token property permissions of a collection.55//! - `create_multiple_items_ex` - Create multiple items within a collection with explicitly specified initial parameters.56//! - `set_transfers_enabled_flag` - Completely allow or disallow transfers for a particular collection.57//! - `burn_item` - Destroy an item.58//! - `burn_from` - Destroy an item on behalf of the owner as a non-owner account.59//! - `transfer` - Change ownership of the token.60//! - `transfer_from` - Change ownership of the token on behalf of the owner as a non-owner account.61//! - `approve` - Allow a non-permissioned address to transfer or burn an item.62//! - `set_collection_limits` - Set specific limits of a collection.63//! - `set_collection_permissions` - Set specific permissions of a collection.64//! - `repartition` - Re-partition a refungible token, while owning all of its parts.6566#![recursion_limit = "1024"]67#![cfg_attr(not(feature = "std"), no_std)]68#![allow(69	clippy::too_many_arguments,70	clippy::unnecessary_mut_passed,71	clippy::unused_unit72)]7374extern crate alloc;7576use frame_support::pallet_prelude::*;77use frame_system::pallet_prelude::*;78pub use pallet::*;79pub mod eth;8081#[cfg(feature = "runtime-benchmarks")]82pub mod benchmarking;83pub mod weights;8485#[frame_support::pallet]86pub mod pallet {87	use frame_support::{dispatch::DispatchResult, ensure, fail, storage::Key, BoundedVec};88	use frame_system::{ensure_root, ensure_signed};89	use pallet_common::{90		dispatch::{dispatch_tx, CollectionDispatch},91		CollectionHandle, CommonWeightInfo, Pallet as PalletCommon, RefungibleExtensionsWeightInfo,92	};93	use pallet_evm::account::CrossAccountId;94	use scale_info::TypeInfo;95	use sp_std::{vec, vec::Vec};96	use up_data_structs::{97		budget, CollectionId, CollectionLimits, CollectionMode, CollectionPermissions,98		CreateCollectionData, CreateItemData, CreateItemExData, Property, PropertyKey,99		PropertyKeyPermission, TokenId, COLLECTION_ADMINS_LIMIT, MAX_COLLECTION_DESCRIPTION_LENGTH,100		MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_PROPERTIES_SIZE, MAX_PROPERTIES_PER_ITEM,101		MAX_PROPERTY_KEY_LENGTH, MAX_PROPERTY_VALUE_LENGTH, MAX_TOKEN_PREFIX_LENGTH,102		MAX_TOKEN_PROPERTIES_SIZE,103	};104	use weights::WeightInfo;105106	use super::*;107108	/// A maximum number of levels of depth in the token nesting tree.109	pub const NESTING_BUDGET: u32 = 5;110111	/// Errors for the common Unique transactions.112	#[pallet::error]113	pub enum Error<T> {114		/// Decimal_points parameter must be lower than [`up_data_structs::MAX_DECIMAL_POINTS`].115		CollectionDecimalPointLimitExceeded,116		/// Length of items properties must be greater than 0.117		EmptyArgument,118		/// Repertition is only supported by refungible collection.119		RepartitionCalledOnNonRefungibleCollection,120	}121122	/// Configuration trait of this pallet.123	#[pallet::config]124	pub trait Config: frame_system::Config + pallet_common::Config + Sized + TypeInfo {125		/// Weight information for extrinsics in this pallet.126		type WeightInfo: WeightInfo;127128		/// Weight information for common pallet operations.129		type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;130131		/// Weight info information for extra refungible pallet operations.132		type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;133	}134135	#[pallet::pallet]136	pub struct Pallet<T>(_);137138	pub type SelfWeightOf<T> = <T as Config>::WeightInfo;139140	// # Used definitions141	//142	// ## User control levels143	//144	// chain-controlled - key is uncontrolled by user145	//                    i.e autoincrementing index146	//                    can use non-cryptographic hash147	// real - key is controlled by user148	//        but it is hard to generate enough colliding values, i.e owner of signed txs149	//        can use non-cryptographic hash150	// controlled - key is completly controlled by users151	//              i.e maps with mutable keys152	//              should use cryptographic hash153	//154	// ## User control level downgrade reasons155	//156	// ?1 - chain-controlled -> controlled157	//      collections/tokens can be destroyed, resulting in massive holes158	// ?2 - chain-controlled -> controlled159	//      same as ?1, but can be only added, resulting in easier exploitation160	// ?3 - real -> controlled161	//      no confirmation required, so addresses can be easily generated162163	//#region Private members164	/// Used for migrations165	#[pallet::storage]166	pub type ChainVersion<T> = StorageValue<_, u64, ValueQuery>;167	//#endregion168169	//#region Tokens transfer sponosoring rate limit baskets170	/// (Collection id (controlled?2), who created (real))171	/// TODO: Off chain worker should remove from this map when collection gets removed172	#[pallet::storage]173	#[pallet::getter(fn create_item_busket)]174	pub type CreateItemBasket<T: Config> = StorageMap<175		Hasher = Blake2_128Concat,176		Key = (CollectionId, T::AccountId),177		Value = BlockNumberFor<T>,178		QueryKind = OptionQuery,179	>;180	/// Collection id (controlled?2), token id (controlled?2)181	#[pallet::storage]182	#[pallet::getter(fn nft_transfer_basket)]183	pub type NftTransferBasket<T: Config> = StorageDoubleMap<184		Hasher1 = Blake2_128Concat,185		Key1 = CollectionId,186		Hasher2 = Blake2_128Concat,187		Key2 = TokenId,188		Value = BlockNumberFor<T>,189		QueryKind = OptionQuery,190	>;191	/// Collection id (controlled?2), owning user (real)192	#[pallet::storage]193	#[pallet::getter(fn fungible_transfer_basket)]194	pub type FungibleTransferBasket<T: Config> = StorageDoubleMap<195		Hasher1 = Blake2_128Concat,196		Key1 = CollectionId,197		Hasher2 = Twox64Concat,198		Key2 = T::AccountId,199		Value = BlockNumberFor<T>,200		QueryKind = OptionQuery,201	>;202	/// Collection id (controlled?2), token id (controlled?2)203	#[pallet::storage]204	#[pallet::getter(fn refungible_transfer_basket)]205	pub type ReFungibleTransferBasket<T: Config> = StorageNMap<206		Key = (207			Key<Blake2_128Concat, CollectionId>,208			Key<Blake2_128Concat, TokenId>,209			Key<Twox64Concat, T::AccountId>,210		),211		Value = BlockNumberFor<T>,212		QueryKind = OptionQuery,213	>;214	//#endregion215216	/// Last sponsoring of token property setting // todo:doc rephrase this and the following217	#[pallet::storage]218	#[pallet::getter(fn token_property_basket)]219	pub type TokenPropertyBasket<T: Config> = StorageDoubleMap<220		Hasher1 = Blake2_128Concat,221		Key1 = CollectionId,222		Hasher2 = Blake2_128Concat,223		Key2 = TokenId,224		Value = BlockNumberFor<T>,225		QueryKind = OptionQuery,226	>;227228	/// Last sponsoring of NFT approval in a collection229	#[pallet::storage]230	#[pallet::getter(fn nft_approve_basket)]231	pub type NftApproveBasket<T: Config> = StorageDoubleMap<232		Hasher1 = Blake2_128Concat,233		Key1 = CollectionId,234		Hasher2 = Blake2_128Concat,235		Key2 = TokenId,236		Value = BlockNumberFor<T>,237		QueryKind = OptionQuery,238	>;239	/// Last sponsoring of fungible tokens approval in a collection240	#[pallet::storage]241	#[pallet::getter(fn fungible_approve_basket)]242	pub type FungibleApproveBasket<T: Config> = StorageDoubleMap<243		Hasher1 = Blake2_128Concat,244		Key1 = CollectionId,245		Hasher2 = Twox64Concat,246		Key2 = T::AccountId,247		Value = BlockNumberFor<T>,248		QueryKind = OptionQuery,249	>;250	/// Last sponsoring of RFT approval in a collection251	#[pallet::storage]252	#[pallet::getter(fn refungible_approve_basket)]253	pub type RefungibleApproveBasket<T: Config> = StorageNMap<254		Key = (255			Key<Blake2_128Concat, CollectionId>,256			Key<Blake2_128Concat, TokenId>,257			Key<Twox64Concat, T::AccountId>,258		),259		Value = BlockNumberFor<T>,260		QueryKind = OptionQuery,261	>;262263	#[pallet::extra_constants]264	impl<T: Config> Pallet<T> {265		/// A maximum number of levels of depth in the token nesting tree.266		fn nesting_budget() -> u32 {267			NESTING_BUDGET268		}269270		/// Maximal length of a collection name.271		fn max_collection_name_length() -> u32 {272			MAX_COLLECTION_NAME_LENGTH273		}274275		/// Maximal length of a collection description.276		fn max_collection_description_length() -> u32 {277			MAX_COLLECTION_DESCRIPTION_LENGTH278		}279280		/// Maximal length of a token prefix.281		fn max_token_prefix_length() -> u32 {282			MAX_TOKEN_PREFIX_LENGTH283		}284285		/// Maximum admins per collection.286		fn collection_admins_limit() -> u32 {287			COLLECTION_ADMINS_LIMIT288		}289290		/// Maximal length of a property key.291		fn max_property_key_length() -> u32 {292			MAX_PROPERTY_KEY_LENGTH293		}294295		/// Maximal length of a property value.296		fn max_property_value_length() -> u32 {297			MAX_PROPERTY_VALUE_LENGTH298		}299300		/// A maximum number of token properties.301		fn max_properties_per_item() -> u32 {302			MAX_PROPERTIES_PER_ITEM303		}304305		/// Maximum size for all collection properties.306		fn max_collection_properties_size() -> u32 {307			MAX_COLLECTION_PROPERTIES_SIZE308		}309310		/// Maximum size of all token properties.311		fn max_token_properties_size() -> u32 {312			MAX_TOKEN_PROPERTIES_SIZE313		}314315		/// Default NFT collection limit.316		fn nft_default_collection_limits() -> CollectionLimits {317			CollectionLimits::with_default_limits(CollectionMode::NFT)318		}319320		/// Default RFT collection limit.321		fn rft_default_collection_limits() -> CollectionLimits {322			CollectionLimits::with_default_limits(CollectionMode::ReFungible)323		}324325		/// Default FT collection limit.326		fn ft_default_collection_limits() -> CollectionLimits {327			CollectionLimits::with_default_limits(CollectionMode::Fungible(0))328		}329	}330331	/// Type alias to Pallet, to be used by construct_runtime.332	#[pallet::call]333	impl<T: Config> Pallet<T> {334		/// Create a collection of tokens.335		///336		/// Each Token may have multiple properties encoded as an array of bytes337		/// of certain length. The initial owner of the collection is set338		/// to the address that signed the transaction and can be changed later.339		///340		/// Prefer the more advanced [`create_collection_ex`][`Pallet::create_collection_ex`] instead.341		///342		/// # Permissions343		///344		/// * Anyone - becomes the owner of the new collection.345		///346		/// # Arguments347		///348		/// * `collection_name`: Wide-character string with collection name349		/// (limit [`MAX_COLLECTION_NAME_LENGTH`]).350		/// * `collection_description`: Wide-character string with collection description351		/// (limit [`MAX_COLLECTION_DESCRIPTION_LENGTH`]).352		/// * `token_prefix`: Byte string containing the token prefix to mark a collection353		/// to which a token belongs (limit [`MAX_TOKEN_PREFIX_LENGTH`]).354		/// * `mode`: Type of items stored in the collection and type dependent data.355		///356		/// returns collection ID357		///358		/// Deprecated: `create_collection_ex` is more up-to-date and advanced, prefer it instead.359		#[pallet::call_index(0)]360		#[pallet::weight(<SelfWeightOf<T>>::create_collection())]361		pub fn create_collection(362			origin: OriginFor<T>,363			collection_name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,364			collection_description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,365			token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,366			mode: CollectionMode,367		) -> DispatchResult {368			let data: CreateCollectionData<T::CrossAccountId> = CreateCollectionData {369				name: collection_name,370				description: collection_description,371				token_prefix,372				mode,373				..Default::default()374			};375			Self::create_collection_ex(origin, data)376		}377378		/// Create a collection with explicit parameters.379		///380		/// Prefer it to the deprecated [`create_collection`][`Pallet::create_collection`] method.381		///382		/// # Permissions383		///384		/// * Anyone - becomes the owner of the new collection.385		///386		/// # Arguments387		///388		/// * `data`: Explicit data of a collection used for its creation.389		#[pallet::call_index(1)]390		#[pallet::weight(<SelfWeightOf<T>>::create_collection())]391		pub fn create_collection_ex(392			origin: OriginFor<T>,393			data: CreateCollectionData<T::CrossAccountId>,394		) -> DispatchResult {395			let sender = ensure_signed(origin)?;396397			// =========398			let sender = T::CrossAccountId::from_sub(sender);399			let _id = T::CollectionDispatch::create(sender.clone(), sender, data)?;400401			Ok(())402		}403404		/// Destroy a collection if no tokens exist within.405		///406		/// # Permissions407		///408		/// * Collection owner409		///410		/// # Arguments411		///412		/// * `collection_id`: Collection to destroy.413		#[pallet::call_index(2)]414		#[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]415		pub fn destroy_collection(416			origin: OriginFor<T>,417			collection_id: CollectionId,418		) -> DispatchResult {419			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);420421			Self::destroy_collection_internal(sender, collection_id)422		}423424		/// Add an address to allow list.425		///426		/// # Permissions427		///428		/// * Collection owner429		/// * Collection admin430		///431		/// # Arguments432		///433		/// * `collection_id`: ID of the modified collection.434		/// * `address`: ID of the address to be added to the allowlist.435		#[pallet::call_index(3)]436		#[pallet::weight(<SelfWeightOf<T>>::add_to_allow_list())]437		pub fn add_to_allow_list(438			origin: OriginFor<T>,439			collection_id: CollectionId,440			address: T::CrossAccountId,441		) -> DispatchResult {442			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {443				fail!(<pallet_common::Error<T>>::UnsupportedOperation);444			}445446			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);447			let collection = <CollectionHandle<T>>::try_get(collection_id)?;448			collection.check_is_internal()?;449450			<PalletCommon<T>>::toggle_allowlist(&collection, &sender, &address, true)?;451452			Ok(())453		}454455		/// Remove an address from allow list.456		///457		/// # Permissions458		///459		/// * Collection owner460		/// * Collection admin461		///462		/// # Arguments463		///464		/// * `collection_id`: ID of the modified collection.465		/// * `address`: ID of the address to be removed from the allowlist.466		#[pallet::call_index(4)]467		#[pallet::weight(<SelfWeightOf<T>>::remove_from_allow_list())]468		pub fn remove_from_allow_list(469			origin: OriginFor<T>,470			collection_id: CollectionId,471			address: T::CrossAccountId,472		) -> DispatchResult {473			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {474				fail!(<pallet_common::Error<T>>::UnsupportedOperation);475			}476477			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);478			let collection = <CollectionHandle<T>>::try_get(collection_id)?;479			collection.check_is_internal()?;480481			<PalletCommon<T>>::toggle_allowlist(&collection, &sender, &address, false)?;482483			Ok(())484		}485486		/// Change the owner of the collection.487		///488		/// # Permissions489		///490		/// * Collection owner491		///492		/// # Arguments493		///494		/// * `collection_id`: ID of the modified collection.495		/// * `new_owner`: ID of the account that will become the owner.496		#[pallet::call_index(5)]497		#[pallet::weight(<SelfWeightOf<T>>::change_collection_owner())]498		pub fn change_collection_owner(499			origin: OriginFor<T>,500			collection_id: CollectionId,501			new_owner: T::AccountId,502		) -> DispatchResult {503			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {504				fail!(<pallet_common::Error<T>>::UnsupportedOperation);505			}506			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);507			let new_owner = T::CrossAccountId::from_sub(new_owner);508			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;509			target_collection.change_owner(sender, new_owner)510		}511512		/// Add an admin to a collection.513		///514		/// NFT Collection can be controlled by multiple admin addresses515		/// (some which can also be servers, for example). Admins can issue516		/// and burn NFTs, as well as add and remove other admins,517		/// but cannot change NFT or Collection ownership.518		///519		/// # Permissions520		///521		/// * Collection owner522		/// * Collection admin523		///524		/// # Arguments525		///526		/// * `collection_id`: ID of the Collection to add an admin for.527		/// * `new_admin`: Address of new admin to add.528		#[pallet::call_index(6)]529		#[pallet::weight(<SelfWeightOf<T>>::add_collection_admin())]530		pub fn add_collection_admin(531			origin: OriginFor<T>,532			collection_id: CollectionId,533			new_admin_id: T::CrossAccountId,534		) -> DispatchResult {535			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {536				fail!(<pallet_common::Error<T>>::UnsupportedOperation);537			}538			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);539			let collection = <CollectionHandle<T>>::try_get(collection_id)?;540			<PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)541		}542543		/// Remove admin of a collection.544		///545		/// An admin address can remove itself. List of admins may become empty,546		/// in which case only Collection Owner will be able to add an Admin.547		///548		/// # Permissions549		///550		/// * Collection owner551		/// * Collection admin552		///553		/// # Arguments554		///555		/// * `collection_id`: ID of the collection to remove the admin for.556		/// * `account_id`: Address of the admin to remove.557		#[pallet::call_index(7)]558		#[pallet::weight(<SelfWeightOf<T>>::remove_collection_admin())]559		pub fn remove_collection_admin(560			origin: OriginFor<T>,561			collection_id: CollectionId,562			account_id: T::CrossAccountId,563		) -> DispatchResult {564			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {565				fail!(<pallet_common::Error<T>>::UnsupportedOperation);566			}567			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);568			let collection = <CollectionHandle<T>>::try_get(collection_id)?;569			<PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)570		}571572		/// Set (invite) a new collection sponsor.573		///574		/// If successful, confirmation from the sponsor-to-be will be pending.575		///576		/// # Permissions577		///578		/// * Collection owner579		/// * Collection admin580		///581		/// # Arguments582		///583		/// * `collection_id`: ID of the modified collection.584		/// * `new_sponsor`: ID of the account of the sponsor-to-be.585		#[pallet::call_index(8)]586		#[pallet::weight(<SelfWeightOf<T>>::set_collection_sponsor())]587		pub fn set_collection_sponsor(588			origin: OriginFor<T>,589			collection_id: CollectionId,590			new_sponsor: T::AccountId,591		) -> DispatchResult {592			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {593				fail!(<pallet_common::Error<T>>::UnsupportedOperation);594			}595			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);596			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;597			target_collection.set_sponsor(&sender, new_sponsor.clone())598		}599600		/// Confirm own sponsorship of a collection, becoming the sponsor.601		///602		/// An invitation must be pending, see [`set_collection_sponsor`][`Pallet::set_collection_sponsor`].603		/// Sponsor can pay the fees of a transaction instead of the sender,604		/// but only within specified limits.605		///606		/// # Permissions607		///608		/// * Sponsor-to-be609		///610		/// # Arguments611		///612		/// * `collection_id`: ID of the collection with the pending sponsor.613		#[pallet::call_index(9)]614		#[pallet::weight(<SelfWeightOf<T>>::confirm_sponsorship())]615		pub fn confirm_sponsorship(616			origin: OriginFor<T>,617			collection_id: CollectionId,618		) -> DispatchResult {619			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {620				fail!(<pallet_common::Error<T>>::UnsupportedOperation);621			}622			let sender = ensure_signed(origin)?;623			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;624			target_collection.confirm_sponsorship(&sender)625		}626627		/// Remove a collection's a sponsor, making everyone pay for their own transactions.628		///629		/// # Permissions630		///631		/// * Collection owner632		///633		/// # Arguments634		///635		/// * `collection_id`: ID of the collection with the sponsor to remove.636		#[pallet::call_index(10)]637		#[pallet::weight(<SelfWeightOf<T>>::remove_collection_sponsor())]638		pub fn remove_collection_sponsor(639			origin: OriginFor<T>,640			collection_id: CollectionId,641		) -> DispatchResult {642			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {643				fail!(<pallet_common::Error<T>>::UnsupportedOperation);644			}645			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);646			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;647			target_collection.remove_sponsor(&sender)648		}649650		/// Mint an item within a collection.651		///652		/// A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].653		///654		/// # Permissions655		///656		/// * Collection owner657		/// * Collection admin658		/// * Anyone if659		///     * Allow List is enabled, and660		///     * Address is added to allow list, and661		///     * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])662		///663		/// # Arguments664		///665		/// * `collection_id`: ID of the collection to which an item would belong.666		/// * `owner`: Address of the initial owner of the item.667		/// * `data`: Token data describing the item to store on chain.668		#[pallet::call_index(11)]669		#[pallet::weight(T::CommonWeightInfo::create_item(data))]670		pub fn create_item(671			origin: OriginFor<T>,672			collection_id: CollectionId,673			owner: T::CrossAccountId,674			data: CreateItemData,675		) -> DispatchResultWithPostInfo {676			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);677			let budget = budget::Value::new(NESTING_BUDGET);678679			dispatch_tx::<T, _>(collection_id, |d| {680				d.create_item(sender, owner, data, &budget)681			})682		}683684		/// Create multiple items within a collection.685		///686		/// A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].687		///688		/// # Permissions689		///690		/// * Collection owner691		/// * Collection admin692		/// * Anyone if693		///     * Allow List is enabled, and694		///     * Address is added to the allow list, and695		///     * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])696		///697		/// # Arguments698		///699		/// * `collection_id`: ID of the collection to which the tokens would belong.700		/// * `owner`: Address of the initial owner of the tokens.701		/// * `items_data`: Vector of data describing each item to be created.702		#[pallet::call_index(12)]703		#[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data))]704		pub fn create_multiple_items(705			origin: OriginFor<T>,706			collection_id: CollectionId,707			owner: T::CrossAccountId,708			items_data: Vec<CreateItemData>,709		) -> DispatchResultWithPostInfo {710			ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);711			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);712			let budget = budget::Value::new(NESTING_BUDGET);713714			dispatch_tx::<T, _>(collection_id, |d| {715				d.create_multiple_items(sender, owner, items_data, &budget)716			})717		}718719		/// Add or change collection properties.720		///721		/// # Permissions722		///723		/// * Collection owner724		/// * Collection admin725		///726		/// # Arguments727		///728		/// * `collection_id`: ID of the modified collection.729		/// * `properties`: Vector of key-value pairs stored as the collection's metadata.730		/// Keys support Latin letters, `-`, `_`, and `.` as symbols.731		#[pallet::call_index(13)]732		#[pallet::weight(T::CommonWeightInfo::set_collection_properties(properties.len() as u32))]733		pub fn set_collection_properties(734			origin: OriginFor<T>,735			collection_id: CollectionId,736			properties: Vec<Property>,737		) -> DispatchResultWithPostInfo {738			ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);739740			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);741742			dispatch_tx::<T, _>(collection_id, |d| {743				d.set_collection_properties(sender, properties)744			})745		}746747		/// Delete specified collection properties.748		///749		/// # Permissions750		///751		/// * Collection Owner752		/// * Collection Admin753		///754		/// # Arguments755		///756		/// * `collection_id`: ID of the modified collection.757		/// * `property_keys`: Vector of keys of the properties to be deleted.758		/// Keys support Latin letters, `-`, `_`, and `.` as symbols.759		#[pallet::call_index(14)]760		#[pallet::weight(T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32))]761		pub fn delete_collection_properties(762			origin: OriginFor<T>,763			collection_id: CollectionId,764			property_keys: Vec<PropertyKey>,765		) -> DispatchResultWithPostInfo {766			ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);767768			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);769770			dispatch_tx::<T, _>(collection_id, |d| {771				d.delete_collection_properties(&sender, property_keys)772			})773		}774775		/// Add or change token properties according to collection's permissions.776		/// Currently properties only work with NFTs.777		///778		/// # Permissions779		///780		/// * Depends on collection's token property permissions and specified property mutability:781		/// 	* Collection owner782		/// 	* Collection admin783		/// 	* Token owner784		///785		/// See [`set_token_property_permissions`][`Pallet::set_token_property_permissions`].786		///787		/// # Arguments788		///789		/// * `collection_id: ID of the collection to which the token belongs.790		/// * `token_id`: ID of the modified token.791		/// * `properties`: Vector of key-value pairs stored as the token's metadata.792		/// Keys support Latin letters, `-`, `_`, and `.` as symbols.793		#[pallet::call_index(15)]794		#[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32))]795		pub fn set_token_properties(796			origin: OriginFor<T>,797			collection_id: CollectionId,798			token_id: TokenId,799			properties: Vec<Property>,800		) -> DispatchResultWithPostInfo {801			ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);802803			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);804			let budget = budget::Value::new(NESTING_BUDGET);805806			dispatch_tx::<T, _>(collection_id, |d| {807				d.set_token_properties(sender, token_id, properties, &budget)808			})809		}810811		/// Delete specified token properties. Currently properties only work with NFTs.812		///813		/// # Permissions814		///815		/// * Depends on collection's token property permissions and specified property mutability:816		/// 	* Collection owner817		/// 	* Collection admin818		/// 	* Token owner819		///820		/// # Arguments821		///822		/// * `collection_id`: ID of the collection to which the token belongs.823		/// * `token_id`: ID of the modified token.824		/// * `property_keys`: Vector of keys of the properties to be deleted.825		/// Keys support Latin letters, `-`, `_`, and `.` as symbols.826		#[pallet::call_index(16)]827		#[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32))]828		pub fn delete_token_properties(829			origin: OriginFor<T>,830			collection_id: CollectionId,831			token_id: TokenId,832			property_keys: Vec<PropertyKey>,833		) -> DispatchResultWithPostInfo {834			ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);835836			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);837			let budget = budget::Value::new(NESTING_BUDGET);838839			dispatch_tx::<T, _>(collection_id, |d| {840				d.delete_token_properties(sender, token_id, property_keys, &budget)841			})842		}843844		/// Add or change token property permissions of a collection.845		///846		/// Without a permission for a particular key, a property with that key847		/// cannot be created in a token.848		///849		/// # Permissions850		///851		/// * Collection owner852		/// * Collection admin853		///854		/// # Arguments855		///856		/// * `collection_id`: ID of the modified collection.857		/// * `property_permissions`: Vector of permissions for property keys.858		/// Keys support Latin letters, `-`, `_`, and `.` as symbols.859		#[pallet::call_index(17)]860		#[pallet::weight(T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32))]861		pub fn set_token_property_permissions(862			origin: OriginFor<T>,863			collection_id: CollectionId,864			property_permissions: Vec<PropertyKeyPermission>,865		) -> DispatchResultWithPostInfo {866			ensure!(!property_permissions.is_empty(), Error::<T>::EmptyArgument);867868			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);869870			dispatch_tx::<T, _>(collection_id, |d| {871				d.set_token_property_permissions(&sender, property_permissions)872			})873		}874875		/// Create multiple items within a collection with explicitly specified initial parameters.876		///877		/// # Permissions878		///879		/// * Collection owner880		/// * Collection admin881		/// * Anyone if882		///     * Allow List is enabled, and883		///     * Address is added to allow list, and884		///     * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])885		///886		/// # Arguments887		///888		/// * `collection_id`: ID of the collection to which the tokens would belong.889		/// * `data`: Explicit item creation data.890		#[pallet::call_index(18)]891		#[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data))]892		pub fn create_multiple_items_ex(893			origin: OriginFor<T>,894			collection_id: CollectionId,895			data: CreateItemExData<T::CrossAccountId>,896		) -> DispatchResultWithPostInfo {897			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);898			let budget = budget::Value::new(NESTING_BUDGET);899900			dispatch_tx::<T, _>(collection_id, |d| {901				d.create_multiple_items_ex(sender, data, &budget)902			})903		}904905		/// Completely allow or disallow transfers for a particular collection.906		///907		/// # Permissions908		///909		/// * Collection owner910		///911		/// # Arguments912		///913		/// * `collection_id`: ID of the collection.914		/// * `value`: New value of the flag, are transfers allowed?915		#[pallet::call_index(19)]916		#[pallet::weight(<SelfWeightOf<T>>::set_transfers_enabled_flag())]917		pub fn set_transfers_enabled_flag(918			origin: OriginFor<T>,919			collection_id: CollectionId,920			value: bool,921		) -> DispatchResult {922			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {923				fail!(<pallet_common::Error<T>>::UnsupportedOperation);924			}925			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);926			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;927			target_collection.check_is_internal()?;928			target_collection.check_is_owner(&sender)?;929930			// =========931932			target_collection.limits.transfers_enabled = Some(value);933			target_collection.save()934		}935936		/// Destroy an item.937		///938		/// # Permissions939		///940		/// * Collection owner941		/// * Collection admin942		/// * Current item owner943		///944		/// # Arguments945		///946		/// * `collection_id`: ID of the collection to which the item belongs.947		/// * `item_id`: ID of item to burn.948		/// * `value`: Number of pieces of the item to destroy.949		/// 	* Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.950		///     * Fungible Mode: The desired number of pieces to burn.951		///     * Re-Fungible Mode: The desired number of pieces to burn.952		#[pallet::call_index(20)]953		#[pallet::weight(T::CommonWeightInfo::burn_item())]954		pub fn burn_item(955			origin: OriginFor<T>,956			collection_id: CollectionId,957			item_id: TokenId,958			value: u128,959		) -> DispatchResultWithPostInfo {960			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);961962			let post_info =963				dispatch_tx::<T, _>(collection_id, |d| d.burn_item(sender, item_id, value))?;964			if value == 1 {965				<NftTransferBasket<T>>::remove(collection_id, item_id);966				<NftApproveBasket<T>>::remove(collection_id, item_id);967			}968			// Those maps should be cleared only if token disappears completly, need to move this part of logic to pallets?969			// <FungibleApproveBasket<T>>::remove(collection_id, sender.as_sub());970			// <RefungibleApproveBasket<T>>::remove((collection_id, item_id, sender.as_sub()));971			Ok(post_info)972		}973974		/// Destroy a token on behalf of the owner as a non-owner account.975		///976		/// See also: [`approve`][`Pallet::approve`].977		///978		/// After this method executes, one approval is removed from the total so that979		/// the approved address will not be able to transfer this item again from this owner.980		///981		/// # Permissions982		///983		/// * Collection owner984		/// * Collection admin985		/// * Current token owner986		/// * Address approved by current item owner987		///988		/// # Arguments989		///990		/// * `from`: The owner of the burning item.991		/// * `collection_id`: ID of the collection to which the item belongs.992		/// * `item_id`: ID of item to burn.993		/// * `value`: Number of pieces to burn.994		/// 	* Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.995		///     * Fungible Mode: The desired number of pieces to burn.996		///     * Re-Fungible Mode: The desired number of pieces to burn.997		#[pallet::call_index(21)]998		#[pallet::weight(T::CommonWeightInfo::burn_from())]999		pub fn burn_from(1000			origin: OriginFor<T>,1001			collection_id: CollectionId,1002			from: T::CrossAccountId,1003			item_id: TokenId,1004			value: u128,1005		) -> DispatchResultWithPostInfo {1006			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1007			let budget = budget::Value::new(NESTING_BUDGET);10081009			dispatch_tx::<T, _>(collection_id, |d| {1010				d.burn_from(sender, from, item_id, value, &budget)1011			})1012		}10131014		/// Change ownership of the token.1015		///1016		/// # Permissions1017		///1018		/// * Collection owner1019		/// * Collection admin1020		/// * Current token owner1021		///1022		/// # Arguments1023		///1024		/// * `recipient`: Address of token recipient.1025		/// * `collection_id`: ID of the collection the item belongs to.1026		/// * `item_id`: ID of the item.1027		///     * Non-Fungible Mode: Required.1028		///     * Fungible Mode: Ignored.1029		///     * Re-Fungible Mode: Required.1030		///1031		/// * `value`: Amount to transfer.1032		/// 	* Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.1033		///     * Fungible Mode: The desired number of pieces to transfer.1034		///     * Re-Fungible Mode: The desired number of pieces to transfer.1035		#[pallet::call_index(22)]1036		#[pallet::weight(T::CommonWeightInfo::transfer())]1037		pub fn transfer(1038			origin: OriginFor<T>,1039			recipient: T::CrossAccountId,1040			collection_id: CollectionId,1041			item_id: TokenId,1042			value: u128,1043		) -> DispatchResultWithPostInfo {1044			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1045			let budget = budget::Value::new(NESTING_BUDGET);10461047			dispatch_tx::<T, _>(collection_id, |d| {1048				d.transfer(sender, recipient, item_id, value, &budget)1049			})1050		}10511052		/// Allow a non-permissioned address to transfer or burn an item.1053		///1054		/// # Permissions1055		///1056		/// * Collection owner1057		/// * Collection admin1058		/// * Current item owner1059		///1060		/// # Arguments1061		///1062		/// * `spender`: Account to be approved to make specific transactions on non-owned tokens.1063		/// * `collection_id`: ID of the collection the item belongs to.1064		/// * `item_id`: ID of the item transactions on which are now approved.1065		/// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).1066		/// Set to 0 to revoke the approval.1067		#[pallet::call_index(23)]1068		#[pallet::weight(T::CommonWeightInfo::approve())]1069		pub fn approve(1070			origin: OriginFor<T>,1071			spender: T::CrossAccountId,1072			collection_id: CollectionId,1073			item_id: TokenId,1074			amount: u128,1075		) -> DispatchResultWithPostInfo {1076			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);10771078			dispatch_tx::<T, _>(collection_id, |d| {1079				d.approve(sender, spender, item_id, amount)1080			})1081		}10821083		/// Allow a non-permissioned address to transfer or burn an item from owner's eth mirror.1084		///1085		/// # Permissions1086		///1087		/// * Collection owner1088		/// * Collection admin1089		/// * Current item owner1090		///1091		/// # Arguments1092		///1093		/// * `from`: Owner's account eth mirror1094		/// * `to`: Account to be approved to make specific transactions on non-owned tokens.1095		/// * `collection_id`: ID of the collection the item belongs to.1096		/// * `item_id`: ID of the item transactions on which are now approved.1097		/// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).1098		/// Set to 0 to revoke the approval.1099		#[pallet::call_index(24)]1100		#[pallet::weight(T::CommonWeightInfo::approve_from())]1101		pub fn approve_from(1102			origin: OriginFor<T>,1103			from: T::CrossAccountId,1104			to: T::CrossAccountId,1105			collection_id: CollectionId,1106			item_id: TokenId,1107			amount: u128,1108		) -> DispatchResultWithPostInfo {1109			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);11101111			dispatch_tx::<T, _>(collection_id, |d| {1112				d.approve_from(sender, from, to, item_id, amount)1113			})1114		}11151116		/// Change ownership of an item on behalf of the owner as a non-owner account.1117		///1118		/// See the [`approve`][`Pallet::approve`] method for additional information.1119		///1120		/// After this method executes, one approval is removed from the total so that1121		/// the approved address will not be able to transfer this item again from this owner.1122		///1123		/// # Permissions1124		///1125		/// * Collection owner1126		/// * Collection admin1127		/// * Current item owner1128		/// * Address approved by current item owner1129		///1130		/// # Arguments1131		///1132		/// * `from`: Address that currently owns the token.1133		/// * `recipient`: Address of the new token-owner-to-be.1134		/// * `collection_id`: ID of the collection the item.1135		/// * `item_id`: ID of the item to be transferred.1136		/// * `value`: Amount to transfer.1137		/// 	* Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.1138		///     * Fungible Mode: The desired number of pieces to transfer.1139		///     * Re-Fungible Mode: The desired number of pieces to transfer.1140		#[pallet::call_index(25)]1141		#[pallet::weight(T::CommonWeightInfo::transfer_from())]1142		pub fn transfer_from(1143			origin: OriginFor<T>,1144			from: T::CrossAccountId,1145			recipient: T::CrossAccountId,1146			collection_id: CollectionId,1147			item_id: TokenId,1148			value: u128,1149		) -> DispatchResultWithPostInfo {1150			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1151			let budget = budget::Value::new(NESTING_BUDGET);11521153			dispatch_tx::<T, _>(collection_id, |d| {1154				d.transfer_from(sender, from, recipient, item_id, value, &budget)1155			})1156		}11571158		/// Set specific limits of a collection. Empty, or None fields mean chain default.1159		///1160		/// # Permissions1161		///1162		/// * Collection owner1163		/// * Collection admin1164		///1165		/// # Arguments1166		///1167		/// * `collection_id`: ID of the modified collection.1168		/// * `new_limit`: New limits of the collection. Fields that are not set (None)1169		/// will not overwrite the old ones.1170		#[pallet::call_index(26)]1171		#[pallet::weight(<SelfWeightOf<T>>::set_collection_limits())]1172		pub fn set_collection_limits(1173			origin: OriginFor<T>,1174			collection_id: CollectionId,1175			new_limit: CollectionLimits,1176		) -> DispatchResult {1177			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1178				fail!(<pallet_common::Error<T>>::UnsupportedOperation);1179			}1180			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1181			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1182			<PalletCommon<T>>::update_limits(&sender, &mut target_collection, new_limit)1183		}11841185		/// Set specific permissions of a collection. Empty, or None fields mean chain default.1186		///1187		/// # Permissions1188		///1189		/// * Collection owner1190		/// * Collection admin1191		///1192		/// # Arguments1193		///1194		/// * `collection_id`: ID of the modified collection.1195		/// * `new_permission`: New permissions of the collection. Fields that are not set (None)1196		/// will not overwrite the old ones.1197		#[pallet::call_index(27)]1198		#[pallet::weight(<SelfWeightOf<T>>::set_collection_limits())]1199		pub fn set_collection_permissions(1200			origin: OriginFor<T>,1201			collection_id: CollectionId,1202			new_permission: CollectionPermissions,1203		) -> DispatchResult {1204			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1205				fail!(<pallet_common::Error<T>>::UnsupportedOperation);1206			}1207			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1208			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1209			<PalletCommon<T>>::update_permissions(&sender, &mut target_collection, new_permission)1210		}12111212		/// Re-partition a refungible token, while owning all of its parts/pieces.1213		///1214		/// # Permissions1215		///1216		/// * Token owner (must own every part)1217		///1218		/// # Arguments1219		///1220		/// * `collection_id`: ID of the collection the RFT belongs to.1221		/// * `token_id`: ID of the RFT.1222		/// * `amount`: New number of parts/pieces into which the token shall be partitioned.1223		#[pallet::call_index(28)]1224		#[pallet::weight(T::RefungibleExtensionsWeightInfo::repartition())]1225		pub fn repartition(1226			origin: OriginFor<T>,1227			collection_id: CollectionId,1228			token_id: TokenId,1229			amount: u128,1230		) -> DispatchResultWithPostInfo {1231			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1232			dispatch_tx::<T, _>(collection_id, |d| {1233				if let Some(refungible_extensions) = d.refungible_extensions() {1234					refungible_extensions.repartition(&sender, token_id, amount)1235				} else {1236					fail!(<Error<T>>::RepartitionCalledOnNonRefungibleCollection)1237				}1238			})1239		}12401241		/// Sets or unsets the approval of a given operator.1242		///1243		/// The `operator` is allowed to transfer all tokens of the `owner` on their behalf.1244		///1245		/// # Arguments1246		///1247		/// * `owner`: Token owner1248		/// * `operator`: Operator1249		/// * `approve`: Should operator status be granted or revoked?1250		#[pallet::call_index(29)]1251		#[pallet::weight(T::CommonWeightInfo::set_allowance_for_all())]1252		pub fn set_allowance_for_all(1253			origin: OriginFor<T>,1254			collection_id: CollectionId,1255			operator: T::CrossAccountId,1256			approve: bool,1257		) -> DispatchResultWithPostInfo {1258			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1259			dispatch_tx::<T, _>(collection_id, |d| {1260				d.set_allowance_for_all(sender, operator, approve)1261			})1262		}12631264		/// Repairs a collection if the data was somehow corrupted.1265		///1266		/// # Arguments1267		///1268		/// * `collection_id`: ID of the collection to repair.1269		#[pallet::call_index(30)]1270		#[pallet::weight(<SelfWeightOf<T>>::force_repair_collection())]1271		pub fn force_repair_collection(1272			origin: OriginFor<T>,1273			collection_id: CollectionId,1274		) -> DispatchResult {1275			if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1276				fail!(<pallet_common::Error<T>>::UnsupportedOperation);1277			}1278			ensure_root(origin)?;1279			<PalletCommon<T>>::repair_collection(collection_id)1280		}12811282		/// Repairs a token if the data was somehow corrupted.1283		///1284		/// # Arguments1285		///1286		/// * `collection_id`: ID of the collection the item belongs to.1287		/// * `item_id`: ID of the item.1288		#[pallet::call_index(31)]1289		#[pallet::weight(T::CommonWeightInfo::force_repair_item())]1290		pub fn force_repair_item(1291			origin: OriginFor<T>,1292			collection_id: CollectionId,1293			item_id: TokenId,1294		) -> DispatchResultWithPostInfo {1295			ensure_root(origin)?;1296			dispatch_tx::<T, _>(collection_id, |d| d.repair_item(item_id))1297		}1298	}12991300	impl<T: Config> Pallet<T> {1301		/// Force set `sponsor` for `collection`.1302		///1303		/// Differs from [`set_collection_sponsor`][`Pallet::set_collection_sponsor`] in that confirmation1304		/// from the `sponsor` is not required.1305		///1306		/// # Arguments1307		///1308		/// * `sponsor`: ID of the account of the sponsor-to-be.1309		/// * `collection_id`: ID of the modified collection.1310		pub fn force_set_sponsor(1311			sponsor: T::AccountId,1312			collection_id: CollectionId,1313		) -> DispatchResult {1314			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1315			target_collection.force_set_sponsor(sponsor)1316		}13171318		/// Force remove `sponsor` for `collection`.1319		///1320		/// Differs from `remove_sponsor` in that1321		/// it doesn't require consent from the `owner` of the collection.1322		///1323		/// # Arguments1324		///1325		/// * `collection_id`: ID of the modified collection.1326		pub fn force_remove_collection_sponsor(collection_id: CollectionId) -> DispatchResult {1327			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1328			target_collection.force_remove_sponsor()1329		}13301331		#[inline(always)]1332		pub(crate) fn destroy_collection_internal(1333			sender: T::CrossAccountId,1334			collection_id: CollectionId,1335		) -> DispatchResult {1336			T::CollectionDispatch::destroy(sender, collection_id)?;13371338			// TODO: basket cleanup should be moved elsewhere1339			// Maybe runtime dispatch.rs should perform it?13401341			let _ = <NftTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1342			let _ = <FungibleTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1343			let _ = <ReFungibleTransferBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);13441345			let _ = <NftApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1346			let _ = <FungibleApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1347			let _ = <RefungibleApproveBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);13481349			Ok(())1350		}1351	}1352}