carbon-drift-v2-decoder 2.0.0

Drift v2 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    carbon_core::graphql::primitives::{Pubkey, I64, U128},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "ProtocolIfSharesTransferConfig")]
pub struct ProtocolIfSharesTransferConfigGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub whitelisted_signers: Vec<Pubkey>,
    pub max_transfer_per_epoch: U128,
    pub current_epoch_transfer: U128,
    pub next_epoch_ts: I64,
    pub padding: Vec<U128>,
}

impl TryFrom<crate::accounts::postgres::ProtocolIfSharesTransferConfigRow>
    for ProtocolIfSharesTransferConfigGraphQL
{
    type Error = carbon_core::error::Error;
    fn try_from(
        row: crate::accounts::postgres::ProtocolIfSharesTransferConfigRow,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            whitelisted_signers: row
                .whitelisted_signers
                .into_iter()
                .map(|item| carbon_core::graphql::primitives::Pubkey(item.0))
                .collect(),
            max_transfer_per_epoch: carbon_core::graphql::primitives::U128(
                *row.max_transfer_per_epoch,
            ),
            current_epoch_transfer: carbon_core::graphql::primitives::U128(
                *row.current_epoch_transfer,
            ),
            next_epoch_ts: carbon_core::graphql::primitives::I64(row.next_epoch_ts),
            padding: row
                .padding
                .into_iter()
                .map(|item| carbon_core::graphql::primitives::U128(*item))
                .collect(),
        })
    }
}