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

feat(02-client/cli): add query for client counterparty. #7235

Merged
merged 3 commits into from
Sep 4, 2024
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 modules/core/02-client/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdQueryConsensusStateHeights(),
GetCmdQueryConsensusState(),
GetCmdQueryHeader(),
GetCmdQueryClient(),
GetCmdSelfConsensusState(),
GetCmdClientParams(),
)
Expand Down
32 changes: 32 additions & 0 deletions modules/core/02-client/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,38 @@ func GetCmdQueryConsensusStateHeights() *cobra.Command {
return cmd
}

// GetCmdQueryClient defines the command to query the client information (creator and counterparty) for the given client ID.
func GetCmdQueryClient() *cobra.Command {
cmd := &cobra.Command{
Use: "client [client-id]",
Short: "Query the information of a client.",
Long: "Query the client information (creator and counterparty) for the provided client ID.",
Example: fmt.Sprintf("%s query %s %s client [client-id]", version.AppName, ibcexported.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.QueryClientRequest{ClientId: clientID}

res, err := queryClient.Client(cmd.Context(), req)
if err != nil {
return err
}
Comment on lines +228 to +235
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected naming here 😅

is this grpc supposed to be renamed to Counterparty at some point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with the CLI being named client initially but that created this command name of simd query ibc client client [client-id] which seemed off to me. If convention is to always mirror grpc, I'll just do the renames. I do think we should probs get a better name here


return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQueryConsensusState defines the command to query the consensus state of
// the chain as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-002-client-semantics#query
func GetCmdQueryConsensusState() *cobra.Command {
Expand Down
Loading