fix: web3 client doesn't expect a nil baseFeePerGas (#854)

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>
This commit is contained in:
yihuang 2021-12-24 00:12:05 +08:00 committed by GitHub
parent 0777d0b670
commit 8bc3cc471b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()),
@ -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 {