Skip to content

Commit

Permalink
fix: Update query.go to include pagination for bank q totals (cosmos#…
Browse files Browse the repository at this point in the history
…11355) (cosmos#11375)

Closes: cosmos#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 791d38c)

Co-authored-by: billy rennekamp <billy.rennekamp@gmail.com>
  • Loading branch information
2 people authored and Eengineer1 committed Aug 26, 2022
1 parent 954dbcf commit 187c014
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 66 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
66 changes: 0 additions & 66 deletions x/bank/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func GetQueryCmd() *cobra.Command {
GetBalancesCmd(),
GetCmdQueryTotalSupply(),
GetCmdDenomsMetadata(),
GetCmdQuerySendEnabled(),
)

return cmd
Expand All @@ -59,7 +58,6 @@ Example:
if err != nil {
return err
}

denom, err := cmd.Flags().GetString(FlagDenom)
if err != nil {
return err
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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
}

0 comments on commit 187c014

Please sign in to comment.