git.delta.rocks / unique-network / refs/commits / 3903c8aaf16e

difftreelog

source

primitives/rmrk-traits/src/nft.rs1.8 KiBsourcehistory
1use codec::{Decode, Encode, MaxEncodedLen};2use scale_info::TypeInfo;34#[cfg(feature = "std")]5use serde::Serialize;67#[cfg(feature = "std")]8use crate::serialize;910use crate::primitives::*;1112#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, Debug, TypeInfo, MaxEncodedLen)]13#[cfg_attr(feature = "std", derive(Serialize))]14pub enum AccountIdOrCollectionNftTuple<AccountId> {15	AccountId(AccountId),16	CollectionAndNftTuple(CollectionId, NftId),17}1819/// Royalty information (recipient and amount)20#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]21#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]22pub struct RoyaltyInfo<AccountId, RoyaltyAmount> {23	/// Recipient (AccountId) of the royalty24	pub recipient: AccountId,25	/// Amount (Permill) of the royalty26	pub amount: RoyaltyAmount,27}2829/// Nft info.30#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]31#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]32#[cfg_attr(33	feature = "std",34	serde(bound = r#"35			AccountId: Serialize,36			RoyaltyAmount: Serialize,37			BoundedString: AsRef<[u8]>38		"#)39)]40pub struct NftInfo<AccountId, RoyaltyAmount, BoundedString> {41	/// The owner of the NFT, can be either an Account or a tuple (CollectionId, NftId)42	pub owner: AccountIdOrCollectionNftTuple<AccountId>,43	/// Royalty (optional)44	pub royalty: Option<RoyaltyInfo<AccountId, RoyaltyAmount>>,4546	/// Arbitrary data about an instance, e.g. IPFS hash47	#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]48	pub metadata: BoundedString,4950	/// Equipped state51	pub equipped: bool,52	/// Pending state (if sent to NFT)53	pub pending: bool,54}5556#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]57#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]58pub struct NftChild {59	pub collection_id: CollectionId,60	pub nft_id: NftId,61}