carbon-boop-decoder 1.0.0

Boop program decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    carbon_core::graphql::primitives::{Pubkey, U64, U8},
    juniper::GraphQLObject,
    serde_json,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "UpdateConfig")]
pub struct UpdateConfigGraphQL {
    pub instruction_metadata: crate::instructions::graphql::InstructionMetadataGraphQL,
    pub new_protocol_fee_recipient: Pubkey,
    pub new_virtual_sol_reserves: U64,
    pub new_virtual_token_reserves: U64,
    pub new_graduation_target: U64,
    pub new_graduation_fee: U64,
    pub new_damping_term: U8,
    pub new_swap_fee_basis_points: U8,
    pub new_token_for_stakers_basis_points: i32,
    pub new_token_amount_for_raydium_liquidity: U64,
    pub new_max_graduation_price_deviation_basis_points: i32,
    pub new_max_swap_amount_for_pool_price_correction_basis_points: i32,
    pub accounts: carbon_core::graphql::primitives::Json,
}

impl TryFrom<crate::instructions::postgres::UpdateConfigRow> for UpdateConfigGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::instructions::postgres::UpdateConfigRow) -> Result<Self, Self::Error> {
        Ok(Self {
            instruction_metadata: row.instruction_metadata.into(),
            new_protocol_fee_recipient: carbon_core::graphql::primitives::Pubkey(
                row.new_protocol_fee_recipient.0,
            ),
            new_virtual_sol_reserves: carbon_core::graphql::primitives::U64(
                *row.new_virtual_sol_reserves,
            ),
            new_virtual_token_reserves: carbon_core::graphql::primitives::U64(
                *row.new_virtual_token_reserves,
            ),
            new_graduation_target: carbon_core::graphql::primitives::U64(
                *row.new_graduation_target,
            ),
            new_graduation_fee: carbon_core::graphql::primitives::U64(*row.new_graduation_fee),
            new_damping_term: carbon_core::graphql::primitives::U8((*row.new_damping_term) as u8),
            new_swap_fee_basis_points: carbon_core::graphql::primitives::U8(
                (*row.new_swap_fee_basis_points) as u8,
            ),
            new_token_for_stakers_basis_points: *row.new_token_for_stakers_basis_points,
            new_token_amount_for_raydium_liquidity: carbon_core::graphql::primitives::U64(
                *row.new_token_amount_for_raydium_liquidity,
            ),
            new_max_graduation_price_deviation_basis_points: *row
                .new_max_graduation_price_deviation_basis_points,
            new_max_swap_amount_for_pool_price_correction_basis_points: *row
                .new_max_swap_amount_for_pool_price_correction_basis_points,
            accounts: carbon_core::graphql::primitives::Json(
                serde_json::to_value(&row.accounts.0)
                    .map_err(|e| carbon_core::error::Error::Custom(e.to_string()))?,
            ),
        })
    }
}