use {
crate::types::graphql::SignedMsgOrderIdGraphQL,
carbon_core::graphql::primitives::{Pubkey, U32},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "SignedMsgUserOrders")]
pub struct SignedMsgUserOrdersGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub authority_pubkey: Pubkey,
pub padding: U32,
pub signed_msg_order_data: Vec<SignedMsgOrderIdGraphQL>,
}
impl TryFrom<crate::accounts::postgres::SignedMsgUserOrdersRow> for SignedMsgUserOrdersGraphQL {
type Error = carbon_core::error::Error;
fn try_from(
row: crate::accounts::postgres::SignedMsgUserOrdersRow,
) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
authority_pubkey: carbon_core::graphql::primitives::Pubkey(row.authority_pubkey.0),
padding: carbon_core::graphql::primitives::U32((*row.padding) as u32),
signed_msg_order_data: row
.signed_msg_order_data
.0
.into_iter()
.map(|item| item.into())
.collect(),
})
}
}