diff --git a/CHANGELOG.md b/CHANGELOG.md index 58d73ee798..7d30f99fb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -173,6 +173,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (types) [\#11004](https://github.com/cosmos/cosmos-sdk/pull/11004) Added mutable versions of many of the sdk.Dec types operations. This improves performance when used by avoiding reallocating a new bigint for each operation. * (x/auth) [\#10880](https://github.com/cosmos/cosmos-sdk/pull/10880) Added a new query to the tx query service that returns a block with transactions fully decoded. * (types) [\#11200](https://github.com/cosmos/cosmos-sdk/pull/11200) Added `Min()` and `Max()` operations on sdk.Coins. +* (gov) [\#11287](https://github.com/cosmos/cosmos-sdk/pull/11287) Fix error message when no flags are provided while executing `submit-legacy-proposal` transaction. ### Bug Fixes diff --git a/x/gov/client/cli/parse.go b/x/gov/client/cli/parse.go index 306b4b10dd..91736f9853 100644 --- a/x/gov/client/cli/parse.go +++ b/x/gov/client/cli/parse.go @@ -19,17 +19,41 @@ type legacyProposal struct { Deposit string } +func (p legacyProposal) validate() error { + if p.Type == "" { + return fmt.Errorf("proposal type is required") + } + + if p.Title == "" { + return fmt.Errorf("proposal title is required") + } + + if p.Description == "" { + return fmt.Errorf("proposal description is required") + } + return nil +} + func parseSubmitLegacyProposalFlags(fs *pflag.FlagSet) (*legacyProposal, error) { proposal := &legacyProposal{} proposalFile, _ := fs.GetString(FlagProposal) if proposalFile == "" { proposalType, _ := fs.GetString(FlagProposalType) + title, _ := fs.GetString(FlagTitle) + description, _ := fs.GetString(FlagDescription) + if proposalType == "" && title == "" && description == "" { + return nil, fmt.Errorf("one of the --proposal or (--title, --description and --type) flags are required") + } proposal.Title, _ = fs.GetString(FlagTitle) proposal.Description, _ = fs.GetString(FlagDescription) proposal.Type = govutils.NormalizeProposalType(proposalType) proposal.Deposit, _ = fs.GetString(FlagDeposit) + if err := proposal.validate(); err != nil { + return nil, err + } + return proposal, nil } @@ -49,6 +73,10 @@ func parseSubmitLegacyProposalFlags(fs *pflag.FlagSet) (*legacyProposal, error) return nil, err } + if err := proposal.validate(); err != nil { + return nil, err + } + return proposal, nil } diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index 17c3db75e4..d23d717fd9 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -27,10 +27,10 @@ const ( // Deprecated: only used for v1beta1 legacy proposals. FlagProposalType = "type" // Deprecated: only used for v1beta1 legacy proposals. - FlagDeposit = "deposit" - flagVoter = "voter" - flagDepositor = "depositor" - flagStatus = "status" + FlagDeposit = "deposit" + flagVoter = "voter" + flagDepositor = "depositor" + flagStatus = "status" // Deprecated: only used for v1beta1 legacy proposals. FlagProposal = "proposal" )