carbon_snapshots_decoder/accounts/
mod.rs

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