Skip to content

Commit

Permalink
fix(x/auth): Add fees on batch sign (#18564)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7bdbc46)

# Conflicts:
#	tests/e2e/auth/suite.go
#	x/auth/CHANGELOG.md
#	x/auth/client/cli/tx_sign.go
  • Loading branch information
raynaudoe authored and mergify[bot] committed Nov 29, 2023
1 parent cfc2a33 commit 398dd79
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 12 deletions.
52 changes: 52 additions & 0 deletions tests/e2e/auth/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func (s *E2ETestSuite) TestCLISignBatch() {
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)

// sign-batch file - offline is set but account-number and sequence are not
<<<<<<< HEAD
_, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--offline")
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")

Expand All @@ -230,27 +231,58 @@ func (s *E2ETestSuite) TestCLISignBatch() {

// sign-batch file - sequence and account-number are set when offline is false
res, err := authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"))
=======
_, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--offline")
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")

// sign-batch file - offline and sequence is set but account-number is not set
_, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), "--offline")
s.Require().EqualError(err, "required flag(s) \"account-number\" not set")

// sign-batch file - offline and account-number is set but sequence is not set
_, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"), "--offline")
s.Require().EqualError(err, "required flag(s) \"sequence\" not set")

// sign-batch file - sequence and account-number are set when offline is false
res, err := authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"))
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().NoError(err)
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))

// sign-batch file
<<<<<<< HEAD
res, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
=======
res, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID))
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().NoError(err)
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))

// sign-batch file signature only
<<<<<<< HEAD
res, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
=======
res, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--signature-only")
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().NoError(err)
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))

// Sign batch malformed tx file.
malformedFile := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf("%smalformed", generatedStd))
defer malformedFile.Close()
<<<<<<< HEAD
_, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
s.Require().Error(err)

// Sign batch malformed tx file signature only.
_, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
=======
_, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{malformedFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID))
s.Require().Error(err)

// Sign batch malformed tx file signature only.
_, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{malformedFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--signature-only")
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().Error(err)

// make a txn to increase the sequence of sender
Expand Down Expand Up @@ -278,7 +310,11 @@ func (s *E2ETestSuite) TestCLISignBatch() {
s.Require().Equal(seq+1, seq1)

// signing sign-batch should start from the last sequence.
<<<<<<< HEAD
signed, err := authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
=======
signed, err := authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--signature-only")
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().NoError(err)
signedTxs := strings.Split(strings.Trim(signed.String(), "\n"), "\n")
s.Require().GreaterOrEqual(len(signedTxs), 1)
Expand Down Expand Up @@ -1118,7 +1154,11 @@ func (s *E2ETestSuite) TestSignBatchMultisig() {
addr1, err := account1.GetAddress()
s.Require().NoError(err)
// sign-batch file
<<<<<<< HEAD
res, err := authclitestutil.TxSignBatchExec(val.ClientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
=======
res, err := authclitestutil.TxSignBatchExec(clientCtx, addr1, []string{filename.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().NoError(err)
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
// write sigs to file
Expand All @@ -1128,7 +1168,11 @@ func (s *E2ETestSuite) TestSignBatchMultisig() {
addr2, err := account2.GetAddress()
s.Require().NoError(err)
// sign-batch file with account2
<<<<<<< HEAD
res, err = authclitestutil.TxSignBatchExec(val.ClientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
=======
res, err = authclitestutil.TxSignBatchExec(clientCtx, addr2, []string{filename.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().NoError(err)
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
// write sigs to file2
Expand Down Expand Up @@ -1187,7 +1231,11 @@ func (s *E2ETestSuite) TestMultisignBatch() {
// sign-batch file
addr1, err := account1.GetAddress()
s.Require().NoError(err)
<<<<<<< HEAD
res, err := authclitestutil.TxSignBatchExec(val.ClientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
=======
res, err := authclitestutil.TxSignBatchExec(clientCtx, addr1, []string{filename.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().NoError(err)
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
// write sigs to file
Expand All @@ -1197,7 +1245,11 @@ func (s *E2ETestSuite) TestMultisignBatch() {
// sign-batch file with account2
addr2, err := account2.GetAddress()
s.Require().NoError(err)
<<<<<<< HEAD
res, err = authclitestutil.TxSignBatchExec(val.ClientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
=======
res, err = authclitestutil.TxSignBatchExec(clientCtx, addr2, []string{filename.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))
s.Require().NoError(err)
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))

Expand Down
67 changes: 62 additions & 5 deletions tests/integration/auth/client/cli/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,75 @@ func (s *CLITestSuite) TestCLISignBatch() {
s.clientCtx.HomeDir = strings.Replace(s.clientCtx.HomeDir, "simd", "simcli", 1)

// sign-batch file - offline is set but account-number and sequence are not
_, err = authtestutil.TxSignBatchExec(s.clientCtx, s.val, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), "--offline")
_, err = authtestutil.TxSignBatchExec(s.clientCtx, s.val, []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), "--offline")
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")

// sign-batch file - offline and sequence is set but account-number is not set
_, err = authtestutil.TxSignBatchExec(s.clientCtx, s.val, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), "--offline")
_, err = authtestutil.TxSignBatchExec(s.clientCtx, s.val, []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), "--offline")
s.Require().EqualError(err, "required flag(s) \"account-number\" not set")

// sign-batch file - offline and account-number is set but sequence is not set
_, err = authtestutil.TxSignBatchExec(s.clientCtx, s.val, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"), "--offline")
_, err = authtestutil.TxSignBatchExec(s.clientCtx, s.val, []string{outputFile.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"), "--offline")
s.Require().EqualError(err, "required flag(s) \"sequence\" not set")
}

func (s *CLITestSuite) TestCLISignBatchTotalFees() {
txCfg := s.clientCtx.TxConfig
s.clientCtx.HomeDir = strings.Replace(s.clientCtx.HomeDir, "simd", "simcli", 1)

testCases := []struct {
name string
args []string
numTransactions int
denom string
}{
{
"Offline batch-sign one transaction",
[]string{"--offline", "--account-number", "1", "--sequence", "1", "--append"},
1,
"stake",
},
{
"Offline batch-sign two transactions",
[]string{"--offline", "--account-number", "1", "--sequence", "1", "--append"},
2,
"stake",
},
}

for _, tc := range testCases {
s.Run(tc.name, func() {
// Create multiple transactions and write them to separate files
sendTokens := sdk.NewCoin(tc.denom, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction))
expectedBatchedTotalFee := int64(0)
txFiles := make([]string, tc.numTransactions)
for i := 0; i < tc.numTransactions; i++ {
tx, err := s.createBankMsg(s.clientCtx, s.val,
sdk.NewCoins(sendTokens), clitestutil.TestTxConfig{GenOnly: true})
s.Require().NoError(err)
txFile := testutil.WriteToNewTempFile(s.T(), tx.String()+"\n")
defer txFile.Close()
txFiles[i] = txFile.Name()

unsignedTx, err := txCfg.TxJSONDecoder()(tx.Bytes())
s.Require().NoError(err)
txBuilder, err := txCfg.WrapTxBuilder(unsignedTx)
expectedBatchedTotalFee += txBuilder.GetTx().GetFee().AmountOf(tc.denom).Int64()
}

// Test batch sign
signedTx, err := authtestutil.TxSignBatchExec(s.clientCtx, s.val, txFiles, tc.args...)
s.Require().NoError(err)
signedFinalTx, err := txCfg.TxJSONDecoder()(signedTx.Bytes())
s.Require().NoError(err)
txBuilder, err := txCfg.WrapTxBuilder(signedFinalTx)
s.Require().NoError(err)
finalTotalFee := txBuilder.GetTx().GetFee()
s.Require().Equal(expectedBatchedTotalFee, finalTotalFee.AmountOf(tc.denom).Int64())
})
}
}

func (s *CLITestSuite) TestCLIQueryTxCmdByHash() {
sendTokens := sdk.NewInt64Coin("stake", 10)

Expand Down Expand Up @@ -757,7 +814,7 @@ func (s *CLITestSuite) TestSignBatchMultisig() {
addr1, err := account1.GetAddress()
s.Require().NoError(err)
// sign-batch file
res, err := authtestutil.TxSignBatchExec(s.clientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
res, err := authtestutil.TxSignBatchExec(s.clientCtx, addr1, []string{filename.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
s.Require().NoError(err)
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
// write sigs to file
Expand All @@ -767,7 +824,7 @@ func (s *CLITestSuite) TestSignBatchMultisig() {
addr2, err := account2.GetAddress()
s.Require().NoError(err)
// sign-batch file with account2
res, err = authtestutil.TxSignBatchExec(s.clientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
res, err = authtestutil.TxSignBatchExec(s.clientCtx, addr2, []string{filename.Name()}, fmt.Sprintf("--%s=%s", flags.FlagChainID, s.clientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
s.Require().NoError(err)
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
// write sigs to file2
Expand Down
36 changes: 36 additions & 0 deletions x/auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
Guiding Principles:
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each version is displayed.
Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section under the
appropriate stanza (see below). Each entry should ideally include a tag and
the Github issue reference in the following format:
* (<tag>) [#<issue-number>] Changelog message.
Types of changes (Stanzas):
"Features" for new features.
"Improvements" for changes in existing functionality.
"Deprecated" for soon-to-be removed features.
"Bug Fixes" for any bug fixes.
"API Breaking" for breaking exported APIs used by developers building on SDK.
Ref: https://keepachangelog.com/en/1.0.0/
-->

# Changelog

## [Unreleased]

### Features

### Improvements

### API Breaking Changes

### Bug Fixes

* (client/cli) [#18564](https://github.com/cosmos/cosmos-sdk/pull/18564) Fix total fees calculation when batch signing
16 changes: 15 additions & 1 deletion x/auth/client/cli/tx_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ 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 {
<<<<<<< HEAD

Check failure on line 124 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '<<'

Check failure on line 124 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected <<, expected }

Check failure on line 124 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected <<, expected }

Check failure on line 124 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expected }

Check failure on line 124 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expected }

Check failure on line 124 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected }

Check failure on line 124 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected }
txBuilder := clientCtx.TxConfig.NewTxBuilder()
=======

Check failure on line 126 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected ==, expected }

Check failure on line 126 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected ==, expected }

Check failure on line 126 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expected }

Check failure on line 126 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expected }

Check failure on line 126 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected }

Check failure on line 126 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected }
var totalFees sdk.Coins

Check failure on line 127 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected var at end of statement

Check failure on line 127 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected var at end of statement

Check failure on line 127 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected var at end of statement

Check failure on line 127 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected var at end of statement

Check failure on line 127 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected var at end of statement

Check failure on line 127 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected var at end of statement

Check warning

Code scanning / CodeQL

Unreachable statement Warning

This statement is unreachable.
txBuilder := txCfg.NewTxBuilder()
>>>>>>> 7bdbc4629 (fix(x/auth): Add fees on batch sign (#18564))

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '>>'

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / dependency-review

illegal character U+0023 '#'

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected >>, expected }

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid character U+0023 '#'

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected >>, expected }

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid character U+0023 '#'

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected >>, expected }

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid character U+0023 '#'

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected >>, expected }

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid character U+0023 '#'

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expected }

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expected }

Check failure on line 129 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'
msgs := make([]sdk.Msg, 0)
newGasLimit := uint64(0)

Expand All @@ -133,6 +138,13 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error {
}
// increment the gas
newGasLimit += fe.GetTx().GetGas()

Check failure on line 140 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: newGasLimit
// Individual fee values from each transaction need to be
// aggregated to calculate the total fee for the batch of transactions.
// 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()...)

Check failure on line 149 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: msgs

Check failure on line 149 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: msgs
}
Expand All @@ -141,13 +153,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)

Check failure on line 160 in x/auth/client/cli/tx_sign.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: newGasLimit

// set the feeAmount
txBuilder.SetFeeAmount(totalFees)

// sign the txs
if ms == "" {
from, _ := cmd.Flags().GetString(flags.FlagFrom)
Expand Down
8 changes: 2 additions & 6 deletions x/auth/client/testutil/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ func TxMultiSignExec(clientCtx client.Context, from, filename string, extraArgs
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetMultiSignCommand(), append(args, extraArgs...))
}

func TxSignBatchExec(clientCtx client.Context, from fmt.Stringer, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
args := []string{
fmt.Sprintf("--from=%s", from.String()),
filename,
}

func TxSignBatchExec(clientCtx client.Context, from fmt.Stringer, filenames []string, extraArgs ...string) (testutil.BufferWriter, error) {
args := append([]string{fmt.Sprintf("--from=%s", from.String())}, filenames...)
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetSignBatchCommand(), append(args, extraArgs...))
}

Expand Down

0 comments on commit 398dd79

Please sign in to comment.