2020-02-25 15:29:54 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-04-04 23:26:15 +00:00
|
|
|
"github.com/kava-labs/kava/x/validator-vesting/types"
|
2020-02-25 15:29:54 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetQueryCmd returns the cli query commands for this module
|
|
|
|
func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
|
|
|
// Group nameservice queries under a subcommand
|
|
|
|
queryValidatorVestingCmd := &cobra.Command{
|
|
|
|
Use: "validator-vesting",
|
|
|
|
Short: "Querying commands for the validator vesting module",
|
|
|
|
}
|
|
|
|
|
|
|
|
queryValidatorVestingCmd.AddCommand(client.GetCommands(
|
|
|
|
QueryCirculatingSupplyCmd(queryRoute, cdc),
|
|
|
|
QueryTotalSupplyCmd(queryRoute, cdc),
|
|
|
|
)...)
|
|
|
|
return queryValidatorVestingCmd
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryCirculatingSupplyCmd queries the total circulating supply
|
|
|
|
func QueryCirculatingSupplyCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
|
|
|
return &cobra.Command{
|
|
|
|
Use: "circulating-supply",
|
|
|
|
Short: "Query circulating supply information",
|
|
|
|
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
|
|
|
|
|
|
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryCirculatingSupply), nil)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("could not get total circulating supply\n")
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-02-25 23:03:40 +00:00
|
|
|
var out int64
|
2020-02-25 15:29:54 +00:00
|
|
|
cdc.MustUnmarshalJSON(res, &out)
|
|
|
|
return cliCtx.PrintOutput(out)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryTotalSupplyCmd queries the total supply of ukava
|
|
|
|
func QueryTotalSupplyCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
|
|
|
return &cobra.Command{
|
|
|
|
Use: "total-supply",
|
|
|
|
Short: "Query total supply information",
|
|
|
|
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
|
|
|
|
|
|
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryTotalSupply), nil)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("could not get total supply\n")
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-02-25 23:03:40 +00:00
|
|
|
var out int64
|
2020-02-25 15:29:54 +00:00
|
|
|
cdc.MustUnmarshalJSON(res, &out)
|
|
|
|
return cliCtx.PrintOutput(out)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|