Moved all commands into a subdir, for easier importing
This commit is contained in:
parent
6a3c91a7f2
commit
28f6a20a98
|
@ -1,226 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var (
|
||||
startCmd = cli.Command{
|
||||
Name: "start",
|
||||
Usage: "Start basecoin",
|
||||
ArgsUsage: "",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdStart(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
addrFlag,
|
||||
eyesFlag,
|
||||
dirFlag,
|
||||
inProcTMFlag,
|
||||
chainIDFlag,
|
||||
ibcPluginFlag,
|
||||
counterPluginFlag,
|
||||
},
|
||||
}
|
||||
|
||||
sendTxCmd = cli.Command{
|
||||
Name: "sendtx",
|
||||
Usage: "Broadcast a basecoin SendTx",
|
||||
ArgsUsage: "",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdSendTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
chainIDFlag,
|
||||
|
||||
fromFlag,
|
||||
|
||||
amountFlag,
|
||||
coinFlag,
|
||||
gasFlag,
|
||||
feeFlag,
|
||||
seqFlag,
|
||||
|
||||
toFlag,
|
||||
},
|
||||
}
|
||||
|
||||
appTxCmd = cli.Command{
|
||||
Name: "apptx",
|
||||
Usage: "Broadcast a basecoin AppTx",
|
||||
ArgsUsage: "",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdAppTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
chainIDFlag,
|
||||
|
||||
fromFlag,
|
||||
|
||||
amountFlag,
|
||||
coinFlag,
|
||||
gasFlag,
|
||||
feeFlag,
|
||||
seqFlag,
|
||||
|
||||
nameFlag,
|
||||
dataFlag,
|
||||
},
|
||||
Subcommands: []cli.Command{
|
||||
counterTxCmd,
|
||||
},
|
||||
}
|
||||
|
||||
counterTxCmd = cli.Command{
|
||||
Name: "counter",
|
||||
Usage: "Craft a transaction to the counter plugin",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdCounterTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
validFlag,
|
||||
},
|
||||
}
|
||||
|
||||
ibcCmd = cli.Command{
|
||||
Name: "ibc",
|
||||
Usage: "Send a transaction to the interblockchain (ibc) plugin",
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
chainIDFlag,
|
||||
|
||||
fromFlag,
|
||||
|
||||
amountFlag,
|
||||
coinFlag,
|
||||
gasFlag,
|
||||
feeFlag,
|
||||
seqFlag,
|
||||
|
||||
nameFlag,
|
||||
dataFlag,
|
||||
},
|
||||
Subcommands: []cli.Command{
|
||||
ibcRegisterTxCmd,
|
||||
ibcUpdateTxCmd,
|
||||
ibcPacketTxCmd,
|
||||
},
|
||||
}
|
||||
|
||||
ibcRegisterTxCmd = cli.Command{
|
||||
Name: "register",
|
||||
Usage: "Register a blockchain via IBC",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdIBCRegisterTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
ibcChainIDFlag,
|
||||
ibcGenesisFlag,
|
||||
},
|
||||
}
|
||||
|
||||
ibcUpdateTxCmd = cli.Command{
|
||||
Name: "update",
|
||||
Usage: "Update the latest state of a blockchain via IBC",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdIBCUpdateTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
ibcHeaderFlag,
|
||||
ibcCommitFlag,
|
||||
},
|
||||
}
|
||||
|
||||
ibcPacketTxCmd = cli.Command{
|
||||
Name: "packet",
|
||||
Usage: "Send a new packet via IBC",
|
||||
Flags: []cli.Flag{
|
||||
//
|
||||
},
|
||||
Subcommands: []cli.Command{
|
||||
ibcPacketCreateTx,
|
||||
ibcPacketPostTx,
|
||||
},
|
||||
}
|
||||
|
||||
ibcPacketCreateTx = cli.Command{
|
||||
Name: "create",
|
||||
Usage: "Create an egress IBC packet",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdIBCPacketCreateTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
ibcFromFlag,
|
||||
ibcToFlag,
|
||||
ibcTypeFlag,
|
||||
ibcPayloadFlag,
|
||||
ibcSequenceFlag,
|
||||
},
|
||||
}
|
||||
|
||||
ibcPacketPostTx = cli.Command{
|
||||
Name: "post",
|
||||
Usage: "Deliver an IBC packet to another chain",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdIBCPacketPostTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
ibcFromFlag,
|
||||
ibcHeightFlag,
|
||||
ibcPacketFlag,
|
||||
ibcProofFlag,
|
||||
},
|
||||
}
|
||||
|
||||
queryCmd = cli.Command{
|
||||
Name: "query",
|
||||
Usage: "Query the merkle tree",
|
||||
ArgsUsage: "<key>",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdQuery(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
},
|
||||
}
|
||||
|
||||
accountCmd = cli.Command{
|
||||
Name: "account",
|
||||
Usage: "Get details of an account",
|
||||
ArgsUsage: "<address>",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdAccount(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
},
|
||||
}
|
||||
|
||||
blockCmd = cli.Command{
|
||||
Name: "block",
|
||||
Usage: "Get the header and commit of a block",
|
||||
ArgsUsage: "<height>",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdBlock(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
},
|
||||
}
|
||||
|
||||
verifyCmd = cli.Command{
|
||||
Name: "verify",
|
||||
Usage: "Verify the IAVL proof",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdVerify(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
proofFlag,
|
||||
keyFlag,
|
||||
valueFlag,
|
||||
rootFlag,
|
||||
},
|
||||
}
|
||||
)
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli"
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
@ -16,6 +16,98 @@ import (
|
|||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
var (
|
||||
IbcCmd = cli.Command{
|
||||
Name: "ibc",
|
||||
Usage: "Send a transaction to the interblockchain (ibc) plugin",
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
chainIDFlag,
|
||||
|
||||
fromFlag,
|
||||
|
||||
amountFlag,
|
||||
coinFlag,
|
||||
gasFlag,
|
||||
feeFlag,
|
||||
seqFlag,
|
||||
|
||||
nameFlag,
|
||||
dataFlag,
|
||||
},
|
||||
Subcommands: []cli.Command{
|
||||
IbcRegisterTxCmd,
|
||||
IbcUpdateTxCmd,
|
||||
IbcPacketTxCmd,
|
||||
},
|
||||
}
|
||||
|
||||
IbcRegisterTxCmd = cli.Command{
|
||||
Name: "register",
|
||||
Usage: "Register a blockchain via IBC",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdIBCRegisterTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
ibcChainIDFlag,
|
||||
ibcGenesisFlag,
|
||||
},
|
||||
}
|
||||
|
||||
IbcUpdateTxCmd = cli.Command{
|
||||
Name: "update",
|
||||
Usage: "Update the latest state of a blockchain via IBC",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdIBCUpdateTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
ibcHeaderFlag,
|
||||
ibcCommitFlag,
|
||||
},
|
||||
}
|
||||
|
||||
IbcPacketTxCmd = cli.Command{
|
||||
Name: "packet",
|
||||
Usage: "Send a new packet via IBC",
|
||||
Flags: []cli.Flag{
|
||||
//
|
||||
},
|
||||
Subcommands: []cli.Command{
|
||||
IbcPacketCreateTx,
|
||||
IbcPacketPostTx,
|
||||
},
|
||||
}
|
||||
|
||||
IbcPacketCreateTx = cli.Command{
|
||||
Name: "create",
|
||||
Usage: "Create an egress IBC packet",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdIBCPacketCreateTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
ibcFromFlag,
|
||||
ibcToFlag,
|
||||
ibcTypeFlag,
|
||||
ibcPayloadFlag,
|
||||
ibcSequenceFlag,
|
||||
},
|
||||
}
|
||||
|
||||
IbcPacketPostTx = cli.Command{
|
||||
Name: "post",
|
||||
Usage: "Deliver an IBC packet to another chain",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdIBCPacketPostTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
ibcFromFlag,
|
||||
ibcHeightFlag,
|
||||
ibcPacketFlag,
|
||||
ibcProofFlag,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func cmdIBCRegisterTx(c *cli.Context) error {
|
||||
chainID := c.String("chain_id")
|
||||
genesisFile := c.String("genesis")
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
@ -14,6 +14,58 @@ import (
|
|||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
var (
|
||||
QueryCmd = cli.Command{
|
||||
Name: "query",
|
||||
Usage: "Query the merkle tree",
|
||||
ArgsUsage: "<key>",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdQuery(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
},
|
||||
}
|
||||
|
||||
AccountCmd = cli.Command{
|
||||
Name: "account",
|
||||
Usage: "Get details of an account",
|
||||
ArgsUsage: "<address>",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdAccount(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
},
|
||||
}
|
||||
|
||||
BlockCmd = cli.Command{
|
||||
Name: "block",
|
||||
Usage: "Get the header and commit of a block",
|
||||
ArgsUsage: "<height>",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdBlock(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
},
|
||||
}
|
||||
|
||||
VerifyCmd = cli.Command{
|
||||
Name: "verify",
|
||||
Usage: "Verify the IAVL proof",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdVerify(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
proofFlag,
|
||||
keyFlag,
|
||||
valueFlag,
|
||||
rootFlag,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func cmdQuery(c *cli.Context) error {
|
||||
if len(c.Args()) != 1 {
|
||||
return errors.New("query command requires an argument ([key])")
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -27,6 +27,24 @@ var config cfg.Config
|
|||
|
||||
const EyesCacheSize = 10000
|
||||
|
||||
var StartCmd = cli.Command{
|
||||
Name: "start",
|
||||
Usage: "Start basecoin",
|
||||
ArgsUsage: "",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdStart(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
addrFlag,
|
||||
eyesFlag,
|
||||
dirFlag,
|
||||
inProcTMFlag,
|
||||
chainIDFlag,
|
||||
ibcPluginFlag,
|
||||
counterPluginFlag,
|
||||
},
|
||||
}
|
||||
|
||||
func cmdStart(c *cli.Context) error {
|
||||
|
||||
// Connect to MerkleEyes
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
@ -17,6 +17,69 @@ import (
|
|||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
var (
|
||||
SendTxCmd = cli.Command{
|
||||
Name: "sendtx",
|
||||
Usage: "Broadcast a basecoin SendTx",
|
||||
ArgsUsage: "",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdSendTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
chainIDFlag,
|
||||
|
||||
fromFlag,
|
||||
|
||||
amountFlag,
|
||||
coinFlag,
|
||||
gasFlag,
|
||||
feeFlag,
|
||||
seqFlag,
|
||||
|
||||
toFlag,
|
||||
},
|
||||
}
|
||||
|
||||
AppTxCmd = cli.Command{
|
||||
Name: "apptx",
|
||||
Usage: "Broadcast a basecoin AppTx",
|
||||
ArgsUsage: "",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdAppTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
nodeFlag,
|
||||
chainIDFlag,
|
||||
|
||||
fromFlag,
|
||||
|
||||
amountFlag,
|
||||
coinFlag,
|
||||
gasFlag,
|
||||
feeFlag,
|
||||
seqFlag,
|
||||
|
||||
nameFlag,
|
||||
dataFlag,
|
||||
},
|
||||
Subcommands: []cli.Command{
|
||||
CounterTxCmd,
|
||||
},
|
||||
}
|
||||
|
||||
CounterTxCmd = cli.Command{
|
||||
Name: "counter",
|
||||
Usage: "Craft a transaction to the counter plugin",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdCounterTx(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
validFlag,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func cmdSendTx(c *cli.Context) error {
|
||||
toHex := c.String("to")
|
||||
fromFile := c.String("from")
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"os"
|
||||
|
||||
"github.com/tendermint/basecoin/cmd/basecoin/commands"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -12,14 +13,14 @@ func main() {
|
|||
app.Usage = "basecoin [command] [args...]"
|
||||
app.Version = "0.1.0"
|
||||
app.Commands = []cli.Command{
|
||||
startCmd,
|
||||
sendTxCmd,
|
||||
appTxCmd,
|
||||
ibcCmd,
|
||||
queryCmd,
|
||||
verifyCmd,
|
||||
blockCmd,
|
||||
accountCmd,
|
||||
commands.StartCmd,
|
||||
commands.SendTxCmd,
|
||||
commands.AppTxCmd,
|
||||
commands.IbcCmd,
|
||||
commands.QueryCmd,
|
||||
commands.VerifyCmd,
|
||||
commands.BlockCmd,
|
||||
commands.AccountCmd,
|
||||
}
|
||||
app.Run(os.Args)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue