use {
carbon_core::graphql::primitives::{U128, U64},
juniper::GraphQLObject,
serde_json,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "GetFees")]
pub struct GetFeesGraphQL {
pub instruction_metadata: crate::instructions::graphql::InstructionMetadataGraphQL,
pub is_pump_pool: bool,
pub market_cap_lamports: U128,
pub trade_size_lamports: U64,
pub accounts: carbon_core::graphql::primitives::Json,
}
impl TryFrom<crate::instructions::postgres::GetFeesRow> for GetFeesGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::instructions::postgres::GetFeesRow) -> Result<Self, Self::Error> {
Ok(Self {
instruction_metadata: row.instruction_metadata.into(),
is_pump_pool: row.is_pump_pool,
market_cap_lamports: carbon_core::graphql::primitives::U128(*row.market_cap_lamports),
trade_size_lamports: carbon_core::graphql::primitives::U64(*row.trade_size_lamports),
accounts: carbon_core::graphql::primitives::Json(
serde_json::to_value(&row.accounts.0)
.map_err(|e| carbon_core::error::Error::Custom(e.to_string()))?,
),
})
}
}