-
Notifications
You must be signed in to change notification settings - Fork 38
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
Setup faucet for sepolia env #1563
Changes from all commits
bae978c
9de7b1b
dfdd614
16b280e
968605a
cf7b609
dab4c30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ import ( | |
"flag" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/params" | ||
|
||
"github.com/obscuronet/go-obscuro/tools/faucet/faucet" | ||
) | ||
|
||
|
@@ -32,6 +34,10 @@ const ( | |
serverPortName = "serverPort" | ||
serverPortDefault = 80 | ||
serverPortUsage = "Port where the web server binds to" | ||
|
||
defaultAmountName = "defaultAmount" | ||
defaultAmountDefault = 100.0 | ||
defaultAmountUsage = "Default amount of token to fund (in ETH)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a pet annoyance, I'll leave it to you consideration. The flags receive ETH but the config struct receives WEI. Worth normalizing one way or the other imo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like we should mostly use explicit big.Int for token values everywhere in code, seems to be mostly what geth does. But the CLI is a human configured interface, imo it makes sense for it to use human readable values but not to leak that into other layers. If I'm checking the config for each env I don't want to have to count the zeroes ideally. |
||
) | ||
|
||
func parseCLIArgs() *faucet.Config { | ||
|
@@ -41,15 +47,25 @@ func parseCLIArgs() *faucet.Config { | |
faucetPK := flag.String(faucetPKName, faucetPKDefault, faucetPKUsage) | ||
jwtSecret := flag.String(jwtSecretName, jwtSecretDefault, jwtSecretUsage) | ||
serverPort := flag.Int(serverPortName, serverPortDefault, serverPortUsage) | ||
defaultAmount := flag.Float64(defaultAmountName, defaultAmountDefault, defaultAmountUsage) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any need for it to be a float ? |
||
flag.Parse() | ||
|
||
return &faucet.Config{ | ||
Port: *faucetPort, | ||
Host: *nodeHost, | ||
HTTPPort: *nodeHTTPPort, | ||
PK: *faucetPK, | ||
JWTSecret: *jwtSecret, | ||
ServerPort: *serverPort, | ||
ChainID: big.NewInt(443), // TODO make this configurable | ||
Port: *faucetPort, | ||
Host: *nodeHost, | ||
HTTPPort: *nodeHTTPPort, | ||
PK: *faucetPK, | ||
JWTSecret: *jwtSecret, | ||
ServerPort: *serverPort, | ||
ChainID: big.NewInt(443), // TODO make this configurable | ||
DefaultFundAmount: toWei(defaultAmount), | ||
} | ||
} | ||
|
||
func toWei(amount *float64) *big.Int { | ||
amtFloat := new(big.Float).SetFloat64(*amount) | ||
weiFloat := new(big.Float).Mul(amtFloat, big.NewFloat(params.Ether)) | ||
// don't care about the accuracy here, float should have less than 18 decimal places | ||
wei, _ := weiFloat.Int(nil) | ||
return wei | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float ?