Skip to content

Commit 24391dd

Browse files
authored
SIMD-0232: UpdateCommissionCollector (#465)
1 parent 0dc94bb commit 24391dd

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

vote-interface/src/instruction.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ use {
2222
serde_derive::{Deserialize, Serialize},
2323
};
2424

25+
#[repr(u8)]
26+
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
27+
#[derive(Debug, PartialEq, Eq, Clone)]
28+
pub enum CommissionKind {
29+
InflationRewards = 0,
30+
BlockRevenue = 1,
31+
}
32+
2533
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
2634
#[derive(Debug, PartialEq, Eq, Clone)]
2735
pub enum VoteInstruction {
@@ -190,6 +198,16 @@ pub enum VoteInstruction {
190198
/// 0. `[WRITE]` Uninitialized vote account
191199
/// 1. `[SIGNER]` New validator identity (node_pubkey)
192200
InitializeAccountV2(VoteInitV2),
201+
202+
/// Update the commission collector for the vote account
203+
///
204+
/// # Account references
205+
/// 0. `[WRITE]` Vote account to be updated with the new collector public key
206+
/// 1. `[WRITE]` New collector account. Must be set to the vote account or
207+
/// a system program owned account. Must be writable to ensure the
208+
/// account is not reserved.
209+
/// 2. `[SIGNER]` Vote account withdraw authority
210+
UpdateCommissionCollector(CommissionKind),
193211
}
194212

195213
impl VoteInstruction {
@@ -509,6 +527,26 @@ pub fn update_commission(
509527
)
510528
}
511529

530+
#[cfg(feature = "bincode")]
531+
pub fn update_commission_collector(
532+
vote_pubkey: &Pubkey,
533+
authorized_withdrawer_pubkey: &Pubkey,
534+
new_collector_pubkey: &Pubkey,
535+
kind: CommissionKind,
536+
) -> Instruction {
537+
let account_metas = vec![
538+
AccountMeta::new(*vote_pubkey, false),
539+
AccountMeta::new(*new_collector_pubkey, false),
540+
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
541+
];
542+
543+
Instruction::new_with_bincode(
544+
id(),
545+
&VoteInstruction::UpdateCommissionCollector(kind),
546+
account_metas,
547+
)
548+
}
549+
512550
#[cfg(feature = "bincode")]
513551
pub fn vote(vote_pubkey: &Pubkey, authorized_voter_pubkey: &Pubkey, vote: Vote) -> Instruction {
514552
let account_metas = vec![

0 commit comments

Comments
 (0)