pub async fn create_transfer_checked_instruction_with_extra_metas<F, Fut>(
token_program_id: &Pubkey,
source_pubkey: &Pubkey,
mint_pubkey: &Pubkey,
destination_pubkey: &Pubkey,
authority_pubkey: &Pubkey,
signer_pubkeys: &[&Pubkey],
amount: u64,
decimals: u8,
fetch_account_data_fn: F,
) -> Result<Instruction, AccountFetchError>
Expand description
Offchain helper to create a TransferChecked
instruction with all
additional required account metas for a transfer, including the ones
required by the transfer hook.
To be client-agnostic and to avoid pulling in the full solana-sdk, this
simply takes a function that will return its data as Future<Vec<u8>>
for
the given address. Can be called in the following way:
ⓘ
let instruction = create_transfer_checked_instruction_with_extra_metas(
&spl_token_2022::id(),
&source,
&mint,
&destination,
&authority,
&[],
amount,
decimals,
|address| self.client.get_account(&address).map_ok(|opt| opt.map(|acc| acc.data)),
)
.await?