use {
carbon_core::graphql::primitives::{I64, U64},
juniper::GraphQLObject,
serde_json,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "AdminUpdateTokenIncentives")]
pub struct AdminUpdateTokenIncentivesGraphQL {
pub instruction_metadata: crate::instructions::graphql::InstructionMetadataGraphQL,
pub start_time: I64,
pub end_time: I64,
pub seconds_in_a_day: I64,
pub day_number: U64,
pub token_supply_per_day: U64,
pub accounts: carbon_core::graphql::primitives::Json,
}
impl TryFrom<crate::instructions::postgres::AdminUpdateTokenIncentivesRow>
for AdminUpdateTokenIncentivesGraphQL
{
type Error = carbon_core::error::Error;
fn try_from(
row: crate::instructions::postgres::AdminUpdateTokenIncentivesRow,
) -> Result<Self, Self::Error> {
Ok(Self {
instruction_metadata: row.instruction_metadata.into(),
start_time: carbon_core::graphql::primitives::I64(row.start_time),
end_time: carbon_core::graphql::primitives::I64(row.end_time),
seconds_in_a_day: carbon_core::graphql::primitives::I64(row.seconds_in_a_day),
day_number: carbon_core::graphql::primitives::U64(*row.day_number),
token_supply_per_day: carbon_core::graphql::primitives::U64(*row.token_supply_per_day),
accounts: carbon_core::graphql::primitives::Json(
serde_json::to_value(&row.accounts.0)
.map_err(|e| carbon_core::error::Error::Custom(e.to_string()))?,
),
})
}
}