Skip to content

Commit

Permalink
fix: correct issue where gas simulation can't be made with --generate…
Browse files Browse the repository at this point in the history
…-only flag (#126)
  • Loading branch information
ejfitzgerald authored Mar 9, 2022
1 parent 071cfdc commit b5cd0bf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ func GenerateTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
return errors.New("cannot estimate gas in offline mode")
}

// If we are simulating the transaction, we are not in offline mode. Then we need to lookup correct sequence
// number and account number information. Otherwise it will fail
var err error
txf, err = PrepareFactory(clientCtx, txf)
if err != nil {
return err
}

_, adjusted, err := CalculateGas(clientCtx.QueryWithData, txf, msgs...)
if err != nil {
return err
}

txf = txf.WithGas(adjusted)
_, _ = fmt.Fprintf(os.Stderr, "%s\n", GasEstimateResponse{GasEstimate: txf.Gas()})
}

tx, err := BuildUnsignedTx(txf, msgs...)
Expand Down

0 comments on commit b5cd0bf

Please sign in to comment.