github.com/lmittmann/w3@v0.20.0/internal/module/util.go (about) 1 package module 2 3 import ( 4 "errors" 5 "math/big" 6 7 "github.com/ethereum/go-ethereum/common/hexutil" 8 ) 9 10 var errNotFound = errors.New("not found") 11 12 func BlockNumberArg(blockNumber *big.Int) string { 13 if blockNumber == nil { 14 return "latest" 15 } 16 17 switch blockNumber.Int64() { 18 case -1: 19 return "pending" 20 } 21 22 return hexutil.EncodeBig(blockNumber) 23 }