use ink::{prelude::vec::Vec, primitives::AccountId};
#[ink::trait_definition]
pub trait PSP34 {
#[ink(message)]
fn collection_id(&self) -> Id;
#[ink(message)]
fn balance_of(&self, owner: AccountId) -> u32;
#[ink(message)]
fn owner_of(&self, id: Id) -> Option<AccountId>;
#[ink(message)]
fn allowance(
&self,
owner: AccountId,
operator: AccountId,
id: Option<Id>,
) -> bool;
#[ink(message)]
fn approve(
&mut self,
operator: AccountId,
id: Option<Id>,
approved: bool,
) -> Result<(), PSP34Error>;
#[ink(message)]
fn transfer(
&mut self,
to: AccountId,
id: Id,
data: Vec<u8>,
) -> Result<(), PSP34Error>;
#[ink(message)]
fn total_supply(&self) -> u64;
}
pub trait PSP34Storage {
fn balance_of(&self, owner: &AccountId) -> u32;
fn total_supply(&self) -> u64;
fn owner_of(&self, id: &Id) -> Option<AccountId>;
fn allowance(
&self,
owner: &AccountId,
operator: &AccountId,
id: &Option<Id>,
) -> bool;
fn set_operator_approval(
&mut self,
owner: &AccountId,
operator: &AccountId,
id: &Option<Id>,
approved: &bool,
);
fn insert_token_owner(
&mut self,
id: &Id,
to: &AccountId,
) -> Result<(), PSP34Error>;
fn remove_token_owner(
&mut self,
id: &Id,
from: &AccountId,
) -> Result<(), PSP34Error>;
}
pub trait PSP34Internal {
fn _balance_of(&self, owner: &AccountId) -> u32;
fn _total_supply(&self) -> u64;
fn _owner_of(&self, id: &Id) -> Option<AccountId>;
fn _allowance(
&self,
owner: &AccountId,
operator: &AccountId,
id: &Option<Id>,
) -> bool;
fn _approve(
&mut self,
owner: &AccountId,
operator: &AccountId,
id: &Option<Id>,
approved: &bool,
) -> Result<(), PSP34Error>;
fn _update(
&mut self,
from: &Option<&AccountId>,
to: &Option<&AccountId>,
id: &Id,
) -> Result<(), PSP34Error>;
fn _transfer(
&mut self,
from: &AccountId,
to: &AccountId,
id: &Id,
data: &Vec<u8>,
) -> Result<(), PSP34Error>;
fn _mint_to(&mut self, to: &AccountId, id: &Id) -> Result<(), PSP34Error>;
fn _burn_from(
&mut self,
from: &AccountId,
id: &Id,
) -> Result<(), PSP34Error>;
}