forked from cerc-io/laconicd-deprecated
261f86fdf2
* bump sdk version to v0.39.0 candidate * updates * update evm * bump commit * more changes * build * genesis * fix tests * fix tests * bump commit * bump commit * bump commit * add keygen func * bump version to 0.39.0-rc0 * update AnteHandler * fix TxDecoder * lint * fix test * update statedb * changelog * fixes * remove extra files * update make test-import * rename test * bump SDK version to final release * update to 0.39.1-rc1 * fix evm tests * update RPC * minor fixes * update to rc2 * bump to v0.39.1 * fix personal API * fix string type cast ambiguity (#449) * init * fix estimate gas test * minor genesis change * remove comments from unstable commit (stargate release) Co-authored-by: Alessio Treglia <quadrispro@ubuntu.com>
140 lines
3.5 KiB
Go
140 lines
3.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
tmamino "github.com/tendermint/tendermint/crypto/encoding/amino"
|
|
"github.com/tendermint/tendermint/libs/cli"
|
|
|
|
sdkclient "github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
|
clientrpc "github.com/cosmos/cosmos-sdk/client/rpc"
|
|
sdkcodec "github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/version"
|
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
|
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
|
|
|
"github.com/cosmos/ethermint/app"
|
|
"github.com/cosmos/ethermint/client"
|
|
"github.com/cosmos/ethermint/codec"
|
|
"github.com/cosmos/ethermint/crypto"
|
|
"github.com/cosmos/ethermint/rpc"
|
|
ethermint "github.com/cosmos/ethermint/types"
|
|
)
|
|
|
|
var (
|
|
cdc = codec.MakeCodec(app.ModuleBasics)
|
|
)
|
|
|
|
func main() {
|
|
// Configure cobra to sort commands
|
|
cobra.EnableCommandSorting = false
|
|
|
|
tmamino.RegisterKeyType(crypto.PubKeySecp256k1{}, crypto.PubKeyAminoName)
|
|
tmamino.RegisterKeyType(crypto.PrivKeySecp256k1{}, crypto.PrivKeyAminoName)
|
|
|
|
keys.CryptoCdc = cdc
|
|
clientkeys.KeysCdc = cdc
|
|
|
|
// Read in the configuration file for the sdk
|
|
config := sdk.GetConfig()
|
|
ethermint.SetBech32Prefixes(config)
|
|
config.Seal()
|
|
|
|
rootCmd := &cobra.Command{
|
|
Use: "ethermintcli",
|
|
Short: "Command line interface for interacting with ethermintd",
|
|
}
|
|
|
|
// Add --chain-id to persistent flags and mark it required
|
|
rootCmd.PersistentFlags().String(flags.FlagChainID, "", "Chain ID of tendermint node")
|
|
rootCmd.PersistentPreRunE = func(_ *cobra.Command, _ []string) error {
|
|
return client.InitConfig(rootCmd)
|
|
}
|
|
|
|
// Construct Root Command
|
|
rootCmd.AddCommand(
|
|
clientrpc.StatusCommand(),
|
|
sdkclient.ConfigCmd(app.DefaultCLIHome),
|
|
queryCmd(cdc),
|
|
txCmd(cdc),
|
|
rpc.EmintServeCmd(cdc),
|
|
flags.LineBreak,
|
|
client.KeyCommands(),
|
|
flags.LineBreak,
|
|
version.Cmd,
|
|
flags.NewCompletionCmd(rootCmd, true),
|
|
)
|
|
|
|
// Add flags and prefix all env exposed with EM
|
|
executor := cli.PrepareMainCmd(rootCmd, "EM", app.DefaultCLIHome)
|
|
|
|
err := executor.Execute()
|
|
if err != nil {
|
|
panic(fmt.Errorf("failed executing CLI command: %w", err))
|
|
}
|
|
}
|
|
|
|
func queryCmd(cdc *sdkcodec.Codec) *cobra.Command {
|
|
queryCmd := &cobra.Command{
|
|
Use: "query",
|
|
Aliases: []string{"q"},
|
|
Short: "Querying subcommands",
|
|
}
|
|
|
|
queryCmd.AddCommand(
|
|
authcmd.GetAccountCmd(cdc),
|
|
flags.LineBreak,
|
|
authcmd.QueryTxsByEventsCmd(cdc),
|
|
authcmd.QueryTxCmd(cdc),
|
|
flags.LineBreak,
|
|
)
|
|
|
|
// add modules' query commands
|
|
app.ModuleBasics.AddQueryCommands(queryCmd, cdc)
|
|
|
|
return queryCmd
|
|
}
|
|
|
|
func txCmd(cdc *sdkcodec.Codec) *cobra.Command {
|
|
txCmd := &cobra.Command{
|
|
Use: "tx",
|
|
Short: "Transactions subcommands",
|
|
}
|
|
|
|
txCmd.AddCommand(
|
|
bankcmd.SendTxCmd(cdc),
|
|
flags.LineBreak,
|
|
authcmd.GetSignCommand(cdc),
|
|
authcmd.GetMultiSignCommand(cdc),
|
|
flags.LineBreak,
|
|
authcmd.GetBroadcastCommand(cdc),
|
|
authcmd.GetEncodeCommand(cdc),
|
|
authcmd.GetDecodeCommand(cdc),
|
|
flags.LineBreak,
|
|
)
|
|
|
|
// add modules' tx commands
|
|
app.ModuleBasics.AddTxCommands(txCmd, cdc)
|
|
|
|
// remove auth and bank commands as they're mounted under the root tx command
|
|
var cmdsToRemove []*cobra.Command
|
|
|
|
for _, cmd := range txCmd.Commands() {
|
|
if cmd.Use == auth.ModuleName || cmd.Use == bank.ModuleName {
|
|
cmdsToRemove = append(cmdsToRemove, cmd)
|
|
}
|
|
}
|
|
|
|
txCmd.RemoveCommand(cmdsToRemove...)
|
|
|
|
return txCmd
|
|
}
|