carbon-bubblegum-decoder 2.0.0

Bubblegum Program Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct SetTreeDelegate {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SetTreeDelegateInstructionAccounts {
    pub tree_authority: solana_pubkey::Pubkey,
    pub tree_creator: solana_pubkey::Pubkey,
    pub new_tree_delegate: solana_pubkey::Pubkey,
    pub merkle_tree: solana_pubkey::Pubkey,
    pub system_program: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl SetTreeDelegate {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [253, 118, 66, 37, 190, 49, 154, 102] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
    }
}

impl ArrangeAccounts for SetTreeDelegate {
    type ArrangedAccounts = SetTreeDelegateInstructionAccounts;

    fn arrange_accounts(
        accounts: &[solana_instruction::AccountMeta],
    ) -> Option<Self::ArrangedAccounts> {
        let mut iter = accounts.iter();

        let tree_authority = next_account(&mut iter)?;
        let tree_creator = next_account(&mut iter)?;
        let new_tree_delegate = next_account(&mut iter)?;
        let merkle_tree = next_account(&mut iter)?;
        let system_program = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(SetTreeDelegateInstructionAccounts {
            tree_authority,
            tree_creator,
            new_tree_delegate,
            merkle_tree,
            system_program,
            remaining: remaining.to_vec(),
        })
    }
}