use {
crate::types::graphql::PlatformCurveParamGraphQL,
carbon_core::graphql::primitives::{Pubkey, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PlatformConfig")]
pub struct PlatformConfigGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub epoch: U64,
pub platform_fee_wallet: Pubkey,
pub platform_nft_wallet: Pubkey,
pub platform_scale: U64,
pub creator_scale: U64,
pub burn_scale: U64,
pub fee_rate: U64,
pub name: Vec<U8>,
pub web: Vec<U8>,
pub img: Vec<U8>,
pub cpswap_config: Pubkey,
pub creator_fee_rate: U64,
pub transfer_fee_extension_auth: Pubkey,
pub platform_vesting_wallet: Pubkey,
pub platform_vesting_scale: U64,
pub platform_cp_creator: Pubkey,
pub padding: Vec<U8>,
pub curve_params: Vec<PlatformCurveParamGraphQL>,
}
impl TryFrom<crate::accounts::postgres::PlatformConfigRow> for PlatformConfigGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::PlatformConfigRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
epoch: carbon_core::graphql::primitives::U64(*row.epoch),
platform_fee_wallet: carbon_core::graphql::primitives::Pubkey(
row.platform_fee_wallet.0,
),
platform_nft_wallet: carbon_core::graphql::primitives::Pubkey(
row.platform_nft_wallet.0,
),
platform_scale: carbon_core::graphql::primitives::U64(*row.platform_scale),
creator_scale: carbon_core::graphql::primitives::U64(*row.creator_scale),
burn_scale: carbon_core::graphql::primitives::U64(*row.burn_scale),
fee_rate: carbon_core::graphql::primitives::U64(*row.fee_rate),
name: row
.name
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
web: row
.web
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
img: row
.img
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
cpswap_config: carbon_core::graphql::primitives::Pubkey(row.cpswap_config.0),
creator_fee_rate: carbon_core::graphql::primitives::U64(*row.creator_fee_rate),
transfer_fee_extension_auth: carbon_core::graphql::primitives::Pubkey(
row.transfer_fee_extension_auth.0,
),
platform_vesting_wallet: carbon_core::graphql::primitives::Pubkey(
row.platform_vesting_wallet.0,
),
platform_vesting_scale: carbon_core::graphql::primitives::U64(
*row.platform_vesting_scale,
),
platform_cp_creator: carbon_core::graphql::primitives::Pubkey(
row.platform_cp_creator.0,
),
padding: row
.padding
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
curve_params: row
.curve_params
.0
.into_iter()
.map(|item| item.into())
.collect(),
})
}
}