carbon_stake_program_decoder/instructions/
delegate_stake.rs

1use carbon_core::{borsh, CarbonDeserialize};
2
3#[derive(
4    CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
5)]
6#[carbon(discriminator = "0x326e5fb3c24b8cf6")]
7pub struct DelegateStake {}
8
9pub struct DelegateStakeInstructionAccounts {
10    pub stake: solana_pubkey::Pubkey,
11    pub vote: solana_pubkey::Pubkey,
12    pub clock: solana_pubkey::Pubkey,
13    pub stake_history: solana_pubkey::Pubkey,
14    pub stake_config: solana_pubkey::Pubkey,
15    pub stake_authority: solana_pubkey::Pubkey,
16}
17
18impl carbon_core::deserialize::ArrangeAccounts for DelegateStake {
19    type ArrangedAccounts = DelegateStakeInstructionAccounts;
20
21    fn arrange_accounts(
22        accounts: &[solana_instruction::AccountMeta],
23    ) -> Option<Self::ArrangedAccounts> {
24        let [stake, vote, clock, stake_history, stake_config, stake_authority, _remaining @ ..] =
25            accounts
26        else {
27            return None;
28        };
29
30        Some(DelegateStakeInstructionAccounts {
31            stake: stake.pubkey,
32            vote: vote.pubkey,
33            clock: clock.pubkey,
34            stake_history: stake_history.pubkey,
35            stake_config: stake_config.pubkey,
36            stake_authority: stake_authority.pubkey,
37        })
38    }
39}