carbon_profile_vault_decoder/accounts/
mod.rs1use crate::PROGRAM_ID;
3use crate::ProfileVaultDecoder;
4
5pub mod vault_authority;
6
7#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
10pub enum ProfileVaultAccount {
11 VaultAuthority(Box<vault_authority::VaultAuthority>),
12}
13
14impl<'a> carbon_core::account::AccountDecoder<'a> for ProfileVaultDecoder {
15 type AccountType = ProfileVaultAccount;
16
17 fn decode_account(
18 &self,
19 account: &'a solana_account::Account,
20 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
21 if account.owner != PROGRAM_ID {
22 return None;
23 }
24
25 let data = account.data.as_slice();
26
27 {
28 if let Some(decoded) = vault_authority::VaultAuthority::decode(data) {
29 return Some(carbon_core::account::DecodedAccount {
30 lamports: account.lamports,
31 data: ProfileVaultAccount::VaultAuthority(Box::new(decoded)),
32 owner: account.owner,
33 executable: account.executable,
34 rent_epoch: account.rent_epoch,
35 });
36 }
37 }
38
39 None
40 }
41}