Skip to content

Commit

Permalink
Changes for web faucet
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-mysten committed Jan 10, 2025
1 parent 7a76e17 commit bc87674
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/sui-faucet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ eyre.workspace = true
tempfile.workspace = true
parking_lot.workspace = true
tonic.workspace = true
reqwest.workspace = true
tower_governor = "0.4.3"
lazy_static = "1"

sui-json-rpc-types.workspace = true
sui-types.workspace = true
Expand All @@ -45,6 +47,8 @@ mysten-network.workspace = true

[dev-dependencies]
test-cluster.workspace = true
wiremock.workspace = true
serde_json.workspace = true

[[bin]]
name = "sui-faucet"
Expand Down
9 changes: 9 additions & 0 deletions crates/sui-faucet/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ use thiserror::Error;

#[derive(Error, Debug, PartialEq, Eq)]
pub enum FaucetError {
#[error("For testnet tokens, please use the Web UI: https://faucet.testnet.sui.io")]
NoToken,

#[error("Request limit exceeded. {0}")]
TooManyRequests(String),

#[error("Faucet cannot read objects from fullnode: {0}")]
FullnodeReadingError(String),

Expand Down Expand Up @@ -42,6 +48,9 @@ pub enum FaucetError {

#[error("Internal error: {0}")]
Internal(String),

#[error("Invalid user agent: {0}")]
InvalidUserAgent(String),
}

impl FaucetError {
Expand Down
7 changes: 7 additions & 0 deletions crates/sui-faucet/src/faucet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ pub struct FaucetConfig {

#[clap(long, action = clap::ArgAction::Set, default_value_t = false)]
pub batch_enabled: bool,

/// Testnet faucet requires authentication via the Web UI at https://faucet.testnet.sui.io
/// This flag is used to indicate that the faucet is running on testnet and enables the
/// authentication check.
#[clap(long)]
pub testnet: bool,
}

impl Default for FaucetConfig {
Expand All @@ -143,6 +149,7 @@ impl Default for FaucetConfig {
batch_request_size: 500,
ttl_expiration: 300,
batch_enabled: false,
testnet: false,
}
}
}
Loading

0 comments on commit bc87674

Please sign in to comment.