pub trait TokenInterface: Send + Sync {
// Required methods
fn program_id(&self) -> Pubkey;
fn unpack_token_account(
&self,
data: &[u8],
) -> Result<Box<dyn TokenState + Send + Sync>, Box<dyn Error + Send + Sync>>;
fn create_initialize_account_instruction(
&self,
account: &Pubkey,
mint: &Pubkey,
owner: &Pubkey,
) -> Result<Instruction, Box<dyn Error + Send + Sync>>;
fn create_transfer_instruction(
&self,
source: &Pubkey,
destination: &Pubkey,
authority: &Pubkey,
amount: u64,
) -> Result<Instruction, Box<dyn Error + Send + Sync>>;
fn create_transfer_checked_instruction(
&self,
source: &Pubkey,
mint: &Pubkey,
destination: &Pubkey,
authority: &Pubkey,
amount: u64,
decimals: u8,
) -> Result<Instruction, Box<dyn Error + Send + Sync>>;
fn get_associated_token_address(
&self,
wallet: &Pubkey,
mint: &Pubkey,
) -> Pubkey;
fn create_associated_token_account_instruction(
&self,
funding_account: &Pubkey,
wallet: &Pubkey,
mint: &Pubkey,
) -> Instruction;
fn unpack_mint(
&self,
mint: &Pubkey,
mint_data: &[u8],
) -> Result<Box<dyn TokenMint + Send + Sync>, Box<dyn Error + Send + Sync>>;
}Required Methods§
fn program_id(&self) -> Pubkey
fn unpack_token_account( &self, data: &[u8], ) -> Result<Box<dyn TokenState + Send + Sync>, Box<dyn Error + Send + Sync>>
fn create_initialize_account_instruction( &self, account: &Pubkey, mint: &Pubkey, owner: &Pubkey, ) -> Result<Instruction, Box<dyn Error + Send + Sync>>
fn create_transfer_instruction( &self, source: &Pubkey, destination: &Pubkey, authority: &Pubkey, amount: u64, ) -> Result<Instruction, Box<dyn Error + Send + Sync>>
fn create_transfer_checked_instruction( &self, source: &Pubkey, mint: &Pubkey, destination: &Pubkey, authority: &Pubkey, amount: u64, decimals: u8, ) -> Result<Instruction, Box<dyn Error + Send + Sync>>
fn get_associated_token_address(&self, wallet: &Pubkey, mint: &Pubkey) -> Pubkey
fn create_associated_token_account_instruction( &self, funding_account: &Pubkey, wallet: &Pubkey, mint: &Pubkey, ) -> Instruction
fn unpack_mint( &self, mint: &Pubkey, mint_data: &[u8], ) -> Result<Box<dyn TokenMint + Send + Sync>, Box<dyn Error + Send + Sync>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".