laconicd/x/faucet/client/cli/query.go
Federico Kunze c8b8f49675
run make format (#351)
* run make format

* fix yaml

* fixes
2020-07-02 11:19:48 -04:00

54 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"
"github.com/cosmos/ethermint/x/faucet/types"
sdk "github.com/cosmos/cosmos-sdk/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)
},
}
}