Make AccountMeta a traditional struct instead of a tuple struct
This commit is contained in:
@ -31,9 +31,9 @@ impl BudgetInstruction {
|
||||
pub fn new_initialize_account(contract: &Pubkey, expr: BudgetExpr) -> Instruction {
|
||||
let mut keys = vec![];
|
||||
if let BudgetExpr::Pay(payment) = &expr {
|
||||
keys.push(AccountMeta(payment.to, false));
|
||||
keys.push(AccountMeta::new(payment.to, false));
|
||||
}
|
||||
keys.push(AccountMeta(*contract, false));
|
||||
keys.push(AccountMeta::new(*contract, false));
|
||||
Instruction::new(id(), &BudgetInstruction::InitializeAccount(expr), keys)
|
||||
}
|
||||
|
||||
@ -43,18 +43,24 @@ impl BudgetInstruction {
|
||||
to: &Pubkey,
|
||||
dt: DateTime<Utc>,
|
||||
) -> Instruction {
|
||||
let mut keys = vec![AccountMeta(*from, true), AccountMeta(*contract, false)];
|
||||
let mut account_metas = vec![
|
||||
AccountMeta::new(*from, true),
|
||||
AccountMeta::new(*contract, false),
|
||||
];
|
||||
if from != to {
|
||||
keys.push(AccountMeta(*to, false));
|
||||
account_metas.push(AccountMeta::new(*to, false));
|
||||
}
|
||||
Instruction::new(id(), &BudgetInstruction::ApplyTimestamp(dt), keys)
|
||||
Instruction::new(id(), &BudgetInstruction::ApplyTimestamp(dt), account_metas)
|
||||
}
|
||||
|
||||
pub fn new_apply_signature(from: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruction {
|
||||
let mut keys = vec![AccountMeta(*from, true), AccountMeta(*contract, false)];
|
||||
let mut account_metas = vec![
|
||||
AccountMeta::new(*from, true),
|
||||
AccountMeta::new(*contract, false),
|
||||
];
|
||||
if from != to {
|
||||
keys.push(AccountMeta(*to, false));
|
||||
account_metas.push(AccountMeta::new(*to, false));
|
||||
}
|
||||
Instruction::new(id(), &BudgetInstruction::ApplySignature, keys)
|
||||
Instruction::new(id(), &BudgetInstruction::ApplySignature, account_metas)
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ impl ConfigInstruction {
|
||||
data: &T,
|
||||
) -> Instruction {
|
||||
let account_metas = vec![
|
||||
AccountMeta(*from_account_pubkey, true),
|
||||
AccountMeta(*config_account_pubkey, true),
|
||||
AccountMeta::new(*from_account_pubkey, true),
|
||||
AccountMeta::new(*config_account_pubkey, true),
|
||||
];
|
||||
Instruction::new(id(), data, account_metas)
|
||||
}
|
||||
|
@ -10,7 +10,10 @@ pub enum RewardsInstruction {
|
||||
|
||||
impl RewardsInstruction {
|
||||
pub fn new_redeem_vote_credits(vote_id: &Pubkey, rewards_id: &Pubkey) -> Instruction {
|
||||
let account_metas = vec![AccountMeta(*vote_id, true), AccountMeta(*rewards_id, false)];
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(*vote_id, true),
|
||||
AccountMeta::new(*rewards_id, false),
|
||||
];
|
||||
Instruction::new(id(), &RewardsInstruction::RedeemVoteCredits, account_metas)
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ fn test_vote_via_bank_with_no_signature() {
|
||||
let vote_ix = Instruction::new(
|
||||
solana_vote_api::id(),
|
||||
&VoteInstruction::Vote(Vote::new(0)),
|
||||
vec![AccountMeta(vote_id, false)], // <--- attack!! No signature.
|
||||
vec![AccountMeta::new(vote_id, false)], // <--- attack!! No signer required.
|
||||
);
|
||||
|
||||
// Sneak in an instruction so that the transaction is signed but
|
||||
|
@ -33,11 +33,11 @@ pub enum VoteInstruction {
|
||||
|
||||
impl VoteInstruction {
|
||||
pub fn new_clear_credits(vote_id: &Pubkey) -> Instruction {
|
||||
let account_metas = vec![AccountMeta(*vote_id, true)];
|
||||
let account_metas = vec![AccountMeta::new(*vote_id, true)];
|
||||
Instruction::new(id(), &VoteInstruction::ClearCredits, account_metas)
|
||||
}
|
||||
pub fn new_delegate_stake(vote_id: &Pubkey, delegate_id: &Pubkey) -> Instruction {
|
||||
let account_metas = vec![AccountMeta(*vote_id, true)];
|
||||
let account_metas = vec![AccountMeta::new(*vote_id, true)];
|
||||
Instruction::new(
|
||||
id(),
|
||||
&VoteInstruction::DelegateStake(*delegate_id),
|
||||
@ -45,7 +45,7 @@ impl VoteInstruction {
|
||||
)
|
||||
}
|
||||
pub fn new_authorize_voter(vote_id: &Pubkey, authorized_voter_id: &Pubkey) -> Instruction {
|
||||
let account_metas = vec![AccountMeta(*vote_id, true)];
|
||||
let account_metas = vec![AccountMeta::new(*vote_id, true)];
|
||||
Instruction::new(
|
||||
id(),
|
||||
&VoteInstruction::AuthorizeVoter(*authorized_voter_id),
|
||||
@ -53,11 +53,11 @@ impl VoteInstruction {
|
||||
)
|
||||
}
|
||||
pub fn new_initialize_account(vote_id: &Pubkey) -> Instruction {
|
||||
let account_metas = vec![AccountMeta(*vote_id, false)];
|
||||
let account_metas = vec![AccountMeta::new(*vote_id, false)];
|
||||
Instruction::new(id(), &VoteInstruction::InitializeAccount, account_metas)
|
||||
}
|
||||
pub fn new_vote(vote_id: &Pubkey, vote: Vote) -> Instruction {
|
||||
let account_metas = vec![AccountMeta(*vote_id, true)];
|
||||
let account_metas = vec![AccountMeta::new(*vote_id, true)];
|
||||
Instruction::new(id(), &VoteInstruction::Vote(vote), account_metas)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user