Label tuple with AccountMeta
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use crate::id;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::transaction::Instruction;
|
||||
use solana_sdk::transaction::{AccountMeta, Instruction};
|
||||
|
||||
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct Vote {
|
||||
@ -33,30 +33,31 @@ pub enum VoteInstruction {
|
||||
|
||||
impl VoteInstruction {
|
||||
pub fn new_clear_credits(vote_id: &Pubkey) -> Instruction {
|
||||
Instruction::new(id(), &VoteInstruction::ClearCredits, vec![(*vote_id, true)])
|
||||
let account_metas = vec![AccountMeta(*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)];
|
||||
Instruction::new(
|
||||
id(),
|
||||
&VoteInstruction::DelegateStake(*delegate_id),
|
||||
vec![(*vote_id, true)],
|
||||
account_metas,
|
||||
)
|
||||
}
|
||||
pub fn new_authorize_voter(vote_id: &Pubkey, authorized_voter_id: &Pubkey) -> Instruction {
|
||||
let account_metas = vec![AccountMeta(*vote_id, true)];
|
||||
Instruction::new(
|
||||
id(),
|
||||
&VoteInstruction::AuthorizeVoter(*authorized_voter_id),
|
||||
vec![(*vote_id, true)],
|
||||
account_metas,
|
||||
)
|
||||
}
|
||||
pub fn new_initialize_account(vote_id: &Pubkey) -> Instruction {
|
||||
Instruction::new(
|
||||
id(),
|
||||
&VoteInstruction::InitializeAccount,
|
||||
vec![(*vote_id, false)],
|
||||
)
|
||||
let account_metas = vec![AccountMeta(*vote_id, false)];
|
||||
Instruction::new(id(), &VoteInstruction::InitializeAccount, account_metas)
|
||||
}
|
||||
pub fn new_vote(vote_id: &Pubkey, vote: Vote) -> Instruction {
|
||||
Instruction::new(id(), &VoteInstruction::Vote(vote), vec![(*vote_id, true)])
|
||||
let account_metas = vec![AccountMeta(*vote_id, true)];
|
||||
Instruction::new(id(), &VoteInstruction::Vote(vote), account_metas)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user