use {
crate::types::graphql::LeafSchemaGraphQL,
carbon_core::graphql::primitives::{Pubkey, U32},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Voucher")]
pub struct VoucherGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub leaf_schema: LeafSchemaGraphQL,
pub index: U32,
pub merkle_tree: Pubkey,
}
impl TryFrom<crate::accounts::postgres::VoucherRow> for VoucherGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::VoucherRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
leaf_schema: row.leaf_schema.0.into(),
index: carbon_core::graphql::primitives::U32((*row.index) as u32),
merkle_tree: carbon_core::graphql::primitives::Pubkey(row.merkle_tree.0),
})
}
}