chore(types): replace amino json encoder with stdlib (#18963)

This commit is contained in:
Marko
2024-01-07 18:28:00 +00:00
committed by GitHub
parent 48516bbf36
commit 732f26b5fe
3 changed files with 4 additions and 5 deletions
+1 -2
View File
@@ -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)
}
+2 -3
View File
@@ -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())