use {
carbon_core::graphql::primitives::{Pubkey, U64},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "VestingRecord")]
pub struct VestingRecordGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub epoch: U64,
pub pool: Pubkey,
pub beneficiary: Pubkey,
pub claimed_amount: U64,
pub token_share_amount: U64,
pub padding: Vec<U64>,
}
impl TryFrom<crate::accounts::postgres::VestingRecordRow> for VestingRecordGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::VestingRecordRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
epoch: carbon_core::graphql::primitives::U64(*row.epoch),
pool: carbon_core::graphql::primitives::Pubkey(row.pool.0),
beneficiary: carbon_core::graphql::primitives::Pubkey(row.beneficiary.0),
claimed_amount: carbon_core::graphql::primitives::U64(*row.claimed_amount),
token_share_amount: carbon_core::graphql::primitives::U64(*row.token_share_amount),
padding: row
.padding
.into_iter()
.map(|item| carbon_core::graphql::primitives::U64(*item))
.collect(),
})
}
}