Refactor: Cleanup InvokeContext (#20785)
* Move blockhash and fee_calculator in ThisInvokeContext instead of using a reference. * Moves tx_wide_compute_cap into InvokeContext::push(). * Adds ThisInvokeContext::new_mock() constructor. * Adds missing loader account in uses of MockInvokeContext. * Use keyed_account_at_index() when accessing keyed_accounts. * Makes sysvar interface consistent between ThisInvokeContext and MockInvokeContext, in order to add InvokeContext::get_sysvars(). * Adds InvokeContext::set_blockhash() and InvokeContext ::set_fee_calculator(). * Adds new_mock_with_features. * Makes ancestors optional in ThisInvokeContext. * Adds prepare_mock_invoke_context() and mock_process_instruction().
This commit is contained in:
committed by
GitHub
parent
0ac89841bf
commit
97c2732d02
@@ -54,20 +54,19 @@ pub fn process_instruction(
|
||||
}
|
||||
|
||||
let mut counter = 0;
|
||||
let mut keyed_accounts_iter = keyed_accounts.iter().skip(2);
|
||||
for (signer, _) in key_list.keys.iter().filter(|(_, is_signer)| *is_signer) {
|
||||
counter += 1;
|
||||
if signer != config_keyed_account.unsigned_key() {
|
||||
let signer_account = keyed_accounts_iter.next();
|
||||
if signer_account.is_none() {
|
||||
ic_msg!(
|
||||
invoke_context,
|
||||
"account {:?} is not in account list",
|
||||
signer
|
||||
);
|
||||
return Err(InstructionError::MissingRequiredSignature);
|
||||
}
|
||||
let signer_key = signer_account.unwrap().signer_key();
|
||||
let signer_account =
|
||||
keyed_account_at_index(keyed_accounts, counter + 1).map_err(|_| {
|
||||
ic_msg!(
|
||||
invoke_context,
|
||||
"account {:?} is not in account list",
|
||||
signer,
|
||||
);
|
||||
InstructionError::MissingRequiredSignature
|
||||
})?;
|
||||
let signer_key = signer_account.signer_key();
|
||||
if signer_key.is_none() {
|
||||
ic_msg!(
|
||||
invoke_context,
|
||||
|
Reference in New Issue
Block a user