-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
@@ -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 { |
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.
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
:
--dry-run
not working when using tx command --dry-run
not working when using tx command
--dry-run
not working when using tx command --dry-run
not working when using tx command
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.
lgtm
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.
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) |
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.
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
.
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.
Correct, however the keyring used is not always took from the context ⇾ https://github.com/cosmos/cosmos-sdk/pull/11558/files#diff-eb0834c140c5c40cca7f39ab9d334536d3529642fce425754b8608c5e79b6430R110
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.
True. You can always call clientCtx.WithKeyring
prior to calling it, but that's a good point. I'm indifferent here.
Description
Closes: #11149
--dry-run
not use the local keyring--generate-only
behavior consistentAuthor 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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
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...
!
in the type prefix if API or client breaking change