mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 15:55:18 +00:00
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
|
package cli
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/spf13/cobra"
|
||
|
|
||
|
"github.com/cosmos/cosmos-sdk/client"
|
||
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||
|
|
||
|
"github.com/kava-labs/kava/x/savings/types"
|
||
|
)
|
||
|
|
||
|
// GetQueryCmd returns the cli query commands for this module
|
||
|
func GetQueryCmd() *cobra.Command {
|
||
|
savingsQueryCmd := &cobra.Command{
|
||
|
Use: types.ModuleName,
|
||
|
Short: "Querying commands for the savings module",
|
||
|
DisableFlagParsing: true,
|
||
|
SuggestionsMinimumDistance: 2,
|
||
|
RunE: client.ValidateCmd,
|
||
|
}
|
||
|
|
||
|
cmds := []*cobra.Command{
|
||
|
GetCmdQueryParams(),
|
||
|
}
|
||
|
|
||
|
for _, cmd := range cmds {
|
||
|
flags.AddQueryFlagsToCmd(cmd)
|
||
|
}
|
||
|
|
||
|
savingsQueryCmd.AddCommand(cmds...)
|
||
|
|
||
|
return savingsQueryCmd
|
||
|
}
|
||
|
|
||
|
// GetCmdQueryParams queries the savings module parameters
|
||
|
func GetCmdQueryParams() *cobra.Command {
|
||
|
return &cobra.Command{
|
||
|
Use: "params",
|
||
|
Short: "get the savings module parameters",
|
||
|
Long: "Get the current global savings module parameters.",
|
||
|
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)
|
||
|
},
|
||
|
}
|
||
|
}
|