use {
carbon_core::graphql::primitives::{Pubkey, U64},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Global")]
pub struct GlobalGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub initialized: bool,
pub authority: Pubkey,
pub fee_recipient: Pubkey,
pub initial_virtual_token_reserves: U64,
pub initial_virtual_sol_reserves: U64,
pub initial_real_token_reserves: U64,
pub token_total_supply: U64,
pub fee_basis_points: U64,
pub withdraw_authority: Pubkey,
pub enable_migrate: bool,
pub pool_migration_fee: U64,
pub creator_fee_basis_points: U64,
pub fee_recipients: Vec<Pubkey>,
pub set_creator_authority: Pubkey,
pub admin_set_creator_authority: Pubkey,
pub create_v2_enabled: bool,
pub whitelist_pda: Pubkey,
pub reserved_fee_recipient: Pubkey,
pub mayhem_mode_enabled: bool,
pub reserved_fee_recipients: Vec<Pubkey>,
}
impl TryFrom<crate::accounts::postgres::GlobalRow> for GlobalGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::GlobalRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
initialized: row.initialized,
authority: carbon_core::graphql::primitives::Pubkey(row.authority.0),
fee_recipient: carbon_core::graphql::primitives::Pubkey(row.fee_recipient.0),
initial_virtual_token_reserves: carbon_core::graphql::primitives::U64(
*row.initial_virtual_token_reserves,
),
initial_virtual_sol_reserves: carbon_core::graphql::primitives::U64(
*row.initial_virtual_sol_reserves,
),
initial_real_token_reserves: carbon_core::graphql::primitives::U64(
*row.initial_real_token_reserves,
),
token_total_supply: carbon_core::graphql::primitives::U64(*row.token_total_supply),
fee_basis_points: carbon_core::graphql::primitives::U64(*row.fee_basis_points),
withdraw_authority: carbon_core::graphql::primitives::Pubkey(row.withdraw_authority.0),
enable_migrate: row.enable_migrate,
pool_migration_fee: carbon_core::graphql::primitives::U64(*row.pool_migration_fee),
creator_fee_basis_points: carbon_core::graphql::primitives::U64(
*row.creator_fee_basis_points,
),
fee_recipients: row
.fee_recipients
.into_iter()
.map(|item| carbon_core::graphql::primitives::Pubkey(item.0))
.collect(),
set_creator_authority: carbon_core::graphql::primitives::Pubkey(
row.set_creator_authority.0,
),
admin_set_creator_authority: carbon_core::graphql::primitives::Pubkey(
row.admin_set_creator_authority.0,
),
create_v2_enabled: row.create_v2_enabled,
whitelist_pda: carbon_core::graphql::primitives::Pubkey(row.whitelist_pda.0),
reserved_fee_recipient: carbon_core::graphql::primitives::Pubkey(
row.reserved_fee_recipient.0,
),
mayhem_mode_enabled: row.mayhem_mode_enabled,
reserved_fee_recipients: row
.reserved_fee_recipients
.into_iter()
.map(|item| carbon_core::graphql::primitives::Pubkey(item.0))
.collect(),
})
}
}