carbon_system_program_decoder/accounts/
mod.rs

1use carbon_core::account::AccountDecoder;
2use carbon_core::deserialize::CarbonDeserialize;
3
4use super::SystemProgramDecoder;
5pub mod nonce;
6
7pub enum SystemAccount {
8    Nonce(nonce::Nonce),
9}
10
11impl AccountDecoder<'_> for SystemProgramDecoder {
12    type AccountType = SystemAccount;
13    fn decode_account(
14        &self,
15        account: &solana_account::Account,
16    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
17        if !account.owner.eq(&solana_program::system_program::id()) {
18            return None;
19        }
20
21        if let Some(decoded_account) = nonce::Nonce::deserialize(account.data.as_slice()) {
22            return Some(carbon_core::account::DecodedAccount {
23                lamports: account.lamports,
24                data: SystemAccount::Nonce(decoded_account),
25                owner: account.owner,
26                executable: account.executable,
27                rent_epoch: account.rent_epoch,
28            });
29        }
30
31        None
32    }
33}