Merge pull request #958 from cosmos/cwgoes/export-genesis-file

Export all genesis information (closes #946)
This commit is contained in:
Rigel 2018-05-07 18:17:03 -04:00 committed by GitHub
commit 7f8734fab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -18,6 +18,7 @@ BREAKING CHANGES
FEATURES:
* Added `gaiad export` command, which exports genesis information & current state
* Gaia stake commands include, DeclareCandidacy, EditCandidacy, Delegate, Unbond
* MountStoreWithDB without providing a custom store works.
* Repo is now lint compliant / GoMetaLinter with tendermint-lint integrated into CI

View File

@ -8,6 +8,7 @@ import (
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/wire"
tmtypes "github.com/tendermint/tendermint/types"
)
// ExportCmd dumps app state to JSON
@ -21,7 +22,16 @@ func ExportCmd(ctx *Context, cdc *wire.Codec, appExporter AppExporter) *cobra.Co
if err != nil {
return errors.Errorf("Error exporting state: %v\n", err)
}
fmt.Println(string(appState))
doc, err := tmtypes.GenesisDocFromFile(ctx.Config.GenesisFile())
if err != nil {
return err
}
doc.AppStateJSON = appState
encoded, err := wire.MarshalJSONIndent(cdc, doc)
if err != nil {
return err
}
fmt.Println(string(encoded))
return nil
},
}