carbon-mpl-token-metadata-decoder 1.0.0

MPL Token Metadata Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::KeyGraphQL,
    carbon_core::graphql::primitives::{Pubkey, U64},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "MasterEditionV1")]
pub struct MasterEditionV1GraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub key: KeyGraphQL,
    pub supply: U64,
    pub max_supply: Option<U64>,
    pub printing_mint: Pubkey,
    pub one_time_printing_authorization_mint: Pubkey,
}

impl TryFrom<crate::accounts::postgres::MasterEditionV1Row> for MasterEditionV1GraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::MasterEditionV1Row) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            key: row.key.0.into(),
            supply: carbon_core::graphql::primitives::U64(*row.supply),
            max_supply: row
                .max_supply
                .map(|v| carbon_core::graphql::primitives::U64(*v)),
            printing_mint: carbon_core::graphql::primitives::Pubkey(row.printing_mint.0),
            one_time_printing_authorization_mint: carbon_core::graphql::primitives::Pubkey(
                row.one_time_printing_authorization_mint.0,
            ),
        })
    }
}