From 21c3e3806b8cbbf6b0df767c64b66f2bc68c5af3 Mon Sep 17 00:00:00 2001 From: Puneet <59960662+puneet2019@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:39:18 +0530 Subject: [PATCH] query for singular host-chain (#756) --- x/liquidstakeibc/client/query.go | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/x/liquidstakeibc/client/query.go b/x/liquidstakeibc/client/query.go index 36b9ddfa5..d6a7fe423 100644 --- a/x/liquidstakeibc/client/query.go +++ b/x/liquidstakeibc/client/query.go @@ -29,6 +29,7 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand( QueryParamsCmd(), QueryHostChainsCmd(), + QueryHostChainCmd(), QueryDepositsCmd(), QueryLSMDepositsCmd(), QueryUnbondingsCmd(), @@ -112,6 +113,41 @@ func QueryHostChainsCmd() *cobra.Command { return cmd } +// QueryHostChainCmd returns the registered host chain. +func QueryHostChainCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "host-chain [chain-id]", + Aliases: []string{"hc"}, + Short: "Query registered host chain with chain-id ", + Args: cobra.ExactArgs(1), + Long: strings.TrimSpace( + fmt.Sprintf( + `Query the current registered host chains: $ %s query liquidstakeibc host-chains`, + version.AppName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.HostChain(cmd.Context(), &types.QueryHostChainRequest{ChainId: args[0]}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + // QueryDepositsCmd returns all user deposits. func QueryDepositsCmd() *cobra.Command { cmd := &cobra.Command{