carbon-raydium-launchpad-decoder 2.0.0

Raydium Launchpad Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::{RaydiumLaunchpadDecoder, PROGRAM_ID};

#[cfg(feature = "postgres")]
pub mod postgres;

#[cfg(feature = "graphql")]
pub mod graphql;

pub mod global_config;
pub mod platform_config;
pub mod platform_global_access;
pub mod pool_state;
pub mod vesting_record;

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum RaydiumLaunchpadAccount {
    GlobalConfig(Box<global_config::GlobalConfig>),
    PlatformConfig(Box<platform_config::PlatformConfig>),
    PlatformGlobalAccess(Box<platform_global_access::PlatformGlobalAccess>),
    PoolState(Box<pool_state::PoolState>),
    VestingRecord(Box<vesting_record::VestingRecord>),
}

impl<'a> carbon_core::account::AccountDecoder<'a> for RaydiumLaunchpadDecoder {
    type AccountType = RaydiumLaunchpadAccount;

    fn decode_account(
        &self,
        account: &'a solana_account::Account,
    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
        if account.owner != PROGRAM_ID {
            return None;
        }

        let data = account.data.as_slice();

        {
            if let Some(decoded) = global_config::GlobalConfig::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: RaydiumLaunchpadAccount::GlobalConfig(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = platform_config::PlatformConfig::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: RaydiumLaunchpadAccount::PlatformConfig(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = platform_global_access::PlatformGlobalAccess::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: RaydiumLaunchpadAccount::PlatformGlobalAccess(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = pool_state::PoolState::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: RaydiumLaunchpadAccount::PoolState(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = vesting_record::VestingRecord::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: RaydiumLaunchpadAccount::VestingRecord(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }

        None
    }
}