Skip to content

Commit

Permalink
replace json encoder from amino json to faster library
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Jan 6, 2024
1 parent 7f3114e commit a1ee2b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
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
2 changes: 1 addition & 1 deletion x/auth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
Expand Down Expand Up @@ -147,7 +148,6 @@ require (
go.etcd.io/bbolt v1.3.7 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
Expand Down

0 comments on commit a1ee2b7

Please sign in to comment.