use {
carbon_core::graphql::primitives::{Pubkey, U32, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "OpenOrdersIndexer")]
pub struct OpenOrdersIndexerGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub bump: U8,
pub created_counter: U32,
pub addresses: Vec<Pubkey>,
}
impl TryFrom<crate::accounts::postgres::OpenOrdersIndexerRow> for OpenOrdersIndexerGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::OpenOrdersIndexerRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
created_counter: carbon_core::graphql::primitives::U32((*row.created_counter) as u32),
addresses: row
.addresses
.into_iter()
.map(|item| carbon_core::graphql::primitives::Pubkey(item.0))
.collect(),
})
}
}