2020-08-17 17:09:02 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2022-01-08 00:39:27 +00:00
|
|
|
"context"
|
2020-08-17 17:09:02 +00:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
2020-08-17 17:09:02 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
|
|
|
2024-08-02 11:32:08 +00:00
|
|
|
"github.com/0glabs/0g-chain/x/issuance/types"
|
2020-08-17 17:09:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetQueryCmd returns the cli query commands for the issuance module
|
2022-01-08 00:39:27 +00:00
|
|
|
func GetQueryCmd() *cobra.Command {
|
2020-08-17 17:09:02 +00:00
|
|
|
issuanceQueryCmd := &cobra.Command{
|
|
|
|
Use: types.ModuleName,
|
|
|
|
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
cmds := []*cobra.Command{
|
|
|
|
GetCmdQueryParams(),
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, cmd := range cmds {
|
|
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
issuanceQueryCmd.AddCommand(cmds...)
|
2020-08-17 17:09:02 +00:00
|
|
|
|
|
|
|
return issuanceQueryCmd
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
// GetCmdQueryParams queries the issuance module parameters
|
|
|
|
func GetCmdQueryParams() *cobra.Command {
|
2020-08-17 17:09:02 +00:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "params",
|
|
|
|
Short: fmt.Sprintf("get the %s module parameters", types.ModuleName),
|
2022-01-08 00:39:27 +00:00
|
|
|
Long: "Get the current issuance module parameters.",
|
2020-08-17 17:09:02 +00:00
|
|
|
Args: cobra.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
2020-08-17 17:09:02 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
queryClient := types.NewQueryClient(clientCtx)
|
|
|
|
|
|
|
|
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-08-17 17:09:02 +00:00
|
|
|
}
|
2022-01-08 00:39:27 +00:00
|
|
|
|
|
|
|
return clientCtx.PrintProto(&res.Params)
|
2020-08-17 17:09:02 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|