carbon-heaven-decoder 2.0.0

Heaven program decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::{FeeType, SlotFeeBracketsParams},
    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 SetProtocolSlotFees {
    pub version: u16,
    pub fee_type: FeeType,
    pub slot_fees: SlotFeeBracketsParams,
}

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

impl SetProtocolSlotFees {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [181, 82, 19, 15, 126, 205, 152, 242] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for SetProtocolSlotFees {
    type ArrangedAccounts = SetProtocolSlotFeesInstructionAccounts;

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

        let owner = next_account(&mut iter)?;
        let protocol_config_state = next_account(&mut iter)?;
        let protocol_owner_state = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(SetProtocolSlotFeesInstructionAccounts {
            owner,
            protocol_config_state,
            protocol_owner_state,
            remaining: remaining.to_vec(),
        })
    }
}