Skip to main content

carbon_jupiter_limit_order_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::{JupiterLimitOrderDecoder, PROGRAM_ID};
3
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod fee;
11pub mod order;
12
13#[derive(Debug, Clone, PartialEq)]
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
16pub enum JupiterLimitOrderAccount {
17    Fee(Box<fee::Fee>),
18    Order(Box<order::Order>),
19}
20
21impl<'a> carbon_core::account::AccountDecoder<'a> for JupiterLimitOrderDecoder {
22    type AccountType = JupiterLimitOrderAccount;
23
24    fn decode_account(
25        &self,
26        account: &'a solana_account::Account,
27    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
28        if account.owner != PROGRAM_ID {
29            return None;
30        }
31
32        let data = account.data.as_slice();
33
34        {
35            if let Some(decoded) = fee::Fee::decode(data) {
36                return Some(carbon_core::account::DecodedAccount {
37                    lamports: account.lamports,
38                    data: JupiterLimitOrderAccount::Fee(Box::new(decoded)),
39                    owner: account.owner,
40                    executable: account.executable,
41                    rent_epoch: account.rent_epoch,
42                });
43            }
44        }
45        {
46            if let Some(decoded) = order::Order::decode(data) {
47                return Some(carbon_core::account::DecodedAccount {
48                    lamports: account.lamports,
49                    data: JupiterLimitOrderAccount::Order(Box::new(decoded)),
50                    owner: account.owner,
51                    executable: account.executable,
52                    rent_epoch: account.rent_epoch,
53                });
54            }
55        }
56
57        None
58    }
59}