Skip to content

Commit

Permalink
Merge PR: fix original rpc bugs (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
KamiD authored Apr 8, 2021
1 parent ed3da63 commit 8863a44
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions app/rpc/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"math/big"
"reflect"

clientcontext "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -177,15 +178,15 @@ func FormatBlock(
gasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,
) map[string]interface{} {
if len(header.DataHash) == 0 {
header.DataHash = tmbytes.HexBytes(common.Hash{}.Bytes())
header.DataHash = common.Hash{}.Bytes()
}

ret := map[string]interface{}{
"number": hexutil.Uint64(header.Height),
"hash": hexutil.Bytes(curBlockHash),
"parentHash": hexutil.Bytes(header.LastBlockID.Hash),
"nonce": hexutil.Uint64(0), // PoW specific
"sha3Uncles": common.Hash{}, // No uncles in Tendermint
"nonce": ethtypes.BlockNonce{}, // PoW specific
"sha3Uncles": common.Hash{}, // No uncles in Tendermint
"logsBloom": bloom,
"transactionsRoot": hexutil.Bytes(header.DataHash),
"stateRoot": hexutil.Bytes(header.AppHash),
Expand All @@ -201,11 +202,15 @@ func FormatBlock(
"uncles": []string{},
"receiptsRoot": common.Hash{},
}
switch transactions.(type) {
case []common.Hash:
ret["transactions"] = transactions.([]common.Hash)
case []*Transaction:
ret["transactions"] = transactions.([]*Transaction)
if !reflect.ValueOf(transactions).IsNil() {
switch transactions.(type) {
case []common.Hash:
ret["transactions"] = transactions.([]common.Hash)
case []*Transaction:
ret["transactions"] = transactions.([]*Transaction)
}
} else {
ret["transactions"] = []common.Hash{}
}
return ret
}
Expand Down

0 comments on commit 8863a44

Please sign in to comment.