* Partial revert "Updates documentation around what needs to be passed in CPI. (#21633)" * Enforces the program_id being passed explicitly by removing it from get_instruction_keyed_accounts(). * instruction_accounts => instructions_account
This commit is contained in:
committed by
GitHub
parent
41ec7c8be9
commit
ba8e15848e
@ -2,7 +2,6 @@
|
||||
|
||||
extern crate solana_program;
|
||||
use solana_program::{
|
||||
account_info::next_account_info,
|
||||
account_info::AccountInfo,
|
||||
entrypoint,
|
||||
entrypoint::ProgramResult,
|
||||
@ -25,20 +24,19 @@ fn process_instruction(
|
||||
}
|
||||
|
||||
let secp_instruction_index = instruction_data[0];
|
||||
let account_info_iter = &mut accounts.iter();
|
||||
let instruction_accounts = next_account_info(account_info_iter)?;
|
||||
assert_eq!(*instruction_accounts.key, instructions::id());
|
||||
let data_len = instruction_accounts.try_borrow_data()?.len();
|
||||
let instructions_account = accounts.last().ok_or(ProgramError::NotEnoughAccountKeys)?;
|
||||
assert_eq!(*instructions_account.key, instructions::id());
|
||||
let data_len = instructions_account.try_borrow_data()?.len();
|
||||
if data_len < 2 {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
let instruction = instructions::load_instruction_at_checked(
|
||||
secp_instruction_index as usize,
|
||||
instruction_accounts,
|
||||
instructions_account,
|
||||
)?;
|
||||
|
||||
let current_instruction = instructions::load_current_index_checked(instruction_accounts)?;
|
||||
let current_instruction = instructions::load_current_index_checked(instructions_account)?;
|
||||
let my_index = instruction_data[1] as u16;
|
||||
assert_eq!(current_instruction, my_index);
|
||||
|
||||
@ -56,7 +54,7 @@ fn process_instruction(
|
||||
&[instruction_data[0], instruction_data[1], 1],
|
||||
vec![AccountMeta::new_readonly(instructions::id(), false)],
|
||||
),
|
||||
&[instruction_accounts.clone()],
|
||||
accounts,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user