cosmos-sdk/x/mint/client/cli/query.go
Alexander Bezobchuk 0ccc48d2a3
CLI/Tests: Remove Fixtures (#6799)
* remove fixtures

* setup tests

* update x/mint

* cli: update x/staking commands

* tests: convert x/staking CLI tests

* tests: fix x/auth CLI tests

* cli updates

* fix buiild

* fix build

* Update x/gov/client/cli/cli_test.go

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>

* remove GenerateOrBroadcastTx

* move TestCLIQueryConn

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
2020-07-21 13:54:07 +00:00

127 lines
3.1 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/cosmos/cosmos-sdk/x/mint/types"
)
// GetQueryCmd returns the cli query commands for the minting module.
func GetQueryCmd() *cobra.Command {
mintingQueryCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Querying commands for the minting module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
mintingQueryCmd.AddCommand(
GetCmdQueryParams(),
GetCmdQueryInflation(),
GetCmdQueryAnnualProvisions(),
)
return mintingQueryCmd
}
// GetCmdQueryParams implements a command to return the current minting
// parameters.
func GetCmdQueryParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current minting parameters",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryParamsRequest{}
res, err := queryClient.Params(context.Background(), params)
if err != nil {
return err
}
return clientCtx.PrintOutput(res.GetParams())
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
// GetCmdQueryInflation implements a command to return the current minting
// inflation value.
func GetCmdQueryInflation() *cobra.Command {
cmd := &cobra.Command{
Use: "inflation",
Short: "Query the current minting inflation value",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryInflationRequest{}
res, err := queryClient.Inflation(context.Background(), params)
if err != nil {
return err
}
return clientCtx.PrintOutput(res.Inflation)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
// GetCmdQueryAnnualProvisions implements a command to return the current minting
// annual provisions value.
func GetCmdQueryAnnualProvisions() *cobra.Command {
cmd := &cobra.Command{
Use: "annual-provisions",
Short: "Query the current minting annual provisions value",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryAnnualProvisionsRequest{}
res, err := queryClient.AnnualProvisions(context.Background(), params)
if err != nil {
return err
}
return clientCtx.PrintOutput(res.AnnualProvisions)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}