Add a transaction and instruction
This commit is contained in:
parent
5979627258
commit
97f2c96a7e
|
@ -23,6 +23,8 @@ pub enum VoteInstruction {
|
|||
InitializeAccount,
|
||||
/// `Delegate` or `Assign` a vote account to a particular node
|
||||
DelegateStake(Pubkey),
|
||||
/// Authorize a voter to send signed votes.
|
||||
AuthorizeVoter(Pubkey),
|
||||
Vote(Vote),
|
||||
/// Clear the credits in the vote account
|
||||
/// * Transaction::keys[0] - the "vote account"
|
||||
|
@ -40,6 +42,13 @@ impl VoteInstruction {
|
|||
vec![(vote_id, true)],
|
||||
)
|
||||
}
|
||||
pub fn new_authorize_voter(vote_id: Pubkey, authorized_voter_id: Pubkey) -> BuilderInstruction {
|
||||
BuilderInstruction::new(
|
||||
id(),
|
||||
&VoteInstruction::AuthorizeVoter(authorized_voter_id),
|
||||
vec![(vote_id, true)],
|
||||
)
|
||||
}
|
||||
pub fn new_initialize_account(vote_id: Pubkey) -> BuilderInstruction {
|
||||
BuilderInstruction::new(
|
||||
id(),
|
||||
|
|
|
@ -73,6 +73,21 @@ impl VoteTransaction {
|
|||
.sign(&[from_keypair, voter_keypair], recent_blockhash)
|
||||
}
|
||||
|
||||
/// Choose a voter id to accept signed votes from
|
||||
pub fn new_authorize_voter(
|
||||
vote_keypair: &Keypair,
|
||||
recent_blockhash: Hash,
|
||||
authorized_voter_id: Pubkey,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
TransactionBuilder::new(fee)
|
||||
.push(VoteInstruction::new_authorize_voter(
|
||||
vote_keypair.pubkey(),
|
||||
authorized_voter_id,
|
||||
))
|
||||
.sign(&[vote_keypair], recent_blockhash)
|
||||
}
|
||||
|
||||
/// Choose a node id to `delegate` or `assign` this vote account to
|
||||
pub fn delegate_vote_account<T: KeypairUtil>(
|
||||
vote_keypair: &T,
|
||||
|
|
Loading…
Reference in New Issue