use {
crate::types::graphql::AmmConstituentDatumGraphQL,
carbon_core::graphql::primitives::{Pubkey, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "AmmConstituentMapping")]
pub struct AmmConstituentMappingGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub lp_pool: Pubkey,
pub bump: U8,
pub padding: Vec<U8>,
pub weights: Vec<AmmConstituentDatumGraphQL>,
}
impl TryFrom<crate::accounts::postgres::AmmConstituentMappingRow> for AmmConstituentMappingGraphQL {
type Error = carbon_core::error::Error;
fn try_from(
row: crate::accounts::postgres::AmmConstituentMappingRow,
) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
lp_pool: carbon_core::graphql::primitives::Pubkey(row.lp_pool.0),
bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
padding: row
.padding
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
weights: row.weights.0.into_iter().map(|item| item.into()).collect(),
})
}
}