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 CreateOrUpdateProtocolStakingAdmin {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CreateOrUpdateProtocolStakingAdminInstructionAccounts {
    pub system_program: solana_pubkey::Pubkey,
    pub payer: solana_pubkey::Pubkey,
    pub current_owner: solana_pubkey::Pubkey,
    pub protocol_owner_state: solana_pubkey::Pubkey,
    pub new_admin: solana_pubkey::Pubkey,
    pub protocol_staking_admin_state: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl CreateOrUpdateProtocolStakingAdmin {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [4, 172, 196, 213, 120, 50, 30, 137] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for CreateOrUpdateProtocolStakingAdmin {
    type ArrangedAccounts = CreateOrUpdateProtocolStakingAdminInstructionAccounts;

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

        let system_program = next_account(&mut iter)?;
        let payer = next_account(&mut iter)?;
        let current_owner = next_account(&mut iter)?;
        let protocol_owner_state = next_account(&mut iter)?;
        let new_admin = next_account(&mut iter)?;
        let protocol_staking_admin_state = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(CreateOrUpdateProtocolStakingAdminInstructionAccounts {
            system_program,
            payer,
            current_owner,
            protocol_owner_state,
            new_admin,
            protocol_staking_admin_state,
            remaining: remaining.to_vec(),
        })
    }
}