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.
- Loading branch information
Showing
4 changed files
with
58 additions
and
249 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,77 +1,88 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/tendermint/tmlibs/cli" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/keys" | ||
"github.com/cosmos/cosmos-sdk/client/lcd" | ||
"github.com/cosmos/cosmos-sdk/client/rpc" | ||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
|
||
"github.com/cosmos/cosmos-sdk/version" | ||
) | ||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/commands" | ||
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/commands" | ||
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/commands" | ||
simplestakingcmd "github.com/cosmos/cosmos-sdk/x/simplestake/commands" | ||
|
||
const ( | ||
flagTo = "to" | ||
flagAmount = "amount" | ||
flagFee = "fee" | ||
"github.com/cosmos/cosmos-sdk/examples/basecoin/app" | ||
"github.com/cosmos/cosmos-sdk/examples/basecoin/types" | ||
) | ||
|
||
// TODO: distinguish from basecli | ||
|
||
// rootCmd is the entry point for this binary | ||
var ( | ||
rootCmd = &cobra.Command{ | ||
Use: "gaiacli", | ||
Short: "Gaia light-client", | ||
} | ||
|
||
lineBreak = &cobra.Command{Run: func(*cobra.Command, []string) {}} | ||
|
||
getAccountCmd = &cobra.Command{ | ||
Use: "account <address>", | ||
Short: "Query account balance", | ||
RunE: todoNotImplemented, | ||
} | ||
) | ||
|
||
func todoNotImplemented(_ *cobra.Command, _ []string) error { | ||
return errors.New("TODO: Command not yet implemented") | ||
} | ||
|
||
func postSendCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "send", | ||
Short: "Create and sign a send tx", | ||
RunE: todoNotImplemented, | ||
} | ||
cmd.Flags().String(flagTo, "", "Address to send coins") | ||
cmd.Flags().String(flagAmount, "", "Amount of coins to send") | ||
cmd.Flags().String(flagFee, "", "Fee to pay along with transaction") | ||
return cmd | ||
} | ||
|
||
func main() { | ||
// disable sorting | ||
cobra.EnableCommandSorting = false | ||
|
||
// generic client commands | ||
AddClientCommands(rootCmd) | ||
// query commands (custom to binary) | ||
// get the codec | ||
cdc := app.MakeCodec() | ||
|
||
// TODO: setup keybase, viper object, etc. to be passed into | ||
// the below functions and eliminate global vars, like we do | ||
// with the cdc | ||
|
||
// add standard rpc, and tx commands | ||
rpc.AddCommands(rootCmd) | ||
rootCmd.AddCommand(client.LineBreak) | ||
tx.AddCommands(rootCmd, cdc) | ||
rootCmd.AddCommand(client.LineBreak) | ||
|
||
// add query/post commands (custom to binary) | ||
rootCmd.AddCommand( | ||
client.GetCommands( | ||
authcmd.GetAccountCmd("main", cdc, types.GetAccountDecoder(cdc)), | ||
)...) | ||
rootCmd.AddCommand( | ||
client.PostCommands( | ||
bankcmd.SendTxCmd(cdc), | ||
)...) | ||
rootCmd.AddCommand( | ||
client.PostCommands( | ||
ibccmd.IBCTransferCmd(cdc), | ||
)...) | ||
rootCmd.AddCommand( | ||
GetCommands(getAccountCmd)...) | ||
// post tx commands (custom to binary) | ||
client.PostCommands( | ||
ibccmd.IBCRelayCmd(cdc), | ||
simplestakingcmd.BondTxCmd(cdc), | ||
)...) | ||
rootCmd.AddCommand( | ||
PostCommands(postSendCommand())...) | ||
client.PostCommands( | ||
simplestakingcmd.UnbondTxCmd(cdc), | ||
)...) | ||
|
||
// add proxy, version and key info | ||
rootCmd.AddCommand( | ||
lineBreak, | ||
serveCommand(), | ||
KeyCommands(), | ||
lineBreak, | ||
client.LineBreak, | ||
lcd.ServeCommand(cdc), | ||
keys.Commands(), | ||
client.LineBreak, | ||
version.VersionCmd, | ||
) | ||
|
||
// prepare and add flags | ||
executor := cli.PrepareBaseCmd(rootCmd, "GA", os.ExpandEnv("$HOME/.gaiacli")) | ||
executor := cli.PrepareMainCmd(rootCmd, "BC", os.ExpandEnv("$HOME/.gaiacli")) | ||
executor.Execute() | ||
} |