refactor: remove bytes/HexBytes (#15211)

Co-authored-by: chixiaowen <chixiaowen@zhigui.com>
This commit is contained in:
Chi Xiao Wen
2023-03-01 18:27:23 +00:00
committed by GitHub
co-authored by chixiaowen
parent 23ef32a35c
commit a49151d693
18 changed files with 144 additions and 138 deletions
+2 -3
View File
@@ -6,7 +6,6 @@ import (
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
cmtbytes "github.com/cometbft/cometbft/libs/bytes"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/gogoproto/proto"
@@ -26,7 +25,7 @@ type Context struct {
baseCtx context.Context
ms storetypes.MultiStore
header cmtproto.Header
headerHash cmtbytes.HexBytes
headerHash []byte
chainID string
txBytes []byte
logger log.Logger
@@ -72,7 +71,7 @@ func (c Context) BlockHeader() cmtproto.Header {
}
// HeaderHash returns a copy of the header hash obtained during abci.RequestBeginBlock
func (c Context) HeaderHash() cmtbytes.HexBytes {
func (c Context) HeaderHash() []byte {
hash := make([]byte, len(c.headerHash))
copy(hash, c.headerHash)
return hash
+1 -1
View File
@@ -121,7 +121,7 @@ func (s *contextTestSuite) TestContextWithCustom() {
s.Require().Equal(meter, ctx.GasMeter())
s.Require().Equal(minGasPrices, ctx.MinGasPrices())
s.Require().Equal(blockGasMeter, ctx.BlockGasMeter())
s.Require().Equal(headerHash, ctx.HeaderHash().Bytes())
s.Require().Equal(headerHash, ctx.HeaderHash())
s.Require().False(ctx.WithIsCheckTx(false).IsCheckTx())
s.Require().Equal(zeroGasCfg, ctx.KVGasConfig())
s.Require().Equal(zeroGasCfg, ctx.TransientKVGasConfig())
+2 -3
View File
@@ -8,7 +8,6 @@ import (
"time"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/bytes"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
"github.com/golang/protobuf/proto" //nolint:staticcheck // grpc-gateway uses deprecated golang/protobuf
"github.com/stretchr/testify/require"
@@ -81,7 +80,7 @@ func (s *resultTestSuite) TestResponseResultTx() {
GasUsed: 90,
}
resultTx := &coretypes.ResultTx{
Hash: bytes.HexBytes([]byte("test")),
Hash: []byte("test"),
Height: 10,
TxResult: deliverTxResult,
}
@@ -128,7 +127,7 @@ txhash: "74657374"
Codespace: "codespace",
Data: []byte("data"),
Log: `[]`,
Hash: bytes.HexBytes([]byte("test")),
Hash: []byte("test"),
}
s.Require().Equal(&sdk.TxResponse{