carbon-drift-v2-decoder 1.0.0

Drift v2 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 = "RevenueShare")]
pub struct RevenueShareGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub authority: Pubkey,
    pub total_referrer_rewards: U64,
    pub total_builder_rewards: U64,
    pub padding: Vec<U8>,
}

impl TryFrom<crate::accounts::postgres::RevenueShareRow> for RevenueShareGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::RevenueShareRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            authority: carbon_core::graphql::primitives::Pubkey(row.authority.0),
            total_referrer_rewards: carbon_core::graphql::primitives::U64(
                *row.total_referrer_rewards,
            ),
            total_builder_rewards: carbon_core::graphql::primitives::U64(
                *row.total_builder_rewards,
            ),
            padding: row
                .padding
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
        })
    }
}