Skip to main content

carbon_mpl_core_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::{MplCoreDecoder, PROGRAM_ID};
3
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod asset_v1;
11pub mod collection_v1;
12pub mod group_v1;
13pub mod hashed_asset_v1;
14pub mod plugin_header_v1;
15pub mod plugin_registry_v1;
16
17#[derive(Debug, Clone, PartialEq)]
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
20pub enum MplCoreAccount {
21    AssetV1(Box<asset_v1::AssetV1>),
22    CollectionV1(Box<collection_v1::CollectionV1>),
23    GroupV1(Box<group_v1::GroupV1>),
24    HashedAssetV1(Box<hashed_asset_v1::HashedAssetV1>),
25    PluginHeaderV1(Box<plugin_header_v1::PluginHeaderV1>),
26    PluginRegistryV1(Box<plugin_registry_v1::PluginRegistryV1>),
27}
28
29impl<'a> carbon_core::account::AccountDecoder<'a> for MplCoreDecoder {
30    type AccountType = MplCoreAccount;
31
32    fn decode_account(
33        &self,
34        account: &'a solana_account::Account,
35    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
36        if account.owner != PROGRAM_ID {
37            return None;
38        }
39
40        let data = account.data.as_slice();
41
42        {
43            if let Some(decoded) = plugin_header_v1::PluginHeaderV1::decode(data) {
44                return Some(carbon_core::account::DecodedAccount {
45                    lamports: account.lamports,
46                    data: MplCoreAccount::PluginHeaderV1(Box::new(decoded)),
47                    owner: account.owner,
48                    executable: account.executable,
49                    rent_epoch: account.rent_epoch,
50                });
51            }
52        }
53        {
54            if let Some(decoded) = plugin_registry_v1::PluginRegistryV1::decode(data) {
55                return Some(carbon_core::account::DecodedAccount {
56                    lamports: account.lamports,
57                    data: MplCoreAccount::PluginRegistryV1(Box::new(decoded)),
58                    owner: account.owner,
59                    executable: account.executable,
60                    rent_epoch: account.rent_epoch,
61                });
62            }
63        }
64        {
65            if let Some(decoded) = asset_v1::AssetV1::decode(data) {
66                return Some(carbon_core::account::DecodedAccount {
67                    lamports: account.lamports,
68                    data: MplCoreAccount::AssetV1(Box::new(decoded)),
69                    owner: account.owner,
70                    executable: account.executable,
71                    rent_epoch: account.rent_epoch,
72                });
73            }
74        }
75        {
76            if let Some(decoded) = collection_v1::CollectionV1::decode(data) {
77                return Some(carbon_core::account::DecodedAccount {
78                    lamports: account.lamports,
79                    data: MplCoreAccount::CollectionV1(Box::new(decoded)),
80                    owner: account.owner,
81                    executable: account.executable,
82                    rent_epoch: account.rent_epoch,
83                });
84            }
85        }
86        {
87            if let Some(decoded) = group_v1::GroupV1::decode(data) {
88                return Some(carbon_core::account::DecodedAccount {
89                    lamports: account.lamports,
90                    data: MplCoreAccount::GroupV1(Box::new(decoded)),
91                    owner: account.owner,
92                    executable: account.executable,
93                    rent_epoch: account.rent_epoch,
94                });
95            }
96        }
97        {
98            if let Some(decoded) = hashed_asset_v1::HashedAssetV1::decode(data) {
99                return Some(carbon_core::account::DecodedAccount {
100                    lamports: account.lamports,
101                    data: MplCoreAccount::HashedAssetV1(Box::new(decoded)),
102                    owner: account.owner,
103                    executable: account.executable,
104                    rent_epoch: account.rent_epoch,
105                });
106            }
107        }
108
109        None
110    }
111}