use {
crate::types::graphql::{SpotFulfillmentConfigStatusGraphQL, SpotFulfillmentTypeGraphQL},
carbon_core::graphql::primitives::{Pubkey, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "SerumV3FulfillmentConfig")]
pub struct SerumV3FulfillmentConfigGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub pubkey: Pubkey,
pub serum_program_id: Pubkey,
pub serum_market: Pubkey,
pub serum_request_queue: Pubkey,
pub serum_event_queue: Pubkey,
pub serum_bids: Pubkey,
pub serum_asks: Pubkey,
pub serum_base_vault: Pubkey,
pub serum_quote_vault: Pubkey,
pub serum_open_orders: Pubkey,
pub serum_signer_nonce: U64,
pub market_index: i32,
pub fulfillment_type: SpotFulfillmentTypeGraphQL,
pub status: SpotFulfillmentConfigStatusGraphQL,
pub padding: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::SerumV3FulfillmentConfigRow>
for SerumV3FulfillmentConfigGraphQL
{
type Error = carbon_core::error::Error;
fn try_from(
row: crate::accounts::postgres::SerumV3FulfillmentConfigRow,
) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
pubkey: carbon_core::graphql::primitives::Pubkey(row.pubkey.0),
serum_program_id: carbon_core::graphql::primitives::Pubkey(row.serum_program_id.0),
serum_market: carbon_core::graphql::primitives::Pubkey(row.serum_market.0),
serum_request_queue: carbon_core::graphql::primitives::Pubkey(
row.serum_request_queue.0,
),
serum_event_queue: carbon_core::graphql::primitives::Pubkey(row.serum_event_queue.0),
serum_bids: carbon_core::graphql::primitives::Pubkey(row.serum_bids.0),
serum_asks: carbon_core::graphql::primitives::Pubkey(row.serum_asks.0),
serum_base_vault: carbon_core::graphql::primitives::Pubkey(row.serum_base_vault.0),
serum_quote_vault: carbon_core::graphql::primitives::Pubkey(row.serum_quote_vault.0),
serum_open_orders: carbon_core::graphql::primitives::Pubkey(row.serum_open_orders.0),
serum_signer_nonce: carbon_core::graphql::primitives::U64(*row.serum_signer_nonce),
market_index: *row.market_index,
fulfillment_type: row.fulfillment_type.0.into(),
status: row.status.0.into(),
padding: row
.padding
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
})
}
}