Skip to content
Snippets Groups Projects
Unverified Commit 0937081f authored by Shaopeng Wang's avatar Shaopeng Wang Committed by GitHub
Browse files

Add NFT trait. (#309)

parent 84d2f8c2
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ pub use currency::{
};
pub use data_provider::{DataFeeder, DataProvider, DataProviderExtended};
pub use get_by_key::GetByKey;
pub use nft::NFT;
pub use price::{DefaultPriceProvider, PriceProvider};
pub use rewards::RewardHandler;
......@@ -25,6 +26,7 @@ pub mod auction;
pub mod currency;
pub mod data_provider;
pub mod get_by_key;
pub mod nft;
pub mod price;
pub mod rewards;
......
use codec::FullCodec;
use sp_runtime::{
traits::{AtLeast32BitUnsigned, MaybeSerializeDeserialize},
DispatchResult,
};
use sp_std::fmt::Debug;
/// Abstraction over a non-fungible token system.
pub trait NFT<AccountId> {
/// The NFT class identifier.
type ClassId: Default + Copy;
/// The NFT token identifier.
type TokenId: Default + Copy;
/// The balance of account.
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default;
/// The number of NFTs assigned to `who`.
fn balance(who: &AccountId) -> Self::Balance;
/// The owner of the given token ID. Returns `None` if the token does not
/// exist.
fn owner(token: (Self::ClassId, Self::TokenId)) -> Option<AccountId>;
/// Transfer the given token ID from one account to another.
fn transfer(from: &AccountId, to: &AccountId, token: (Self::ClassId, Self::TokenId)) -> DispatchResult;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment