|
22 | 22 | serde_derive::{Deserialize, Serialize}, |
23 | 23 | }; |
24 | 24 |
|
| 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 | + |
25 | 33 | #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
26 | 34 | #[derive(Debug, PartialEq, Eq, Clone)] |
27 | 35 | pub enum VoteInstruction { |
@@ -190,6 +198,16 @@ pub enum VoteInstruction { |
190 | 198 | /// 0. `[WRITE]` Uninitialized vote account |
191 | 199 | /// 1. `[SIGNER]` New validator identity (node_pubkey) |
192 | 200 | 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), |
193 | 211 | } |
194 | 212 |
|
195 | 213 | impl VoteInstruction { |
@@ -509,6 +527,26 @@ pub fn update_commission( |
509 | 527 | ) |
510 | 528 | } |
511 | 529 |
|
| 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 | + |
512 | 550 | #[cfg(feature = "bincode")] |
513 | 551 | pub fn vote(vote_pubkey: &Pubkey, authorized_voter_pubkey: &Pubkey, vote: Vote) -> Instruction { |
514 | 552 | let account_metas = vec![ |
|
0 commit comments