Skip to main content

carbon_system_program_decoder/accounts/
mod.rs

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