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(x/auth): Add fees on batch sign #18564

Merged
merged 12 commits into from
Nov 29, 2023
2 changes: 2 additions & 0 deletions x/auth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ Ref: https://keepachangelog.com/en/1.0.0/
### API Breaking Changes

### Bug Fixes

* (client/cli) [#18564](https://github.com/cosmos/cosmos-sdk/pull/18564) Fix total fees when batch signing
raynaudoe marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 10 additions & 1 deletion x/auth/client/cli/tx_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error {
appendMessagesToSingleTx, _ := cmd.Flags().GetBool(flagAppend)
// Combines all tx msgs and create single signed transaction
if appendMessagesToSingleTx {
var totalFees sdk.Coins
txBuilder := txCfg.NewTxBuilder()
msgs := make([]sdk.Msg, 0)
newGasLimit := uint64(0)
Expand All @@ -129,6 +130,12 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error {
}
// increment the gas
newGasLimit += fe.GetTx().GetGas()
// Individual fee values from each transaction need to be aggregated to calculate the total fee for the batch of transactions.
raynaudoe marked this conversation as resolved.
Show resolved Hide resolved
// https://github.com/cosmos/cosmos-sdk/issues/18064
unmergedFees := fe.GetTx().GetFee()
for _, fee := range unmergedFees {
totalFees = totalFees.Add(fee)
}
// append messages
msgs = append(msgs, unsignedStdTx.GetMsgs()...)
}
Expand All @@ -140,13 +147,15 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error {

// set the memo,fees,feeGranter,feePayer from cmd flags
txBuilder.SetMemo(txFactory.Memo())
txBuilder.SetFeeAmount(txFactory.Fees())
txBuilder.SetFeeGranter(clientCtx.FeeGranter)
txBuilder.SetFeePayer(clientCtx.FeePayer)

// set the gasLimit
txBuilder.SetGasLimit(newGasLimit)

// set the feeAmount
txBuilder.SetFeeAmount(totalFees)

// sign the txs
from, _ := cmd.Flags().GetString(flags.FlagFrom)
err := sigTxOrMultisig(clientCtx, txBuilder, txFactory, from, multisigKey)
Expand Down
Loading