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: overwrite sequence and account-number flags when used with offline=false #9856

Merged
merged 35 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
525b2d5
return MaxUint64 for Limit on InfiniteGasMeter and add a func to retu…
likhita-809 Jul 8, 2021
188851d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 9, 2021
4ebb8b7
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 12, 2021
2ebdadd
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 13, 2021
90c3f5c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 19, 2021
2ceb46d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 20, 2021
7474885
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 23, 2021
b3d6b13
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 26, 2021
6a80511
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 26, 2021
b5c15ef
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 27, 2021
85bc2ef
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 28, 2021
ddfdae6
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Jul 29, 2021
2dd8869
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Aug 2, 2021
a40985d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Aug 3, 2021
e57ffcc
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk
likhita-809 Aug 4, 2021
c3d6b73
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Aug 5, 2021
dcdab0c
overwrite sequence and account-number flag's values with default valu…
likhita-809 Aug 5, 2021
ae00407
improve sign-batch cli help msg
likhita-809 Aug 5, 2021
6ca20cf
add changelod
likhita-809 Aug 5, 2021
7fba98e
fix lint issues
likhita-809 Aug 5, 2021
30d7ac6
add tess
likhita-809 Aug 5, 2021
cb7e57a
fix failing test
likhita-809 Aug 5, 2021
05f888d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Aug 6, 2021
ead516d
small fix
likhita-809 Aug 6, 2021
1141a68
small fixes
likhita-809 Aug 6, 2021
f3fe6b9
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Aug 6, 2021
3471d78
small refactor
likhita-809 Aug 6, 2021
79cda3c
code refactoring
likhita-809 Aug 6, 2021
60780ba
Merge branch 'master' into likhita/sequence-flag-ux-issue
alexanderbez Aug 6, 2021
59a947d
address review comment
likhita-809 Aug 6, 2021
ac135c4
Merge branch 'likhita/sequence-flag-ux-issue' of https://github.com/c…
likhita-809 Aug 6, 2021
6e60afa
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Aug 7, 2021
7ffb026
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Aug 9, 2021
5f0843d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Aug 9, 2021
7b0e7a7
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Aug 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (cli) [\#9856](https://github.com/cosmos/cosmos-sdk/pull/9856) Overwrite `--sequence` and `--account-number` flags with default flag values when used with `offline=false` in `sign-batch` command.
* (cli) [\#9593](https://github.com/cosmos/cosmos-sdk/pull/9593) Check if chain-id is blank before verifying signatures in multisign and error.
* (cli) [\#9717](https://github.com/cosmos/cosmos-sdk/pull/9717) Added CLI flag `--output json/text` to `tx` cli commands.

Expand Down
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 @@ -28,7 +28,7 @@ func GetSignBatchCommand() *cobra.Command {
Long: `Sign batch files of transactions generated with --generate-only.
The command processes list of transactions from file (one StdTx each line), generate
signed transactions or signatures and print their JSON encoding, delimited by '\n'.
As the signatures are generated, the command updates the account sequence number accordingly.
As the signatures are generated, the command updates the account and sequence number accordingly.

If the --signature-only flag is set, it will output the signature parts only.

Expand All @@ -38,6 +38,9 @@ it is required to set such parameters manually. Note, invalid values will cause
the transaction to fail. The sequence will be incremented automatically for each
transaction that is signed.

If --account-number or --sequence flag is used when offline=false, they are ignored and
overwritten by the default flag values.

The --multisig=<multisig_key> flag generates a signature on behalf of a multisig
account key. It implies --signature-only.
`,
Expand Down Expand Up @@ -89,6 +92,12 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error {
}
scanner := authclient.NewBatchScanner(txCfg, infile)

if !clientCtx.Offline {
txFactory = txFactory.WithAccountNumber(0).WithSequence(0)
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
} else {
txFactory = txFactory.WithAccountNumber(txFactory.AccountNumber()).WithSequence(txFactory.Sequence())
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
}

for sequence := txFactory.Sequence(); scanner.Scan(); sequence++ {
unsignedStdTx := scanner.Tx()
txFactory = txFactory.WithSequence(sequence)
Expand Down
15 changes: 14 additions & 1 deletion x/auth/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,21 @@ func (s *IntegrationTestSuite) TestCLISignBatch() {
_, err = 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")

// sign-batch file - offline and sequence is set but account-number is not set
_, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.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 = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.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 := 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"))
s.Require().NoError(err)
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))

// sign-batch file
res, err := TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
res, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
s.Require().NoError(err)
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))

Expand Down