//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::{
        AuthorityGraphQL, ExtraAccountGraphQL, ValidationResultsOffsetGraphQL,
    },
    carbon_core::graphql::primitives::{Json, Pubkey},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "OracleInitInfo")]
pub struct OracleInitInfoGraphQL {
    pub base_address: Pubkey,
    pub init_plugin_authority: Option<AuthorityGraphQL>,
    pub lifecycle_checks: Vec<Json>,
    pub base_address_config: Option<ExtraAccountGraphQL>,
    pub results_offset: Option<ValidationResultsOffsetGraphQL>,
}

impl From<crate::types::OracleInitInfo> for OracleInitInfoGraphQL {
    fn from(original: crate::types::OracleInitInfo) -> Self {
        Self {
            base_address: carbon_core::graphql::primitives::Pubkey(original.base_address),
            init_plugin_authority: original.init_plugin_authority.map(|v| v.into()),
            lifecycle_checks: original
                .lifecycle_checks
                .into_iter()
                .map(|item| {
                    carbon_core::graphql::primitives::Json(
                        serde_json::to_value(item).unwrap_or(serde_json::Value::Null),
                    )
                })
                .collect(),
            base_address_config: original.base_address_config.map(|v| v.into()),
            results_offset: original.results_offset.map(|v| v.into()),
        }
    }
}
