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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#![doc(html_root_url = "https://docs.rs/mintscan/0.0.1")]
#![forbid(unsafe_code, clippy::unwrap_used)]
#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]
pub mod coin;
pub mod v1;
mod deserializers;
pub use self::coin::Coin;
pub use tendermint;
use iqhttp::{HttpsClient, Result};
pub type Address = String;
pub type Rate = String;
pub struct Mintscan {
client: HttpsClient,
}
impl Mintscan {
pub fn new(hostname: impl Into<String>) -> Self {
Self {
client: HttpsClient::new(hostname),
}
}
pub async fn status(&self) -> Result<v1::Status> {
self.client
.get_json("/v1/status", &Default::default())
.await
}
pub async fn validator(&self, addr: impl Into<Address>) -> Result<v1::staking::Validator> {
let path = format!("/v1/staking/validator/{}", &addr.into());
self.client.get_json(&path, &Default::default()).await
}
pub async fn validator_uptime(
&self,
addr: impl Into<Address>,
) -> Result<v1::staking::validator::Uptime> {
let path = format!("/v1/staking/validator/uptime/{}", &addr.into());
self.client.get_json(&path, &Default::default()).await
}
}
impl From<HttpsClient> for Mintscan {
fn from(client: HttpsClient) -> Mintscan {
Mintscan { client }
}
}