0g-chain/cmd/kvcli/main.go

163 lines
3.8 KiB
Go
Raw Normal View History

2018-05-25 13:46:33 +00:00
package main
import (
"github.com/spf13/cobra"
2018-08-14 22:13:54 +00:00
"github.com/tendermint/tendermint/libs/cli"
2018-05-25 13:46:33 +00:00
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/keys"
"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/client/cli"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
2018-08-14 22:13:54 +00:00
//govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
2018-06-18 14:49:09 +00:00
//ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
2018-08-14 22:13:54 +00:00
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
2018-07-15 14:08:08 +00:00
paychancmd "github.com/kava-labs/kava/internal/x/paychan/client/cmd"
2018-05-25 13:46:33 +00:00
2018-06-16 16:21:13 +00:00
"github.com/kava-labs/kava/internal/app"
2018-08-14 22:13:54 +00:00
//"github.com/kava-labs/kava/internal/lcd"
2018-05-25 13:46:33 +00:00
)
var (
rootCmd = &cobra.Command{
2018-06-16 21:34:07 +00:00
Use: "kvcli",
Short: "Kava Light-Client",
2018-05-25 13:46:33 +00:00
}
)
func main() {
cobra.EnableCommandSorting = false
// get the codec
2018-08-14 22:13:54 +00:00
cdc := app.CreateKavaAppCodec()
2018-05-25 13:46:33 +00:00
2018-08-14 22:13:54 +00:00
// add standard rpc commands
2018-05-25 13:46:33 +00:00
rpc.AddCommands(rootCmd)
2018-08-14 22:13:54 +00:00
//Add state commands
tendermintCmd := &cobra.Command{
Use: "tendermint",
Short: "Tendermint state querying subcommands",
}
tendermintCmd.AddCommand(
rpc.BlockCommand(),
rpc.ValidatorCommand(),
)
tx.AddCommands(tendermintCmd, cdc)
//Add IBC commands
// ibcCmd := &cobra.Command{
// Use: "ibc",
// Short: "Inter-Blockchain Communication subcommands",
// }
// ibcCmd.AddCommand(
// client.PostCommands(
// ibccmd.IBCTransferCmd(cdc),
// ibccmd.IBCRelayCmd(cdc),
// )...)
advancedCmd := &cobra.Command{
Use: "advanced",
Short: "Advanced subcommands",
}
advancedCmd.AddCommand(
tendermintCmd,
//ibcCmd,
//lcd.ServeCommand(cdc),
)
2018-05-25 13:46:33 +00:00
rootCmd.AddCommand(
2018-08-14 22:13:54 +00:00
advancedCmd,
client.LineBreak,
)
//Add stake commands
stakeCmd := &cobra.Command{
Use: "stake",
Short: "Stake and validation subcommands",
}
stakeCmd.AddCommand(
2018-05-25 13:46:33 +00:00
client.GetCommands(
2018-08-14 22:13:54 +00:00
stakecmd.GetCmdQueryValidator("stake", cdc),
stakecmd.GetCmdQueryValidators("stake", cdc),
stakecmd.GetCmdQueryDelegation("stake", cdc),
stakecmd.GetCmdQueryDelegations("stake", cdc),
slashingcmd.GetCmdQuerySigningInfo("slashing", cdc),
)...)
stakeCmd.AddCommand(
client.PostCommands(
stakecmd.GetCmdCreateValidator(cdc),
stakecmd.GetCmdEditValidator(cdc),
stakecmd.GetCmdDelegate(cdc),
stakecmd.GetCmdUnbond("stake", cdc),
stakecmd.GetCmdRedelegate("stake", cdc),
slashingcmd.GetCmdUnrevoke(cdc),
2018-05-25 13:46:33 +00:00
)...)
2018-08-14 22:13:54 +00:00
rootCmd.AddCommand(
stakeCmd,
)
//Add stake commands
// govCmd := &cobra.Command{
// Use: "gov",
// Short: "Governance and voting subcommands",
// }
// govCmd.AddCommand(
// client.GetCommands(
// govcmd.GetCmdQueryProposal("gov", cdc),
// govcmd.GetCmdQueryVote("gov", cdc),
// govcmd.GetCmdQueryVotes("gov", cdc),
// )...)
// govCmd.AddCommand(
// client.PostCommands(
// govcmd.GetCmdSubmitProposal(cdc),
// govcmd.GetCmdDeposit(cdc),
// govcmd.GetCmdVote(cdc),
// )...)
// rootCmd.AddCommand(
// govCmd,
// )
2018-05-25 13:46:33 +00:00
2018-08-14 22:13:54 +00:00
//Add auth and bank commands
rootCmd.AddCommand(
client.GetCommands(
authcmd.GetAccountCmd("acc", cdc, authcmd.GetAccountDecoder(cdc)),
)...)
2018-05-25 13:46:33 +00:00
rootCmd.AddCommand(
2018-07-08 22:09:07 +00:00
client.PostCommands( // this just wraps the input cmds with common flags
2018-05-25 13:46:33 +00:00
bankcmd.SendTxCmd(cdc),
)...)
2018-07-14 22:27:56 +00:00
paychanCmd := &cobra.Command{
Use: "paychan",
Short: "Payment channel subcommands",
}
2018-07-15 14:08:08 +00:00
paychanCmd.AddCommand(
2018-07-14 22:27:56 +00:00
client.PostCommands(
paychancmd.CreatePaychanCmd(cdc),
paychancmd.GenerateNewStateCmd(cdc),
paychancmd.ClosePaychanCmd(cdc),
)...)
rootCmd.AddCommand(
paychanCmd,
)
2018-05-25 13:46:33 +00:00
// add proxy, version and key info
rootCmd.AddCommand(
keys.Commands(),
client.LineBreak,
version.VersionCmd,
)
// prepare and add flags
2018-08-14 22:13:54 +00:00
executor := cli.PrepareMainCmd(rootCmd, "KV", app.DefaultCLIHome)
err := executor.Execute()
if err != nil {
panic(err)
}
2018-05-25 13:46:33 +00:00
}