Skip to main content

carbon_system_program_decoder/instructions/
upgrade_nonce_account.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 UpgradeNonceAccount {}
6
7#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct UpgradeNonceAccountInstructionAccounts {
10    pub nonce_account: solana_pubkey::Pubkey,
11    pub remaining: Vec<solana_instruction::AccountMeta>,
12}
13
14impl UpgradeNonceAccount {
15    pub fn decode(data: &[u8]) -> Option<Self> {
16        if data.len() < 4 {
17            return None;
18        }
19        let discriminator = &data[0..4];
20        if discriminator != [12, 0, 0, 0] {
21            return None;
22        }
23
24        let mut data_slice = data;
25
26        data_slice = &data_slice[4..];
27
28        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
29    }
30}
31
32impl ArrangeAccounts for UpgradeNonceAccount {
33    type ArrangedAccounts = UpgradeNonceAccountInstructionAccounts;
34
35    fn arrange_accounts(
36        accounts: &[solana_instruction::AccountMeta],
37    ) -> Option<Self::ArrangedAccounts> {
38        let mut iter = accounts.iter();
39
40        let nonce_account = next_account(&mut iter)?;
41
42        let remaining = iter.as_slice();
43
44        Some(UpgradeNonceAccountInstructionAccounts {
45            nonce_account,
46            remaining: remaining.to_vec(),
47        })
48    }
49}