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

fix: fix consumer chain query CLI #2190

Merged
merged 3 commits into from
Aug 29, 2024
Merged
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
32 changes: 30 additions & 2 deletions x/ccv/provider/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewQueryCmd() *cobra.Command {
cmd.AddCommand(CmdValidatorConsumerCommissionRate())
cmd.AddCommand(CmdBlocksUntilNextEpoch())
cmd.AddCommand(CmdConsumerIdFromClientId())
cmd.AddCommand(CmdConsumerChain())
return cmd
}

Expand Down Expand Up @@ -88,15 +89,15 @@ func CmdConsumerChains() *cobra.Command {

req := &types.QueryConsumerChainsRequest{}

if args[0] != "" {
if len(args) >= 1 && args[0] != "" {
phase, err := strconv.ParseInt(args[0], 10, 32)
if err != nil {
return err
}
req.Phase = types.ConsumerPhase(phase)
}

if args[1] != "" {
if len(args) == 2 && args[1] != "" {
limit, err := strconv.ParseInt(args[1], 10, 32)
if err != nil {
return err
Expand Down Expand Up @@ -553,3 +554,30 @@ func CmdConsumerIdFromClientId() *cobra.Command {

return cmd
}

func CmdConsumerChain() *cobra.Command {
cmd := &cobra.Command{
Use: "consumer-chain [consumer-id]",
Short: "Query the consumer chain associated with the consumer id",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryConsumerChainRequest{ConsumerId: args[0]}
res, err := queryClient.QueryConsumerChain(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading