2020-06-15 16:01:58 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2024-02-27 19:40:52 +00:00
|
|
|
"context"
|
2020-06-15 16:01:58 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
2020-06-15 16:01:58 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/validator-vesting/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetQueryCmd returns the cli query commands for the kavadist module
|
2022-01-08 00:39:27 +00:00
|
|
|
func GetQueryCmd() *cobra.Command {
|
2020-06-15 16:01:58 +00:00
|
|
|
valVestingQueryCmd := &cobra.Command{
|
|
|
|
Use: types.QueryPath,
|
|
|
|
Short: "Querying commands for the validator vesting module",
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
cmds := []*cobra.Command{
|
|
|
|
queryCirculatingSupply(),
|
|
|
|
queryTotalSupply(),
|
|
|
|
queryCirculatingSupplyHARD(),
|
|
|
|
queryCirculatingSupplyUSDX(),
|
|
|
|
queryCirculatingSupplySWP(),
|
|
|
|
queryTotalSupplyHARD(),
|
|
|
|
queryTotalSupplyUSDX(),
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, cmd := range cmds {
|
|
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
|
|
}
|
2020-06-15 16:01:58 +00:00
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
valVestingQueryCmd.AddCommand(cmds...)
|
2020-06-15 16:01:58 +00:00
|
|
|
return valVestingQueryCmd
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
func queryCirculatingSupply() *cobra.Command {
|
2020-06-15 16:01:58 +00:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "circulating-supply",
|
|
|
|
Short: "Get circulating supply",
|
|
|
|
Long: "Get the current circulating supply of kava tokens",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
cliCtx, err := client.GetClientQueryContext(cmd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-06-15 16:01:58 +00:00
|
|
|
|
2024-02-27 19:40:52 +00:00
|
|
|
queryClient := types.NewQueryClient(cliCtx)
|
|
|
|
res, err := queryClient.CirculatingSupply(context.Background(), &types.QueryCirculatingSupplyRequest{})
|
2020-06-15 16:01:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-27 19:40:52 +00:00
|
|
|
return cliCtx.PrintString(res.Amount.String())
|
2020-06-15 16:01:58 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
func queryTotalSupply() *cobra.Command {
|
2020-06-15 16:01:58 +00:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "total-supply",
|
|
|
|
Short: "Get total supply",
|
|
|
|
Long: "Get the current total supply of kava tokens",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
cliCtx, err := client.GetClientQueryContext(cmd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-27 19:40:52 +00:00
|
|
|
queryClient := types.NewQueryClient(cliCtx)
|
|
|
|
res, err := queryClient.TotalSupply(context.Background(), &types.QueryTotalSupplyRequest{})
|
2020-06-15 16:01:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-27 19:40:52 +00:00
|
|
|
return cliCtx.PrintString(res.Amount.String())
|
2020-06-15 16:01:58 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2020-11-12 21:48:20 +00:00
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
func queryCirculatingSupplyHARD() *cobra.Command {
|
2020-11-12 21:48:20 +00:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "circulating-supply-hard",
|
|
|
|
Short: "Get HARD circulating supply",
|
|
|
|
Long: "Get the current circulating supply of HARD tokens",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
cliCtx, err := client.GetClientQueryContext(cmd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-12 21:48:20 +00:00
|
|
|
|
2024-02-27 19:40:52 +00:00
|
|
|
queryClient := types.NewQueryClient(cliCtx)
|
|
|
|
res, err := queryClient.CirculatingSupplyHARD(context.Background(), &types.QueryCirculatingSupplyHARDRequest{})
|
2020-11-12 21:48:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-27 19:40:52 +00:00
|
|
|
return cliCtx.PrintString(res.Amount.String())
|
2020-11-12 21:48:20 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
func queryCirculatingSupplyUSDX() *cobra.Command {
|
2020-11-12 21:48:20 +00:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "circulating-supply-usdx",
|
|
|
|
Short: "Get USDX circulating supply",
|
|
|
|
Long: "Get the current circulating supply of USDX tokens",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
cliCtx, err := client.GetClientQueryContext(cmd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-12 21:48:20 +00:00
|
|
|
|
2024-02-27 19:40:52 +00:00
|
|
|
queryClient := types.NewQueryClient(cliCtx)
|
|
|
|
res, err := queryClient.CirculatingSupplyUSDX(context.Background(), &types.QueryCirculatingSupplyUSDXRequest{})
|
2020-11-12 21:48:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-27 19:40:52 +00:00
|
|
|
return cliCtx.PrintString(res.Amount.String())
|
2020-11-12 21:48:20 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
func queryCirculatingSupplySWP() *cobra.Command {
|
2021-09-01 15:21:31 +00:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "circulating-supply-swp",
|
|
|
|
Short: "Get SWP circulating supply",
|
|
|
|
Long: "Get the current circulating supply of SWP tokens",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
cliCtx, err := client.GetClientQueryContext(cmd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-09-01 15:21:31 +00:00
|
|
|
|
2024-02-27 19:40:52 +00:00
|
|
|
queryClient := types.NewQueryClient(cliCtx)
|
|
|
|
res, err := queryClient.CirculatingSupplySWP(context.Background(), &types.QueryCirculatingSupplySWPRequest{})
|
2021-09-01 15:21:31 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-27 19:40:52 +00:00
|
|
|
return cliCtx.PrintString(res.Amount.String())
|
2021-09-01 15:21:31 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
func queryTotalSupplyHARD() *cobra.Command {
|
2020-11-12 21:48:20 +00:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "total-supply-hard",
|
|
|
|
Short: "Get HARD total supply",
|
|
|
|
Long: "Get the current total supply of HARD tokens",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
cliCtx, err := client.GetClientQueryContext(cmd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-12 21:48:20 +00:00
|
|
|
|
2024-02-27 19:40:52 +00:00
|
|
|
queryClient := types.NewQueryClient(cliCtx)
|
|
|
|
res, err := queryClient.TotalSupplyHARD(context.Background(), &types.QueryTotalSupplyHARDRequest{})
|
2020-11-12 21:48:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-27 19:40:52 +00:00
|
|
|
return cliCtx.PrintString(res.Amount.String())
|
2020-11-12 21:48:20 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
func queryTotalSupplyUSDX() *cobra.Command {
|
2020-11-12 21:48:20 +00:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "total-supply-usdx",
|
|
|
|
Short: "Get USDX total supply",
|
|
|
|
Long: "Get the current total supply of USDX tokens",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
cliCtx, err := client.GetClientQueryContext(cmd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-12 21:48:20 +00:00
|
|
|
|
2024-02-27 19:40:52 +00:00
|
|
|
queryClient := types.NewQueryClient(cliCtx)
|
|
|
|
res, err := queryClient.TotalSupplyUSDX(context.Background(), &types.QueryTotalSupplyUSDXRequest{})
|
2020-11-12 21:48:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-27 19:40:52 +00:00
|
|
|
return cliCtx.PrintString(res.Amount.String())
|
2020-11-12 21:48:20 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|