fix: --dry-run not working when using tx command - #11558
Conversation
| // 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.
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
alexanderbez
left a comment
There was a problem hiding this comment.
Looks great @julienrbrt! Just one small comment. Love the tests too.
| 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.
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.
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.
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-runnot use the local keyring--generate-onlybehavior 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.mdReviewers 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