use {
crate::types::graphql::{NonceStateGraphQL, NonceVersionGraphQL},
carbon_core::graphql::primitives::{Pubkey, U64},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Nonce")]
pub struct NonceGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub version: NonceVersionGraphQL,
pub state: NonceStateGraphQL,
pub authority: Pubkey,
pub blockhash: Pubkey,
pub lamports_per_signature: U64,
}
impl TryFrom<crate::accounts::postgres::NonceRow> for NonceGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::NonceRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
version: row.version.0.into(),
state: row.state.0.into(),
authority: carbon_core::graphql::primitives::Pubkey(row.authority.0),
blockhash: carbon_core::graphql::primitives::Pubkey(row.blockhash.0),
lamports_per_signature: carbon_core::graphql::primitives::U64(
*row.lamports_per_signature,
),
})
}
}