carbon-raydium-launchpad-decoder 2.0.0

Raydium Launchpad Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::PlatformParams,
    carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts},
};
/// Create platform config account
/// # Arguments
/// * `ctx` - The context of accounts
///
/// # Fields
/// * `fee_rate` - Fee rate of the platform
/// * `name` - Name of the platform
/// * `web` - Website of the platform
/// * `img` - Image link of the platform
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct CreatePlatformConfig {
    pub platform_params: PlatformParams,
}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CreatePlatformConfigInstructionAccounts {
    pub platform_admin: solana_pubkey::Pubkey,
    pub platform_fee_wallet: solana_pubkey::Pubkey,
    pub platform_nft_wallet: solana_pubkey::Pubkey,
    pub platform_config: solana_pubkey::Pubkey,
    pub cpswap_config: solana_pubkey::Pubkey,
    pub system_program: solana_pubkey::Pubkey,
    pub transfer_fee_extension_authority: solana_pubkey::Pubkey,
    pub platform_vesting_wallet: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl CreatePlatformConfig {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [176, 90, 196, 175, 253, 113, 220, 20] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for CreatePlatformConfig {
    type ArrangedAccounts = CreatePlatformConfigInstructionAccounts;

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

        let platform_admin = next_account(&mut iter)?;
        let platform_fee_wallet = next_account(&mut iter)?;
        let platform_nft_wallet = next_account(&mut iter)?;
        let platform_config = next_account(&mut iter)?;
        let cpswap_config = next_account(&mut iter)?;
        let system_program = next_account(&mut iter)?;
        let transfer_fee_extension_authority = next_account(&mut iter)?;
        let platform_vesting_wallet = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(CreatePlatformConfigInstructionAccounts {
            platform_admin,
            platform_fee_wallet,
            platform_nft_wallet,
            platform_config,
            cpswap_config,
            system_program,
            transfer_fee_extension_authority,
            platform_vesting_wallet,
            remaining: remaining.to_vec(),
        })
    }
}