From 187c014c4eb5a4a3bd9a449f455052cd154e823f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 15 Mar 2022 17:40:49 +0100 Subject: [PATCH] fix: Update query.go to include pagination for bank q totals (#11355) (#11375) Closes: #11354 --- *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) (cherry picked from commit 791d38c90c1d02b832dad3d93ae658e882ec9bd9) Co-authored-by: billy rennekamp --- CHANGELOG.md | 1 + x/bank/client/cli/query.go | 66 -------------------------------------- 2 files changed, 1 insertion(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 758dd57c75d3c..b847a4adac2bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* [\#11354](https://github.com/cosmos/cosmos-sdk/pull/11355) Added missing pagination flag for `bank q total` query. * [\#11197](https://github.com/cosmos/cosmos-sdk/pull/11197) Signing with multisig now works with multisig address which is not in the keyring. * (client) [\#11283](https://github.com/cosmos/cosmos-sdk/issues/11283) Support multiple keys for tx simulation and setting automatic gas for txs. * (store) [\#11177](https://github.com/cosmos/cosmos-sdk/pull/11177) Update the prune `everything` strategy to store the last two heights. diff --git a/x/bank/client/cli/query.go b/x/bank/client/cli/query.go index df544fd315d6c..a9cdadb9753d7 100644 --- a/x/bank/client/cli/query.go +++ b/x/bank/client/cli/query.go @@ -33,7 +33,6 @@ func GetQueryCmd() *cobra.Command { GetBalancesCmd(), GetCmdQueryTotalSupply(), GetCmdDenomsMetadata(), - GetCmdQuerySendEnabled(), ) return cmd @@ -59,7 +58,6 @@ Example: if err != nil { return err } - denom, err := cmd.Flags().GetString(FlagDenom) if err != nil { return err @@ -76,22 +74,17 @@ Example: if err != nil { return err } - ctx := cmd.Context() - if denom == "" { params := types.NewQueryAllBalancesRequest(addr, pageReq) - res, err := queryClient.AllBalances(ctx, params) if err != nil { return err } - return clientCtx.PrintProto(res) } params := types.NewQueryBalanceRequest(addr, denom) - res, err := queryClient.Balance(ctx, params) if err != nil { return err @@ -131,7 +124,6 @@ To query for the client metadata of a specific coin denomination use: if err != nil { return err } - denom, err := cmd.Flags().GetString(FlagDenom) if err != nil { return err @@ -167,7 +159,6 @@ func GetCmdQueryTotalSupply() *cobra.Command { cmd := &cobra.Command{ Use: "total", Short: "Query the total supply of coins of the chain", - Args: cobra.NoArgs, Long: strings.TrimSpace( fmt.Sprintf(`Query total supply of coins that are held by accounts in the chain. @@ -185,7 +176,6 @@ To query for the total supply of a specific coin denomination use: if err != nil { return err } - denom, err := cmd.Flags().GetString(FlagDenom) if err != nil { return err @@ -198,7 +188,6 @@ To query for the total supply of a specific coin denomination use: if err != nil { return err } - if denom == "" { res, err := queryClient.TotalSupply(ctx, &types.QueryTotalSupplyRequest{Pagination: pageReq}) if err != nil { @@ -223,58 +212,3 @@ To query for the total supply of a specific coin denomination use: return cmd } - -func GetCmdQuerySendEnabled() *cobra.Command { - cmd := &cobra.Command{ - Use: "send-enabled [denom1 ...]", - Short: "Query for send enabled entries", - Long: strings.TrimSpace(`Query for send enabled entries that have been specifically set. - -To look up one or more specific denoms, supply them as arguments to this command. -To look up all denoms, do not provide any arguments. -`, - ), - Example: strings.TrimSpace( - fmt.Sprintf(`Getting one specific entry: - $ %[1]s query %[2]s send-enabled foocoin - -Getting two specific entries: - $ %[1]s query %[2]s send-enabled foocoin barcoin - -Getting all entries: - $ %[1]s query %[2]s send-enabled -`, - version.AppName, types.ModuleName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - reqPag, err := client.ReadPageRequest(client.MustFlagSetWithPageKeyDecoded(cmd.Flags())) - if err != nil { - return err - } - - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - req := &types.QuerySendEnabledRequest{ - Denoms: args, - Pagination: reqPag, - } - - res, err := queryClient.SendEnabled(cmd.Context(), req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "send enabled entries") - - return cmd -}