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 +}