diff --git a/CHANGELOG.md b/CHANGELOG.md index 865e002fd04a..8eaedb138cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Features + +* [\#9750](https://github.com/cosmos/cosmos-sdk/pull/9750) Emit events for tx signature and sequence, so clients can now query txs by signature (`tx.signature=''`) or by address and sequence combo (`tx.acc_seq='/'`). + ### Improvements * (cli) [\#9717](https://github.com/cosmos/cosmos-sdk/pull/9717) Added CLI flag `--output json/text` to `tx` cli commands. diff --git a/types/events.go b/types/events.go index 9c495a9da2a7..27a0017635af 100644 --- a/types/events.go +++ b/types/events.go @@ -227,7 +227,6 @@ var ( AttributeKeyAccountSequence = "acc_seq" AttributeKeySignature = "signature" - AttributeKeyFee = "fee" EventTypeMessage = "message" diff --git a/x/auth/client/cli/query.go b/x/auth/client/cli/query.go index e38dac0e3dd6..ececfc69212a 100644 --- a/x/auth/client/cli/query.go +++ b/x/auth/client/cli/query.go @@ -218,12 +218,12 @@ $ %s query txs --%s 'message.sender=cosmos1...&message.action=withdraw_delegator func QueryTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: "tx --type=[hash|acc_seq|signature] [hash|acc_seq|signature]", - Short: "Query for a transaction by hash, \"/\" combination or comma-separated signatures in a committed block", + Short: "Query for a transaction by hash, addr++seq combination or signature in a committed block", Long: strings.TrimSpace(fmt.Sprintf(` Example: $ %s query tx -$ %s query tx --%s=%s / -$ %s query tx --%s=%s , +$ %s query tx --%s=%s : +$ %s query tx --%s=%s `, version.AppName, version.AppName, flagType, typeAccSeq, diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 626e0130f42a..58a4e577cbb2 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -425,76 +425,6 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() { } } -func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() { - val := s.network.Validators[0] - - account2, err := val.ClientCtx.Keyring.Key("newAccount2") - s.Require().NoError(err) - - sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10) - - // Send coins. - out, err := s.createBankMsg( - val, account2.GetAddress(), - sdk.NewCoins(sendTokens), - ) - s.Require().NoError(err) - var txRes sdk.TxResponse - s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes)) - s.Require().NoError(s.network.WaitForNextBlock()) - - // Query the tx by hash to get the inner tx. - out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{txRes.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) - s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes)) - - testCases := []struct { - name string - args []string - expectEmpty bool - }{ - { - "fee event happy case", - []string{ - fmt.Sprintf("--events=tx.fee=%s", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - }, - { - "no matching fee event", - []string{ - fmt.Sprintf("--events=tx.fee=%s", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0))).String()), - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - true, - }, - } - - for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { - cmd := authcli.QueryTxsByEventsCmd() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - s.Require().NoError(err) - - var result sdk.SearchTxsResult - s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) - - if tc.expectEmpty { - s.Require().Equal(0, len(result.Txs)) - } else { - s.Require().NotEqual(0, len(result.Txs)) - s.Require().NotNil(result.Txs[0]) - } - }) - } -} - func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() { val1 := s.network.Validators[0]