difftreelog
refactorprimitives): purge defaultness from rmrk
in: master
1 file changed
primitives/data-structs/src/rmrk.rsdiffbeforeafterboth1use 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(bound = r#"62 AccountId: Serialize,63 BoundedString: AsRef<[u8]>,64 BoundedSymbol: AsRef<[u8]>65 "#)66)]67pub struct CollectionInfo<BoundedString, BoundedSymbol, AccountId> {68 /// Current bidder and bid price.69 pub issuer: AccountId,7071 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]72 pub metadata: BoundedString,73 pub max: Option<u32>,7475 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]76 pub symbol: BoundedSymbol,77 pub nfts_count: u32,78}7980#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, Debug, TypeInfo, MaxEncodedLen)]81#[cfg_attr(feature = "std", derive(Serialize))]82pub enum AccountIdOrCollectionNftTuple<AccountId> {83 AccountId(AccountId),84 CollectionAndNftTuple(CollectionId, NftId),85}8687/// Royalty information (recipient and amount)88#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]89#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]90pub struct RoyaltyInfo<AccountId, RoyaltyAmount> {91 /// Recipient (AccountId) of the royalty92 pub recipient: AccountId,93 /// Amount (Permill) of the royalty94 pub amount: RoyaltyAmount,95}9697/// Nft info.98#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]99#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]100#[cfg_attr(101 feature = "std",102 serde(bound = r#"103 AccountId: Serialize,104 RoyaltyAmount: Serialize,105 BoundedString: AsRef<[u8]>106 "#)107)]108pub struct NftInfo<AccountId, RoyaltyAmount, BoundedString> {109 /// The owner of the NFT, can be either an Account or a tuple (CollectionId, NftId)110 pub owner: AccountIdOrCollectionNftTuple<AccountId>,111 /// Royalty (optional)112 pub royalty: Option<RoyaltyInfo<AccountId, RoyaltyAmount>>,113114 /// Arbitrary data about an instance, e.g. IPFS hash115 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]116 pub metadata: BoundedString,117118 /// Equipped state119 pub equipped: bool,120 /// Pending state (if sent to NFT)121 pub pending: bool,122}123124#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]125#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]126pub struct NftChild {127 pub collection_id: CollectionId,128 pub nft_id: NftId,129}130131#[cfg_attr(feature = "std", derive(Serialize))]132#[derive(Encode, Decode, PartialEq, TypeInfo)]133#[cfg_attr(134 feature = "std",135 serde(bound = r#"136 BoundedKey: AsRef<[u8]>,137 BoundedValue: AsRef<[u8]>138 "#)139)]140pub struct PropertyInfo<BoundedKey, BoundedValue> {141 /// Key of the property142 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]143 pub key: BoundedKey,144145 /// Value of the property146 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]147 pub value: BoundedValue,148}149150#[derive(Encode, Decode, Default, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]151#[cfg_attr(feature = "std", derive(Serialize))]152#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]153pub struct BasicResource<BoundedString> {154 /// If the resource is Media, the base property is absent. Media src should be a URI like an155 /// IPFS hash.156 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]157 pub src: Option<BoundedString>,158159 /// Reference to IPFS location of metadata160 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]161 pub metadata: Option<BoundedString>,162163 /// Optional location or identier of license164 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]165 pub license: Option<BoundedString>,166167 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given168 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is169 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns170 /// another bird, showing the full render of one bird inside the other's inventory might be a171 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an172 /// image that is lighter and faster to load but representative of this resource.173 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]174 pub thumb: Option<BoundedString>,175}176177#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]178#[cfg_attr(feature = "std", derive(Serialize))]179#[cfg_attr(180 feature = "std",181 serde(bound = r#"182 BoundedString: AsRef<[u8]>,183 BoundedParts: AsRef<[PartId]>184 "#)185)]186pub struct ComposableResource<BoundedString, BoundedParts> {187 /// If a resource is composed, it will have an array of parts that compose it188 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]189 pub parts: BoundedParts,190191 /// A Base is uniquely identified by the combination of the word `base`, its minting block192 /// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.193 /// base-4477293-kanaria_superbird.194 pub base: BaseId,195196 /// If the resource is Media, the base property is absent. Media src should be a URI like an197 /// IPFS hash.198 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]199 pub src: Option<BoundedString>,200201 /// Reference to IPFS location of metadata202 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]203 pub metadata: Option<BoundedString>,204205 /// If the resource has the slot property, it was designed to fit into a specific Base's slot.206 /// The baseslot will be composed of two dot-delimited values, like so:207 /// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is208 /// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird209210 /// Optional location or identier of license211 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]212 pub license: Option<BoundedString>,213214 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given215 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is216 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns217 /// another bird, showing the full render of one bird inside the other's inventory might be a218 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an219 /// image that is lighter and faster to load but representative of this resource.220 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]221 pub thumb: Option<BoundedString>,222}223224#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]225#[cfg_attr(feature = "std", derive(Serialize))]226#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]227pub struct SlotResource<BoundedString> {228 /// A Base is uniquely identified by the combination of the word `base`, its minting block229 /// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.230 /// base-4477293-kanaria_superbird.231 pub base: BaseId,232233 /// If the resource is Media, the base property is absent. Media src should be a URI like an234 /// IPFS hash.235 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]236 pub src: Option<BoundedString>,237238 /// Reference to IPFS location of metadata239 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]240 pub metadata: Option<BoundedString>,241242 /// If the resource has the slot property, it was designed to fit into a specific Base's slot.243 /// The baseslot will be composed of two dot-delimited values, like so:244 /// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is245 /// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird246 pub slot: SlotId,247248 /// The license field, if present, should contain a link to a license (IPFS or static HTTP249 /// url), or an identifier, like RMRK_nocopy or ipfs://ipfs/someHashOfLicense.250 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]251 pub license: Option<BoundedString>,252253 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given254 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is255 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns256 /// another bird, showing the full render of one bird inside the other's inventory might be a257 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an258 /// image that is lighter and faster to load but representative of this resource.259 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]260 pub thumb: Option<BoundedString>,261}262263#[derive(Encode, Decode, Derivative, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]264#[cfg_attr(feature = "std", derive(Serialize))]265#[cfg_attr(266 feature = "std",267 serde(bound = r#"268 BoundedString: AsRef<[u8]>,269 BoundedParts: AsRef<[PartId]>270 "#)271)]272#[derivative(Default(bound = ""))]273pub enum ResourceTypes<BoundedString: Default, BoundedParts> {274 #[derivative(Default)]275 Basic(BasicResource<BoundedString>),276 Composable(ComposableResource<BoundedString, BoundedParts>),277 Slot(SlotResource<BoundedString>),278}279280#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]281#[cfg_attr(feature = "std", derive(Serialize))]282#[cfg_attr(283 feature = "std",284 serde(bound = r#"285 BoundedString: AsRef<[u8]>,286 BoundedParts: AsRef<[PartId]>287 "#)288)]289pub struct ResourceInfo<BoundedString: Default, BoundedParts> {290 /// id is a 5-character string of reasonable uniqueness.291 /// The combination of base ID and resource id should be unique across the entire RMRK292 /// ecosystem which293 //#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]294 pub id: ResourceId,295296 /// Resource297 pub resource: ResourceTypes<BoundedString, BoundedParts>,298299 /// If resource is sent to non-rootowned NFT, pending will be false and need to be accepted300 pub pending: bool,301302 /// If resource removal request is sent by non-rootowned NFT, pending will be true and need to be accepted303 pub pending_removal: bool,304}305306#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]307#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]308#[cfg_attr(309 feature = "std",310 serde(bound = r#"311 AccountId: Serialize,312 BoundedString: AsRef<[u8]>313 "#)314)]315pub struct BaseInfo<AccountId, BoundedString> {316 /// Original creator of the Base317 pub issuer: AccountId,318319 /// Specifies how an NFT should be rendered, ie "svg"320 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]321 pub base_type: BoundedString,322323 /// User provided symbol during Base creation324 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]325 pub symbol: BoundedString,326}327328#[cfg_attr(feature = "std", derive(Serialize))]329#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]330#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]331pub struct FixedPart<BoundedString> {332 pub id: PartId,333 pub z: ZIndex,334335 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]336 pub src: BoundedString,337}338339#[cfg_attr(feature = "std", derive(Serialize))]340#[derive(Encode, Decode, Debug, Derivative, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]341#[cfg_attr(342 feature = "std",343 serde(bound = "BoundedCollectionList: AsRef<[CollectionId]>")344)]345#[derivative(Default(bound = ""))]346pub enum EquippableList<BoundedCollectionList> {347 All,348349 #[derivative(Default)]350 Empty,351352 Custom(#[cfg_attr(feature = "std", serde(with = "serialize::vec"))] BoundedCollectionList),353}354355#[cfg_attr(feature = "std", derive(Serialize))]356#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]357#[cfg_attr(358 feature = "std",359 serde(bound = r#"360 BoundedString: AsRef<[u8]>,361 BoundedCollectionList: AsRef<[CollectionId]>362 "#)363)]364pub struct SlotPart<BoundedString, BoundedCollectionList> {365 pub id: PartId,366 pub equippable: EquippableList<BoundedCollectionList>,367368 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]369 pub src: BoundedString,370371 pub z: ZIndex,372}373374#[cfg_attr(feature = "std", derive(Serialize))]375#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]376#[cfg_attr(377 feature = "std",378 serde(bound = r#"379 BoundedString: AsRef<[u8]>,380 BoundedCollectionList: AsRef<[CollectionId]>381 "#)382)]383pub enum PartType<BoundedString, BoundedCollectionList> {384 FixedPart(FixedPart<BoundedString>),385 SlotPart(SlotPart<BoundedString, BoundedCollectionList>),386}387388impl<BoundedString, BoundedCollectionList> PartType<BoundedString, BoundedCollectionList> {389 pub fn id(&self) -> PartId {390 match self {391 Self::FixedPart(part) => part.id,392 Self::SlotPart(part) => part.id,393 }394 }395396 pub fn src(&self) -> &BoundedString {397 match self {398 Self::FixedPart(part) => &part.src,399 Self::SlotPart(part) => &part.src,400 }401 }402403 pub fn z_index(&self) -> ZIndex {404 match self {405 Self::FixedPart(part) => part.z,406 Self::SlotPart(part) => part.z,407 }408 }409}410411#[cfg_attr(feature = "std", derive(Eq, Serialize))]412#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]413#[cfg_attr(414 feature = "std",415 serde(bound = r#"416 BoundedString: AsRef<[u8]>,417 PropertyList: AsRef<[ThemeProperty<BoundedString>]>,418 "#)419)]420pub struct Theme<BoundedString, PropertyList> {421 /// Name of the theme422 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]423 pub name: BoundedString,424425 /// Theme properties426 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]427 pub properties: PropertyList,428 /// Inheritability429 pub inherit: bool,430}431432#[cfg_attr(feature = "std", derive(Eq, Serialize))]433#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]434#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]435pub struct ThemeProperty<BoundedString> {436 /// Key of the property437 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]438 pub key: BoundedString,439440 /// Value of the property441 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]442 pub value: BoundedString,443}1use codec::{Decode, Encode, MaxEncodedLen};2use scale_info::TypeInfo;34#[cfg(feature = "std")]5use serde::Serialize;67use primitives::*;89pub mod primitives {10 pub type CollectionId = u32;11 pub type ResourceId = u32;12 pub type NftId = u32;13 pub type BaseId = u32;14 pub type SlotId = u32;15 pub type PartId = u32;16 pub type ZIndex = u32;17}1819#[cfg(feature = "std")]20mod serialize {21 use core::convert::AsRef;22 use serde::ser::{self, Serialize};2324 pub mod vec {25 use super::*;2627 pub fn serialize<D, V, C>(value: &C, serializer: D) -> Result<D::Ok, D::Error>28 where29 D: ser::Serializer,30 V: Serialize,31 C: AsRef<[V]>,32 {33 value.as_ref().serialize(serializer)34 }35 }3637 pub mod opt_vec {38 use super::*;3940 pub fn serialize<D, V, C>(value: &Option<C>, serializer: D) -> Result<D::Ok, D::Error>41 where42 D: ser::Serializer,43 V: Serialize,44 C: AsRef<[V]>,45 {46 match value {47 Some(value) => super::vec::serialize(value, serializer),48 None => serializer.serialize_none(),49 }50 }51 }52}5354/// Collection info.55#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]56#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]57#[cfg_attr(58 feature = "std",59 serde(bound = r#"60 AccountId: Serialize,61 BoundedString: AsRef<[u8]>,62 BoundedSymbol: AsRef<[u8]>63 "#)64)]65pub struct CollectionInfo<BoundedString, BoundedSymbol, AccountId> {66 /// Current bidder and bid price.67 pub issuer: AccountId,6869 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]70 pub metadata: BoundedString,71 pub max: Option<u32>,7273 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]74 pub symbol: BoundedSymbol,75 pub nfts_count: u32,76}7778#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, Debug, TypeInfo, MaxEncodedLen)]79#[cfg_attr(feature = "std", derive(Serialize))]80pub enum AccountIdOrCollectionNftTuple<AccountId> {81 AccountId(AccountId),82 CollectionAndNftTuple(CollectionId, NftId),83}8485/// Royalty information (recipient and amount)86#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]87#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]88pub struct RoyaltyInfo<AccountId, RoyaltyAmount> {89 /// Recipient (AccountId) of the royalty90 pub recipient: AccountId,91 /// Amount (Permill) of the royalty92 pub amount: RoyaltyAmount,93}9495/// Nft info.96#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]97#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]98#[cfg_attr(99 feature = "std",100 serde(bound = r#"101 AccountId: Serialize,102 RoyaltyAmount: Serialize,103 BoundedString: AsRef<[u8]>104 "#)105)]106pub struct NftInfo<AccountId, RoyaltyAmount, BoundedString> {107 /// The owner of the NFT, can be either an Account or a tuple (CollectionId, NftId)108 pub owner: AccountIdOrCollectionNftTuple<AccountId>,109 /// Royalty (optional)110 pub royalty: Option<RoyaltyInfo<AccountId, RoyaltyAmount>>,111112 /// Arbitrary data about an instance, e.g. IPFS hash113 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]114 pub metadata: BoundedString,115116 /// Equipped state117 pub equipped: bool,118 /// Pending state (if sent to NFT)119 pub pending: bool,120}121122#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]123#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]124pub struct NftChild {125 pub collection_id: CollectionId,126 pub nft_id: NftId,127}128129#[cfg_attr(feature = "std", derive(Serialize))]130#[derive(Encode, Decode, PartialEq, TypeInfo)]131#[cfg_attr(132 feature = "std",133 serde(bound = r#"134 BoundedKey: AsRef<[u8]>,135 BoundedValue: AsRef<[u8]>136 "#)137)]138pub struct PropertyInfo<BoundedKey, BoundedValue> {139 /// Key of the property140 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]141 pub key: BoundedKey,142143 /// Value of the property144 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]145 pub value: BoundedValue,146}147148#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]149#[cfg_attr(feature = "std", derive(Serialize))]150#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]151pub struct BasicResource<BoundedString> {152 /// If the resource is Media, the base property is absent. Media src should be a URI like an153 /// IPFS hash.154 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]155 pub src: Option<BoundedString>,156157 /// Reference to IPFS location of metadata158 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]159 pub metadata: Option<BoundedString>,160161 /// Optional location or identier of license162 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]163 pub license: Option<BoundedString>,164165 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given166 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is167 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns168 /// another bird, showing the full render of one bird inside the other's inventory might be a169 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an170 /// image that is lighter and faster to load but representative of this resource.171 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]172 pub thumb: Option<BoundedString>,173}174175#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]176#[cfg_attr(feature = "std", derive(Serialize))]177#[cfg_attr(178 feature = "std",179 serde(bound = r#"180 BoundedString: AsRef<[u8]>,181 BoundedParts: AsRef<[PartId]>182 "#)183)]184pub struct ComposableResource<BoundedString, BoundedParts> {185 /// If a resource is composed, it will have an array of parts that compose it186 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]187 pub parts: BoundedParts,188189 /// A Base is uniquely identified by the combination of the word `base`, its minting block190 /// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.191 /// base-4477293-kanaria_superbird.192 pub base: BaseId,193194 /// If the resource is Media, the base property is absent. Media src should be a URI like an195 /// IPFS hash.196 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]197 pub src: Option<BoundedString>,198199 /// Reference to IPFS location of metadata200 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]201 pub metadata: Option<BoundedString>,202203 /// If the resource has the slot property, it was designed to fit into a specific Base's slot.204 /// The baseslot will be composed of two dot-delimited values, like so:205 /// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is206 /// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird207208 /// Optional location or identier of license209 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]210 pub license: Option<BoundedString>,211212 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given213 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is214 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns215 /// another bird, showing the full render of one bird inside the other's inventory might be a216 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an217 /// image that is lighter and faster to load but representative of this resource.218 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]219 pub thumb: Option<BoundedString>,220}221222#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]223#[cfg_attr(feature = "std", derive(Serialize))]224#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]225pub struct SlotResource<BoundedString> {226 /// A Base is uniquely identified by the combination of the word `base`, its minting block227 /// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.228 /// base-4477293-kanaria_superbird.229 pub base: BaseId,230231 /// If the resource is Media, the base property is absent. Media src should be a URI like an232 /// IPFS hash.233 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]234 pub src: Option<BoundedString>,235236 /// Reference to IPFS location of metadata237 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]238 pub metadata: Option<BoundedString>,239240 /// If the resource has the slot property, it was designed to fit into a specific Base's slot.241 /// The baseslot will be composed of two dot-delimited values, like so:242 /// "base-4477293-kanaria_superbird.machine_gun_scope". This means: "This resource is243 /// compatible with the machine_gun_scope slot of base base-4477293-kanaria_superbird244 pub slot: SlotId,245246 /// The license field, if present, should contain a link to a license (IPFS or static HTTP247 /// url), or an identifier, like RMRK_nocopy or ipfs://ipfs/someHashOfLicense.248 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]249 pub license: Option<BoundedString>,250251 /// If the resource has the thumb property, this will be a URI to a thumbnail of the given252 /// resource. For example, if we have a composable NFT like a Kanaria bird, the resource is253 /// complex and too detailed to show in a search-results page or a list. Also, if a bird owns254 /// another bird, showing the full render of one bird inside the other's inventory might be a255 /// bit of a strain on the browser. For this reason, the thumb value can contain a URI to an256 /// image that is lighter and faster to load but representative of this resource.257 #[cfg_attr(feature = "std", serde(with = "serialize::opt_vec"))]258 pub thumb: Option<BoundedString>,259}260261#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]262#[cfg_attr(feature = "std", derive(Serialize))]263#[cfg_attr(264 feature = "std",265 serde(bound = r#"266 BoundedString: AsRef<[u8]>,267 BoundedParts: AsRef<[PartId]>268 "#)269)]270pub enum ResourceTypes<BoundedString, BoundedParts> {271 Basic(BasicResource<BoundedString>),272 Composable(ComposableResource<BoundedString, BoundedParts>),273 Slot(SlotResource<BoundedString>),274}275276#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]277#[cfg_attr(feature = "std", derive(Serialize))]278#[cfg_attr(279 feature = "std",280 serde(bound = r#"281 BoundedString: AsRef<[u8]>,282 BoundedParts: AsRef<[PartId]>283 "#)284)]285pub struct ResourceInfo<BoundedString, BoundedParts> {286 /// id is a 5-character string of reasonable uniqueness.287 /// The combination of base ID and resource id should be unique across the entire RMRK288 /// ecosystem which289 //#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]290 pub id: ResourceId,291292 /// Resource293 pub resource: ResourceTypes<BoundedString, BoundedParts>,294295 /// If resource is sent to non-rootowned NFT, pending will be false and need to be accepted296 pub pending: bool,297298 /// If resource removal request is sent by non-rootowned NFT, pending will be true and need to be accepted299 pub pending_removal: bool,300}301302#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]303#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]304#[cfg_attr(305 feature = "std",306 serde(bound = r#"307 AccountId: Serialize,308 BoundedString: AsRef<[u8]>309 "#)310)]311pub struct BaseInfo<AccountId, BoundedString> {312 /// Original creator of the Base313 pub issuer: AccountId,314315 /// Specifies how an NFT should be rendered, ie "svg"316 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]317 pub base_type: BoundedString,318319 /// User provided symbol during Base creation320 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]321 pub symbol: BoundedString,322}323324#[cfg_attr(feature = "std", derive(Serialize))]325#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]326#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]327pub struct FixedPart<BoundedString> {328 pub id: PartId,329 pub z: ZIndex,330331 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]332 pub src: BoundedString,333}334335#[cfg_attr(feature = "std", derive(Serialize))]336#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]337#[cfg_attr(338 feature = "std",339 serde(bound = "BoundedCollectionList: AsRef<[CollectionId]>")340)]341pub enum EquippableList<BoundedCollectionList> {342 All,343 Empty,344 Custom(#[cfg_attr(feature = "std", serde(with = "serialize::vec"))] BoundedCollectionList),345}346347#[cfg_attr(feature = "std", derive(Serialize))]348#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]349#[cfg_attr(350 feature = "std",351 serde(bound = r#"352 BoundedString: AsRef<[u8]>,353 BoundedCollectionList: AsRef<[CollectionId]>354 "#)355)]356pub struct SlotPart<BoundedString, BoundedCollectionList> {357 pub id: PartId,358 pub equippable: EquippableList<BoundedCollectionList>,359360 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]361 pub src: BoundedString,362363 pub z: ZIndex,364}365366#[cfg_attr(feature = "std", derive(Serialize))]367#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]368#[cfg_attr(369 feature = "std",370 serde(bound = r#"371 BoundedString: AsRef<[u8]>,372 BoundedCollectionList: AsRef<[CollectionId]>373 "#)374)]375pub enum PartType<BoundedString, BoundedCollectionList> {376 FixedPart(FixedPart<BoundedString>),377 SlotPart(SlotPart<BoundedString, BoundedCollectionList>),378}379380impl<BoundedString, BoundedCollectionList> PartType<BoundedString, BoundedCollectionList> {381 pub fn id(&self) -> PartId {382 match self {383 Self::FixedPart(part) => part.id,384 Self::SlotPart(part) => part.id,385 }386 }387388 pub fn src(&self) -> &BoundedString {389 match self {390 Self::FixedPart(part) => &part.src,391 Self::SlotPart(part) => &part.src,392 }393 }394395 pub fn z_index(&self) -> ZIndex {396 match self {397 Self::FixedPart(part) => part.z,398 Self::SlotPart(part) => part.z,399 }400 }401}402403#[cfg_attr(feature = "std", derive(Eq, Serialize))]404#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]405#[cfg_attr(406 feature = "std",407 serde(bound = r#"408 BoundedString: AsRef<[u8]>,409 PropertyList: AsRef<[ThemeProperty<BoundedString>]>,410 "#)411)]412pub struct Theme<BoundedString, PropertyList> {413 /// Name of the theme414 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]415 pub name: BoundedString,416417 /// Theme properties418 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]419 pub properties: PropertyList,420 /// Inheritability421 pub inherit: bool,422}423424#[cfg_attr(feature = "std", derive(Eq, Serialize))]425#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]426#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]427pub struct ThemeProperty<BoundedString> {428 /// Key of the property429 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]430 pub key: BoundedString,431432 /// Value of the property433 #[cfg_attr(feature = "std", serde(with = "serialize::vec"))]434 pub value: BoundedString,435}