chore: remove x/gov dependencies in x/distr (#16587)
Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com>
This commit is contained in:
parent
aeccbc910c
commit
7e0148805a
@ -399,7 +399,7 @@ func TestMsgSetSendEnabled(t *testing.T) {
|
||||
"invalid authority",
|
||||
"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn",
|
||||
addr1Str,
|
||||
"invalid signer",
|
||||
"expected authority account as only signer for proposal message",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@ -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")
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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")
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 (
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user