Skip to content

Commit

Permalink
Add export command to stake module
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes committed Apr 24, 2018
1 parent cdd9977 commit 77843aa
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions x/stake/commands/export.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 77843aa

Please sign in to comment.