Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request faucet top-up on low balance #135

Merged
merged 7 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
RUSTC_WRAPPER: sccache
CC: sccache clang
CXX: sccache clang++
FAUCET_TOPUP_REQ_URL: '${{ vars.FAUCET_TOPUP_REQ_URL }}'

jobs:
deploy:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

### Added

- [#135] (https://github.com/ChainSafe/forest-explorer/pull/135) Added link to
request for faucet top-up which is configurable using github env var.

### Changed

### Removed
Expand Down
12 changes: 11 additions & 1 deletion src/faucet/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ pub fn Faucet(target_network: Network) -> impl IntoView {
);

let (fading_messages, set_fading_messages) = signal(HashSet::new());

let drip_amount = match target_network {
Network::Mainnet => crate::constants::MAINNET_DRIP_AMOUNT.clone(),
Network::Testnet => crate::constants::CALIBNET_DRIP_AMOUNT.clone(),
};
let topup_req_url = option_env!("FAUCET_TOPUP_REQ_URL");
view! {
{move || {
let errors = faucet.get().get_error_messages();
Expand Down Expand Up @@ -137,6 +141,12 @@ pub fn Faucet(target_network: Network) -> impl IntoView {
{format!("Rate-limited! {duration}s")}
</button>
}.into_any()
} else if faucet.get().get_faucet_balance() < drip_amount {
view! {
<a href={topup_req_url} target="_blank" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r">
"Request Faucet Top-up"
</a>
}.into_any()
} else {
view! {
<button
Expand Down
Loading