fix(cli): submit-legacy-proposal: return propoer error if no flag is provided (#11287)
## Description Closes: #10624 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
This commit is contained in:
parent
86927825ff
commit
3633081463
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user