feat: parse home flag earlier (#20771)
This commit is contained in:
@@ -3,7 +3,6 @@ package cmd
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -18,7 +17,6 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/debug"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||
"github.com/cosmos/cosmos-sdk/client/pruning"
|
||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||
@@ -143,13 +141,6 @@ func appExport(
|
||||
appOpts servertypes.AppOptions,
|
||||
modulesToExport []string,
|
||||
) (servertypes.ExportedApp, error) {
|
||||
// this check is necessary as we use the flag in x/upgrade.
|
||||
// we can exit more gracefully by checking the flag here.
|
||||
homePath, ok := appOpts.Get(flags.FlagHome).(string)
|
||||
if !ok || homePath == "" {
|
||||
return servertypes.ExportedApp{}, errors.New("application home not set")
|
||||
}
|
||||
|
||||
viperAppOpts, ok := appOpts.(*viper.Viper)
|
||||
if !ok {
|
||||
return servertypes.ExportedApp{}, errors.New("appOpts is not viper.Viper")
|
||||
@@ -172,13 +163,3 @@ func appExport(
|
||||
|
||||
return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
|
||||
}
|
||||
|
||||
var tempDir = func() string {
|
||||
dir, err := os.MkdirTemp("", "simapp")
|
||||
if err != nil {
|
||||
dir = simapp.DefaultNodeHome
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
return dir
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
func NewRootCmd() *cobra.Command {
|
||||
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
|
||||
// note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go)
|
||||
tempApp := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir()))
|
||||
tempApp := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome))
|
||||
encodingConfig := params.EncodingConfig{
|
||||
InterfaceRegistry: tempApp.InterfaceRegistry(),
|
||||
Codec: tempApp.AppCodec(),
|
||||
@@ -114,7 +114,7 @@ func NewRootCmd() *cobra.Command {
|
||||
// autocli opts
|
||||
customClientTemplate, customClientConfig := initClientConfig()
|
||||
var err error
|
||||
initClientCtx, err = config.ReadDefaultValuesFromDefaultClientConfig(initClientCtx, customClientTemplate, customClientConfig)
|
||||
initClientCtx, err = config.CreateClientConfig(initClientCtx, customClientTemplate, customClientConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
)
|
||||
|
||||
@@ -38,10 +37,7 @@ func NewRootCmd() *cobra.Command {
|
||||
|
||||
if err := depinject.Inject(
|
||||
depinject.Configs(simapp.AppConfig(),
|
||||
depinject.Supply(
|
||||
log.NewNopLogger(),
|
||||
simtestutil.NewAppOptionsWithFlagHome(tempDir()),
|
||||
),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
depinject.Provide(
|
||||
ProvideClientContext,
|
||||
),
|
||||
@@ -128,7 +124,7 @@ func ProvideClientContext(
|
||||
|
||||
// Read the config to overwrite the default values with the values from the config file
|
||||
customClientTemplate, customClientConfig := initClientConfig()
|
||||
clientCtx, err = config.ReadDefaultValuesFromDefaultClientConfig(clientCtx, customClientTemplate, customClientConfig)
|
||||
clientCtx, err = config.CreateClientConfig(clientCtx, customClientTemplate, customClientConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user