carbon_virtuals_decoder/accounts/
mod.rs

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