From 203d2c19ccf95a48ffa0dd939bfed7b1d6fae756 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Tue, 24 Apr 2018 15:26:28 +0200 Subject: [PATCH] Add export command to stake module --- x/stake/commands/export.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 x/stake/commands/export.go diff --git a/x/stake/commands/export.go b/x/stake/commands/export.go new file mode 100644 index 0000000000..f3d1516d53 --- /dev/null +++ b/x/stake/commands/export.go @@ -0,0 +1,30 @@ +package commands + +import ( + "fmt" + + "github.com/spf13/cobra" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/wire" // XXX fix + "github.com/cosmos/cosmos-sdk/x/stake" +) + +// get the command to export state +func GetCmdExport(load func() (stake.Keeper, sdk.Context), cdc *wire.Codec) *cobra.Command { + cmd := &cobra.Command{ + Use: "export", + Short: "Export stake module state as JSON to stdout", + RunE: func(cmd *cobra.Command, args []string) error { + keeper, ctx := load() + genesis := keeper.WriteGenesis(ctx) + output, err := wire.MarshalJSONIndent(cdc, genesis) + if err != nil { + return err + } + fmt.Println(string(output)) + return nil + }, + } + return cmd +}