From 5663e52315ed17ae606b9dd874ec8e52a6d7861c Mon Sep 17 00:00:00 2001 From: zzzckck <152148891+zzzckck@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:51:31 +0800 Subject: [PATCH] faucet: code improve Co-authored-by: Matus Kysel --- cmd/faucet/faucet.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 0df6bb676c..e83a32835a 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -95,8 +95,9 @@ var ( var websiteTmpl string func weiToEtherStringFx(wei *big.Int, prec int) string { - f, _ := new(big.Float).Quo(new(big.Float).SetInt(wei), big.NewFloat(params.Ether)).Float64() - return strconv.FormatFloat(f, 'f', prec, 64) + etherValue := new(big.Float).Quo(new(big.Float).SetInt(wei), big.NewFloat(params.Ether)) + // Format the big.Float directly to a string with the specified precision + return etherValue.Text('f', prec) } func main() {