carbon-orca-whirlpool-decoder 1.0.0

Orca Whirlpool Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::DynamicTickGraphQL,
    carbon_core::graphql::primitives::{Pubkey, U128},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "DynamicTickArray")]
pub struct DynamicTickArrayGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub start_tick_index: i32,
    pub whirlpool: Pubkey,
    pub tick_bitmap: U128,
    pub ticks: Vec<DynamicTickGraphQL>,
}

impl TryFrom<crate::accounts::postgres::DynamicTickArrayRow> for DynamicTickArrayGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::DynamicTickArrayRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            start_tick_index: row.start_tick_index,
            whirlpool: carbon_core::graphql::primitives::Pubkey(row.whirlpool.0),
            tick_bitmap: carbon_core::graphql::primitives::U128(*row.tick_bitmap),
            ticks: row.ticks.0.into_iter().map(|item| item.into()).collect(),
        })
    }
}