use {
carbon_core::graphql::primitives::{Pubkey, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Pool")]
pub struct PoolGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub pool_bump: U8,
pub index: i32,
pub creator: Pubkey,
pub base_mint: Pubkey,
pub quote_mint: Pubkey,
pub lp_mint: Pubkey,
pub pool_base_token_account: Pubkey,
pub pool_quote_token_account: Pubkey,
pub lp_supply: U64,
pub coin_creator: Pubkey,
pub is_mayhem_mode: bool,
pub is_cashback_coin: bool,
}
impl TryFrom<crate::accounts::postgres::PoolRow> for PoolGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::PoolRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
pool_bump: carbon_core::graphql::primitives::U8((*row.pool_bump) as u8),
index: *row.index,
creator: carbon_core::graphql::primitives::Pubkey(row.creator.0),
base_mint: carbon_core::graphql::primitives::Pubkey(row.base_mint.0),
quote_mint: carbon_core::graphql::primitives::Pubkey(row.quote_mint.0),
lp_mint: carbon_core::graphql::primitives::Pubkey(row.lp_mint.0),
pool_base_token_account: carbon_core::graphql::primitives::Pubkey(
row.pool_base_token_account.0,
),
pool_quote_token_account: carbon_core::graphql::primitives::Pubkey(
row.pool_quote_token_account.0,
),
lp_supply: carbon_core::graphql::primitives::U64(*row.lp_supply),
coin_creator: carbon_core::graphql::primitives::Pubkey(row.coin_creator.0),
is_mayhem_mode: row.is_mayhem_mode,
is_cashback_coin: row.is_cashback_coin,
})
}
}