Merge pull request #337 from CosmWasm/export_home_334
Fix home dir issue in export command
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -108,7 +109,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) {
|
|||||||
debug.Cmd(),
|
debug.Cmd(),
|
||||||
)
|
)
|
||||||
|
|
||||||
server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, createWasnAppAndExport, addModuleInitFlags)
|
server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, createWasmAppAndExport, addModuleInitFlags)
|
||||||
|
|
||||||
// add keybase, auxiliary RPC, query, and tx child commands
|
// add keybase, auxiliary RPC, query, and tx child commands
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
@@ -237,19 +238,23 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createWasnAppAndExport(
|
func createWasmAppAndExport(
|
||||||
logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string,
|
logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string,
|
||||||
appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) {
|
appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) {
|
||||||
|
|
||||||
var wasmApp *app.WasmApp
|
var wasmApp *app.WasmApp
|
||||||
|
homePath, ok := appOpts.Get(flags.FlagHome).(string)
|
||||||
|
if !ok || homePath == "" {
|
||||||
|
return servertypes.ExportedApp{}, errors.New("application home not set")
|
||||||
|
}
|
||||||
if height != -1 {
|
if height != -1 {
|
||||||
wasmApp = app.NewWasmApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), app.GetEnabledProposals(), appOpts)
|
wasmApp = app.NewWasmApp(logger, db, traceStore, false, map[int64]bool{}, homePath, uint(1), app.GetEnabledProposals(), appOpts)
|
||||||
|
|
||||||
if err := wasmApp.LoadHeight(height); err != nil {
|
if err := wasmApp.LoadHeight(height); err != nil {
|
||||||
return servertypes.ExportedApp{}, err
|
return servertypes.ExportedApp{}, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wasmApp = app.NewWasmApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), app.GetEnabledProposals(), appOpts)
|
wasmApp = app.NewWasmApp(logger, db, traceStore, true, map[int64]bool{}, homePath, uint(1), app.GetEnabledProposals(), appOpts)
|
||||||
}
|
}
|
||||||
|
|
||||||
return wasmApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
|
return wasmApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
|
||||||
|
|||||||
Reference in New Issue
Block a user