Skip to main content

carbon_system_program_decoder/instructions/
authorize_nonce_account.rs

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