use {
crate::types::graphql::{SpotFulfillmentConfigStatusGraphQL, SpotFulfillmentTypeGraphQL},
carbon_core::graphql::primitives::{Pubkey, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PhoenixV1FulfillmentConfig")]
pub struct PhoenixV1FulfillmentConfigGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub pubkey: Pubkey,
pub phoenix_program_id: Pubkey,
pub phoenix_log_authority: Pubkey,
pub phoenix_market: Pubkey,
pub phoenix_base_vault: Pubkey,
pub phoenix_quote_vault: Pubkey,
pub market_index: i32,
pub fulfillment_type: SpotFulfillmentTypeGraphQL,
pub status: SpotFulfillmentConfigStatusGraphQL,
pub padding: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::PhoenixV1FulfillmentConfigRow>
for PhoenixV1FulfillmentConfigGraphQL
{
type Error = carbon_core::error::Error;
fn try_from(
row: crate::accounts::postgres::PhoenixV1FulfillmentConfigRow,
) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
pubkey: carbon_core::graphql::primitives::Pubkey(row.pubkey.0),
phoenix_program_id: carbon_core::graphql::primitives::Pubkey(row.phoenix_program_id.0),
phoenix_log_authority: carbon_core::graphql::primitives::Pubkey(
row.phoenix_log_authority.0,
),
phoenix_market: carbon_core::graphql::primitives::Pubkey(row.phoenix_market.0),
phoenix_base_vault: carbon_core::graphql::primitives::Pubkey(row.phoenix_base_vault.0),
phoenix_quote_vault: carbon_core::graphql::primitives::Pubkey(
row.phoenix_quote_vault.0,
),
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(),
})
}
}