carbon-heaven-decoder 2.0.0

Heaven 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 AdminMintMsol {
    pub version: u16,
    pub amount: u64,
}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AdminMintMsolInstructionAccounts {
    pub token_program: solana_pubkey::Pubkey,
    pub associated_token_program: solana_pubkey::Pubkey,
    pub payer: solana_pubkey::Pubkey,
    pub admin: solana_pubkey::Pubkey,
    pub protocol_config_state: solana_pubkey::Pubkey,
    pub system_program: solana_pubkey::Pubkey,
    pub protocol_staking_admin_state: solana_pubkey::Pubkey,
    pub address_lookup_program: solana_pubkey::Pubkey,
    pub instruction_sysvar_account_info: solana_pubkey::Pubkey,
    pub temp_sol_holder: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl AdminMintMsol {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [140, 202, 57, 195, 97, 213, 168, 19] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for AdminMintMsol {
    type ArrangedAccounts = AdminMintMsolInstructionAccounts;

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

        let token_program = next_account(&mut iter)?;
        let associated_token_program = next_account(&mut iter)?;
        let payer = next_account(&mut iter)?;
        let admin = next_account(&mut iter)?;
        let protocol_config_state = next_account(&mut iter)?;
        let system_program = next_account(&mut iter)?;
        let protocol_staking_admin_state = next_account(&mut iter)?;
        let address_lookup_program = next_account(&mut iter)?;
        let instruction_sysvar_account_info = next_account(&mut iter)?;
        let temp_sol_holder = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(AdminMintMsolInstructionAccounts {
            token_program,
            associated_token_program,
            payer,
            admin,
            protocol_config_state,
            system_program,
            protocol_staking_admin_state,
            address_lookup_program,
            instruction_sysvar_account_info,
            temp_sol_holder,
            remaining: remaining.to_vec(),
        })
    }
}