difftreelog
fix EquippableList default
in: master
1 file changed
primitives/data-structs/src/rmrk.rsdiffbeforeafterboth1use codec::{Decode, Encode, MaxEncodedLen};2use scale_info::TypeInfo;345#[cfg(feature = "std")]6use serde::Serialize;78use primitives::*;910pub mod primitives {11 pub type CollectionId = u32;12 pub type ResourceId = u32;13 pub type NftId = u32;14 pub type BaseId = u32;15 pub type SlotId = u32;16 pub type PartId = u32;17 pub type ZIndex = u32;18}1920#[cfg(feature = "std")]21mod serialize {22 use core::convert::AsRef;23 use serde::ser::{self, Serialize};2425 pub mod vec {26 use super::*;2728 pub fn serialize<D, V, C>(value: &C, serializer: D) -> Result<D::Ok, D::Error>29 where30 D: ser::Serializer,31 V: Serialize,32 C: AsRef<[V]>,33 {34 value.as_ref().serialize(serializer)35 }36 }3738 pub mod opt_vec {39 use super::*;4041 pub fn serialize<D, V, C>(value: &Option<C>, serializer: D) -> Result<D::Ok, D::Error>42 where43 D: ser::Serializer,44 V: Serialize,45 C: AsRef<[V]>,46 {47 match value {48 Some(value) => super::vec::serialize(value, serializer),49 None => serializer.serialize_none()50 }51 }52 }53}5455/// Collection info.56#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]57#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]58#[cfg_attr(59 feature = "std",60 serde(61 bound = r#"62 AccountId: Serialize,63 BoundedString: AsRef<[u8]>,64 BoundedSymbol: AsRef<[u8]>65 "#66 )67)]68pub struct CollectionInfo<BoundedString, BoundedSymbol, AccountId> {69 /// Current bidder and bid price.70 pub issuer: AccountId,7172 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]73 pub metadata: BoundedString,74 pub max: Option<u32>,7576 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]77 pub symbol: BoundedSymbol,78 pub nfts_count: u32,79}8081#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, Debug, TypeInfo, MaxEncodedLen)]82#[cfg_attr(feature = "std", derive(Serialize))]83pub enum AccountIdOrCollectionNftTuple<AccountId> {84 AccountId(AccountId),85 CollectionAndNftTuple(CollectionId, NftId),86}8788/// Royalty information (recipient and amount)89#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]90#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]91pub struct RoyaltyInfo<AccountId, RoyaltyAmount> {92 /// Recipient (AccountId) of the royalty93 pub recipient: AccountId,94 /// Amount (Permill) of the royalty95 pub amount: RoyaltyAmount,96}9798/// Nft info.99#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]100#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]101#[cfg_attr(102 feature = "std",103 serde(104 bound = r#"105 AccountId: Serialize,106 RoyaltyAmount: Serialize,107 BoundedString: AsRef<[u8]>108 "#109 )110)]111pub struct NftInfo<AccountId, RoyaltyAmount, BoundedString> {112 /// The owner of the NFT, can be either an Account or a tuple (CollectionId, NftId)113 pub owner: AccountIdOrCollectionNftTuple<AccountId>,114 /// Royalty (optional)115 pub royalty: Option<RoyaltyInfo<AccountId, RoyaltyAmount>>,116117 /// Arbitrary data about an instance, e.g. IPFS hash118 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]119 pub metadata: BoundedString,120121 /// Equipped state122 pub equipped: bool,123 /// Pending state (if sent to NFT)124 pub pending: bool,125}126127#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]128#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]129pub struct NftChild {130 pub collection_id: CollectionId,131 pub nft_id: NftId132}133134#[cfg_attr(feature = "std", derive(Serialize))]135#[derive(Encode, Decode, PartialEq, TypeInfo)]136#[cfg_attr(137 feature = "std",138 serde(139 bound = r#"140 BoundedKey: AsRef<[u8]>,141 BoundedValue: AsRef<[u8]>142 "#143 )144)]145pub struct PropertyInfo<BoundedKey, BoundedValue>146{147 /// Key of the property148 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]149 pub key: BoundedKey,150151 /// Value of the property152 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]153 pub value: BoundedValue,154}155156#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]157#[cfg_attr(feature = "std", derive(Serialize))]158#[cfg_attr(159 feature = "std",160 serde(bound = "BoundedString: AsRef<[u8]>")161)]162pub struct BasicResource<BoundedString> {163 /// If the resource is Media, the base property is absent. Media src should be a URI like an164 /// IPFS hash.165 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]166 pub src: Option<BoundedString>,167168 /// Reference to IPFS location of metadata169 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]170 pub metadata: Option<BoundedString>,171172 /// Optional location or identier of license173 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]174 pub license: Option<BoundedString>,175176 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given177 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is178 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns179 /// another bird, showing the full render of one bird inside the other's inventory might be a180 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an181 /// image that is lighter and faster to load but representative of this resource.182 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]183 pub thumb: Option<BoundedString>,184}185186#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]187#[cfg_attr(feature = "std", derive(Serialize))]188#[cfg_attr(189 feature = "std",190 serde(191 bound = r#"192 BoundedString: AsRef<[u8]>,193 BoundedParts: AsRef<[PartId]>194 "#195 )196)]197pub struct ComposableResource<BoundedString, BoundedParts> {198 /// If a resource is composed, it will have an array of parts that compose it199 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]200 pub parts: BoundedParts,201202 /// A Base is uniquely identified by the combination of the word `base`, its minting block203 /// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.204 /// base-4477293-kanaria_superbird.205 pub base: BaseId,206207 /// If the resource is Media, the base property is absent. Media src should be a URI like an208 /// IPFS hash.209 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]210 pub src: Option<BoundedString>,211212 /// Reference to IPFS location of metadata213 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]214 pub metadata: Option<BoundedString>,215216 /// If the resource has the slot property, it was designed to fit into a specific Base's slot.217 /// The baseslot will be composed of two dot-delimited values, like so:218 /// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is219 /// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird220221 /// Optional location or identier of license222 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]223 pub license: Option<BoundedString>,224225 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given226 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is227 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns228 /// another bird, showing the full render of one bird inside the other's inventory might be a229 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an230 /// image that is lighter and faster to load but representative of this resource.231 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]232 pub thumb: Option<BoundedString>,233}234235#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]236#[cfg_attr(feature = "std", derive(Serialize))]237#[cfg_attr(238 feature = "std",239 serde(bound = "BoundedString: AsRef<[u8]>")240)]241pub struct SlotResource<BoundedString> {242 /// A Base is uniquely identified by the combination of the word `base`, its minting block243 /// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.244 /// base-4477293-kanaria_superbird.245 pub base: BaseId,246247 /// If the resource is Media, the base property is absent. Media src should be a URI like an248 /// IPFS hash.249 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]250 pub src: Option<BoundedString>,251252 /// Reference to IPFS location of metadata253 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]254 pub metadata: Option<BoundedString>,255256 /// If the resource has the slot property, it was designed to fit into a specific Base's slot.257 /// The baseslot will be composed of two dot-delimited values, like so:258 /// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is259 /// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird260 pub slot: SlotId,261262 /// The license field, if present, should contain a link to a license (IPFS or static HTTP263 /// url), or an identifier, like RMRK_nocopy or ipfs://ipfs/someHashOfLicense.264 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]265 pub license: Option<BoundedString>,266267 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given268 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is269 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns270 /// another bird, showing the full render of one bird inside the other's inventory might be a271 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an272 /// image that is lighter and faster to load but representative of this resource.273 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]274 pub thumb: Option<BoundedString>,275}276277#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]278#[cfg_attr(feature = "std", derive(Serialize))]279#[cfg_attr(280 feature = "std",281 serde(282 bound = r#"283 BoundedString: AsRef<[u8]>,284 BoundedParts: AsRef<[PartId]>285 "#286 )287)]288pub enum ResourceTypes<BoundedString, BoundedParts> {289 Basic(BasicResource<BoundedString>),290 Composable(ComposableResource<BoundedString, BoundedParts>),291 Slot(SlotResource<BoundedString>),292}293294295#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]296#[cfg_attr(feature = "std", derive(Serialize))]297#[cfg_attr(298 feature = "std",299 serde(300 bound = r#"301 BoundedResource: AsRef<[u8]>,302 BoundedString: AsRef<[u8]>,303 BoundedParts: AsRef<[PartId]>304 "#305 )306)]307pub struct ResourceInfo<BoundedResource, BoundedString, BoundedParts> {308 /// id is a 5-character string of reasonable uniqueness.309 /// The combination of base ID and resource id should be unique across the entire RMRK310 /// ecosystem which311 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]312 pub id: BoundedResource,313314 /// Resource315 pub resource: ResourceTypes<BoundedString, BoundedParts>,316317 /// If resource is sent to non-rootowned NFT, pending will be false and need to be accepted318 pub pending: bool,319320 /// If resource removal request is sent by non-rootowned NFT, pending will be true and need to be accepted321 pub pending_removal: bool,322}323324#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]325#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]326#[cfg_attr(327 feature = "std",328 serde(329 bound = r#"330 AccountId: Serialize,331 BoundedString: AsRef<[u8]>332 "#333 )334)]335pub struct BaseInfo<AccountId, BoundedString> {336 /// Original creator of the Base337 pub issuer: AccountId,338339 /// Specifies how an NFT should be rendered, ie "svg"340 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]341 pub base_type: BoundedString,342343 /// User provided symbol during Base creation344 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]345 pub symbol: BoundedString,346}347348#[cfg_attr(feature = "std", derive(Serialize))]349#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]350#[cfg_attr(351 feature = "std",352 serde(bound = "BoundedString: AsRef<[u8]>")353)]354pub struct FixedPart<BoundedString> {355 pub id: PartId,356 pub z: ZIndex,357358 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]359 pub src: BoundedString,360}361362#[cfg_attr(feature = "std", derive(Serialize))]363#[derive(Encode, Decode, Debug, Default, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]364#[cfg_attr(365 feature = "std",366 serde(bound = "BoundedCollectionList: AsRef<[CollectionId]>")367)]368pub enum EquippableList<BoundedCollectionList> {369 All,370 #[default] Empty,371 Custom(372 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]373 BoundedCollectionList374 ),375}376377#[cfg_attr(feature = "std", derive(Serialize))]378#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]379#[cfg_attr(380 feature = "std",381 serde(382 bound = r#"383 BoundedString: AsRef<[u8]>,384 BoundedCollectionList: AsRef<[CollectionId]>385 "#386 )387)]388pub struct SlotPart<BoundedString, BoundedCollectionList> {389 pub id: PartId,390 pub equippable: EquippableList<BoundedCollectionList>,391392 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]393 pub src: BoundedString,394395 pub z: ZIndex,396}397398#[cfg_attr(feature = "std", derive(Serialize))]399#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]400#[cfg_attr(401 feature = "std",402 serde(403 bound = r#"404 BoundedString: AsRef<[u8]>,405 BoundedCollectionList: AsRef<[CollectionId]>406 "#407 )408)]409pub enum PartType<BoundedString, BoundedCollectionList> {410 FixedPart(FixedPart<BoundedString>),411 SlotPart(SlotPart<BoundedString, BoundedCollectionList>),412}413414#[cfg_attr(feature = "std", derive(Eq, Serialize))]415#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]416#[cfg_attr(417 feature = "std",418 serde(419 bound = r#"420 BoundedString: AsRef<[u8]>,421 PropertyList: AsRef<[ThemeProperty<BoundedString>]>,422 "#423 )424)]425pub struct Theme<BoundedString, PropertyList> {426 /// Name of the theme427 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]428 pub name: BoundedString,429430 /// Theme properties431 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]432 pub properties: PropertyList,433 /// Inheritability434 pub inherit: bool,435}436437#[cfg_attr(feature = "std", derive(Eq, Serialize))]438#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]439#[cfg_attr(440 feature = "std",441 serde(bound = "BoundedString: AsRef<[u8]>")442)]443pub struct ThemeProperty<BoundedString> {444 /// Key of the property445 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]446 pub key: BoundedString,447448 /// Value of the property449 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]450 pub value: BoundedString,451}1use codec::{Decode, Encode, MaxEncodedLen};2use scale_info::TypeInfo;34use derivative::Derivative;56#[cfg(feature = "std")]7use serde::Serialize;89use primitives::*;1011pub mod primitives {12 pub type CollectionId = u32;13 pub type ResourceId = u32;14 pub type NftId = u32;15 pub type BaseId = u32;16 pub type SlotId = u32;17 pub type PartId = u32;18 pub type ZIndex = u32;19}2021#[cfg(feature = "std")]22mod serialize {23 use core::convert::AsRef;24 use serde::ser::{self, Serialize};2526 pub mod vec {27 use super::*;2829 pub fn serialize<D, V, C>(value: &C, serializer: D) -> Result<D::Ok, D::Error>30 where31 D: ser::Serializer,32 V: Serialize,33 C: AsRef<[V]>,34 {35 value.as_ref().serialize(serializer)36 }37 }3839 pub mod opt_vec {40 use super::*;4142 pub fn serialize<D, V, C>(value: &Option<C>, serializer: D) -> Result<D::Ok, D::Error>43 where44 D: ser::Serializer,45 V: Serialize,46 C: AsRef<[V]>,47 {48 match value {49 Some(value) => super::vec::serialize(value, serializer),50 None => serializer.serialize_none()51 }52 }53 }54}5556/// Collection info.57#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]58#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]59#[cfg_attr(60 feature = "std",61 serde(62 bound = r#"63 AccountId: Serialize,64 BoundedString: AsRef<[u8]>,65 BoundedSymbol: AsRef<[u8]>66 "#67 )68)]69pub struct CollectionInfo<BoundedString, BoundedSymbol, AccountId> {70 /// Current bidder and bid price.71 pub issuer: AccountId,7273 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]74 pub metadata: BoundedString,75 pub max: Option<u32>,7677 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]78 pub symbol: BoundedSymbol,79 pub nfts_count: u32,80}8182#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, Debug, TypeInfo, MaxEncodedLen)]83#[cfg_attr(feature = "std", derive(Serialize))]84pub enum AccountIdOrCollectionNftTuple<AccountId> {85 AccountId(AccountId),86 CollectionAndNftTuple(CollectionId, NftId),87}8889/// Royalty information (recipient and amount)90#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]91#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]92pub struct RoyaltyInfo<AccountId, RoyaltyAmount> {93 /// Recipient (AccountId) of the royalty94 pub recipient: AccountId,95 /// Amount (Permill) of the royalty96 pub amount: RoyaltyAmount,97}9899/// Nft info.100#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]101#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]102#[cfg_attr(103 feature = "std",104 serde(105 bound = r#"106 AccountId: Serialize,107 RoyaltyAmount: Serialize,108 BoundedString: AsRef<[u8]>109 "#110 )111)]112pub struct NftInfo<AccountId, RoyaltyAmount, BoundedString> {113 /// The owner of the NFT, can be either an Account or a tuple (CollectionId, NftId)114 pub owner: AccountIdOrCollectionNftTuple<AccountId>,115 /// Royalty (optional)116 pub royalty: Option<RoyaltyInfo<AccountId, RoyaltyAmount>>,117118 /// Arbitrary data about an instance, e.g. IPFS hash119 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]120 pub metadata: BoundedString,121122 /// Equipped state123 pub equipped: bool,124 /// Pending state (if sent to NFT)125 pub pending: bool,126}127128#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]129#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]130pub struct NftChild {131 pub collection_id: CollectionId,132 pub nft_id: NftId133}134135#[cfg_attr(feature = "std", derive(Serialize))]136#[derive(Encode, Decode, PartialEq, TypeInfo)]137#[cfg_attr(138 feature = "std",139 serde(140 bound = r#"141 BoundedKey: AsRef<[u8]>,142 BoundedValue: AsRef<[u8]>143 "#144 )145)]146pub struct PropertyInfo<BoundedKey, BoundedValue>147{148 /// Key of the property149 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]150 pub key: BoundedKey,151152 /// Value of the property153 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]154 pub value: BoundedValue,155}156157#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]158#[cfg_attr(feature = "std", derive(Serialize))]159#[cfg_attr(160 feature = "std",161 serde(bound = "BoundedString: AsRef<[u8]>")162)]163pub struct BasicResource<BoundedString> {164 /// If the resource is Media, the base property is absent. Media src should be a URI like an165 /// IPFS hash.166 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]167 pub src: Option<BoundedString>,168169 /// Reference to IPFS location of metadata170 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]171 pub metadata: Option<BoundedString>,172173 /// Optional location or identier of license174 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]175 pub license: Option<BoundedString>,176177 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given178 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is179 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns180 /// another bird, showing the full render of one bird inside the other's inventory might be a181 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an182 /// image that is lighter and faster to load but representative of this resource.183 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]184 pub thumb: Option<BoundedString>,185}186187#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]188#[cfg_attr(feature = "std", derive(Serialize))]189#[cfg_attr(190 feature = "std",191 serde(192 bound = r#"193 BoundedString: AsRef<[u8]>,194 BoundedParts: AsRef<[PartId]>195 "#196 )197)]198pub struct ComposableResource<BoundedString, BoundedParts> {199 /// If a resource is composed, it will have an array of parts that compose it200 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]201 pub parts: BoundedParts,202203 /// A Base is uniquely identified by the combination of the word `base`, its minting block204 /// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.205 /// base-4477293-kanaria_superbird.206 pub base: BaseId,207208 /// If the resource is Media, the base property is absent. Media src should be a URI like an209 /// IPFS hash.210 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]211 pub src: Option<BoundedString>,212213 /// Reference to IPFS location of metadata214 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]215 pub metadata: Option<BoundedString>,216217 /// If the resource has the slot property, it was designed to fit into a specific Base's slot.218 /// The baseslot will be composed of two dot-delimited values, like so:219 /// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is220 /// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird221222 /// Optional location or identier of license223 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]224 pub license: Option<BoundedString>,225226 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given227 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is228 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns229 /// another bird, showing the full render of one bird inside the other's inventory might be a230 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an231 /// image that is lighter and faster to load but representative of this resource.232 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]233 pub thumb: Option<BoundedString>,234}235236#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]237#[cfg_attr(feature = "std", derive(Serialize))]238#[cfg_attr(239 feature = "std",240 serde(bound = "BoundedString: AsRef<[u8]>")241)]242pub struct SlotResource<BoundedString> {243 /// A Base is uniquely identified by the combination of the word `base`, its minting block244 /// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.245 /// base-4477293-kanaria_superbird.246 pub base: BaseId,247248 /// If the resource is Media, the base property is absent. Media src should be a URI like an249 /// IPFS hash.250 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]251 pub src: Option<BoundedString>,252253 /// Reference to IPFS location of metadata254 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]255 pub metadata: Option<BoundedString>,256257 /// If the resource has the slot property, it was designed to fit into a specific Base's slot.258 /// The baseslot will be composed of two dot-delimited values, like so:259 /// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is260 /// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird261 pub slot: SlotId,262263 /// The license field, if present, should contain a link to a license (IPFS or static HTTP264 /// url), or an identifier, like RMRK_nocopy or ipfs://ipfs/someHashOfLicense.265 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]266 pub license: Option<BoundedString>,267268 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given269 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is270 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns271 /// another bird, showing the full render of one bird inside the other's inventory might be a272 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an273 /// image that is lighter and faster to load but representative of this resource.274 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]275 pub thumb: Option<BoundedString>,276}277278#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]279#[cfg_attr(feature = "std", derive(Serialize))]280#[cfg_attr(281 feature = "std",282 serde(283 bound = r#"284 BoundedString: AsRef<[u8]>,285 BoundedParts: AsRef<[PartId]>286 "#287 )288)]289pub enum ResourceTypes<BoundedString, BoundedParts> {290 Basic(BasicResource<BoundedString>),291 Composable(ComposableResource<BoundedString, BoundedParts>),292 Slot(SlotResource<BoundedString>),293}294295296#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]297#[cfg_attr(feature = "std", derive(Serialize))]298#[cfg_attr(299 feature = "std",300 serde(301 bound = r#"302 BoundedResource: AsRef<[u8]>,303 BoundedString: AsRef<[u8]>,304 BoundedParts: AsRef<[PartId]>305 "#306 )307)]308pub struct ResourceInfo<BoundedResource, BoundedString, BoundedParts> {309 /// id is a 5-character string of reasonable uniqueness.310 /// The combination of base ID and resource id should be unique across the entire RMRK311 /// ecosystem which312 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]313 pub id: BoundedResource,314315 /// Resource316 pub resource: ResourceTypes<BoundedString, BoundedParts>,317318 /// If resource is sent to non-rootowned NFT, pending will be false and need to be accepted319 pub pending: bool,320321 /// If resource removal request is sent by non-rootowned NFT, pending will be true and need to be accepted322 pub pending_removal: bool,323}324325#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]326#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]327#[cfg_attr(328 feature = "std",329 serde(330 bound = r#"331 AccountId: Serialize,332 BoundedString: AsRef<[u8]>333 "#334 )335)]336pub struct BaseInfo<AccountId, BoundedString> {337 /// Original creator of the Base338 pub issuer: AccountId,339340 /// Specifies how an NFT should be rendered, ie "svg"341 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]342 pub base_type: BoundedString,343344 /// User provided symbol during Base creation345 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]346 pub symbol: BoundedString,347}348349#[cfg_attr(feature = "std", derive(Serialize))]350#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]351#[cfg_attr(352 feature = "std",353 serde(bound = "BoundedString: AsRef<[u8]>")354)]355pub struct FixedPart<BoundedString> {356 pub id: PartId,357 pub z: ZIndex,358359 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]360 pub src: BoundedString,361}362363#[cfg_attr(feature = "std", derive(Serialize))]364#[derive(Encode, Decode, Debug, Derivative, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]365#[cfg_attr(366 feature = "std",367 serde(bound = "BoundedCollectionList: AsRef<[CollectionId]>")368)]369#[derivative(Default(bound=""))]370pub enum EquippableList<BoundedCollectionList> {371 All,372373 #[derivative(Default)]374 Empty,375376 Custom(377 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]378 BoundedCollectionList379 ),380}381382#[cfg_attr(feature = "std", derive(Serialize))]383#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]384#[cfg_attr(385 feature = "std",386 serde(387 bound = r#"388 BoundedString: AsRef<[u8]>,389 BoundedCollectionList: AsRef<[CollectionId]>390 "#391 )392)]393pub struct SlotPart<BoundedString, BoundedCollectionList> {394 pub id: PartId,395 pub equippable: EquippableList<BoundedCollectionList>,396397 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]398 pub src: BoundedString,399400 pub z: ZIndex,401}402403#[cfg_attr(feature = "std", derive(Serialize))]404#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]405#[cfg_attr(406 feature = "std",407 serde(408 bound = r#"409 BoundedString: AsRef<[u8]>,410 BoundedCollectionList: AsRef<[CollectionId]>411 "#412 )413)]414pub enum PartType<BoundedString, BoundedCollectionList> {415 FixedPart(FixedPart<BoundedString>),416 SlotPart(SlotPart<BoundedString, BoundedCollectionList>),417}418419#[cfg_attr(feature = "std", derive(Eq, Serialize))]420#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]421#[cfg_attr(422 feature = "std",423 serde(424 bound = r#"425 BoundedString: AsRef<[u8]>,426 PropertyList: AsRef<[ThemeProperty<BoundedString>]>,427 "#428 )429)]430pub struct Theme<BoundedString, PropertyList> {431 /// Name of the theme432 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]433 pub name: BoundedString,434435 /// Theme properties436 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]437 pub properties: PropertyList,438 /// Inheritability439 pub inherit: bool,440}441442#[cfg_attr(feature = "std", derive(Eq, Serialize))]443#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]444#[cfg_attr(445 feature = "std",446 serde(bound = "BoundedString: AsRef<[u8]>")447)]448pub struct ThemeProperty<BoundedString> {449 /// Key of the property450 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]451 pub key: BoundedString,452453 /// Value of the property454 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]455 pub value: BoundedString,456}