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:
committed by
GitHub
parent
37c36ce3fa
commit
140c8dd01f
@ -43,10 +43,7 @@ pub fn process_instruction(
|
||||
let signers = instruction_context.get_signers(transaction_context);
|
||||
match limited_deserialize(data)? {
|
||||
StakeInstruction::Initialize(authorized, lockup) => {
|
||||
let rent = get_sysvar_with_account_check::rent(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let rent = get_sysvar_with_account_check::rent(invoke_context, instruction_context, 1)?;
|
||||
me.initialize(&authorized, &lockup, &rent)
|
||||
}
|
||||
StakeInstruction::Authorize(authorized_pubkey, stake_authorize) => {
|
||||
@ -55,10 +52,8 @@ pub fn process_instruction(
|
||||
.is_active(&feature_set::require_custodian_for_locked_stake_authorize::id());
|
||||
|
||||
if require_custodian_for_locked_stake_authorize {
|
||||
let clock = get_sysvar_with_account_check::clock(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let clock =
|
||||
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 1)?;
|
||||
let _current_authority =
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?;
|
||||
let custodian =
|
||||
@ -93,10 +88,8 @@ pub fn process_instruction(
|
||||
.is_active(&feature_set::require_custodian_for_locked_stake_authorize::id());
|
||||
|
||||
if require_custodian_for_locked_stake_authorize {
|
||||
let clock = get_sysvar_with_account_check::clock(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let clock =
|
||||
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 2)?;
|
||||
let custodian =
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 3)
|
||||
.ok()
|
||||
@ -127,13 +120,12 @@ pub fn process_instruction(
|
||||
}
|
||||
StakeInstruction::DelegateStake => {
|
||||
let vote = keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
let clock = get_sysvar_with_account_check::clock(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let clock =
|
||||
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 2)?;
|
||||
let stake_history = get_sysvar_with_account_check::stake_history(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 3)?,
|
||||
invoke_context,
|
||||
instruction_context,
|
||||
3,
|
||||
)?;
|
||||
let config_account =
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 4)?;
|
||||
@ -152,13 +144,12 @@ pub fn process_instruction(
|
||||
StakeInstruction::Merge => {
|
||||
let source_stake =
|
||||
&keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
let clock = get_sysvar_with_account_check::clock(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let clock =
|
||||
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 2)?;
|
||||
let stake_history = get_sysvar_with_account_check::stake_history(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 3)?,
|
||||
invoke_context,
|
||||
instruction_context,
|
||||
3,
|
||||
)?;
|
||||
me.merge(
|
||||
invoke_context,
|
||||
@ -170,13 +161,12 @@ pub fn process_instruction(
|
||||
}
|
||||
StakeInstruction::Withdraw(lamports) => {
|
||||
let to = &keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
let clock = get_sysvar_with_account_check::clock(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let clock =
|
||||
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 2)?;
|
||||
let stake_history = get_sysvar_with_account_check::stake_history(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 3)?,
|
||||
invoke_context,
|
||||
instruction_context,
|
||||
3,
|
||||
)?;
|
||||
me.withdraw(
|
||||
lamports,
|
||||
@ -188,10 +178,8 @@ pub fn process_instruction(
|
||||
)
|
||||
}
|
||||
StakeInstruction::Deactivate => {
|
||||
let clock = get_sysvar_with_account_check::clock(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let clock =
|
||||
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 1)?;
|
||||
me.deactivate(&clock, &signers)
|
||||
}
|
||||
StakeInstruction::SetLockup(lockup) => {
|
||||
@ -214,10 +202,8 @@ pub fn process_instruction(
|
||||
.ok_or(InstructionError::MissingRequiredSignature)?,
|
||||
};
|
||||
|
||||
let rent = get_sysvar_with_account_check::rent(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let rent =
|
||||
get_sysvar_with_account_check::rent(invoke_context, instruction_context, 1)?;
|
||||
me.initialize(&authorized, &Lockup::default(), &rent)
|
||||
} else {
|
||||
Err(InstructionError::InvalidInstructionData)
|
||||
@ -228,10 +214,8 @@ pub fn process_instruction(
|
||||
.feature_set
|
||||
.is_active(&feature_set::vote_stake_checked_instructions::id())
|
||||
{
|
||||
let clock = get_sysvar_with_account_check::clock(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let clock =
|
||||
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 1)?;
|
||||
let _current_authority =
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?;
|
||||
let authorized_pubkey =
|
||||
@ -262,10 +246,8 @@ pub fn process_instruction(
|
||||
{
|
||||
let authority_base =
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||
let clock = get_sysvar_with_account_check::clock(
|
||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 2)?,
|
||||
invoke_context,
|
||||
)?;
|
||||
let clock =
|
||||
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 2)?;
|
||||
let authorized_pubkey =
|
||||
&keyed_account_at_index(keyed_accounts, first_instruction_account + 3)?
|
||||
.signer_key()
|
||||
|
Reference in New Issue
Block a user