change gentx cmd amount field to arg from flag (#8183)

* Read gentx amount as argument

* Update gentx command usage

* Update gentx tests

* Update docs of gentx

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
This commit is contained in:
Prathyusha Lakkireddy
2020-12-17 17:27:30 +01:00
committed by GitHub
co-authored by Alessio Treglia
parent 96f89df56b
commit be573cb0ce
4 changed files with 7 additions and 7 deletions
+4 -5
View File
@@ -35,9 +35,9 @@ func GenTxCmd(mbm module.BasicManager, txEncCfg client.TxEncodingConfig, genBalI
fsCreateValidator, defaultsDesc := cli.CreateValidatorMsgFlagSet(ipDefault)
cmd := &cobra.Command{
Use: "gentx [key_name]",
Use: "gentx [key_name] [amount]",
Short: "Generate a genesis tx carrying a self delegation",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(2),
Long: fmt.Sprintf(`Generate a genesis transaction that creates a validator with a self-delegation,
that is signed by the key in the Keyring referenced by a given name. A node ID and Bech32 consensus
pubkey may optionally be provided. If they are omitted, they will be retrieved from the priv_validator.json
@@ -45,8 +45,7 @@ file. The following default parameters are included:
%s
Example:
$ %s gentx my-key-name --home=/path/to/home/dir --keyring-backend=os --chain-id=test-chain-1 \
--amount=1000000stake \
$ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=os --chain-id=test-chain-1 \
--moniker="myvalidator" \
--commission-max-change-rate=0.01 \
--commission-max-rate=1.0 \
@@ -118,7 +117,7 @@ $ %s gentx my-key-name --home=/path/to/home/dir --keyring-backend=os --chain-id=
return errors.Wrap(err, "error creating configuration to create validator msg")
}
amount, _ := cmd.Flags().GetString(cli.FlagAmount)
amount := args[1]
coins, err := sdk.ParseCoinsNormalized(amount)
if err != nil {
return errors.Wrap(err, "failed to parse coins")
+1
View File
@@ -65,6 +65,7 @@ func (s *IntegrationTestSuite) TestGenTxCmd() {
fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID),
fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, genTxFile),
val.Moniker,
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(),
})
err := cmd.ExecuteContext(ctx)