carbon-orca-whirlpool-decoder 1.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "LockConfig")]
pub struct LockConfigGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub position: Pubkey,
    pub position_owner: Pubkey,
    pub whirlpool: Pubkey,
    pub locked_timestamp: U64,
    pub lock_type: LockTypeLabelGraphQL,
}

impl TryFrom<crate::accounts::postgres::LockConfigRow> for LockConfigGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::LockConfigRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            position: carbon_core::graphql::primitives::Pubkey(row.position.0),
            position_owner: carbon_core::graphql::primitives::Pubkey(row.position_owner.0),
            whirlpool: carbon_core::graphql::primitives::Pubkey(row.whirlpool.0),
            locked_timestamp: carbon_core::graphql::primitives::U64(*row.locked_timestamp),
            lock_type: row.lock_type.0.into(),
        })
    }
}