Skip to content

Commit

Permalink
feat(marketplace): Add query cmd for AllowedDenoms (#1099)
Browse files Browse the repository at this point in the history
* feat: add allowed denoms cli query

* chore: register query cmd

Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
  • Loading branch information
aleem1314 and ryanchristo authored May 16, 2022
1 parent 0e20767 commit 946887f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions x/ecocredit/client/marketplace/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,44 @@ $ regen q sell-orders-by-batch-denom C01-20210101-20210201-001 --pagination.limi
flags.AddPaginationFlagsToCmd(cmd, "sell-orders-by-batch-denom")
return cmd
}

// QueryAllowedDenomsCmd returns a query command that retrieves allowed denoms with pagination.
func QueryAllowedDenomsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "allowed-denoms",
Short: "List all allowed denoms with pagination",
Long: strings.TrimSpace(`
Retrieve allowed denoms with pagination
Example:
$ regen q allowed-denoms
$ regen q allowed-denoms --pagination.limit 10 --pagination.offset 2
`),
Example: "$ regen q allowed-denoms",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
ctx, err := sdkclient.GetClientQueryContext(cmd)
if err != nil {
return err
}

client := marketplace.NewQueryClient(ctx)
pagination, err := sdkclient.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}
res, err := client.AllowedDenoms(cmd.Context(), &marketplace.QueryAllowedDenomsRequest{
Pagination: pagination,
})
if err != nil {
return err
}

return ctx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "allowed-denoms")

return cmd
}
1 change: 1 addition & 0 deletions x/ecocredit/client/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func QueryCmd(name string) *cobra.Command {
marketplacecli.QuerySellOrdersCmd(),
marketplacecli.QuerySellOrdersByAddressCmd(),
marketplacecli.QuerySellOrdersByBatchDenomCmd(),
marketplacecli.QueryAllowedDenomsCmd(),
)
return cmd
}
Expand Down

0 comments on commit 946887f

Please sign in to comment.