This repository was archived by the owner on Mar 11, 2025. It is now read-only.
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Provide token program cross-program-invocation wrappers #91
Closed as not planned
Description
Could use a trait object:
pub fn token_transfer(
&self,
accounts: &[AccountInfo],
token: &Pubkey,
destination: &Pubkey,
amount: u64,
) -> Result<(), ProgramError> {
let swap_string = self.self_pubkey.to_string();
let signers = &[&[&swap_string[..32]][..]];
let ix = spl_token::instruction::transfer(
self.token_program,
self.authority,
token,
destination,
amount,
)?;
invoke_signed(&ix, accounts, signers)
}