Skip to main content

carbon_bubblegum_decoder/instructions/
create_tree.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 CreateTree {
6    pub max_depth: u32,
7    pub max_buffer_size: u32,
8    pub public: Option<bool>,
9}
10
11#[derive(Debug, Clone, PartialEq)]
12#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
13pub struct CreateTreeInstructionAccounts {
14    pub tree_authority: solana_pubkey::Pubkey,
15    pub merkle_tree: solana_pubkey::Pubkey,
16    pub payer: solana_pubkey::Pubkey,
17    pub tree_creator: solana_pubkey::Pubkey,
18    pub log_wrapper: solana_pubkey::Pubkey,
19    pub compression_program: solana_pubkey::Pubkey,
20    pub system_program: solana_pubkey::Pubkey,
21    pub remaining: Vec<solana_instruction::AccountMeta>,
22}
23
24impl CreateTree {
25    pub fn decode(data: &[u8]) -> Option<Self> {
26        if data.len() < 8 {
27            return None;
28        }
29        let discriminator = &data[0..8];
30        if discriminator != [165, 83, 136, 142, 89, 202, 47, 220] {
31            return None;
32        }
33
34        let mut data_slice = data;
35
36        data_slice = &data_slice[8..];
37
38        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
39    }
40}
41
42impl ArrangeAccounts for CreateTree {
43    type ArrangedAccounts = CreateTreeInstructionAccounts;
44
45    fn arrange_accounts(
46        accounts: &[solana_instruction::AccountMeta],
47    ) -> Option<Self::ArrangedAccounts> {
48        let mut iter = accounts.iter();
49
50        let tree_authority = next_account(&mut iter)?;
51        let merkle_tree = next_account(&mut iter)?;
52        let payer = next_account(&mut iter)?;
53        let tree_creator = next_account(&mut iter)?;
54        let log_wrapper = next_account(&mut iter)?;
55        let compression_program = next_account(&mut iter)?;
56        let system_program = next_account(&mut iter)?;
57
58        let remaining = iter.as_slice();
59
60        Some(CreateTreeInstructionAccounts {
61            tree_authority,
62            merkle_tree,
63            payer,
64            tree_creator,
65            log_wrapper,
66            compression_program,
67            system_program,
68            remaining: remaining.to_vec(),
69        })
70    }
71}