cosmos-sdk/x/staking/client/cli/flags.go
MD Aleem d794b97901
fix: edit validator bug from the cli (#10684)
<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

Closes: #10660 

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

---

### 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)
2021-12-08 11:08:29 +00:00

114 lines
4.1 KiB
Go

package cli
import (
flag "github.com/spf13/pflag"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
const (
FlagAddressValidator = "validator"
FlagAddressValidatorSrc = "addr-validator-source"
FlagAddressValidatorDst = "addr-validator-dest"
FlagPubKey = "pubkey"
FlagAmount = "amount"
FlagSharesAmount = "shares-amount"
FlagSharesFraction = "shares-fraction"
FlagMoniker = "moniker"
FlagEditMoniker = "new-moniker"
FlagIdentity = "identity"
FlagWebsite = "website"
FlagSecurityContact = "security-contact"
FlagDetails = "details"
FlagCommissionRate = "commission-rate"
FlagCommissionMaxRate = "commission-max-rate"
FlagCommissionMaxChangeRate = "commission-max-change-rate"
FlagMinSelfDelegation = "min-self-delegation"
FlagGenesisFormat = "genesis-format"
FlagNodeID = "node-id"
FlagIP = "ip"
)
// common flagsets to add to various functions
var (
fsShares = flag.NewFlagSet("", flag.ContinueOnError)
fsValidator = flag.NewFlagSet("", flag.ContinueOnError)
fsRedelegation = flag.NewFlagSet("", flag.ContinueOnError)
)
func init() {
fsShares.String(FlagSharesAmount, "", "Amount of source-shares to either unbond or redelegate as a positive integer or decimal")
fsShares.String(FlagSharesFraction, "", "Fraction of source-shares to either unbond or redelegate as a positive integer or decimal >0 and <=1")
fsValidator.String(FlagAddressValidator, "", "The Bech32 address of the validator")
fsRedelegation.String(FlagAddressValidatorSrc, "", "The Bech32 address of the source validator")
fsRedelegation.String(FlagAddressValidatorDst, "", "The Bech32 address of the destination validator")
}
// FlagSetCommissionCreate Returns the FlagSet used for commission create.
func FlagSetCommissionCreate() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagCommissionRate, "", "The initial commission rate percentage")
fs.String(FlagCommissionMaxRate, "", "The maximum commission rate percentage")
fs.String(FlagCommissionMaxChangeRate, "", "The maximum commission change rate percentage (per day)")
return fs
}
// FlagSetMinSelfDelegation Returns the FlagSet used for minimum set delegation.
func FlagSetMinSelfDelegation() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagMinSelfDelegation, "", "The minimum self delegation required on the validator")
return fs
}
// FlagSetAmount Returns the FlagSet for amount related operations.
func FlagSetAmount() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagAmount, "", "Amount of coins to bond")
return fs
}
// FlagSetPublicKey Returns the flagset for Public Key related operations.
func FlagSetPublicKey() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagPubKey, "", "The validator's Protobuf JSON encoded public key")
return fs
}
func flagSetDescriptionEdit() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagEditMoniker, types.DoNotModifyDesc, "The validator's name")
fs.String(FlagIdentity, types.DoNotModifyDesc, "The (optional) identity signature (ex. UPort or Keybase)")
fs.String(FlagWebsite, types.DoNotModifyDesc, "The validator's (optional) website")
fs.String(FlagSecurityContact, types.DoNotModifyDesc, "The validator's (optional) security contact email")
fs.String(FlagDetails, types.DoNotModifyDesc, "The validator's (optional) details")
return fs
}
func flagSetCommissionUpdate() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagCommissionRate, "", "The new commission rate percentage")
return fs
}
func flagSetDescriptionCreate() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagMoniker, "", "The validator's name")
fs.String(FlagIdentity, "", "The optional identity signature (ex. UPort or Keybase)")
fs.String(FlagWebsite, "", "The validator's (optional) website")
fs.String(FlagSecurityContact, "", "The validator's (optional) security contact email")
fs.String(FlagDetails, "", "The validator's (optional) details")
return fs
}