carbon-heaven-decoder 2.0.0

Heaven program decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::{HeavenDecoder, PROGRAM_ID};

#[cfg(feature = "postgres")]
pub mod postgres;

#[cfg(feature = "graphql")]
pub mod graphql;

pub mod liquidity_pool_state;
pub mod msol_ticket_sol_spent;
pub mod protocol_admin_state;
pub mod protocol_config;
pub mod protocol_owner_state;
pub mod user_lp_position;

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum HeavenAccount {
    LiquidityPoolState(Box<liquidity_pool_state::LiquidityPoolState>),
    MsolTicketSolSpent(Box<msol_ticket_sol_spent::MsolTicketSolSpent>),
    ProtocolAdminState(Box<protocol_admin_state::ProtocolAdminState>),
    ProtocolConfig(Box<protocol_config::ProtocolConfig>),
    ProtocolOwnerState(Box<protocol_owner_state::ProtocolOwnerState>),
    UserLpPosition(Box<user_lp_position::UserLpPosition>),
}

impl<'a> carbon_core::account::AccountDecoder<'a> for HeavenDecoder {
    type AccountType = HeavenAccount;

    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) = liquidity_pool_state::LiquidityPoolState::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: HeavenAccount::LiquidityPoolState(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = msol_ticket_sol_spent::MsolTicketSolSpent::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: HeavenAccount::MsolTicketSolSpent(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = protocol_admin_state::ProtocolAdminState::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: HeavenAccount::ProtocolAdminState(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = protocol_config::ProtocolConfig::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: HeavenAccount::ProtocolConfig(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = protocol_owner_state::ProtocolOwnerState::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: HeavenAccount::ProtocolOwnerState(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = user_lp_position::UserLpPosition::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: HeavenAccount::UserLpPosition(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }

        None
    }
}