carbon_tcomp_decoder/accounts/
mod.rs

1use carbon_core::account::AccountDecoder;
2use carbon_core::deserialize::CarbonDeserialize;
3
4use super::TcompDecoder;
5pub mod bid_state;
6pub mod list_state;
7
8#[derive(Debug, serde::Serialize)]
9pub enum TcompAccount {
10    ListState(list_state::ListState),
11    BidState(bid_state::BidState),
12}
13
14impl<'a> AccountDecoder<'a> for TcompDecoder {
15    type AccountType = TcompAccount;
16    fn decode_account(
17        &self,
18        account: &solana_account::Account,
19    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
20        if let Some(decoded_account) = list_state::ListState::deserialize(account.data.as_slice()) {
21            return Some(carbon_core::account::DecodedAccount {
22                lamports: account.lamports,
23                data: TcompAccount::ListState(decoded_account),
24                owner: account.owner,
25                executable: account.executable,
26                rent_epoch: account.rent_epoch,
27            });
28        }
29
30        if let Some(decoded_account) = bid_state::BidState::deserialize(account.data.as_slice()) {
31            return Some(carbon_core::account::DecodedAccount {
32                lamports: account.lamports,
33                data: TcompAccount::BidState(decoded_account),
34                owner: account.owner,
35                executable: account.executable,
36                rent_epoch: account.rent_epoch,
37            });
38        }
39
40        None
41    }
42}