-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix: added key when dry-run is true #9480
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
37c3ce4
fix: added key when dry-run is true
ryanchristo 7de01ec
apply review suggestions
ryanchristo f6f9949
udpate changelog
ryanchristo 59e7e18
Merge branch 'master' into ryan/9475-add-key-dry-run
ryanchristo 1deac80
Merge branch 'master' into ryan/9475-add-key-dry-run
amaury1093 ed64981
Merge branch 'master' into ryan/9475-add-key-dry-run
amaury1093 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ func runAddCmdPrepare(cmd *cobra.Command, args []string) error { | |
return err | ||
} | ||
|
||
return RunAddCmd(clientCtx, cmd, args, buf) | ||
return runAddCmd(clientCtx, cmd, args, buf) | ||
} | ||
|
||
/* | ||
|
@@ -100,10 +100,12 @@ input | |
output | ||
- armor encrypted private key (saved to file) | ||
*/ | ||
func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *bufio.Reader) error { | ||
func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *bufio.Reader) error { | ||
var err error | ||
|
||
name := args[0] | ||
dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun) | ||
multisigKeys, _ := cmd.Flags().GetStringSlice(flagMultisig) | ||
interactive, _ := cmd.Flags().GetBool(flagInteractive) | ||
noBackup, _ := cmd.Flags().GetBool(flagNoBackup) | ||
showMnemonic := !noBackup | ||
|
@@ -117,7 +119,10 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf | |
return err | ||
} | ||
|
||
if dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun); !dryRun { | ||
if dryRun { | ||
// use in memory keybase | ||
kb = keyring.NewInMemory() | ||
} else { | ||
_, err = kb.Key(name) | ||
if err == nil { | ||
// account exists, ask for user confirmation | ||
|
@@ -136,7 +141,6 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf | |
} | ||
} | ||
|
||
multisigKeys, _ := cmd.Flags().GetStringSlice(flagMultisig) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why moving it out of the |
||
if len(multisigKeys) != 0 { | ||
var pks []cryptotypes.PubKey | ||
amaury1093 marked this conversation as resolved.
Show resolved
Hide resolved
amaury1093 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
multisigThreshold, _ := cmd.Flags().GetInt(flagMultiSigThreshold) | ||
|
@@ -160,12 +164,12 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf | |
} | ||
|
||
pk := multisig.NewLegacyAminoPubKey(multisigThreshold, pks) | ||
if _, err := kb.SaveMultisig(name, pk); err != nil { | ||
info, err := kb.SaveMultisig(name, pk) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cmd.PrintErrf("Key %q saved to disk.\n", name) | ||
return nil | ||
return printCreate(cmd, info, false, "", outputFormat) | ||
} | ||
} | ||
|
||
|
@@ -176,8 +180,13 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf | |
if err != nil { | ||
return err | ||
} | ||
_, err := kb.SavePubKey(name, pk, algo.Name()) | ||
return err | ||
|
||
info, err := kb.SavePubKey(name, pk, algo.Name()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return printCreate(cmd, info, false, "", outputFormat) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Print info for pubkey as we do for other keys. |
||
} | ||
|
||
coinType, _ := cmd.Flags().GetUint32(flagCoinType) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not not sure why this was public before.