Skip to main content

carbon_vertigo_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::{VertigoDecoder, PROGRAM_ID};
3
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod pool;
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 VertigoAccount {
16    Pool(Box<pool::Pool>),
17}
18
19impl<'a> carbon_core::account::AccountDecoder<'a> for VertigoDecoder {
20    type AccountType = VertigoAccount;
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) = pool::Pool::decode(data) {
34                return Some(carbon_core::account::DecodedAccount {
35                    lamports: account.lamports,
36                    data: VertigoAccount::Pool(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}