Remove WithSigner (#10325)

automerge
This commit is contained in:
Greg Fitzgerald
2020-05-30 00:17:44 -06:00
committed by GitHub
parent 55a64712b9
commit 19d11800bf
7 changed files with 103 additions and 99 deletions

View File

@@ -8,7 +8,7 @@ use serde_derive::{Deserialize, Serialize};
use solana_sdk::{
account::{get_signers, KeyedAccount},
clock::{Epoch, UnixTimestamp},
instruction::{AccountMeta, Instruction, InstructionError, WithSigner},
instruction::{AccountMeta, Instruction, InstructionError},
program_utils::{limited_deserialize, next_keyed_account, DecodeError},
pubkey::Pubkey,
system_instruction,
@@ -184,8 +184,8 @@ fn _split(
let account_metas = vec![
AccountMeta::new(*stake_pubkey, false),
AccountMeta::new(*split_stake_pubkey, false),
]
.with_signer(authorized_pubkey);
AccountMeta::new_readonly(*authorized_pubkey, true),
];
Instruction::new(id(), &StakeInstruction::Split(lamports), account_metas)
}
@@ -293,8 +293,8 @@ pub fn authorize(
let account_metas = vec![
AccountMeta::new(*stake_pubkey, false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
]
.with_signer(authorized_pubkey);
AccountMeta::new_readonly(*authorized_pubkey, true),
];
Instruction::new(
id(),
@@ -314,8 +314,8 @@ pub fn delegate_stake(
AccountMeta::new_readonly(sysvar::clock::id(), false),
AccountMeta::new_readonly(sysvar::stake_history::id(), false),
AccountMeta::new_readonly(crate::config::id(), false),
]
.with_signer(authorized_pubkey);
AccountMeta::new_readonly(*authorized_pubkey, true),
];
Instruction::new(id(), &StakeInstruction::DelegateStake, account_metas)
}
@@ -331,11 +331,11 @@ pub fn withdraw(
AccountMeta::new(*to_pubkey, false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
AccountMeta::new_readonly(sysvar::stake_history::id(), false),
]
.with_signer(withdrawer_pubkey);
AccountMeta::new_readonly(*withdrawer_pubkey, true),
];
if let Some(custodian_pubkey) = custodian_pubkey {
account_metas = account_metas.with_signer(custodian_pubkey)
account_metas.push(AccountMeta::new_readonly(*custodian_pubkey, true));
}
Instruction::new(id(), &StakeInstruction::Withdraw(lamports), account_metas)
@@ -345,8 +345,8 @@ pub fn deactivate_stake(stake_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> In
let account_metas = vec![
AccountMeta::new(*stake_pubkey, false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
]
.with_signer(authorized_pubkey);
AccountMeta::new_readonly(*authorized_pubkey, true),
];
Instruction::new(id(), &StakeInstruction::Deactivate, account_metas)
}
@@ -355,7 +355,10 @@ pub fn set_lockup(
lockup: &LockupArgs,
custodian_pubkey: &Pubkey,
) -> Instruction {
let account_metas = vec![AccountMeta::new(*stake_pubkey, false)].with_signer(custodian_pubkey);
let account_metas = vec![
AccountMeta::new(*stake_pubkey, false),
AccountMeta::new_readonly(*custodian_pubkey, true),
];
Instruction::new(id(), &StakeInstruction::SetLockup(*lockup), account_metas)
}

View File

@@ -12,7 +12,7 @@ use solana_metrics::inc_new_counter_info;
use solana_sdk::{
account::{get_signers, KeyedAccount},
hash::Hash,
instruction::{AccountMeta, Instruction, InstructionError, WithSigner},
instruction::{AccountMeta, Instruction, InstructionError},
program_utils::{limited_deserialize, next_keyed_account, DecodeError},
pubkey::Pubkey,
system_instruction,
@@ -108,8 +108,8 @@ fn initialize_account(vote_pubkey: &Pubkey, vote_init: &VoteInit) -> Instruction
AccountMeta::new(*vote_pubkey, false),
AccountMeta::new_readonly(sysvar::rent::id(), false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
]
.with_signer(&vote_init.node_pubkey);
AccountMeta::new_readonly(vote_init.node_pubkey, true),
];
Instruction::new(
id(),
@@ -162,8 +162,8 @@ pub fn authorize(
let account_metas = vec![
AccountMeta::new(*vote_pubkey, false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
]
.with_signer(authorized_pubkey);
AccountMeta::new_readonly(*authorized_pubkey, true),
];
Instruction::new(
id(),
@@ -180,8 +180,8 @@ pub fn update_validator_identity(
let account_metas = vec![
AccountMeta::new(*vote_pubkey, false),
AccountMeta::new_readonly(*node_pubkey, true),
]
.with_signer(authorized_withdrawer_pubkey);
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
];
Instruction::new(
id(),
@@ -195,8 +195,8 @@ pub fn vote(vote_pubkey: &Pubkey, authorized_voter_pubkey: &Pubkey, vote: Vote)
AccountMeta::new(*vote_pubkey, false),
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
]
.with_signer(authorized_voter_pubkey);
AccountMeta::new_readonly(*authorized_voter_pubkey, true),
];
Instruction::new(id(), &VoteInstruction::Vote(vote), account_metas)
}
@@ -211,8 +211,8 @@ pub fn vote_switch(
AccountMeta::new(*vote_pubkey, false),
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
]
.with_signer(authorized_voter_pubkey);
AccountMeta::new_readonly(*authorized_voter_pubkey, true),
];
Instruction::new(
id(),
@@ -230,8 +230,8 @@ pub fn withdraw(
let account_metas = vec![
AccountMeta::new(*vote_pubkey, false),
AccountMeta::new(*to_pubkey, false),
]
.with_signer(authorized_withdrawer_pubkey);
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
];
Instruction::new(id(), &VoteInstruction::Withdraw(lamports), account_metas)
}