Merge PR #4665: Refactor x/gov Module Structure (prep for module spec)
This commit is contained in:
committed by
Alexander Bezobchuk
parent
83db58ec5e
commit
e4c8bd72b7
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
@@ -75,7 +75,7 @@ Where proposal.json contains:
|
||||
from := cliCtx.GetFromAddress()
|
||||
content := types.NewParameterChangeProposal(proposal.Title, proposal.Description, proposal.Changes.ToParamChanges())
|
||||
|
||||
msg := gov.NewMsgSubmitProposal(content, proposal.Deposit, from)
|
||||
msg := govtypes.NewMsgSubmitProposal(content, proposal.Deposit, from)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
|
||||
@@ -36,7 +36,7 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
|
||||
content := params.NewParameterChangeProposal(req.Title, req.Description, req.Changes.ToParamChanges())
|
||||
|
||||
msg := gov.NewMsgSubmitProposal(content, req.Deposit, req.Proposer)
|
||||
msg := govtypes.NewMsgSubmitProposal(content, req.Deposit, req.Proposer)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
)
|
||||
|
||||
// NewParamChangeProposalHandler creates a new governance Handler for a ParamChangeProposal
|
||||
func NewParamChangeProposalHandler(k Keeper) govtypes.Handler {
|
||||
return func(ctx sdk.Context, content govtypes.Content) sdk.Error {
|
||||
switch c := content.(type) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
)
|
||||
@@ -158,7 +158,7 @@ var paramChangePool = []simParamChange{
|
||||
// SimulateParamChangeProposalContent returns random parameter change content.
|
||||
// It will generate a ParameterChangeProposal object with anywhere between 1 and
|
||||
// 3 parameter changes all of which have random, but valid values.
|
||||
func SimulateParamChangeProposalContent(r *rand.Rand, _ *baseapp.BaseApp, _ sdk.Context, _ []simulation.Account) gov.Content {
|
||||
func SimulateParamChangeProposalContent(r *rand.Rand, _ *baseapp.BaseApp, _ sdk.Context, _ []simulation.Account) govtypes.Content {
|
||||
numChanges := simulation.RandIntBetween(r, 1, len(paramChangePool)/2)
|
||||
paramChanges := make([]params.ParamChange, numChanges, numChanges)
|
||||
paramChangesKeys := make(map[string]struct{})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
// ModuleKey defines the name of the module
|
||||
// ModuleName defines the name of the module
|
||||
ModuleName = "params"
|
||||
|
||||
// RouterKey defines the routing key for a ParameterChangeProposal
|
||||
|
||||
@@ -39,7 +39,7 @@ func (pcp ParameterChangeProposal) GetTitle() string { return pcp.Title }
|
||||
// GetDescription returns the description of a parameter change proposal.
|
||||
func (pcp ParameterChangeProposal) GetDescription() string { return pcp.Description }
|
||||
|
||||
// GetDescription returns the routing key of a parameter change proposal.
|
||||
// ProposalRoute returns the routing key of a parameter change proposal.
|
||||
func (pcp ParameterChangeProposal) ProposalRoute() string { return RouterKey }
|
||||
|
||||
// ProposalType returns the type of a parameter change proposal.
|
||||
@@ -103,7 +103,7 @@ func (pc ParamChange) String() string {
|
||||
`, pc.Subspace, pc.Key, pc.Subkey, pc.Value)
|
||||
}
|
||||
|
||||
// ValidateChange performs basic validation checks over a set of ParamChange. It
|
||||
// ValidateChanges performs basic validation checks over a set of ParamChange. It
|
||||
// returns an error if any ParamChange is invalid.
|
||||
func ValidateChanges(changes []ParamChange) sdk.Error {
|
||||
if len(changes) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user