use crate::graphql;
use graphql::dh_fill_pool;
use graphql_client::GraphQLQuery;
use nash_mpc::curves::traits::ECPoint;
use super::{DhFillPoolRequest, K1FillPool, R1FillPool};
use crate::types::Blockchain;
impl DhFillPoolRequest {
pub fn make_query(&self) -> graphql_client::QueryBody<dh_fill_pool::Variables> {
let dh_publics = match self {
Self::Bitcoin(K1FillPool {
publics,
secrets: _,
}) => publics.iter().map(|x| Some(x.to_hex())).collect(),
Self::Ethereum(K1FillPool {
publics,
secrets: _,
}) => publics.iter().map(|x| Some(x.to_hex())).collect(),
Self::NEO(R1FillPool {
publics,
secrets: _,
}) => publics.iter().map(|x| Some(x.to_hex())).collect(),
};
let dh_args = dh_fill_pool::Variables {
dh_publics,
blockchain: self.blockchain().into(),
};
graphql::DhFillPool::build_query(dh_args)
}
}
impl Into<dh_fill_pool::Blockchain> for Blockchain {
fn into(self) -> dh_fill_pool::Blockchain {
match self {
Blockchain::Ethereum => dh_fill_pool::Blockchain::ETH,
Blockchain::Bitcoin => dh_fill_pool::Blockchain::BTC,
Blockchain::NEO => dh_fill_pool::Blockchain::NEO,
}
}
}