carbon-token-2022-decoder 1.0.0

Carbon Token 2022 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts},
    solana_pubkey::Pubkey,
};
/// Initialize a new mint with a group member pointer
/// Fails if the mint has already been initialized, so must be called before
/// `InitializeMint`.
/// The mint must have exactly enough space allocated for the base mint (82
/// bytes), plus 83 bytes of padding, 1 byte reserved for the account type,
/// then space required for this extension, plus any others.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct InitializeGroupMemberPointer {
    /// The public key for the account that can update the group member address.
    pub authority: Option<Pubkey>,
    /// The account address that holds the member.
    pub member_address: Option<Pubkey>,
}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializeGroupMemberPointerInstructionAccounts {
    pub mint: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl InitializeGroupMemberPointer {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 2 {
            return None;
        }
        let discriminator = data[0];
        if discriminator != 41 {
            return None;
        }
        let group_member_pointer_discriminator = data[1];
        if group_member_pointer_discriminator != 0 {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[1..];

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

impl ArrangeAccounts for InitializeGroupMemberPointer {
    type ArrangedAccounts = InitializeGroupMemberPointerInstructionAccounts;

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

        let mint = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(InitializeGroupMemberPointerInstructionAccounts {
            mint,
            remaining: remaining.to_vec(),
        })
    }
}