forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cli to basecoind, fix compatability issues
- Loading branch information
1 parent
c0f9a6f
commit 4e91a0d
Showing
3 changed files
with
62 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)", | ||
} | ||
) | ||
|
||
// 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 | ||
} | ||
|
||
// TODO CREATE CLI | ||
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters