1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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,
}
}
}