difftreelog
doc: unique pallet complete
in: master
2 files changed
pallets/unique/src/eth/mod.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Implementation of CollectionHelpers contract.161817use core::marker::PhantomData;19use core::marker::PhantomData;18use evm_coder::{execution::*, generate_stubgen, solidity_interface, weight, types::*};20use evm_coder::{execution::*, generate_stubgen, solidity_interface, weight, types::*};33use sp_std::vec::Vec;35use sp_std::vec::Vec;34use alloc::format;36use alloc::format;353738/// See [`CollectionHelpersCall`]36struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);39pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);37impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {40impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {38 fn recorder(&self) -> &SubstrateRecorder<T> {41 fn recorder(&self) -> &SubstrateRecorder<T> {39 &self.042 &self.044 }47 }45}48}464950/// @title Contract, which allows users to operate with collections47#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]51#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]48impl<T: Config + pallet_nonfungible::Config> EvmCollectionHelpers<T> {52impl<T: Config + pallet_nonfungible::Config> EvmCollectionHelpers<T> {53 /// Create an NFT collection54 /// @param name Name of the collection55 /// @param description Informative description of the collection56 /// @param token_prefix Token prefix to represent the collection tokens in UI and user applications57 /// @return address Address of the newly created collection49 #[weight(<SelfWeightOf<T>>::create_collection())]58 #[weight(<SelfWeightOf<T>>::create_collection())]50 fn create_nonfungible_collection(59 fn create_nonfungible_collection(51 &mut self,60 &mut self,100 Ok(address)109 Ok(address)101 }110 }102111112 /// Check if a collection exists113 /// @param collection_address Address of the collection in question114 /// @return bool Does the collection exist?103 fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {115 fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {104 if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {116 if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {105 let collection_id = id;117 let collection_id = id;110 }122 }111}123}112124125/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]113pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);126pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);114impl<T: Config + pallet_nonfungible::Config> OnMethodCall<T> for CollectionHelpersOnMethodCall<T> {127impl<T: Config + pallet_nonfungible::Config> OnMethodCall<T> for CollectionHelpersOnMethodCall<T> {115 fn is_reserved(contract: &sp_core::H160) -> bool {128 fn is_reserved(contract: &sp_core::H160) -> bool {pallets/unique/src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// 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.166517#![recursion_limit = "1024"]66#![recursion_limit = "1024"]18#![cfg_attr(not(feature = "std"), no_std)]67#![cfg_attr(not(feature = "std"), no_std)]54pub mod weights;103pub mod weights;55use weights::WeightInfo;104use weights::WeightInfo;56105106/// Maximum number of levels of depth in the token nesting tree.57const NESTING_BUDGET: u32 = 5;107pub const NESTING_BUDGET: u32 = 5;5810859decl_error! {109decl_error! {60 /// Error for non-fungible-token module.110 /// Errors for the common Unique transactions.61 pub enum Error for Module<T: Config> {111 pub enum Error for Module<T: Config> {62 /// Decimal_points parameter must be lower than MAX_DECIMAL_POINTS constant, currently it is 30.112 /// Decimal_points parameter must be lower than [`up_data_structs::MAX_DECIMAL_POINTS`].63 CollectionDecimalPointLimitExceeded,113 CollectionDecimalPointLimitExceeded,64 /// This address is not set as sponsor, use setCollectionSponsor first.114 /// This address is not set as sponsor, use setCollectionSponsor first.65 ConfirmUnsetSponsorFail,115 ConfirmUnsetSponsorFail,66 /// Length of items properties must be greater than 0.116 /// Length of items properties must be greater than 0.67 EmptyArgument,117 EmptyArgument,68 /// Repertition is only supported by refungible collection118 /// Repertition is only supported by refungible collection.69 RepartitionCalledOnNonRefungibleCollection,119 RepartitionCalledOnNonRefungibleCollection,70 }120 }71}121}72122123/// Configuration trait of this pallet.73pub trait Config: system::Config + pallet_common::Config + Sized + TypeInfo {124pub trait Config: system::Config + pallet_common::Config + Sized + TypeInfo {125 /// Overarching event type.74 type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;126 type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;7512776 /// Weight information for extrinsics in this pallet.128 /// Weight information for extrinsics in this pallet.77 type WeightInfo: WeightInfo;129 type WeightInfo: WeightInfo;130131 /// Weight information for common pallet operations.78 type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;132 type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;133134 /// Weight info information for extra refungible pallet operations.79 type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;135 type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;80}136}8113788 /// Collection sponsor was removed144 /// Collection sponsor was removed89 ///145 ///90 /// # Arguments146 /// # Arguments91 ///92 /// * collection_id: Globally unique collection identifier.147 /// * collection_id: ID of the affected collection.93 CollectionSponsorRemoved(CollectionId),148 CollectionSponsorRemoved(CollectionId),9414995 /// Collection admin was added150 /// Collection admin was added96 ///151 ///97 /// # Arguments152 /// # Arguments98 ///99 /// * collection_id: Globally unique collection identifier.153 /// * collection_id: ID of the affected collection.100 ///101 /// * admin: Admin address.154 /// * admin: Admin address.102 CollectionAdminAdded(CollectionId, CrossAccountId),155 CollectionAdminAdded(CollectionId, CrossAccountId),103156104 /// Collection owned was changed157 /// Collection owned was changed105 ///158 ///106 /// # Arguments159 /// # Arguments107 ///108 /// * collection_id: Globally unique collection identifier.160 /// * collection_id: ID of the affected collection.109 ///110 /// * owner: New owner address.161 /// * owner: New owner address.111 CollectionOwnedChanged(CollectionId, AccountId),162 CollectionOwnedChanged(CollectionId, AccountId),112163113 /// Collection sponsor was set164 /// Collection sponsor was set114 ///165 ///115 /// # Arguments166 /// # Arguments116 ///117 /// * collection_id: Globally unique collection identifier.167 /// * collection_id: ID of the affected collection.118 ///119 /// * owner: New sponsor address.168 /// * owner: New sponsor address.120 CollectionSponsorSet(CollectionId, AccountId),169 CollectionSponsorSet(CollectionId, AccountId),121170122 /// New sponsor was confirm171 /// New sponsor was confirm123 ///172 ///124 /// # Arguments173 /// # Arguments125 ///126 /// * collection_id: Globally unique collection identifier.174 /// * collection_id: ID of the affected collection.127 ///128 /// * sponsor: New sponsor address.175 /// * sponsor: New sponsor address.129 SponsorshipConfirmed(CollectionId, AccountId),176 SponsorshipConfirmed(CollectionId, AccountId),130177131 /// Collection admin was removed178 /// Collection admin was removed132 ///179 ///133 /// # Arguments180 /// # Arguments134 ///135 /// * collection_id: Globally unique collection identifier.181 /// * collection_id: ID of the affected collection.136 ///137 /// * admin: Admin address.182 /// * admin: Removed admin address.138 CollectionAdminRemoved(CollectionId, CrossAccountId),183 CollectionAdminRemoved(CollectionId, CrossAccountId),139184140 /// Address was removed from the allow list185 /// Address was removed from the allow list141 ///186 ///142 /// # Arguments187 /// # Arguments143 ///144 /// * collection_id: Globally unique collection identifier.188 /// * collection_id: ID of the affected collection.145 ///146 /// * user: Address.189 /// * user: Address of the removed account.147 AllowListAddressRemoved(CollectionId, CrossAccountId),190 AllowListAddressRemoved(CollectionId, CrossAccountId),148191149 /// Address was added to the allow list192 /// Address was added to the allow list150 ///193 ///151 /// # Arguments194 /// # Arguments152 ///153 /// * collection_id: Globally unique collection identifier.195 /// * collection_id: ID of the affected collection.154 ///155 /// * user: Address.196 /// * user: Address of the added account.156 AllowListAddressAdded(CollectionId, CrossAccountId),197 AllowListAddressAdded(CollectionId, CrossAccountId),157198158 /// Collection limits were set199 /// Collection limits were set159 ///200 ///160 /// # Arguments201 /// # Arguments161 ///162 /// * collection_id: Globally unique collection identifier.202 /// * collection_id: ID of the affected collection.163 CollectionLimitSet(CollectionId),203 CollectionLimitSet(CollectionId),164204165 /// Collection permissions were set205 /// Collection permissions were set166 ///206 ///167 /// # Arguments207 /// # Arguments168 ///169 /// * collection_id: Globally unique collection identifier.208 /// * collection_id: ID of the affected collection.170 CollectionPermissionSet(CollectionId),209 CollectionPermissionSet(CollectionId),171 }210 }172}211}232}271}233272234decl_module! {273decl_module! {274 /// Type alias to Pallet, to be used by construct_runtime.235 pub struct Module<T: Config> for enum Call275 pub struct Module<T: Config> for enum Call236 where276 where237 origin: T::Origin277 origin: T::Origin252 0292 0253 }293 }254294255 /// This method creates a Collection of NFTs. Each Token may have multiple properties encoded as an array of bytes of certain length. The initial owner of the collection is set to the address that signed the transaction and can be changed later.295 /// DEPRECATED - use create_collection_ex. Create a Collection of tokens.296 ///297 /// Each Token may have multiple properties encoded as an array of bytes298 /// of certain length. The initial owner of the collection is set299 /// to the address that signed the transaction and can be changed later.300 ///301 /// Prefer [`create_collection_ex`](Call::create_collection_ex) instead.256 ///302 ///257 /// # Permissions303 /// # Permissions258 ///304 ///259 /// * Anyone.305 /// * Anyone - becomes the owner of the new collection.260 ///306 ///261 /// # Arguments307 /// # Arguments262 ///308 ///263 /// * collection_name: UTF-16 string with collection name (limit 64 characters), will be stored as zero-terminated.309 /// * `collection_name`: UTF-16 string with collection name (limit 64 characters),310 /// will be stored as zero-terminated.264 /// * collection_description - UTF-16 string with collection description (limit 256 characters), will be stored as zero-terminated.311 /// * `collection_description`: UTF-16 string with collection description (limit 256 characters),312 /// will be stored as zero-terminated.265 /// * token_prefix - UTF-8 string with token prefix.313 /// * `token_prefix`: UTF-8 string with token prefix.266 /// * mode - [CollectionMode] collection type and type dependent data.314 /// * `mode`: [`CollectionMode`] and type dependent data.267 // returns collection ID315 // returns collection ID268 #[weight = <SelfWeightOf<T>>::create_collection()]316 #[weight = <SelfWeightOf<T>>::create_collection()]269 #[transactional]317 #[transactional]284 }334 }285335286 /// Create a collection with explicit parameters.336 /// Create a collection with explicit parameters.287 /// Prefer it to the deprecated [`created_collection`] method.337 /// Prefer it to the deprecated [`create_collection`](Call::create_collection) method.288 ///338 ///289 /// # Permissions339 /// # Permissions290 ///340 ///291 /// * Anyone.341 /// * Anyone - becomes the owner of the new collection.292 ///342 ///293 /// # Arguments343 /// # Arguments294 ///344 ///295 /// * data: explicit create-collection data.345 /// * `data`: Explicit data of a collection used for its creation.296 #[weight = <SelfWeightOf<T>>::create_collection()]346 #[weight = <SelfWeightOf<T>>::create_collection()]297 #[transactional]347 #[transactional]298 pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {348 pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {305 Ok(())355 Ok(())306 }356 }307357308 /// Destroy the collection if no tokens exist within.358 /// Destroy a collection if no tokens exist within.309 ///359 ///310 /// # Permissions360 /// # Permissions311 ///361 ///312 /// * Collection Owner362 /// * Collection owner313 ///363 ///314 /// # Arguments364 /// # Arguments315 ///365 ///316 /// * collection_id - collection to destroy.366 /// * `collection_id`: Collection to destroy.317 #[weight = <SelfWeightOf<T>>::destroy_collection()]367 #[weight = <SelfWeightOf<T>>::destroy_collection()]318 #[transactional]368 #[transactional]319 pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {369 pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {340 ///390 ///341 /// # Permissions391 /// # Permissions342 ///392 ///343 /// * Collection Owner393 /// * Collection owner344 /// * Collection Admin394 /// * Collection admin345 ///395 ///346 /// # Arguments396 /// # Arguments347 ///397 ///348 /// * collection_id.398 /// * `collection_id`: ID of the modified collection.349 /// * address.399 /// * `address`: ID of the address to be added to the allowlist.350 #[weight = <SelfWeightOf<T>>::add_to_allow_list()]400 #[weight = <SelfWeightOf<T>>::add_to_allow_list()]351 #[transactional]401 #[transactional]352 pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{402 pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{374 ///424 ///375 /// # Permissions425 /// # Permissions376 ///426 ///377 /// * Collection Owner427 /// * Collection owner378 /// * Collection Admin428 /// * Collection admin379 ///429 ///380 /// # Arguments430 /// # Arguments381 ///431 ///382 /// * collection_id.432 /// * `collection_id`: ID of the modified collection.383 /// * address.433 /// * `address`: ID of the address to be removed from the allowlist.384 #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]434 #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]385 #[transactional]435 #[transactional]386 pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{436 pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{408 ///458 ///409 /// # Permissions459 /// # Permissions410 ///460 ///411 /// * Collection Owner461 /// * Collection owner412 ///462 ///413 /// # Arguments463 /// # Arguments414 ///464 ///415 /// * collection_id.465 /// * `collection_id`: ID of the modified collection.416 /// * new_owner.466 /// * `new_owner`: ID of the account that will become the owner.417 #[weight = <SelfWeightOf<T>>::change_collection_owner()]467 #[weight = <SelfWeightOf<T>>::change_collection_owner()]418 #[transactional]468 #[transactional]419 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {469 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {433 target_collection.save()483 target_collection.save()434 }484 }435485436 /// Adds an admin of the collection.486 /// Add an admin to a collection.437 /// NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.487 ///488 /// NFT Collection can be controlled by multiple admin addresses489 /// (some which can also be servers, for example). Admins can issue490 /// and burn NFTs, as well as add and remove other admins,491 /// but cannot change NFT or Collection ownership.438 ///492 ///439 /// # Permissions493 /// # Permissions440 ///494 ///441 /// * Collection Owner495 /// * Collection owner442 /// * Collection Admin496 /// * Collection admin443 ///497 ///444 /// # Arguments498 /// # Arguments445 ///499 ///446 /// * collection_id - ID of the Collection to add admin for.500 /// * `collection_id`: ID of the Collection to add an admin for.447 /// * new_admin - Address of new admin to add.501 /// * `new_admin`: Address of new admin to add.448 #[weight = <SelfWeightOf<T>>::add_collection_admin()]502 #[weight = <SelfWeightOf<T>>::add_collection_admin()]449 #[transactional]503 #[transactional]450 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin: T::CrossAccountId) -> DispatchResult {504 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin: T::CrossAccountId) -> DispatchResult {460 <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin, true)514 <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin, true)461 }515 }462516463 /// Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which case only Collection Owner will be able to add an Admin.517 /// Remove admin of a collection.518 ///519 /// An admin address can remove itself. List of admins may become empty,520 /// in which case only Collection Owner will be able to add an Admin.464 ///521 ///465 /// # Permissions522 /// # Permissions466 ///523 ///467 /// * Collection Owner524 /// * Collection owner468 /// * Collection Admin525 /// * Collection admin469 ///526 ///470 /// # Arguments527 /// # Arguments471 ///528 ///472 /// * collection_id - ID of the Collection to remove admin for.529 /// * `collection_id`: ID of the collection to remove the admin for.473 /// * account_id - Address of admin to remove.530 /// * `account_id`: Address of the admin to remove.474 #[weight = <SelfWeightOf<T>>::remove_collection_admin()]531 #[weight = <SelfWeightOf<T>>::remove_collection_admin()]475 #[transactional]532 #[transactional]476 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {533 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {486 <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)543 <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)487 }544 }488545546 /// Set (invite) a new collection sponsor.489 /// Set (invite) a new collection sponsor. If successful, confirmation from the sponsor-to-be will be pending.547 /// If successful, confirmation from the sponsor-to-be will be pending.490 ///548 ///491 /// # Permissions549 /// # Permissions492 ///550 ///493 /// * Collection Owner551 /// * Collection owner494 /// * Collection Admin552 /// * Collection admin495 ///553 ///496 /// # Arguments554 /// # Arguments497 ///555 ///498 /// * collection_id.556 /// * `collection_id`: ID of the modified collection.499 /// * new_sponsor.557 /// * `new_sponsor`: ID of the account of the sponsor-to-be.500 #[weight = <SelfWeightOf<T>>::set_collection_sponsor()]558 #[weight = <SelfWeightOf<T>>::set_collection_sponsor()]501 #[transactional]559 #[transactional]502 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {560 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {516 target_collection.save()574 target_collection.save()517 }575 }518576519 /// Confirm own sponsorship of a collection.577 /// Confirm own sponsorship of a collection, becoming the sponsor.578 /// An invitation must be pending, see [`set_collection_sponsor`](Call::set_collection_sponsor).579 ///580 /// Sponsor can pay the fees of a transaction instead of the sender,581 /// but only within specified limits.520 ///582 ///521 /// # Permissions583 /// # Permissions522 ///584 ///523 /// * Sponsor-to-be585 /// * Sponsor-to-be524 ///586 ///525 /// # Arguments587 /// # Arguments526 ///588 ///527 /// * collection_id.589 /// * `collection_id`: ID of the collection with the pending sponsor.528 #[weight = <SelfWeightOf<T>>::confirm_sponsorship()]590 #[weight = <SelfWeightOf<T>>::confirm_sponsorship()]529 #[transactional]591 #[transactional]530 pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {592 pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {545 target_collection.save()607 target_collection.save()546 }608 }547609548 /// Switch back to pay-per-own-transaction model.610 /// Remove a sponsor from a collection, making everyone pay for their own transactions.549 ///611 ///550 /// # Permissions612 /// # Permissions551 ///613 ///552 /// * Collection Owner614 /// * Collection owner553 ///615 ///554 /// # Arguments616 /// # Arguments555 ///617 ///556 /// * collection_id.618 /// * `collection_id`: ID of the collection with the sponsor to remove.557 #[weight = <SelfWeightOf<T>>::remove_collection_sponsor()]619 #[weight = <SelfWeightOf<T>>::remove_collection_sponsor()]558 #[transactional]620 #[transactional]559 pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {621 pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {571 target_collection.save()633 target_collection.save()572 }634 }573635574 /// Create a concrete instance of NFT Collection created with CreateCollection method.636 /// Mint an item within a collection.637 ///638 /// A collection must exist first, see [`create_collection_ex`](Call::create_collection_ex).575 ///639 ///576 /// # Permissions640 /// # Permissions577 ///641 ///578 /// * Collection Owner642 /// * Collection owner579 /// * Collection Admin643 /// * Collection admin580 /// * Anyone if644 /// * Anyone if581 /// * Allow List is enabled, and645 /// * Allow List is enabled, and582 /// * Address is added to allow list, and646 /// * Address is added to allow list, and583 /// * MintPermission is enabled (see SetMintPermission method)647 /// * MintPermission is enabled (see [`set_collection_permissions`](Call::set_collection_permissions))584 ///648 ///585 /// # Arguments649 /// # Arguments586 ///650 ///587 /// * collection_id - ID of the collection.651 /// * `collection_id`: ID of the collection to which an item would belong.588 /// * owner - Address, initial owner of the NFT.652 /// * `owner`: Address of the initial owner of the item.589 /// * data - Token data to store on chain.653 /// * `data`: Token data describing the item to store on chain.590 #[weight = T::CommonWeightInfo::create_item()]654 #[weight = T::CommonWeightInfo::create_item()]591 #[transactional]655 #[transactional]592 pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {656 pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {596 dispatch_tx::<T, _>(collection_id, |d| d.create_item(sender, owner, data, &budget))660 dispatch_tx::<T, _>(collection_id, |d| d.create_item(sender, owner, data, &budget))597 }661 }598662599 /// Create multiple items in a collection created with CreateCollection method.663 /// Create multiple items within a collection.664 ///665 /// A collection must exist first, see [`create_collection_ex`](Call::create_collection_ex).600 ///666 ///601 /// # Permissions667 /// # Permissions602 ///668 ///603 /// * Collection Owner669 /// * Collection owner604 /// * Collection Admin670 /// * Collection admin605 /// * Anyone if671 /// * Anyone if606 /// * Allow List is enabled, and672 /// * Allow List is enabled, and607 /// * Address is added to allow list, and673 /// * Address is added to the allow list, and608 /// * MintPermission is enabled (see SetMintPermission method)674 /// * MintPermission is enabled (see [`set_collection_permissions`](Call::set_collection_permissions))609 ///675 ///610 /// # Arguments676 /// # Arguments611 ///677 ///612 /// * collection_id - ID of the collection.678 /// * `collection_id`: ID of the collection to which the tokens would belong.613 /// * owner - Address, initial owner of the NFT.679 /// * `owner`: Address of the initial owner of the tokens.614 /// * items_data - Array items properties. Each property is an array of bytes itself, see [`create_item`].680 /// * `items_data`: Vector of data describing each item to be created.615 #[weight = T::CommonWeightInfo::create_multiple_items(&items_data)]681 #[weight = T::CommonWeightInfo::create_multiple_items(&items_data)]616 #[transactional]682 #[transactional]617 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {683 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {626 ///692 ///627 /// # Permissions693 /// # Permissions628 ///694 ///629 /// * Collection Owner695 /// * Collection owner630 /// * Collection Admin696 /// * Collection admin631 ///697 ///632 /// # Arguments698 /// # Arguments633 ///699 ///634 /// * collection_id.700 /// * `collection_id`: ID of the modified collection.635 /// * properties - Vector of key-value pairs stored as the collection's metadata. Keys support Latin letters, `-`, `_`, and `.` as symbols.701 /// * `properties`: Vector of key-value pairs stored as the collection's metadata.702 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.636 #[weight = T::CommonWeightInfo::set_collection_properties(properties.len() as u32)]703 #[weight = T::CommonWeightInfo::set_collection_properties(properties.len() as u32)]637 #[transactional]704 #[transactional]638 pub fn set_collection_properties(705 pub fn set_collection_properties(656 ///723 ///657 /// # Arguments724 /// # Arguments658 ///725 ///659 /// * collection_id.726 /// * `collection_id`: ID of the modified collection.660 /// * property_keys - Vector of keys of the properties to be deleted.727 /// * `property_keys`: Vector of keys of the properties to be deleted.728 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.661 #[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]729 #[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]662 #[transactional]730 #[transactional]663 pub fn delete_collection_properties(731 pub fn delete_collection_properties(673 }741 }674742675 /// Add or change token properties according to collection's permissions.743 /// Add or change token properties according to collection's permissions.744 /// Currently properties only work with NFTs.676 ///745 ///677 /// # Permissions746 /// # Permissions678 ///747 ///679 /// * Depends on collection's token property permissions and specified property mutability:748 /// * Depends on collection's token property permissions and specified property mutability:680 /// * Collection Owner749 /// * Collection owner681 /// * Collection Admin750 /// * Collection admin682 /// * Token Owner751 /// * Token owner752 ///753 /// See [`set_token_property_permissions`](Call::set_token_property_permissions).683 ///754 ///684 /// # Arguments755 /// # Arguments685 ///756 ///686 /// * collection_id.757 /// * `collection_id: ID of the collection to which the token belongs.687 /// * token_id.758 /// * `token_id`: ID of the modified token.688 /// * properties - Vector of key-value pairs stored as the token's metadata. Keys support Latin letters, `-`, `_`, and `.` as symbols.759 /// * `properties`: Vector of key-value pairs stored as the token's metadata.760 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.689 #[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]761 #[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]690 #[transactional]762 #[transactional]691 pub fn set_token_properties(763 pub fn set_token_properties(702 dispatch_tx::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties, &budget))774 dispatch_tx::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties, &budget))703 }775 }704776705 /// Delete specified token properties.777 /// Delete specified token properties. Currently properties only work with NFTs.706 ///778 ///707 /// # Permissions779 /// # Permissions708 ///780 ///709 /// * Depends on collection's token property permissions and specified property mutability:781 /// * Depends on collection's token property permissions and specified property mutability:710 /// * Collection Owner782 /// * Collection owner711 /// * Collection Admin783 /// * Collection admin712 /// * Token Owner784 /// * Token owner713 ///785 ///714 /// # Arguments786 /// # Arguments715 ///787 ///716 /// * collection_id.788 /// * `collection_id`: ID of the collection to which the token belongs.717 /// * token_id.789 /// * `token_id`: ID of the modified token.718 /// * property_keys - Vector of keys of the properties to be deleted.790 /// * `property_keys`: Vector of keys of the properties to be deleted.791 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.719 #[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]792 #[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]720 #[transactional]793 #[transactional]721 pub fn delete_token_properties(794 pub fn delete_token_properties(733 }806 }734807735 /// Add or change token property permissions of a collection.808 /// Add or change token property permissions of a collection.809 ///810 /// Without a permission for a particular key, a property with that key811 /// cannot be created in a token.736 ///812 ///737 /// # Permissions813 /// # Permissions738 ///814 ///739 /// * Collection Owner815 /// * Collection owner740 /// * Collection Admin816 /// * Collection admin741 ///817 ///742 /// # Arguments818 /// # Arguments743 ///819 ///744 /// * collection_id.820 /// * `collection_id`: ID of the modified collection.745 /// * property_permissions - Vector of permissions for property keys. Keys support Latin letters, `-`, `_`, and `.` as symbols.821 /// * `property_permissions`: Vector of permissions for property keys.822 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.746 #[weight = T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32)]823 #[weight = T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32)]747 #[transactional]824 #[transactional]748 pub fn set_token_property_permissions(825 pub fn set_token_property_permissions(757 dispatch_tx::<T, _>(collection_id, |d| d.set_token_property_permissions(&sender, property_permissions))834 dispatch_tx::<T, _>(collection_id, |d| d.set_token_property_permissions(&sender, property_permissions))758 }835 }759836760 /// Create multiple items inside a collection with explicitly specified initial parameters.837 /// Create multiple items within a collection with explicitly specified initial parameters.761 ///838 ///762 /// # Permissions839 /// # Permissions763 ///840 ///764 /// * Collection Owner841 /// * Collection owner765 /// * Collection Admin842 /// * Collection admin766 /// * Anyone if843 /// * Anyone if767 /// * Allow List is enabled, and844 /// * Allow List is enabled, and768 /// * Address is added to allow list, and845 /// * Address is added to allow list, and769 /// * MintPermission is enabled (see SetMintPermission method)846 /// * MintPermission is enabled (see [`set_collection_permissions`](Call::set_collection_permissions))770 ///847 ///771 /// # Arguments848 /// # Arguments772 ///849 ///773 /// * collection_id - ID of the collection.850 /// * `collection_id`: ID of the collection to which the tokens would belong.774 /// * data - Explicit item creation data.851 /// * `data`: Explicit item creation data.775 #[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]852 #[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]776 #[transactional]853 #[transactional]777 pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {854 pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {781 dispatch_tx::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data, &budget))858 dispatch_tx::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data, &budget))782 }859 }783860784 /// Set transfers_enabled value for particular collection.861 /// Completely allow or disallow transfers for a particular collection.785 ///862 ///786 /// # Permissions863 /// # Permissions787 ///864 ///788 /// * Collection Owner865 /// * Collection owner789 ///866 ///790 /// # Arguments867 /// # Arguments791 ///868 ///792 /// * collection_id - ID of the collection.869 /// * `collection_id`: ID of the collection.793 /// * value - New flag value.870 /// * `value`: New value of the flag, are transfers allowed?794 #[weight = <SelfWeightOf<T>>::set_transfers_enabled_flag()]871 #[weight = <SelfWeightOf<T>>::set_transfers_enabled_flag()]795 #[transactional]872 #[transactional]796 pub fn set_transfers_enabled_flag(origin, collection_id: CollectionId, value: bool) -> DispatchResult {873 pub fn set_transfers_enabled_flag(origin, collection_id: CollectionId, value: bool) -> DispatchResult {805 target_collection.save()882 target_collection.save()806 }883 }807884808 /// Destroy a concrete instance of NFT.885 /// Destroy an item.809 ///886 ///810 /// # Permissions887 /// # Permissions811 ///888 ///812 /// * Collection Owner889 /// * Collection owner813 /// * Collection Admin890 /// * Collection admin814 /// * Current NFT Owner891 /// * Current item owner815 ///892 ///816 /// # Arguments893 /// # Arguments817 ///894 ///818 /// * collection_id - ID of the collection.895 /// * `collection_id`: ID of the collection to which the item belongs.819 /// * item_id - ID of NFT to burn.896 /// * `item_id`: ID of item to burn.897 /// * `value`: Number of parts of the item to destroy.898 /// * Non-Fungible Mode: There is always 1 NFT.899 /// * Fungible Mode: The desired number of parts to burn.900 /// * Re-Fungible Mode: The desired number of parts to burn.820 #[weight = T::CommonWeightInfo::burn_item()]901 #[weight = T::CommonWeightInfo::burn_item()]821 #[transactional]902 #[transactional]822 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {903 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {833 Ok(post_info)914 Ok(post_info)834 }915 }835916836 /// Destroy a concrete instance of NFT on behalf of the owner.917 /// Destroy a token on behalf of the owner as a non-owner account.837 /// See also: [`approve`]918 /// See also: [`approve`](Call::approve).919 ///920 /// After this method executes, one approval is removed from the total so that921 /// the approved address will not be able to transfer this item again from this owner.838 ///922 ///839 /// # Permissions923 /// # Permissions840 ///924 ///841 /// * Collection Owner.925 /// * Collection owner842 /// * Collection Admin.926 /// * Collection admin843 /// * Current NFT Owner.927 /// * Current token owner928 /// * Address approved by current item owner844 ///929 ///845 /// # Arguments930 /// # Arguments846 ///931 ///932 /// * `from`: The owner of the burning item.847 /// * collection_id - ID of the collection.933 /// * `collection_id`: ID of the collection to which the item belongs.848 /// * item_id - ID of NFT to burn.934 /// * `item_id`: ID of item to burn.849 /// * from - The owner of the item from whom it is taken away.935 /// * `value`: Number of parts to burn.936 /// * Non-Fungible Mode: There is always 1 NFT.937 /// * Fungible Mode: The desired number of parts to burn.938 /// * Re-Fungible Mode: The desired number of parts to burn.850 #[weight = T::CommonWeightInfo::burn_from()]939 #[weight = T::CommonWeightInfo::burn_from()]851 #[transactional]940 #[transactional]852 pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {941 pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {860 ///949 ///861 /// # Permissions950 /// # Permissions862 ///951 ///863 /// * Collection Owner952 /// * Collection owner864 /// * Collection Admin953 /// * Collection admin865 /// * Current NFT owner954 /// * Current token owner866 ///955 ///867 /// # Arguments956 /// # Arguments868 ///957 ///869 /// * recipient - Address of token recipient.958 /// * `recipient`: Address of token recipient.870 ///959 /// * `collection_id`: ID of the collection the item belongs to.871 /// * collection_id.872 ///873 /// * item_id - ID of the item960 /// * `item_id`: ID of the item.874 /// * Non-Fungible Mode: Required.961 /// * Non-Fungible Mode: Required.875 /// * Fungible Mode: Ignored.962 /// * Fungible Mode: Ignored.876 /// * Re-Fungible Mode: Required.963 /// * Re-Fungible Mode: Required.877 ///964 ///878 /// * value - Amount to transfer.965 /// * `value`: Amount to transfer.879 /// * Non-Fungible Mode: Ignored966 /// * Non-Fungible Mode: There is always 1 NFT.880 /// * Fungible Mode: Must specify transferred amount967 /// * Fungible Mode: The desired number of parts to transfer.881 /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)968 /// * Re-Fungible Mode: The desired number of parts to transfer.882 #[weight = T::CommonWeightInfo::transfer()]969 #[weight = T::CommonWeightInfo::transfer()]883 #[transactional]970 #[transactional]884 pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {971 pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {888 dispatch_tx::<T, _>(collection_id, |d| d.transfer(sender, recipient, item_id, value, &budget))975 dispatch_tx::<T, _>(collection_id, |d| d.transfer(sender, recipient, item_id, value, &budget))889 }976 }890977891 /// Set, change, or remove approved address to transfer the ownership of the NFT.978 /// Allow a non-permissioned address to transfer or burn an item.892 ///979 ///893 /// # Permissions980 /// # Permissions894 ///981 ///895 /// * Collection Owner982 /// * Collection owner896 /// * Collection Admin983 /// * Collection admin897 /// * Current NFT owner984 /// * Current item owner898 ///985 ///899 /// # Arguments986 /// # Arguments900 ///987 ///901 /// * approved - Address that is approved to transfer this NFT or zero (if needed to remove approval).988 /// * `spender`: Account to be approved to make specific transactions on non-owned tokens.902 /// * collection_id.989 /// * `collection_id`: ID of the collection the item belongs to.903 /// * item_id - ID of the item.990 /// * `item_id`: ID of the item transactions on which are now approved.991 /// * `amount`: Number of approved transactions overwriting the current number,992 /// e.g. set to `0` to remove approval.904 #[weight = T::CommonWeightInfo::approve()]993 #[weight = T::CommonWeightInfo::approve()]905 #[transactional]994 #[transactional]906 pub fn approve(origin, spender: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResultWithPostInfo {995 pub fn approve(origin, spender: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResultWithPostInfo {909 dispatch_tx::<T, _>(collection_id, |d| d.approve(sender, spender, item_id, amount))998 dispatch_tx::<T, _>(collection_id, |d| d.approve(sender, spender, item_id, amount))910 }999 }9111000912 /// Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this owner.1001 /// Change ownership of an item on behalf of the owner as a non-owner account.1002 /// See the [`approve`](Call::approve) method for additional information.1003 ///1004 /// After this method executes, one approval is removed from the total so that1005 /// the approved address will not be able to transfer this item again from this owner.913 ///1006 ///914 /// # Permissions1007 /// # Permissions915 ///1008 ///916 /// * Collection Owner1009 /// * Collection owner917 /// * Collection Admin1010 /// * Collection admin918 /// * Current NFT owner1011 /// * Current item owner919 /// * Address approved by current NFT owner1012 /// * Address approved by current item owner920 ///1013 ///921 /// # Arguments1014 /// # Arguments922 ///1015 ///923 /// * from - Address that currently owns the token.1016 /// * `from`: Address that currently owns the token.924 /// * recipient - Address of the new token-owner-to-be.1017 /// * `recipient`: Address of the new token-owner-to-be.925 /// * collection_id.1018 /// * `collection_id`: ID of the collection the item.926 /// * item_id - ID of the item to be transferred.1019 /// * `item_id`: ID of the item to be transferred.927 /// * value - Amount to transfer.1020 /// * `value`: Amount of parts to transfer.1021 /// * Non-Fungible Mode: There is always 1 NFT.1022 /// * Fungible Mode: The desired number of parts to transfer.1023 /// * Re-Fungible Mode: The desired number of parts to transfer.928 #[weight = T::CommonWeightInfo::transfer_from()]1024 #[weight = T::CommonWeightInfo::transfer_from()]929 #[transactional]1025 #[transactional]930 pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {1026 pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {938 ///1034 ///939 /// # Permissions1035 /// # Permissions940 ///1036 ///941 /// * Collection Owner1037 /// * Collection owner942 /// * Collection Admin1038 /// * Collection admin943 ///1039 ///944 /// # Arguments1040 /// # Arguments945 ///1041 ///946 /// * collection_id.1042 /// * `collection_id`: ID of the modified collection.947 /// * new_limit - New limits of the collection. They will overwrite the current ones.1043 /// * `new_limit`: New limits of the collection. They will overwrite the current ones.948 #[weight = <SelfWeightOf<T>>::set_collection_limits()]1044 #[weight = <SelfWeightOf<T>>::set_collection_limits()]949 #[transactional]1045 #[transactional]950 pub fn set_collection_limits(1046 pub fn set_collection_limits(971 ///1067 ///972 /// # Permissions1068 /// # Permissions973 ///1069 ///974 /// * Collection Owner1070 /// * Collection owner975 /// * Collection Admin1071 /// * Collection admin976 ///1072 ///977 /// # Arguments1073 /// # Arguments978 ///1074 ///979 /// * collection_id.1075 /// * `collection_id`: ID of the modified collection.980 /// * new_permission - New permissions of the collection. They will overwrite the current ones.1076 /// * `new_permission`: New permissions of the collection. They will overwrite the current ones.981 #[weight = <SelfWeightOf<T>>::set_collection_limits()]1077 #[weight = <SelfWeightOf<T>>::set_collection_limits()]982 #[transactional]1078 #[transactional]983 pub fn set_collection_permissions(1079 pub fn set_collection_permissions(1004 ///1100 ///1005 /// # Permissions1101 /// # Permissions1006 ///1102 ///1007 /// * Token Owner (must own every part)1103 /// * Token owner (must own every part)1008 ///1104 ///1009 /// # Arguments1105 /// # Arguments1010 ///1106 ///1011 /// * collection_id.1107 /// * `collection_id`: ID of the collection the RFT belongs to.1012 /// * token_id - ID of the RFT.1108 /// * `token_id`: ID of the RFT.1013 /// * amount - New number of parts into which the token shall be partitioned.1109 /// * `amount`: New number of parts into which the token shall be partitioned.1014 #[weight = T::RefungibleExtensionsWeightInfo::repartition()]1110 #[weight = T::RefungibleExtensionsWeightInfo::repartition()]1015 #[transactional]1111 #[transactional]1016 pub fn repartition(1112 pub fn repartition(