From 2e918315e34ee5dc5dd2404b1723fc8051c73554 Mon Sep 17 00:00:00 2001 From: Ali Zahid Raja Date: Wed, 5 Oct 2022 21:07:23 +0500 Subject: [PATCH 1/4] removed TypeMsg constants --- modules/apps/29-fee/types/msgs.go | 16 ---------------- modules/apps/transfer/types/msgs.go | 10 ---------- modules/core/02-client/types/msgs.go | 8 -------- modules/core/04-channel/keeper/keeper_test.go | 7 ++++--- 4 files changed, 4 insertions(+), 37 deletions(-) diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 5e2f791748f..36b9de99242 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -10,12 +10,6 @@ import ( host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) -// msg types -const ( - TypeMsgPayPacketFee = "payPacketFee" - TypeMsgPayPacketFeeAsync = "payPacketFeeAsync" -) - // NewMsgRegisterPayee creates a new instance of MsgRegisterPayee func NewMsgRegisterPayee(portID, channelID, relayerAddr, payeeAddr string) *MsgRegisterPayee { return &MsgRegisterPayee{ @@ -159,11 +153,6 @@ func (msg MsgPayPacketFee) Route() string { return RouterKey } -// Type implements sdk.Msg -func (msg MsgPayPacketFee) Type() string { - return TypeMsgPayPacketFee -} - // GetSignBytes implements sdk.Msg. func (msg MsgPayPacketFee) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) @@ -205,11 +194,6 @@ func (msg MsgPayPacketFeeAsync) Route() string { return RouterKey } -// Type implements sdk.Msg -func (msg MsgPayPacketFeeAsync) Type() string { - return TypeMsgPayPacketFeeAsync -} - // GetSignBytes implements sdk.Msg. func (msg MsgPayPacketFeeAsync) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index f076ba979e7..445d63a10d3 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -10,11 +10,6 @@ import ( host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) -// msg types -const ( - TypeMsgTransfer = "transfer" -) - // NewMsgTransfer creates a new MsgTransfer instance // //nolint:interfacer @@ -39,11 +34,6 @@ func (MsgTransfer) Route() string { return RouterKey } -// Type implements sdk.Msg -func (MsgTransfer) Type() string { - return TypeMsgTransfer -} - // ValidateBasic performs a basic check of the MsgTransfer fields. // NOTE: timeout height or timestamp values can be 0 to disable the timeout. // NOTE: The recipient addresses format is not validated as the format defined by diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index 70221ac4d15..4681f996ccb 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -9,14 +9,6 @@ import ( "github.com/cosmos/ibc-go/v6/modules/core/exported" ) -// message types for the IBC client -const ( - TypeMsgCreateClient string = "create_client" - TypeMsgUpdateClient string = "update_client" - TypeMsgUpgradeClient string = "upgrade_client" - TypeMsgSubmitMisbehaviour string = "submit_misbehaviour" -) - var ( _ sdk.Msg = &MsgCreateClient{} _ sdk.Msg = &MsgUpdateClient{} diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index ac97d72e7c3..4d65c70452c 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -89,6 +89,7 @@ func (suite *KeeperTestSuite) TestGetAllChannelsWithPortPrefix() { const ( secondChannelID = "channel-1" differentChannelPortID = "different-portid" + MsgTransfer = "transfer" ) allChannels := []types.IdentifiedChannel{ @@ -106,13 +107,13 @@ func (suite *KeeperTestSuite) TestGetAllChannelsWithPortPrefix() { name: "transfer channel is retrieved with prefix", prefix: "tra", allChannels: allChannels, - expectedChannels: []types.IdentifiedChannel{types.NewIdentifiedChannel(transfertypes.TypeMsgTransfer, ibctesting.FirstChannelID, types.Channel{})}, + expectedChannels: []types.IdentifiedChannel{types.NewIdentifiedChannel(MsgTransfer, ibctesting.FirstChannelID, types.Channel{})}, }, { name: "matches port with full name as prefix", - prefix: transfertypes.TypeMsgTransfer, + prefix: MsgTransfer, allChannels: allChannels, - expectedChannels: []types.IdentifiedChannel{types.NewIdentifiedChannel(transfertypes.TypeMsgTransfer, ibctesting.FirstChannelID, types.Channel{})}, + expectedChannels: []types.IdentifiedChannel{types.NewIdentifiedChannel(MsgTransfer, ibctesting.FirstChannelID, types.Channel{})}, }, { name: "no ports match prefix", From 5ce114e92387975d65e8fa7cce27392e9ca1e19e Mon Sep 17 00:00:00 2001 From: Ali Zahid Raja Date: Wed, 5 Oct 2022 21:44:25 +0500 Subject: [PATCH 2/4] updated changelog.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ad9cd98c33..3d941494edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (light-clients/06-solomachine) Moving `verifyMisbehaviour` function from update.go to misbehaviour_handle.go. * (apps/27-interchain-accounts) [\#2297](https://github.com/cosmos/ibc-go/pull/2297) Adding cli command to generate ICS27 packet data. * (modules/core/keeper) [\#1728](https://github.com/cosmos/ibc-go/pull/2399) Updated channel callback errors to include portID & channelID for better identification of errors. +* [\#2434](https://github.com/cosmos/ibc-go/pull/2478) Removed all `TypeMsg` constants ### Features From 909b6c329e1ade22a42b0e035393516fd73c0d21 Mon Sep 17 00:00:00 2001 From: Ali Zahid Raja Date: Thu, 6 Oct 2022 02:26:13 +0500 Subject: [PATCH 3/4] removed associated tests --- modules/apps/29-fee/types/msgs_test.go | 10 ---------- modules/apps/transfer/types/msgs_test.go | 7 ------- 2 files changed, 17 deletions(-) diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index e34e0738318..05dcc84ec46 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -237,11 +237,6 @@ func TestMsgPayPacketFeeRoute(t *testing.T) { require.Equal(t, types.RouterKey, msg.Route()) } -func TestMsgPayPacketFeeType(t *testing.T) { - var msg types.MsgPayPacketFee - require.Equal(t, "payPacketFee", msg.Type()) -} - func TestMsgPayPacketFeeGetSignBytes(t *testing.T) { fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) msg := types.NewMsgPayPacketFee(fee, ibctesting.MockFeePort, ibctesting.FirstChannelID, defaultAccAddress, nil) @@ -391,11 +386,6 @@ func TestMsgPayPacketFeeAsyncRoute(t *testing.T) { require.Equal(t, types.RouterKey, msg.Route()) } -func TestMsgPayPacketFeeAsyncType(t *testing.T) { - var msg types.MsgPayPacketFeeAsync - require.Equal(t, "payPacketFeeAsync", msg.Type()) -} - func TestMsgPayPacketFeeAsyncGetSignBytes(t *testing.T) { packetID := channeltypes.NewPacketID(ibctesting.MockFeePort, ibctesting.FirstChannelID, 1) fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index cf690f35c17..b61dda213ba 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -46,13 +46,6 @@ func TestMsgTransferRoute(t *testing.T) { require.Equal(t, RouterKey, msg.Route()) } -// TestMsgTransferType tests Type for MsgTransfer -func TestMsgTransferType(t *testing.T) { - msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, timeoutHeight, 0) - - require.Equal(t, "transfer", msg.Type()) -} - func TestMsgTransferGetSignBytes(t *testing.T) { msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, timeoutHeight, 0) expected := fmt.Sprintf(`{"type":"cosmos-sdk/MsgTransfer","value":{"receiver":"%s","sender":"%s","source_channel":"testchannel","source_port":"testportid","timeout_height":{"revision_height":"10"},"token":{"amount":"100","denom":"atom"}}}`, addr2, addr1) From 43a35c7a7df1ae538797c69f91dcf25d75a40333 Mon Sep 17 00:00:00 2001 From: Ali Zahid Raja Date: Thu, 6 Oct 2022 15:13:47 +0500 Subject: [PATCH 4/4] removed new variable --- modules/core/04-channel/keeper/keeper_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index f2ffc5a16ba..422eb28bd36 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -88,7 +88,6 @@ func (suite *KeeperTestSuite) TestGetAllChannelsWithPortPrefix() { const ( secondChannelID = "channel-1" differentChannelPortID = "different-portid" - MsgTransfer = "transfer" ) allChannels := []types.IdentifiedChannel{ @@ -106,13 +105,13 @@ func (suite *KeeperTestSuite) TestGetAllChannelsWithPortPrefix() { name: "transfer channel is retrieved with prefix", prefix: "tra", allChannels: allChannels, - expectedChannels: []types.IdentifiedChannel{types.NewIdentifiedChannel(MsgTransfer, ibctesting.FirstChannelID, types.Channel{})}, + expectedChannels: []types.IdentifiedChannel{types.NewIdentifiedChannel(transfertypes.PortID, ibctesting.FirstChannelID, types.Channel{})}, }, { name: "matches port with full name as prefix", - prefix: MsgTransfer, + prefix: transfertypes.PortID, allChannels: allChannels, - expectedChannels: []types.IdentifiedChannel{types.NewIdentifiedChannel(MsgTransfer, ibctesting.FirstChannelID, types.Channel{})}, + expectedChannels: []types.IdentifiedChannel{types.NewIdentifiedChannel(transfertypes.PortID, ibctesting.FirstChannelID, types.Channel{})}, }, { name: "no ports match prefix",