mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
a573625df8
* bump SDK version to v0.38.3 Co-authored-by: Denali Marsh <denali@kava.io> Co-authored-by: Kevin Davis <kjydavis3@gmail.com> Co-authored-by: Kevin Davis <karzak@users.noreply.github.com> Co-authored-by: denalimarsh <denalimarsh@gmail.com> Co-authored-by: rhuairahrighairigh <ruaridh.odonnell@gmail.com>
73 lines
2.0 KiB
Go
73 lines
2.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/kava-labs/kava/x/validator-vesting/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"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(flags.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
|
|
}
|
|
|
|
var out int64
|
|
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
|
|
}
|
|
|
|
var out int64
|
|
cdc.MustUnmarshalJSON(res, &out)
|
|
return cliCtx.PrintOutput(out)
|
|
},
|
|
}
|
|
}
|