carbon-token-program-decoder 1.0.0

Token Program Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    carbon_core::graphql::primitives::{Pubkey, U64, U8},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Mint")]
pub struct MintGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub mint_authority: Option<Pubkey>,
    pub supply: U64,
    pub decimals: U8,
    pub is_initialized: bool,
    pub freeze_authority: Option<Pubkey>,
}

impl TryFrom<crate::accounts::postgres::MintRow> for MintGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::MintRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            mint_authority: row
                .mint_authority
                .map(|v| carbon_core::graphql::primitives::Pubkey(v.0)),
            supply: carbon_core::graphql::primitives::U64(*row.supply),
            decimals: carbon_core::graphql::primitives::U8((*row.decimals) as u8),
            is_initialized: row.is_initialized,
            freeze_authority: row
                .freeze_authority
                .map(|v| carbon_core::graphql::primitives::Pubkey(v.0)),
        })
    }
}