use {
crate::types::graphql::PoolFeesGraphQL,
carbon_core::graphql::primitives::{Pubkey, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Config")]
pub struct ConfigGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub pool_fees: PoolFeesGraphQL,
pub activation_duration: U64,
pub vault_config_key: Pubkey,
pub pool_creator_authority: Pubkey,
pub activation_type: U8,
pub partner_fee_numerator: U64,
pub padding: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::ConfigRow> for ConfigGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::ConfigRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
pool_fees: row.pool_fees.0.into(),
activation_duration: carbon_core::graphql::primitives::U64(*row.activation_duration),
vault_config_key: carbon_core::graphql::primitives::Pubkey(row.vault_config_key.0),
pool_creator_authority: carbon_core::graphql::primitives::Pubkey(
row.pool_creator_authority.0,
),
activation_type: carbon_core::graphql::primitives::U8((*row.activation_type) as u8),
partner_fee_numerator: carbon_core::graphql::primitives::U64(
*row.partner_fee_numerator,
),
padding: row
.padding
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
})
}
}