Skip to content

Commit

Permalink
query for singular host-chain (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
puneet2019 authored Feb 2, 2024
1 parent c02835a commit 21c3e38
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions x/liquidstakeibc/client/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func NewQueryCmd() *cobra.Command {
cmd.AddCommand(
QueryParamsCmd(),
QueryHostChainsCmd(),
QueryHostChainCmd(),
QueryDepositsCmd(),
QueryLSMDepositsCmd(),
QueryUnbondingsCmd(),
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 21c3e38

Please sign in to comment.