Add cli to basecoind, fix compatability issues
This commit is contained in:
committed by
rigelrozanski
parent
c0f9a6f1cb
commit
4e91a0db89
@@ -1,27 +1,70 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/examples/basecoin/app"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("This is temporary, for unblocking our build process.")
|
||||
return
|
||||
// gaiadCmd is the entry point for this binary
|
||||
var (
|
||||
gaiadCmd = &cobra.Command{
|
||||
Use: "gaiad",
|
||||
Short: "Gaia Daemon (server)",
|
||||
}
|
||||
)
|
||||
|
||||
// TODO CREATE CLI
|
||||
// defaultOptions sets up the app_options for the
|
||||
// default genesis file
|
||||
func defaultOptions(args []string) (json.RawMessage, error) {
|
||||
addr, secret, err := server.GenerateCoinKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println("Secret phrase to access coins:")
|
||||
fmt.Println(secret)
|
||||
|
||||
opts := fmt.Sprintf(`{
|
||||
"accounts": [{
|
||||
"address": "%s",
|
||||
"coins": [
|
||||
{
|
||||
"denom": "mycoin",
|
||||
"amount": 9007199254740992
|
||||
}
|
||||
]
|
||||
}]
|
||||
}`, addr)
|
||||
return json.RawMessage(opts), nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "main")
|
||||
db, err := dbm.NewGoLevelDB("basecoind", "data")
|
||||
db, err := dbm.NewGoLevelDB("/tmp/basecoind", "data")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
bapp := app.NewBasecoinApp(logger, db)
|
||||
baseapp.RunForever(bapp)
|
||||
|
||||
gaiadCmd.AddCommand(
|
||||
server.InitCmd(defaultOptions),
|
||||
server.StartCmd(bapp, bapp.Logger),
|
||||
server.UnsafeResetAllCmd(bapp.Logger),
|
||||
version.VersionCmd,
|
||||
)
|
||||
|
||||
// prepare and add flags
|
||||
executor := cli.PrepareBaseCmd(gaiadCmd, "GA", os.ExpandEnv("$HOME/.gaiad"))
|
||||
executor.Execute()
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func main() {
|
||||
|
||||
gaiadCmd.AddCommand(
|
||||
server.InitCmd(defaultOptions),
|
||||
server.StartCmd(app),
|
||||
server.StartCmd(app, app.Logger),
|
||||
server.UnsafeResetAllCmd(app.Logger),
|
||||
version.VersionCmd,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user