Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
fix: web3 client doesn't expect a nil baseFeePerGas (#854)
Browse files Browse the repository at this point in the history
Closes: #853

Solution:
- only set baseFeePerGas when base fee is not nil.

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
  • Loading branch information
yihuang and fedekunze authored Dec 23, 2021
1 parent 0777d0b commit 8bc3cc4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rpc/ethereum/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func FormatBlock(
transactionsRoot = common.BytesToHash(header.DataHash)
}

return map[string]interface{}{
result := map[string]interface{}{
"number": hexutil.Uint64(header.Height),
"hash": hexutil.Bytes(header.Hash()),
"parentHash": common.BytesToHash(header.LastBlockID.Hash.Bytes()),
Expand All @@ -116,12 +116,17 @@ func FormatBlock(
"timestamp": hexutil.Uint64(header.Time.Unix()),
"transactionsRoot": transactionsRoot,
"receiptsRoot": ethtypes.EmptyRootHash,
"baseFeePerGas": (*hexutil.Big)(baseFee),

"uncles": []common.Hash{},
"transactions": transactions,
"totalDifficulty": (*hexutil.Big)(big.NewInt(0)),
}

if baseFee != nil {
result["baseFeePerGas"] = (*hexutil.Big)(baseFee)
}

return result
}

type DataError interface {
Expand Down

0 comments on commit 8bc3cc4

Please sign in to comment.