difftreelog
Merge pull request #427 from UniqueNetwork/doc/architectural-changes
in: master
19 files changed
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -42,6 +42,7 @@
#[rpc(server)]
#[async_trait]
pub trait UniqueApi<BlockHash, CrossAccountId, AccountId> {
+ /// Get tokens owned by account.
#[method(name = "unique_accountTokens")]
fn account_tokens(
&self,
@@ -49,12 +50,16 @@
account: CrossAccountId,
at: Option<BlockHash>,
) -> Result<Vec<TokenId>>;
+
+ /// Get tokens contained within a collection.
#[method(name = "unique_collectionTokens")]
fn collection_tokens(
&self,
collection: CollectionId,
at: Option<BlockHash>,
) -> Result<Vec<TokenId>>;
+
+ /// Check if the token exists.
#[method(name = "unique_tokenExists")]
fn token_exists(
&self,
@@ -63,6 +68,7 @@
at: Option<BlockHash>,
) -> Result<bool>;
+ /// Get the token owner.
#[method(name = "unique_tokenOwner")]
fn token_owner(
&self,
@@ -80,6 +86,7 @@
at: Option<BlockHash>,
) -> Result<Vec<CrossAccountId>>;
+ /// Get the topmost token owner in the hierarchy of a possibly nested token.
#[method(name = "unique_topmostTokenOwner")]
fn topmost_token_owner(
&self,
@@ -87,6 +94,8 @@
token: TokenId,
at: Option<BlockHash>,
) -> Result<Option<CrossAccountId>>;
+
+ /// Get tokens nested directly into the token.
#[method(name = "unique_tokenChildren")]
fn token_children(
&self,
@@ -95,6 +104,7 @@
at: Option<BlockHash>,
) -> Result<Vec<TokenChild>>;
+ /// Get collection properties, optionally limited to the provided keys.
#[method(name = "unique_collectionProperties")]
fn collection_properties(
&self,
@@ -103,6 +113,7 @@
at: Option<BlockHash>,
) -> Result<Vec<Property>>;
+ /// Get token properties, optionally limited to the provided keys.
#[method(name = "unique_tokenProperties")]
fn token_properties(
&self,
@@ -112,6 +123,7 @@
at: Option<BlockHash>,
) -> Result<Vec<Property>>;
+ /// Get property permissions, optionally limited to the provided keys.
#[method(name = "unique_propertyPermissions")]
fn property_permissions(
&self,
@@ -120,6 +132,7 @@
at: Option<BlockHash>,
) -> Result<Vec<PropertyKeyPermission>>;
+ /// Get token data, including properties, optionally limited to the provided keys, and total pieces for an RFT.
#[method(name = "unique_tokenData")]
fn token_data(
&self,
@@ -129,8 +142,11 @@
at: Option<BlockHash>,
) -> Result<TokenData<CrossAccountId>>;
+ /// Get the amount of distinctive tokens present in a collection.
#[method(name = "unique_totalSupply")]
fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;
+
+ /// Get the amount of any user tokens owned by an account.
#[method(name = "unique_accountBalance")]
fn account_balance(
&self,
@@ -138,6 +154,8 @@
account: CrossAccountId,
at: Option<BlockHash>,
) -> Result<u32>;
+
+ /// Get the amount of a specific token owned by an account.
#[method(name = "unique_balance")]
fn balance(
&self,
@@ -146,6 +164,8 @@
token: TokenId,
at: Option<BlockHash>,
) -> Result<String>;
+
+ /// Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor.
#[method(name = "unique_allowance")]
fn allowance(
&self,
@@ -156,18 +176,23 @@
at: Option<BlockHash>,
) -> Result<String>;
+ /// Get the list of admin accounts of a collection.
#[method(name = "unique_adminlist")]
fn adminlist(
&self,
collection: CollectionId,
at: Option<BlockHash>,
) -> Result<Vec<CrossAccountId>>;
+
+ /// Get the list of accounts allowed to operate within a collection.
#[method(name = "unique_allowlist")]
fn allowlist(
&self,
collection: CollectionId,
at: Option<BlockHash>,
) -> Result<Vec<CrossAccountId>>;
+
+ /// Check if a user is allowed to operate within a collection.
#[method(name = "unique_allowed")]
fn allowed(
&self,
@@ -175,17 +200,24 @@
user: CrossAccountId,
at: Option<BlockHash>,
) -> Result<bool>;
+
+ /// Get the last token ID created in a collection.
#[method(name = "unique_lastTokenId")]
fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;
+
+ /// Get collection info by the specified ID.
#[method(name = "unique_collectionById")]
fn collection_by_id(
&self,
collection: CollectionId,
at: Option<BlockHash>,
) -> Result<Option<RpcCollection<AccountId>>>;
+
+ /// Get chain stats about collections.
#[method(name = "unique_collectionStats")]
fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;
+ /// Get the number of blocks until sponsoring a transaction is available.
#[method(name = "unique_nextSponsored")]
fn next_sponsored(
&self,
@@ -195,6 +227,7 @@
at: Option<BlockHash>,
) -> Result<Option<u64>>;
+ /// Get effective collection limits. If not explicitly set, get the chain defaults.
#[method(name = "unique_effectiveCollectionLimits")]
fn effective_collection_limits(
&self,
@@ -202,6 +235,7 @@
at: Option<BlockHash>,
) -> Result<Option<CollectionLimits>>;
+ /// Get the total amount of pieces of an RFT.
#[method(name = "unique_totalPieces")]
fn total_pieces(
&self,
@@ -228,20 +262,20 @@
Theme,
>
{
+ /// Get the latest created collection ID.
#[method(name = "rmrk_lastCollectionIdx")]
- /// Get the latest created collection id
fn last_collection_idx(&self, at: Option<BlockHash>) -> Result<RmrkCollectionId>;
+ /// Get collection info by ID.
#[method(name = "rmrk_collectionById")]
- /// Get collection by id
fn collection_by_id(
&self,
id: RmrkCollectionId,
at: Option<BlockHash>,
) -> Result<Option<CollectionInfo>>;
+ /// Get NFT info by collection and NFT IDs.
#[method(name = "rmrk_nftById")]
- /// Get NFT by collection id and NFT id
fn nft_by_id(
&self,
collection_id: RmrkCollectionId,
@@ -249,8 +283,8 @@
at: Option<BlockHash>,
) -> Result<Option<NftInfo>>;
+ /// Get tokens owned by an account in a collection.
#[method(name = "rmrk_accountTokens")]
- /// Get tokens owned by an account in a collection
fn account_tokens(
&self,
account_id: AccountId,
@@ -258,8 +292,8 @@
at: Option<BlockHash>,
) -> Result<Vec<RmrkNftId>>;
+ /// Get tokens nested in an NFT - its direct children (not the children's children).
#[method(name = "rmrk_nftChildren")]
- /// Get NFT children
fn nft_children(
&self,
collection_id: RmrkCollectionId,
@@ -267,8 +301,8 @@
at: Option<BlockHash>,
) -> Result<Vec<RmrkNftChild>>;
+ /// Get collection properties, created by the user - not the proxy-specific properties.
#[method(name = "rmrk_collectionProperties")]
- /// Get collection properties
fn collection_properties(
&self,
collection_id: RmrkCollectionId,
@@ -276,8 +310,8 @@
at: Option<BlockHash>,
) -> Result<Vec<PropertyInfo>>;
+ /// Get NFT properties, created by the user - not the proxy-specific properties.
#[method(name = "rmrk_nftProperties")]
- /// Get NFT properties
fn nft_properties(
&self,
collection_id: RmrkCollectionId,
@@ -286,8 +320,8 @@
at: Option<BlockHash>,
) -> Result<Vec<PropertyInfo>>;
+ /// Get data of resources of an NFT.
#[method(name = "rmrk_nftResources")]
- /// Get NFT resources
fn nft_resources(
&self,
collection_id: RmrkCollectionId,
@@ -295,8 +329,8 @@
at: Option<BlockHash>,
) -> Result<Vec<ResourceInfo>>;
+ /// Get the priority of a resource in an NFT.
#[method(name = "rmrk_nftResourcePriority")]
- /// Get NFT resource priority
fn nft_resource_priority(
&self,
collection_id: RmrkCollectionId,
@@ -305,14 +339,15 @@
at: Option<BlockHash>,
) -> Result<Option<u32>>;
+ /// Get base info by its ID.
#[method(name = "rmrk_base")]
- /// Get base info
fn base(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Option<BaseInfo>>;
+ /// Get all parts of a base.
#[method(name = "rmrk_baseParts")]
- /// Get all Base's parts
fn base_parts(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Vec<PartType>>;
+ /// Get the theme names belonging to a base.
#[method(name = "rmrk_themeNames")]
fn theme_names(
&self,
@@ -320,6 +355,7 @@
at: Option<BlockHash>,
) -> Result<Vec<RmrkThemeName>>;
+ /// Get theme info, including properties, optionally limited to the provided keys.
#[method(name = "rmrk_themes")]
fn theme(
&self,
pallets/common/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! # Common pallet18//!19//! The Common pallet provides functionality for handling collections.20//!21//! ## Overview22//!23//! The Common pallet provides an interface for common collection operations for different collection types24//! (see [CommonCollectionOperations]), as well as a generic dispatcher for these, see [dispatch] module.25//! It also provides this functionality to EVM, see [erc] and [eth] modules.26//!27//! The Common pallet provides functions for:28//!29//! - Setting and approving collection sponsor.30//! - Get\set\delete allow list.31//! - Get\set\delete collection properties.32//! - Get\set\delete collection property permissions.33//! - Get\set\delete token property permissions.34//! - Get\set\delete collection administrators.35//! - Checking access permissions.36//!37//! ### Terminology38//! **Collection sponsor** - For the collection, you can set a sponsor, at whose expense it will39//! be possible to mint tokens.40//!41//! **Allow list** - List of users who have the right to minting tokens.42//!43//! **Collection properties** - Collection properties are simply key-value stores where various44//! metadata can be placed.45//!46//! **Permissions on token properties** - For each property in the token can be set permission47//! to change, see [`PropertyPermission`].48//!49//! **Collection administrator** - For a collection, you can set administrators who have the right50//! to most actions on the collection.5152#![warn(missing_docs)]53#![cfg_attr(not(feature = "std"), no_std)]54extern crate alloc;5556use core::ops::{Deref, DerefMut};57use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};58use sp_std::vec::Vec;59use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};60use evm_coder::ToLog;61use frame_support::{62 dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Weight, PostDispatchInfo},63 ensure,64 traits::{Imbalance, Get, Currency, WithdrawReasons, ExistenceRequirement},65 weights::Pays,66 transactional,67};68use pallet_evm::GasWeightMapping;69use up_data_structs::{70 COLLECTION_NUMBER_LIMIT,71 Collection,72 RpcCollection,73 CollectionId,74 CreateItemData,75 MAX_TOKEN_PREFIX_LENGTH,76 COLLECTION_ADMINS_LIMIT,77 TokenId,78 TokenChild,79 CollectionStats,80 MAX_TOKEN_OWNERSHIP,81 CollectionMode,82 NFT_SPONSOR_TRANSFER_TIMEOUT,83 FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,84 REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,85 MAX_SPONSOR_TIMEOUT,86 CUSTOM_DATA_LIMIT,87 CollectionLimits,88 CreateCollectionData,89 SponsorshipState,90 CreateItemExData,91 SponsoringRateLimit,92 budget::Budget,93 PhantomType,94 Property,95 Properties,96 PropertiesPermissionMap,97 PropertyKey,98 PropertyValue,99 PropertyPermission,100 PropertiesError,101 PropertyKeyPermission,102 TokenData,103 TrySetProperty,104 PropertyScope,105 // RMRK106 RmrkCollectionInfo,107 RmrkInstanceInfo,108 RmrkResourceInfo,109 RmrkPropertyInfo,110 RmrkBaseInfo,111 RmrkPartType,112 RmrkBoundedTheme,113 RmrkNftChild,114 CollectionPermissions,115 SchemaVersion,116};117118pub use pallet::*;119use sp_core::H160;120use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};121#[cfg(feature = "runtime-benchmarks")]122pub mod benchmarking;123pub mod dispatch;124pub mod erc;125pub mod eth;126pub mod weights;127128/// Weight info.129pub type SelfWeightOf<T> = <T as Config>::WeightInfo;130131/// Collection handle contains information about collection data and id.132/// Also provides functionality to count consumed gas.133///134/// CollectionHandle is used as a generic wrapper for collections of all types.135/// It allows to perform common operations and queries on any collection type,136/// both completely general for all, as well as their respective implementations of [`CommonCollectionOperations`].137#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]138pub struct CollectionHandle<T: Config> {139 /// Collection id140 pub id: CollectionId,141 collection: Collection<T::AccountId>,142 /// Substrate recorder for counting consumed gas143 pub recorder: SubstrateRecorder<T>,144}145146impl<T: Config> WithRecorder<T> for CollectionHandle<T> {147 fn recorder(&self) -> &SubstrateRecorder<T> {148 &self.recorder149 }150 fn into_recorder(self) -> SubstrateRecorder<T> {151 self.recorder152 }153}154155impl<T: Config> CollectionHandle<T> {156 /// Same as [CollectionHandle::new] but with an explicit gas limit.157 pub fn new_with_gas_limit(id: CollectionId, gas_limit: u64) -> Option<Self> {158 <CollectionById<T>>::get(id).map(|collection| Self {159 id,160 collection,161 recorder: SubstrateRecorder::new(gas_limit),162 })163 }164165 /// Same as [CollectionHandle::new] but with an existed [`SubstrateRecorder`].166 pub fn new_with_recorder(id: CollectionId, recorder: SubstrateRecorder<T>) -> Option<Self> {167 <CollectionById<T>>::get(id).map(|collection| Self {168 id,169 collection,170 recorder,171 })172 }173174 /// Retrives collection data from storage and creates collection handle with default parameters.175 /// If collection not found return `None`176 pub fn new(id: CollectionId) -> Option<Self> {177 Self::new_with_gas_limit(id, u64::MAX)178 }179180 /// Same as [`CollectionHandle::new`] but if collection not found [CollectionNotFound](Error::CollectionNotFound) returned.181 pub fn try_get(id: CollectionId) -> Result<Self, DispatchError> {182 Ok(Self::new(id).ok_or(<Error<T>>::CollectionNotFound)?)183 }184185 /// Consume gas for reading.186 pub fn consume_store_reads(&self, reads: u64) -> evm_coder::execution::Result<()> {187 self.recorder188 .consume_gas(T::GasWeightMapping::weight_to_gas(189 <T as frame_system::Config>::DbWeight::get()190 .read191 .saturating_mul(reads),192 ))193 }194195 /// Consume gas for writing.196 pub fn consume_store_writes(&self, writes: u64) -> evm_coder::execution::Result<()> {197 self.recorder198 .consume_gas(T::GasWeightMapping::weight_to_gas(199 <T as frame_system::Config>::DbWeight::get()200 .write201 .saturating_mul(writes),202 ))203 }204205 /// Save collection to storage.206 pub fn save(self) -> DispatchResult {207 <CollectionById<T>>::insert(self.id, self.collection);208 Ok(())209 }210211 /// Set collection sponsor.212 ///213 /// Unique collections allows sponsoring for certain actions.214 /// This method allows you to set the sponsor of the collection.215 /// In order for sponsorship to become active, it must be confirmed through [`Self::confirm_sponsorship`].216 pub fn set_sponsor(&mut self, sponsor: T::AccountId) -> DispatchResult {217 self.collection.sponsorship = SponsorshipState::Unconfirmed(sponsor);218 Ok(())219 }220221 /// Confirm sponsorship222 ///223 /// In order for the sponsorship to become active, the user set as the sponsor must confirm their participation.224 /// Before confirming sponsorship, the user must be specified as the sponsor of the collection via [`Self::set_sponsor`].225 pub fn confirm_sponsorship(&mut self, sender: &T::AccountId) -> Result<bool, DispatchError> {226 if self.collection.sponsorship.pending_sponsor() != Some(sender) {227 return Ok(false);228 }229230 self.collection.sponsorship = SponsorshipState::Confirmed(sender.clone());231 Ok(true)232 }233234 /// Checks that the collection was created with, and must be operated upon through **Unique API**.235 /// Now check only the `external_collection` flag and if it's **true**, then return [`Error::CollectionIsExternal`] error.236 pub fn check_is_internal(&self) -> DispatchResult {237 if self.external_collection {238 return Err(<Error<T>>::CollectionIsExternal)?;239 }240241 Ok(())242 }243244 /// Checks that the collection was created with, and must be operated upon through an **assimilated API**.245 /// Now check only the `external_collection` flag and if it's **false**, then return [`Error::CollectionIsInternal`] error.246 pub fn check_is_external(&self) -> DispatchResult {247 if !self.external_collection {248 return Err(<Error<T>>::CollectionIsInternal)?;249 }250251 Ok(())252 }253}254255impl<T: Config> Deref for CollectionHandle<T> {256 type Target = Collection<T::AccountId>;257258 fn deref(&self) -> &Self::Target {259 &self.collection260 }261}262263impl<T: Config> DerefMut for CollectionHandle<T> {264 fn deref_mut(&mut self) -> &mut Self::Target {265 &mut self.collection266 }267}268269impl<T: Config> CollectionHandle<T> {270 /// Checks if the `user` is the owner of the collection.271 pub fn check_is_owner(&self, user: &T::CrossAccountId) -> DispatchResult {272 ensure!(*user.as_sub() == self.owner, <Error<T>>::NoPermission);273 Ok(())274 }275276 /// Returns **true** if the `user` is the owner or administrator of the collection.277 pub fn is_owner_or_admin(&self, user: &T::CrossAccountId) -> bool {278 *user.as_sub() == self.owner || <IsAdmin<T>>::get((self.id, user))279 }280281 /// Checks if the `user` is the owner or administrator of the collection.282 pub fn check_is_owner_or_admin(&self, user: &T::CrossAccountId) -> DispatchResult {283 ensure!(self.is_owner_or_admin(user), <Error<T>>::NoPermission);284 Ok(())285 }286287 /// Return **true** if `user` was not allowed to have tokens, and he can ignore such restrictions.288 pub fn ignores_allowance(&self, user: &T::CrossAccountId) -> bool {289 self.limits.owner_can_transfer() && self.is_owner_or_admin(user)290 }291292 /// Return **true** if `user` does not have enough token parts, and he can ignore such restrictions.293 pub fn ignores_owned_amount(&self, user: &T::CrossAccountId) -> bool {294 self.limits.owner_can_transfer() && self.is_owner_or_admin(user)295 }296297 /// Checks if the user is in the allow list. If not [Error::AddressNotInAllowlist] returns.298 pub fn check_allowlist(&self, user: &T::CrossAccountId) -> DispatchResult {299 ensure!(300 <Allowlist<T>>::get((self.id, user)),301 <Error<T>>::AddressNotInAllowlist302 );303 Ok(())304 }305}306307#[frame_support::pallet]308pub mod pallet {309 use super::*;310 use pallet_evm::account;311 use dispatch::CollectionDispatch;312 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key, traits::StorageVersion};313 use frame_system::pallet_prelude::*;314 use frame_support::traits::Currency;315 use up_data_structs::{TokenId, mapping::TokenAddressMapping};316 use scale_info::TypeInfo;317 use weights::WeightInfo;318319 #[pallet::config]320 pub trait Config:321 frame_system::Config322 + pallet_evm_coder_substrate::Config323 + pallet_evm::Config324 + TypeInfo325 + account::Config326 {327 /// Weight information for functions of this pallet.328 type WeightInfo: WeightInfo;329330 /// Events compatible with [`frame_system::Config::Event`].331 type Event: IsType<<Self as frame_system::Config>::Event> + From<Event<Self>>;332333 /// Handler of accounts and payment.334 type Currency: Currency<Self::AccountId>;335336 /// Set price to create a collection.337 #[pallet::constant]338 type CollectionCreationPrice: Get<339 <<Self as Config>::Currency as Currency<Self::AccountId>>::Balance,340 >;341342 /// Dispatcher of operations on collections.343 type CollectionDispatch: CollectionDispatch<Self>;344345 /// Account which holds the chain's treasury.346 type TreasuryAccountId: Get<Self::AccountId>;347348 /// Address under which the CollectionHelper contract would be available.349 type ContractAddress: Get<H160>;350351 /// Mapper for token addresses to Ethereum addresses.352 type EvmTokenAddressMapping: TokenAddressMapping<H160>;353354 /// Mapper for token addresses to [`CrossAccountId`].355 type CrossTokenAddressMapping: TokenAddressMapping<Self::CrossAccountId>;356 }357358 const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);359360 #[pallet::pallet]361 #[pallet::storage_version(STORAGE_VERSION)]362 #[pallet::generate_store(pub(super) trait Store)]363 pub struct Pallet<T>(_);364365 #[pallet::extra_constants]366 impl<T: Config> Pallet<T> {367 /// Maximum admins per collection.368 pub fn collection_admins_limit() -> u32 {369 COLLECTION_ADMINS_LIMIT370 }371 }372373 #[pallet::event]374 #[pallet::generate_deposit(pub fn deposit_event)]375 pub enum Event<T: Config> {376 /// New collection was created377 CollectionCreated(378 /// Globally unique identifier of newly created collection.379 CollectionId,380 /// [`CollectionMode`] converted into _u8_.381 u8,382 /// Collection owner.383 T::AccountId,384 ),385386 /// New collection was destroyed387 CollectionDestroyed(388 /// Globally unique identifier of collection.389 CollectionId,390 ),391392 /// New item was created.393 ItemCreated(394 /// Id of the collection where item was created.395 CollectionId,396 /// Id of an item. Unique within the collection.397 TokenId,398 /// Owner of newly created item399 T::CrossAccountId,400 /// Always 1 for NFT401 u128,402 ),403404 /// Collection item was burned.405 ItemDestroyed(406 /// Id of the collection where item was destroyed.407 CollectionId,408 /// Identifier of burned NFT.409 TokenId,410 /// Which user has destroyed its tokens.411 T::CrossAccountId,412 /// Amount of token pieces destroed. Always 1 for NFT.413 u128,414 ),415416 /// Item was transferred417 Transfer(418 /// Id of collection to which item is belong.419 CollectionId,420 /// Id of an item.421 TokenId,422 /// Original owner of item.423 T::CrossAccountId,424 /// New owner of item.425 T::CrossAccountId,426 /// Amount of token pieces transfered. Always 1 for NFT.427 u128,428 ),429430 /// Amount pieces of token owned by `sender` was approved for `spender`.431 Approved(432 /// Id of collection to which item is belong.433 CollectionId,434 /// Id of an item.435 TokenId,436 /// Original owner of item.437 T::CrossAccountId,438 /// Id for which the approval was granted.439 T::CrossAccountId,440 /// Amount of token pieces transfered. Always 1 for NFT.441 u128,442 ),443444 /// The colletion property has been set.445 CollectionPropertySet(446 /// Id of collection to which property has been set.447 CollectionId,448 /// The property that was set.449 PropertyKey,450 ),451452 /// The property has been deleted.453 CollectionPropertyDeleted(454 /// Id of collection to which property has been deleted.455 CollectionId,456 /// The property that was deleted.457 PropertyKey,458 ),459460 /// The token property has been set.461 TokenPropertySet(462 /// Identifier of the collection whose token has the property set.463 CollectionId,464 /// The token for which the property was set.465 TokenId,466 /// The property that was set.467 PropertyKey,468 ),469470 /// The token property has been deleted.471 TokenPropertyDeleted(472 /// Identifier of the collection whose token has the property deleted.473 CollectionId,474 /// The token for which the property was deleted.475 TokenId,476 /// The property that was deleted.477 PropertyKey,478 ),479480 /// The colletion property permission has been set.481 PropertyPermissionSet(482 /// Id of collection to which property permission has been set.483 CollectionId,484 /// The property permission that was set.485 PropertyKey,486 ),487 }488489 #[pallet::error]490 pub enum Error<T> {491 /// This collection does not exist.492 CollectionNotFound,493 /// Sender parameter and item owner must be equal.494 MustBeTokenOwner,495 /// No permission to perform action496 NoPermission,497 /// Destroying only empty collections is allowed498 CantDestroyNotEmptyCollection,499 /// Collection is not in mint mode.500 PublicMintingNotAllowed,501 /// Address is not in allow list.502 AddressNotInAllowlist,503504 /// Collection name can not be longer than 63 char.505 CollectionNameLimitExceeded,506 /// Collection description can not be longer than 255 char.507 CollectionDescriptionLimitExceeded,508 /// Token prefix can not be longer than 15 char.509 CollectionTokenPrefixLimitExceeded,510 /// Total collections bound exceeded.511 TotalCollectionsLimitExceeded,512 /// Exceeded max admin count513 CollectionAdminCountExceeded,514 /// Collection limit bounds per collection exceeded515 CollectionLimitBoundsExceeded,516 /// Tried to enable permissions which are only permitted to be disabled517 OwnerPermissionsCantBeReverted,518 /// Collection settings not allowing items transferring519 TransferNotAllowed,520 /// Account token limit exceeded per collection521 AccountTokenLimitExceeded,522 /// Collection token limit exceeded523 CollectionTokenLimitExceeded,524 /// Metadata flag frozen525 MetadataFlagFrozen,526527 /// Item not exists.528 TokenNotFound,529 /// Item balance not enough.530 TokenValueTooLow,531 /// Requested value more than approved.532 ApprovedValueTooLow,533 /// Tried to approve more than owned534 CantApproveMoreThanOwned,535536 /// Can't transfer tokens to ethereum zero address537 AddressIsZero,538 /// Target collection doesn't supports this operation539 UnsupportedOperation,540541 /// Not sufficient funds to perform action542 NotSufficientFounds,543544 /// User not passed nesting rule545 UserIsNotAllowedToNest,546 /// Only tokens from specific collections may nest tokens under this547 SourceCollectionIsNotAllowedToNest,548549 /// Tried to store more data than allowed in collection field550 CollectionFieldSizeExceeded,551552 /// Tried to store more property data than allowed553 NoSpaceForProperty,554555 /// Tried to store more property keys than allowed556 PropertyLimitReached,557558 /// Property key is too long559 PropertyKeyIsTooLong,560561 /// Only ASCII letters, digits, and '_', '-' are allowed562 InvalidCharacterInPropertyKey,563564 /// Empty property keys are forbidden565 EmptyPropertyKey,566567 /// Tried to access an external collection with an internal API568 CollectionIsExternal,569570 /// Tried to access an internal collection with an external API571 CollectionIsInternal,572 }573574 /// Storage of the count of created collections.575 #[pallet::storage]576 pub type CreatedCollectionCount<T> = StorageValue<Value = CollectionId, QueryKind = ValueQuery>;577578 /// Storage of the count of deleted collections.579 #[pallet::storage]580 pub type DestroyedCollectionCount<T> =581 StorageValue<Value = CollectionId, QueryKind = ValueQuery>;582583 /// Storage of collection info.584 #[pallet::storage]585 pub type CollectionById<T> = StorageMap<586 Hasher = Blake2_128Concat,587 Key = CollectionId,588 Value = Collection<<T as frame_system::Config>::AccountId>,589 QueryKind = OptionQuery,590 >;591592 /// Storage of collection properties.593 #[pallet::storage]594 #[pallet::getter(fn collection_properties)]595 pub type CollectionProperties<T> = StorageMap<596 Hasher = Blake2_128Concat,597 Key = CollectionId,598 Value = Properties,599 QueryKind = ValueQuery,600 OnEmpty = up_data_structs::CollectionProperties,601 >;602603 /// Storage of collection properties permissions.604 #[pallet::storage]605 #[pallet::getter(fn property_permissions)]606 pub type CollectionPropertyPermissions<T> = StorageMap<607 Hasher = Blake2_128Concat,608 Key = CollectionId,609 Value = PropertiesPermissionMap,610 QueryKind = ValueQuery,611 >;612613 /// Storage of collection admins count.614 #[pallet::storage]615 pub type AdminAmount<T> = StorageMap<616 Hasher = Blake2_128Concat,617 Key = CollectionId,618 Value = u32,619 QueryKind = ValueQuery,620 >;621622 /// List of collection admins623 #[pallet::storage]624 pub type IsAdmin<T: Config> = StorageNMap<625 Key = (626 Key<Blake2_128Concat, CollectionId>,627 Key<Blake2_128Concat, T::CrossAccountId>,628 ),629 Value = bool,630 QueryKind = ValueQuery,631 >;632633 /// Allowlisted collection users634 #[pallet::storage]635 pub type Allowlist<T: Config> = StorageNMap<636 Key = (637 Key<Blake2_128Concat, CollectionId>,638 Key<Blake2_128Concat, T::CrossAccountId>,639 ),640 Value = bool,641 QueryKind = ValueQuery,642 >;643644 /// Not used by code, exists only to provide some types to metadata.645 #[pallet::storage]646 pub type DummyStorageValue<T: Config> = StorageValue<647 Value = (648 CollectionStats,649 CollectionId,650 TokenId,651 TokenChild,652 PhantomType<(653 TokenData<T::CrossAccountId>,654 RpcCollection<T::AccountId>,655 // RMRK656 RmrkCollectionInfo<T::AccountId>,657 RmrkInstanceInfo<T::AccountId>,658 RmrkResourceInfo,659 RmrkPropertyInfo,660 RmrkBaseInfo<T::AccountId>,661 RmrkPartType,662 RmrkBoundedTheme,663 RmrkNftChild,664 )>,665 ),666 QueryKind = OptionQuery,667 >;668669 #[pallet::hooks]670 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {671 fn on_runtime_upgrade() -> Weight {672 if StorageVersion::get::<Pallet<T>>() < StorageVersion::new(1) {673 use up_data_structs::{CollectionVersion1, CollectionVersion2};674 <CollectionById<T>>::translate::<CollectionVersion1<T::AccountId>, _>(|id, v| {675 let mut props = Vec::new();676 if !v.offchain_schema.is_empty() {677 props.push(Property {678 key: b"_old_offchainSchema".to_vec().try_into().unwrap(),679 value: v680 .offchain_schema681 .clone()682 .into_inner()683 .try_into()684 .expect("offchain schema too big"),685 });686 }687 if !v.variable_on_chain_schema.is_empty() {688 props.push(Property {689 key: b"_old_variableOnChainSchema".to_vec().try_into().unwrap(),690 value: v691 .variable_on_chain_schema692 .clone()693 .into_inner()694 .try_into()695 .expect("offchain schema too big"),696 });697 }698 if !v.const_on_chain_schema.is_empty() {699 props.push(Property {700 key: b"_old_constOnChainSchema".to_vec().try_into().unwrap(),701 value: v702 .const_on_chain_schema703 .clone()704 .into_inner()705 .try_into()706 .expect("offchain schema too big"),707 });708 }709 props.push(Property {710 key: b"_old_schemaVersion".to_vec().try_into().unwrap(),711 value: match v.schema_version {712 SchemaVersion::ImageURL => b"ImageUrl".as_slice(),713 SchemaVersion::Unique => b"Unique".as_slice(),714 }715 .to_vec()716 .try_into()717 .unwrap(),718 });719 Self::set_scoped_collection_properties(720 id,721 PropertyScope::None,722 props.into_iter(),723 )724 .expect("existing data larger than properties");725 let mut new = CollectionVersion2::from(v.clone());726 new.permissions.access = Some(v.access);727 new.permissions.mint_mode = Some(v.mint_mode);728 Some(new)729 });730 }731732 0733 }734 }735}736737impl<T: Config> Pallet<T> {738 /// Enshure that receiver address is correct.739 ///740 /// Ethereum receiver 0x0000000000000000000000000000000000000000 is reserved, and shouldn't own tokens.741 pub fn ensure_correct_receiver(receiver: &T::CrossAccountId) -> DispatchResult {742 ensure!(743 &T::CrossAccountId::from_eth(H160([0; 20])) != receiver,744 <Error<T>>::AddressIsZero745 );746 Ok(())747 }748749 /// Get a vector of collection admins.750 pub fn adminlist(collection: CollectionId) -> Vec<T::CrossAccountId> {751 <IsAdmin<T>>::iter_prefix((collection,))752 .map(|(a, _)| a)753 .collect()754 }755756 /// Get a vector of users allowed to mint tokens.757 pub fn allowlist(collection: CollectionId) -> Vec<T::CrossAccountId> {758 <Allowlist<T>>::iter_prefix((collection,))759 .map(|(a, _)| a)760 .collect()761 }762763 /// Is `user` allowed to mint token in `collection`.764 pub fn allowed(collection: CollectionId, user: T::CrossAccountId) -> bool {765 <Allowlist<T>>::get((collection, user))766 }767768 /// Get statistics of collections.769 pub fn collection_stats() -> CollectionStats {770 let created = <CreatedCollectionCount<T>>::get();771 let destroyed = <DestroyedCollectionCount<T>>::get();772 CollectionStats {773 created: created.0,774 destroyed: destroyed.0,775 alive: created.0 - destroyed.0,776 }777 }778779 /// Get the effective limits for the collection.780 pub fn effective_collection_limits(collection: CollectionId) -> Option<CollectionLimits> {781 let collection = <CollectionById<T>>::get(collection);782 if collection.is_none() {783 return None;784 }785786 let collection = collection.unwrap();787 let limits = collection.limits;788 let effective_limits = CollectionLimits {789 account_token_ownership_limit: Some(limits.account_token_ownership_limit()),790 sponsored_data_size: Some(limits.sponsored_data_size()),791 sponsored_data_rate_limit: Some(792 limits793 .sponsored_data_rate_limit794 .unwrap_or(SponsoringRateLimit::SponsoringDisabled),795 ),796 token_limit: Some(limits.token_limit()),797 sponsor_transfer_timeout: Some(limits.sponsor_transfer_timeout(798 match collection.mode {799 CollectionMode::NFT => NFT_SPONSOR_TRANSFER_TIMEOUT,800 CollectionMode::Fungible(_) => FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,801 CollectionMode::ReFungible => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,802 },803 )),804 sponsor_approve_timeout: Some(limits.sponsor_approve_timeout()),805 owner_can_transfer: Some(limits.owner_can_transfer()),806 owner_can_destroy: Some(limits.owner_can_destroy()),807 transfers_enabled: Some(limits.transfers_enabled()),808 };809810 Some(effective_limits)811 }812813 /// Returns information about the `collection` adapted for rpc.814 pub fn rpc_collection(collection: CollectionId) -> Option<RpcCollection<T::AccountId>> {815 let Collection {816 name,817 description,818 owner,819 mode,820 token_prefix,821 sponsorship,822 limits,823 permissions,824 external_collection,825 } = <CollectionById<T>>::get(collection)?;826827 let token_property_permissions = <CollectionPropertyPermissions<T>>::get(collection)828 .into_iter()829 .map(|(key, permission)| PropertyKeyPermission { key, permission })830 .collect();831832 let properties = <CollectionProperties<T>>::get(collection)833 .into_iter()834 .map(|(key, value)| Property { key, value })835 .collect();836837 let permissions = CollectionPermissions {838 access: Some(permissions.access()),839 mint_mode: Some(permissions.mint_mode()),840 nesting: Some(permissions.nesting().clone()),841 };842843 Some(RpcCollection {844 name: name.into_inner(),845 description: description.into_inner(),846 owner,847 mode,848 token_prefix: token_prefix.into_inner(),849 sponsorship,850 limits,851 permissions,852 token_property_permissions,853 properties,854 read_only: external_collection,855 })856 }857}858859macro_rules! limit_default {860 ($old:ident, $new:ident, $($field:ident $(($arg:expr))? => $check:expr),* $(,)?) => {{861 $(862 if let Some($new) = $new.$field {863 let $old = $old.$field($($arg)?);864 let _ = $new;865 let _ = $old;866 $check867 } else {868 $new.$field = $old.$field869 }870 )*871 }};872}873macro_rules! limit_default_clone {874 ($old:ident, $new:ident, $($field:ident $(($arg:expr))? => $check:expr),* $(,)?) => {{875 $(876 if let Some($new) = $new.$field.clone() {877 let $old = $old.$field($($arg)?);878 let _ = $new;879 let _ = $old;880 $check881 } else {882 $new.$field = $old.$field.clone()883 }884 )*885 }};886}887888impl<T: Config> Pallet<T> {889 /// Create new collection.890 ///891 /// * `owner` - The owner of the collection.892 /// * `data` - Description of the created collection.893 /// * `is_external` - Marks that collection managet by not "Unique network".894 pub fn init_collection(895 owner: T::CrossAccountId,896 data: CreateCollectionData<T::AccountId>,897 is_external: bool,898 ) -> Result<CollectionId, DispatchError> {899 {900 ensure!(901 data.token_prefix.len() <= MAX_TOKEN_PREFIX_LENGTH as usize,902 Error::<T>::CollectionTokenPrefixLimitExceeded903 );904 }905906 let created_count = <CreatedCollectionCount<T>>::get()907 .0908 .checked_add(1)909 .ok_or(ArithmeticError::Overflow)?;910 let destroyed_count = <DestroyedCollectionCount<T>>::get().0;911 let id = CollectionId(created_count);912913 // bound Total number of collections914 ensure!(915 created_count - destroyed_count <= COLLECTION_NUMBER_LIMIT,916 <Error<T>>::TotalCollectionsLimitExceeded917 );918919 // =========920921 let collection = Collection {922 owner: owner.as_sub().clone(),923 name: data.name,924 mode: data.mode.clone(),925 description: data.description,926 token_prefix: data.token_prefix,927 sponsorship: data928 .pending_sponsor929 .map(SponsorshipState::Unconfirmed)930 .unwrap_or_default(),931 limits: data932 .limits933 .map(|limits| Self::clamp_limits(data.mode.clone(), &Default::default(), limits))934 .unwrap_or_else(|| Ok(CollectionLimits::default()))?,935 permissions: data936 .permissions937 .map(|permissions| {938 Self::clamp_permissions(data.mode.clone(), &Default::default(), permissions)939 })940 .unwrap_or_else(|| Ok(CollectionPermissions::default()))?,941 external_collection: is_external,942 };943944 let mut collection_properties = up_data_structs::CollectionProperties::get();945 collection_properties946 .try_set_from_iter(data.properties.into_iter())947 .map_err(<Error<T>>::from)?;948949 CollectionProperties::<T>::insert(id, collection_properties);950951 let mut token_props_permissions = PropertiesPermissionMap::new();952 token_props_permissions953 .try_set_from_iter(data.token_property_permissions.into_iter())954 .map_err(<Error<T>>::from)?;955956 CollectionPropertyPermissions::<T>::insert(id, token_props_permissions);957958 // Take a (non-refundable) deposit of collection creation959 {960 let mut imbalance =961 <<<T as Config>::Currency as Currency<T::AccountId>>::PositiveImbalance>::zero();962 imbalance.subsume(963 <<T as Config>::Currency as Currency<T::AccountId>>::deposit_creating(964 &T::TreasuryAccountId::get(),965 T::CollectionCreationPrice::get(),966 ),967 );968 <T as Config>::Currency::settle(969 owner.as_sub(),970 imbalance,971 WithdrawReasons::TRANSFER,972 ExistenceRequirement::KeepAlive,973 )974 .map_err(|_| Error::<T>::NotSufficientFounds)?;975 }976977 <CreatedCollectionCount<T>>::put(created_count);978 <Pallet<T>>::deposit_event(Event::CollectionCreated(979 id,980 data.mode.id(),981 owner.as_sub().clone(),982 ));983 <PalletEvm<T>>::deposit_log(984 erc::CollectionHelpersEvents::CollectionCreated {985 owner: *owner.as_eth(),986 collection_id: eth::collection_id_to_address(id),987 }988 .to_log(T::ContractAddress::get()),989 );990 <CollectionById<T>>::insert(id, collection);991 Ok(id)992 }993994 /// Destroy collection.995 ///996 /// * `collection` - Collection handler.997 /// * `sender` - The owner or administrator of the collection.998 pub fn destroy_collection(999 collection: CollectionHandle<T>,1000 sender: &T::CrossAccountId,1001 ) -> DispatchResult {1002 ensure!(1003 collection.limits.owner_can_destroy(),1004 <Error<T>>::NoPermission,1005 );1006 collection.check_is_owner(sender)?;10071008 let destroyed_collections = <DestroyedCollectionCount<T>>::get()1009 .01010 .checked_add(1)1011 .ok_or(ArithmeticError::Overflow)?;10121013 // =========10141015 <DestroyedCollectionCount<T>>::put(destroyed_collections);1016 <CollectionById<T>>::remove(collection.id);1017 <AdminAmount<T>>::remove(collection.id);1018 <IsAdmin<T>>::remove_prefix((collection.id,), None);1019 <Allowlist<T>>::remove_prefix((collection.id,), None);1020 <CollectionProperties<T>>::remove(collection.id);10211022 <Pallet<T>>::deposit_event(Event::CollectionDestroyed(collection.id));1023 Ok(())1024 }10251026 /// Set collection property.1027 ///1028 /// * `collection` - Collection handler.1029 /// * `sender` - The owner or administrator of the collection.1030 /// * `property` - The property to set.1031 pub fn set_collection_property(1032 collection: &CollectionHandle<T>,1033 sender: &T::CrossAccountId,1034 property: Property,1035 ) -> DispatchResult {1036 collection.check_is_owner_or_admin(sender)?;10371038 CollectionProperties::<T>::try_mutate(collection.id, |properties| {1039 let property = property.clone();1040 properties.try_set(property.key, property.value)1041 })1042 .map_err(<Error<T>>::from)?;10431044 Self::deposit_event(Event::CollectionPropertySet(collection.id, property.key));10451046 Ok(())1047 }10481049 /// Set scouped collection property.1050 ///1051 /// * `collection_id` - ID of the collection for which the property is being set.1052 /// * `scope` - Property scope.1053 /// * `property` - The property to set.1054 pub fn set_scoped_collection_property(1055 collection_id: CollectionId,1056 scope: PropertyScope,1057 property: Property,1058 ) -> DispatchResult {1059 CollectionProperties::<T>::try_mutate(collection_id, |properties| {1060 properties.try_scoped_set(scope, property.key, property.value)1061 })1062 .map_err(<Error<T>>::from)?;10631064 Ok(())1065 }10661067 /// Set scouped collection properties.1068 ///1069 /// * `collection_id` - ID of the collection for which the properties is being set.1070 /// * `scope` - Property scope.1071 /// * `properties` - The properties to set.1072 pub fn set_scoped_collection_properties(1073 collection_id: CollectionId,1074 scope: PropertyScope,1075 properties: impl Iterator<Item = Property>,1076 ) -> DispatchResult {1077 CollectionProperties::<T>::try_mutate(collection_id, |stored_properties| {1078 stored_properties.try_scoped_set_from_iter(scope, properties)1079 })1080 .map_err(<Error<T>>::from)?;10811082 Ok(())1083 }10841085 /// Set collection properties.1086 ///1087 /// * `collection` - Collection handler.1088 /// * `sender` - The owner or administrator of the collection.1089 /// * `properties` - The properties to set.1090 #[transactional]1091 pub fn set_collection_properties(1092 collection: &CollectionHandle<T>,1093 sender: &T::CrossAccountId,1094 properties: Vec<Property>,1095 ) -> DispatchResult {1096 for property in properties {1097 Self::set_collection_property(collection, sender, property)?;1098 }10991100 Ok(())1101 }11021103 /// Delete collection property.1104 ///1105 /// * `collection` - Collection handler.1106 /// * `sender` - The owner or administrator of the collection.1107 /// * `property` - The property to delete.1108 pub fn delete_collection_property(1109 collection: &CollectionHandle<T>,1110 sender: &T::CrossAccountId,1111 property_key: PropertyKey,1112 ) -> DispatchResult {1113 collection.check_is_owner_or_admin(sender)?;11141115 CollectionProperties::<T>::try_mutate(collection.id, |properties| {1116 properties.remove(&property_key)1117 })1118 .map_err(<Error<T>>::from)?;11191120 Self::deposit_event(Event::CollectionPropertyDeleted(1121 collection.id,1122 property_key,1123 ));11241125 Ok(())1126 }11271128 /// Delete collection properties.1129 ///1130 /// * `collection` - Collection handler.1131 /// * `sender` - The owner or administrator of the collection.1132 /// * `properties` - The properties to delete.1133 #[transactional]1134 pub fn delete_collection_properties(1135 collection: &CollectionHandle<T>,1136 sender: &T::CrossAccountId,1137 property_keys: Vec<PropertyKey>,1138 ) -> DispatchResult {1139 for key in property_keys {1140 Self::delete_collection_property(collection, sender, key)?;1141 }11421143 Ok(())1144 }11451146 /// Set collection propetry permission without any checks.1147 ///1148 /// Used for migrations.1149 ///1150 /// * `collection` - Collection handler.1151 /// * `property_permissions` - Property permissions.1152 pub fn set_property_permission_unchecked(1153 collection: CollectionId,1154 property_permission: PropertyKeyPermission,1155 ) -> DispatchResult {1156 <CollectionPropertyPermissions<T>>::try_mutate(collection, |permissions| {1157 permissions.try_set(property_permission.key, property_permission.permission)1158 })1159 .map_err(<Error<T>>::from)?;1160 Ok(())1161 }11621163 /// Set collection property permission.1164 ///1165 /// * `collection` - Collection handler.1166 /// * `sender` - The owner or administrator of the collection.1167 /// * `property_permission` - Property permission.1168 pub fn set_property_permission(1169 collection: &CollectionHandle<T>,1170 sender: &T::CrossAccountId,1171 property_permission: PropertyKeyPermission,1172 ) -> DispatchResult {1173 collection.check_is_owner_or_admin(sender)?;11741175 let all_permissions = CollectionPropertyPermissions::<T>::get(collection.id);1176 let current_permission = all_permissions.get(&property_permission.key);1177 if matches![1178 current_permission,1179 Some(PropertyPermission { mutable: false, .. })1180 ] {1181 return Err(<Error<T>>::NoPermission.into());1182 }11831184 CollectionPropertyPermissions::<T>::try_mutate(collection.id, |permissions| {1185 let property_permission = property_permission.clone();1186 permissions.try_set(property_permission.key, property_permission.permission)1187 })1188 .map_err(<Error<T>>::from)?;11891190 Self::deposit_event(Event::PropertyPermissionSet(1191 collection.id,1192 property_permission.key,1193 ));11941195 Ok(())1196 }11971198 /// Set token property permission.1199 ///1200 /// * `collection` - Collection handler.1201 /// * `sender` - The owner or administrator of the collection.1202 /// * `property_permissions` - Property permissions.1203 #[transactional]1204 pub fn set_token_property_permissions(1205 collection: &CollectionHandle<T>,1206 sender: &T::CrossAccountId,1207 property_permissions: Vec<PropertyKeyPermission>,1208 ) -> DispatchResult {1209 for prop_pemission in property_permissions {1210 Self::set_property_permission(collection, sender, prop_pemission)?;1211 }12121213 Ok(())1214 }12151216 /// Get collection property.1217 pub fn get_collection_property(1218 collection_id: CollectionId,1219 key: &PropertyKey,1220 ) -> Option<PropertyValue> {1221 Self::collection_properties(collection_id).get(key).cloned()1222 }12231224 /// Convert byte vector to property key vector.1225 pub fn bytes_keys_to_property_keys(1226 keys: Vec<Vec<u8>>,1227 ) -> Result<Vec<PropertyKey>, DispatchError> {1228 keys.into_iter()1229 .map(|key| -> Result<PropertyKey, DispatchError> {1230 key.try_into()1231 .map_err(|_| <Error<T>>::PropertyKeyIsTooLong.into())1232 })1233 .collect::<Result<Vec<PropertyKey>, DispatchError>>()1234 }12351236 /// Get properties according to given keys.1237 pub fn filter_collection_properties(1238 collection_id: CollectionId,1239 keys: Option<Vec<PropertyKey>>,1240 ) -> Result<Vec<Property>, DispatchError> {1241 let properties = Self::collection_properties(collection_id);12421243 let properties = keys1244 .map(|keys| {1245 keys.into_iter()1246 .filter_map(|key| {1247 properties.get(&key).map(|value| Property {1248 key,1249 value: value.clone(),1250 })1251 })1252 .collect()1253 })1254 .unwrap_or_else(|| {1255 properties1256 .into_iter()1257 .map(|(key, value)| Property { key, value })1258 .collect()1259 });12601261 Ok(properties)1262 }12631264 /// Get property permissions according to given keys.1265 pub fn filter_property_permissions(1266 collection_id: CollectionId,1267 keys: Option<Vec<PropertyKey>>,1268 ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {1269 let permissions = Self::property_permissions(collection_id);12701271 let key_permissions = keys1272 .map(|keys| {1273 keys.into_iter()1274 .filter_map(|key| {1275 permissions1276 .get(&key)1277 .map(|permission| PropertyKeyPermission {1278 key,1279 permission: permission.clone(),1280 })1281 })1282 .collect()1283 })1284 .unwrap_or_else(|| {1285 permissions1286 .into_iter()1287 .map(|(key, permission)| PropertyKeyPermission { key, permission })1288 .collect()1289 });12901291 Ok(key_permissions)1292 }12931294 /// Toggle `user` participation in the `collection`'s allow list.1295 pub fn toggle_allowlist(1296 collection: &CollectionHandle<T>,1297 sender: &T::CrossAccountId,1298 user: &T::CrossAccountId,1299 allowed: bool,1300 ) -> DispatchResult {1301 collection.check_is_owner_or_admin(sender)?;13021303 // =========13041305 if allowed {1306 <Allowlist<T>>::insert((collection.id, user), true);1307 } else {1308 <Allowlist<T>>::remove((collection.id, user));1309 }13101311 Ok(())1312 }13131314 /// Toggle `user` participation in the `collection`'s admin list.1315 pub fn toggle_admin(1316 collection: &CollectionHandle<T>,1317 sender: &T::CrossAccountId,1318 user: &T::CrossAccountId,1319 admin: bool,1320 ) -> DispatchResult {1321 collection.check_is_owner(sender)?;13221323 let was_admin = <IsAdmin<T>>::get((collection.id, user));1324 if was_admin == admin {1325 return Ok(());1326 }1327 let amount = <AdminAmount<T>>::get(collection.id);13281329 if admin {1330 let amount = amount1331 .checked_add(1)1332 .ok_or(<Error<T>>::CollectionAdminCountExceeded)?;1333 ensure!(1334 amount <= Self::collection_admins_limit(),1335 <Error<T>>::CollectionAdminCountExceeded,1336 );13371338 // =========13391340 <AdminAmount<T>>::insert(collection.id, amount);1341 <IsAdmin<T>>::insert((collection.id, user), true);1342 } else {1343 <AdminAmount<T>>::insert(collection.id, amount.saturating_sub(1));1344 <IsAdmin<T>>::remove((collection.id, user));1345 }13461347 Ok(())1348 }13491350 /// Merge set fields from `new_limit` to `old_limit`.1351 pub fn clamp_limits(1352 mode: CollectionMode,1353 old_limit: &CollectionLimits,1354 mut new_limit: CollectionLimits,1355 ) -> Result<CollectionLimits, DispatchError> {1356 let limits = old_limit;1357 limit_default!(old_limit, new_limit,1358 account_token_ownership_limit => ensure!(1359 new_limit <= MAX_TOKEN_OWNERSHIP,1360 <Error<T>>::CollectionLimitBoundsExceeded,1361 ),1362 sponsored_data_size => ensure!(1363 new_limit <= CUSTOM_DATA_LIMIT,1364 <Error<T>>::CollectionLimitBoundsExceeded,1365 ),13661367 sponsored_data_rate_limit => {},1368 token_limit => ensure!(1369 old_limit >= new_limit && new_limit > 0,1370 <Error<T>>::CollectionTokenLimitExceeded1371 ),13721373 sponsor_transfer_timeout(match mode {1374 CollectionMode::NFT => NFT_SPONSOR_TRANSFER_TIMEOUT,1375 CollectionMode::Fungible(_) => FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,1376 CollectionMode::ReFungible => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,1377 }) => ensure!(1378 new_limit <= MAX_SPONSOR_TIMEOUT,1379 <Error<T>>::CollectionLimitBoundsExceeded,1380 ),1381 sponsor_approve_timeout => {},1382 owner_can_transfer => ensure!(1383 !limits.owner_can_transfer_instaled() ||1384 old_limit || !new_limit,1385 <Error<T>>::OwnerPermissionsCantBeReverted,1386 ),1387 owner_can_destroy => ensure!(1388 old_limit || !new_limit,1389 <Error<T>>::OwnerPermissionsCantBeReverted,1390 ),1391 transfers_enabled => {},1392 );1393 Ok(new_limit)1394 }13951396 /// Merge set fields from `new_permission` to `old_permission`.1397 pub fn clamp_permissions(1398 _mode: CollectionMode,1399 old_permission: &CollectionPermissions,1400 mut new_permission: CollectionPermissions,1401 ) -> Result<CollectionPermissions, DispatchError> {1402 limit_default_clone!(old_permission, new_permission,1403 access => {},1404 mint_mode => {},1405 nesting => { /* todo check for permissive, if only it gets out of benchmarks */ },1406 );1407 Ok(new_permission)1408 }1409}14101411/// Indicates unsupported methods by returning [Error::UnsupportedOperation].1412#[macro_export]1413macro_rules! unsupported {1414 () => {1415 Err(<Error<T>>::UnsupportedOperation.into())1416 };1417}14181419/// Return weights for various worst-case operations.1420pub trait CommonWeightInfo<CrossAccountId> {1421 /// Weight of item creation.1422 fn create_item() -> Weight;14231424 /// Weight of items creation.1425 fn create_multiple_items(amount: &[CreateItemData]) -> Weight;14261427 /// Weight of items creation.1428 fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;14291430 /// The weight of the burning item.1431 fn burn_item() -> Weight;14321433 /// Property setting weight.1434 ///1435 /// * `amount`- The number of properties to set.1436 fn set_collection_properties(amount: u32) -> Weight;14371438 /// Collection property deletion weight.1439 ///1440 /// * `amount`- The number of properties to set.1441 fn delete_collection_properties(amount: u32) -> Weight;14421443 /// Token property setting weight.1444 ///1445 /// * `amount`- The number of properties to set.1446 fn set_token_properties(amount: u32) -> Weight;14471448 /// Token property deletion weight.1449 ///1450 /// * `amount`- The number of properties to delete.1451 fn delete_token_properties(amount: u32) -> Weight;14521453 /// Token property permissions set weight.1454 ///1455 /// * `amount`- The number of property permissions to set.1456 fn set_token_property_permissions(amount: u32) -> Weight;14571458 /// Transfer price of the token or its parts.1459 fn transfer() -> Weight;14601461 /// The price of setting the permission of the operation from another user.1462 fn approve() -> Weight;14631464 /// Transfer price from another user.1465 fn transfer_from() -> Weight;14661467 /// The price of burning a token from another user.1468 fn burn_from() -> Weight;14691470 /// Differs from burn_item in case of Fungible and Refungible, as it should burn1471 /// whole users's balance.1472 ///1473 /// This method shouldn't be used directly, as it doesn't count breadth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead1474 fn burn_recursively_self_raw() -> Weight;14751476 /// Cost of iterating over `amount` children while burning, without counting child burning itself.1477 ///1478 /// This method shouldn't be used directly, as it doesn't count depth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead1479 fn burn_recursively_breadth_raw(amount: u32) -> Weight;14801481 /// The price of recursive burning a token.1482 ///1483 /// `max_selfs` - The maximum burning weight of the token itself.1484 /// `max_breadth` - The maximum number of nested tokens to burn.1485 fn burn_recursively(max_selfs: u32, max_breadth: u32) -> Weight {1486 Self::burn_recursively_self_raw()1487 .saturating_mul(max_selfs.max(1) as u64)1488 .saturating_add(Self::burn_recursively_breadth_raw(max_breadth))1489 }1490}14911492/// Weight info extension trait for refungible pallet.1493pub trait RefungibleExtensionsWeightInfo {1494 /// Weight of token repartition.1495 fn repartition() -> Weight;1496}14971498/// Common collection operations.1499///1500/// It wraps methods in Fungible, Nonfungible and Refungible pallets1501/// and adds weight info.1502pub trait CommonCollectionOperations<T: Config> {1503 /// Create token.1504 ///1505 /// * `sender` - The user who mint the token and pays for the transaction.1506 /// * `to` - The user who will own the token.1507 /// * `data` - Token data.1508 /// * `nesting_budget` - A budget that can be spent on nesting tokens.1509 fn create_item(1510 &self,1511 sender: T::CrossAccountId,1512 to: T::CrossAccountId,1513 data: CreateItemData,1514 nesting_budget: &dyn Budget,1515 ) -> DispatchResultWithPostInfo;15161517 /// Create multiple tokens.1518 ///1519 /// * `sender` - The user who mint the token and pays for the transaction.1520 /// * `to` - The user who will own the token.1521 /// * `data` - Token data.1522 /// * `nesting_budget` - A budget that can be spent on nesting tokens.1523 fn create_multiple_items(1524 &self,1525 sender: T::CrossAccountId,1526 to: T::CrossAccountId,1527 data: Vec<CreateItemData>,1528 nesting_budget: &dyn Budget,1529 ) -> DispatchResultWithPostInfo;15301531 /// Create multiple tokens.1532 ///1533 /// * `sender` - The user who mint the token and pays for the transaction.1534 /// * `to` - The user who will own the token.1535 /// * `data` - Token data.1536 /// * `nesting_budget` - A budget that can be spent on nesting tokens.1537 fn create_multiple_items_ex(1538 &self,1539 sender: T::CrossAccountId,1540 data: CreateItemExData<T::CrossAccountId>,1541 nesting_budget: &dyn Budget,1542 ) -> DispatchResultWithPostInfo;15431544 /// Burn token.1545 ///1546 /// * `sender` - The user who owns the token.1547 /// * `token` - Token id that will burned.1548 /// * `amount` - The number of parts of the token that will be burned.1549 fn burn_item(1550 &self,1551 sender: T::CrossAccountId,1552 token: TokenId,1553 amount: u128,1554 ) -> DispatchResultWithPostInfo;15551556 /// Burn token and all nested tokens recursievly.1557 ///1558 /// * `sender` - The user who owns the token.1559 /// * `token` - Token id that will burned.1560 /// * `self_budget` - The budget that can be spent on burning tokens.1561 /// * `breadth_budget` - The budget that can be spent on burning nested tokens.1562 fn burn_item_recursively(1563 &self,1564 sender: T::CrossAccountId,1565 token: TokenId,1566 self_budget: &dyn Budget,1567 breadth_budget: &dyn Budget,1568 ) -> DispatchResultWithPostInfo;15691570 /// Set collection properties.1571 ///1572 /// * `sender` - Must be either the owner of the collection or its admin.1573 /// * `properties` - Properties to be set.1574 fn set_collection_properties(1575 &self,1576 sender: T::CrossAccountId,1577 properties: Vec<Property>,1578 ) -> DispatchResultWithPostInfo;15791580 /// Delete collection properties.1581 ///1582 /// * `sender` - Must be either the owner of the collection or its admin.1583 /// * `properties` - The properties to be removed.1584 fn delete_collection_properties(1585 &self,1586 sender: &T::CrossAccountId,1587 property_keys: Vec<PropertyKey>,1588 ) -> DispatchResultWithPostInfo;15891590 /// Set token properties.1591 ///1592 /// The appropriate [`PropertyPermission`] for the token property1593 /// must be set with [`Self::set_token_property_permissions`].1594 ///1595 /// * `sender` - Must be either the owner of the token or its admin.1596 /// * `token_id` - The token for which the properties are being set.1597 /// * `properties` - Properties to be set.1598 /// * `budget` - Budget for setting properties.1599 fn set_token_properties(1600 &self,1601 sender: T::CrossAccountId,1602 token_id: TokenId,1603 properties: Vec<Property>,1604 budget: &dyn Budget,1605 ) -> DispatchResultWithPostInfo;16061607 /// Remove token properties.1608 ///1609 /// The appropriate [`PropertyPermission`] for the token property1610 /// must be set with [`Self::set_token_property_permissions`].1611 ///1612 /// * `sender` - Must be either the owner of the token or its admin.1613 /// * `token_id` - The token for which the properties are being remove.1614 /// * `property_keys` - Keys to remove corresponding properties.1615 /// * `budget` - Budget for removing properties.1616 fn delete_token_properties(1617 &self,1618 sender: T::CrossAccountId,1619 token_id: TokenId,1620 property_keys: Vec<PropertyKey>,1621 budget: &dyn Budget,1622 ) -> DispatchResultWithPostInfo;16231624 /// Set token property permissions.1625 ///1626 /// * `sender` - Must be either the owner of the token or its admin.1627 /// * `token_id` - The token for which the properties are being set.1628 /// * `properties` - Properties to be set.1629 /// * `budget` - Budget for setting properties.1630 fn set_token_property_permissions(1631 &self,1632 sender: &T::CrossAccountId,1633 property_permissions: Vec<PropertyKeyPermission>,1634 ) -> DispatchResultWithPostInfo;16351636 /// Transfer amount of token pieces.1637 ///1638 /// * `sender` - Donor user.1639 /// * `to` - Recepient user.1640 /// * `token` - The token of which parts are being sent.1641 /// * `amount` - The number of parts of the token that will be transferred.1642 /// * `budget` - The maximum budget that can be spent on the transfer.1643 fn transfer(1644 &self,1645 sender: T::CrossAccountId,1646 to: T::CrossAccountId,1647 token: TokenId,1648 amount: u128,1649 budget: &dyn Budget,1650 ) -> DispatchResultWithPostInfo;16511652 /// Grant access to another account to transfer parts of the token owned by the calling user via [Self::transfer_from].1653 ///1654 /// * `sender` - The user who grants access to the token.1655 /// * `spender` - The user to whom the rights are granted.1656 /// * `token` - The token to which access is granted.1657 /// * `amount` - The amount of pieces that another user can dispose of.1658 fn approve(1659 &self,1660 sender: T::CrossAccountId,1661 spender: T::CrossAccountId,1662 token: TokenId,1663 amount: u128,1664 ) -> DispatchResultWithPostInfo;16651666 /// Send parts of a token owned by another user.1667 ///1668 /// Before calling this method, you must grant rights to the calling user via [`Self::approve`].1669 ///1670 /// * `sender` - The user who must have access to the token (see [`Self::approve`]).1671 /// * `from` - The user who owns the token.1672 /// * `to` - Recepient user.1673 /// * `token` - The token of which parts are being sent.1674 /// * `amount` - The number of parts of the token that will be transferred.1675 /// * `budget` - The maximum budget that can be spent on the transfer.1676 fn transfer_from(1677 &self,1678 sender: T::CrossAccountId,1679 from: T::CrossAccountId,1680 to: T::CrossAccountId,1681 token: TokenId,1682 amount: u128,1683 budget: &dyn Budget,1684 ) -> DispatchResultWithPostInfo;16851686 /// Burn parts of a token owned by another user.1687 ///1688 /// Before calling this method, you must grant rights to the calling user via [`Self::approve`].1689 ///1690 /// * `sender` - The user who must have access to the token (see [`Self::approve`]).1691 /// * `from` - The user who owns the token.1692 /// * `token` - The token of which parts are being sent.1693 /// * `amount` - The number of parts of the token that will be transferred.1694 /// * `budget` - The maximum budget that can be spent on the burn.1695 fn burn_from(1696 &self,1697 sender: T::CrossAccountId,1698 from: T::CrossAccountId,1699 token: TokenId,1700 amount: u128,1701 budget: &dyn Budget,1702 ) -> DispatchResultWithPostInfo;17031704 /// Check permission to nest token.1705 ///1706 /// * `sender` - The user who initiated the check.1707 /// * `from` - The token that is checked for embedding.1708 /// * `under` - Token under which to check.1709 /// * `budget` - The maximum budget that can be spent on the check.1710 fn check_nesting(1711 &self,1712 sender: T::CrossAccountId,1713 from: (CollectionId, TokenId),1714 under: TokenId,1715 budget: &dyn Budget,1716 ) -> DispatchResult;17171718 /// Nest one token into another.1719 ///1720 /// * `under` - Token holder.1721 /// * `to_nest` - Nested token.1722 fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId));17231724 /// Unnest token.1725 ///1726 /// * `under` - Token holder.1727 /// * `to_nest` - Token to unnest.1728 fn unnest(&self, under: TokenId, to_nest: (CollectionId, TokenId));17291730 /// Get all user tokens.1731 ///1732 /// * `account` - Account for which you need to get tokens.1733 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId>;17341735 /// Get all the tokens in the collection.1736 fn collection_tokens(&self) -> Vec<TokenId>;17371738 /// Check if the token exists.1739 ///1740 /// * `token` - Id token to check.1741 fn token_exists(&self, token: TokenId) -> bool;17421743 /// Get the id of the last minted token.1744 fn last_token_id(&self) -> TokenId;17451746 /// Get the owner of the token.1747 ///1748 /// * `token` - The token for which you need to find out the owner.1749 fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId>;17501751 /// Returns 10 tokens owners in no particular order.1752 ///1753 /// * `token` - The token for which you need to find out the owners.1754 fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId>;17551756 /// Get the value of the token property by key.1757 ///1758 /// * `token` - Token with the property to get.1759 /// * `key` - Property name.1760 fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue>;17611762 /// Get a set of token properties by key vector.1763 ///1764 /// * `token` - Token with the property to get.1765 /// * `keys` - Vector of property keys. If this parameter is [None](sp_std::result::Result),1766 /// then all properties are returned.1767 fn token_properties(&self, token: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property>;17681769 /// Amount of unique collection tokens1770 fn total_supply(&self) -> u32;17711772 /// Amount of different tokens account has.1773 ///1774 /// * `account` - The account for which need to get the balance.1775 fn account_balance(&self, account: T::CrossAccountId) -> u32;17761777 /// Amount of specific token account have.1778 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128;17791780 /// Amount of token pieces1781 fn total_pieces(&self, token: TokenId) -> Option<u128>;17821783 /// Get the number of parts of the token that a trusted user can manage.1784 ///1785 /// * `sender` - Trusted user.1786 /// * `spender` - Owner of the token.1787 /// * `token` - The token for which to get the value.1788 fn allowance(1789 &self,1790 sender: T::CrossAccountId,1791 spender: T::CrossAccountId,1792 token: TokenId,1793 ) -> u128;17941795 /// Get extension for RFT collection.1796 fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>>;1797}17981799/// Extension for RFT collection.1800pub trait RefungibleExtensions<T>1801where1802 T: Config,1803{1804 /// Change the number of parts of the token.1805 ///1806 /// When the value changes down, this function is equivalent to burning parts of the token.1807 ///1808 /// * `sender` - The user calling the repartition operation. Must be the owner of the token.1809 /// * `token` - The token for which you want to change the number of parts.1810 /// * `amount` - The new value of the parts of the token.1811 fn repartition(1812 &self,1813 sender: &T::CrossAccountId,1814 token: TokenId,1815 amount: u128,1816 ) -> DispatchResultWithPostInfo;1817}18181819/// Merge [`DispatchResult`] with [`Weight`] into [`DispatchResultWithPostInfo`].1820///1821/// Used for [`CommonCollectionOperations`] implementations and flexible enough to do so.1822pub fn with_weight(res: DispatchResult, weight: Weight) -> DispatchResultWithPostInfo {1823 let post_info = PostDispatchInfo {1824 actual_weight: Some(weight),1825 pays_fee: Pays::Yes,1826 };1827 match res {1828 Ok(()) => Ok(post_info),1829 Err(error) => Err(DispatchErrorWithPostInfo { post_info, error }),1830 }1831}18321833impl<T: Config> From<PropertiesError> for Error<T> {1834 fn from(error: PropertiesError) -> Self {1835 match error {1836 PropertiesError::NoSpaceForProperty => Self::NoSpaceForProperty,1837 PropertiesError::PropertyLimitReached => Self::PropertyLimitReached,1838 PropertiesError::InvalidCharacterInPropertyKey => Self::InvalidCharacterInPropertyKey,1839 PropertiesError::PropertyKeyIsTooLong => Self::PropertyKeyIsTooLong,1840 PropertiesError::EmptyPropertyKey => Self::EmptyPropertyKey,1841 }1842 }1843}pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -119,8 +119,7 @@
pub enum Error<T> {
/// Not Fungible item data used to mint in Fungible collection.
NotFungibleDataUsedToMintFungibleCollectionToken,
- /// Not default id passed as TokenId argument.
- /// The default value of TokenId for Fungible collection is 0.
+ /// Fungible tokens hold no ID, and the default value of TokenId for Fungible collection is 0.
FungibleItemsHaveNoId,
/// Tried to set data for fungible item.
FungibleItemsDontHaveData,
@@ -157,7 +156,7 @@
QueryKind = ValueQuery,
>;
- /// Storage for delegated assets.
+ /// Storage for assets delegated to a limited extent to other users.
#[pallet::storage]
pub type Allowance<T: Config> = StorageNMap<
Key = (
@@ -172,7 +171,6 @@
/// Wrapper around untyped collection handle, asserting inner collection is of fungible type.
/// Required for interaction with Fungible collections, type safety and implementation [`solidity_interface`][`evm_coder::solidity_interface`].
-
pub struct FungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);
/// Implementation of methods required for dispatching during runtime.
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -21,7 +21,7 @@
//! - [`Config`]
//! - [`NonfungibleHandle`]
//! - [`Pallet`]
-//! - [`CommonWeights`]
+//! - [`CommonWeights`](common::CommonWeights)
//!
//! ## Overview
//!
@@ -130,6 +130,8 @@
pub type CreateItemData<T> = CreateNftExData<<T as pallet_evm::account::Config>::CrossAccountId>;
pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;
+/// Token data, stored independently from other data used to describe it
+/// for the convenience of database access. Notably contains the owner account address.
#[struct_versioning::versioned(version = 2, upper)]
#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]
pub struct ItemData<CrossAccountId> {
@@ -176,17 +178,17 @@
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);
- /// Amount of tokens minted for collection.
+ /// Total amount of minted tokens in a collection.
#[pallet::storage]
pub type TokensMinted<T: Config> =
StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;
- /// Amount of burnt tokens for collection.
+ /// Amount of burnt tokens in a collection.
#[pallet::storage]
pub type TokensBurnt<T: Config> =
StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;
- /// Custom data serialized to bytes for token.
+ /// Token data, used to partially describe a token.
#[pallet::storage]
pub type TokenData<T: Config> = StorageNMap<
Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),
@@ -194,7 +196,7 @@
QueryKind = OptionQuery,
>;
- /// Key-Value map stored for token.
+ /// Map of key-value pairs, describing the metadata of a token.
#[pallet::storage]
#[pallet::getter(fn token_properties)]
pub type TokenProperties<T: Config> = StorageNMap<
@@ -204,7 +206,14 @@
OnEmpty = up_data_structs::TokenProperties,
>;
- /// Custom data that is serialized to bytes and attached to a token property.
+ /// Custom data of a token that is serialized to bytes,
+ /// primarily reserved for on-chain operations,
+ /// normally obscured from the external users.
+ ///
+ /// Auxiliary properties are slightly different from
+ /// usual [`TokenProperties`] due to an unlimited number
+ /// and separately stored and written-to key-value pairs.
+ ///
/// Currently used to store RMRK data.
#[pallet::storage]
#[pallet::getter(fn token_aux_property)]
@@ -244,7 +253,7 @@
QueryKind = ValueQuery,
>;
- /// Amount of tokens owned by account.
+ /// Amount of tokens owned by an account in a collection.
#[pallet::storage]
pub type AccountBalance<T: Config> = StorageNMap<
Key = (
@@ -255,7 +264,7 @@
QueryKind = ValueQuery,
>;
- /// Allowance set by an owner for a spender for a token.
+ /// Allowance set by a token owner for another user to perform one of certain transactions on a token.
#[pallet::storage]
pub type Allowance<T: Config> = StorageNMap<
Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),
@@ -263,6 +272,7 @@
QueryKind = OptionQuery,
>;
+ /// Upgrade from the old schema to properties.
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> Weight {
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -21,7 +21,7 @@
//! - [`Config`]
//! - [`RefungibleHandle`]
//! - [`Pallet`]
-//! - [`CommonWeights`]
+//! - [`CommonWeights`](common::CommonWeights)
//!
//! ## Overview
//!
@@ -119,6 +119,8 @@
pub mod weights;
pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;
+/// Token data, stored independently from other data used to describe it
+/// for the convenience of database access. Notably contains the token metadata.
#[struct_versioning::versioned(version = 2, upper)]
#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen)]
pub struct ItemData {
@@ -143,13 +145,13 @@
pub enum Error<T> {
/// Not Refungible item data used to mint in Refungible collection.
NotRefungibleDataUsedToMintFungibleCollectionToken,
- /// Maximum refungibility exceeded
+ /// Maximum refungibility exceeded.
WrongRefungiblePieces,
- /// Refungible token can't be repartitioned by user who isn't owns all pieces
+ /// Refungible token can't be repartitioned by user who isn't owns all pieces.
RepartitionWhileNotOwningAllPieces,
- /// Refungible token can't nest other tokens
+ /// Refungible token can't nest other tokens.
RefungibleDisallowsNesting,
- /// Setting item properties is not allowed
+ /// Setting item properties is not allowed.
SettingPropertiesNotAllowed,
}
@@ -167,17 +169,17 @@
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);
- /// Amount of tokens minted for collection
+ /// Total amount of minted tokens in a collection.
#[pallet::storage]
pub type TokensMinted<T: Config> =
StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;
- /// Amount of burnt tokens for collection
+ /// Amount of tokens burnt in a collection.
#[pallet::storage]
pub type TokensBurnt<T: Config> =
StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;
- /// Custom data serialized to bytes for token
+ /// Token data, used to partially describe a token.
#[pallet::storage]
pub type TokenData<T: Config> = StorageNMap<
Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),
@@ -185,6 +187,7 @@
QueryKind = ValueQuery,
>;
+ /// Amount of pieces a refungible token is split into.
#[pallet::storage]
#[pallet::getter(fn token_properties)]
pub type TokenProperties<T: Config> = StorageNMap<
@@ -202,7 +205,7 @@
QueryKind = ValueQuery,
>;
- /// Used to enumerate tokens owned by account
+ /// Used to enumerate tokens owned by account.
#[pallet::storage]
pub type Owned<T: Config> = StorageNMap<
Key = (
@@ -214,7 +217,7 @@
QueryKind = ValueQuery,
>;
- /// Amount of tokens owned by account
+ /// Amount of tokens (not pieces) partially owned by an account within a collection.
#[pallet::storage]
pub type AccountBalance<T: Config> = StorageNMap<
Key = (
@@ -226,7 +229,7 @@
QueryKind = ValueQuery,
>;
- /// Amount of token pieces owned by account
+ /// Amount of token pieces owned by account.
#[pallet::storage]
pub type Balance<T: Config> = StorageNMap<
Key = (
@@ -239,7 +242,7 @@
QueryKind = ValueQuery,
>;
- /// Allowance set by an owner for a spender for a token
+ /// Allowance set by a token owner for another user to perform one of certain transactions on a number of pieces of a token.
#[pallet::storage]
pub type Allowance<T: Config> = StorageNMap<
Key = (
pallets/scheduler/src/lib.rsdiffbeforeafterboth--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -24,7 +24,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// <http://www.apache.org/licenses/LICENSE-2.0>
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -50,7 +50,7 @@
//! Also possible to book a call with a certain frequency.
//!
//! Key differences from the original pallet:
-//! https://crates.io/crates/pallet-scheduler
+//! <https://crates.io/crates/pallet-scheduler>
//! Schedule Id restricted by 16 bytes. Identificator for booked call.
//! Priority limited by HARD DEADLINE (<= 63). Calls over maximum weight don't include to block.
//! The maximum weight that may be scheduled per block for any dispatchables of less priority than `schedule::HARD_DEADLINE`.
@@ -267,6 +267,7 @@
/// A Scheduler-Runtime interface for finer payment handling.
pub trait DispatchCall<T: frame_system::Config + Config, SelfContainedSignedInfo> {
+ /// Reserve (lock) the maximum spendings on a call, calculated from its weight and the repetition count.
fn reserve_balance(
id: ScheduledId,
sponsor: <T as frame_system::Config>::AccountId,
@@ -274,7 +275,7 @@
count: u32,
) -> Result<(), DispatchError>;
- /// Unlock centain amount from payer
+ /// Unreserve (unlock) a certain amount from the payer's reserved funds, returning the change.
fn pay_for_call(
id: ScheduledId,
sponsor: <T as frame_system::Config>::AccountId,
@@ -290,6 +291,7 @@
TransactionValidityError,
>;
+ /// Release unspent reserved funds in case of a schedule cancel.
fn cancel_reserve(
id: ScheduledId,
sponsor: <T as frame_system::Config>::AccountId,
@@ -494,9 +496,8 @@
Agenda::<T>::append(wake, Some(s));
}
}
- /// Weight should be 0, because transaction already paid
+ // Total weight should be 0, because the transaction is already paid for
0
- //total_weight
}
}
pallets/structure/src/lib.rsdiffbeforeafterboth--- a/pallets/structure/src/lib.rs
+++ b/pallets/structure/src/lib.rs
@@ -78,19 +78,19 @@
#[pallet::error]
pub enum Error<T> {
- /// While searched for owner, got already checked account
+ /// While nesting, encountered an already checked account, detecting a loop.
OuroborosDetected,
- /// While searched for owner, encountered depth limit
+ /// While nesting, reached the depth limit of nesting, exceeding the provided budget.
DepthLimit,
- /// While iterating over children, encountered breadth limit
+ /// While nesting, reached the breadth limit of nesting, exceeding the provided budget.
BreadthLimit,
- /// While searched for owner, found token owner by not-yet-existing token
+ /// Couldn't find the token owner that is itself a token.
TokenNotFound,
}
#[pallet::event]
pub enum Event<T> {
- /// Executed call on behalf of token
+ /// Executed call on behalf of the token.
Executed(DispatchResult),
}
@@ -126,11 +126,11 @@
#[derive(PartialEq)]
pub enum Parent<CrossAccountId> {
- /// Token owned by normal account
+ /// Token owned by a normal account.
User(CrossAccountId),
- /// Passed token not found
+ /// Could not find the token provided as the owner.
TokenNotFound,
- /// Token owner is another token (target token still may not exist)
+ /// Token owner is another token (still, the target token may not exist).
Token(CollectionId, TokenId),
}
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+//! Implementation of CollectionHelpers contract.
+
use core::marker::PhantomData;
use evm_coder::{execution::*, generate_stubgen, solidity_interface, weight, types::*};
use ethereum as _;
@@ -33,7 +35,8 @@
use sp_std::vec::Vec;
use alloc::format;
-struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);
+/// See [`CollectionHelpersCall`]
+pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);
impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {
fn recorder(&self) -> &SubstrateRecorder<T> {
&self.0
@@ -44,8 +47,14 @@
}
}
+/// @title Contract, which allows users to operate with collections
#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]
impl<T: Config + pallet_nonfungible::Config> EvmCollectionHelpers<T> {
+ /// Create an NFT collection
+ /// @param name Name of the collection
+ /// @param description Informative description of the collection
+ /// @param token_prefix Token prefix to represent the collection tokens in UI and user applications
+ /// @return address Address of the newly created collection
#[weight(<SelfWeightOf<T>>::create_collection())]
fn create_nonfungible_collection(
&mut self,
@@ -100,6 +109,9 @@
Ok(address)
}
+ /// Check if a collection exists
+ /// @param collection_address Address of the collection in question
+ /// @return bool Does the collection exist?
fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {
if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {
let collection_id = id;
@@ -110,6 +122,7 @@
}
}
+/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]
pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);
impl<T: Config + pallet_nonfungible::Config> OnMethodCall<T> for CollectionHelpersOnMethodCall<T> {
fn is_reserved(contract: &sp_core::H160) -> bool {
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -14,6 +14,55 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+//! # Unique Pallet
+//!
+//! A pallet governing Unique transactions.
+//!
+//! - [`Config`]
+//! - [`Call`]
+//! - [`Pallet`]
+//!
+//! ## Overview
+//!
+//! The Unique pallet's purpose is to be the primary interface between
+//! external users and the inner structure of the Unique chains.
+//!
+//! It also contains an implementation of [`CollectionHelpers`][`eth`],
+//! an Ethereum contract dealing with collection operations.
+//!
+//! ## Interface
+//!
+//! ### Dispatchables
+//!
+//! - `create_collection` - Create a collection of tokens. **Deprecated**, use `create_collection_ex`.
+//! - `create_collection_ex` - Create a collection of tokens with explicit parameters.
+//! - `destroy_collection` - Destroy a collection if no tokens exist within.
+//! - `add_to_allow_list` - Add an address to allow list.
+//! - `remove_from_allow_list` - Remove an address from allow list.
+//! - `change_collection_owner` - Change the owner of the collection.
+//! - `add_collection_admin` - Add an admin to a collection.
+//! - `remove_collection_admin` - Remove admin of a collection.
+//! - `set_collection_sponsor` - Invite a new collection sponsor.
+//! - `confirm_sponsorship` - Confirm own sponsorship of a collection, becoming the sponsor.
+//! - `remove_collection_sponsor` - Remove a sponsor from a collection.
+//! - `create_item` - Create an item within a collection.
+//! - `create_multiple_items` - Create multiple items within a collection.
+//! - `set_collection_properties` - Add or change collection properties.
+//! - `delete_collection_properties` - Delete specified collection properties.
+//! - `set_token_properties` - Add or change token properties.
+//! - `delete_token_properties` - Delete token properties.
+//! - `set_token_property_permissions` - Add or change token property permissions of a collection.
+//! - `create_multiple_items_ex` - Create multiple items within a collection with explicitly specified initial parameters.
+//! - `set_transfers_enabled_flag` - Completely allow or disallow transfers for a particular collection.
+//! - `burn_item` - Destroy an item.
+//! - `burn_from` - Destroy an item on behalf of the owner as a non-owner account.
+//! - `transfer` - Change ownership of the token.
+//! - `transfer_from` - Change ownership of the token on behalf of the owner as a non-owner account.
+//! - `approve` - Allow a non-permissioned address to transfer or burn an item.
+//! - `set_collection_limits` - Set specific limits of a collection.
+//! - `set_collection_permissions` - Set specific permissions of a collection.
+//! - `repartition` - Re-partition a refungible token, while owning all of its parts.
+
#![recursion_limit = "1024"]
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(
@@ -54,28 +103,35 @@
pub mod weights;
use weights::WeightInfo;
-const NESTING_BUDGET: u32 = 5;
+/// Maximum number of levels of depth in the token nesting tree.
+pub const NESTING_BUDGET: u32 = 5;
decl_error! {
- /// Error for non-fungible-token module.
+ /// Errors for the common Unique transactions.
pub enum Error for Module<T: Config> {
- /// Decimal_points parameter must be lower than MAX_DECIMAL_POINTS constant, currently it is 30.
+ /// Decimal_points parameter must be lower than [`up_data_structs::MAX_DECIMAL_POINTS`].
CollectionDecimalPointLimitExceeded,
/// This address is not set as sponsor, use setCollectionSponsor first.
ConfirmUnsetSponsorFail,
/// Length of items properties must be greater than 0.
EmptyArgument,
- /// Repertition is only supported by refungible collection
+ /// Repertition is only supported by refungible collection.
RepartitionCalledOnNonRefungibleCollection,
}
}
+/// Configuration trait of this pallet.
pub trait Config: system::Config + pallet_common::Config + Sized + TypeInfo {
+ /// Overarching event type.
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
+
+ /// Weight information for common pallet operations.
type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;
+
+ /// Weight info information for extra refungible pallet operations.
type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;
}
@@ -88,80 +144,68 @@
/// Collection sponsor was removed
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
+ /// * collection_id: ID of the affected collection.
CollectionSponsorRemoved(CollectionId),
/// Collection admin was added
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
- ///
- /// * admin: Admin address.
+ /// * collection_id: ID of the affected collection.
+ /// * admin: Admin address.
CollectionAdminAdded(CollectionId, CrossAccountId),
- /// Collection owned was change
+ /// Collection owned was changed
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
- ///
- /// * owner: New owner address.
+ /// * collection_id: ID of the affected collection.
+ /// * owner: New owner address.
CollectionOwnedChanged(CollectionId, AccountId),
/// Collection sponsor was set
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
- ///
- /// * owner: New sponsor address.
+ /// * collection_id: ID of the affected collection.
+ /// * owner: New sponsor address.
CollectionSponsorSet(CollectionId, AccountId),
/// New sponsor was confirm
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
- ///
- /// * sponsor: New sponsor address.
+ /// * collection_id: ID of the affected collection.
+ /// * sponsor: New sponsor address.
SponsorshipConfirmed(CollectionId, AccountId),
/// Collection admin was removed
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
- ///
- /// * admin: Admin address.
+ /// * collection_id: ID of the affected collection.
+ /// * admin: Removed admin address.
CollectionAdminRemoved(CollectionId, CrossAccountId),
- /// Address was remove from allow list
+ /// Address was removed from the allow list
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
- ///
- /// * user: Address.
+ /// * collection_id: ID of the affected collection.
+ /// * user: Address of the removed account.
AllowListAddressRemoved(CollectionId, CrossAccountId),
- /// Address was add to allow list
+ /// Address was added to the allow list
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
- ///
- /// * user: Address.
+ /// * collection_id: ID of the affected collection.
+ /// * user: Address of the added account.
AllowListAddressAdded(CollectionId, CrossAccountId),
- /// Collection limits was set
+ /// Collection limits were set
///
/// # Arguments
- ///
- /// * collection_id: Globally unique collection identifier.
+ /// * collection_id: ID of the affected collection.
CollectionLimitSet(CollectionId),
+ /// Collection permissions were set
+ ///
+ /// # Arguments
+ /// * collection_id: ID of the affected collection.
CollectionPermissionSet(CollectionId),
}
}
@@ -198,7 +242,7 @@
ChainVersion: u64;
//#endregion
- //#region Tokens transfer rate limit baskets
+ //#region Tokens transfer sponosoring rate limit baskets
/// (Collection id (controlled?2), who created (real))
/// TODO: Off chain worker should remove from this map when collection gets removed
pub CreateItemBasket get(fn create_item_basket): map hasher(blake2_128_concat) (CollectionId, T::AccountId) => Option<T::BlockNumber>;
@@ -214,16 +258,20 @@
/// Collection id (controlled?2), token id (controlled?2)
#[deprecated]
pub VariableMetaDataBasket get(fn variable_meta_data_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;
+ /// Last sponsoring of token property setting // todo:doc rephrase this and the following
pub TokenPropertyBasket get(fn token_property_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;
- /// Approval sponsoring
+ /// Last sponsoring of NFT approval in a collection
pub NftApproveBasket get(fn nft_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;
+ /// Last sponsoring of fungible tokens approval in a collection
pub FungibleApproveBasket get(fn fungible_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;
+ /// Last sponsoring of RFT approval in a collection
pub RefungibleApproveBasket get(fn refungible_approve_basket): nmap hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;
}
}
decl_module! {
+ /// Type alias to Pallet, to be used by construct_runtime.
pub struct Module<T: Config> for enum Call
where
origin: T::Origin
@@ -244,30 +292,38 @@
0
}
- /// 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.
- ///
- /// # Permissions
+ /// Create a collection of tokens.
///
- /// * Anyone.
+ /// 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.
///
- /// # Arguments
+ /// Prefer the more advanced [`create_collection_ex`][`Pallet::create_collection_ex`] instead.
///
- /// * collection_name: UTF-16 string with collection name (limit 64 characters), will be stored as zero-terminated.
+ /// # Permissions
///
- /// * collection_description: UTF-16 string with collection description (limit 256 characters), will be stored as zero-terminated.
+ /// * Anyone - becomes the owner of the new collection.
///
- /// * token_prefix: UTF-8 string with token prefix.
+ /// # Arguments
///
- /// * mode: [CollectionMode] collection type and type dependent data.
+ /// * `collection_name`: Wide-character string with collection name
+ /// (limit [`MAX_COLLECTION_NAME_LENGTH`]).
+ /// * `collection_description`: Wide-character string with collection description
+ /// (limit [`MAX_COLLECTION_DESCRIPTION_LENGTH`]).
+ /// * `token_prefix`: Byte string containing the token prefix to mark a collection
+ /// to which a token belongs (limit [`MAX_TOKEN_PREFIX_LENGTH`]).
+ /// * `mode`: Type of items stored in the collection and type dependent data.
// returns collection ID
#[weight = <SelfWeightOf<T>>::create_collection()]
#[transactional]
- #[deprecated]
- pub fn create_collection(origin,
- collection_name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,
- collection_description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,
- token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,
- mode: CollectionMode) -> DispatchResult {
+ #[deprecated(note = "`create_collection_ex` is more up-to-date and advanced, prefer it instead")]
+ pub fn create_collection(
+ origin,
+ collection_name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,
+ collection_description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,
+ token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,
+ mode: CollectionMode
+ ) -> DispatchResult {
let data: CreateCollectionData<T::AccountId> = CreateCollectionData {
name: collection_name,
description: collection_description,
@@ -278,9 +334,17 @@
Self::create_collection_ex(origin, data)
}
- /// This method creates a collection
+ /// Create a collection with explicit parameters.
+ ///
+ /// Prefer it to the deprecated [`create_collection`][`Pallet::create_collection`] method.
+ ///
+ /// # Permissions
+ ///
+ /// * Anyone - becomes the owner of the new collection.
///
- /// Prefer it to deprecated [`created_collection`] method
+ /// # Arguments
+ ///
+ /// * `data`: Explicit data of a collection used for its creation.
#[weight = <SelfWeightOf<T>>::create_collection()]
#[transactional]
pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {
@@ -293,15 +357,15 @@
Ok(())
}
- /// Destroys collection if no tokens within this collection
+ /// Destroy a collection if no tokens exist within.
///
/// # Permissions
///
- /// * Collection Owner.
+ /// * Collection owner
///
/// # Arguments
///
- /// * collection_id: collection to destroy.
+ /// * `collection_id`: Collection to destroy.
#[weight = <SelfWeightOf<T>>::destroy_collection()]
#[transactional]
pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {
@@ -328,14 +392,13 @@
///
/// # Permissions
///
- /// * Collection Owner
- /// * Collection Admin
+ /// * Collection owner
+ /// * Collection admin
///
/// # Arguments
///
- /// * collection_id.
- ///
- /// * address.
+ /// * `collection_id`: ID of the modified collection.
+ /// * `address`: ID of the address to be added to the allowlist.
#[weight = <SelfWeightOf<T>>::add_to_allow_list()]
#[transactional]
pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
@@ -363,14 +426,13 @@
///
/// # Permissions
///
- /// * Collection Owner
- /// * Collection Admin
+ /// * Collection owner
+ /// * Collection admin
///
/// # Arguments
///
- /// * collection_id.
- ///
- /// * address.
+ /// * `collection_id`: ID of the modified collection.
+ /// * `address`: ID of the address to be removed from the allowlist.
#[weight = <SelfWeightOf<T>>::remove_from_allow_list()]
#[transactional]
pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
@@ -398,13 +460,12 @@
///
/// # Permissions
///
- /// * Collection Owner.
+ /// * Collection owner
///
/// # Arguments
///
- /// * collection_id.
- ///
- /// * new_owner.
+ /// * `collection_id`: ID of the modified collection.
+ /// * `new_owner`: ID of the account that will become the owner.
#[weight = <SelfWeightOf<T>>::change_collection_owner()]
#[transactional]
pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {
@@ -424,46 +485,51 @@
target_collection.save()
}
- /// Adds an admin of the Collection.
- /// 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.
+ /// Add an admin to a collection.
///
+ /// 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.
+ ///
/// # Permissions
///
- /// * Collection Owner.
- /// * Collection Admin.
+ /// * Collection owner
+ /// * Collection admin
///
/// # Arguments
///
- /// * collection_id: ID of the Collection to add admin for.
- ///
- /// * new_admin_id: Address of new admin to add.
+ /// * `collection_id`: ID of the Collection to add an admin for.
+ /// * `new_admin`: Address of new admin to add.
#[weight = <SelfWeightOf<T>>::add_collection_admin()]
#[transactional]
- pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::CrossAccountId) -> DispatchResult {
+ pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin: T::CrossAccountId) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let collection = <CollectionHandle<T>>::try_get(collection_id)?;
collection.check_is_internal()?;
<Pallet<T>>::deposit_event(Event::<T>::CollectionAdminAdded(
collection_id,
- new_admin_id.clone()
+ new_admin.clone()
));
- <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)
+ <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin, true)
}
- /// 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.
+ /// Remove admin of a 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.
///
/// # Permissions
///
- /// * Collection Owner.
- /// * Collection Admin.
+ /// * Collection owner
+ /// * Collection admin
///
/// # Arguments
///
- /// * collection_id: ID of the Collection to remove admin for.
- ///
- /// * account_id: Address of admin to remove.
+ /// * `collection_id`: ID of the collection to remove the admin for.
+ /// * `account_id`: Address of the admin to remove.
#[weight = <SelfWeightOf<T>>::remove_collection_admin()]
#[transactional]
pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {
@@ -479,15 +545,19 @@
<PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)
}
+ /// Set (invite) a new collection sponsor.
+ ///
+ /// If successful, confirmation from the sponsor-to-be will be pending.
+ ///
/// # Permissions
///
- /// * Collection Owner
+ /// * Collection owner
+ /// * Collection admin
///
/// # Arguments
///
- /// * collection_id.
- ///
- /// * new_sponsor.
+ /// * `collection_id`: ID of the modified collection.
+ /// * `new_sponsor`: ID of the account of the sponsor-to-be.
#[weight = <SelfWeightOf<T>>::set_collection_sponsor()]
#[transactional]
pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {
@@ -507,13 +577,19 @@
target_collection.save()
}
+ /// Confirm own sponsorship of a collection, becoming the sponsor.
+ ///
+ /// An invitation must be pending, see [`set_collection_sponsor`][`Pallet::set_collection_sponsor`].
+ /// Sponsor can pay the fees of a transaction instead of the sender,
+ /// but only within specified limits.
+ ///
/// # Permissions
///
- /// * Sponsor.
+ /// * Sponsor-to-be
///
/// # Arguments
///
- /// * collection_id.
+ /// * `collection_id`: ID of the collection with the pending sponsor.
#[weight = <SelfWeightOf<T>>::confirm_sponsorship()]
#[transactional]
pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {
@@ -534,15 +610,15 @@
target_collection.save()
}
- /// Switch back to pay-per-own-transaction model.
+ /// Remove a collection's a sponsor, making everyone pay for their own transactions.
///
/// # Permissions
///
- /// * Collection owner.
+ /// * Collection owner
///
/// # Arguments
///
- /// * collection_id.
+ /// * `collection_id`: ID of the collection with the sponsor to remove.
#[weight = <SelfWeightOf<T>>::remove_collection_sponsor()]
#[transactional]
pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {
@@ -560,24 +636,24 @@
target_collection.save()
}
- /// This method creates a concrete instance of NFT Collection created with CreateCollection method.
+ /// Mint an item within a collection.
+ ///
+ /// A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].
///
/// # Permissions
///
- /// * Collection Owner.
- /// * Collection Admin.
+ /// * Collection owner
+ /// * Collection admin
/// * Anyone if
/// * Allow List is enabled, and
/// * Address is added to allow list, and
- /// * MintPermission is enabled (see SetMintPermission method)
+ /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])
///
/// # Arguments
- ///
- /// * collection_id: ID of the collection.
///
- /// * owner: Address, initial owner of the NFT.
- ///
- /// * data: Token data to store on chain.
+ /// * `collection_id`: ID of the collection to which an item would belong.
+ /// * `owner`: Address of the initial owner of the item.
+ /// * `data`: Token data describing the item to store on chain.
#[weight = T::CommonWeightInfo::create_item()]
#[transactional]
pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {
@@ -587,24 +663,24 @@
dispatch_tx::<T, _>(collection_id, |d| d.create_item(sender, owner, data, &budget))
}
- /// This method creates multiple items in a collection created with CreateCollection method.
+ /// Create multiple items within a collection.
///
+ /// A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].
+ ///
/// # Permissions
///
- /// * Collection Owner.
- /// * Collection Admin.
+ /// * Collection owner
+ /// * Collection admin
/// * Anyone if
/// * Allow List is enabled, and
- /// * Address is added to allow list, and
- /// * MintPermission is enabled (see SetMintPermission method)
+ /// * Address is added to the allow list, and
+ /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])
///
/// # Arguments
///
- /// * collection_id: ID of the collection.
- ///
- /// * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].
- ///
- /// * owner: Address, initial owner of the NFT.
+ /// * `collection_id`: ID of the collection to which the tokens would belong.
+ /// * `owner`: Address of the initial owner of the tokens.
+ /// * `items_data`: Vector of data describing each item to be created.
#[weight = T::CommonWeightInfo::create_multiple_items(&items_data)]
#[transactional]
pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {
@@ -615,6 +691,18 @@
dispatch_tx::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))
}
+ /// Add or change collection properties.
+ ///
+ /// # Permissions
+ ///
+ /// * Collection owner
+ /// * Collection admin
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the modified collection.
+ /// * `properties`: Vector of key-value pairs stored as the collection's metadata.
+ /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[weight = T::CommonWeightInfo::set_collection_properties(properties.len() as u32)]
#[transactional]
pub fn set_collection_properties(
@@ -629,6 +717,18 @@
dispatch_tx::<T, _>(collection_id, |d| d.set_collection_properties(sender, properties))
}
+ /// Delete specified collection properties.
+ ///
+ /// # Permissions
+ ///
+ /// * Collection Owner
+ /// * Collection Admin
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the modified collection.
+ /// * `property_keys`: Vector of keys of the properties to be deleted.
+ /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]
#[transactional]
pub fn delete_collection_properties(
@@ -643,6 +743,24 @@
dispatch_tx::<T, _>(collection_id, |d| d.delete_collection_properties(&sender, property_keys))
}
+ /// Add or change token properties according to collection's permissions.
+ /// Currently properties only work with NFTs.
+ ///
+ /// # Permissions
+ ///
+ /// * Depends on collection's token property permissions and specified property mutability:
+ /// * Collection owner
+ /// * Collection admin
+ /// * Token owner
+ ///
+ /// See [`set_token_property_permissions`][`Pallet::set_token_property_permissions`].
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id: ID of the collection to which the token belongs.
+ /// * `token_id`: ID of the modified token.
+ /// * `properties`: Vector of key-value pairs stored as the token's metadata.
+ /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]
#[transactional]
pub fn set_token_properties(
@@ -659,6 +777,21 @@
dispatch_tx::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties, &budget))
}
+ /// Delete specified token properties. Currently properties only work with NFTs.
+ ///
+ /// # Permissions
+ ///
+ /// * Depends on collection's token property permissions and specified property mutability:
+ /// * Collection owner
+ /// * Collection admin
+ /// * Token owner
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the collection to which the token belongs.
+ /// * `token_id`: ID of the modified token.
+ /// * `property_keys`: Vector of keys of the properties to be deleted.
+ /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]
#[transactional]
pub fn delete_token_properties(
@@ -675,6 +808,21 @@
dispatch_tx::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, property_keys, &budget))
}
+ /// Add or change token property permissions of a collection.
+ ///
+ /// Without a permission for a particular key, a property with that key
+ /// cannot be created in a token.
+ ///
+ /// # Permissions
+ ///
+ /// * Collection owner
+ /// * Collection admin
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the modified collection.
+ /// * `property_permissions`: Vector of permissions for property keys.
+ /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[weight = T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32)]
#[transactional]
pub fn set_token_property_permissions(
@@ -689,6 +837,21 @@
dispatch_tx::<T, _>(collection_id, |d| d.set_token_property_permissions(&sender, property_permissions))
}
+ /// Create multiple items within a collection with explicitly specified initial parameters.
+ ///
+ /// # Permissions
+ ///
+ /// * Collection owner
+ /// * Collection admin
+ /// * Anyone if
+ /// * Allow List is enabled, and
+ /// * Address is added to allow list, and
+ /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the collection to which the tokens would belong.
+ /// * `data`: Explicit item creation data.
#[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]
#[transactional]
pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {
@@ -698,17 +861,16 @@
dispatch_tx::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data, &budget))
}
- /// Set transfers_enabled value for particular collection
+ /// Completely allow or disallow transfers for a particular collection.
///
/// # Permissions
///
- /// * Collection Owner.
+ /// * Collection owner
///
/// # Arguments
///
- /// * collection_id: ID of the collection.
- ///
- /// * value: New flag value.
+ /// * `collection_id`: ID of the collection.
+ /// * `value`: New value of the flag, are transfers allowed?
#[weight = <SelfWeightOf<T>>::set_transfers_enabled_flag()]
#[transactional]
pub fn set_transfers_enabled_flag(origin, collection_id: CollectionId, value: bool) -> DispatchResult {
@@ -723,19 +885,22 @@
target_collection.save()
}
- /// Destroys a concrete instance of NFT.
+ /// Destroy an item.
///
/// # Permissions
///
- /// * Collection Owner.
- /// * Collection Admin.
- /// * Current NFT Owner.
+ /// * Collection owner
+ /// * Collection admin
+ /// * Current item owner
///
/// # Arguments
///
- /// * collection_id: ID of the collection.
- ///
- /// * item_id: ID of NFT to burn.
+ /// * `collection_id`: ID of the collection to which the item belongs.
+ /// * `item_id`: ID of item to burn.
+ /// * `value`: Number of pieces of the item to destroy.
+ /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.
+ /// * Fungible Mode: The desired number of pieces to burn.
+ /// * Re-Fungible Mode: The desired number of pieces to burn.
#[weight = T::CommonWeightInfo::burn_item()]
#[transactional]
pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
@@ -752,22 +917,29 @@
Ok(post_info)
}
- /// Destroys a concrete instance of NFT on behalf of the owner
- /// See also: [`approve`]
+ /// Destroy a token on behalf of the owner as a non-owner account.
+ ///
+ /// See also: [`approve`][`Pallet::approve`].
+ ///
+ /// After this method executes, one approval is removed from the total so that
+ /// the approved address will not be able to transfer this item again from this owner.
///
/// # Permissions
///
- /// * Collection Owner.
- /// * Collection Admin.
- /// * Current NFT Owner.
+ /// * Collection owner
+ /// * Collection admin
+ /// * Current token owner
+ /// * Address approved by current item owner
///
/// # Arguments
///
- /// * collection_id: ID of the collection.
- ///
- /// * item_id: ID of NFT to burn.
- ///
- /// * from: owner of item
+ /// * `from`: The owner of the burning item.
+ /// * `collection_id`: ID of the collection to which the item belongs.
+ /// * `item_id`: ID of item to burn.
+ /// * `value`: Number of pieces to burn.
+ /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.
+ /// * Fungible Mode: The desired number of pieces to burn.
+ /// * Re-Fungible Mode: The desired number of pieces to burn.
#[weight = T::CommonWeightInfo::burn_from()]
#[transactional]
pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
@@ -781,25 +953,23 @@
///
/// # Permissions
///
- /// * Collection Owner
- /// * Collection Admin
- /// * Current NFT owner
+ /// * Collection owner
+ /// * Collection admin
+ /// * Current token owner
///
/// # Arguments
- ///
- /// * recipient: Address of token recipient.
///
- /// * collection_id.
- ///
- /// * item_id: ID of the item
+ /// * `recipient`: Address of token recipient.
+ /// * `collection_id`: ID of the collection the item belongs to.
+ /// * `item_id`: ID of the item.
/// * Non-Fungible Mode: Required.
/// * Fungible Mode: Ignored.
/// * Re-Fungible Mode: Required.
///
- /// * value: Amount to transfer.
- /// * Non-Fungible Mode: Ignored
- /// * Fungible Mode: Must specify transferred amount
- /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)
+ /// * `value`: Amount to transfer.
+ /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.
+ /// * Fungible Mode: The desired number of pieces to transfer.
+ /// * Re-Fungible Mode: The desired number of pieces to transfer.
#[weight = T::CommonWeightInfo::transfer()]
#[transactional]
pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
@@ -809,21 +979,21 @@
dispatch_tx::<T, _>(collection_id, |d| d.transfer(sender, recipient, item_id, value, &budget))
}
- /// Set, change, or remove approved address to transfer the ownership of the NFT.
+ /// Allow a non-permissioned address to transfer or burn an item.
///
/// # Permissions
///
- /// * Collection Owner
- /// * Collection Admin
- /// * Current NFT owner
+ /// * Collection owner
+ /// * Collection admin
+ /// * Current item owner
///
/// # Arguments
///
- /// * approved: Address that is approved to transfer this NFT or zero (if needed to remove approval).
- ///
- /// * collection_id.
- ///
- /// * item_id: ID of the item.
+ /// * `spender`: Account to be approved to make specific transactions on non-owned tokens.
+ /// * `collection_id`: ID of the collection the item belongs to.
+ /// * `item_id`: ID of the item transactions on which are now approved.
+ /// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).
+ /// Set to 0 to revoke the approval.
#[weight = T::CommonWeightInfo::approve()]
#[transactional]
pub fn approve(origin, spender: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResultWithPostInfo {
@@ -832,25 +1002,30 @@
dispatch_tx::<T, _>(collection_id, |d| d.approve(sender, spender, item_id, amount))
}
- /// 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.
+ /// Change ownership of an item on behalf of the owner as a non-owner account.
///
- /// # Permissions
- /// * Collection Owner
- /// * Collection Admin
- /// * Current NFT owner
- /// * Address approved by current NFT owner
+ /// See the [`approve`][`Pallet::approve`] method for additional information.
///
- /// # Arguments
+ /// After this method executes, one approval is removed from the total so that
+ /// the approved address will not be able to transfer this item again from this owner.
///
- /// * from: Address that owns token.
+ /// # Permissions
///
- /// * recipient: Address of token recipient.
+ /// * Collection owner
+ /// * Collection admin
+ /// * Current item owner
+ /// * Address approved by current item owner
///
- /// * collection_id.
+ /// # Arguments
///
- /// * item_id: ID of the item.
- ///
- /// * value: Amount to transfer.
+ /// * `from`: Address that currently owns the token.
+ /// * `recipient`: Address of the new token-owner-to-be.
+ /// * `collection_id`: ID of the collection the item.
+ /// * `item_id`: ID of the item to be transferred.
+ /// * `value`: Amount to transfer.
+ /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.
+ /// * Fungible Mode: The desired number of pieces to transfer.
+ /// * Re-Fungible Mode: The desired number of pieces to transfer.
#[weight = T::CommonWeightInfo::transfer_from()]
#[transactional]
pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {
@@ -860,6 +1035,18 @@
dispatch_tx::<T, _>(collection_id, |d| d.transfer_from(sender, from, recipient, item_id, value, &budget))
}
+ /// Set specific limits of a collection. Empty, or None fields mean chain default.
+ ///
+ /// # Permissions
+ ///
+ /// * Collection owner
+ /// * Collection admin
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the modified collection.
+ /// * `new_limit`: New limits of the collection. Fields that are not set (None)
+ /// will not overwrite the old ones.
#[weight = <SelfWeightOf<T>>::set_collection_limits()]
#[transactional]
pub fn set_collection_limits(
@@ -882,12 +1069,24 @@
target_collection.save()
}
+ /// Set specific permissions of a collection. Empty, or None fields mean chain default.
+ ///
+ /// # Permissions
+ ///
+ /// * Collection owner
+ /// * Collection admin
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the modified collection.
+ /// * `new_permission`: New permissions of the collection. Fields that are not set (None)
+ /// will not overwrite the old ones.
#[weight = <SelfWeightOf<T>>::set_collection_limits()]
#[transactional]
pub fn set_collection_permissions(
origin,
collection_id: CollectionId,
- new_limit: CollectionPermissions,
+ new_permission: CollectionPermissions,
) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
@@ -895,7 +1094,7 @@
target_collection.check_is_owner_or_admin(&sender)?;
let old_limit = &target_collection.permissions;
- target_collection.permissions = <PalletCommon<T>>::clamp_permissions(target_collection.mode.clone(), &old_limit, new_limit)?;
+ target_collection.permissions = <PalletCommon<T>>::clamp_permissions(target_collection.mode.clone(), &old_limit, new_permission)?;
<Pallet<T>>::deposit_event(Event::<T>::CollectionPermissionSet(
collection_id
@@ -904,18 +1103,29 @@
target_collection.save()
}
+ /// Re-partition a refungible token, while owning all of its parts/pieces.
+ ///
+ /// # Permissions
+ ///
+ /// * Token owner (must own every part)
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the collection the RFT belongs to.
+ /// * `token_id`: ID of the RFT.
+ /// * `amount`: New number of parts/pieces into which the token shall be partitioned.
#[weight = T::RefungibleExtensionsWeightInfo::repartition()]
#[transactional]
pub fn repartition(
origin,
collection_id: CollectionId,
- token: TokenId,
+ token_id: TokenId,
amount: u128,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
dispatch_tx::<T, _>(collection_id, |d| {
if let Some(refungible_extensions) = d.refungible_extensions() {
- refungible_extensions.repartition(&sender, token, amount)
+ refungible_extensions.repartition(&sender, token_id, amount)
} else {
fail!(<Error<T>>::RepartitionCalledOnNonRefungibleCollection)
}
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -197,7 +197,6 @@
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub enum CollectionMode {
NFT,
- // decimal points
Fungible(DecimalPoints),
ReFungible,
}
@@ -252,12 +251,14 @@
pub enum SponsorshipState<AccountId> {
/// The fees are applied to the transaction sender
Disabled,
+ /// Pending confirmation from a sponsor-to-be
Unconfirmed(AccountId),
/// Transactions are sponsored by specified account
Confirmed(AccountId),
}
impl<AccountId> SponsorshipState<AccountId> {
+ /// Get the acting sponsor account, if present
pub fn sponsor(&self) -> Option<&AccountId> {
match self {
Self::Confirmed(sponsor) => Some(sponsor),
@@ -265,6 +266,7 @@
}
}
+ /// Get the sponsor account currently pending confirmation, if present
pub fn pending_sponsor(&self) -> Option<&AccountId> {
match self {
Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),
@@ -272,6 +274,7 @@
}
}
+ /// Is sponsorship set and acting
pub fn confirmed(&self) -> bool {
matches!(self, Self::Confirmed(_))
}
@@ -283,7 +286,7 @@
}
}
-/// Used in storage
+/// Collection parameters, used in storage (see [`RpcCollection`] for the RPC version).
#[struct_versioning::versioned(version = 2, upper)]
#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
pub struct Collection<AccountId> {
@@ -324,7 +327,7 @@
pub meta_update_permission: MetaUpdatePermission,
}
-/// Used in RPC calls
+/// Collection parameters, used in RPC calls (see [`Collection`] for the storage version).
#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct RpcCollection<AccountId> {
@@ -362,26 +365,41 @@
pub type CollectionPropertiesVec = BoundedVec<Property, ConstU32<MAX_PROPERTIES_PER_ITEM>>;
-/// All fields are wrapped in `Option`s, where None means chain default
-// When adding/removing fields from this struct - don't forget to also update clamp_limits
+/// Limits and restrictions of a collection.
+/// All fields are wrapped in `Option`s, where None means chain default.
+///
+/// todo:doc links to chain defaults
+// IMPORTANT: When adding/removing fields from this struct - don't forget to also
+// update clamp_limits() in pallet-common.
#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct CollectionLimits {
+ /// Maximum number of owned tokens per account. Chain default: [`ACCOUNT_TOKEN_OWNERSHIP_LIMIT`]
pub account_token_ownership_limit: Option<u32>,
+ /// Maximum size of data in bytes of a sponsored transaction. Chain default: [`CUSTOM_DATA_LIMIT`]
pub sponsored_data_size: Option<u32>,
/// FIXME should we delete this or repurpose it?
/// None - setVariableMetadata is not sponsored
/// Some(v) - setVariableMetadata is sponsored
/// if there is v block between txs
+ ///
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,
+ /// Maximum amount of tokens inside the collection. Chain default: [`COLLECTION_TOKEN_LIMIT`]
pub token_limit: Option<u32>,
- // Timeouts for item types in passed blocks
+ /// Timeout for sponsoring a token transfer in passed blocks. Chain default:
+ /// either [`NFT_SPONSOR_TRANSFER_TIMEOUT`], [`FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT`], or [`REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT`],
+ /// depending on the collection type.
pub sponsor_transfer_timeout: Option<u32>,
+ /// Timeout for sponsoring an approval in passed blocks. Chain default: [`SPONSOR_APPROVE_TIMEOUT`]
pub sponsor_approve_timeout: Option<u32>,
+ /// Can a token be transferred by the owner. Chain default: `false`
pub owner_can_transfer: Option<bool>,
+ /// Can a token be burned by the owner. Chain default: `true`
pub owner_can_destroy: Option<bool>,
+ /// Can a token be transferred at all. Chain default: `true`
pub transfers_enabled: Option<bool>,
}
@@ -434,7 +452,10 @@
}
}
-// When adding/removing fields from this struct - don't forget to also update clamp_limits
+/// Permissions on certain operations within a collection.
+/// All fields are wrapped in `Option`s, where None means chain default.
+// IMPORTANT: When adding/removing fields from this struct - don't forget to also
+// update clamp_limits() in pallet-common.
#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct CollectionPermissions {
@@ -489,6 +510,7 @@
}
}
+/// Part of collection permissions, if set, defines who is able to nest tokens into other tokens.
#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen, Derivative)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[derivative(Debug)]
@@ -505,38 +527,49 @@
pub permissive: bool,
}
+/// Enum denominating how often can sponsoring occur if it is enabled.
#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub enum SponsoringRateLimit {
+ /// Sponsoring is disabled, and the collection sponsor will not pay for transactions
SponsoringDisabled,
+ /// Once per how many blocks can sponsorship of a transaction type occur
Blocks(u32),
}
+/// Data used to describe an NFT at creation.
#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[derivative(Debug)]
pub struct CreateNftData {
+ /// Key-value pairs used to describe the token as metadata
#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
#[derivative(Debug(format_with = "bounded::vec_debug"))]
pub properties: CollectionPropertiesVec,
}
+/// Data used to describe a Fungible token at creation.
#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct CreateFungibleData {
+ /// Number of fungible coins minted
pub value: u128,
}
+/// Data used to describe a Refungible token at creation.
#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[derivative(Debug)]
pub struct CreateReFungibleData {
+ /// Immutable metadata of the token
#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
#[derivative(Debug(format_with = "bounded::vec_debug"))]
pub const_data: BoundedVec<u8, CustomDataLimit>,
+ /// Number of pieces the RFT is split into
pub pieces: u128,
+ /// Key-value pairs used to describe the token as metadata
#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
#[derivative(Debug(format_with = "bounded::vec_debug"))]
pub properties: CollectionPropertiesVec,
@@ -550,6 +583,7 @@
None,
}
+/// Enum holding data used for creation of all three item types.
#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub enum CreateItemData {
@@ -558,6 +592,7 @@
ReFungible(CreateReFungibleData),
}
+/// Explicit NFT creation data with meta parameters.
#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]
#[derivative(Debug)]
pub struct CreateNftExData<CrossAccountId> {
@@ -566,6 +601,7 @@
pub owner: CrossAccountId,
}
+/// Explicit RFT creation data with meta parameters.
#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]
#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]
pub struct CreateRefungibleExData<CrossAccountId> {
@@ -577,6 +613,7 @@
pub properties: CollectionPropertiesVec,
}
+/// Explicit item creation data with meta parameters, namely the owner.
#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]
#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]
pub enum CreateItemExData<CrossAccountId> {
@@ -624,6 +661,7 @@
}
}
+/// Token's address, dictated by its collection and token IDs.
#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
// todo possibly rename to be used generally as an address pair
tests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-errors.ts
+++ b/tests/src/interfaces/augment-api-errors.ts
@@ -57,7 +57,7 @@
**/
AddressNotInAllowlist: AugmentedError<ApiType>;
/**
- * Requested value more than approved.
+ * Requested value is more than the approved
**/
ApprovedValueTooLow: AugmentedError<ApiType>;
/**
@@ -113,7 +113,7 @@
**/
EmptyPropertyKey: AugmentedError<ApiType>;
/**
- * Only ASCII letters, digits, and '_', '-' are allowed
+ * Only ASCII letters, digits, and symbols `_`, `-`, and `.` are allowed
**/
InvalidCharacterInPropertyKey: AugmentedError<ApiType>;
/**
@@ -133,7 +133,7 @@
**/
NoSpaceForProperty: AugmentedError<ApiType>;
/**
- * Not sufficient funds to perform action
+ * Insufficient funds to perform an action
**/
NotSufficientFounds: AugmentedError<ApiType>;
/**
@@ -153,15 +153,15 @@
**/
PublicMintingNotAllowed: AugmentedError<ApiType>;
/**
- * Only tokens from specific collections may nest tokens under this
+ * Only tokens from specific collections may nest tokens under this one
**/
SourceCollectionIsNotAllowedToNest: AugmentedError<ApiType>;
/**
- * Item not exists.
+ * Item does not exist
**/
TokenNotFound: AugmentedError<ApiType>;
/**
- * Item balance not enough.
+ * Item is balance not enough
**/
TokenValueTooLow: AugmentedError<ApiType>;
/**
@@ -173,11 +173,11 @@
**/
TransferNotAllowed: AugmentedError<ApiType>;
/**
- * Target collection doesn't supports this operation
+ * Target collection doesn't support this operation
**/
UnsupportedOperation: AugmentedError<ApiType>;
/**
- * User not passed nesting rule
+ * User does not satisfy the nesting rule
**/
UserIsNotAllowedToNest: AugmentedError<ApiType>;
/**
@@ -285,8 +285,7 @@
**/
FungibleItemsDontHaveData: AugmentedError<ApiType>;
/**
- * Not default id passed as TokenId argument.
- * The default value of TokenId for Fungible collection is 0.
+ * Fungible tokens hold no ID, and the default value of TokenId for Fungible collection is 0.
**/
FungibleItemsHaveNoId: AugmentedError<ApiType>;
/**
@@ -426,19 +425,19 @@
**/
NotRefungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;
/**
- * Refungible token can't nest other tokens
+ * Refungible token can't nest other tokens.
**/
RefungibleDisallowsNesting: AugmentedError<ApiType>;
/**
- * Refungible token can't be repartitioned by user who isn't owns all pieces
+ * Refungible token can't be repartitioned by user who isn't owns all pieces.
**/
RepartitionWhileNotOwningAllPieces: AugmentedError<ApiType>;
/**
- * Setting item properties is not allowed
+ * Setting item properties is not allowed.
**/
SettingPropertiesNotAllowed: AugmentedError<ApiType>;
/**
- * Maximum refungibility exceeded
+ * Maximum refungibility exceeded.
**/
WrongRefungiblePieces: AugmentedError<ApiType>;
/**
@@ -509,19 +508,19 @@
};
structure: {
/**
- * While iterating over children, encountered breadth limit
+ * While iterating over children, reached the breadth limit.
**/
BreadthLimit: AugmentedError<ApiType>;
/**
- * While searched for owner, encountered depth limit
+ * While searching for the owner, reached the depth limit.
**/
DepthLimit: AugmentedError<ApiType>;
/**
- * While searched for owner, got already checked account
+ * While searching for the owner, encountered an already checked account, detecting a loop.
**/
OuroborosDetected: AugmentedError<ApiType>;
/**
- * While searched for owner, found token owner by not-yet-existing token
+ * Couldn't find the token owner that is itself a token.
**/
TokenNotFound: AugmentedError<ApiType>;
/**
@@ -597,7 +596,7 @@
};
unique: {
/**
- * Decimal_points parameter must be lower than MAX_DECIMAL_POINTS constant, currently it is 30.
+ * Decimal_points parameter must be lower than [`up_data_structs::MAX_DECIMAL_POINTS`].
**/
CollectionDecimalPointLimitExceeded: AugmentedError<ApiType>;
/**
@@ -609,7 +608,7 @@
**/
EmptyArgument: AugmentedError<ApiType>;
/**
- * Repertition is only supported by refungible collection
+ * Repertition is only supported by refungible collection.
**/
RepartitionCalledOnNonRefungibleCollection: AugmentedError<ApiType>;
/**
tests/src/interfaces/augment-api-events.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-events.ts
+++ b/tests/src/interfaces/augment-api-events.ts
@@ -75,7 +75,7 @@
**/
CollectionPropertyDeleted: AugmentedEvent<ApiType, [u32, Bytes]>;
/**
- * The colletion property has been set.
+ * The colletion property has been added or edited.
**/
CollectionPropertySet: AugmentedEvent<ApiType, [u32, Bytes]>;
/**
@@ -87,7 +87,7 @@
**/
ItemDestroyed: AugmentedEvent<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr, u128]>;
/**
- * The colletion property permission has been set.
+ * The token property permission of a collection has been set.
**/
PropertyPermissionSet: AugmentedEvent<ApiType, [u32, Bytes]>;
/**
@@ -95,7 +95,7 @@
**/
TokenPropertyDeleted: AugmentedEvent<ApiType, [u32, u32, Bytes]>;
/**
- * The token property has been set.
+ * The token property has been added or edited.
**/
TokenPropertySet: AugmentedEvent<ApiType, [u32, u32, Bytes]>;
/**
@@ -407,7 +407,7 @@
};
structure: {
/**
- * Executed call on behalf of token
+ * Executed call on behalf of the token.
**/
Executed: AugmentedEvent<ApiType, [Result<Null, SpRuntimeDispatchError>]>;
/**
@@ -499,90 +499,80 @@
};
unique: {
/**
- * Address was add to allow list
+ * Address was added to the allow list
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
- *
- * * user: Address.
+ * * collection_id: ID of the affected collection.
+ * * user: Address of the added account.
**/
AllowListAddressAdded: AugmentedEvent<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
- * Address was remove from allow list
+ * Address was removed from the allow list
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
- *
- * * user: Address.
+ * * collection_id: ID of the affected collection.
+ * * user: Address of the removed account.
**/
AllowListAddressRemoved: AugmentedEvent<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
* Collection admin was added
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
- *
- * * admin: Admin address.
+ * * collection_id: ID of the affected collection.
+ * * admin: Admin address.
**/
CollectionAdminAdded: AugmentedEvent<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
* Collection admin was removed
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
- *
- * * admin: Admin address.
+ * * collection_id: ID of the affected collection.
+ * * admin: Removed admin address.
**/
CollectionAdminRemoved: AugmentedEvent<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
- * Collection limits was set
+ * Collection limits were set
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
+ * * collection_id: ID of the affected collection.
**/
CollectionLimitSet: AugmentedEvent<ApiType, [u32]>;
/**
- * Collection owned was change
+ * Collection owned was changed
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
- *
- * * owner: New owner address.
+ * * collection_id: ID of the affected collection.
+ * * owner: New owner address.
**/
CollectionOwnedChanged: AugmentedEvent<ApiType, [u32, AccountId32]>;
+ /**
+ * Collection permissions were set
+ *
+ * # Arguments
+ * * collection_id: ID of the affected collection.
+ **/
CollectionPermissionSet: AugmentedEvent<ApiType, [u32]>;
/**
* Collection sponsor was removed
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
+ * * collection_id: ID of the affected collection.
**/
CollectionSponsorRemoved: AugmentedEvent<ApiType, [u32]>;
/**
* Collection sponsor was set
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
- *
- * * owner: New sponsor address.
+ * * collection_id: ID of the affected collection.
+ * * owner: New sponsor address.
**/
CollectionSponsorSet: AugmentedEvent<ApiType, [u32, AccountId32]>;
/**
* New sponsor was confirm
*
* # Arguments
- *
- * * collection_id: Globally unique collection identifier.
- *
- * * sponsor: New sponsor address.
+ * * collection_id: ID of the affected collection.
+ * * sponsor: New sponsor address.
**/
SponsorshipConfirmed: AugmentedEvent<ApiType, [u32, AccountId32]>;
/**
tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -70,11 +70,11 @@
};
common: {
/**
- * Storage of collection admins count.
+ * Storage of the amount of collection admins.
**/
adminAmount: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
- * Allowlisted collection users
+ * Allowlisted collection users.
**/
allowlist: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
@@ -86,11 +86,11 @@
**/
collectionProperties: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<UpDataStructsProperties>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
- * Storage of collection properties permissions.
+ * Storage of token property permissions of a collection.
**/
collectionPropertyPermissions: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<BTreeMap<Bytes, UpDataStructsPropertyPermission>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
- * Storage of the count of created collections.
+ * Storage of the count of created collections. Essentially contains the last collection ID.
**/
createdCollectionCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
@@ -102,7 +102,7 @@
**/
dummyStorageValue: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[UpDataStructsCollectionStats, u32, u32, UpDataStructsTokenChild, PhantomTypeUpDataStructs]>>>, []> & QueryableStorageEntry<ApiType, []>;
/**
- * List of collection admins
+ * List of collection admins.
**/
isAdmin: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
@@ -200,7 +200,7 @@
};
fungible: {
/**
- * Storage for delegated assets.
+ * Storage for assets delegated to a limited extent to other users.
**/
allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
@@ -244,11 +244,11 @@
};
nonfungible: {
/**
- * Amount of tokens owned by account.
+ * Amount of tokens owned by an account in a collection.
**/
accountBalance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u32>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
- * Allowance set by an owner for a spender for a token.
+ * Allowance set by a token owner for another user to perform one of certain transactions on a token.
**/
allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
/**
@@ -256,7 +256,14 @@
**/
owned: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: u32 | AnyNumber | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]>;
/**
- * Custom data that is serialized to bytes and attached to a token property.
+ * Custom data of a token that is serialized to bytes,
+ * primarily reserved for on-chain operations,
+ * normally obscured from the external users.
+ *
+ * Auxiliary properties are slightly different from
+ * usual [`TokenProperties`] due to an unlimited number
+ * and separately stored and written-to key-value pairs.
+ *
* Currently used to store RMRK data.
**/
tokenAuxProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: UpDataStructsPropertyScope | 'None' | 'Rmrk' | number | Uint8Array, arg4: Bytes | string | Uint8Array) => Observable<Option<Bytes>>, [u32, u32, UpDataStructsPropertyScope, Bytes]> & QueryableStorageEntry<ApiType, [u32, u32, UpDataStructsPropertyScope, Bytes]>;
@@ -265,19 +272,19 @@
**/
tokenChildren: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: ITuple<[u32, u32]> | [u32 | AnyNumber | Uint8Array, u32 | AnyNumber | Uint8Array]) => Observable<bool>, [u32, u32, ITuple<[u32, u32]>]> & QueryableStorageEntry<ApiType, [u32, u32, ITuple<[u32, u32]>]>;
/**
- * Custom data serialized to bytes for token.
+ * Token data, used to partially describe a token.
**/
tokenData: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletNonfungibleItemData>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
/**
- * Key-Value map stored for token.
+ * Map of key-value pairs, describing the metadata of a token.
**/
tokenProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<UpDataStructsProperties>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
/**
- * Amount of burnt tokens for collection.
+ * Amount of burnt tokens in a collection.
**/
tokensBurnt: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
- * Amount of tokens minted for collection.
+ * Total amount of minted tokens in a collection.
**/
tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
@@ -444,32 +451,35 @@
};
refungible: {
/**
- * Amount of tokens owned by account
+ * Amount of tokens (not pieces) partially owned by an account within a collection.
**/
accountBalance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u32>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
- * Allowance set by an owner for a spender for a token
+ * Allowance set by a token owner for another user to perform one of certain transactions on a number of pieces of a token.
**/
allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg4: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
- * Amount of token pieces owned by account
+ * Amount of token pieces owned by account.
**/
balance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
- * Used to enumerate tokens owned by account
+ * Used to enumerate tokens owned by account.
**/
owned: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: u32 | AnyNumber | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]>;
/**
- * Custom data serialized to bytes for token
+ * Token data, used to partially describe a token.
**/
tokenData: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<PalletRefungibleItemData>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ /**
+ * Amount of pieces a refungible token is split into.
+ **/
tokenProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<UpDataStructsProperties>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
/**
- * Amount of burnt tokens for collection
+ * Amount of tokens burnt in a collection.
**/
tokensBurnt: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
- * Amount of tokens minted for collection
+ * Total amount of minted tokens in a collection.
**/
tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
@@ -663,24 +673,33 @@
* TODO: Off chain worker should remove from this map when collection gets removed
**/
createItemBasket: AugmentedQuery<ApiType, (arg: ITuple<[u32, AccountId32]> | [u32 | AnyNumber | Uint8Array, AccountId32 | string | Uint8Array]) => Observable<Option<u32>>, [ITuple<[u32, AccountId32]>]> & QueryableStorageEntry<ApiType, [ITuple<[u32, AccountId32]>]>;
+ /**
+ * Last sponsoring of fungible tokens approval in a collection
+ **/
fungibleApproveBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, AccountId32]>;
/**
* Collection id (controlled?2), owning user (real)
**/
fungibleTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, AccountId32]>;
/**
- * Approval sponsoring
+ * Last sponsoring of NFT approval in a collection
**/
nftApproveBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<u32>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
/**
* Collection id (controlled?2), token id (controlled?2)
**/
nftTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<u32>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ /**
+ * Last sponsoring of RFT approval in a collection
+ **/
refungibleApproveBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u32, u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, u32, AccountId32]>;
/**
* Collection id (controlled?2), token id (controlled?2)
**/
reFungibleTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u32, u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, u32, AccountId32]>;
+ /**
+ * Last sponsoring of token property setting // todo:doc rephrase this and the following
+ **/
tokenPropertyBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<u32>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
/**
* Variable metadata sponsoring
tests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -629,47 +629,47 @@
};
unique: {
/**
- * Get amount of different user tokens
+ * Get the amount of any user tokens owned by an account
**/
accountBalance: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u32>>;
/**
- * Get tokens owned by account
+ * Get tokens owned by an account in a collection
**/
accountTokens: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<u32>>>;
/**
- * Get admin list
+ * Get the list of admin accounts of a collection
**/
adminlist: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletEvmAccountBasicCrossAccountIdRepr>>>;
/**
- * Get allowed amount
+ * Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor
**/
allowance: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, sender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, spender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
/**
- * Check if user is allowed to use collection
+ * Check if a user is allowed to operate within a collection
**/
allowed: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<bool>>;
/**
- * Get allowlist
+ * Get the list of accounts allowed to operate within a collection
**/
allowlist: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletEvmAccountBasicCrossAccountIdRepr>>>;
/**
- * Get amount of specific account token
+ * Get the amount of a specific token owned by an account
**/
balance: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
/**
- * Get collection by specified id
+ * Get a collection by the specified ID
**/
collectionById: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsRpcCollection>>>;
/**
- * Get collection properties
+ * Get collection properties, optionally limited to the provided keys
**/
collectionProperties: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsProperty>>>;
/**
- * Get collection stats
+ * Get chain stats about collections
**/
collectionStats: AugmentedRpc<(at?: Hash | string | Uint8Array) => Observable<UpDataStructsCollectionStats>>;
/**
- * Get tokens contained in collection
+ * Get tokens contained within a collection
**/
collectionTokens: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<u32>>>;
/**
@@ -681,15 +681,15 @@
**/
effectiveCollectionLimits: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsCollectionLimits>>>;
/**
- * Get last token id
+ * Get the last token ID created in a collection
**/
lastTokenId: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u32>>;
/**
- * Get number of blocks when sponsored transaction is available
+ * Get the number of blocks until sponsoring a transaction is available
**/
nextSponsored: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<u64>>>;
/**
- * Get property permissions
+ * Get property permissions, optionally limited to the provided keys
**/
propertyPermissions: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsPropertyKeyPermission>>>;
/**
@@ -697,15 +697,15 @@
**/
tokenChildren: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsTokenChild>>>;
/**
- * Get token data
+ * Get token data, including properties, optionally limited to the provided keys, and total pieces for an RFT
**/
tokenData: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<UpDataStructsTokenData>>;
/**
- * Check if token exists
+ * Check if the token exists
**/
tokenExists: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<bool>>;
/**
- * Get token owner
+ * Get the token owner
**/
tokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>>;
/**
@@ -713,19 +713,19 @@
**/
tokenOwners: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletEvmAccountBasicCrossAccountIdRepr>>>;
/**
- * Get token properties
+ * Get token properties, optionally limited to the provided keys
**/
tokenProperties: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsProperty>>>;
/**
- * Get token owner, in case of nested token - find parent recursive
+ * Get the topmost token owner in the hierarchy of a possibly nested token
**/
topmostTokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>>;
/**
- * Get total pieces of token
+ * Get the total amount of pieces of an RFT
**/
totalPieces: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<u128>>>;
/**
- * Get amount of unique collection tokens
+ * Get the amount of distinctive tokens present in a collection
**/
totalSupply: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u32>>;
/**
tests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -730,87 +730,99 @@
};
unique: {
/**
- * Adds an admin of the Collection.
- * 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.
+ * Add an admin to a collection.
+ *
+ * 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.
*
* # Permissions
*
- * * Collection Owner.
- * * Collection Admin.
+ * * Collection owner
+ * * Collection admin
*
* # Arguments
- *
- * * collection_id: ID of the Collection to add admin for.
*
- * * new_admin_id: Address of new admin to add.
+ * * `collection_id`: ID of the Collection to add an admin for.
+ * * `new_admin`: Address of new admin to add.
**/
- addCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newAdminId: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
+ addCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newAdmin: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
* Add an address to allow list.
*
* # Permissions
*
- * * Collection Owner
- * * Collection Admin
+ * * Collection owner
+ * * Collection admin
*
* # Arguments
*
- * * collection_id.
- *
- * * address.
+ * * `collection_id`: ID of the modified collection.
+ * * `address`: ID of the address to be added to the allowlist.
**/
addToAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
- * Set, change, or remove approved address to transfer the ownership of the NFT.
+ * Allow a non-permissioned address to transfer or burn an item.
*
* # Permissions
*
- * * Collection Owner
- * * Collection Admin
- * * Current NFT owner
+ * * Collection owner
+ * * Collection admin
+ * * Current item owner
*
* # Arguments
- *
- * * approved: Address that is approved to transfer this NFT or zero (if needed to remove approval).
*
- * * collection_id.
- *
- * * item_id: ID of the item.
+ * * `spender`: Account to be approved to make specific transactions on non-owned tokens.
+ * * `collection_id`: ID of the collection the item belongs to.
+ * * `item_id`: ID of the item transactions on which are now approved.
+ * * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).
+ * Set to 0 to revoke the approval.
**/
approve: AugmentedSubmittable<(spender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletEvmAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
/**
- * Destroys a concrete instance of NFT on behalf of the owner
- * See also: [`approve`]
+ * Destroy a token on behalf of the owner as a non-owner account.
+ *
+ * See also: [`approve`][`Pallet::approve`].
+ *
+ * After this method executes, one approval is removed from the total so that
+ * the approved address will not be able to transfer this item again from this owner.
*
* # Permissions
*
- * * Collection Owner.
- * * Collection Admin.
- * * Current NFT Owner.
+ * * Collection owner
+ * * Collection admin
+ * * Current token owner
+ * * Address approved by current item owner
*
* # Arguments
*
- * * collection_id: ID of the collection.
- *
- * * item_id: ID of NFT to burn.
- *
- * * from: owner of item
+ * * `from`: The owner of the burning item.
+ * * `collection_id`: ID of the collection to which the item belongs.
+ * * `item_id`: ID of item to burn.
+ * * `value`: Number of pieces to burn.
+ * * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.
+ * * Fungible Mode: The desired number of pieces to burn.
+ * * Re-Fungible Mode: The desired number of pieces to burn.
**/
burnFrom: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, from: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32, u128]>;
/**
- * Destroys a concrete instance of NFT.
+ * Destroy an item.
*
* # Permissions
*
- * * Collection Owner.
- * * Collection Admin.
- * * Current NFT Owner.
+ * * Collection owner
+ * * Collection admin
+ * * Current item owner
*
* # Arguments
*
- * * collection_id: ID of the collection.
- *
- * * item_id: ID of NFT to burn.
+ * * `collection_id`: ID of the collection to which the item belongs.
+ * * `item_id`: ID of item to burn.
+ * * `value`: Number of pieces of the item to destroy.
+ * * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.
+ * * Fungible Mode: The desired number of pieces to burn.
+ * * Re-Fungible Mode: The desired number of pieces to burn.
**/
burnItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u128]>;
/**
@@ -818,131 +830,200 @@
*
* # Permissions
*
- * * Collection Owner.
+ * * Collection owner
*
* # Arguments
*
- * * collection_id.
- *
- * * new_owner.
+ * * `collection_id`: ID of the modified collection.
+ * * `new_owner`: ID of the account that will become the owner.
**/
changeCollectionOwner: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newOwner: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
/**
+ * Confirm own sponsorship of a collection, becoming the sponsor.
+ *
+ * An invitation must be pending, see [`set_collection_sponsor`][`Pallet::set_collection_sponsor`].
+ * Sponsor can pay the fees of a transaction instead of the sender,
+ * but only within specified limits.
+ *
* # Permissions
*
- * * Sponsor.
+ * * Sponsor-to-be
*
* # Arguments
*
- * * collection_id.
+ * * `collection_id`: ID of the collection with the pending sponsor.
**/
confirmSponsorship: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
/**
- * 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.
+ * Create a collection of tokens.
+ *
+ * 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.
+ *
+ * Prefer the more advanced [`create_collection_ex`][`Pallet::create_collection_ex`] instead.
*
* # Permissions
*
- * * Anyone.
+ * * Anyone - becomes the owner of the new collection.
*
* # Arguments
*
- * * collection_name: UTF-16 string with collection name (limit 64 characters), will be stored as zero-terminated.
+ * * `collection_name`: Wide-character string with collection name
+ * (limit [`MAX_COLLECTION_NAME_LENGTH`]).
+ * * `collection_description`: Wide-character string with collection description
+ * (limit [`MAX_COLLECTION_DESCRIPTION_LENGTH`]).
+ * * `token_prefix`: Byte string containing the token prefix to mark a collection
+ * to which a token belongs (limit [`MAX_TOKEN_PREFIX_LENGTH`]).
+ * * `mode`: Type of items stored in the collection and type dependent data.
+ **/
+ createCollection: AugmentedSubmittable<(collectionName: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], collectionDescription: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], tokenPrefix: Bytes | string | Uint8Array, mode: UpDataStructsCollectionMode | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<u16>, Vec<u16>, Bytes, UpDataStructsCollectionMode]>;
+ /**
+ * Create a collection with explicit parameters.
*
- * * collection_description: UTF-16 string with collection description (limit 256 characters), will be stored as zero-terminated.
+ * Prefer it to the deprecated [`create_collection`][`Pallet::create_collection`] method.
+ *
+ * # Permissions
*
- * * token_prefix: UTF-8 string with token prefix.
+ * * Anyone - becomes the owner of the new collection.
*
- * * mode: [CollectionMode] collection type and type dependent data.
- **/
- createCollection: AugmentedSubmittable<(collectionName: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], collectionDescription: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], tokenPrefix: Bytes | string | Uint8Array, mode: UpDataStructsCollectionMode | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<u16>, Vec<u16>, Bytes, UpDataStructsCollectionMode]>;
- /**
- * This method creates a collection
+ * # Arguments
*
- * Prefer it to deprecated [`created_collection`] method
+ * * `data`: Explicit data of a collection used for its creation.
**/
createCollectionEx: AugmentedSubmittable<(data: UpDataStructsCreateCollectionData | { mode?: any; access?: any; name?: any; description?: any; tokenPrefix?: any; pendingSponsor?: any; limits?: any; permissions?: any; tokenPropertyPermissions?: any; properties?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [UpDataStructsCreateCollectionData]>;
/**
- * This method creates a concrete instance of NFT Collection created with CreateCollection method.
+ * Mint an item within a collection.
*
+ * A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].
+ *
* # Permissions
*
- * * Collection Owner.
- * * Collection Admin.
+ * * Collection owner
+ * * Collection admin
* * Anyone if
* * Allow List is enabled, and
* * Address is added to allow list, and
- * * MintPermission is enabled (see SetMintPermission method)
+ * * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])
*
* # Arguments
*
- * * collection_id: ID of the collection.
+ * * `collection_id`: ID of the collection to which an item would belong.
+ * * `owner`: Address of the initial owner of the item.
+ * * `data`: Token data describing the item to store on chain.
+ **/
+ createItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, data: UpDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsCreateItemData]>;
+ /**
+ * Create multiple items within a collection.
*
- * * owner: Address, initial owner of the NFT.
+ * A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].
+ *
+ * # Permissions
+ *
+ * * Collection owner
+ * * Collection admin
+ * * Anyone if
+ * * Allow List is enabled, and
+ * * Address is added to the allow list, and
+ * * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])
*
- * * data: Token data to store on chain.
+ * # Arguments
+ *
+ * * `collection_id`: ID of the collection to which the tokens would belong.
+ * * `owner`: Address of the initial owner of the tokens.
+ * * `items_data`: Vector of data describing each item to be created.
**/
- createItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, data: UpDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsCreateItemData]>;
+ createMultipleItems: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemsData: Vec<UpDataStructsCreateItemData> | (UpDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, Vec<UpDataStructsCreateItemData>]>;
/**
- * This method creates multiple items in a collection created with CreateCollection method.
+ * Create multiple items within a collection with explicitly specified initial parameters.
*
* # Permissions
*
- * * Collection Owner.
- * * Collection Admin.
+ * * Collection owner
+ * * Collection admin
* * Anyone if
* * Allow List is enabled, and
* * Address is added to allow list, and
- * * MintPermission is enabled (see SetMintPermission method)
+ * * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])
*
* # Arguments
*
- * * collection_id: ID of the collection.
+ * * `collection_id`: ID of the collection to which the tokens would belong.
+ * * `data`: Explicit item creation data.
+ **/
+ createMultipleItemsEx: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, data: UpDataStructsCreateItemExData | { NFT: any } | { Fungible: any } | { RefungibleMultipleItems: any } | { RefungibleMultipleOwners: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsCreateItemExData]>;
+ /**
+ * Delete specified collection properties.
*
- * * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ *
+ * # Arguments
*
- * * owner: Address, initial owner of the NFT.
+ * * `collection_id`: ID of the modified collection.
+ * * `property_keys`: Vector of keys of the properties to be deleted.
+ * Keys support Latin letters, `-`, `_`, and `.` as symbols.
**/
- createMultipleItems: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemsData: Vec<UpDataStructsCreateItemData> | (UpDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, Vec<UpDataStructsCreateItemData>]>;
- createMultipleItemsEx: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, data: UpDataStructsCreateItemExData | { NFT: any } | { Fungible: any } | { RefungibleMultipleItems: any } | { RefungibleMultipleOwners: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsCreateItemExData]>;
deleteCollectionProperties: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, propertyKeys: Vec<Bytes> | (Bytes | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, Vec<Bytes>]>;
+ /**
+ * Delete specified token properties. Currently properties only work with NFTs.
+ *
+ * # Permissions
+ *
+ * * Depends on collection's token property permissions and specified property mutability:
+ * * Collection owner
+ * * Collection admin
+ * * Token owner
+ *
+ * # Arguments
+ *
+ * * `collection_id`: ID of the collection to which the token belongs.
+ * * `token_id`: ID of the modified token.
+ * * `property_keys`: Vector of keys of the properties to be deleted.
+ * Keys support Latin letters, `-`, `_`, and `.` as symbols.
+ **/
deleteTokenProperties: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, propertyKeys: Vec<Bytes> | (Bytes | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, u32, Vec<Bytes>]>;
/**
- * Destroys collection if no tokens within this collection
+ * Destroy a collection if no tokens exist within.
*
* # Permissions
*
- * * Collection Owner.
+ * * Collection owner
*
* # Arguments
*
- * * collection_id: collection to destroy.
+ * * `collection_id`: Collection to destroy.
**/
destroyCollection: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
/**
- * 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.
+ * Remove admin of a 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.
*
* # Permissions
*
- * * Collection Owner.
- * * Collection Admin.
+ * * Collection owner
+ * * Collection admin
*
* # Arguments
*
- * * collection_id: ID of the Collection to remove admin for.
- *
- * * account_id: Address of admin to remove.
+ * * `collection_id`: ID of the collection to remove the admin for.
+ * * `account_id`: Address of the admin to remove.
**/
removeCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, accountId: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
/**
- * Switch back to pay-per-own-transaction model.
+ * Remove a collection's a sponsor, making everyone pay for their own transactions.
*
* # Permissions
*
- * * Collection owner.
+ * * Collection owner
*
* # Arguments
*
- * * collection_id.
+ * * `collection_id`: ID of the collection with the sponsor to remove.
**/
removeCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
/**
@@ -950,46 +1031,140 @@
*
* # Permissions
*
- * * Collection Owner
- * * Collection Admin
+ * * Collection owner
+ * * Collection admin
*
* # Arguments
*
- * * collection_id.
+ * * `collection_id`: ID of the modified collection.
+ * * `address`: ID of the address to be removed from the allowlist.
+ **/
+ removeFromAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
+ /**
+ * Re-partition a refungible token, while owning all of its parts/pieces.
+ *
+ * # Permissions
+ *
+ * * Token owner (must own every part)
+ *
+ * # Arguments
+ *
+ * * `collection_id`: ID of the collection the RFT belongs to.
+ * * `token_id`: ID of the RFT.
+ * * `amount`: New number of parts/pieces into which the token shall be partitioned.
+ **/
+ repartition: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u128]>;
+ /**
+ * Set specific limits of a collection. Empty, or None fields mean chain default.
+ *
+ * # Permissions
*
- * * address.
+ * * Collection owner
+ * * Collection admin
+ *
+ * # Arguments
+ *
+ * * `collection_id`: ID of the modified collection.
+ * * `new_limit`: New limits of the collection. Fields that are not set (None)
+ * will not overwrite the old ones.
**/
- removeFromAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
- repartition: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, token: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u128]>;
setCollectionLimits: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: UpDataStructsCollectionLimits | { accountTokenOwnershipLimit?: any; sponsoredDataSize?: any; sponsoredDataRateLimit?: any; tokenLimit?: any; sponsorTransferTimeout?: any; sponsorApproveTimeout?: any; ownerCanTransfer?: any; ownerCanDestroy?: any; transfersEnabled?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsCollectionLimits]>;
- setCollectionPermissions: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: UpDataStructsCollectionPermissions | { access?: any; mintMode?: any; nesting?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsCollectionPermissions]>;
- setCollectionProperties: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, properties: Vec<UpDataStructsProperty> | (UpDataStructsProperty | { key?: any; value?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, Vec<UpDataStructsProperty>]>;
/**
+ * Set specific permissions of a collection. Empty, or None fields mean chain default.
+ *
* # Permissions
*
- * * Collection Owner
+ * * Collection owner
+ * * Collection admin
*
* # Arguments
*
- * * collection_id.
+ * * `collection_id`: ID of the modified collection.
+ * * `new_permission`: New permissions of the collection. Fields that are not set (None)
+ * will not overwrite the old ones.
+ **/
+ setCollectionPermissions: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newPermission: UpDataStructsCollectionPermissions | { access?: any; mintMode?: any; nesting?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsCollectionPermissions]>;
+ /**
+ * Add or change collection properties.
+ *
+ * # Permissions
+ *
+ * * Collection owner
+ * * Collection admin
*
- * * new_sponsor.
+ * # Arguments
+ *
+ * * `collection_id`: ID of the modified collection.
+ * * `properties`: Vector of key-value pairs stored as the collection's metadata.
+ * Keys support Latin letters, `-`, `_`, and `.` as symbols.
**/
+ setCollectionProperties: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, properties: Vec<UpDataStructsProperty> | (UpDataStructsProperty | { key?: any; value?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, Vec<UpDataStructsProperty>]>;
+ /**
+ * Set (invite) a new collection sponsor.
+ *
+ * If successful, confirmation from the sponsor-to-be will be pending.
+ *
+ * # Permissions
+ *
+ * * Collection owner
+ * * Collection admin
+ *
+ * # Arguments
+ *
+ * * `collection_id`: ID of the modified collection.
+ * * `new_sponsor`: ID of the account of the sponsor-to-be.
+ **/
setCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newSponsor: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
+ /**
+ * Add or change token properties according to collection's permissions.
+ * Currently properties only work with NFTs.
+ *
+ * # Permissions
+ *
+ * * Depends on collection's token property permissions and specified property mutability:
+ * * Collection owner
+ * * Collection admin
+ * * Token owner
+ *
+ * See [`set_token_property_permissions`][`Pallet::set_token_property_permissions`].
+ *
+ * # Arguments
+ *
+ * * `collection_id: ID of the collection to which the token belongs.
+ * * `token_id`: ID of the modified token.
+ * * `properties`: Vector of key-value pairs stored as the token's metadata.
+ * Keys support Latin letters, `-`, `_`, and `.` as symbols.
+ **/
setTokenProperties: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, properties: Vec<UpDataStructsProperty> | (UpDataStructsProperty | { key?: any; value?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, u32, Vec<UpDataStructsProperty>]>;
- setTokenPropertyPermissions: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, propertyPermissions: Vec<UpDataStructsPropertyKeyPermission> | (UpDataStructsPropertyKeyPermission | { key?: any; permission?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, Vec<UpDataStructsPropertyKeyPermission>]>;
/**
- * Set transfers_enabled value for particular collection
+ * Add or change token property permissions of a collection.
+ *
+ * Without a permission for a particular key, a property with that key
+ * cannot be created in a token.
*
* # Permissions
*
- * * Collection Owner.
+ * * Collection owner
+ * * Collection admin
*
* # Arguments
*
- * * collection_id: ID of the collection.
+ * * `collection_id`: ID of the modified collection.
+ * * `property_permissions`: Vector of permissions for property keys.
+ * Keys support Latin letters, `-`, `_`, and `.` as symbols.
+ **/
+ setTokenPropertyPermissions: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, propertyPermissions: Vec<UpDataStructsPropertyKeyPermission> | (UpDataStructsPropertyKeyPermission | { key?: any; permission?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, Vec<UpDataStructsPropertyKeyPermission>]>;
+ /**
+ * Completely allow or disallow transfers for a particular collection.
*
- * * value: New flag value.
+ * # Permissions
+ *
+ * * Collection owner
+ *
+ * # Arguments
+ *
+ * * `collection_id`: ID of the collection.
+ * * `value`: New value of the flag, are transfers allowed?
**/
setTransfersEnabledFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;
/**
@@ -997,47 +1172,50 @@
*
* # Permissions
*
- * * Collection Owner
- * * Collection Admin
- * * Current NFT owner
+ * * Collection owner
+ * * Collection admin
+ * * Current token owner
*
* # Arguments
*
- * * recipient: Address of token recipient.
- *
- * * collection_id.
- *
- * * item_id: ID of the item
+ * * `recipient`: Address of token recipient.
+ * * `collection_id`: ID of the collection the item belongs to.
+ * * `item_id`: ID of the item.
* * Non-Fungible Mode: Required.
* * Fungible Mode: Ignored.
* * Re-Fungible Mode: Required.
*
- * * value: Amount to transfer.
- * * Non-Fungible Mode: Ignored
- * * Fungible Mode: Must specify transferred amount
- * * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)
+ * * `value`: Amount to transfer.
+ * * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.
+ * * Fungible Mode: The desired number of pieces to transfer.
+ * * Re-Fungible Mode: The desired number of pieces to transfer.
**/
transfer: AugmentedSubmittable<(recipient: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletEvmAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
/**
- * 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.
- *
- * # Permissions
- * * Collection Owner
- * * Collection Admin
- * * Current NFT owner
- * * Address approved by current NFT owner
+ * Change ownership of an item on behalf of the owner as a non-owner account.
*
- * # Arguments
+ * See the [`approve`][`Pallet::approve`] method for additional information.
*
- * * from: Address that owns token.
+ * After this method executes, one approval is removed from the total so that
+ * the approved address will not be able to transfer this item again from this owner.
*
- * * recipient: Address of token recipient.
+ * # Permissions
*
- * * collection_id.
+ * * Collection owner
+ * * Collection admin
+ * * Current item owner
+ * * Address approved by current item owner
*
- * * item_id: ID of the item.
+ * # Arguments
*
- * * value: Amount to transfer.
+ * * `from`: Address that currently owns the token.
+ * * `recipient`: Address of the new token-owner-to-be.
+ * * `collection_id`: ID of the collection the item.
+ * * `item_id`: ID of the item to be transferred.
+ * * `value`: Amount to transfer.
+ * * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.
+ * * Fungible Mode: The desired number of pieces to transfer.
+ * * Re-Fungible Mode: The desired number of pieces to transfer.
**/
transferFrom: AugmentedSubmittable<(from: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, recipient: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
/**
tests/src/interfaces/default/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -1672,7 +1672,7 @@
readonly isAddCollectionAdmin: boolean;
readonly asAddCollectionAdmin: {
readonly collectionId: u32;
- readonly newAdminId: PalletEvmAccountBasicCrossAccountIdRepr;
+ readonly newAdmin: PalletEvmAccountBasicCrossAccountIdRepr;
} & Struct;
readonly isRemoveCollectionAdmin: boolean;
readonly asRemoveCollectionAdmin: {
@@ -1784,12 +1784,12 @@
readonly isSetCollectionPermissions: boolean;
readonly asSetCollectionPermissions: {
readonly collectionId: u32;
- readonly newLimit: UpDataStructsCollectionPermissions;
+ readonly newPermission: UpDataStructsCollectionPermissions;
} & Struct;
readonly isRepartition: boolean;
readonly asRepartition: {
readonly collectionId: u32;
- readonly token: u32;
+ readonly tokenId: u32;
readonly amount: u128;
} & Struct;
readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition';
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1269,7 +1269,7 @@
},
add_collection_admin: {
collectionId: 'u32',
- newAdminId: 'PalletEvmAccountBasicCrossAccountIdRepr',
+ newAdmin: 'PalletEvmAccountBasicCrossAccountIdRepr',
},
remove_collection_admin: {
collectionId: 'u32',
@@ -1361,11 +1361,11 @@
},
set_collection_permissions: {
collectionId: 'u32',
- newLimit: 'UpDataStructsCollectionPermissions',
+ newPermission: 'UpDataStructsCollectionPermissions',
},
repartition: {
collectionId: 'u32',
- token: 'u32',
+ tokenId: 'u32',
amount: 'u128'
}
}
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1385,7 +1385,7 @@
readonly isAddCollectionAdmin: boolean;
readonly asAddCollectionAdmin: {
readonly collectionId: u32;
- readonly newAdminId: PalletEvmAccountBasicCrossAccountIdRepr;
+ readonly newAdmin: PalletEvmAccountBasicCrossAccountIdRepr;
} & Struct;
readonly isRemoveCollectionAdmin: boolean;
readonly asRemoveCollectionAdmin: {
@@ -1497,12 +1497,12 @@
readonly isSetCollectionPermissions: boolean;
readonly asSetCollectionPermissions: {
readonly collectionId: u32;
- readonly newLimit: UpDataStructsCollectionPermissions;
+ readonly newPermission: UpDataStructsCollectionPermissions;
} & Struct;
readonly isRepartition: boolean;
readonly asRepartition: {
readonly collectionId: u32;
- readonly token: u32;
+ readonly tokenId: u32;
readonly amount: u128;
} & Struct;
readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition';
tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -37,49 +37,143 @@
export default {
types: {},
rpc: {
- adminlist: fun('Get admin list', [collectionParam], 'Vec<PalletEvmAccountBasicCrossAccountIdRepr>'),
- allowlist: fun('Get allowlist', [collectionParam], 'Vec<PalletEvmAccountBasicCrossAccountIdRepr>'),
+ accountTokens: fun(
+ 'Get tokens owned by an account in a collection',
+ [collectionParam, crossAccountParam()],
+ 'Vec<u32>',
+ ),
+ collectionTokens: fun(
+ 'Get tokens contained within a collection',
+ [collectionParam],
+ 'Vec<u32>',
+ ),
+ tokenExists: fun(
+ 'Check if the token exists',
+ [collectionParam, tokenParam],
+ 'bool',
+ ),
- accountTokens: fun('Get tokens owned by account', [collectionParam, crossAccountParam()], 'Vec<u32>'),
- collectionTokens: fun('Get tokens contained in collection', [collectionParam], 'Vec<u32>'),
+ tokenOwner: fun(
+ 'Get the token owner',
+ [collectionParam, tokenParam],
+ `Option<${CROSS_ACCOUNT_ID_TYPE}>`,
+ ),
+ topmostTokenOwner: fun(
+ 'Get the topmost token owner in the hierarchy of a possibly nested token',
+ [collectionParam, tokenParam],
+ `Option<${CROSS_ACCOUNT_ID_TYPE}>`,
+ ),
+ tokenOwners: fun(
+ 'Returns 10 tokens owners in no particular order',
+ [collectionParam, tokenParam],
+ `Vec<${CROSS_ACCOUNT_ID_TYPE}>`,
+ ),
+ tokenChildren: fun(
+ 'Get tokens nested directly into the token',
+ [collectionParam, tokenParam],
+ 'Vec<UpDataStructsTokenChild>',
+ ),
- lastTokenId: fun('Get last token id', [collectionParam], 'u32'),
- totalSupply: fun('Get amount of unique collection tokens', [collectionParam], 'u32'),
- accountBalance: fun('Get amount of different user tokens', [collectionParam, crossAccountParam()], 'u32'),
- balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),
- allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),
- tokenOwner: fun('Get token owner', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),
- tokenOwners: fun('Returns 10 tokens owners in no particular order', [collectionParam, tokenParam], `Vec<${CROSS_ACCOUNT_ID_TYPE}>`),
- topmostTokenOwner: fun('Get token owner, in case of nested token - find parent recursive', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),
- tokenChildren: fun('Get tokens nested directly into the token', [collectionParam, tokenParam], 'Vec<UpDataStructsTokenChild>'),
- constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),
- variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),
collectionProperties: fun(
- 'Get collection properties',
+ 'Get collection properties, optionally limited to the provided keys',
[collectionParam, propertyKeysParam],
'Vec<UpDataStructsProperty>',
),
tokenProperties: fun(
- 'Get token properties',
+ 'Get token properties, optionally limited to the provided keys',
[collectionParam, tokenParam, propertyKeysParam],
'Vec<UpDataStructsProperty>',
),
propertyPermissions: fun(
- 'Get property permissions',
+ 'Get property permissions, optionally limited to the provided keys',
[collectionParam, propertyKeysParam],
'Vec<UpDataStructsPropertyKeyPermission>',
),
+
+ constMetadata: fun(
+ 'Get token constant metadata',
+ [collectionParam, tokenParam],
+ 'Vec<u8>',
+ ),
+ variableMetadata: fun(
+ 'Get token variable metadata',
+ [collectionParam, tokenParam],
+ 'Vec<u8>',
+ ),
+
tokenData: fun(
- 'Get token data',
+ 'Get token data, including properties, optionally limited to the provided keys, and total pieces for an RFT',
[collectionParam, tokenParam, propertyKeysParam],
'UpDataStructsTokenData',
),
- tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'),
- collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsRpcCollection>'),
- collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),
- allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),
- nextSponsored: fun('Get number of blocks when sponsored transaction is available', [collectionParam, crossAccountParam(), tokenParam], 'Option<u64>'),
- effectiveCollectionLimits: fun('Get effective collection limits', [collectionParam], 'Option<UpDataStructsCollectionLimits>'),
- totalPieces: fun('Get total pieces of token', [collectionParam, tokenParam], 'Option<u128>'),
+ totalSupply: fun(
+ 'Get the amount of distinctive tokens present in a collection',
+ [collectionParam],
+ 'u32',
+ ),
+
+ accountBalance: fun(
+ 'Get the amount of any user tokens owned by an account',
+ [collectionParam, crossAccountParam()],
+ 'u32',
+ ),
+ balance: fun(
+ 'Get the amount of a specific token owned by an account',
+ [collectionParam, crossAccountParam(), tokenParam],
+ 'u128',
+ ),
+ allowance: fun(
+ 'Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor',
+ [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam],
+ 'u128',
+ ),
+
+ adminlist: fun(
+ 'Get the list of admin accounts of a collection',
+ [collectionParam],
+ 'Vec<PalletEvmAccountBasicCrossAccountIdRepr>',
+ ),
+ allowlist: fun(
+ 'Get the list of accounts allowed to operate within a collection',
+ [collectionParam],
+ 'Vec<PalletEvmAccountBasicCrossAccountIdRepr>',
+ ),
+ allowed: fun(
+ 'Check if a user is allowed to operate within a collection',
+ [collectionParam, crossAccountParam()],
+ 'bool',
+ ),
+
+ lastTokenId: fun(
+ 'Get the last token ID created in a collection',
+ [collectionParam],
+ 'u32',
+ ),
+ collectionById: fun(
+ 'Get a collection by the specified ID',
+ [collectionParam],
+ 'Option<UpDataStructsRpcCollection>',
+ ),
+ collectionStats: fun(
+ 'Get chain stats about collections',
+ [],
+ 'UpDataStructsCollectionStats',
+ ),
+
+ nextSponsored: fun(
+ 'Get the number of blocks until sponsoring a transaction is available',
+ [collectionParam, crossAccountParam(), tokenParam],
+ 'Option<u64>',
+ ),
+ effectiveCollectionLimits: fun(
+ 'Get effective collection limits',
+ [collectionParam],
+ 'Option<UpDataStructsCollectionLimits>',
+ ),
+ totalPieces: fun(
+ 'Get the total amount of pieces of an RFT',
+ [collectionParam, tokenParam],
+ 'Option<u128>',
+ ),
},
};