Skip to content

Commit

Permalink
mintscan: update api paths (iqlusioninc#1075)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shella authored Nov 16, 2022
1 parent 247872c commit b0f8c55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 10 additions & 5 deletions mintscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,22 @@ impl Mintscan {
}

/// Get `/v1/status` endpoint.
pub async fn status(&self) -> Result<v1::Status> {
pub async fn status(&self, network: &str) -> Result<v1::Status> {
self.client
.get_json("/v1/status", &Default::default())
.get_json(&format!("/v1/{}/status", network), &Default::default())
.await
}

/// Get `/v1/staking/validator` endpoint.
///
/// Accepts a Bech32-encoded account address for the validator.
pub async fn validator(&self, addr: impl Into<Address>) -> Result<v1::staking::Validator> {
pub async fn validator(
&self,
network: &str,
addr: impl Into<Address>,
) -> Result<v1::staking::Validator> {
// TODO(tarcieri): path construction with proper escaping
let path = format!("/v1/staking/validator/{}", &addr.into());
let path = format!("/v1/{}/validators/{}", &network, &addr.into());
self.client.get_json(&path, &Default::default()).await
}

Expand All @@ -63,10 +67,11 @@ impl Mintscan {
/// Accepts a Bech32-encoded account address for the validator.
pub async fn validator_uptime(
&self,
network: &str,
addr: impl Into<Address>,
) -> Result<v1::staking::validator::Uptime> {
// TODO(tarcieri): path construction with proper escaping
let path = format!("/v1/staking/validator/uptime/{}", &addr.into());
let path = format!("/v1/{}/validators/{}/uptime", &network, &addr.into());
self.client.get_json(&path, &Default::default()).await
}
}
Expand Down
8 changes: 4 additions & 4 deletions mintscan/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
use mintscan::Mintscan;

/// API host to test against.
const API_HOST: &str = "api.cosmostation.io";
const API_HOST: &str = "api.mintscan.io";

/// Example validator (iqlusion).
const VALIDATOR_ADDR: &str = "cosmosvaloper1grgelyng2v6v3t8z87wu3sxgt9m5s03xfytvz7";

#[tokio::test]
async fn status() {
let result = Mintscan::new(API_HOST).status().await;
let result = Mintscan::new(API_HOST).status("cosmos").await;

// TODO(tarcieri): better assertions
assert!(result.is_ok());
Expand All @@ -21,7 +21,7 @@ async fn status() {
#[tokio::test]
async fn validator() {
let validator = Mintscan::new(API_HOST)
.validator(VALIDATOR_ADDR)
.validator("cosmos", VALIDATOR_ADDR)
.await
.unwrap();

Expand All @@ -42,7 +42,7 @@ async fn validator() {
#[tokio::test]
async fn validator_uptime() {
let result = Mintscan::new(API_HOST)
.validator_uptime(VALIDATOR_ADDR)
.validator_uptime("cosmos", VALIDATOR_ADDR)
.await;

// TODO(tarcieri): better assertions
Expand Down

0 comments on commit b0f8c55

Please sign in to comment.