Skip to main content

carbon_raydium_launchpad_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::{RaydiumLaunchpadDecoder, PROGRAM_ID};
3
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod global_config;
11pub mod platform_config;
12pub mod platform_global_access;
13pub mod pool_state;
14pub mod vesting_record;
15
16#[derive(Debug, Clone, PartialEq)]
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
19pub enum RaydiumLaunchpadAccount {
20    GlobalConfig(Box<global_config::GlobalConfig>),
21    PlatformConfig(Box<platform_config::PlatformConfig>),
22    PlatformGlobalAccess(Box<platform_global_access::PlatformGlobalAccess>),
23    PoolState(Box<pool_state::PoolState>),
24    VestingRecord(Box<vesting_record::VestingRecord>),
25}
26
27impl<'a> carbon_core::account::AccountDecoder<'a> for RaydiumLaunchpadDecoder {
28    type AccountType = RaydiumLaunchpadAccount;
29
30    fn decode_account(
31        &self,
32        account: &'a solana_account::Account,
33    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
34        if account.owner != PROGRAM_ID {
35            return None;
36        }
37
38        let data = account.data.as_slice();
39
40        {
41            if let Some(decoded) = global_config::GlobalConfig::decode(data) {
42                return Some(carbon_core::account::DecodedAccount {
43                    lamports: account.lamports,
44                    data: RaydiumLaunchpadAccount::GlobalConfig(Box::new(decoded)),
45                    owner: account.owner,
46                    executable: account.executable,
47                    rent_epoch: account.rent_epoch,
48                });
49            }
50        }
51        {
52            if let Some(decoded) = platform_config::PlatformConfig::decode(data) {
53                return Some(carbon_core::account::DecodedAccount {
54                    lamports: account.lamports,
55                    data: RaydiumLaunchpadAccount::PlatformConfig(Box::new(decoded)),
56                    owner: account.owner,
57                    executable: account.executable,
58                    rent_epoch: account.rent_epoch,
59                });
60            }
61        }
62        {
63            if let Some(decoded) = platform_global_access::PlatformGlobalAccess::decode(data) {
64                return Some(carbon_core::account::DecodedAccount {
65                    lamports: account.lamports,
66                    data: RaydiumLaunchpadAccount::PlatformGlobalAccess(Box::new(decoded)),
67                    owner: account.owner,
68                    executable: account.executable,
69                    rent_epoch: account.rent_epoch,
70                });
71            }
72        }
73        {
74            if let Some(decoded) = pool_state::PoolState::decode(data) {
75                return Some(carbon_core::account::DecodedAccount {
76                    lamports: account.lamports,
77                    data: RaydiumLaunchpadAccount::PoolState(Box::new(decoded)),
78                    owner: account.owner,
79                    executable: account.executable,
80                    rent_epoch: account.rent_epoch,
81                });
82            }
83        }
84        {
85            if let Some(decoded) = vesting_record::VestingRecord::decode(data) {
86                return Some(carbon_core::account::DecodedAccount {
87                    lamports: account.lamports,
88                    data: RaydiumLaunchpadAccount::VestingRecord(Box::new(decoded)),
89                    owner: account.owner,
90                    executable: account.executable,
91                    rent_epoch: account.rent_epoch,
92                });
93            }
94        }
95
96        None
97    }
98}