From 0a7ad0181b16d7048bc1b14e116de7d295304dbe Mon Sep 17 00:00:00 2001 From: Cory Date: Thu, 3 Mar 2022 09:19:54 -0800 Subject: [PATCH] fix: ensure TxFactory has acc & seq fields when simulating tx in generate-only mode (#11313) * fix: ensure TxFactory has acc no & seq when simulating tx in generate only mode * add changelog Co-authored-by: Aleksandr Bezobchuk --- CHANGELOG.md | 1 + client/tx/factory.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 347636f371..e3d3740919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -218,6 +218,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#11222](https://github.com/cosmos/cosmos-sdk/pull/11222) reject query with block height in the future * [#11229](https://github.com/cosmos/cosmos-sdk/pull/11229) Handled the error message of `transaction encountered error` from tendermint. * (x/authz) [\#11252](https://github.com/cosmos/cosmos-sdk/pull/11252) Allow insufficient funds error for authz simulation +* (cli) [\#11313](https://github.com/cosmos/cosmos-sdk/pull/11313) Fixes `--gas auto` when executing CLI transactions in `--generate-only` mode ### State Machine Breaking diff --git a/client/tx/factory.go b/client/tx/factory.go index 5e80532822..15032250a8 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -276,7 +276,14 @@ func (f Factory) PrintUnsignedTx(clientCtx client.Context, msgs ...sdk.Msg) erro return errors.New("cannot estimate gas in offline mode") } - _, adjusted, err := CalculateGas(clientCtx, f, msgs...) + // Prepare TxFactory with acc & seq numbers as CalculateGas requires + // account and sequence numbers to be set + preparedTxf, err := f.Prepare(clientCtx) + if err != nil { + return err + } + + _, adjusted, err := CalculateGas(clientCtx, preparedTxf, msgs...) if err != nil { return err }