git.delta.rocks / unique-network / refs/commits / 91e514bdbb72

difftreelog

source

primitives/rmrk-traits/src/nft.rs1.9 KiBsourcehistory
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, Copy, Clone, Debug, TypeInfo, MaxEncodedLen)]17#[cfg_attr(feature = "std", derive(Serialize))]18pub enum AccountIdOrCollectionNftTuple<AccountId> {19	AccountId(AccountId),20	CollectionAndNftTuple(CollectionId, NftId),21}2223/// Royalty information (recipient and amount)24#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]25#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]26pub struct RoyaltyInfo<AccountId, RoyaltyAmount> {27	/// Recipient (AccountId) of the royalty28	pub recipient: AccountId,29	/// Amount (Permill) of the royalty30	pub amount: RoyaltyAmount,31}3233/// Nft info.34#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]35#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]36#[cfg_attr(37	feature = "std",38	serde(bound = r#"39			AccountId: Serialize,40			RoyaltyAmount: Serialize,41			BoundedString: AsRef<[u8]>42		"#)43)]44pub struct NftInfo<AccountId, RoyaltyAmount, BoundedString> {45	/// The owner of the NFT, can be either an Account or a tuple (CollectionId, NftId)46	pub owner: AccountIdOrCollectionNftTuple<AccountId>,47	/// Royalty (optional)48	pub royalty: Option<RoyaltyInfo<AccountId, RoyaltyAmount>>,4950	/// Arbitrary data about an instance, e.g. IPFS hash51	#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]52	pub metadata: BoundedString,5354	/// Equipped state55	pub equipped: bool,56	/// Pending state (if sent to NFT)57	pub pending: bool,58}5960#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]61#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]62pub struct NftChild {63	pub collection_id: CollectionId,64	pub nft_id: NftId,65}