carbon_crew_decoder/accounts/
mod.rs1use carbon_core::account::AccountDecoder;
2use carbon_core::deserialize::CarbonDeserialize;
3
4use super::CrewDecoder;
5pub mod crew_config;
6pub mod pack_tiers;
7pub mod pack_type;
8pub mod sft_redemption;
9pub mod user_redemption;
10
11#[derive(Debug, serde::Serialize)]
12pub enum CrewAccount {
13 CrewConfig(crew_config::CrewConfig),
14 PackTiers(pack_tiers::PackTiers),
15 PackType(pack_type::PackType),
16 SftRedemption(sft_redemption::SftRedemption),
17 UserRedemption(user_redemption::UserRedemption),
18}
19
20impl<'a> AccountDecoder<'a> for CrewDecoder {
21 type AccountType = CrewAccount;
22 fn decode_account(
23 &self,
24 account: &solana_account::Account,
25 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
26 if let Some(decoded_account) = crew_config::CrewConfig::deserialize(account.data.as_slice())
27 {
28 return Some(carbon_core::account::DecodedAccount {
29 lamports: account.lamports,
30 data: CrewAccount::CrewConfig(decoded_account),
31 owner: account.owner,
32 executable: account.executable,
33 rent_epoch: account.rent_epoch,
34 });
35 }
36
37 if let Some(decoded_account) = pack_tiers::PackTiers::deserialize(account.data.as_slice()) {
38 return Some(carbon_core::account::DecodedAccount {
39 lamports: account.lamports,
40 data: CrewAccount::PackTiers(decoded_account),
41 owner: account.owner,
42 executable: account.executable,
43 rent_epoch: account.rent_epoch,
44 });
45 }
46
47 if let Some(decoded_account) = pack_type::PackType::deserialize(account.data.as_slice()) {
48 return Some(carbon_core::account::DecodedAccount {
49 lamports: account.lamports,
50 data: CrewAccount::PackType(decoded_account),
51 owner: account.owner,
52 executable: account.executable,
53 rent_epoch: account.rent_epoch,
54 });
55 }
56
57 if let Some(decoded_account) =
58 sft_redemption::SftRedemption::deserialize(account.data.as_slice())
59 {
60 return Some(carbon_core::account::DecodedAccount {
61 lamports: account.lamports,
62 data: CrewAccount::SftRedemption(decoded_account),
63 owner: account.owner,
64 executable: account.executable,
65 rent_epoch: account.rent_epoch,
66 });
67 }
68
69 if let Some(decoded_account) =
70 user_redemption::UserRedemption::deserialize(account.data.as_slice())
71 {
72 return Some(carbon_core::account::DecodedAccount {
73 lamports: account.lamports,
74 data: CrewAccount::UserRedemption(decoded_account),
75 owner: account.owner,
76 executable: account.executable,
77 rent_epoch: account.rent_epoch,
78 });
79 }
80
81 None
82 }
83}