Skip to main content

carbon_address_lookup_table_decoder/accounts/
mod.rs

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