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

fix(faucet): faucet loading #768

Merged
merged 2 commits into from
Sep 3, 2024
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
3 changes: 3 additions & 0 deletions cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ func InitFaucet(logger zerolog.Logger) (Faucet, error) {
Amount: float64(amount),
}

dailySupply.Set(f.DailySupply)

if f.config.Mnemonic != "" {
if err = f.setupNewAccount(); err != nil {
return Faucet{}, err
Expand Down Expand Up @@ -278,6 +280,7 @@ func (f *Faucet) Send(addr string, force bool) (string, int, error) {

f.TokensAvailable = (f.TokensAvailable - float64(len(f.Batch))*f.Amount/uwardConversion)
f.log.Info().Msgf("tokens available: %f", f.TokensAvailable)
dailySupply.Set(f.TokensAvailable)

f.Batch = []string{}
return result.TxHash, http.StatusOK, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/faucet/js/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function startPolling() {
.then((response) => response.text())
.then((html) => {
document.getElementById("tx-status").innerHTML = html;
if (html.includes('id="tx-result"')) {
if (html.includes('class="tx-result"')) {
clearInterval(pollingInterval);
}
});
Expand Down
6 changes: 6 additions & 0 deletions cmd/faucet/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ var (
Name: "req_error_count",
Help: "The total number of failed requests for errors during send",
})

dailySupply = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "faucet",
Name: "daily_limit",
Help: "The total amount left of tokens available per day",
})
)
Loading