diff --git a/e2e/tests/wasm/grandpa_test.go b/e2e/tests/wasm/grandpa_test.go index 6aa250b1885..a35ae853638 100644 --- a/e2e/tests/wasm/grandpa_test.go +++ b/e2e/tests/wasm/grandpa_test.go @@ -19,14 +19,14 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testutil" testifysuite "github.com/stretchr/testify/suite" - cmtjson "github.com/cometbft/cometbft/libs/json" - "cosmossdk.io/math" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + cmtjson "github.com/cometbft/cometbft/libs/json" + "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs.go b/modules/apps/27-interchain-accounts/controller/types/msgs.go index 213fcbfbc04..1afa45929cb 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs.go @@ -50,16 +50,6 @@ func (msg MsgRegisterInterchainAccount) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgRegisterInterchainAccount) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Owner) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{accAddr} -} - // NewMsgSendTx creates a new instance of MsgSendTx func NewMsgSendTx(owner, connectionID string, relativeTimeoutTimestamp uint64, packetData icatypes.InterchainAccountPacketData) *MsgSendTx { return &MsgSendTx{ @@ -95,16 +85,6 @@ func (msg MsgSendTx) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgSendTx) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Owner) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{accAddr} -} - // NewMsgUpdateParams creates a new MsgUpdateParams instance func NewMsgUpdateParams(signer string, params Params) *MsgUpdateParams { return &MsgUpdateParams{ @@ -122,13 +102,3 @@ func (msg MsgUpdateParams) ValidateBasic() error { return nil } - -// GetSigners implements sdk.Msg -func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{accAddr} -} diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index 541f3830fb6..17bf0d98e0c 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -98,7 +98,10 @@ func TestMsgRegisterInterchainAccountGetSigners(t *testing.T) { require.NoError(t, err) msg := types.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, ibctesting.TestAccAddress, "") - require.Equal(t, []sdk.AccAddress{expSigner}, msg.GetSigners()) + encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) + require.NoError(t, err) + require.Equal(t, expSigner.Bytes(), signers[0]) } func TestMsgSendTxValidateBasic(t *testing.T) { @@ -214,7 +217,9 @@ func TestMsgSendTxGetSigners(t *testing.T) { 100000, packetData, ) - require.Equal(t, []sdk.AccAddress{expSigner}, msg.GetSigners()) + signers, _, err := encodingConfig.Codec.GetMsgV1Signers(msg) + require.NoError(t, err) + require.Equal(t, expSigner.Bytes(), signers[0]) } // TestMsgUpdateParamsValidateBasic tests ValidateBasic for MsgUpdateParams @@ -259,12 +264,15 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { Signer: tc.address.String(), Params: types.DefaultParams(), } + + encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(&msg) if tc.expPass { - require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners()) + require.NoError(t, err) + require.Equal(t, tc.address.Bytes(), signers[0]) } else { - require.Panics(t, func() { - msg.GetSigners() - }) + require.Error(t, err) } + } } diff --git a/modules/apps/27-interchain-accounts/host/types/msgs.go b/modules/apps/27-interchain-accounts/host/types/msgs.go index 845139a4a34..8b23b5040e1 100644 --- a/modules/apps/27-interchain-accounts/host/types/msgs.go +++ b/modules/apps/27-interchain-accounts/host/types/msgs.go @@ -30,13 +30,3 @@ func (msg MsgUpdateParams) ValidateBasic() error { return msg.Params.Validate() } - -// GetSigners implements sdk.Msg -func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{accAddr} -} diff --git a/modules/apps/27-interchain-accounts/host/types/msgs_test.go b/modules/apps/27-interchain-accounts/host/types/msgs_test.go index 1170f82b895..b9d1d96e2bc 100644 --- a/modules/apps/27-interchain-accounts/host/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/host/types/msgs_test.go @@ -6,7 +6,9 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" ) @@ -62,12 +64,13 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { tc := tc msg := types.NewMsgUpdateParams(tc.address.String(), types.DefaultParams()) + encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) if tc.expPass { - require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners()) + require.NoError(t, err) + require.Equal(t, tc.address.Bytes(), signers[0]) } else { - require.Panics(t, func() { - msg.GetSigners() - }) + require.Error(t, err) } } } diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index af2a9287a65..be3a3c5f860 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -63,16 +63,6 @@ func (msg MsgRegisterPayee) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgRegisterPayee) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Relayer) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{signer} -} - // NewMsgRegisterCounterpartyPayee creates a new instance of MsgRegisterCounterpartyPayee func NewMsgRegisterCounterpartyPayee(portID, channelID, relayerAddr, counterpartyPayeeAddr string) *MsgRegisterCounterpartyPayee { return &MsgRegisterCounterpartyPayee{ @@ -109,16 +99,6 @@ func (msg MsgRegisterCounterpartyPayee) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgRegisterCounterpartyPayee) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Relayer) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{signer} -} - // NewMsgPayPacketFee creates a new instance of MsgPayPacketFee func NewMsgPayPacketFee(fee Fee, sourcePortID, sourceChannelID, signer string, relayers []string) *MsgPayPacketFee { return &MsgPayPacketFee{ @@ -155,15 +135,6 @@ func (msg MsgPayPacketFee) ValidateBasic() error { return msg.Fee.Validate() } -// GetSigners implements sdk.Msg -func (msg MsgPayPacketFee) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgPayPacketAsync creates a new instance of MsgPayPacketFee func NewMsgPayPacketFeeAsync(packetID channeltypes.PacketId, packetFee PacketFee) *MsgPayPacketFeeAsync { return &MsgPayPacketFeeAsync{ @@ -180,13 +151,3 @@ func (msg MsgPayPacketFeeAsync) ValidateBasic() error { return msg.PacketFee.Validate() } - -// GetSigners implements sdk.Msg -// The signer of the fee message must be the refund address -func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.PacketFee.RefundAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 6f1d2bce4eb..68195180ba0 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -6,9 +6,11 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cometbft/cometbft/crypto/secp256k1" + modulefee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" @@ -88,7 +90,11 @@ func TestMsgRegisterPayeeValidation(t *testing.T) { func TestRegisterPayeeGetSigners(t *testing.T) { accAddress := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) msg := types.NewMsgRegisterPayee(ibctesting.MockPort, ibctesting.FirstChannelID, accAddress.String(), defaultAccAddress) - require.Equal(t, []sdk.AccAddress{accAddress}, msg.GetSigners()) + + encodingCfg := moduletestutil.MakeTestEncodingConfig(modulefee.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) + require.NoError(t, err) + require.Equal(t, accAddress.Bytes(), signers[0]) } func TestMsgRegisterCountepartyPayeeValidation(t *testing.T) { @@ -168,7 +174,11 @@ func TestMsgRegisterCountepartyPayeeValidation(t *testing.T) { func TestRegisterCountepartyAddressGetSigners(t *testing.T) { accAddress := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) msg := types.NewMsgRegisterCounterpartyPayee(ibctesting.MockPort, ibctesting.FirstChannelID, accAddress.String(), defaultAccAddress) - require.Equal(t, []sdk.AccAddress{accAddress}, msg.GetSigners()) + + encodingCfg := moduletestutil.MakeTestEncodingConfig(modulefee.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) + require.NoError(t, err) + require.Equal(t, accAddress.Bytes(), signers[0]) } func TestMsgPayPacketFeeValidation(t *testing.T) { @@ -244,7 +254,10 @@ func TestPayPacketFeeGetSigners(t *testing.T) { fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) msg := types.NewMsgPayPacketFee(fee, ibctesting.MockFeePort, ibctesting.FirstChannelID, refundAddr.String(), nil) - require.Equal(t, []sdk.AccAddress{refundAddr}, msg.GetSigners()) + encodingCfg := moduletestutil.MakeTestEncodingConfig(modulefee.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) + require.NoError(t, err) + require.Equal(t, refundAddr.Bytes(), signers[0]) } func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { @@ -378,8 +391,10 @@ func TestPayPacketFeeAsyncGetSigners(t *testing.T) { packetID := channeltypes.NewPacketID(ibctesting.MockFeePort, ibctesting.FirstChannelID, 1) fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) packetFee := types.NewPacketFee(fee, refundAddr.String(), nil) - msg := types.NewMsgPayPacketFeeAsync(packetID, packetFee) - require.Equal(t, []sdk.AccAddress{refundAddr}, msg.GetSigners()) + encodingCfg := moduletestutil.MakeTestEncodingConfig(modulefee.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) + require.NoError(t, err) + require.Equal(t, refundAddr.Bytes(), signers[0]) } diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index ad126d149c7..2b045fee47e 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -42,16 +42,6 @@ func (msg MsgUpdateParams) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{accAddr} -} - // NewMsgTransfer creates a new MsgTransfer instance func NewMsgTransfer( sourcePort, sourceChannel string, @@ -88,7 +78,7 @@ func (msg MsgTransfer) ValidateBasic() error { if !msg.Token.IsPositive() { return errorsmod.Wrap(ibcerrors.ErrInsufficientFunds, msg.Token.String()) } - // NOTE: sender format must be validated as it is required by the GetSigners function. + _, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) @@ -104,12 +94,3 @@ func (msg MsgTransfer) ValidateBasic() error { } return ValidateIBCDenom(msg.Token.Denom) } - -// GetSigners implements sdk.Msg -func (msg MsgTransfer) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 6dc2dedc31a..e9bb11cac54 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -9,7 +9,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" @@ -85,11 +87,12 @@ func TestMsgTransferValidation(t *testing.T) { // TestMsgTransferGetSigners tests GetSigners for MsgTransfer func TestMsgTransferGetSigners(t *testing.T) { addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - msg := types.NewMsgTransfer(validPort, validChannel, coin, addr.String(), receiver, timeoutHeight, 0, "") - res := msg.GetSigners() - require.Equal(t, []sdk.AccAddress{addr}, res) + encodingCfg := moduletestutil.MakeTestEncodingConfig(transfer.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) + require.NoError(t, err) + require.Equal(t, addr.Bytes(), signers[0]) } // TestMsgUpdateParamsValidateBasic tests ValidateBasic for MsgUpdateParams @@ -134,12 +137,14 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { Signer: tc.address.String(), Params: types.DefaultParams(), } + + encodingCfg := moduletestutil.MakeTestEncodingConfig(transfer.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(&msg) if tc.expPass { - require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners()) + require.NoError(t, err) + require.Equal(t, tc.address.Bytes(), signers[0]) } else { - require.Panics(t, func() { - msg.GetSigners() - }) + require.Error(t, err) } } } diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index 1eb5472ca87..77aee0828ee 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -83,15 +83,6 @@ func (msg MsgCreateClient) ValidateBasic() error { return consensusState.ValidateBasic() } -// GetSigners implements sdk.Msg -func (msg MsgCreateClient) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (msg MsgCreateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var clientState exported.ClientState @@ -134,15 +125,6 @@ func (msg MsgUpdateClient) ValidateBasic() error { return host.ClientIdentifierValidator(msg.ClientId) } -// GetSigners implements sdk.Msg -func (msg MsgUpdateClient) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var clientMsg exported.ClientMessage @@ -204,15 +186,6 @@ func (msg MsgUpgradeClient) ValidateBasic() error { return host.ClientIdentifierValidator(msg.ClientId) } -// GetSigners implements sdk.Msg -func (msg MsgUpgradeClient) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (msg MsgUpgradeClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var ( @@ -256,15 +229,6 @@ func (msg MsgSubmitMisbehaviour) ValidateBasic() error { return host.ClientIdentifierValidator(msg.ClientId) } -// GetSigners returns the single expected signer for a MsgSubmitMisbehaviour. -func (msg MsgSubmitMisbehaviour) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (msg MsgSubmitMisbehaviour) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var misbehaviour exported.ClientMessage @@ -301,15 +265,6 @@ func (msg *MsgRecoverClient) ValidateBasic() error { return nil } -// GetSigners returns the expected signers for a MsgRecoverClient message. -func (msg *MsgRecoverClient) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // NewMsgIBCSoftwareUpgrade creates a new MsgIBCSoftwareUpgrade instance func NewMsgIBCSoftwareUpgrade(signer string, plan upgradetypes.Plan, upgradedClientState exported.ClientState) (*MsgIBCSoftwareUpgrade, error) { anyClient, err := PackClientState(upgradedClientState) @@ -343,15 +298,6 @@ func (msg *MsgIBCSoftwareUpgrade) ValidateBasic() error { return msg.Plan.ValidateBasic() } -// GetSigners returns the expected signers for a MsgIBCSoftwareUpgrade message. -func (msg *MsgIBCSoftwareUpgrade) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (msg *MsgIBCSoftwareUpgrade) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return unpacker.UnpackAny(msg.UpgradedClientState, new(exported.ClientState)) @@ -365,15 +311,6 @@ func NewMsgUpdateParams(signer string, params Params) *MsgUpdateParams { } } -// GetSigners returns the expected signers for a MsgUpdateParams message. -func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // ValidateBasic performs basic checks on a MsgUpdateParams. func (msg *MsgUpdateParams) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index f051492780c..ccbd90e3ead 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -14,7 +14,9 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + ibc "github.com/cosmos/ibc-go/v8/modules/core" "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v8/modules/core/24-host" @@ -701,12 +703,13 @@ func TestMsgRecoverClientGetSigners(t *testing.T) { msg := types.MsgRecoverClient{ Signer: tc.address.String(), } + encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(&msg) if tc.expPass { - require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners()) + require.NoError(t, err) + require.Equal(t, tc.address.Bytes(), signers[0]) } else { - require.Panics(t, func() { - msg.GetSigners() - }) + require.Error(t, err) } } } @@ -755,7 +758,7 @@ func (suite *TypesTestSuite) TestMsgIBCSoftwareUpgrade_NewMsgIBCSoftwareUpgrade( } // TestMsgIBCSoftwareUpgrade_GetSigners tests GetSigners for MsgIBCSoftwareUpgrade -func (suite *TypesTestSuite) TestMsgIBCSoftwareUpgrade_GetSigners() { +func TestMsgIBCSoftwareUpgrade_GetSigners(t *testing.T) { testCases := []struct { name string address sdk.AccAddress @@ -774,7 +777,7 @@ func (suite *TypesTestSuite) TestMsgIBCSoftwareUpgrade_GetSigners() { } for _, tc := range testCases { - clientState := ibctm.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath) + clientState := ibctm.NewClientState("testchain1-1", ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath) plan := upgradetypes.Plan{ Name: "upgrade IBC clients", Height: 1000, @@ -784,12 +787,15 @@ func (suite *TypesTestSuite) TestMsgIBCSoftwareUpgrade_GetSigners() { plan, clientState, ) - suite.Require().NoError(err) + require.NoError(t, err) + encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) if tc.expPass { - suite.Require().Equal([]sdk.AccAddress{tc.address}, msg.GetSigners()) + require.NoError(t, err) + require.Equal(t, tc.address.Bytes(), signers[0]) } else { - suite.Require().Panics(func() { msg.GetSigners() }) + require.Error(t, err) } } } @@ -949,18 +955,18 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { for _, tc := range testCases { tc := tc - t.Run(tc.name, func(t *testing.T) { - msg := types.MsgUpdateParams{ - Signer: tc.address.String(), - Params: types.DefaultParams(), - } - if tc.expPass { - require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners()) - } else { - require.Panics(t, func() { - msg.GetSigners() - }) - } - }) + + msg := types.MsgUpdateParams{ + Signer: tc.address.String(), + Params: types.DefaultParams(), + } + encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(&msg) + if tc.expPass { + require.NoError(t, err) + require.Equal(t, tc.address.Bytes(), signers[0]) + } else { + require.Error(t, err) + } } } diff --git a/modules/core/03-connection/types/msgs.go b/modules/core/03-connection/types/msgs.go index c46c783767e..cac392c49ee 100644 --- a/modules/core/03-connection/types/msgs.go +++ b/modules/core/03-connection/types/msgs.go @@ -74,15 +74,6 @@ func (msg MsgConnectionOpenInit) ValidateBasic() error { return msg.Counterparty.ValidateBasic() } -// GetSigners implements sdk.Msg -func (msg MsgConnectionOpenInit) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // NewMsgConnectionOpenTry creates a new MsgConnectionOpenTry instance func NewMsgConnectionOpenTry( clientID, counterpartyConnectionID, counterpartyClientID string, @@ -167,15 +158,6 @@ func (msg MsgConnectionOpenTry) UnpackInterfaces(unpacker codectypes.AnyUnpacker return unpacker.UnpackAny(msg.ClientState, new(exported.ClientState)) } -// GetSigners implements sdk.Msg -func (msg MsgConnectionOpenTry) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // NewMsgConnectionOpenAck creates a new MsgConnectionOpenAck instance func NewMsgConnectionOpenAck( connectionID, counterpartyConnectionID string, counterpartyClient exported.ClientState, @@ -244,15 +226,6 @@ func (msg MsgConnectionOpenAck) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgConnectionOpenAck) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // NewMsgConnectionOpenConfirm creates a new MsgConnectionOpenConfirm instance func NewMsgConnectionOpenConfirm( connectionID string, proofAck []byte, proofHeight clienttypes.Height, @@ -281,15 +254,6 @@ func (msg MsgConnectionOpenConfirm) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgConnectionOpenConfirm) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // NewMsgUpdateParams creates a new MsgUpdateParams instance func NewMsgUpdateParams(signer string, params Params) *MsgUpdateParams { return &MsgUpdateParams{ @@ -298,15 +262,6 @@ func NewMsgUpdateParams(signer string, params Params) *MsgUpdateParams { } } -// GetSigners returns the expected signers for a MsgUpdateParams message. -func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { - accAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{accAddr} -} - // ValidateBasic performs basic checks on a MsgUpdateParams. func (msg *MsgUpdateParams) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index ba26c117c0e..b125baa6e56 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -16,7 +16,9 @@ import ( storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + ibc "github.com/cosmos/ibc-go/v8/modules/core" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" @@ -299,12 +301,14 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { Signer: tc.address.String(), Params: types.DefaultParams(), } + + encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(&msg) if tc.expPass { - require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners()) + require.NoError(t, err) + require.Equal(t, tc.address.Bytes(), signers[0]) } else { - require.Panics(t, func() { - msg.GetSigners() - }) + require.Error(t, err) } } } diff --git a/modules/core/04-channel/types/msgs.go b/modules/core/04-channel/types/msgs.go index 812829307c0..02f6c43777b 100644 --- a/modules/core/04-channel/types/msgs.go +++ b/modules/core/04-channel/types/msgs.go @@ -73,15 +73,6 @@ func (msg MsgChannelOpenInit) ValidateBasic() error { return msg.Channel.ValidateBasic() } -// GetSigners implements sdk.Msg -func (msg MsgChannelOpenInit) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgChannelOpenTry creates a new MsgChannelOpenTry instance // The version string is deprecated and will be ignored by core IBC. // It is left as an argument for go API backwards compatibility. @@ -131,15 +122,6 @@ func (msg MsgChannelOpenTry) ValidateBasic() error { return msg.Channel.ValidateBasic() } -// GetSigners implements sdk.Msg -func (msg MsgChannelOpenTry) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgChannelOpenAck creates a new MsgChannelOpenAck instance func NewMsgChannelOpenAck( portID, channelID, counterpartyChannelID string, cpv string, proofTry []byte, proofHeight clienttypes.Height, @@ -177,15 +159,6 @@ func (msg MsgChannelOpenAck) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgChannelOpenAck) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgChannelOpenConfirm creates a new MsgChannelOpenConfirm instance func NewMsgChannelOpenConfirm( portID, channelID string, proofAck []byte, proofHeight clienttypes.Height, @@ -218,15 +191,6 @@ func (msg MsgChannelOpenConfirm) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgChannelOpenConfirm) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgChannelCloseInit creates a new MsgChannelCloseInit instance func NewMsgChannelCloseInit( portID string, channelID string, signer string, @@ -253,15 +217,6 @@ func (msg MsgChannelCloseInit) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgChannelCloseInit) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgChannelCloseConfirm creates a new MsgChannelCloseConfirm instance func NewMsgChannelCloseConfirm( portID, channelID string, proofInit []byte, proofHeight clienttypes.Height, @@ -294,15 +249,6 @@ func (msg MsgChannelCloseConfirm) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg -func (msg MsgChannelCloseConfirm) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgRecvPacket constructs new MsgRecvPacket func NewMsgRecvPacket( packet Packet, proofCommitment []byte, proofHeight clienttypes.Height, @@ -335,15 +281,6 @@ func (msg MsgRecvPacket) GetDataSignBytes() []byte { return []byte(s) } -// GetSigners implements sdk.Msg -func (msg MsgRecvPacket) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgTimeout constructs new MsgTimeout func NewMsgTimeout( packet Packet, nextSequenceRecv uint64, proofUnreceived []byte, @@ -373,15 +310,6 @@ func (msg MsgTimeout) ValidateBasic() error { return msg.Packet.ValidateBasic() } -// GetSigners implements sdk.Msg -func (msg MsgTimeout) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgTimeoutOnClose constructs new MsgTimeoutOnClose func NewMsgTimeoutOnClose( packet Packet, nextSequenceRecv uint64, @@ -416,15 +344,6 @@ func (msg MsgTimeoutOnClose) ValidateBasic() error { return msg.Packet.ValidateBasic() } -// GetSigners implements sdk.Msg -func (msg MsgTimeoutOnClose) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} - // NewMsgAcknowledgement constructs a new MsgAcknowledgement func NewMsgAcknowledgement( packet Packet, @@ -455,12 +374,3 @@ func (msg MsgAcknowledgement) ValidateBasic() error { } return msg.Packet.ValidateBasic() } - -// GetSigners implements sdk.Msg -func (msg MsgAcknowledgement) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - panic(err) - } - return []sdk.AccAddress{signer} -} diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index 8570ad59065..e5c027120bb 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -14,10 +14,13 @@ import ( storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + ibc "github.com/cosmos/ibc-go/v8/modules/core" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/cosmos/ibc-go/v8/testing/simapp" ) @@ -339,11 +342,14 @@ func (suite *TypesTestSuite) TestMsgRecvPacketValidateBasic() { } func (suite *TypesTestSuite) TestMsgRecvPacketGetSigners() { - msg := types.NewMsgRecvPacket(packet, suite.proof, height, addr) - res := msg.GetSigners() + signer := sdk.AccAddress(ibctesting.TestAccAddress) + msg := types.NewMsgRecvPacket(packet, suite.proof, height, signer.String()) - expected := "[7465737461646472313131313131313131313131]" - suite.Equal(expected, fmt.Sprintf("%v", res)) + encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) + signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) + + suite.Require().NoError(err) + suite.Require().Equal(signer.Bytes(), signers[0]) } func (suite *TypesTestSuite) TestMsgTimeoutValidateBasic() {