diff --git a/CHANGELOG.md b/CHANGELOG.md index a1a9ca9aed9..7e9a9341f34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,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 ` 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 ` to get the current activity status of a client ### Client Breaking Changes diff --git a/modules/core/02-client/client/cli/cli.go b/modules/core/02-client/client/cli/cli.go index eade59ba6f1..1b6572ebb75 100644 --- a/modules/core/02-client/client/cli/cli.go +++ b/modules/core/02-client/client/cli/cli.go @@ -20,6 +20,7 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( GetCmdQueryClientStates(), GetCmdQueryClientState(), + GetCmdQueryClientStatus(), GetCmdQueryConsensusStates(), GetCmdQueryConsensusState(), GetCmdQueryHeader(), diff --git a/modules/core/02-client/client/cli/query.go b/modules/core/02-client/client/cli/query.go index 5ed7c049bed..8633b92a469 100644 --- a/modules/core/02-client/client/cli/query.go +++ b/modules/core/02-client/client/cli/query.go @@ -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 {