use {
crate::types::graphql::PoolStateGraphQL,
carbon_core::graphql::primitives::{Pubkey, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "VirtualsPool")]
pub struct VirtualsPoolGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub creator: Pubkey,
pub mint: Pubkey,
pub virtual_y: U64,
pub graduation_x: U64,
pub state: PoolStateGraphQL,
pub bump: U8,
}
impl TryFrom<crate::accounts::postgres::VirtualsPoolRow> for VirtualsPoolGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::VirtualsPoolRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
creator: carbon_core::graphql::primitives::Pubkey(row.creator.0),
mint: carbon_core::graphql::primitives::Pubkey(row.mint.0),
virtual_y: carbon_core::graphql::primitives::U64(*row.virtual_y),
graduation_x: carbon_core::graphql::primitives::U64(*row.graduation_x),
state: row.state.0.into(),
bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
})
}
}