use {
carbon_core::graphql::primitives::{I64, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PythLazerOracle")]
pub struct PythLazerOracleGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub price: I64,
pub publish_time: U64,
pub posted_slot: U64,
pub exponent: i32,
pub padding: Vec<U8>,
pub conf: U64,
}
impl TryFrom<crate::accounts::postgres::PythLazerOracleRow> for PythLazerOracleGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::PythLazerOracleRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
price: carbon_core::graphql::primitives::I64(row.price),
publish_time: carbon_core::graphql::primitives::U64(*row.publish_time),
posted_slot: carbon_core::graphql::primitives::U64(*row.posted_slot),
exponent: row.exponent,
padding: row
.padding
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
conf: carbon_core::graphql::primitives::U64(*row.conf),
})
}
}