Adds check_number_of_instruction_accounts() to all builtin programs except for the address-lookup-table. (#23984)
This commit is contained in:
committed by
GitHub
parent
ac8b662413
commit
794645d092
@ -284,6 +284,7 @@ pub fn process_instruction(
|
||||
space,
|
||||
owner,
|
||||
} => {
|
||||
instruction_context.check_number_of_instruction_accounts(2)?;
|
||||
let from = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let to = keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
let to_address = Address::create(to.unsigned_key(), None, invoke_context)?;
|
||||
@ -305,6 +306,7 @@ pub fn process_instruction(
|
||||
space,
|
||||
owner,
|
||||
} => {
|
||||
instruction_context.check_number_of_instruction_accounts(2)?;
|
||||
let from = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let to = keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
let to_address = Address::create(
|
||||
@ -324,12 +326,14 @@ pub fn process_instruction(
|
||||
)
|
||||
}
|
||||
SystemInstruction::Assign { owner } => {
|
||||
instruction_context.check_number_of_instruction_accounts(1)?;
|
||||
let keyed_account = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let mut account = keyed_account.try_account_ref_mut()?;
|
||||
let address = Address::create(keyed_account.unsigned_key(), None, invoke_context)?;
|
||||
assign(&mut account, &address, &owner, &signers, invoke_context)
|
||||
}
|
||||
SystemInstruction::Transfer { lamports } => {
|
||||
instruction_context.check_number_of_instruction_accounts(2)?;
|
||||
let from = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let to = keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
transfer(from, to, lamports, invoke_context)
|
||||
@ -339,6 +343,7 @@ pub fn process_instruction(
|
||||
from_seed,
|
||||
from_owner,
|
||||
} => {
|
||||
instruction_context.check_number_of_instruction_accounts(3)?;
|
||||
let from = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let base = keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
let to = keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?;
|
||||
@ -353,6 +358,7 @@ pub fn process_instruction(
|
||||
)
|
||||
}
|
||||
SystemInstruction::AdvanceNonceAccount => {
|
||||
instruction_context.check_number_of_instruction_accounts(1)?;
|
||||
let me = &mut keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
#[allow(deprecated)]
|
||||
let recent_blockhashes = get_sysvar_with_account_check::recent_blockhashes(
|
||||
@ -370,6 +376,7 @@ pub fn process_instruction(
|
||||
advance_nonce_account(me, &signers, invoke_context)
|
||||
}
|
||||
SystemInstruction::WithdrawNonceAccount(lamports) => {
|
||||
instruction_context.check_number_of_instruction_accounts(2)?;
|
||||
let me = &mut keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let to = &mut keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
#[allow(deprecated)]
|
||||
@ -382,6 +389,7 @@ pub fn process_instruction(
|
||||
withdraw_nonce_account(me, lamports, to, &rent, &signers, invoke_context)
|
||||
}
|
||||
SystemInstruction::InitializeNonceAccount(authorized) => {
|
||||
instruction_context.check_number_of_instruction_accounts(1)?;
|
||||
let me = &mut keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
#[allow(deprecated)]
|
||||
let recent_blockhashes = get_sysvar_with_account_check::recent_blockhashes(
|
||||
@ -400,10 +408,12 @@ pub fn process_instruction(
|
||||
initialize_nonce_account(me, &authorized, &rent, invoke_context)
|
||||
}
|
||||
SystemInstruction::AuthorizeNonceAccount(nonce_authority) => {
|
||||
instruction_context.check_number_of_instruction_accounts(1)?;
|
||||
let me = &mut keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
authorize_nonce_account(me, &nonce_authority, &signers, invoke_context)
|
||||
}
|
||||
SystemInstruction::Allocate { space } => {
|
||||
instruction_context.check_number_of_instruction_accounts(1)?;
|
||||
let keyed_account = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let mut account = keyed_account.try_account_ref_mut()?;
|
||||
let address = Address::create(keyed_account.unsigned_key(), None, invoke_context)?;
|
||||
@ -415,6 +425,7 @@ pub fn process_instruction(
|
||||
space,
|
||||
owner,
|
||||
} => {
|
||||
instruction_context.check_number_of_instruction_accounts(1)?;
|
||||
let keyed_account = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let mut account = keyed_account.try_account_ref_mut()?;
|
||||
let address = Address::create(
|
||||
@ -432,6 +443,7 @@ pub fn process_instruction(
|
||||
)
|
||||
}
|
||||
SystemInstruction::AssignWithSeed { base, seed, owner } => {
|
||||
instruction_context.check_number_of_instruction_accounts(1)?;
|
||||
let keyed_account = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
let mut account = keyed_account.try_account_ref_mut()?;
|
||||
let address = Address::create(
|
||||
|
Reference in New Issue
Block a user