git.delta.rocks / unique-network / refs/commits / 0e74039449d0

difftreelog

doc(rmrk): adjusted for clarity

Farhad Hakimov2022-07-22parent: #287a010.patch.diff
in: master

4 files changed

modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -48,7 +48,43 @@
 //! - 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>
+//! - RMRK specification repository: <https://github.com/rmrk-team/rmrk-spec>
+//! 
+//! ## Terminology
+//! 
+//! For more information on RMRK, see RMRK's own documentation.
+//! 
+//! ### Intro to RMRK
+//! 
+//! - **Resource:** Additional piece of metadata of an NFT usually serving to add 
+//! a piece of media on top of the root metadata (NFT's own), be it a different wing 
+//! on the root template bird or something entirely unrelated.
+//! 
+//! - **Base:** A list of possible "components" - Parts, a combination of which can 
+//! be appended/equipped to/on an NFT.
+//! 
+//! - **Part:** Something that, together with other Parts, can constitute an NFT. 
+//! Parts are defined in the Base to which they belong. Parts can be either 
+//! of the `slot` type or `fixed` type. Slots are intended for equippables.
+//! Note that "part of something" and "Part of a Base" can be easily confused, 
+//! and in this documentation these words are distinguished by the capital letter.
+//! 
+//! - **Theme:** Named objects of variable => value pairs which get interpolated into 
+//! the Base's `themable` Parts. Themes can hold any value, but are often represented 
+//! in RMRK's examples as colors applied to visible Parts.
+//! 
+//! ### Peculiarities in Unique
+//! 
+//! - **Scoped properties:** Properties that are normally obscured from users. 
+//! Their purpose is to contain structured metadata that was not included in the Unique standard 
+//! for collections and tokens, meant to be operated on by proxies and other outliers. 
+//! Scoped properties are prefixed with `some-scope:`, where `some-scope` is 
+//! an arbitrary keyword, like "rmrk", and `:` is an unacceptable symbol in user-defined 
+//! properties, which, along with other safeguards, makes them impossible to tamper with.
+//! 
+//! - **Auxiliary properties:** A slightly different structure of properties, 
+//! trading universality of use for more convenient storage, writes and access. 
+//! Meant to be inaccessible to end users.
 //!
 //! ## Proxy Implementation
 //!
@@ -74,17 +110,17 @@
 //!
 //! 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,
+//! is an unacceptable symbol in user-defined properties, which, along with other safeguards,
 //! makes them impossible to tamper with.
 //!
-//! ### Collection and NFT Types
+//! ### Collection and NFT Types, and Base, Parts and Themes Handling
 //!
 //! 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
 //! [`NftType`](pallet_rmrk_core::misc::NftType).
-//!
+//! 
 //! ## Interface
 //!
 //! ### Dispatchables
@@ -276,9 +312,9 @@
 		/* RMRK compatible events */
 		/// Only destroying collections without tokens is allowed.
 		CollectionNotEmpty,
-		/// Could not find an ID for a collection. It is likely there were too many collections created on the chain.
+		/// Could not find an ID for a collection. It is likely there were too many collections created on the chain, causing an overflow.
 		NoAvailableCollectionId,
-		/// Token does not exist, or there is no suitable ID for it, likely too many tokens were created in a collection.
+		/// Token does not exist, or there is no suitable ID for it, likely too many tokens were created in a collection, causing an overflow.
 		NoAvailableNftId,
 		/// Collection does not exist, has a wrong type, or does not map to a Unique ID.
 		CollectionUnknown,
@@ -301,7 +337,7 @@
 		CannotRejectNonPendingNft,
 		/// Resource is not pending for the operation.
 		ResourceNotPending,
-		/// Could not find an ID for the resource. Is is likely there were too many resources created on an NFT.
+		/// Could not find an ID for the resource. It is likely there were too many resources created on an NFT, causing an overflow.
 		NoAvailableResourceId,
 	}
 
@@ -587,8 +623,9 @@
 		/// # Arguments:
 		/// - `collection_id`: RMRK ID of the collection in which the NFT to burn belongs to.
 		/// - `nft_id`: ID of the NFT to be destroyed.
-		/// - `max_burns`: Maximum number of tokens to burn, used for nesting. The transaction
+		/// - `max_burns`: Maximum number of tokens to burn, assuming nesting. The transaction
 		/// is reverted if there are more tokens to burn in the nesting tree than this number.
+		/// This is primarily a mechanism of transaction weight control.
 		#[transactional]
 		#[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]
 		pub fn burn_nft(
@@ -1165,11 +1202,7 @@
 
 		/// Create and set/propose a basic resource for an NFT.
 		///
-		/// A resource is considered a part of an NFT, an additional piece of metadata
-		/// usually serving to add a piece of media on top of the root metadata, be it
-		/// a different wing on the root template bird or something entirely unrelated.
-		/// A basic resource is the simplest, lacking a base or composables.
-		///
+		/// A basic resource is the simplest, lacking a Base and anything that comes with it.
 		/// See RMRK docs for more information and examples.
 		///
 		/// # Permissions:
@@ -1211,11 +1244,7 @@
 
 		/// Create and set/propose a composable resource for an NFT.
 		///
-		/// A resource is considered a part of an NFT, an additional piece of metadata
-		/// usually serving to add a piece of media on top of the root metadata, be it
-		/// a different wing on the root template bird or something entirely unrelated.
-		/// A composable resource links to a base and has a subset of its parts it is composed of.
-		///
+		/// A composable resource links to a Base and has a subset of its Parts it is composed of.
 		/// See RMRK docs for more information and examples.
 		///
 		/// # Permissions:
@@ -1277,11 +1306,7 @@
 
 		/// Create and set/propose a slot resource for an NFT.
 		///
-		/// A resource is considered a part of an NFT, an additional piece of metadata
-		/// usually serving to add a piece of media on top of the root metadata, be it
-		/// a different wing on the root template bird or something entirely unrelated.
-		/// A slot resource links to a base and a slot in it which it now occupies.
-		///
+		/// A slot resource links to a Base and a slot ID in it which it can fit into.
 		/// See RMRK docs for more information and examples.
 		///
 		/// # Permissions:
@@ -1575,6 +1600,8 @@
 
 	/// Get incremented resource ID from within an NFT's properties and store the new latest ID.
 	/// Thus, the returned resource ID should be used.
+	/// 
+	/// Resource IDs are unique only across an NFT.
 	fn acquire_next_resource_id(
 		collection_id: CollectionId,
 		nft_id: TokenId,
@@ -1693,8 +1720,8 @@
 		Ok(())
 	}
 
-	/// Remove one usage of a base from an NFT's property of associated bases. The base will stay, however,
-	/// if the count of resources using the base is still non-zero.
+	/// Remove a Base ID from an NFT if they are associated. 
+	/// The Base itself is deleted if the number of associated NFTs reaches 0.
 	fn remove_associated_base_id(
 		collection_id: CollectionId,
 		nft_id: TokenId,
@@ -1837,9 +1864,9 @@
 		Self::decode_property_value(&Self::get_collection_property(collection_id, key)?)
 	}
 
-	/// Get the type of a collection stored in it as a scoped property.
+	/// Get the type of a collection stored as a scoped property.
 	///
-	/// RMRK Core proxy differentiates between regular collections as well as RMRK bases as collections.
+	/// RMRK Core proxy differentiates between regular collections as well as RMRK Bases as collections.
 	pub fn get_collection_type(
 		collection_id: CollectionId,
 	) -> Result<misc::CollectionType, DispatchError> {
@@ -1921,9 +1948,9 @@
 		<TokenData<T>>::contains_key((collection_id, nft_id))
 	}
 
-	/// Get the type of an NFT stored in it as a scoped property.
+	/// Get the type of an NFT stored as a scoped property.
 	///
-	/// RMRK Core proxy differentiates between regular NFTs, and RMRK parts and themes.
+	/// RMRK Core proxy differentiates between regular NFTs, and RMRK Parts and Themes.
 	pub fn get_nft_type(
 		collection_id: CollectionId,
 		token_id: TokenId,
@@ -2013,8 +2040,8 @@
 			})
 	}
 
-	/// Get all non-scoped properties from a collection or a token, and apply some transformation
-	/// to each key-value pair.
+	/// Get all non-scoped properties from a collection or a token, and apply some transformation,
+	/// supplied by `mapper`, to each key-value pair.
 	pub fn iterate_user_properties<Key, Value, R, Mapper>(
 		collection_id: CollectionId,
 		token_id: Option<TokenId>,
modifiedpallets/proxy-rmrk-core/src/rpc.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/rpc.rs
+++ b/pallets/proxy-rmrk-core/src/rpc.rs
@@ -224,7 +224,7 @@
 	Ok(properties)
 }
 
-/// Get data of resources of an NFT.
+/// Get full information on each resource of an NFT, including pending.
 pub fn nft_resources<T: Config>(
 	collection_id: RmrkCollectionId,
 	nft_id: RmrkNftId,
modifiedpallets/proxy-rmrk-equip/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-equip/src/lib.rs
+++ b/pallets/proxy-rmrk-equip/src/lib.rs
@@ -30,7 +30,7 @@
 //! of solutions based on RMRK.
 //!
 //! RMRK Equip itself contains functionality to equip NFTs, and work with Bases,
-//! Parts, and Themes.
+//! Parts, and Themes. See [Proxy Implementation](#proxy-implementation) for details.
 //!
 //! 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`].
@@ -52,6 +52,42 @@
 //! - 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>
+//! 
+//! ## Terminology
+//! 
+//! For more information on RMRK, see RMRK's own documentation.
+//! 
+//! ### Intro to RMRK
+//! 
+//! - **Resource:** Additional piece of metadata of an NFT usually serving to add 
+//! a piece of media on top of the root metadata (NFT's own), be it a different wing 
+//! on the root template bird or something entirely unrelated.
+//! 
+//! - **Base:** A list of possible "components" - Parts, a combination of which can 
+//! be appended/equipped to/on an NFT.
+//! 
+//! - **Part:** Something that, together with other Parts, can constitute an NFT. 
+//! Parts are defined in the Base to which they belong. Parts can be either 
+//! of the `slot` type or `fixed` type. Slots are intended for equippables.
+//! Note that "part of something" and "Part of a Base" can be easily confused, 
+//! and in this documentation these words are distinguished by the capital letter.
+//! 
+//! - **Theme:** Named objects of variable => value pairs which get interpolated into 
+//! the Base's `themable` Parts. Themes can hold any value, but are often represented 
+//! in RMRK's examples as colors applied to visible Parts.
+//! 
+//! ### Peculiarities in Unique
+//! 
+//! - **Scoped properties:** Properties that are normally obscured from users. 
+//! Their purpose is to contain structured metadata that was not included in the Unique standard 
+//! for collections and tokens, meant to be operated on by proxies and other outliers. 
+//! Scoped properties are prefixed with `some-scope:`, where `some-scope` is 
+//! an arbitrary keyword, like "rmrk", and `:` is an unacceptable symbol in user-defined 
+//! properties, which, along with other safeguards, makes them impossible to tamper with.
+//! 
+//! - **Auxiliary properties:** A slightly different structure of properties, 
+//! trading universality of use for more convenient storage, writes and access. 
+//! Meant to be inaccessible to end users.
 //!
 //! ## Proxy Implementation
 //!
@@ -77,10 +113,10 @@
 //!
 //! 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,
+//! is an unacceptable symbol in user-defined properties, which, along with other safeguards,
 //! makes them impossible to tamper with.
 //!
-//! ### Collection and NFT Types
+//! ### Collection and NFT Types, and Base, Parts and Themes Handling
 //!
 //! 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
@@ -134,13 +170,13 @@
 		type WeightInfo: WeightInfo;
 	}
 
-	/// Map of a base ID and a part ID to an NFT in the base collection serving as the part.
+	/// Map of a Base ID and a Part ID to an NFT in the Base collection serving as the Part.
 	#[pallet::storage]
 	#[pallet::getter(fn internal_part_id)]
 	pub type InernalPartId<T: Config> =
 		StorageDoubleMap<_, Twox64Concat, CollectionId, Twox64Concat, RmrkPartId, TokenId>;
 
-	/// Checkmark that a base has a Theme NFT named "default".
+	/// Checkmark that a Base has a Theme NFT named "default".
 	#[pallet::storage]
 	#[pallet::getter(fn base_has_default_theme)]
 	pub type BaseHasDefaultTheme<T: Config> =
@@ -167,17 +203,17 @@
 	pub enum Error<T> {
 		/// No permission to perform action.
 		PermissionError,
-		/// Could not find an ID for a base collection. It is likely there were too many collections created on the chain.
+		/// Could not find an ID for a Base collection. It is likely there were too many collections created on the chain, causing an overflow.
 		NoAvailableBaseId,
-		/// Could not find a suitable ID for a part, likely too many part tokens were created in the base.
+		/// Could not find a suitable ID for a Part, likely too many Part tokens were created in the Base, causing an overflow
 		NoAvailablePartId,
 		/// Base collection linked to this ID does not exist.
 		BaseDoesntExist,
-		/// No theme named "default" is associated with the Base.
+		/// No Theme named "default" is associated with the Base.
 		NeedsDefaultThemeFirst,
 		/// Part linked to this ID does not exist.
 		PartDoesntExist,
-		/// Cannot assign equippables to a fixed part.
+		/// Cannot assign equippables to a fixed Part.
 		NoEquippableOnFixedPart,
 	}
 
@@ -185,15 +221,15 @@
 	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)
+		/// 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.
+		/// - 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))]
@@ -254,7 +290,7 @@
 		/// 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).
+		/// Modeled after [Themeadd interaction](https://github.com/rmrk-team/rmrk-spec/blob/master/standards/rmrk2.0.0/interactions/themeadd.md).
 		///
 		/// # Permissions:
 		/// - Base issuer
@@ -379,8 +415,7 @@
 }
 
 impl<T: Config> Pallet<T> {
-	/// Create or renew an NFT serving as a part, setting its properties
-	/// to those of the part.
+	/// Create or renew an NFT serving as a Part.
 	fn create_part(
 		sender: &T::CrossAccountId,
 		collection: &NonfungibleHandle<T>,
@@ -444,7 +479,7 @@
 		Ok(())
 	}
 
-	/// Ensure that the collection under the base ID is a base collection,
+	/// Ensure that the collection under the Base ID is a Base collection,
 	/// and fetch it.
 	fn get_base(base_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {
 		let collection =
modifiedprimitives/rmrk-traits/src/resource.rsdiffbeforeafterboth
before · primitives/rmrk-traits/src/resource.rs
1// Copyright (C) 2021-2022 RMRK2// This file is part of rmrk-substrate.3// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE45use codec::{Decode, Encode, MaxEncodedLen};6use scale_info::TypeInfo;78#[cfg(feature = "std")]9use serde::Serialize;1011#[cfg(feature = "std")]12use crate::serialize;1314use crate::primitives::*;1516#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]17#[cfg_attr(feature = "std", derive(Serialize))]18#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]19pub struct BasicResource<BoundedString> {20	/// If the resource is Media, the base property is absent. Media src should be a URI like an21	/// IPFS hash.22	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]23	pub src: Option<BoundedString>,2425	/// Reference to IPFS location of metadata26	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]27	pub metadata: Option<BoundedString>,2829	/// Optional location or identier of license30	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]31	pub license: Option<BoundedString>,3233	/// If the resource has the thumb property, this will be a URI to a thumbnail of the given34	/// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is35	/// complex and too detailed to show in a search-results page or a list. Also, if a bird owns36	/// another bird, showing the full render of one bird inside the other's inventory might be a37	/// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an38	/// image that is lighter and faster to load but representative of this resource.39	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]40	pub thumb: Option<BoundedString>,41}4243#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]44#[cfg_attr(feature = "std", derive(Serialize))]45#[cfg_attr(46	feature = "std",47	serde(bound = r#"48			BoundedString: AsRef<[u8]>,49			BoundedParts: AsRef<[PartId]>50		"#)51)]52pub struct ComposableResource<BoundedString, BoundedParts> {53	/// If a resource is composed, it will have an array of parts that compose it54	#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]55	pub parts: BoundedParts,5657	/// A Base is uniquely identified by the combination of the word `base`, its minting block58	/// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.59	/// base-4477293-kanaria_superbird.60	pub base: BaseId,6162	/// If the resource is Media, the base property is absent. Media src should be a URI like an63	/// IPFS hash.64	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]65	pub src: Option<BoundedString>,6667	/// Reference to IPFS location of metadata68	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]69	pub metadata: Option<BoundedString>,7071	/// If the resource has the slot property, it was designed to fit into a specific Base's slot.72	/// The baseslot will be composed of two dot-delimited values, like so:73	/// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is74	/// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird7576	/// Optional location or identier of license77	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]78	pub license: Option<BoundedString>,7980	/// If the resource has the thumb property, this will be a URI to a thumbnail of the given81	/// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is82	/// complex and too detailed to show in a search-results page or a list. Also, if a bird owns83	/// another bird, showing the full render of one bird inside the other's inventory might be a84	/// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an85	/// image that is lighter and faster to load but representative of this resource.86	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]87	pub thumb: Option<BoundedString>,88}8990#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]91#[cfg_attr(feature = "std", derive(Serialize))]92#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]93pub struct SlotResource<BoundedString> {94	/// A Base is uniquely identified by the combination of the word `base`, its minting block95	/// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.96	/// base-4477293-kanaria_superbird.97	pub base: BaseId,9899	/// If the resource is Media, the base property is absent. Media src should be a URI like an100	/// IPFS hash.101	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]102	pub src: Option<BoundedString>,103104	/// Reference to IPFS location of metadata105	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]106	pub metadata: Option<BoundedString>,107108	/// If the resource has the slot property, it was designed to fit into a specific Base's slot.109	/// The baseslot will be composed of two dot-delimited values, like so:110	/// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is111	/// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird112	pub slot: SlotId,113114	/// The license field, if present, should contain a link to a license (IPFS or static HTTP115	/// url), or an identifier, like RMRK_nocopy or ipfs://ipfs/someHashOfLicense.116	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]117	pub license: Option<BoundedString>,118119	/// If the resource has the thumb property, this will be a URI to a thumbnail of the given120	/// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is121	/// complex and too detailed to show in a search-results page or a list. Also, if a bird owns122	/// another bird, showing the full render of one bird inside the other's inventory might be a123	/// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an124	/// image that is lighter and faster to load but representative of this resource.125	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]126	pub thumb: Option<BoundedString>,127}128129#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]130#[cfg_attr(feature = "std", derive(Serialize))]131#[cfg_attr(132	feature = "std",133	serde(bound = r#"134			BoundedString: AsRef<[u8]>,135			BoundedParts: AsRef<[PartId]>136		"#)137)]138pub enum ResourceTypes<BoundedString, BoundedParts> {139	Basic(BasicResource<BoundedString>),140	Composable(ComposableResource<BoundedString, BoundedParts>),141	Slot(SlotResource<BoundedString>),142}143144#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]145#[cfg_attr(feature = "std", derive(Serialize))]146#[cfg_attr(147	feature = "std",148	serde(bound = r#"149			BoundedString: AsRef<[u8]>,150			BoundedParts: AsRef<[PartId]>151		"#)152)]153pub struct ResourceInfo<BoundedString, BoundedParts> {154	/// id is a 5-character string of reasonable uniqueness.155	/// The combination of base ID and resource id should be unique across the entire RMRK156	/// ecosystem which157	//#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]158	pub id: ResourceId,159160	/// Resource161	pub resource: ResourceTypes<BoundedString, BoundedParts>,162163	/// If resource is sent to non-rootowned NFT, pending will be false and need to be accepted164	pub pending: bool,165166	/// If resource removal request is sent by non-rootowned NFT, pending will be true and need to be accepted167	pub pending_removal: bool,168}
after · primitives/rmrk-traits/src/resource.rs
1// Copyright (C) 2021-2022 RMRK2// This file is part of rmrk-substrate.3// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE45use codec::{Decode, Encode, MaxEncodedLen};6use scale_info::TypeInfo;78#[cfg(feature = "std")]9use serde::Serialize;1011#[cfg(feature = "std")]12use crate::serialize;1314use crate::primitives::*;1516#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]17#[cfg_attr(feature = "std", derive(Serialize))]18#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]19pub struct BasicResource<BoundedString> {20	/// If the resource is Media, the base property is absent. Media src should be a URI like an21	/// IPFS hash.22	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]23	pub src: Option<BoundedString>,2425	/// Reference to IPFS location of metadata26	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]27	pub metadata: Option<BoundedString>,2829	/// Optional location or identier of license30	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]31	pub license: Option<BoundedString>,3233	/// If the resource has the thumb property, this will be a URI to a thumbnail of the given34	/// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is35	/// complex and too detailed to show in a search-results page or a list. Also, if a bird owns36	/// another bird, showing the full render of one bird inside the other's inventory might be a37	/// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an38	/// image that is lighter and faster to load but representative of this resource.39	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]40	pub thumb: Option<BoundedString>,41}4243#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]44#[cfg_attr(feature = "std", derive(Serialize))]45#[cfg_attr(46	feature = "std",47	serde(bound = r#"48			BoundedString: AsRef<[u8]>,49			BoundedParts: AsRef<[PartId]>50		"#)51)]52pub struct ComposableResource<BoundedString, BoundedParts> {53	/// If a resource is composed, it will have an array of parts that compose it54	#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]55	pub parts: BoundedParts,5657	/// A Base is uniquely identified by the combination of the word `base`, its minting block58	/// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.59	/// base-4477293-kanaria_superbird.60	pub base: BaseId,6162	/// If the resource is Media, the base property is absent. Media src should be a URI like an63	/// IPFS hash.64	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]65	pub src: Option<BoundedString>,6667	/// Reference to IPFS location of metadata68	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]69	pub metadata: Option<BoundedString>,7071	/// If the resource has the slot property, it was designed to fit into a specific Base's slot.72	/// The baseslot will be composed of two dot-delimited values, like so:73	/// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is74	/// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird7576	/// Optional location or identier of license77	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]78	pub license: Option<BoundedString>,7980	/// If the resource has the thumb property, this will be a URI to a thumbnail of the given81	/// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is82	/// complex and too detailed to show in a search-results page or a list. Also, if a bird owns83	/// another bird, showing the full render of one bird inside the other's inventory might be a84	/// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an85	/// image that is lighter and faster to load but representative of this resource.86	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]87	pub thumb: Option<BoundedString>,88}8990#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]91#[cfg_attr(feature = "std", derive(Serialize))]92#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]93pub struct SlotResource<BoundedString> {94	/// A Base is uniquely identified by the combination of the word `base`, its minting block95	/// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.96	/// base-4477293-kanaria_superbird.97	pub base: BaseId,9899	/// If the resource is Media, the base property is absent. Media src should be a URI like an100	/// IPFS hash.101	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]102	pub src: Option<BoundedString>,103104	/// Reference to IPFS location of metadata105	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]106	pub metadata: Option<BoundedString>,107108	/// If the resource has the slot property, it was designed to fit into a specific Base's slot.109	/// The baseslot will be composed of two dot-delimited values, like so:110	/// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is111	/// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird112	pub slot: SlotId,113114	/// The license field, if present, should contain a link to a license (IPFS or static HTTP115	/// url), or an identifier, like RMRK_nocopy or ipfs://ipfs/someHashOfLicense.116	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]117	pub license: Option<BoundedString>,118119	/// If the resource has the thumb property, this will be a URI to a thumbnail of the given120	/// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is121	/// complex and too detailed to show in a search-results page or a list. Also, if a bird owns122	/// another bird, showing the full render of one bird inside the other's inventory might be a123	/// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an124	/// image that is lighter and faster to load but representative of this resource.125	#[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]126	pub thumb: Option<BoundedString>,127}128129#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]130#[cfg_attr(feature = "std", derive(Serialize))]131#[cfg_attr(132	feature = "std",133	serde(bound = r#"134			BoundedString: AsRef<[u8]>,135			BoundedParts: AsRef<[PartId]>136		"#)137)]138pub enum ResourceTypes<BoundedString, BoundedParts> {139	Basic(BasicResource<BoundedString>),140	Composable(ComposableResource<BoundedString, BoundedParts>),141	Slot(SlotResource<BoundedString>),142}143144#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]145#[cfg_attr(feature = "std", derive(Serialize))]146#[cfg_attr(147	feature = "std",148	serde(bound = r#"149			BoundedString: AsRef<[u8]>,150			BoundedParts: AsRef<[PartId]>151		"#)152)]153pub struct ResourceInfo<BoundedString, BoundedParts> {154	/// ID a unique identifier for a resource across all those of a single NFT.155	/// The combination of a collection ID, an NFT ID, and the resource ID must be 156	/// unique across the entire RMRK ecosystem.157	//#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]158	pub id: ResourceId,159160	/// Resource type and the accordingly structured data stored161	pub resource: ResourceTypes<BoundedString, BoundedParts>,162163	/// If resource is sent to non-rootowned NFT, pending will be false and need to be accepted164	pub pending: bool,165166	/// If resource removal request is sent by non-rootowned NFT, pending will be true and need to be accepted167	pub pending_removal: bool,168}