Skip to content

Commit

Permalink
transfer hook: add new onchain helper
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Jan 10, 2024
1 parent 0b076b1 commit dfb7feb
Show file tree
Hide file tree
Showing 3 changed files with 520 additions and 3 deletions.
4 changes: 3 additions & 1 deletion token/program-2022-test/tests/transfer_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use {
processor::Processor,
},
spl_token_client::token::{ExtensionInitializationParams, TokenError as TokenClientError},
spl_transfer_hook_interface::{get_extra_account_metas_address, offchain::add_extra_account_metas_for_execute},
spl_transfer_hook_interface::{
get_extra_account_metas_address, offchain::add_extra_account_metas_for_execute,
},
std::{convert::TryInto, sync::Arc},
};

Expand Down
4 changes: 2 additions & 2 deletions token/program-2022/src/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use {
account_info::AccountInfo, entrypoint::ProgramResult, instruction::AccountMeta,
program::invoke_signed, pubkey::Pubkey,
},
spl_transfer_hook_interface::onchain::add_cpi_accounts_for_execute,
};

/// Helper to CPI into token-2022 on-chain, looking through the additional
Expand Down Expand Up @@ -62,7 +61,8 @@ pub fn invoke_transfer_checked<'a>(
let mint_data = mint_info.try_borrow_data()?;
let mint = StateWithExtensions::<Mint>::unpack(&mint_data)?;
if let Some(program_id) = transfer_hook::get_program_id(&mint) {
add_cpi_accounts_for_execute(
#[allow(deprecated)]
spl_transfer_hook_interface::onchain::add_cpi_accounts_for_execute(
&mut cpi_instruction,
&mut cpi_account_infos,
mint_info.key,
Expand Down
Loading

0 comments on commit dfb7feb

Please sign in to comment.