difftreelog
style cargo fmt
in: master
5 files changed
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617//! # RMRK Core Proxy Pallet17//! # RMRK Core Proxy Pallet18//! 18//!19//! A pallet used as proxy for RMRK Core (<https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-core>).19//! A pallet used as proxy for RMRK Core (<https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-core>).20//! 20//!21//! - [`Config`]21//! - [`Config`]22//! - [`Call`]22//! - [`Call`]23//! - [`Pallet`]23//! - [`Pallet`]24//! 24//!25//! ## Overview25//! ## Overview26//! 26//!27//! The RMRK Core Proxy pallet mirrors the functionality of RMRK Core, 27//! The RMRK Core Proxy pallet mirrors the functionality of RMRK Core,28//! binding its externalities to Unique's own underlying structure.28//! binding its externalities to Unique's own underlying structure.29//! It is purposed to mimic RMRK Core exactly, allowing seamless integrations29//! It is purposed to mimic RMRK Core exactly, allowing seamless integrations30//! of solutions based on RMRK.30//! of solutions based on RMRK.31//! 31//!32//! RMRK Core itself contains essential functionality for RMRK's nested and32//! RMRK Core itself contains essential functionality for RMRK's nested and33//! multi-resourced NFTs.33//! multi-resourced NFTs.34//! 34//!35//! *Note*, that while RMRK itself is subject to active development and restructuring,35//! *Note*, that while RMRK itself is subject to active development and restructuring,36//! the proxy may be caught temporarily out of date.36//! the proxy may be caught temporarily out of date.37//! 37//!38//! ### What is RMRK?38//! ### What is RMRK?39//! 39//!40//! RMRK is a set of NFT standards which compose several "NFT 2.0 lego" primitives. 40//! RMRK is a set of NFT standards which compose several "NFT 2.0 lego" primitives.41//! Putting these legos together allows a user to create NFT systems of arbitrary complexity.41//! Putting these legos together allows a user to create NFT systems of arbitrary complexity.42//! 42//!43//! Meaning, RMRK NFTs are dynamic, able to nest into each other and form a hierarchy,43//! Meaning, RMRK NFTs are dynamic, able to nest into each other and form a hierarchy,44//! make use of specific changeable and partially shared metadata in the form of resources, 44//! make use of specific changeable and partially shared metadata in the form of resources,45//! and more.45//! and more.46//! 46//!47//! Visit RMRK documentation and repositories to learn more:47//! Visit RMRK documentation and repositories to learn more:48//! - Docs: <https://docs.rmrk.app/getting-started/>48//! - Docs: <https://docs.rmrk.app/getting-started/>49//! - FAQ: <https://coda.io/@rmrk/faq>49//! - FAQ: <https://coda.io/@rmrk/faq>50//! - Substrate code repository: <https://github.com/rmrk-team/rmrk-substrate>50//! - Substrate code repository: <https://github.com/rmrk-team/rmrk-substrate>51//! - RMRK spec repository: <https://github.com/rmrk-team/rmrk-spec>51//! - RMRK spec repository: <https://github.com/rmrk-team/rmrk-spec>52//! 52//!53//! ## Proxy Implementation53//! ## Proxy Implementation54//! 54//!55//! An external user is supposed to be able to utilize this proxy as they would55//! An external user is supposed to be able to utilize this proxy as they would56//! utilize RMRK, and get exactly the same results. Normally, Unique transactions56//! utilize RMRK, and get exactly the same results. Normally, Unique transactions57//! are off-limits to RMRK collections and tokens, and vice versa. However,57//! are off-limits to RMRK collections and tokens, and vice versa. However,58//! the information stored on chain can be freely interpreted by storage reads and RPCs.58//! the information stored on chain can be freely interpreted by storage reads and RPCs.59//! 59//!60//! ### ID Mapping60//! ### ID Mapping61//! 61//!62//! RMRK's collections' IDs are counted independently of Unique's and start at 0.62//! RMRK's collections' IDs are counted independently of Unique's and start at 0.63//! Note that tokens' IDs still start at 1.63//! Note that tokens' IDs still start at 1.64//! The collections themselves, as well as tokens, are stored as Unique collections,64//! The collections themselves, as well as tokens, are stored as Unique collections,65//! and thus RMRK IDs are mapped to Unique IDs (but not vice versa).65//! and thus RMRK IDs are mapped to Unique IDs (but not vice versa).66//! 66//!67//! ### External/Internal Collection Insulation67//! ### External/Internal Collection Insulation68//! 68//!69//! A Unique transaction cannot target collections purposed for RMRK,69//! A Unique transaction cannot target collections purposed for RMRK,70//! and they are flagged as `external` to specify that. On the other hand, 70//! and they are flagged as `external` to specify that. On the other hand,71//! due to the mapping, RMRK transactions and RPCs simply cannot reach Unique collections.71//! due to the mapping, RMRK transactions and RPCs simply cannot reach Unique collections.72//! 72//!73//! ### Native Properties73//! ### Native Properties74//! 74//!75//! Many of RMRK's native parameters are stored as scoped properties of a collection 75//! Many of RMRK's native parameters are stored as scoped properties of a collection76//! or an NFT on the chain. Scoped properties are prefixed with `rmrk:`, where `:`76//! or an NFT on the chain. Scoped properties are prefixed with `rmrk:`, where `:`77//! is an unacceptable symbol in user-defined proeprties, which, along with other safeguards,77//! is an unacceptable symbol in user-defined proeprties, which, along with other safeguards,78//! makes them impossible to tamper with.78//! makes them impossible to tamper with.79//! 79//!80//! ### Collection and NFT Types80//! ### Collection and NFT Types81//! 81//!82//! RMRK introduces the concept of a Base, which is a catalgoue of Parts, 82//! RMRK introduces the concept of a Base, which is a catalgoue of Parts,83//! possible components of an NFT. Due to its similarity with the functionality83//! possible components of an NFT. Due to its similarity with the functionality84//! of a token collection, a Base is stored and handled as one, and the Base's Parts and Themes84//! of a token collection, a Base is stored and handled as one, and the Base's Parts and Themes85//! are the collection's NFTs. See [`CollectionType`](pallet_rmrk_core::misc::CollectionType) and 85//! are the collection's NFTs. See [`CollectionType`](pallet_rmrk_core::misc::CollectionType) and86//! [`NftType`](pallet_rmrk_core::misc::NftType).86//! [`NftType`](pallet_rmrk_core::misc::NftType).87//! 87//!88//! ## Interface88//! ## Interface89//! 89//!90//! ### Dispatchables90//! ### Dispatchables91//! 91//!92//! - `create_collection` - Create a new collection of NFTs.92//! - `create_collection` - Create a new collection of NFTs.93//! - `destroy_collection` - Destroy a collection.93//! - `destroy_collection` - Destroy a collection.94//! - `change_collection_issuer` - Change the issuer of a collection. 94//! - `change_collection_issuer` - Change the issuer of a collection.95//! Analogous to Unique's collection's [`owner`](up_data_structs::Collection).95//! Analogous to Unique's collection's [`owner`](up_data_structs::Collection).96//! - `lock_collection` - "Lock" the collection and prevent new token creation. **Cannot be undone.**96//! - `lock_collection` - "Lock" the collection and prevent new token creation. **Cannot be undone.**97//! - `mint_nft` - Mint an NFT in a specified collection.97//! - `mint_nft` - Mint an NFT in a specified collection.269 RmrkPropertyValueIsTooLong,269 RmrkPropertyValueIsTooLong,270 /// Could not find a property by the supplied key.270 /// Could not find a property by the supplied key.271 RmrkPropertyIsNotFound,271 RmrkPropertyIsNotFound,272 /// Something went wrong when decoding encoded data from the storage. 272 /// Something went wrong when decoding encoded data from the storage.273 /// Perhaps, there was a wrong key supplied for the type, or the data was improperly stored.273 /// Perhaps, there was a wrong key supplied for the type, or the data was improperly stored.274 UnableToDecodeRmrkData,274 UnableToDecodeRmrkData,275275290 CollectionFullOrLocked,290 CollectionFullOrLocked,291 /// No such resource found.291 /// No such resource found.292 ResourceDoesntExist,292 ResourceDoesntExist,293 /// If an NFT is sent to a descendant, that would form a nesting loop, an ouroboros. 293 /// If an NFT is sent to a descendant, that would form a nesting loop, an ouroboros.294 /// Sending to self is redundant.294 /// Sending to self is redundant.295 CannotSendToDescendentOrSelf,295 CannotSendToDescendentOrSelf,296 /// Not the target owner of the sent NFT.296 /// Not the target owner of the sent NFT.317 /// # Arguments:317 /// # Arguments:318 /// - `metadata`: Metadata describing the collection, e.g. IPFS hash. Cannot be changed.318 /// - `metadata`: Metadata describing the collection, e.g. IPFS hash. Cannot be changed.319 /// - `max`: Optional maximum number of tokens.319 /// - `max`: Optional maximum number of tokens.320 /// - `symbol`: UTF-8 string with token prefix, by which to represent the token in wallets and UIs. 320 /// - `symbol`: UTF-8 string with token prefix, by which to represent the token in wallets and UIs.321 /// Analogous to Unique's [`token_prefix`](up_data_structs::Collection). Cannot be changed.321 /// Analogous to Unique's [`token_prefix`](up_data_structs::Collection). Cannot be changed.322 #[transactional]322 #[transactional]323 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]323 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]383 Ok(())383 Ok(())384 }384 }385385386 /// Destroy a collection. 386 /// Destroy a collection.387 /// 387 ///388 /// Only empty collections can be destroyed. If it has any tokens, they must be burned first.388 /// Only empty collections can be destroyed. If it has any tokens, they must be burned first.389 ///389 ///390 /// # Permissions:390 /// # Permissions:419 }419 }420420421 /// Change the issuer of a collection. Analogous to Unique's collection's [`owner`](up_data_structs::Collection).421 /// Change the issuer of a collection. Analogous to Unique's collection's [`owner`](up_data_structs::Collection).422 /// 422 ///423 /// # Permissions:423 /// # Permissions:424 /// * Collection issuer424 /// * Collection issuer425 ///425 ///457 }457 }458458459 /// "Lock" the collection and prevent new token creation. Cannot be undone.459 /// "Lock" the collection and prevent new token creation. Cannot be undone.460 /// 460 ///461 /// # Permissions:461 /// # Permissions:462 /// * Collection issuer462 /// * Collection issuer463 ///463 ///498 ///498 ///499 /// # Permissions:499 /// # Permissions:500 /// * Collection issuer500 /// * Collection issuer501 /// 501 ///502 /// # Arguments:502 /// # Arguments:503 /// - `owner`: Owner account of the NFT. If set to None, defaults to the sender (collection issuer).503 /// - `owner`: Owner account of the NFT. If set to None, defaults to the sender (collection issuer).504 /// - `collection_id`: RMRK collection ID for the NFT to be minted within. Cannot be changed.504 /// - `collection_id`: RMRK collection ID for the NFT to be minted within. Cannot be changed.574 Ok(())574 Ok(())575 }575 }576576577 /// Burn an NFT, destroying it and its nested tokens up to the specified limit. 577 /// Burn an NFT, destroying it and its nested tokens up to the specified limit.578 /// If the burning budget is exceeded, the transaction is reverted.578 /// If the burning budget is exceeded, the transaction is reverted.579 /// 579 ///580 /// This is the way to burn a nested token as well.580 /// This is the way to burn a nested token as well.581 /// 581 ///582 /// For more information, see [`burn_recursively`](pallet_nonfungible::pallet::Pallet::burn_recursively).582 /// For more information, see [`burn_recursively`](pallet_nonfungible::pallet::Pallet::burn_recursively).583 /// 583 ///584 /// # Permissions:584 /// # Permissions:585 /// * Token owner585 /// * Token owner586 /// 586 ///587 /// # Arguments:587 /// # Arguments:588 /// - `collection_id`: RMRK ID of the collection in which the NFT to burn belongs to.588 /// - `collection_id`: RMRK ID of the collection in which the NFT to burn belongs to.589 /// - `nft_id`: ID of the NFT to be destroyed.589 /// - `nft_id`: ID of the NFT to be destroyed.590 /// - `max_burns`: Maximum number of tokens to burn, used for nesting. The transaction 590 /// - `max_burns`: Maximum number of tokens to burn, used for nesting. The transaction591 /// is reverted if there are more tokens to burn in the nesting tree than this number.591 /// is reverted if there are more tokens to burn in the nesting tree than this number.592 #[transactional]592 #[transactional]593 #[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]593 #[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]625625626 /// Transfer an NFT from an account/NFT A to another account/NFT B.626 /// Transfer an NFT from an account/NFT A to another account/NFT B.627 /// The token must be transferable. Nesting cannot occur deeper than the [`NESTING_BUDGET`].627 /// The token must be transferable. Nesting cannot occur deeper than the [`NESTING_BUDGET`].628 /// 628 ///629 /// If the target owner is an NFT owned by another account, then the NFT will enter629 /// If the target owner is an NFT owned by another account, then the NFT will enter630 /// the pending state and will have to be accepted by the other account.630 /// the pending state and will have to be accepted by the other account.631 ///631 ///632 /// # Permissions:632 /// # Permissions:633 /// - Token owner633 /// - Token owner634 /// 634 ///635 /// # Arguments:635 /// # Arguments:636 /// - `collection_id`: RMRK ID of the collection of the NFT to be transferred.636 /// - `collection_id`: RMRK ID of the collection of the NFT to be transferred.637 /// - `nft_id`: ID of the NFT to be transferred.637 /// - `nft_id`: ID of the NFT to be transferred.750 }750 }751751752 /// Accept an NFT sent from another account to self or an owned NFT.752 /// Accept an NFT sent from another account to self or an owned NFT.753 /// 753 ///754 /// The NFT in question must be pending, and, thus, be [sent](`crate::pallet::Call::send`) first.754 /// The NFT in question must be pending, and, thus, be [sent](`crate::pallet::Call::send`) first.755 /// 755 ///756 /// # Permissions:756 /// # Permissions:757 /// - Token-owner-to-be757 /// - Token-owner-to-be758 ///758 ///759 /// # Arguments:759 /// # Arguments:760 /// - `rmrk_collection_id`: RMRK collection ID of the NFT to be accepted.760 /// - `rmrk_collection_id`: RMRK collection ID of the NFT to be accepted.761 /// - `rmrk_nft_id`: ID of the NFT to be accepted.761 /// - `rmrk_nft_id`: ID of the NFT to be accepted.762 /// - `new_owner`: Either the sender's account ID or a sender-owned NFT, 762 /// - `new_owner`: Either the sender's account ID or a sender-owned NFT,763 /// whichever the accepted NFT was sent to.763 /// whichever the accepted NFT was sent to.764 #[transactional]764 #[transactional]765 #[pallet::weight(<SelfWeightOf<T>>::accept_nft())]765 #[pallet::weight(<SelfWeightOf<T>>::accept_nft())]842842843 /// Reject an NFT sent from another account to self or owned NFT.843 /// Reject an NFT sent from another account to self or owned NFT.844 /// The NFT in question will not be sent back and burnt instead.844 /// The NFT in question will not be sent back and burnt instead.845 /// 845 ///846 /// The NFT in question must be pending, and, thus, be [sent](`crate::pallet::Call::send`) first.846 /// The NFT in question must be pending, and, thus, be [sent](`crate::pallet::Call::send`) first.847 /// 847 ///848 /// # Permissions:848 /// # Permissions:849 /// - Token-owner-to-be-not849 /// - Token-owner-to-be-not850 /// 850 ///851 /// # Arguments:851 /// # Arguments:852 /// - `rmrk_collection_id`: RMRK ID of the NFT to be rejected.852 /// - `rmrk_collection_id`: RMRK ID of the NFT to be rejected.853 /// - `rmrk_nft_id`: ID of the NFT to be rejected.853 /// - `rmrk_nft_id`: ID of the NFT to be rejected.905 }905 }906906907 /// Accept the addition of a newly created pending resource to an existing NFT.907 /// Accept the addition of a newly created pending resource to an existing NFT.908 /// 908 ///909 /// This transaction is needed when a resource is created and assigned to an NFT909 /// This transaction is needed when a resource is created and assigned to an NFT910 /// by a non-owner, i.e. the collection issuer, with one of the 910 /// by a non-owner, i.e. the collection issuer, with one of the911 /// [`add_...` transactions](crate::pallet::Call::add_basic_resource).911 /// [`add_...` transactions](crate::pallet::Call::add_basic_resource).912 /// 912 ///913 /// # Permissions:913 /// # Permissions:914 /// - Token owner914 /// - Token owner915 ///915 ///960 }960 }961961962 /// Accept the removal of a removal-pending resource from an NFT.962 /// Accept the removal of a removal-pending resource from an NFT.963 /// 963 ///964 /// This transaction is needed when a non-owner, i.e. the collection issuer, 964 /// This transaction is needed when a non-owner, i.e. the collection issuer,965 /// requests a [removal](`crate::pallet::Call::remove_resource`) of a resource from an NFT.965 /// requests a [removal](`crate::pallet::Call::remove_resource`) of a resource from an NFT.966 /// 966 ///967 /// # Permissions:967 /// # Permissions:968 /// - Token owner968 /// - Token owner969 ///969 ///1036 Ok(())1036 Ok(())1037 }1037 }103810381039 /// Add or edit a custom user property, a key-value pair, describing the metadata 1039 /// Add or edit a custom user property, a key-value pair, describing the metadata1040 /// of a token or a collection, on either one of these.1040 /// of a token or a collection, on either one of these.1041 /// 1041 ///1042 /// Note that in this proxy implementation many details regarding RMRK are stored 1042 /// Note that in this proxy implementation many details regarding RMRK are stored1043 /// as scoped properties prefixed with "rmrk:", normally inaccessible 1043 /// as scoped properties prefixed with "rmrk:", normally inaccessible1044 /// to external transactions and RPCs.1044 /// to external transactions and RPCs.1045 /// 1045 ///1046 /// # Permissions:1046 /// # Permissions:1047 /// - Collection issuer - in case of collection property1047 /// - Collection issuer - in case of collection property1048 /// - Token owner - in case of NFT property1048 /// - Token owner - in case of NFT property111311131114 /// Set a different order of resource priorities for an NFT. Priorities can be used,1114 /// Set a different order of resource priorities for an NFT. Priorities can be used,1115 /// for example, for order of rendering.1115 /// for example, for order of rendering.1116 /// 1116 ///1117 /// Note that the priorities are not updated automatically, and are an empty vector1117 /// Note that the priorities are not updated automatically, and are an empty vector1118 /// by default. There is no pre-set definition for the order to be particular,1118 /// by default. There is no pre-set definition for the order to be particular,1119 /// it can be interpreted arbitrarily use-case by use-case.1119 /// it can be interpreted arbitrarily use-case by use-case.1120 /// 1120 ///1121 /// # Permissions:1121 /// # Permissions:1122 /// - Token owner1122 /// - Token owner1123 ///1123 ///1164 }1164 }116511651166 /// Create and set/propose a basic resource for an NFT.1166 /// Create and set/propose a basic resource for an NFT.1167 /// 1167 ///1168 /// A resource is considered a part of an NFT, an additional piece of metadata1168 /// A resource is considered a part of an NFT, an additional piece of metadata1169 /// usually serving to add a piece of media on top of the root metadata, be it1169 /// usually serving to add a piece of media on top of the root metadata, be it1170 /// a different wing on the root template bird or something entirely unrelated.1170 /// a different wing on the root template bird or something entirely unrelated.1171 /// A basic resource is the simplest, lacking a base or composables.1171 /// A basic resource is the simplest, lacking a base or composables.1172 /// 1172 ///1173 /// See RMRK docs for more information and examples.1173 /// See RMRK docs for more information and examples.1174 /// 1174 ///1175 /// # Permissions:1175 /// # Permissions:1176 /// - Collection issuer - if not the token owner, adding the resource will warrant 1176 /// - Collection issuer - if not the token owner, adding the resource will warrant1177 /// the owner's [acceptance](crate::pallet::Call::accept_resource).1177 /// the owner's [acceptance](crate::pallet::Call::accept_resource).1178 ///1178 ///1179 /// # Arguments:1179 /// # Arguments:1210 }1210 }121112111212 /// Create and set/propose a composable resource for an NFT.1212 /// Create and set/propose a composable resource for an NFT.1213 /// 1213 ///1214 /// A resource is considered a part of an NFT, an additional piece of metadata1214 /// A resource is considered a part of an NFT, an additional piece of metadata1215 /// usually serving to add a piece of media on top of the root metadata, be it1215 /// usually serving to add a piece of media on top of the root metadata, be it1216 /// a different wing on the root template bird or something entirely unrelated.1216 /// a different wing on the root template bird or something entirely unrelated.1217 /// A composable resource links to a base and has a subset of its parts it is composed of.1217 /// A composable resource links to a base and has a subset of its parts it is composed of.1218 /// 1218 ///1219 /// See RMRK docs for more information and examples.1219 /// See RMRK docs for more information and examples.1220 /// 1220 ///1221 /// # Permissions:1221 /// # Permissions:1222 /// - Collection issuer - if not the token owner, adding the resource will warrant 1222 /// - Collection issuer - if not the token owner, adding the resource will warrant1223 /// the owner's [acceptance](crate::pallet::Call::accept_resource).1223 /// the owner's [acceptance](crate::pallet::Call::accept_resource).1224 ///1224 ///1225 /// # Arguments:1225 /// # Arguments:1276 }1276 }127712771278 /// Create and set/propose a slot resource for an NFT.1278 /// Create and set/propose a slot resource for an NFT.1279 /// 1279 ///1280 /// A resource is considered a part of an NFT, an additional piece of metadata1280 /// A resource is considered a part of an NFT, an additional piece of metadata1281 /// usually serving to add a piece of media on top of the root metadata, be it1281 /// usually serving to add a piece of media on top of the root metadata, be it1282 /// a different wing on the root template bird or something entirely unrelated.1282 /// a different wing on the root template bird or something entirely unrelated.1283 /// A slot resource links to a base and a slot in it which it now occupies.1283 /// A slot resource links to a base and a slot in it which it now occupies.1284 /// 1284 ///1285 /// See RMRK docs for more information and examples.1285 /// See RMRK docs for more information and examples.1286 /// 1286 ///1287 /// # Permissions:1287 /// # Permissions:1288 /// - Collection issuer - if not the token owner, adding the resource will warrant 1288 /// - Collection issuer - if not the token owner, adding the resource will warrant1289 /// the owner's [acceptance](crate::pallet::Call::accept_resource).1289 /// the owner's [acceptance](crate::pallet::Call::accept_resource).1290 ///1290 ///1291 /// # Arguments:1291 /// # Arguments:1322 }1322 }132313231324 /// Remove and erase a resource from an NFT.1324 /// Remove and erase a resource from an NFT.1325 /// 1325 ///1326 /// If the sender does not own the NFT, then it will be pending confirmation,1326 /// If the sender does not own the NFT, then it will be pending confirmation,1327 /// and will have to be [accepted](crate::pallet::Call::accept_resource_removal) by the token owner.1327 /// and will have to be [accepted](crate::pallet::Call::accept_resource_removal) by the token owner.1328 /// 1328 ///1329 /// # Permissions1329 /// # Permissions1330 /// - Collection issuer1330 /// - Collection issuer1331 /// 1331 ///1332 /// # Arguments1332 /// # Arguments1333 /// - `collection_id`: RMRK ID of a collection to which the NFT making use of the resource belongs to.1333 /// - `collection_id`: RMRK ID of a collection to which the NFT making use of the resource belongs to.1334 /// - `nft_id`: ID of the NFT with a resource to be removed.1334 /// - `nft_id`: ID of the NFT with a resource to be removed.1371 Ok(scoped_key)1371 Ok(scoped_key)1372 }1372 }137313731374 /// Form a Unique property, transforming a RMRK key into bytes (without assigning the scope yet) 1374 /// Form a Unique property, transforming a RMRK key into bytes (without assigning the scope yet)1375 /// and encoding the value from an arbitrary type into bytes.1375 /// and encoding the value from an arbitrary type into bytes.1376 pub fn encode_rmrk_property<E: Encode>(1376 pub fn encode_rmrk_property<E: Encode>(1377 rmrk_key: RmrkProperty,1377 rmrk_key: RmrkProperty,1416 }1416 }141714171418 /// Initialize a new NFT collection with certain RMRK-scoped properties.1418 /// Initialize a new NFT collection with certain RMRK-scoped properties.1419 /// 1419 ///1420 /// See [`init_collection`](pallet_nonfungible::pallet::Pallet::init_collection) for more details.1420 /// See [`init_collection`](pallet_nonfungible::pallet::Pallet::init_collection) for more details.1421 fn init_collection(1421 fn init_collection(1422 sender: T::CrossAccountId,1422 sender: T::CrossAccountId,1439 }1439 }144014401441 /// Mint a new NFT with certain RMRK-scoped properties. Sender must be the collection owner.1441 /// Mint a new NFT with certain RMRK-scoped properties. Sender must be the collection owner.1442 /// 1442 ///1443 /// See [`create_item`](pallet_nonfungible::pallet::Pallet::create_item) for more details.1443 /// See [`create_item`](pallet_nonfungible::pallet::Pallet::create_item) for more details.1444 pub fn create_nft(1444 pub fn create_nft(1445 sender: &T::CrossAccountId,1445 sender: &T::CrossAccountId,1469 }1464 }147014651471 /// Burn an NFT, along with its nested children, limited by `max_burns`. The sender must be the token owner.1466 /// Burn an NFT, along with its nested children, limited by `max_burns`. The sender must be the token owner.1472 /// 1467 ///1473 /// See [`burn_recursively`](pallet_nonfungible::pallet::Pallet::burn_recursively) for more details.1468 /// See [`burn_recursively`](pallet_nonfungible::pallet::Pallet::burn_recursively) for more details.1474 fn destroy_nft(1469 fn destroy_nft(1475 sender: T::CrossAccountId,1470 sender: T::CrossAccountId,1531 })1526 })1532 }1527 }153315281534 /// Apply a mutation to the property of a token containing sent tokens 1529 /// Apply a mutation to the property of a token containing sent tokens1535 /// that are currently pending acceptance.1530 /// that are currently pending acceptance.1536 fn mutate_pending_children(1531 fn mutate_pending_children(1537 (target_collection_id, target_nft_id): (CollectionId, TokenId),1532 (target_collection_id, target_nft_id): (CollectionId, TokenId),1557 )1552 )1558 }1553 }155915541560 /// Get an iterator from a token's property containing tokens sent to it 1555 /// Get an iterator from a token's property containing tokens sent to it1561 /// that are currently pending acceptance.1556 /// that are currently pending acceptance.1562 fn iterate_pending_children(1557 fn iterate_pending_children(1563 collection_id: CollectionId,1558 collection_id: CollectionId,1601 Ok(resource_id)1596 Ok(resource_id)1602 }1597 }160315981604 /// Create and add a resource for a regular NFT, mark it as pending if the sender 1599 /// Create and add a resource for a regular NFT, mark it as pending if the sender1605 /// is not the token owner. The sender must be the collection owner.1600 /// is not the token owner. The sender must be the collection owner.1606 fn resource_add(1601 fn resource_add(1607 sender: T::AccountId,1602 sender: T::AccountId,1698 Ok(())1693 Ok(())1699 }1694 }170016951701 /// Remove one usage of a base from an NFT's property of associated bases. The base will stay, however, 1696 /// Remove one usage of a base from an NFT's property of associated bases. The base will stay, however,1702 /// if the count of resources using the base is still non-zero.1697 /// if the count of resources using the base is still non-zero.1703 fn remove_associated_base_id(1698 fn remove_associated_base_id(1704 collection_id: CollectionId,1699 collection_id: CollectionId,1843 }1838 }184418391845 /// Get the type of a collection stored in it as a scoped property.1840 /// Get the type of a collection stored in it as a scoped property.1846 /// 1841 ///1847 /// RMRK Core proxy differentiates between regular collections as well as RMRK bases as collections.1842 /// RMRK Core proxy differentiates between regular collections as well as RMRK bases as collections.1848 pub fn get_collection_type(1843 pub fn get_collection_type(1849 collection_id: CollectionId,1844 collection_id: CollectionId,1882 Self::get_nft_collection(collection_id)1877 Self::get_nft_collection(collection_id)1883 }1878 }188418791885 /// Same as [`get_typed_nft_collection`](crate::pallet::Pallet::get_typed_nft_collection), 1880 /// Same as [`get_typed_nft_collection`](crate::pallet::Pallet::get_typed_nft_collection),1886 /// but also return the Unique collection ID.1881 /// but also return the Unique collection ID.1887 pub fn get_typed_nft_collection_mapped(1882 pub fn get_typed_nft_collection_mapped(1888 rmrk_collection_id: RmrkCollectionId,1883 rmrk_collection_id: RmrkCollectionId,1927 }1922 }192819231929 /// Get the type of an NFT stored in it as a scoped property.1924 /// Get the type of an NFT stored in it as a scoped property.1930 /// 1925 ///1931 /// RMRK Core proxy differentiates between regular NFTs, and RMRK parts and themes.1926 /// RMRK Core proxy differentiates between regular NFTs, and RMRK parts and themes.1932 pub fn get_nft_type(1927 pub fn get_nft_type(1933 collection_id: CollectionId,1928 collection_id: CollectionId,1949 Ok(())1944 Ok(())1950 }1945 }195119461952 /// Ensure that an account is the owner of the token, either directly 1947 /// Ensure that an account is the owner of the token, either directly1953 /// or at the top of the nesting hierarchy; return an error if it is not.1948 /// or at the top of the nesting hierarchy; return an error if it is not.1954 pub fn ensure_nft_owner(1949 pub fn ensure_nft_owner(1955 collection_id: CollectionId,1950 collection_id: CollectionId,1971 Ok(())1966 Ok(())1972 }1967 }197319681974 /// Fetch non-scoped properties of a collection or a token that match the filter keys supplied, 1969 /// Fetch non-scoped properties of a collection or a token that match the filter keys supplied,1975 /// or, if None are provided, return all non-scoped properties.1970 /// or, if None are provided, return all non-scoped properties.1976 pub fn filter_user_properties<Key, Value, R, Mapper>(1971 pub fn filter_user_properties<Key, Value, R, Mapper>(1977 collection_id: CollectionId,1972 collection_id: CollectionId,2018 })2013 })2019 }2014 }202020152021 /// Get all non-scoped properties from a collection or a token, and apply some transformation 2016 /// Get all non-scoped properties from a collection or a token, and apply some transformation2022 /// to each key-value pair.2017 /// to each key-value pair.2023 pub fn iterate_user_properties<Key, Value, R, Mapper>(2018 pub fn iterate_user_properties<Key, Value, R, Mapper>(2024 collection_id: CollectionId,2019 collection_id: CollectionId,pallets/proxy-rmrk-core/src/misc.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/misc.rs
+++ b/pallets/proxy-rmrk-core/src/misc.rs
@@ -19,7 +19,7 @@
use super::*;
use codec::{Encode, Decode, Error};
-/// Match errors from one type to another and return an error
+/// Match errors from one type to another and return an error
/// if a match is successful.
#[macro_export]
macro_rules! map_unique_err_to_proxy {
pallets/proxy-rmrk-core/src/property.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/property.rs
+++ b/pallets/proxy-rmrk-core/src/property.rs
@@ -24,7 +24,7 @@
pub const RESOURCE_ID_PREFIX: &str = "rsid-";
/// Property prefix for storing custom user-defined properties.
pub const USER_PROPERTY_PREFIX: &str = "userprop-";
-/// Property scope for RMRK, used to signify that this property
+/// Property scope for RMRK, used to signify that this property
/// was created and is used by RMRK.
pub const RMRK_SCOPE: PropertyScope = PropertyScope::Rmrk;
pallets/proxy-rmrk-core/src/rpc.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/rpc.rs
+++ b/pallets/proxy-rmrk-core/src/rpc.rs
@@ -104,7 +104,6 @@
}))
}
-
/// Get tokens owned by an account in a collection.
pub fn account_tokens<T: Config>(
account_id: T::AccountId,
pallets/proxy-rmrk-equip/src/lib.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-equip/src/lib.rs
+++ b/pallets/proxy-rmrk-equip/src/lib.rs
@@ -15,83 +15,83 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
//! # RMRK Core Proxy Pallet
-//!
+//!
//! A pallet used as proxy for RMRK Core (<https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-core>).
-//!
+//!
//! - [`Config`]
//! - [`Call`]
//! - [`Pallet`]
-//!
+//!
//! ## Overview
-//!
-//! The RMRK Equip Proxy pallet mirrors the functionality of RMRK Equip,
+//!
+//! The RMRK Equip Proxy pallet mirrors the functionality of RMRK Equip,
//! binding its externalities to Unique's own underlying structure.
//! It is purposed to mimic RMRK Equip exactly, allowing seamless integrations
//! of solutions based on RMRK.
-//!
+//!
//! RMRK Equip itself contains functionality to equip NFTs, and work with Bases,
//! Parts, and Themes.
-//!
-//! Equip Proxy is responsible for a more specific area of RMRK, and heavily relies on the Core.
+//!
+//! Equip Proxy is responsible for a more specific area of RMRK, and heavily relies on the Core.
//! For a more foundational description of proxy implementation, please refer to [`pallet_rmrk_core`].
-//!
+//!
//! *Note*, that while RMRK itself is subject to active development and restructuring,
//! the proxy may be caught temporarily out of date.
-//!
+//!
//! ### What is RMRK?
-//!
-//! RMRK is a set of NFT standards which compose several "NFT 2.0 lego" primitives.
+//!
+//! RMRK is a set of NFT standards which compose several "NFT 2.0 lego" primitives.
//! Putting these legos together allows a user to create NFT systems of arbitrary complexity.
-//!
+//!
//! Meaning, RMRK NFTs are dynamic, able to nest into each other and form a hierarchy,
-//! make use of specific changeable and partially shared metadata in the form of resources,
+//! make use of specific changeable and partially shared metadata in the form of resources,
//! and more.
-//!
+//!
//! Visit RMRK documentation and repositories to learn more:
//! - Docs: <https://docs.rmrk.app/getting-started/>
//! - FAQ: <https://coda.io/@rmrk/faq>
//! - Substrate code repository: <https://github.com/rmrk-team/rmrk-substrate>
//! - RMRK spec repository: <https://github.com/rmrk-team/rmrk-spec>
-//!
+//!
//! ## Proxy Implementation
-//!
+//!
//! An external user is supposed to be able to utilize this proxy as they would
//! utilize RMRK, and get exactly the same results. Normally, Unique transactions
//! are off-limits to RMRK collections and tokens, and vice versa. However,
//! the information stored on chain can be freely interpreted by storage reads and RPCs.
-//!
+//!
//! ### ID Mapping
-//!
+//!
//! RMRK's collections' IDs are counted independently of Unique's and start at 0.
//! Note that tokens' IDs still start at 1.
//! The collections themselves, as well as tokens, are stored as Unique collections,
//! and thus RMRK IDs are mapped to Unique IDs (but not vice versa).
-//!
+//!
//! ### External/Internal Collection Insulation
-//!
+//!
//! A Unique transaction cannot target collections purposed for RMRK,
-//! and they are flagged as `external` to specify that. On the other hand,
+//! and they are flagged as `external` to specify that. On the other hand,
//! due to the mapping, RMRK transactions and RPCs simply cannot reach Unique collections.
-//!
+//!
//! ### Native Properties
-//!
-//! Many of RMRK's native parameters are stored as scoped properties of a collection
+//!
+//! Many of RMRK's native parameters are stored as scoped properties of a collection
//! or an NFT on the chain. Scoped properties are prefixed with `rmrk:`, where `:`
//! is an unacceptable symbol in user-defined proeprties, which, along with other safeguards,
//! makes them impossible to tamper with.
-//!
+//!
//! ### Collection and NFT Types
-//!
-//! RMRK introduces the concept of a Base, which is a catalgoue of Parts,
+//!
+//! RMRK introduces the concept of a Base, which is a catalgoue of Parts,
//! possible components of an NFT. Due to its similarity with the functionality
//! of a token collection, a Base is stored and handled as one, and the Base's Parts and Themes
-//! are the collection's NFTs. See [`CollectionType`](pallet_rmrk_core::misc::CollectionType) and
+//! are the collection's NFTs. See [`CollectionType`](pallet_rmrk_core::misc::CollectionType) and
//! [`NftType`](pallet_rmrk_core::misc::NftType).
-//!
+//!
//! ## Interface
-//!
+//!
//! ### Dispatchables
-//!
+//!
//! - `create_base` - Create a new Base.
//! - `theme_add` - Add a Theme to a Base.
//! - `equippable` - Update the array of Collections allowed to be equipped to a Base's specified Slot Part.
@@ -184,16 +184,16 @@
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Create a new Base.
- ///
+ ///
/// Modeled after the [base interaction](https://github.com/rmrk-team/rmrk-spec/blob/master/standards/rmrk2.0.0/interactions/base.md)
- ///
+ ///
/// # Permissions
/// - Anyone - will be assigned as the issuer of the base.
///
/// # Arguments:
/// - `base_type`: Arbitrary media type, e.g. "svg".
/// - `symbol`: Arbitrary client-chosen symbol.
- /// - `parts`: Array of Fixed and Slot parts composing the base,
+ /// - `parts`: Array of Fixed and Slot parts composing the base,
/// confined in length by [`RmrkPartsLimit`](up_data_structs::RmrkPartsLimit).
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::create_base(parts.len() as u32))]
@@ -228,7 +228,10 @@
collection_id,
PropertyScope::Rmrk,
[
- <PalletCore<T>>::encode_rmrk_property(CollectionType, &misc::CollectionType::Base)?,
+ <PalletCore<T>>::encode_rmrk_property(
+ CollectionType,
+ &misc::CollectionType::Base,
+ )?,
<PalletCore<T>>::encode_rmrk_property(BaseType, &base_type)?,
]
.into_iter(),
@@ -250,12 +253,12 @@
/// Add a Theme to a Base.
/// A Theme named "default" is required prior to adding other Themes.
- ///
+ ///
/// Modeled after [themeadd interaction](https://github.com/rmrk-team/rmrk-spec/blob/master/standards/rmrk2.0.0/interactions/themeadd.md).
///
/// # Permissions:
/// - Base issuer
- ///
+ ///
/// # Arguments:
/// - `base_id`: Base ID containing the Theme to be updated.
/// - `theme`: Theme to add to the Base. A Theme has a name and properties, which are an
@@ -314,12 +317,12 @@
}
/// Update the array of Collections allowed to be equipped to a Base's specified Slot Part.
- ///
+ ///
/// Modeled after [equippable interaction](https://github.com/rmrk-team/rmrk-spec/blob/master/standards/rmrk2.0.0/interactions/equippable.md).
///
/// # Permissions:
/// - Base issuer
- ///
+ ///
/// # Arguments:
/// - `base_id`: Base containing the Slot Part to be updated.
/// - `part_id`: Slot Part whose Equippable List is being updated.