From 651267c7d5b1041fe9ef7a370aa88298f3fccddf Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 2 Sep 2021 16:52:25 +0200 Subject: [PATCH 1/3] adding client status cli query --- modules/core/02-client/client/cli/cli.go | 1 + modules/core/02-client/client/cli/query.go | 33 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) 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..b1a38e3049b 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", + 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 { From e83e01fd9eb64c3523db91ce5b66f7a57fb3ab60 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 3 Sep 2021 10:03:15 +0200 Subject: [PATCH 2/3] adding query client status cli to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c109aa0613..a3715e1cda1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ` 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 From 3e77566c6602794dc87e133207d430ebacf29bb7 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 3 Sep 2021 10:05:40 +0200 Subject: [PATCH 3/3] updating long CLI help usage --- modules/core/02-client/client/cli/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/02-client/client/cli/query.go b/modules/core/02-client/client/cli/query.go index b1a38e3049b..8633b92a469 100644 --- a/modules/core/02-client/client/cli/query.go +++ b/modules/core/02-client/client/cli/query.go @@ -94,7 +94,7 @@ func GetCmdQueryClientStatus() *cobra.Command { cmd := &cobra.Command{ Use: "status [client-id]", Short: "Query client status", - Long: "Query client activity 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 {