Skip to content

Commit

Permalink
Revert "[CLI] Fix faucet errors when server returns a 503 (#18553)"
Browse files Browse the repository at this point in the history
This reverts commit 1f577d2.
  • Loading branch information
stefan-mysten committed Jul 12, 2024
1 parent 9a4bbcb commit 4908f0a
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions crates/sui/src/client_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use std::{
};

use anyhow::{anyhow, bail, ensure, Context};
use axum::http::StatusCode;
use bip32::DerivationPath;
use clap::*;
use colored::Colorize;
Expand Down Expand Up @@ -2525,26 +2524,15 @@ pub async fn request_tokens_from_faucet(
.json(&json_body)
.send()
.await?;
if resp.status() == 429 {
bail!("Faucet received too many requests from this IP address. Please try again after 60 minutes.");
}
let faucet_resp: FaucetResponse = resp.json().await?;

match resp.status() {
StatusCode::ACCEPTED => {
let faucet_resp: FaucetResponse = resp.json().await?;

if let Some(err) = faucet_resp.error {
bail!("Faucet request was unsuccessful: {err}")
} else {
println!("Request successful. It can take up to 1 minute to get the coin. Run sui client gas to check your gas coins.");
}
}
StatusCode::TOO_MANY_REQUESTS => {
bail!("Faucet service received too many requests from this IP address. Please try again after 60 minutes.");
}
StatusCode::SERVICE_UNAVAILABLE => {
bail!("Faucet service is currently overloaded or unavailable. Please try again later.");
}
status_code => {
bail!("Faucet request was unsuccessful: {status_code}");
}
if let Some(err) = faucet_resp.error {
bail!("Faucet request was unsuccessful: {err}")
} else {
println!("Request successful. It can take up to 1 minute to get the coin. Run sui client gas to check your gas coins.");
}
Ok(())
}
Expand Down

0 comments on commit 4908f0a

Please sign in to comment.