use crate::{VirtualsDecoder, PROGRAM_ID};
#[cfg(feature = "postgres")]
pub mod postgres;
#[cfg(feature = "graphql")]
pub mod graphql;
pub mod virtuals_pool;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum VirtualsAccount {
VirtualsPool(Box<virtuals_pool::VirtualsPool>),
}
impl<'a> carbon_core::account::AccountDecoder<'a> for VirtualsDecoder {
type AccountType = VirtualsAccount;
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) = virtuals_pool::VirtualsPool::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: VirtualsAccount::VirtualsPool(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
None
}
}