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

Update frontend #17

Merged
merged 13 commits into from
Jul 5, 2024
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ The following are the available command-line flags(excluding above wallet flags)
| ----------------- | --------------------------------------------------- | ------------------------------------------ |
| -httpport | Listener port to serve HTTP connection | 8080 |
| -proxycount | Count of reverse proxies in front of the server | 0 |
| -token-address | Token contract address | 0x8a21CF9Ba08Ae709D64Cb25AfAA951183EC9FF6D |
| -token.address | Token contract address | 0x8a21CF9Ba08Ae709D64Cb25AfAA951183EC9FF6D |
| -faucet.amount | Number of ERC20 tokens to transfer per user request | 1 |
| -faucet.minutes | Number of minutes to wait between funding rounds | 10080 (1 week) |
| -faucet.name | Network name to display on the frontend | sepolia |
| -faucet.symbol | Token symbol to display on the frontend | LSK |
| -explorer.url | Block explorer URL | https://sepolia-blockscout.lisk.com |
| -explorer.tx.path | Block explorer transaction path fragment | tx |
| -hcaptcha.sitekey | hCaptcha sitekey | |
| -hcaptcha.secret | hCaptcha secret | |

Expand Down
7 changes: 5 additions & 2 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
appVersion = "v1.1.0"
chainIDMap = map[string]int{"lisk_sepolia": 4202}

tokenAddress = flag.String("token-address", os.Getenv("ERC20_TOKEN_ADDRESS"), "Contract address of ERC20 token")
tokenAddress = flag.String("token.address", os.Getenv("ERC20_TOKEN_ADDRESS"), "Contract address of ERC20 token")

httpPortFlag = flag.Int("httpport", 8080, "Listener port to serve HTTP connection")
proxyCntFlag = flag.Int("proxycount", 0, "Count of reverse proxies in front of the server")
Expand All @@ -31,6 +31,9 @@ var (
netnameFlag = flag.String("faucet.name", "lisk_sepolia", "Network name to display on the frontend")
symbolFlag = flag.String("faucet.symbol", "LSK", "Token symbol to display on the frontend")

explorerURL = flag.String("explorer.url", "https://sepolia-blockscout.lisk.com", "Block explorer URL")
explorerTxPath = flag.String("explorer.tx.path", "tx", "Block explorer transaction path fragment")

keyJSONFlag = flag.String("wallet.keyjson", os.Getenv("KEYSTORE"), "Keystore file to fund user requests with")
keyPassFlag = flag.String("wallet.keypass", "password.txt", "Passphrase text file to decrypt keystore")
privKeyFlag = flag.String("wallet.privkey", os.Getenv("PRIVATE_KEY"), "Private key hex to fund user requests with")
Expand Down Expand Up @@ -62,7 +65,7 @@ func Execute() {
if err != nil {
panic(fmt.Errorf("cannot connect to web3 provider: %w", err))
}
config := server.NewConfig(*netnameFlag, *symbolFlag, *httpPortFlag, *intervalFlag, *payoutFlag, *proxyCntFlag, *hcaptchaSiteKeyFlag, *hcaptchaSecretFlag)
config := server.NewConfig(*netnameFlag, *symbolFlag, *httpPortFlag, *intervalFlag, *payoutFlag, *proxyCntFlag, *hcaptchaSiteKeyFlag, *hcaptchaSecretFlag, *explorerURL, *explorerTxPath)
go server.NewServer(txBuilder, config).Run()

c := make(chan os.Signal, 1)
Expand Down
6 changes: 5 additions & 1 deletion internal/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ type Config struct {
proxyCount int
hcaptchaSiteKey string
hcaptchaSecret string
explorerURL string
explorerTxPath string
}

func NewConfig(network, symbol string, httpPort, interval, payout, proxyCount int, hcaptchaSiteKey, hcaptchaSecret string) *Config {
func NewConfig(network, symbol string, httpPort, interval, payout, proxyCount int, hcaptchaSiteKey, hcaptchaSecret, explorerURL, explorerTxPath string) *Config {
return &Config{
network: network,
symbol: symbol,
Expand All @@ -21,5 +23,7 @@ func NewConfig(network, symbol string, httpPort, interval, payout, proxyCount in
proxyCount: proxyCount,
hcaptchaSiteKey: hcaptchaSiteKey,
hcaptchaSecret: hcaptchaSecret,
explorerURL: explorerURL,
explorerTxPath: explorerTxPath,
}
}
2 changes: 2 additions & 0 deletions internal/server/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type infoResponse struct {
Payout string `json:"payout"`
Symbol string `json:"symbol"`
HcaptchaSiteKey string `json:"hcaptcha_sitekey,omitempty"`
ExplorerURL string `json:"explorer_url"`
ExplorerTxPath string `json:"explorer_txPath"`
}

type malformedRequest struct {
Expand Down
4 changes: 3 additions & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *Server) handleClaim() http.HandlerFunc {
"txHash": txHash,
"address": address,
}).Info("Transaction sent successfully")
resp := claimResponse{Message: fmt.Sprintf("Txhash: %s", txHash)}
resp := claimResponse{Message: fmt.Sprintf("txhash: %s", txHash)}
renderJSON(w, resp, http.StatusOK)
}
}
Expand All @@ -93,6 +93,8 @@ func (s *Server) handleInfo() http.HandlerFunc {
Symbol: s.cfg.symbol,
Payout: strconv.Itoa(s.cfg.payout),
HcaptchaSiteKey: s.cfg.hcaptchaSiteKey,
ExplorerURL: s.cfg.explorerURL,
ExplorerTxPath: s.cfg.explorerTxPath,
}, http.StatusOK)
}
}
Expand Down
12 changes: 12 additions & 0 deletions web/public/error-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/faucet-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions web/public/faucet-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions web/public/github-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions web/public/success-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions web/public/warning-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading