Skip to content

Commit

Permalink
chore: remove x/gov dependencies in x/distr (#16587)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Kocubinski <[email protected]>
  • Loading branch information
atheeshp and kocubinski authored Jun 19, 2023
1 parent aeccbc9 commit 7e01488
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tests/integration/bank/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func TestMsgSetSendEnabled(t *testing.T) {
"invalid authority",
"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn",
addr1Str,
"invalid signer",
"expected authority account as only signer for proposal message",
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion x/bank/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
3 changes: 1 addition & 2 deletions x/distribution/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions x/distribution/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 0 additions & 6 deletions x/distribution/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -36,10 +35,5 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&MsgDepositValidatorRewardsPool{},
)

registry.RegisterImplementations(
(*govtypes.Content)(nil),
&CommunityPoolSpendProposal{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
1 change: 1 addition & 0 deletions x/distribution/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
3 changes: 3 additions & 0 deletions x/distribution/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions x/gov/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion x/gov/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions x/gov/types/v1beta1/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 changes: 1 addition & 1 deletion x/mint/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 7e01488

Please sign in to comment.