Skip to main content

carbon_stake_program_decoder/instructions/
move_stake.rs

1//! This code was AUTOGENERATED using the Codama library.
2use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
5pub struct MoveStake {
6    pub args: u64,
7}
8
9#[derive(Debug, Clone, PartialEq)]
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11pub struct MoveStakeInstructionAccounts {
12    pub source_stake: solana_pubkey::Pubkey,
13    pub destination_stake: solana_pubkey::Pubkey,
14    pub stake_authority: solana_pubkey::Pubkey,
15    pub remaining: Vec<solana_instruction::AccountMeta>,
16}
17
18impl MoveStake {
19    pub fn decode(data: &[u8]) -> Option<Self> {
20        if data.is_empty() {
21            return None;
22        }
23        let discriminator = &data[0..1];
24        if discriminator != [16] {
25            return None;
26        }
27
28        let mut data_slice = data;
29
30        data_slice = &data_slice[1..];
31
32        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
33    }
34}
35
36impl ArrangeAccounts for MoveStake {
37    type ArrangedAccounts = MoveStakeInstructionAccounts;
38
39    fn arrange_accounts(
40        accounts: &[solana_instruction::AccountMeta],
41    ) -> Option<Self::ArrangedAccounts> {
42        let mut iter = accounts.iter();
43
44        let source_stake = next_account(&mut iter)?;
45        let destination_stake = next_account(&mut iter)?;
46        let stake_authority = next_account(&mut iter)?;
47
48        let remaining = iter.as_slice();
49
50        Some(MoveStakeInstructionAccounts {
51            source_stake,
52            destination_stake,
53            stake_authority,
54            remaining: remaining.to_vec(),
55        })
56    }
57}