use {
crate::types::graphql::CurrencyGraphQL,
carbon_core::graphql::primitives::{Pubkey, U32, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "ConfigAccount")]
pub struct ConfigAccountGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub migration_authority: Pubkey,
pub backend_authority: Pubkey,
pub config_authority: Pubkey,
pub helio_fee: Pubkey,
pub dex_fee: Pubkey,
pub fee_bps: i32,
pub dex_fee_share: U8,
pub migration_fee: U64,
pub marketcap_threshold: U64,
pub marketcap_currency: CurrencyGraphQL,
pub min_supported_decimal_places: U8,
pub max_supported_decimal_places: U8,
pub min_supported_token_supply: U64,
pub max_supported_token_supply: U64,
pub bump: U8,
pub coef_b: U32,
}
impl TryFrom<crate::accounts::postgres::ConfigAccountRow> for ConfigAccountGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::ConfigAccountRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
migration_authority: carbon_core::graphql::primitives::Pubkey(
row.migration_authority.0,
),
backend_authority: carbon_core::graphql::primitives::Pubkey(row.backend_authority.0),
config_authority: carbon_core::graphql::primitives::Pubkey(row.config_authority.0),
helio_fee: carbon_core::graphql::primitives::Pubkey(row.helio_fee.0),
dex_fee: carbon_core::graphql::primitives::Pubkey(row.dex_fee.0),
fee_bps: *row.fee_bps,
dex_fee_share: carbon_core::graphql::primitives::U8((*row.dex_fee_share) as u8),
migration_fee: carbon_core::graphql::primitives::U64(*row.migration_fee),
marketcap_threshold: carbon_core::graphql::primitives::U64(*row.marketcap_threshold),
marketcap_currency: row.marketcap_currency.0.into(),
min_supported_decimal_places: carbon_core::graphql::primitives::U8(
(*row.min_supported_decimal_places) as u8,
),
max_supported_decimal_places: carbon_core::graphql::primitives::U8(
(*row.max_supported_decimal_places) as u8,
),
min_supported_token_supply: carbon_core::graphql::primitives::U64(
*row.min_supported_token_supply,
),
max_supported_token_supply: carbon_core::graphql::primitives::U64(
*row.max_supported_token_supply,
),
bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
coef_b: carbon_core::graphql::primitives::U32((*row.coef_b) as u32),
})
}
}