carbon_token_2022_decoder/instructions/
initialize_account2.rs

1//! This code was AUTOGENERATED using the Codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun Codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7use carbon_core::account_utils::next_account;
8use carbon_core::borsh;
9use carbon_core::deserialize::ArrangeAccounts;
10use carbon_core::deserialize::CarbonDeserialize;
11use carbon_core::CarbonDeserialize;
12use solana_pubkey::Pubkey;
13
14/// Like InitializeAccount, but the owner pubkey is passed via instruction
15/// data rather than the accounts list. This variant may be preferable
16/// when using Cross Program Invocation from an instruction that does
17/// not need the owner's `AccountInfo` otherwise.
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
20pub struct InitializeAccount2 {
21    /// The new account's owner/multisignature.
22    pub owner: Pubkey,
23}
24
25#[derive(Debug, Clone, PartialEq)]
26#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
27pub struct InitializeAccount2InstructionAccounts {
28    pub account: solana_pubkey::Pubkey,
29    pub mint: solana_pubkey::Pubkey,
30    pub rent: solana_pubkey::Pubkey,
31    pub remaining: Vec<solana_instruction::AccountMeta>,
32}
33
34impl InitializeAccount2 {
35    pub fn decode(data: &[u8]) -> Option<Self> {
36        if data.is_empty() {
37            return None;
38        }
39        let discriminator = &data[0..1];
40        if discriminator != [16] {
41            return None;
42        }
43
44        let data_slice = data;
45
46        let data_slice = &data_slice[1..];
47
48        Self::deserialize(data_slice)
49    }
50}
51
52impl ArrangeAccounts for InitializeAccount2 {
53    type ArrangedAccounts = InitializeAccount2InstructionAccounts;
54
55    fn arrange_accounts(
56        accounts: &[solana_instruction::AccountMeta],
57    ) -> Option<Self::ArrangedAccounts> {
58        let mut iter = accounts.iter();
59
60        let account = next_account(&mut iter)?;
61        let mint = next_account(&mut iter)?;
62        let rent = next_account(&mut iter)?;
63
64        let remaining = iter.as_slice();
65
66        Some(InitializeAccount2InstructionAccounts {
67            account,
68            mint,
69            rent,
70            remaining: remaining.to_vec(),
71        })
72    }
73}