forked from cerc-io/laconicd-deprecated
0351bef644
* testnet faucet * commands * updates * faucet module * genesis state * fixes * module.go * add module to app * update Fund * querier route * querier * CLI query * fix query * add rest routes * update cli query
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/ethermint/x/faucet/types"
|
|
)
|
|
|
|
// GetQueryCmd defines evm module queries through the cli
|
|
func GetQueryCmd(cdc *codec.Codec) *cobra.Command {
|
|
faucetQueryCmd := &cobra.Command{
|
|
Use: types.ModuleName,
|
|
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: client.ValidateCmd,
|
|
}
|
|
faucetQueryCmd.AddCommand(flags.GetCommands(
|
|
GetCmdFunded(cdc),
|
|
)...)
|
|
return faucetQueryCmd
|
|
}
|
|
|
|
// GetCmdFunded queries the total amount funded by the faucet.
|
|
func GetCmdFunded(cdc *codec.Codec) *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "funded",
|
|
Short: "Gets storage for an account at a given key",
|
|
Args: cobra.NoArgs,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
|
|
res, height, err := cliCtx.Query(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryFunded))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var out sdk.Coins
|
|
cdc.MustUnmarshalJSON(res, &out)
|
|
cliCtx = cliCtx.WithHeight(height)
|
|
return cliCtx.PrintOutput(out)
|
|
},
|
|
}
|
|
}
|