use {
carbon_core::graphql::primitives::{Pubkey, I64, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "StubOracle")]
pub struct StubOracleGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub owner: Pubkey,
pub mint: Pubkey,
pub price: f64,
pub last_update_ts: I64,
pub last_update_slot: U64,
pub deviation: f64,
pub reserved: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::StubOracleRow> for StubOracleGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::StubOracleRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
owner: carbon_core::graphql::primitives::Pubkey(row.owner.0),
mint: carbon_core::graphql::primitives::Pubkey(row.mint.0),
price: row.price,
last_update_ts: carbon_core::graphql::primitives::I64(row.last_update_ts),
last_update_slot: carbon_core::graphql::primitives::U64(*row.last_update_slot),
deviation: row.deviation,
reserved: row
.reserved
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
})
}
}