nash_protocol/protocol/dh_fill_pool/
request.rs1use crate::graphql;
2use graphql::dh_fill_pool;
3use graphql_client::GraphQLQuery;
4use nash_mpc::curves::traits::ECPoint;
5
6use super::{DhFillPoolRequest, K1FillPool, R1FillPool};
7use crate::types::Blockchain;
8
9impl DhFillPoolRequest {
10 pub fn make_query(&self) -> graphql_client::QueryBody<dh_fill_pool::Variables> {
15 let dh_publics = match self {
17 Self::Bitcoin(K1FillPool {
18 publics,
19 secrets: _,
20 }) => publics.iter().map(|x| Some(x.to_hex())).collect(),
21 Self::Ethereum(K1FillPool {
22 publics,
23 secrets: _,
24 }) => publics.iter().map(|x| Some(x.to_hex())).collect(),
25 Self::NEO(R1FillPool {
26 publics,
27 secrets: _,
28 }) => publics.iter().map(|x| Some(x.to_hex())).collect(),
29 };
30 let dh_args = dh_fill_pool::Variables {
31 dh_publics,
32 blockchain: self.blockchain().into(),
33 };
34 graphql::DhFillPool::build_query(dh_args)
35 }
36}
37
38impl Into<dh_fill_pool::Blockchain> for Blockchain {
39 fn into(self) -> dh_fill_pool::Blockchain {
40 match self {
41 Blockchain::Ethereum => dh_fill_pool::Blockchain::ETH,
42 Blockchain::Bitcoin => dh_fill_pool::Blockchain::BTC,
43 Blockchain::NEO => dh_fill_pool::Blockchain::NEO,
44 }
45 }
46}