Skip to content

Commit

Permalink
chore(types): replace amino json encoder with stdlib (#18963)
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle authored Jan 7, 2024
1 parent 48516bb commit 732f26b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (tx) [#18772](https://github.com/cosmos/cosmos-sdk/pull/18772) Remove misleading gas wanted from tx simulation failure log.
* (tx) [#18852](https://github.com/cosmos/cosmos-sdk/pull/18852) Add `WithFromName` to tx factory.
* (testutil) [#18930](https://github.com/cosmos/cosmos-sdk/pull/18930) Add NodeURI for clientCtx.
* (types) [#18963](https://github.com/cosmos/cosmos-sdk/pull/18963) Swap out amino json encoding of `ABCIMessageLogs` for std lib json encoding

### Bug Fixes

Expand Down
3 changes: 1 addition & 2 deletions types/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ func NewABCIMessageLog(i uint32, log string, events Events) ABCIMessageLog {
// String implements the fmt.Stringer interface for the ABCIMessageLogs type.
func (logs ABCIMessageLogs) String() (str string) {
if logs != nil {
cdc := codec.NewLegacyAmino()
raw, err := cdc.MarshalJSON(logs)
raw, err := json.Marshal(logs)
if err == nil {
str = string(raw)
}
Expand Down
5 changes: 2 additions & 3 deletions types/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types_test

import (
"encoding/hex"
"encoding/json"
"strings"
"testing"
"time"
Expand All @@ -12,7 +13,6 @@ import (
cmt "github.com/cometbft/cometbft/types"
"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -39,14 +39,13 @@ func (s *resultTestSuite) TestParseABCILog() {
}

func (s *resultTestSuite) TestABCIMessageLog() {
cdc := codec.NewLegacyAmino()
events := sdk.Events{
sdk.NewEvent("transfer", sdk.NewAttribute("sender", "foo")),
sdk.NewEvent("transfer", sdk.NewAttribute("sender", "bar")),
}
msgLog := sdk.NewABCIMessageLog(0, "", events)
msgLogs := sdk.ABCIMessageLogs{msgLog}
bz, err := cdc.MarshalJSON(msgLogs)
bz, err := json.Marshal(msgLogs)

s.Require().NoError(err)
s.Require().Equal(string(bz), msgLogs.String())
Expand Down

0 comments on commit 732f26b

Please sign in to comment.