Skip to content

Commit

Permalink
👌 Applied suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nagdahimanshu committed Jul 5, 2024
1 parent 895acd1 commit 46fc2a4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
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 | 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")

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
2 changes: 2 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions web/src/Faucet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
payout: 1,
symbol: 'ETH',
hcaptcha_sitekey: '',
explorer_url: '',
explorer_txPath: '',
};
let mounted = false;
Expand Down

0 comments on commit 46fc2a4

Please sign in to comment.