Skip to content

Commit

Permalink
Merge pull request #337 from CosmWasm/export_home_334
Browse files Browse the repository at this point in the history
Fix home dir issue in export command
  • Loading branch information
alpe authored Dec 14, 2020
2 parents ae169ce + 06f42c5 commit 9e2a97e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/wasmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -108,7 +109,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) {
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
rootCmd.AddCommand(
Expand Down Expand Up @@ -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,
appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) {

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 {
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 {
return servertypes.ExportedApp{}, err
}
} 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)
Expand Down

0 comments on commit 9e2a97e

Please sign in to comment.