//! This code was AUTOGENERATED using the Codama library.
pub mod deposit_all_token_types_schema;
pub mod deposit_single_token_type_exact_amount_in_schema;
pub mod initialize_schema;
pub mod swap_schema;
pub mod withdraw_all_token_types_schema;
pub mod withdraw_single_token_type_exact_amount_out_schema;

use juniper::GraphQLObject;
pub use {
    deposit_all_token_types_schema::*, deposit_single_token_type_exact_amount_in_schema::*,
    initialize_schema::*, swap_schema::*, withdraw_all_token_types_schema::*,
    withdraw_single_token_type_exact_amount_out_schema::*,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "InstructionMetadata")]
pub struct InstructionMetadataGraphQL {
    pub signature: String,
    pub instruction_index: carbon_core::graphql::primitives::U32,
    pub stack_height: carbon_core::graphql::primitives::U32,
    pub slot: Option<carbon_core::graphql::primitives::U64>,
}

impl From<carbon_core::postgres::metadata::InstructionRowMetadata> for InstructionMetadataGraphQL {
    fn from(metadata: carbon_core::postgres::metadata::InstructionRowMetadata) -> Self {
        Self {
            signature: metadata.signature,
            instruction_index: carbon_core::graphql::primitives::U32(
                (*metadata.instruction_index) as u32,
            ),
            stack_height: carbon_core::graphql::primitives::U32((*metadata.stack_height) as u32),
            slot: metadata
                .slot
                .map(|v| carbon_core::graphql::primitives::U64(*v)),
        }
    }
}
