carbon_system_program_decoder/accounts/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use carbon_core::account::{AccountDecoder, DecodedAccount};
use solana_sdk::account::ReadableAccount;

use crate::SystemProgramDecoder;
pub enum SystemProgramAccount {
    Account(Vec<u8>),
}

impl<'a> AccountDecoder<'a> for SystemProgramDecoder {
    type AccountType = SystemProgramAccount;

    fn decode_account(
        &self,
        account: &solana_sdk::account::Account,
    ) -> Option<DecodedAccount<Self::AccountType>> {
        if account.owner() != &solana_sdk::system_program::id() {
            return None;
        }

        Some(DecodedAccount {
            data: SystemProgramAccount::Account(account.data.clone()),
            lamports: account.lamports,
            owner: account.owner,
            executable: account.executable,
            rent_epoch: account.rent_epoch,
        })
    }
}