use crate::{SystemProgramDecoder, PROGRAM_ID};
#[cfg(feature = "postgres")]
pub mod postgres;
#[cfg(feature = "graphql")]
pub mod graphql;
pub mod nonce;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum SystemProgramAccount {
Nonce(Box<nonce::Nonce>),
}
impl<'a> carbon_core::account::AccountDecoder<'a> for SystemProgramDecoder {
type AccountType = SystemProgramAccount;
fn decode_account(
&self,
account: &'a solana_account::Account,
) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
if account.owner != PROGRAM_ID {
return None;
}
let data = account.data.as_slice();
{
if let Some(decoded) = nonce::Nonce::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: SystemProgramAccount::Nonce(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
None
}
}