Skip to content

Commit 4638933

Browse files
feat(02-client/cli): add query for client counterparty. (#7235)
* feat(02-client/cli): add query for client counterparty. * chore: mirror grpc name. * Apply suggestions from code review Co-authored-by: Carlos Rodriguez <carlos@interchain.io> --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
1 parent d4d1dc6 commit 4638933

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

modules/core/02-client/client/cli/cli.go

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func GetQueryCmd() *cobra.Command {
2626
GetCmdQueryConsensusStateHeights(),
2727
GetCmdQueryConsensusState(),
2828
GetCmdQueryHeader(),
29+
GetCmdQueryClient(),
2930
GetCmdSelfConsensusState(),
3031
GetCmdClientParams(),
3132
)

modules/core/02-client/client/cli/query.go

+32
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,38 @@ func GetCmdQueryConsensusStateHeights() *cobra.Command {
210210
return cmd
211211
}
212212

213+
// GetCmdQueryClient defines the command to query the client information (creator and counterparty) for the given client ID.
214+
func GetCmdQueryClient() *cobra.Command {
215+
cmd := &cobra.Command{
216+
Use: "client [client-id]",
217+
Short: "Query the information of a client.",
218+
Long: "Query the client information (creator and counterparty) for the provided client ID.",
219+
Example: fmt.Sprintf("%s query %s %s client [client-id]", version.AppName, ibcexported.ModuleName, types.SubModuleName),
220+
Args: cobra.ExactArgs(1),
221+
RunE: func(cmd *cobra.Command, args []string) error {
222+
clientCtx, err := client.GetClientQueryContext(cmd)
223+
if err != nil {
224+
return err
225+
}
226+
clientID := args[0]
227+
228+
queryClient := types.NewQueryClient(clientCtx)
229+
230+
req := &types.QueryClientRequest{ClientId: clientID}
231+
232+
res, err := queryClient.Client(cmd.Context(), req)
233+
if err != nil {
234+
return err
235+
}
236+
237+
return clientCtx.PrintProto(res)
238+
},
239+
}
240+
flags.AddQueryFlagsToCmd(cmd)
241+
242+
return cmd
243+
}
244+
213245
// GetCmdQueryConsensusState defines the command to query the consensus state of
214246
// the chain as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-002-client-semantics#query
215247
func GetCmdQueryConsensusState() *cobra.Command {

0 commit comments

Comments
 (0)