From 732f26b5fe0fa707f6867763d98a98fbf692576f Mon Sep 17 00:00:00 2001 From: Marko Date: Sun, 7 Jan 2024 19:28:00 +0100 Subject: [PATCH] chore(types): replace amino json encoder with stdlib (#18963) --- CHANGELOG.md | 1 + types/result.go | 3 +-- types/result_test.go | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaf8af5713..d41323763c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/types/result.go b/types/result.go index 4463bf8da0..1c62d05ab6 100644 --- a/types/result.go +++ b/types/result.go @@ -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) } diff --git a/types/result_test.go b/types/result_test.go index 19e43cd5e2..69fc5eba74 100644 --- a/types/result_test.go +++ b/types/result_test.go @@ -2,6 +2,7 @@ package types_test import ( "encoding/hex" + "encoding/json" "strings" "testing" "time" @@ -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" ) @@ -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())