#![doc = include_str!("../README.md")]
#![forbid(unsafe_code)]
#![warn(
clippy::unwrap_used,
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 {
let mut client = HttpsClient::new(hostname);
client
.add_header(iqhttp::header::REFERER, "https://mintscan.io/")
.expect("couldn't add referer header");
Self { client }
}
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 }
}
}