use ink::{
contract_ref, env::DefaultEnvironment, prelude::vec::Vec,
primitives::AccountId,
};
pub type PSP22Ref = contract_ref!(PSP22, DefaultEnvironment);
pub use pendzl::traits::Balance;
#[ink::trait_definition]
pub trait PSP22 {
#[ink(message)]
fn total_supply(&self) -> Balance;
#[ink(message)]
fn balance_of(&self, owner: AccountId) -> Balance;
#[ink(message)]
fn allowance(&self, owner: AccountId, spender: AccountId) -> Balance;
#[ink(message)]
fn transfer(
&mut self,
to: AccountId,
value: Balance,
data: Vec<u8>,
) -> Result<(), PSP22Error>;
#[ink(message)]
fn transfer_from(
&mut self,
from: AccountId,
to: AccountId,
value: Balance,
data: Vec<u8>,
) -> Result<(), PSP22Error>;
#[ink(message)]
fn approve(
&mut self,
spender: AccountId,
value: Balance,
) -> Result<(), PSP22Error>;
#[ink(message)]
fn increase_allowance(
&mut self,
spender: AccountId,
delta_value: Balance,
) -> Result<(), PSP22Error>;
#[ink(message)]
fn decrease_allowance(
&mut self,
spender: AccountId,
delta_value: Balance,
) -> Result<(), PSP22Error>;
}
pub trait PSP22Storage {
fn total_supply(&self) -> Balance;
fn increase_total_supply(
&mut self,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn decrease_total_supply(
&mut self,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn balance_of(&self, account: &AccountId) -> Balance;
fn increase_balance_of(
&mut self,
account: &AccountId,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn decrease_balance_of(
&mut self,
account: &AccountId,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn allowance(&self, owner: &AccountId, spender: &AccountId) -> Balance;
fn set_allowance(
&mut self,
owner: &AccountId,
spender: &AccountId,
value: &Balance,
);
fn increase_allowance(
&mut self,
owner: &AccountId,
spender: &AccountId,
amount: &Balance,
) -> Result<Balance, PSP22Error>;
fn decrease_allowance(
&mut self,
owner: &AccountId,
spender: &AccountId,
amount: &Balance,
) -> Result<Balance, PSP22Error>;
}
pub trait PSP22Internal {
fn _total_supply(&self) -> Balance;
fn _balance_of(&self, owner: &AccountId) -> Balance;
fn _allowance(&self, owner: &AccountId, spender: &AccountId) -> Balance;
fn _update(
&mut self,
from: Option<&AccountId>,
to: Option<&AccountId>,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn _transfer(
&mut self,
from: &AccountId,
to: &AccountId,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn _mint_to(
&mut self,
to: &AccountId,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn _burn_from(
&mut self,
from: &AccountId,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn _approve(
&mut self,
owner: &AccountId,
spender: &AccountId,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn _decrease_allowance_from_to(
&mut self,
owner: &AccountId,
spender: &AccountId,
amount: &Balance,
) -> Result<(), PSP22Error>;
fn _increase_allowance_from_to(
&mut self,
owner: &AccountId,
spender: &AccountId,
amount: &Balance,
) -> Result<(), PSP22Error>;
}