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

[R4R] Require moniker on gaiad init #2773

Merged
merged 7 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ IMPROVEMENTS
* [\#2749](https://github.com/cosmos/cosmos-sdk/pull/2749) Add --chain-id flag to gaiad testnet

* Gaia
* Require moniker to be provided on `gaiad init`.

* SDK
- [x/mock/simulation] [\#2720] major cleanup, introduction of helper objects, reorganization
Expand Down
12 changes: 10 additions & 2 deletions cmd/gaia/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,32 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cob
RunE: func(_ *cobra.Command, _ []string) error {
config := ctx.Config
config.SetRoot(viper.GetString(cli.HomeFlag))

chainID := viper.GetString(client.FlagChainID)
if chainID == "" {
chainID = fmt.Sprintf("test-chain-%v", common.RandStr(6))
}

nodeID, _, err := InitializeNodeValidatorFiles(config)
if err != nil {
return err
}

if viper.GetString(flagMoniker) != "" {
config.Moniker = viper.GetString(flagMoniker)
moniker := viper.GetString(flagMoniker)
if moniker == "" {
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("required flag \"%s\" has not been set", flagMoniker)
}

config.Moniker = moniker

var appState json.RawMessage
genFile := config.GenesisFile()

if appState, err = initializeEmptyGenesis(cdc, genFile, chainID,
viper.GetBool(flagOverwrite)); err != nil {
return err
}

if err = ExportGenesisFile(genFile, chainID, nil, appState); err != nil {
return err
}
Expand All @@ -91,5 +98,6 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cob
cmd.Flags().BoolP(flagOverwrite, "o", false, "overwrite the genesis.json file")
cmd.Flags().String(client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
cmd.Flags().String(flagMoniker, "", "set the validator's moniker")

return cmd
}