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

fix: --dry-run not working when using tx command #11558

Merged
merged 8 commits into from
Apr 11, 2022

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Apr 6, 2022

Description

Closes: #11149

  • Let --dry-run not use the local keyring
  • Fixes for required flags not shown
  • Make --generate-only behavior consistent

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

client/context.go Outdated Show resolved Hide resolved
@@ -365,7 +374,7 @@ func GetFromFields(kr keyring.Keyring, from string, genOnly bool) (sdk.AccAddres

// NewKeyringFromBackend gets a Keyring object from a backend
func NewKeyringFromBackend(ctx Context, backend string) (keyring.Keyring, error) {
if ctx.GenerateOnly || ctx.Simulate {
if ctx.Simulate {
Copy link
Member Author

@julienrbrt julienrbrt Apr 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed because --generate-only should be able to read the key ring (for this feature #9838) so it should not be overwritten.
Moreover this was actually never true as NewKeyringFromBackend was called before that the generate flag was read by readTxCommandFlags:

@julienrbrt julienrbrt marked this pull request as ready for review April 7, 2022 10:42
@julienrbrt julienrbrt requested a review from aaronc as a code owner April 7, 2022 10:42
@julienrbrt julienrbrt changed the title cli: fix --dry-run not working when using tx command fix: fix --dry-run not working when using tx command Apr 8, 2022
@julienrbrt julienrbrt changed the title fix: fix --dry-run not working when using tx command fix: --dry-run not working when using tx command Apr 8, 2022
Copy link
Collaborator

@anilcse anilcse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @julienrbrt! Just one small comment. Love the tests too.

@@ -248,7 +248,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err

if clientCtx.From == "" || flagSet.Changed(flags.FlagFrom) {
from, _ := flagSet.GetString(flags.FlagFrom)
fromAddr, fromName, keyType, err := GetFromFields(clientCtx.Keyring, from, clientCtx.GenerateOnly)
fromAddr, fromName, keyType, err := GetFromFields(clientCtx, clientCtx.Keyring, from)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I dont think there's a need to pass both clientCtx and clientCtx.Keyring, we might as well just pass clientCtx and get the keyring from that in GetFromFields.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. You can always call clientCtx.WithKeyring prior to calling it, but that's a good point. I'm indifferent here.

client/context.go Outdated Show resolved Hide resolved
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@julienrbrt julienrbrt added the A:automerge Automatically merge PR once all prerequisites pass. label Apr 11, 2022
@mergify mergify bot merged commit 4f1cc3a into master Apr 11, 2022
@mergify mergify bot deleted the 11149-dry-run-not-worked-when-use-tx-command branch April 11, 2022 15:50
@amaury1093 amaury1093 mentioned this pull request May 23, 2022
72 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:CLI C:x/auth C:x/bank C:x/feegrant
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--dry-run not worked when use tx command
5 participants