use {carbon_core::graphql::primitives::U64, juniper::GraphQLObject};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "SettlementAccount")]
pub struct SettlementAccountGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub settlement_price: U64,
pub strikes: Vec<U64>,
}
impl TryFrom<crate::accounts::postgres::SettlementAccountRow> for SettlementAccountGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::SettlementAccountRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
settlement_price: carbon_core::graphql::primitives::U64(*row.settlement_price),
strikes: row
.strikes
.into_iter()
.map(|item| carbon_core::graphql::primitives::U64(*item))
.collect(),
})
}
}