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

feat(x/ecocredit): basket query cli cmd #766

Merged
merged 5 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions x/ecocredit/client/basket/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ import (
"github.com/regen-network/regen-ledger/x/ecocredit/basket"
)

// QueryBasketCmd returns a query command that retrieves a basket.
func QueryBasketCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "basket [basket-denom]",
Short: "Gets the info for a basket",
Long: "Retrieves the information for a basket given a specific basket denom",
Example: "regen q ecocredit basket SOMEBASKET",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
client := basket.NewQueryClient(ctx)

res, err := client.Basket(cmd.Context(), &basket.QueryBasketRequest{BasketDenom: args[0]})
if err != nil {
return err
}

return ctx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd
}

// QueryBasketBalanceCmd returns a query command that retrieves the balance of a credit batch in the basket.
func QueryBasketBalanceCmd() *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions x/ecocredit/client/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func QueryCmd(name string) *cobra.Command {
QuerySupplyCmd(),
QueryCreditTypesCmd(),
QueryParams(),
basketcli.QueryBasketCmd(),
basketcli.QueryBasketBalanceCmd(),
basketcli.QueryBasketBalancesCmd(),
)
Expand Down