Skip to main content

carbon_wavebreak_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::{WavebreakDecoder, PROGRAM_ID};
3
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod authority_config;
11pub mod bonding_curve;
12pub mod consumed_permission;
13pub mod mint_config;
14pub mod permission_config;
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 WavebreakAccount {
20    AuthorityConfig(Box<authority_config::AuthorityConfig>),
21    BondingCurve(Box<bonding_curve::BondingCurve>),
22    ConsumedPermission(Box<consumed_permission::ConsumedPermission>),
23    MintConfig(Box<mint_config::MintConfig>),
24    PermissionConfig(Box<permission_config::PermissionConfig>),
25}
26
27impl<'a> carbon_core::account::AccountDecoder<'a> for WavebreakDecoder {
28    type AccountType = WavebreakAccount;
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) = authority_config::AuthorityConfig::decode(data) {
42                return Some(carbon_core::account::DecodedAccount {
43                    lamports: account.lamports,
44                    data: WavebreakAccount::AuthorityConfig(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) = bonding_curve::BondingCurve::decode(data) {
53                return Some(carbon_core::account::DecodedAccount {
54                    lamports: account.lamports,
55                    data: WavebreakAccount::BondingCurve(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) = mint_config::MintConfig::decode(data) {
64                return Some(carbon_core::account::DecodedAccount {
65                    lamports: account.lamports,
66                    data: WavebreakAccount::MintConfig(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) = permission_config::PermissionConfig::decode(data) {
75                return Some(carbon_core::account::DecodedAccount {
76                    lamports: account.lamports,
77                    data: WavebreakAccount::PermissionConfig(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) = consumed_permission::ConsumedPermission::decode(data) {
86                return Some(carbon_core::account::DecodedAccount {
87                    lamports: account.lamports,
88                    data: WavebreakAccount::ConsumedPermission(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}