diff --git a/tests/integration/bank/app_test.go b/tests/integration/bank/app_test.go index ec74b9aa9969..fde912059809 100644 --- a/tests/integration/bank/app_test.go +++ b/tests/integration/bank/app_test.go @@ -399,7 +399,7 @@ func TestMsgSetSendEnabled(t *testing.T) { "invalid authority", "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", addr1Str, - "invalid signer", + "expected authority account as only signer for proposal message", }, }, { diff --git a/x/bank/types/errors.go b/x/bank/types/errors.go index bec021a99f4e..a6aa4af14ec5 100644 --- a/x/bank/types/errors.go +++ b/x/bank/types/errors.go @@ -12,5 +12,5 @@ var ( ErrInvalidKey = errors.Register(ModuleName, 7, "invalid key") ErrDuplicateEntry = errors.Register(ModuleName, 8, "duplicate entry") ErrMultipleSenders = errors.Register(ModuleName, 9, "multiple senders not allowed") - ErrInvalidSigner = errors.Register(ModuleName, 10, "invalid signer") + ErrInvalidSigner = errors.Register(ModuleName, 10, "expected authority account as only signer for proposal message") ) diff --git a/x/distribution/keeper/msg_server.go b/x/distribution/keeper/msg_server.go index 94c34588abc1..2c2485075c23 100644 --- a/x/distribution/keeper/msg_server.go +++ b/x/distribution/keeper/msg_server.go @@ -10,7 +10,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) type msgServer struct { @@ -214,7 +213,7 @@ func (k *Keeper) validateAuthority(authority string) error { } if k.authority != authority { - return errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, authority) + return errors.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, authority) } return nil diff --git a/x/distribution/module.go b/x/distribution/module.go index 5d15832852b3..37547438de30 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -29,7 +29,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/distribution/keeper" "github.com/cosmos/cosmos-sdk/x/distribution/simulation" "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -249,7 +248,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { } // default to governance authority if not provided - authority := authtypes.NewModuleAddress(govtypes.ModuleName) + authority := authtypes.NewModuleAddress(types.GovModuleName) if in.Config.Authority != "" { authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) } diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index 3cf2c732ca66..0f8d86ac4447 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -6,7 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) // RegisterLegacyAminoCodec registers the necessary x/distribution interfaces @@ -36,10 +35,5 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgDepositValidatorRewardsPool{}, ) - registry.RegisterImplementations( - (*govtypes.Content)(nil), - &CommunityPoolSpendProposal{}, - ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/distribution/types/errors.go b/x/distribution/types/errors.go index 0ce6a76d887c..a208b7bc210b 100644 --- a/x/distribution/types/errors.go +++ b/x/distribution/types/errors.go @@ -17,4 +17,5 @@ var ( ErrNoValidatorExists = errors.Register(ModuleName, 12, "validator does not exist") ErrNoDelegationExists = errors.Register(ModuleName, 13, "delegation does not exist") ErrInvalidProposalContent = errors.Register(ModuleName, 14, "invalid proposal content") + ErrInvalidSigner = errors.Register(ModuleName, 15, "expected authority account as only signer for proposal message") ) diff --git a/x/distribution/types/keys.go b/x/distribution/types/keys.go index 7e555b6c2b23..7f7e5b4b27b2 100644 --- a/x/distribution/types/keys.go +++ b/x/distribution/types/keys.go @@ -19,6 +19,9 @@ const ( // RouterKey is the message route for distribution RouterKey = ModuleName + + // GovModuleName is the name of the gov module + GovModuleName = "gov" ) // Keys for distribution store diff --git a/x/distribution/types/proposal.go b/x/distribution/types/proposal.go index 257e546dcc9e..b522020feb40 100644 --- a/x/distribution/types/proposal.go +++ b/x/distribution/types/proposal.go @@ -35,7 +35,7 @@ func (csp *CommunityPoolSpendProposal) ValidateBasic() error { } // validateAbstract is semantically duplicated from x/gov/types/v1beta1/proposal.go to avoid a cyclic dependency -// between these two modules, x/distribution and x/gov. +// between these two modules (x/distribution and x/gov). // See: https://github.com/cosmos/cosmos-sdk/blob/4a6a1e3cb8de459891cb0495052589673d14ef51/x/gov/types/v1beta1/proposal.go#L196-L214 func validateAbstract(c *CommunityPoolSpendProposal) error { const ( diff --git a/x/gov/keeper/msg_server_test.go b/x/gov/keeper/msg_server_test.go index cb4181c8237d..a99f0e521c19 100644 --- a/x/gov/keeper/msg_server_test.go +++ b/x/gov/keeper/msg_server_test.go @@ -160,7 +160,7 @@ func (suite *KeeperTestSuite) TestSubmitProposalReq() { ) }, expErr: true, - expErrMsg: "expected gov account as only signer for proposal message", + expErrMsg: "expected authority account as only signer for proposal message", }, "signer isn't gov account": { preRun: func() (*v1.MsgSubmitProposal, error) { @@ -175,7 +175,7 @@ func (suite *KeeperTestSuite) TestSubmitProposalReq() { ) }, expErr: true, - expErrMsg: "expected gov account as only signer for proposal message", + expErrMsg: "expected authority account as only signer for proposal message", }, "invalid msg handler": { preRun: func() (*v1.MsgSubmitProposal, error) { diff --git a/x/gov/types/errors.go b/x/gov/types/errors.go index fa584da93433..43bd7481b2ae 100644 --- a/x/gov/types/errors.go +++ b/x/gov/types/errors.go @@ -17,7 +17,7 @@ var ( ErrUnroutableProposalMsg = errors.Register(ModuleName, 10, "proposal message not recognized by router") ErrNoProposalMsgs = errors.Register(ModuleName, 11, "no messages proposed") ErrInvalidProposalMsg = errors.Register(ModuleName, 12, "invalid proposal message") - ErrInvalidSigner = errors.Register(ModuleName, 13, "expected gov account as only signer for proposal message") + ErrInvalidSigner = errors.Register(ModuleName, 13, "expected authority account as only signer for proposal message") ErrMetadataTooLong = errors.Register(ModuleName, 15, "metadata too long") ErrMinDepositTooSmall = errors.Register(ModuleName, 16, "minimum deposit is too small") ErrInvalidProposer = errors.Register(ModuleName, 18, "invalid proposer") diff --git a/x/gov/types/v1beta1/codec.go b/x/gov/types/v1beta1/codec.go index d5b8b90880e2..e4479a6f4ce7 100644 --- a/x/gov/types/v1beta1/codec.go +++ b/x/gov/types/v1beta1/codec.go @@ -6,6 +6,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -32,6 +33,10 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*Content)(nil), &TextProposal{}, ) + registry.RegisterImplementations( + (*Content)(nil), + &distrtypes.CommunityPoolSpendProposal{}, // nolint: staticcheck // avoid using `CommunityPoolSpendProposal`, might be reomved in future. + ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/mint/types/errors.go b/x/mint/types/errors.go index f3637858e847..f3797fe3bfaf 100644 --- a/x/mint/types/errors.go +++ b/x/mint/types/errors.go @@ -2,4 +2,4 @@ package types import "cosmossdk.io/errors" -var ErrInvalidSigner = errors.Register(ModuleName, 1, "invalid signer") +var ErrInvalidSigner = errors.Register(ModuleName, 1, "expected authority account as only signer for proposal message")