carbon_phoenix_v1_decoder/accounts/
mod.rs

1use carbon_core::account::AccountDecoder;
2use carbon_core::deserialize::CarbonDeserialize;
3
4use crate::PROGRAM_ID;
5
6use super::PhoenixDecoder;
7pub mod market_header;
8pub mod seat;
9
10pub enum PhoenixAccount {
11    MarketHeader(Box<market_header::MarketHeader>),
12    Seat(seat::Seat),
13}
14
15impl AccountDecoder<'_> for PhoenixDecoder {
16    type AccountType = PhoenixAccount;
17    fn decode_account(
18        &self,
19        account: &solana_account::Account,
20    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
21        if !account.owner.eq(&PROGRAM_ID) {
22            return None;
23        }
24
25        if let Some(decoded_account) =
26            market_header::MarketHeader::deserialize(account.data.as_slice())
27        {
28            return Some(carbon_core::account::DecodedAccount {
29                lamports: account.lamports,
30                data: PhoenixAccount::MarketHeader(Box::new(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) = seat::Seat::deserialize(account.data.as_slice()) {
38            return Some(carbon_core::account::DecodedAccount {
39                lamports: account.lamports,
40                data: PhoenixAccount::Seat(decoded_account),
41                owner: account.owner,
42                executable: account.executable,
43                rent_epoch: account.rent_epoch,
44            });
45        }
46
47        None
48    }
49}