carbon_points_store_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::PROGRAM_ID;
3use crate::PointsStoreDecoder;
4
5pub mod points_store;
6pub mod redemption_config;
7pub mod user_redemption;
8
9#[derive(Debug, Clone, PartialEq)]
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
12pub enum PointsStoreAccount {
13    PointsStore(Box<points_store::PointsStore>),
14    RedemptionConfig(Box<redemption_config::RedemptionConfig>),
15    UserRedemption(Box<user_redemption::UserRedemption>),
16}
17
18impl<'a> carbon_core::account::AccountDecoder<'a> for PointsStoreDecoder {
19    type AccountType = PointsStoreAccount;
20
21    fn decode_account(
22        &self,
23        account: &'a solana_account::Account,
24    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
25        if account.owner != PROGRAM_ID {
26            return None;
27        }
28
29        let data = account.data.as_slice();
30
31        {
32            if let Some(decoded) = points_store::PointsStore::decode(data) {
33                return Some(carbon_core::account::DecodedAccount {
34                    lamports: account.lamports,
35                    data: PointsStoreAccount::PointsStore(Box::new(decoded)),
36                    owner: account.owner,
37                    executable: account.executable,
38                    rent_epoch: account.rent_epoch,
39                });
40            }
41        }
42        {
43            if let Some(decoded) = redemption_config::RedemptionConfig::decode(data) {
44                return Some(carbon_core::account::DecodedAccount {
45                    lamports: account.lamports,
46                    data: PointsStoreAccount::RedemptionConfig(Box::new(decoded)),
47                    owner: account.owner,
48                    executable: account.executable,
49                    rent_epoch: account.rent_epoch,
50                });
51            }
52        }
53        {
54            if let Some(decoded) = user_redemption::UserRedemption::decode(data) {
55                return Some(carbon_core::account::DecodedAccount {
56                    lamports: account.lamports,
57                    data: PointsStoreAccount::UserRedemption(Box::new(decoded)),
58                    owner: account.owner,
59                    executable: account.executable,
60                    rent_epoch: account.rent_epoch,
61                });
62            }
63        }
64
65        None
66    }
67}