parent
0fc1b98525
commit
4207275d18
|
@ -7,7 +7,10 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
flag "github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/basecoin/state"
|
||||
btypes "github.com/tendermint/basecoin/types"
|
||||
|
||||
keycmd "github.com/tendermint/go-crypto/cmd"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
lightclient "github.com/tendermint/light-client"
|
||||
|
@ -20,7 +23,7 @@ type AccountPresenter struct{}
|
|||
func (_ AccountPresenter) MakeKey(str string) ([]byte, error) {
|
||||
res, err := hex.DecodeString(str)
|
||||
if err == nil {
|
||||
res = append([]byte("base/a/"), res...)
|
||||
res = state.AccountKey(res)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
@ -41,21 +44,6 @@ func (_ BaseTxPresenter) ParseData(raw []byte) (interface{}, error) {
|
|||
return tx, err
|
||||
}
|
||||
|
||||
// SendTXReader allows us to create SendTx
|
||||
type SendTxReader struct {
|
||||
ChainID string
|
||||
}
|
||||
|
||||
func (t SendTxReader) ReadTxJSON(data []byte) (interface{}, error) {
|
||||
var tx btypes.SendTx
|
||||
err := json.Unmarshal(data, &tx)
|
||||
send := SendTx{
|
||||
chainID: t.ChainID,
|
||||
Tx: &tx,
|
||||
}
|
||||
return &send, errors.Wrap(err, "parse sendtx")
|
||||
}
|
||||
|
||||
type SendTxMaker struct{}
|
||||
|
||||
func (m SendTxMaker) MakeReader() (lightclient.TxReader, error) {
|
||||
|
@ -72,7 +60,8 @@ type SendFlags struct {
|
|||
}
|
||||
|
||||
func (m SendTxMaker) Flags() (*flag.FlagSet, interface{}) {
|
||||
fs := flag.NewFlagSet("foobar", flag.ContinueOnError)
|
||||
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
||||
|
||||
fs.String("to", "", "Destination address for the bits")
|
||||
fs.String("amount", "", "Coins to send in the format <amt><coin>,<amt><coin>...")
|
||||
fs.String("fee", "", "Coins for the transaction fee of the format <amt><coin>")
|
||||
|
@ -81,6 +70,21 @@ func (m SendTxMaker) Flags() (*flag.FlagSet, interface{}) {
|
|||
return fs, &SendFlags{}
|
||||
}
|
||||
|
||||
// SendTXReader allows us to create SendTx
|
||||
type SendTxReader struct {
|
||||
ChainID string
|
||||
}
|
||||
|
||||
func (t SendTxReader) ReadTxJSON(data []byte) (interface{}, error) {
|
||||
var tx btypes.SendTx
|
||||
err := json.Unmarshal(data, &tx)
|
||||
send := SendTx{
|
||||
chainID: t.ChainID,
|
||||
Tx: &tx,
|
||||
}
|
||||
return &send, errors.Wrap(err, "parse sendtx")
|
||||
}
|
||||
|
||||
func (t SendTxReader) ReadTxFlags(flags interface{}) (interface{}, error) {
|
||||
data := flags.(*SendFlags)
|
||||
|
||||
|
@ -134,7 +138,7 @@ func (t SendTxReader) ReadTxFlags(flags interface{}) (interface{}, error) {
|
|||
return &send, nil
|
||||
}
|
||||
|
||||
/** copied from basecoin cli - put in common somewhere? **/
|
||||
/** TODO copied from basecoin cli - put in common somewhere? **/
|
||||
|
||||
// Returns true for non-empty hex-string prefixed with "0x"
|
||||
func isHex(s string) bool {
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
keycmd "github.com/tendermint/go-crypto/cmd"
|
||||
"github.com/tendermint/light-client/commands"
|
||||
"github.com/tendermint/light-client/commands/proofs"
|
||||
"github.com/tendermint/light-client/commands/proxy"
|
||||
"github.com/tendermint/light-client/commands/seeds"
|
||||
"github.com/tendermint/light-client/commands/txs"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
@ -25,22 +24,23 @@ tmcli to work for any custom abci app.
|
|||
`,
|
||||
}
|
||||
|
||||
func init() {
|
||||
func main() {
|
||||
commands.AddBasicFlags(BaseCli)
|
||||
|
||||
// set up the various commands to use
|
||||
BaseCli.AddCommand(keycmd.RootCmd)
|
||||
BaseCli.AddCommand(commands.InitCmd)
|
||||
BaseCli.AddCommand(seeds.RootCmd)
|
||||
//initialize proofs and txs
|
||||
proofs.StatePresenters.Register("account", AccountPresenter{})
|
||||
proofs.TxPresenters.Register("base", BaseTxPresenter{})
|
||||
BaseCli.AddCommand(proofs.RootCmd)
|
||||
txs.Register("send", SendTxMaker{})
|
||||
BaseCli.AddCommand(txs.RootCmd)
|
||||
BaseCli.AddCommand(proxy.RootCmd)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// set up the various commands to use
|
||||
BaseCli.AddCommand(
|
||||
keycmd.RootCmd,
|
||||
commands.InitCmd,
|
||||
seeds.RootCmd,
|
||||
proofs.RootCmd,
|
||||
txs.RootCmd,
|
||||
)
|
||||
|
||||
cmd := cli.PrepareMainCmd(BaseCli, "BC", os.ExpandEnv("$HOME/.basecli"))
|
||||
cmd.Execute()
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import:
|
|||
- rpc/lib/types
|
||||
- types
|
||||
- package: github.com/tendermint/tmlibs
|
||||
version: develop
|
||||
version: basecoin-cli
|
||||
subpackages:
|
||||
- cli
|
||||
- common
|
||||
|
|
Loading…
Reference in New Issue