use {
crate::types::graphql::TickGraphQL, carbon_core::graphql::primitives::Pubkey,
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "TickArray")]
pub struct TickArrayGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub start_tick_index: i32,
pub ticks: Vec<TickGraphQL>,
pub whirlpool: Pubkey,
}
impl TryFrom<crate::accounts::postgres::TickArrayRow> for TickArrayGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::TickArrayRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
start_tick_index: row.start_tick_index,
ticks: row.ticks.0.into_iter().map(|item| item.into()).collect(),
whirlpool: carbon_core::graphql::primitives::Pubkey(row.whirlpool.0),
})
}
}