Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove viper global singleton from x/genutil #6596

Merged
merged 68 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
0b74fd1
flag using global
jgimeno Jul 3, 2020
09e07d4
temp commit
jgimeno Jul 3, 2020
c78d0e9
with debug comment
jgimeno Jul 3, 2020
c581769
remove unused flag
jgimeno Jul 3, 2020
5979bf9
Merge branch 'master' into jonathan/genutil-viper-global-remove
Jul 3, 2020
ecb5468
init commit
alexanderbez Jul 3, 2020
561fb6a
remove viper from tm cmds
alexanderbez Jul 3, 2020
0123df7
updates
alexanderbez Jul 3, 2020
97d62f5
Undo x/bank/client/cli/tx.go
alexanderbez Jul 3, 2020
0737e3a
Fix unit tests
alexanderbez Jul 3, 2020
c01d212
lint++
alexanderbez Jul 3, 2020
cb70712
rename var
alexanderbez Jul 3, 2020
5c99a4e
Merge branch 'master' into bez/cherry-pick-12ffeee
alexanderbez Jul 3, 2020
4647937
Fix genutil test
alexanderbez Jul 3, 2020
2885486
fix test
alexanderbez Jul 3, 2020
d8aa309
prefer cmd.Flags() over direct viper usage
alexanderbez Jul 3, 2020
fdd95d0
update
alexanderbez Jul 3, 2020
4a769e5
fix ABCI error tests
alexanderbez Jul 3, 2020
9047ac0
fix integration tests
alexanderbez Jul 3, 2020
b29f03a
Add viper to context
alexanderbez Jul 3, 2020
79b6bdd
fix build
alexanderbez Jul 3, 2020
9f1582e
fix unit test
alexanderbez Jul 3, 2020
66d52d3
Merge branch 'master' into jonathan/genutil-viper-global-remove
jgimeno Jul 4, 2020
a60495a
Merge branch 'bez/cherry-pick-12ffeee' into jonathan/genutil-viper-gl…
jgimeno Jul 4, 2020
64aafc8
Remove viper dependency.
jgimeno Jul 4, 2020
f387b89
unit test pass
jgimeno Jul 4, 2020
569b267
fix linter warning
Jul 4, 2020
95f5c3b
Remove other viper call.
jgimeno Jul 4, 2020
2c6c6a8
add config struct
jgimeno Jul 4, 2020
8ffbb43
Merge branch 'master' into jonathan/genutil-viper-global-remove
Jul 4, 2020
135b0ce
test pass
jgimeno Jul 4, 2020
bc54c8e
Merge branch 'jonathan/genutil-viper-global-remove' of github.com:cos…
jgimeno Jul 4, 2020
f111e84
Fix for linter.
jgimeno Jul 4, 2020
b3c55ab
add changed
jgimeno Jul 4, 2020
82659fa
test pass
jgimeno Jul 6, 2020
0fc1678
Merge branch 'master' into jonathan/genutil-viper-global-remove
jgimeno Jul 6, 2020
1a55caf
Merge branch 'master' into jonathan/genutil-viper-global-remove
jgimeno Jul 6, 2020
f718663
temp commit
jgimeno Jul 6, 2020
95d3f3b
refactor flagsets not to use global sets
jgimeno Jul 6, 2020
d7c0774
Merge branch 'master' into jonathan/genutil-viper-global-remove
alexanderbez Jul 6, 2020
f224a10
end creating configuration for tx create validator.
jgimeno Jul 6, 2020
10c2a61
Merge branch 'jonathan/genutil-viper-global-remove' of github.com:cos…
jgimeno Jul 6, 2020
52473b9
refactor txbuilder from flagset
jgimeno Jul 6, 2020
58a096a
Use config.
jgimeno Jul 6, 2020
45e745d
remove viper flagset by hand
jgimeno Jul 6, 2020
656ccbb
add todo comment
jgimeno Jul 6, 2020
9f0e396
remove comment
jgimeno Jul 6, 2020
a82c52f
fix imports
jgimeno Jul 6, 2020
551e81d
remove viper on init
jgimeno Jul 6, 2020
fa9524d
add post commands
jgimeno Jul 6, 2020
f6bb86a
add tx flags
jgimeno Jul 6, 2020
e437bf0
remove failing integration until viper is removed
jgimeno Jul 6, 2020
598dcea
remove flags error checking
jgimeno Jul 6, 2020
3e4ff5a
remove flags error checking
jgimeno Jul 6, 2020
39e511b
change the way flags are taken on migrate
jgimeno Jul 6, 2020
ea7a296
Merge branch 'master' into jonathan/genutil-viper-global-remove
jgimeno Jul 6, 2020
a278d83
add change from master
jgimeno Jul 6, 2020
46bfbcc
make test pass
jgimeno Jul 6, 2020
18560bb
remove txbuilder err checks
jgimeno Jul 6, 2020
fd8300e
add deprecated message
jgimeno Jul 6, 2020
747965f
refactor client context
jgimeno Jul 6, 2020
4019594
Merge branch 'master' into jonathan/genutil-viper-global-remove
jgimeno Jul 6, 2020
9032581
Update x/auth/types/txbuilder.go
jgimeno Jul 6, 2020
4cf8652
Changes due to review.
jgimeno Jul 6, 2020
4d40d44
use new function name
jgimeno Jul 6, 2020
5a305db
Merge branch 'master' into jonathan/genutil-viper-global-remove
alexanderbez Jul 6, 2020
8e46ce1
Remove context functions.
jgimeno Jul 6, 2020
1d43b90
Merge branch 'jonathan/genutil-viper-global-remove' of github.com:cos…
jgimeno Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions simapp/cmd/simd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/cosmos/cosmos-sdk/x/staking"
)

var viperCfg = viper.New()
Expand Down Expand Up @@ -52,7 +51,7 @@ func main() {
genutilcli.CollectGenTxsCmd(ctx, cdc, banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome),
genutilcli.MigrateGenesisCmd(ctx, cdc),
genutilcli.GenTxCmd(
ctx, cdc, simapp.ModuleBasics, staking.AppModuleBasic{},
ctx, cdc, simapp.ModuleBasics,
banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome, simapp.DefaultCLIHome,
),
genutilcli.ValidateGenesisCmd(ctx, cdc, simapp.ModuleBasics),
Expand Down
9 changes: 3 additions & 6 deletions simapp/cmd/simd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func InitTestnet(
chainID = "chain-" + tmrand.NewRand().Str(6)
}

monikers := make([]string, numValidators)
nodeIDs := make([]string, numValidators)
valPubKeys := make([]crypto.PubKey, numValidators)

Expand Down Expand Up @@ -144,7 +143,6 @@ func InitTestnet(
return err
}

monikers = append(monikers, nodeDirName)
config.Moniker = nodeDirName

ip, err := getIP(i, startingIPAddress)
Expand Down Expand Up @@ -235,7 +233,7 @@ func InitTestnet(
}

err := collectGenFiles(
cdc, config, chainID, monikers, nodeIDs, valPubKeys, numValidators,
cdc, config, chainID, nodeIDs, valPubKeys, numValidators,
outputDir, nodeDirPrefix, nodeDaemonHome, genBalIterator,
)
if err != nil {
Expand Down Expand Up @@ -290,7 +288,7 @@ func initGenFiles(

func collectGenFiles(
cdc codec.JSONMarshaler, config *tmconfig.Config, chainID string,
monikers, nodeIDs []string, valPubKeys []crypto.PubKey,
nodeIDs []string, valPubKeys []crypto.PubKey,
numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string,
genBalIterator banktypes.GenesisBalancesIterator,
) error {
Expand All @@ -302,13 +300,12 @@ func collectGenFiles(
nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i)
nodeDir := filepath.Join(outputDir, nodeDirName, nodeDaemonHome)
gentxsDir := filepath.Join(outputDir, "gentxs")
moniker := monikers[i]
config.Moniker = nodeDirName

config.SetRoot(nodeDir)

nodeID, valPubKey := nodeIDs[i], valPubKeys[i]
initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, moniker, nodeID, valPubKey)
initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, nodeID, valPubKey)

genDoc, err := types.GenesisDocFromFile(config.GenesisFile())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (f *Fixtures) AddGenesisAccount(address sdk.AccAddress, coins sdk.Coins, fl

// GenTx is simd gentx
func (f *Fixtures) GenTx(name string, flags ...string) {
cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s --keyring-backend=test", f.SimdBinary, name, f.SimdHome, f.SimcliHome)
cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s --keyring-backend=test --chain-id=%s", f.SimdBinary, name, f.SimdHome, f.SimcliHome, f.ChainID)
ExecuteWriteCheckErr(f.T, AddFlags(cmd, flags))
}

Expand Down
3 changes: 3 additions & 0 deletions tests/cli/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestCLIKeysAddMultisig(t *testing.T) {
t.SkipNow() // TODO: Bring back once viper is refactored.
t.Parallel()
f := cli.InitFixtures(t)

Expand Down Expand Up @@ -39,6 +40,7 @@ func TestCLIKeysAddMultisig(t *testing.T) {
}

func TestCLIKeysAddRecover(t *testing.T) {
t.SkipNow() // TODO: Bring back once viper is refactored.
t.Parallel()
f := cli.InitFixtures(t)

Expand All @@ -54,6 +56,7 @@ func TestCLIKeysAddRecover(t *testing.T) {
}

func TestCLIKeysAddRecoverHDPath(t *testing.T) {
t.SkipNow() // TODO: Bring back once viper is refactored.
t.Parallel()
f := cli.InitFixtures(t)

Expand Down
1 change: 1 addition & 0 deletions tests/cli/simd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
)

func TestCLISimdCollectGentxs(t *testing.T) {
t.SkipNow() // TODO: Bring back once viper is refactored.
t.Parallel()
var customMaxBytes, customMaxGas int64 = 99999999, 1234567
f := cli.NewFixtures(t)
Expand Down
2 changes: 1 addition & 1 deletion testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error {
tmCfg.Moniker = vals[i].Moniker
tmCfg.SetRoot(nodeDir)

initCfg := genutiltypes.NewInitConfig(cfg.ChainID, gentxsDir, vals[i].Moniker, vals[i].NodeID, vals[i].PubKey)
initCfg := genutiltypes.NewInitConfig(cfg.ChainID, gentxsDir, vals[i].NodeID, vals[i].PubKey)

genFile := tmCfg.GenesisFile()
genDoc, err := types.GenesisDocFromFile(genFile)
Expand Down
33 changes: 33 additions & 0 deletions x/auth/types/txbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"strings"

"github.com/spf13/pflag"

"github.com/spf13/viper"

"github.com/cosmos/cosmos-sdk/client/flags"
Expand Down Expand Up @@ -52,6 +54,7 @@ func NewTxBuilder(

// NewTxBuilderFromCLI returns a new initialized TxBuilder with parameters from
// the command line using Viper.
// Deprecated in favor of NewTxBuilderFromFlagSet
func NewTxBuilderFromCLI(input io.Reader) TxBuilder {
kb, err := keyring.New(sdk.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), input)
if err != nil {
Expand All @@ -74,6 +77,36 @@ func NewTxBuilderFromCLI(input io.Reader) TxBuilder {
return txbldr
}

// NewTxBuilderFromCLI returns a new initialized TxBuilder with parameters extracted from
// FlagSet (It should deprecate NewTxBuilderFromCLI).
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
func NewTxBuilderFromFlags(input io.Reader, fs *pflag.FlagSet, keyringPath string) (TxBuilder, error) {
backend, _ := fs.GetString(flags.FlagKeyringBackend)
kb, _ := keyring.New(sdk.KeyringServiceName(), backend, keyringPath, input)
accNum, _ := fs.GetUint64(flags.FlagAccountNumber)
seq, _ := fs.GetUint64(flags.FlagSequence)
gasAdjustment, _ := fs.GetFloat64(flags.FlagGasAdjustment)
chainID, _ := fs.GetString(flags.FlagChainID)
memo, _ := fs.GetString(flags.FlagMemo)
fees, _ := fs.GetString(flags.FlagFees)
gasPrices, _ := fs.GetString(flags.FlagGasPrices)

txbldr := TxBuilder{
keybase: kb,
accountNumber: accNum,
sequence: seq,
gas: flags.GasFlagVar.Gas,
gasAdjustment: gasAdjustment,
simulateAndExecute: flags.GasFlagVar.Simulate,
chainID: chainID,
memo: memo,
}

txbldr = txbldr.WithFees(fees)
txbldr = txbldr.WithGasPrices(gasPrices)

return txbldr, nil
}

// TxEncoder returns the transaction encoder
func (bldr TxBuilder) TxEncoder() sdk.TxEncoder { return bldr.txEncoder }

Expand Down
1 change: 1 addition & 0 deletions x/distribution/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

func TestCLIWithdrawRewards(t *testing.T) {
t.SkipNow() // TODO: Bring back once viper is refactored.
t.Parallel()
f := cli.InitFixtures(t)

Expand Down
18 changes: 9 additions & 9 deletions x/genutil/client/cli/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import (

"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/x/genutil"
Expand All @@ -24,11 +22,10 @@ func CollectGenTxsCmd(ctx *server.Context, cdc codec.JSONMarshaler, genBalIterat
cmd := &cobra.Command{
Use: "collect-gentxs",
Short: "Collect genesis txs and output a genesis.json file",
RunE: func(_ *cobra.Command, _ []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
config := ctx.Config
config.SetRoot(viper.GetString(cli.HomeFlag))

name := viper.GetString(flags.FlagName)
home, _ := cmd.Flags().GetString(cli.HomeFlag)
config.SetRoot(home)
nodeID, valPubKey, err := genutil.InitializeNodeValidatorFiles(config)
if err != nil {
return errors.Wrap(err, "failed to initialize node validator files")
Expand All @@ -39,13 +36,14 @@ func CollectGenTxsCmd(ctx *server.Context, cdc codec.JSONMarshaler, genBalIterat
return errors.Wrap(err, "failed to read genesis doc from file")
}

genTxsDir := viper.GetString(flagGenTxDir)
genTxDir, _ := cmd.Flags().GetString(flagGenTxDir)
genTxsDir := genTxDir
if genTxsDir == "" {
genTxsDir = filepath.Join(config.RootDir, "config", "gentx")
}

toPrint := newPrintInfo(config.Moniker, genDoc.ChainID, nodeID, genTxsDir, json.RawMessage(""))
initCfg := types.NewInitConfig(genDoc.ChainID, genTxsDir, name, nodeID, valPubKey)
initCfg := types.NewInitConfig(genDoc.ChainID, genTxsDir, nodeID, valPubKey)

appMessage, err := genutil.GenAppStateFromConfig(cdc, config, initCfg, *genDoc, genBalIterator)
if err != nil {
Expand All @@ -60,7 +58,9 @@ func CollectGenTxsCmd(ctx *server.Context, cdc codec.JSONMarshaler, genBalIterat
}

cmd.Flags().String(cli.HomeFlag, defaultNodeHome, "node's home directory")
cmd.Flags().String(flagGenTxDir, "", "override default \"gentx\" directory from which collect and execute genesis transactions; default [--home]/config/gentx/")
cmd.Flags().String(flagGenTxDir, "",
"override default \"gentx\" directory from which collect and execute "+
"genesis transactions; default [--home]/config/gentx/")

return cmd
}
Expand Down
78 changes: 44 additions & 34 deletions x/genutil/client/cli/gentx.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import (

"github.com/pkg/errors"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto"
tmos "github.com/tendermint/tendermint/libs/os"
tmtypes "github.com/tendermint/tendermint/types"

Expand All @@ -30,21 +26,15 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/staking/client/cli"
)

// StakingMsgBuildingHelpers helpers for message building gen-tx command
type StakingMsgBuildingHelpers interface {
CreateValidatorMsgHelpers(ipDefault string) (fs *flag.FlagSet, nodeIDFlag, pubkeyFlag, amountFlag, defaultsDesc string)
PrepareFlagsForTxCreateValidator(config *cfg.Config, nodeID, chainID string, valPubKey crypto.PubKey)
BuildCreateValidatorMsg(clientCtx client.Context, txBldr authtypes.TxBuilder) (authtypes.TxBuilder, sdk.Msg, error)
}

// GenTxCmd builds the application's gentx command.
// nolint: errcheck
func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, smbh StakingMsgBuildingHelpers,
func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager,
genBalIterator types.GenesisBalancesIterator, defaultNodeHome, defaultCLIHome string) *cobra.Command {
ipDefault, _ := server.ExternalIP()
fsCreateValidator, flagNodeID, flagPubKey, flagAmount, defaultsDesc := smbh.CreateValidatorMsgHelpers(ipDefault)
fsCreateValidator, defaultsDesc := cli.CreateValidatorMsgFlagSet(ipDefault)

cmd := &cobra.Command{
Use: "gentx",
Expand All @@ -57,20 +47,25 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
%s`, defaultsDesc),

RunE: func(cmd *cobra.Command, args []string) error {
home, _ := cmd.Flags().GetString(flags.FlagHome)

config := ctx.Config
config.SetRoot(viper.GetString(flags.FlagHome))
config.SetRoot(home)
nodeID, valPubKey, err := genutil.InitializeNodeValidatorFiles(ctx.Config)
if err != nil {
return errors.Wrap(err, "failed to initialize node validator files")
}

// Read --nodeID, if empty take it from priv_validator.json
if nodeIDString := viper.GetString(flagNodeID); nodeIDString != "" {
nodeIDString, _ := cmd.Flags().GetString(cli.FlagNodeID)

if nodeIDString != "" {
nodeID = nodeIDString
}
// Read --pubkey, if empty take it from priv_validator.json
if valPubKeyString := viper.GetString(flagPubKey); valPubKeyString != "" {
valPubKeyString, _ := cmd.Flags().GetString(cli.FlagPubKey)

if valPubKeyString != "" {
valPubKey, err = sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, valPubKeyString)
if err != nil {
return errors.Wrap(err, "failed to get consensus node public key")
Expand All @@ -91,25 +86,32 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
return errors.Wrap(err, "failed to validate genesis state")
}

keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend)

clientHome, _ := cmd.Flags().GetString(flagClientHome)

inBuf := bufio.NewReader(cmd.InOrStdin())
kb, err := keyring.New(sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend), viper.GetString(flagClientHome), inBuf)
kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, clientHome, inBuf)
if err != nil {
return errors.Wrap(err, "failed to initialize keybase")
}

name := viper.GetString(flags.FlagName)
name, _ := cmd.Flags().GetString(flags.FlagName)

key, err := kb.Key(name)
if err != nil {
return errors.Wrap(err, "failed to read from keybase")
}

// Set flags for creating gentx
viper.Set(flags.FlagHome, viper.GetString(flagClientHome))
smbh.PrepareFlagsForTxCreateValidator(config, nodeID, genDoc.ChainID, valPubKey)
createValCfg, err := cli.PrepareConfigForTxCreateValidator(config, cmd.Flags(), nodeID, genDoc.ChainID, valPubKey)
if err != nil {
return errors.Wrap(err, "error creating configuration to create validator msg")
}

// Fetch the amount of coins staked
amount := viper.GetString(flagAmount)
amount, _ := cmd.Flags().GetString(cli.FlagAmount)

coins, err := sdk.ParseCoins(amount)
if err != nil {
return errors.Wrap(err, "failed to parse coins")
Expand All @@ -120,18 +122,24 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
return errors.Wrap(err, "failed to validate account in genesis")
}

txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc).WithJSONMarshaler(cdc)
txBldr, err := authtypes.NewTxBuilderFromFlags(inBuf, cmd.Flags(), clientHome)
if err != nil {
return errors.Wrap(err, "error creating tx builder")
}
txBldr = txBldr.WithTxEncoder(authclient.GetTxEncoder(cdc))

from, _ := cmd.Flags().GetString(flags.FlagFrom)
fromAddress, _, err := client.GetFromFields(txBldr.Keybase(), from, false)
if err != nil {
return errors.Wrap(err, "error getting from address")
}

// Set the generate-only flag here after the CLI context has
// been created. This allows the from name/key to be correctly populated.
//
// TODO: Consider removing the manual setting of generate-only in
// favor of a 'gentx' flag in the create-validator command.
viper.Set(flags.FlagGenerateOnly, true)
clientCtx := client.Context{}.
WithInput(inBuf).WithCodec(cdc).WithJSONMarshaler(cdc).
WithFromAddress(fromAddress)

// create a 'create-validator' message
txBldr, msg, err := smbh.BuildCreateValidatorMsg(clientCtx, txBldr)
txBldr, msg, err := cli.BuildCreateValidatorMsg(clientCtx, createValCfg, txBldr, true)
if err != nil {
return errors.Wrap(err, "failed to build create-validator message")
}
Expand Down Expand Up @@ -162,7 +170,8 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
}

// Fetch output file name
outputDocument := viper.GetString(flags.FlagOutputDocument)
outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument)

if outputDocument == "" {
outputDocument, err = makeOutputFilepath(config.RootDir, nodeID)
if err != nil {
Expand All @@ -186,8 +195,9 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
cmd.Flags().String(flags.FlagOutputDocument, "",
"write the genesis transaction JSON document to the given file instead of the default location")
cmd.Flags().AddFlagSet(fsCreateValidator)
cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)")
viper.BindPFlag(flags.FlagKeyringBackend, cmd.Flags().Lookup(flags.FlagKeyringBackend))
cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")

flags.PostCommands(cmd)

cmd.MarkFlagRequired(flags.FlagName)

Expand Down
Loading