mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
573590a229
* hack to set tendermint config correctly * Revert "hack to set tendermint config correctly" This reverts commit d34150ab934ab018cc3e95ea9398f098c09e0c8e. * update cosmos-sdk to include env prefix fix
112 lines
3.5 KiB
Go
112 lines
3.5 KiB
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/config"
|
|
"github.com/cosmos/cosmos-sdk/client/debug"
|
|
"github.com/cosmos/cosmos-sdk/server"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
|
"github.com/spf13/cobra"
|
|
tmcli "github.com/tendermint/tendermint/libs/cli"
|
|
ethermintclient "github.com/tharsis/ethermint/client"
|
|
"github.com/tharsis/ethermint/crypto/hd"
|
|
ethermintserver "github.com/tharsis/ethermint/server"
|
|
servercfg "github.com/tharsis/ethermint/server/config"
|
|
|
|
"github.com/kava-labs/kava/app"
|
|
"github.com/kava-labs/kava/app/params"
|
|
kavaclient "github.com/kava-labs/kava/client"
|
|
"github.com/kava-labs/kava/migrate"
|
|
)
|
|
|
|
// EnvPrefix is the prefix environment variables must have to configure the app.
|
|
const EnvPrefix = "KAVA"
|
|
|
|
// NewRootCmd creates a new root command for the kava blockchain.
|
|
func NewRootCmd() *cobra.Command {
|
|
app.SetSDKConfig().Seal()
|
|
|
|
encodingConfig := app.MakeEncodingConfig()
|
|
|
|
initClientCtx := client.Context{}.
|
|
WithCodec(encodingConfig.Marshaler).
|
|
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
|
WithTxConfig(encodingConfig.TxConfig).
|
|
WithLegacyAmino(encodingConfig.Amino).
|
|
WithInput(os.Stdin).
|
|
WithAccountRetriever(types.AccountRetriever{}).
|
|
WithHomeDir(app.DefaultNodeHome).
|
|
WithKeyringOptions(hd.EthSecp256k1Option()).
|
|
WithViper(EnvPrefix)
|
|
|
|
rootCmd := &cobra.Command{
|
|
Use: "kava",
|
|
Short: "Daemon and CLI for the Kava blockchain.",
|
|
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
|
cmd.SetOut(cmd.OutOrStdout())
|
|
cmd.SetErr(cmd.ErrOrStderr())
|
|
|
|
initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
initClientCtx, err = config.ReadFromClientConfig(initClientCtx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err = client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
|
|
return err
|
|
}
|
|
|
|
customAppTemplate, customAppConfig := servercfg.AppConfig("ukava")
|
|
|
|
return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig)
|
|
},
|
|
}
|
|
|
|
addSubCmds(rootCmd, encodingConfig, app.DefaultNodeHome)
|
|
|
|
return rootCmd
|
|
}
|
|
|
|
// addSubCmds registers all the sub commands used by kava.
|
|
func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, defaultNodeHome string) {
|
|
rootCmd.AddCommand(
|
|
ethermintclient.ValidateChainID(
|
|
genutilcli.InitCmd(app.ModuleBasics, defaultNodeHome),
|
|
),
|
|
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome),
|
|
migrate.MigrateGenesisCmd(),
|
|
migrate.AssertInvariantsCmd(encodingConfig),
|
|
genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, defaultNodeHome),
|
|
genutilcli.ValidateGenesisCmd(app.ModuleBasics),
|
|
AddGenesisAccountCmd(defaultNodeHome),
|
|
tmcli.NewCompletionCmd(rootCmd, true), // TODO add other shells, drop tmcli dependency, unhide?
|
|
// testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), // TODO add
|
|
debug.Cmd(),
|
|
config.Cmd(),
|
|
)
|
|
|
|
ac := appCreator{
|
|
encodingConfig: encodingConfig,
|
|
}
|
|
|
|
// ethermintserver adds additional flags to start the JSON-RPC server for evm support
|
|
ethermintserver.AddCommands(rootCmd, defaultNodeHome, ac.newApp, ac.appExport, ac.addStartCmdFlags)
|
|
|
|
// add keybase, auxiliary RPC, query, and tx child commands
|
|
rootCmd.AddCommand(
|
|
StatusCommand(),
|
|
newQueryCmd(),
|
|
newTxCmd(),
|
|
kavaclient.KeyCommands(app.DefaultNodeHome),
|
|
)
|
|
}
|