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

adding client status cli query #372

Merged
merged 4 commits into from
Sep 3, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features

* [\#198](https://github.com/cosmos/ibc-go/pull/198) New CLI command `query ibc-transfer escrow-address <port> <channel id>` to get the escrow address for a channel; can be used to then query balance of escrowed tokens
* [\#372](https://github.com/cosmos/ibc-go/pull/372) New CLI command `query ibc client status <client id>` to get the current activity status of a client

### Client Breaking Changes

Expand Down
1 change: 1 addition & 0 deletions modules/core/02-client/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func GetQueryCmd() *cobra.Command {
queryCmd.AddCommand(
GetCmdQueryClientStates(),
GetCmdQueryClientState(),
GetCmdQueryClientStatus(),
GetCmdQueryConsensusStates(),
GetCmdQueryConsensusState(),
GetCmdQueryHeader(),
Expand Down
33 changes: 33 additions & 0 deletions modules/core/02-client/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ func GetCmdQueryClientState() *cobra.Command {
return cmd
}

// GetCmdQueryClientStatus defines the command to query the status of a client with a given id
func GetCmdQueryClientStatus() *cobra.Command {
cmd := &cobra.Command{
Use: "status [client-id]",
Short: "Query client status",
Long: "Query client activity status. Any client without an 'Active' status is considered inactive",
Example: fmt.Sprintf("%s query %s %s status [client-id]", version.AppName, host.ModuleName, types.SubModuleName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

clientID := args[0]
queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryClientStatusRequest{
ClientId: clientID,
}

clientStatusRes, err := queryClient.ClientStatus(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(clientStatusRes)
},
}

return cmd
}

// GetCmdQueryConsensusStates defines the command to query all the consensus states from a given
// client state.
func GetCmdQueryConsensusStates() *cobra.Command {
Expand Down