From d169f3d14ddad8ecdcb6fbc054e8b2f662bb9d71 Mon Sep 17 00:00:00 2001 From: benluelo Date: Thu, 30 Jan 2025 20:05:39 +0000 Subject: [PATCH] fix(rpc): eth_feeHistory base fee cannot be null --- rpc/backend/chain_info.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rpc/backend/chain_info.go b/rpc/backend/chain_info.go index bd78e1d1d6..de0d271a71 100644 --- a/rpc/backend/chain_info.go +++ b/rpc/backend/chain_info.go @@ -223,6 +223,15 @@ func (b *Backend) FeeHistory( return nil, err } + // the eth rpc spec requires a hex string to be returned for these values, so if they are nil then default them to 0x0 + if oneFeeHistory.BaseFee == nil { + oneFeeHistory.BaseFee = big.NewInt(0) + } + + if oneFeeHistory.NextBaseFee == nil { + oneFeeHistory.NextBaseFee = big.NewInt(0) + } + // copy thisBaseFee[index] = (*hexutil.Big)(oneFeeHistory.BaseFee) thisBaseFee[index+1] = (*hexutil.Big)(oneFeeHistory.NextBaseFee)