Refactor: Replaces KeyedAccount in_get_sysvar_with_account_check (#23905)

* Replaces all use sites of get_sysvar_with_account_check by get_sysvar_with_account_check2.

* Removes get_sysvar_with_account_check.

* Renames get_sysvar_with_account_check2 to get_sysvar_with_account_check.
This commit is contained in:
Alexander Meißner
2022-03-24 19:30:42 +01:00
committed by GitHub
parent 37c36ce3fa
commit 140c8dd01f
5 changed files with 50 additions and 161 deletions

View File

@@ -356,8 +356,9 @@ pub fn process_instruction(
let me = &mut keyed_account_at_index(keyed_accounts, first_instruction_account)?;
#[allow(deprecated)]
let recent_blockhashes = get_sysvar_with_account_check::recent_blockhashes(
keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?,
invoke_context,
instruction_context,
1,
)?;
if recent_blockhashes.is_empty() {
ic_msg!(
@@ -373,21 +374,20 @@ pub fn process_instruction(
let to = &mut keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
#[allow(deprecated)]
let _recent_blockhashes = get_sysvar_with_account_check::recent_blockhashes(
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?,
invoke_context,
)?;
let rent = get_sysvar_with_account_check::rent(
keyed_account_at_index(keyed_accounts, first_instruction_account + 3)?,
invoke_context,
instruction_context,
2,
)?;
let rent = get_sysvar_with_account_check::rent(invoke_context, instruction_context, 3)?;
withdraw_nonce_account(me, lamports, to, &rent, &signers, invoke_context)
}
SystemInstruction::InitializeNonceAccount(authorized) => {
let me = &mut keyed_account_at_index(keyed_accounts, first_instruction_account)?;
#[allow(deprecated)]
let recent_blockhashes = get_sysvar_with_account_check::recent_blockhashes(
keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?,
invoke_context,
instruction_context,
1,
)?;
if recent_blockhashes.is_empty() {
ic_msg!(
@@ -396,10 +396,7 @@ pub fn process_instruction(
);
return Err(NonceError::NoRecentBlockhashes.into());
}
let rent = get_sysvar_with_account_check::rent(
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?,
invoke_context,
)?;
let rent = get_sysvar_with_account_check::rent(invoke_context, instruction_context, 2)?;
initialize_nonce_account(me, &authorized, &rent, invoke_context)
}
SystemInstruction::AuthorizeNonceAccount(nonce_authority) => {