0g-chain/x/evmutil/client/cli/query.go

64 lines
1.4 KiB
Go
Raw Normal View History

package cli
import (
"context"
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"
"github.com/kava-labs/kava/x/evmutil/types"
)
// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd() *cobra.Command {
evmutilQueryCmd := &cobra.Command{
Use: "evmutil",
Short: "Querying commands for the evmutil module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmds := []*cobra.Command{
QueryParamsCmd(),
}
for _, cmd := range cmds {
flags.AddQueryFlagsToCmd(cmd)
}
evmutilQueryCmd.AddCommand(cmds...)
return evmutilQueryCmd
}
// QueryParamsCmd queries the evmutil module parameters
func QueryParamsCmd() *cobra.Command {
return &cobra.Command{
Use: "params",
Short: "Query the evmutil module parameters",
Example: fmt.Sprintf(
"%[1]s q %[2]s params",
version.AppName, types.ModuleName,
),
Args: cobra.NoArgs,
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.Params(context.Background(), &types.QueryParamsRequest{})
if err != nil {
return err
}
return clientCtx.PrintProto(&res.Params)
},
}
}