Skip to content

Commit

Permalink
adding client status cli query (#372)
Browse files Browse the repository at this point in the history
* adding client status cli query

* adding query client status cli to changelog

* updating long CLI help usage
  • Loading branch information
damiannolan authored Sep 3, 2021
1 parent a6bf50d commit 74182d8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
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

0 comments on commit 74182d8

Please sign in to comment.