Struct spl_token_client::token::Token
source · pub struct Token<T> { /* private fields */ }Implementations§
source§impl<T> Token<T>where
T: SendTransaction,
impl<T> Token<T>where T: SendTransaction,
pub fn new( client: Arc<dyn ProgramClient<T>>, program_id: &Pubkey, address: &Pubkey, decimals: Option<u8>, payer: Arc<dyn Signer> ) -> Self
pub fn new_native( client: Arc<dyn ProgramClient<T>>, program_id: &Pubkey, payer: Arc<dyn Signer> ) -> Self
pub fn is_native(&self) -> bool
sourcepub fn get_address(&self) -> &Pubkey
pub fn get_address(&self) -> &Pubkey
Get token address.
pub fn with_payer(self, payer: Arc<dyn Signer>) -> Token<T>
pub fn with_nonce( self, nonce_account: &Pubkey, nonce_authority: Arc<dyn Signer> ) -> Token<T>
pub fn with_memo<M: AsRef<str>>(&self, memo: M, signers: Vec<Pubkey>) -> &Self
pub async fn get_new_latest_blockhash(&self) -> TokenResult<Hash>
pub async fn process_ixs<S: Signers>( &self, token_instructions: &[Instruction], signing_keypairs: &S ) -> TokenResult<T::Output>
pub async fn create_mint<'a, S: Signers>( &self, mint_authority: &'a Pubkey, freeze_authority: Option<&'a Pubkey>, extension_initialization_params: Vec<ExtensionInitializationParams>, signing_keypairs: &S ) -> TokenResult<T::Output>
sourcepub async fn create_native_mint(
client: Arc<dyn ProgramClient<T>>,
program_id: &Pubkey,
payer: Arc<dyn Signer>
) -> TokenResult<Self>
pub async fn create_native_mint( client: Arc<dyn ProgramClient<T>>, program_id: &Pubkey, payer: Arc<dyn Signer> ) -> TokenResult<Self>
Create native mint
sourcepub async fn create_multisig(
&self,
account: &dyn Signer,
multisig_members: &[&Pubkey],
minimum_signers: u8
) -> TokenResult<T::Output>
pub async fn create_multisig( &self, account: &dyn Signer, multisig_members: &[&Pubkey], minimum_signers: u8 ) -> TokenResult<T::Output>
Create multisig
sourcepub fn get_associated_token_address(&self, owner: &Pubkey) -> Pubkey
pub fn get_associated_token_address(&self, owner: &Pubkey) -> Pubkey
Get the address for the associated token account.
sourcepub async fn create_associated_token_account(
&self,
owner: &Pubkey
) -> TokenResult<T::Output>
pub async fn create_associated_token_account( &self, owner: &Pubkey ) -> TokenResult<T::Output>
Create and initialize the associated account.
sourcepub async fn create_auxiliary_token_account(
&self,
account: &dyn Signer,
owner: &Pubkey
) -> TokenResult<T::Output>
pub async fn create_auxiliary_token_account( &self, account: &dyn Signer, owner: &Pubkey ) -> TokenResult<T::Output>
Create and initialize a new token account.
sourcepub async fn create_auxiliary_token_account_with_extension_space(
&self,
account: &dyn Signer,
owner: &Pubkey,
extensions: Vec<ExtensionType>
) -> TokenResult<T::Output>
pub async fn create_auxiliary_token_account_with_extension_space( &self, account: &dyn Signer, owner: &Pubkey, extensions: Vec<ExtensionType> ) -> TokenResult<T::Output>
Create and initialize a new token account.
sourcepub async fn get_account(&self, account: &Pubkey) -> TokenResult<BaseAccount>
pub async fn get_account(&self, account: &Pubkey) -> TokenResult<BaseAccount>
Retrieve a raw account
sourcepub async fn get_mint_info(&self) -> TokenResult<StateWithExtensionsOwned<Mint>>
pub async fn get_mint_info(&self) -> TokenResult<StateWithExtensionsOwned<Mint>>
Retrive mint information.
sourcepub async fn get_account_info(
&self,
account: &Pubkey
) -> TokenResult<StateWithExtensionsOwned<Account>>
pub async fn get_account_info( &self, account: &Pubkey ) -> TokenResult<StateWithExtensionsOwned<Account>>
Retrieve account information.
sourcepub async fn get_or_create_associated_account_info(
&self,
owner: &Pubkey
) -> TokenResult<StateWithExtensionsOwned<Account>>
pub async fn get_or_create_associated_account_info( &self, owner: &Pubkey ) -> TokenResult<StateWithExtensionsOwned<Account>>
Retrieve the associated account or create one if not found.
Assign a new authority to the account.
sourcepub async fn mint_to<S: Signers>(
&self,
destination: &Pubkey,
authority: &Pubkey,
amount: u64,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn mint_to<S: Signers>( &self, destination: &Pubkey, authority: &Pubkey, amount: u64, signing_keypairs: &S ) -> TokenResult<T::Output>
Mint new tokens
sourcepub async fn transfer<S: Signers>(
&self,
source: &Pubkey,
destination: &Pubkey,
authority: &Pubkey,
amount: u64,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn transfer<S: Signers>( &self, source: &Pubkey, destination: &Pubkey, authority: &Pubkey, amount: u64, signing_keypairs: &S ) -> TokenResult<T::Output>
Transfer tokens to another account
sourcepub async fn create_recipient_associated_account_and_transfer<S: Signers>(
&self,
source: &Pubkey,
destination: &Pubkey,
destination_owner: &Pubkey,
authority: &Pubkey,
amount: u64,
fee: Option<u64>,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn create_recipient_associated_account_and_transfer<S: Signers>( &self, source: &Pubkey, destination: &Pubkey, destination_owner: &Pubkey, authority: &Pubkey, amount: u64, fee: Option<u64>, signing_keypairs: &S ) -> TokenResult<T::Output>
Transfer tokens to an associated account, creating it if it does not exist
sourcepub async fn transfer_with_fee<S: Signers>(
&self,
source: &Pubkey,
destination: &Pubkey,
authority: &Pubkey,
amount: u64,
fee: u64,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn transfer_with_fee<S: Signers>( &self, source: &Pubkey, destination: &Pubkey, authority: &Pubkey, amount: u64, fee: u64, signing_keypairs: &S ) -> TokenResult<T::Output>
Transfer tokens to another account, given an expected fee
sourcepub async fn burn<S: Signers>(
&self,
source: &Pubkey,
authority: &Pubkey,
amount: u64,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn burn<S: Signers>( &self, source: &Pubkey, authority: &Pubkey, amount: u64, signing_keypairs: &S ) -> TokenResult<T::Output>
Burn tokens from account
sourcepub async fn approve<S: Signers>(
&self,
source: &Pubkey,
delegate: &Pubkey,
authority: &Pubkey,
amount: u64,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn approve<S: Signers>( &self, source: &Pubkey, delegate: &Pubkey, authority: &Pubkey, amount: u64, signing_keypairs: &S ) -> TokenResult<T::Output>
Approve a delegate to spend tokens
sourcepub async fn revoke<S: Signers>(
&self,
source: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn revoke<S: Signers>( &self, source: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Revoke a delegate
sourcepub async fn close_account<S: Signers>(
&self,
account: &Pubkey,
lamports_destination: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn close_account<S: Signers>( &self, account: &Pubkey, lamports_destination: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Close an empty account and reclaim its lamports
sourcepub async fn empty_and_close_account<S: Signers>(
&self,
account_to_close: &Pubkey,
lamports_destination: &Pubkey,
tokens_destination: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn empty_and_close_account<S: Signers>( &self, account_to_close: &Pubkey, lamports_destination: &Pubkey, tokens_destination: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Close an account, reclaiming its lamports and tokens
sourcepub async fn freeze<S: Signers>(
&self,
account: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn freeze<S: Signers>( &self, account: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Freeze a token account
sourcepub async fn thaw<S: Signers>(
&self,
account: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn thaw<S: Signers>( &self, account: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Thaw / unfreeze a token account
sourcepub async fn wrap<S: Signers>(
&self,
account: &Pubkey,
owner: &Pubkey,
lamports: u64,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn wrap<S: Signers>( &self, account: &Pubkey, owner: &Pubkey, lamports: u64, signing_keypairs: &S ) -> TokenResult<T::Output>
Wrap lamports into native account
sourcepub async fn wrap_with_mutable_ownership<S: Signers>(
&self,
account: &Pubkey,
owner: &Pubkey,
lamports: u64,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn wrap_with_mutable_ownership<S: Signers>( &self, account: &Pubkey, owner: &Pubkey, lamports: u64, signing_keypairs: &S ) -> TokenResult<T::Output>
Wrap lamports into a native account that can always have its ownership changed
sourcepub async fn sync_native(&self, account: &Pubkey) -> TokenResult<T::Output>
pub async fn sync_native(&self, account: &Pubkey) -> TokenResult<T::Output>
Sync native account lamports
sourcepub async fn set_transfer_fee<S: Signers>(
&self,
authority: &Pubkey,
transfer_fee_basis_points: u16,
maximum_fee: u64,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn set_transfer_fee<S: Signers>( &self, authority: &Pubkey, transfer_fee_basis_points: u16, maximum_fee: u64, signing_keypairs: &S ) -> TokenResult<T::Output>
Set transfer fee
sourcepub async fn set_default_account_state<S: Signers>(
&self,
authority: &Pubkey,
state: &AccountState,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn set_default_account_state<S: Signers>( &self, authority: &Pubkey, state: &AccountState, signing_keypairs: &S ) -> TokenResult<T::Output>
Set default account state on mint
sourcepub async fn harvest_withheld_tokens_to_mint(
&self,
sources: &[&Pubkey]
) -> TokenResult<T::Output>
pub async fn harvest_withheld_tokens_to_mint( &self, sources: &[&Pubkey] ) -> TokenResult<T::Output>
Harvest withheld tokens to mint
sourcepub async fn withdraw_withheld_tokens_from_mint<S: Signers>(
&self,
destination: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn withdraw_withheld_tokens_from_mint<S: Signers>( &self, destination: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Withdraw withheld tokens from mint
sourcepub async fn withdraw_withheld_tokens_from_accounts<S: Signers>(
&self,
destination: &Pubkey,
authority: &Pubkey,
sources: &[&Pubkey],
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn withdraw_withheld_tokens_from_accounts<S: Signers>( &self, destination: &Pubkey, authority: &Pubkey, sources: &[&Pubkey], signing_keypairs: &S ) -> TokenResult<T::Output>
Withdraw withheld tokens from accounts
sourcepub async fn reallocate<S: Signers>(
&self,
account: &Pubkey,
authority: &Pubkey,
extension_types: &[ExtensionType],
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn reallocate<S: Signers>( &self, account: &Pubkey, authority: &Pubkey, extension_types: &[ExtensionType], signing_keypairs: &S ) -> TokenResult<T::Output>
Reallocate a token account to be large enough for a set of ExtensionTypes
sourcepub async fn enable_required_transfer_memos<S: Signers>(
&self,
account: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn enable_required_transfer_memos<S: Signers>( &self, account: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Require memos on transfers into this account
sourcepub async fn disable_required_transfer_memos<S: Signers>(
&self,
account: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn disable_required_transfer_memos<S: Signers>( &self, account: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Stop requiring memos on transfers into this account
sourcepub async fn enable_cpi_guard<S: Signers>(
&self,
account: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn enable_cpi_guard<S: Signers>( &self, account: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Prevent unsafe usage of token account through CPI
sourcepub async fn disable_cpi_guard<S: Signers>(
&self,
account: &Pubkey,
authority: &Pubkey,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn disable_cpi_guard<S: Signers>( &self, account: &Pubkey, authority: &Pubkey, signing_keypairs: &S ) -> TokenResult<T::Output>
Stop preventing unsafe usage of token account through CPI
sourcepub async fn update_interest_rate<S: Signers>(
&self,
authority: &Pubkey,
new_rate: i16,
signing_keypairs: &S
) -> TokenResult<T::Output>
pub async fn update_interest_rate<S: Signers>( &self, authority: &Pubkey, new_rate: i16, signing_keypairs: &S ) -> TokenResult<T::Output>
Update interest rate
sourcepub async fn confidential_transfer_update_mint<S: Signer>(
&self,
authority: &S,
auto_approve_new_account: bool,
auditor_encryption_pubkey: Option<EncryptionPubkey>
) -> TokenResult<T::Output>
pub async fn confidential_transfer_update_mint<S: Signer>( &self, authority: &S, auto_approve_new_account: bool, auditor_encryption_pubkey: Option<EncryptionPubkey> ) -> TokenResult<T::Output>
Update confidential transfer mint