use {
crate::types::graphql::{PriceFeedMessageGraphQL, VerificationLevelGraphQL},
carbon_core::graphql::primitives::{Pubkey, U64},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PriceUpdateV2")]
pub struct PriceUpdateV2GraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub write_authority: Pubkey,
pub verification_level: VerificationLevelGraphQL,
pub price_message: PriceFeedMessageGraphQL,
pub posted_slot: U64,
}
impl TryFrom<crate::accounts::postgres::PriceUpdateV2Row> for PriceUpdateV2GraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::PriceUpdateV2Row) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
write_authority: carbon_core::graphql::primitives::Pubkey(row.write_authority.0),
verification_level: row.verification_level.0.into(),
price_message: row.price_message.0.into(),
posted_slot: carbon_core::graphql::primitives::U64(*row.posted_slot),
})
}
}