Skip to content

Commit 7de1880

Browse files
committed
fix: replace emptyAppOptions with tmpAppOptions and add tempDir helper logic
1 parent 84457b5 commit 7de1880

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

cmd/exrpd/cmd/root.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ import (
5050
"github.com/xrplevm/node/v10/app"
5151
)
5252

53-
type emptyAppOptions struct{}
54-
55-
func (ao emptyAppOptions) Get(_ string) interface{} { return nil }
53+
type tmpAppOptions struct{}
54+
55+
func (ao tmpAppOptions) Get(searchFlag string) interface{} {
56+
switch searchFlag {
57+
case flags.FlagHome:
58+
return tempDir(app.DefaultNodeHome)
59+
default:
60+
return nil
61+
}
62+
}
5663

5764
// NewRootCmd creates a new root command for a Cosmos SDK application
5865
func NewRootCmd() (*cobra.Command, sdktestutil.TestEncodingConfig) {
@@ -64,7 +71,7 @@ func NewRootCmd() (*cobra.Command, sdktestutil.TestEncodingConfig) {
6471
dbm.NewMemDB(),
6572
nil, true, nil,
6673
0,
67-
emptyAppOptions{},
74+
tmpAppOptions{},
6875
)
6976
encodingConfig := sdktestutil.TestEncodingConfig{
7077
InterfaceRegistry: tempApp.InterfaceRegistry(),
@@ -424,3 +431,13 @@ func getChainIDFromOpts(appOpts servertypes.AppOptions) (chainID string, err err
424431

425432
return
426433
}
434+
435+
func tempDir(defaultHome string) string {
436+
dir, err := os.MkdirTemp("", ".exrpd-tmp")
437+
if err != nil {
438+
dir = defaultHome
439+
}
440+
defer os.RemoveAll(dir)
441+
442+
return dir
443+
}

0 commit comments

Comments
 (0)