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::U64,
    juniper::GraphQLObject,
};

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

impl TryFrom<crate::accounts::postgres::MasterEditionV2Row> for MasterEditionV2GraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::MasterEditionV2Row) -> 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)),
        })
    }
}