use {
carbon_core::graphql::primitives::{Pubkey, U128, U32},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "FuelOverflow")]
pub struct FuelOverflowGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub authority: Pubkey,
pub fuel_insurance: U128,
pub fuel_deposits: U128,
pub fuel_borrows: U128,
pub fuel_positions: U128,
pub fuel_taker: U128,
pub fuel_maker: U128,
pub last_fuel_sweep_ts: U32,
pub last_reset_ts: U32,
pub padding: Vec<U128>,
}
impl TryFrom<crate::accounts::postgres::FuelOverflowRow> for FuelOverflowGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::FuelOverflowRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
authority: carbon_core::graphql::primitives::Pubkey(row.authority.0),
fuel_insurance: carbon_core::graphql::primitives::U128(*row.fuel_insurance),
fuel_deposits: carbon_core::graphql::primitives::U128(*row.fuel_deposits),
fuel_borrows: carbon_core::graphql::primitives::U128(*row.fuel_borrows),
fuel_positions: carbon_core::graphql::primitives::U128(*row.fuel_positions),
fuel_taker: carbon_core::graphql::primitives::U128(*row.fuel_taker),
fuel_maker: carbon_core::graphql::primitives::U128(*row.fuel_maker),
last_fuel_sweep_ts: carbon_core::graphql::primitives::U32(
(*row.last_fuel_sweep_ts) as u32,
),
last_reset_ts: carbon_core::graphql::primitives::U32((*row.last_reset_ts) as u32),
padding: row
.padding
.into_iter()
.map(|item| carbon_core::graphql::primitives::U128(*item))
.collect(),
})
}
}