diff --git a/protocol/cmd/dydxprotocold/cmd/root.go b/protocol/cmd/dydxprotocold/cmd/root.go index 82a5adfe9f7..801ccbc813b 100644 --- a/protocol/cmd/dydxprotocold/cmd/root.go +++ b/protocol/cmd/dydxprotocold/cmd/root.go @@ -61,11 +61,9 @@ const ( // TODO(DEC-1097): improve `cmd/` by adding tests, custom app configs, custom init cmd, and etc. func NewRootCmd( option *RootCmdOption, - homeDir string, ) *cobra.Command { return NewRootCmdWithInterceptors( option, - homeDir, func(serverCtxPtr *server.Context) { }, @@ -80,7 +78,6 @@ func NewRootCmd( func NewRootCmdWithInterceptors( option *RootCmdOption, - homeDir string, serverCtxInterceptor func(serverCtxPtr *server.Context), appConfigInterceptor func(string, *DydxAppConfig) (string, *DydxAppConfig), appInterceptor func(app *dydxapp.App) *dydxapp.App, @@ -106,7 +103,7 @@ func NewRootCmdWithInterceptors( WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). WithBroadcastMode(flags.BroadcastSync). - WithHomeDir(homeDir). + WithHomeDir(tempDir()). WithViper(EnvPrefix) rootCmd := &cobra.Command{ @@ -164,6 +161,7 @@ func NewRootCmdWithInterceptors( if err != nil { panic(err) } + initClientCtx.HomeDir = "" if err := autoCliOpts(tempApp, initClientCtx).EnhanceRootCommand(rootCmd); err != nil { panic(err) } @@ -423,3 +421,13 @@ func appExport( return dydxApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } + +var tempDir = func() string { + dir, err := os.MkdirTemp("", "dydxprotocol") + if err != nil { + dir = dydxapp.DefaultNodeHome + } + defer os.RemoveAll(dir) + + return dir +} diff --git a/protocol/cmd/dydxprotocold/main.go b/protocol/cmd/dydxprotocold/main.go index a17b70d60dc..76cc794aa34 100644 --- a/protocol/cmd/dydxprotocold/main.go +++ b/protocol/cmd/dydxprotocold/main.go @@ -14,7 +14,7 @@ func main() { config.SetupConfig() option := cmd.GetOptionWithCustomStartCmd() - rootCmd := cmd.NewRootCmd(option, app.DefaultNodeHome) + rootCmd := cmd.NewRootCmd(option) cmd.AddTendermintSubcommands(rootCmd) cmd.AddInitCmdPostRunE(rootCmd)