carbon_points_store_decoder/accounts/
mod.rs1use carbon_core::account::AccountDecoder;
2use carbon_core::deserialize::CarbonDeserialize;
3
4use super::PointsStoreDecoder;
5pub mod points_store;
6pub mod redemption_config;
7pub mod user_redemption;
8
9#[derive(Debug, serde::Serialize)]
10pub enum PointsStoreAccount {
11 PointsStore(points_store::PointsStore),
12 RedemptionConfig(redemption_config::RedemptionConfig),
13 UserRedemption(user_redemption::UserRedemption),
14}
15
16impl<'a> AccountDecoder<'a> for PointsStoreDecoder {
17 type AccountType = PointsStoreAccount;
18 fn decode_account(
19 &self,
20 account: &solana_account::Account,
21 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
22 if let Some(decoded_account) =
23 points_store::PointsStore::deserialize(account.data.as_slice())
24 {
25 return Some(carbon_core::account::DecodedAccount {
26 lamports: account.lamports,
27 data: PointsStoreAccount::PointsStore(decoded_account),
28 owner: account.owner,
29 executable: account.executable,
30 rent_epoch: account.rent_epoch,
31 });
32 }
33
34 if let Some(decoded_account) =
35 redemption_config::RedemptionConfig::deserialize(account.data.as_slice())
36 {
37 return Some(carbon_core::account::DecodedAccount {
38 lamports: account.lamports,
39 data: PointsStoreAccount::RedemptionConfig(decoded_account),
40 owner: account.owner,
41 executable: account.executable,
42 rent_epoch: account.rent_epoch,
43 });
44 }
45
46 if let Some(decoded_account) =
47 user_redemption::UserRedemption::deserialize(account.data.as_slice())
48 {
49 return Some(carbon_core::account::DecodedAccount {
50 lamports: account.lamports,
51 data: PointsStoreAccount::UserRedemption(decoded_account),
52 owner: account.owner,
53 executable: account.executable,
54 rent_epoch: account.rent_epoch,
55 });
56 }
57
58 None
59 }
60}