use {
crate::types::graphql::{EscrowAuthorityGraphQL, KeyGraphQL},
carbon_core::graphql::primitives::{Pubkey, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "TokenOwnedEscrow")]
pub struct TokenOwnedEscrowGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub key: KeyGraphQL,
pub base_token: Pubkey,
pub authority: EscrowAuthorityGraphQL,
pub bump: U8,
}
impl TryFrom<crate::accounts::postgres::TokenOwnedEscrowRow> for TokenOwnedEscrowGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::TokenOwnedEscrowRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
key: row.key.0.into(),
base_token: carbon_core::graphql::primitives::Pubkey(row.base_token.0),
authority: row.authority.0.into(),
bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
})
}
}