From 58da5bf60f58b68625b8188850fe920b1f83531c Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Wed, 16 Jun 2021 23:39:12 +0200 Subject: [PATCH 1/2] perf: MsgTypeUrl optimization --- types/tx_msg.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/tx_msg.go b/types/tx_msg.go index d7f15e83f078..42d01fdc55ee 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -1,8 +1,6 @@ package types import ( - fmt "fmt" - "github.com/gogo/protobuf/proto" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -79,5 +77,5 @@ type TxEncoder func(tx Tx) ([]byte, error) // MsgTypeURL returns the TypeURL of a `sdk.Msg`. func MsgTypeURL(msg Msg) string { - return fmt.Sprintf("/%s", proto.MessageName(msg)) + return "/" + proto.MessageName(msg) } From ec6cf8dabfd45243c9b45bb61397ad5cf03391da Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Wed, 16 Jun 2021 23:58:20 +0200 Subject: [PATCH 2/2] add tests --- types/tx_msg_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/tx_msg_test.go b/types/tx_msg_test.go index 7a55c7d63e64..bf7763b02913 100644 --- a/types/tx_msg_test.go +++ b/types/tx_msg_test.go @@ -29,3 +29,7 @@ func (s *testMsgSuite) TestMsg() { s.Require().Nil(msg.ValidateBasic()) s.Require().NotPanics(func() { msg.GetSignBytes() }) } + +func (s *testMsgSuite) TestMsgTypeURL() { + s.Require().Equal("/testdata.TestMsg", sdk.MsgTypeURL(new(testdata.TestMsg))) +}