carbon-raydium-launchpad-decoder 2.0.0

Raydium Launchpad Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
/// Updates configuration parameters
/// # Arguments
/// * `ctx` - The context of accounts
/// * `param` - Parameter to update:
/// - 0: Update trade_fee_rate
/// - 1: Update fee owner
/// - 12: Toggle whether explicit platform authorization is required
/// * `value` - New value for the selected parameter
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct UpdateConfig {
    pub param: u8,
    pub value: u64,
}

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

impl UpdateConfig {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [29, 158, 252, 191, 10, 83, 219, 99] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for UpdateConfig {
    type ArrangedAccounts = UpdateConfigInstructionAccounts;

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

        let owner = next_account(&mut iter)?;
        let global_config = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(UpdateConfigInstructionAccounts {
            owner,
            global_config,
            remaining: remaining.to_vec(),
        })
    }
}