Skip to content

Commit

Permalink
fix(cmd/cel-key): Ensure keyring-backend is actually test by default (
Browse files Browse the repository at this point in the history
celestiaorg#1879)

`KeysCommand` from the sdk is quite wonky in that it really only sets a
keyring backend if the flag was `changed`, so this hack ensures we can
properly set a default and that the default is `test`.

Resolves celestiaorg#1876
  • Loading branch information
renaynay authored Mar 9, 2023
1 parent 572efab commit 1c71505
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/cel-key/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -46,6 +47,14 @@ func init() {
return err
}

if !cmd.Flag(flags.FlagKeyringBackend).Changed {
err = cmd.Flag(flags.FlagKeyringBackend).Value.Set(keyring.BackendTest)
if err != nil {
return err
}
cmd.Flag(flags.FlagKeyringBackend).Changed = true
}

return ParseDirectoryFlags(cmd)
}
}
Expand Down

0 comments on commit 1c71505

Please sign in to comment.