Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 095bc48

Browse files
author
Joe C
authored
transfer hook: add new onchain helper
As another step for solving #6064, the onchain helpers now need to be replaced. This PR makes that change in the SPL Transfer Hook interface. Specifically, this commit adds a new `add_extra_accounts_for_execute_cpi(..)` helper and deprecates the old one. Like its offchain counterpart, this new helper requires the arguments for `instruction::execute(..)` in order to validate that a proper `ExecuteInstruction` is being resolved, thus ensuring proper account resolution. This function, like its now-deprecated sibling, is designed specifically to add extra accounts to an `ExecuteInstruction` CPI instruction. It's expected that the instruction being provided is a CPI instruction for another program, and that program will CPI to the transfer hook program in question. Details about this have been added to the helper's documentation.
1 parent 5f490e5 commit 095bc48

File tree

2 files changed

+444
-2
lines changed

2 files changed

+444
-2
lines changed

token/program-2022/src/onchain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use {
1111
account_info::AccountInfo, entrypoint::ProgramResult, instruction::AccountMeta,
1212
program::invoke_signed, pubkey::Pubkey,
1313
},
14-
spl_transfer_hook_interface::onchain::add_cpi_accounts_for_execute,
1514
};
1615

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

0 commit comments

Comments
 (0)