From 62a58fe6d379b4b57713240fc4af8688c52668de Mon Sep 17 00:00:00 2001 From: Xiaozhou Li Date: Wed, 25 May 2022 22:00:38 -0700 Subject: [PATCH] forceGasGwei (#62) --- eth/options.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/eth/options.go b/eth/options.go index d244a7a..f4fa986 100644 --- a/eth/options.go +++ b/eth/options.go @@ -4,7 +4,10 @@ package eth import ( "math/big" + "strconv" "time" + + "github.com/celer-network/goutils/log" ) type txOptions struct { @@ -14,7 +17,7 @@ type txOptions struct { minGasGwei uint64 maxGasGwei uint64 addGasGwei uint64 - forceGasGwei *uint64 + forceGasGwei *uint64 // use pointer to allow forcing zero gas // EIP-1559 Tx gas price maxFeePerGasGwei uint64 maxPriorityFeePerGasGwei uint64 @@ -94,9 +97,15 @@ func WithAddGasGwei(g uint64) TxOption { }) } -func WithForceGasGwei(g uint64) TxOption { +func WithForceGasGwei(g string) TxOption { return newFuncTxOption(func(o *txOptions) { - o.forceGasGwei = &g + if g != "" { + gwei, err := strconv.ParseUint(g, 10, 64) + if err != nil { + log.Errorln("invalid ForceGasGwei", g) + } + o.forceGasGwei = &gwei + } }) }