From 31d401ea687066465846ec4a0d2388ef80e4b0cc Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Feb 2023 15:44:27 +0100 Subject: [PATCH] rpc: remove DecimalOrHex type (#26629) It's the same as math.HexOrDecimal64, which has more uses across the codebase. --- internal/ethapi/api.go | 2 +- rpc/types.go | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 4fa5b9e67..58f65f86d 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -88,7 +88,7 @@ type feeHistoryResult struct { } // FeeHistory returns the fee market history. -func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error) { +func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error) { oldest, reward, baseFee, gasUsed, err := s.b.FeeHistory(ctx, int(blockCount), lastBlock, rewardPercentiles) if err != nil { return nil, err diff --git a/rpc/types.go b/rpc/types.go index 9dda067e7..55d11fbaa 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -243,24 +243,3 @@ func BlockNumberOrHashWithHash(hash common.Hash, canonical bool) BlockNumberOrHa RequireCanonical: canonical, } } - -// DecimalOrHex unmarshals a non-negative decimal or hex parameter into a uint64. -type DecimalOrHex uint64 - -// UnmarshalJSON implements json.Unmarshaler. -func (dh *DecimalOrHex) UnmarshalJSON(data []byte) error { - input := strings.TrimSpace(string(data)) - if len(input) >= 2 && input[0] == '"' && input[len(input)-1] == '"' { - input = input[1 : len(input)-1] - } - - value, err := strconv.ParseUint(input, 10, 64) - if err != nil { - value, err = hexutil.DecodeUint64(input) - } - if err != nil { - return err - } - *dh = DecimalOrHex(value) - return nil -}