cmd: fix some serialization
This commit is contained in:
parent
530694f93c
commit
e69395c01f
|
@ -19,7 +19,8 @@ var (
|
|||
genesisFlag,
|
||||
inProcTMFlag,
|
||||
chainIDFlag,
|
||||
pluginFlag,
|
||||
ibcPluginFlag,
|
||||
counterPluginFlag,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -89,6 +90,18 @@ var (
|
|||
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,
|
||||
|
|
|
@ -38,10 +38,14 @@ var (
|
|||
Usage: "Run Tendermint in-process with the App",
|
||||
}
|
||||
|
||||
pluginFlag = cli.StringFlag{
|
||||
Name: "plugin",
|
||||
Value: "counter", // load the counter by default
|
||||
Usage: "Plugin to enable",
|
||||
ibcPluginFlag = cli.BoolFlag{
|
||||
Name: "ibc-plugin",
|
||||
Usage: "Enable the ibc plugin",
|
||||
}
|
||||
|
||||
counterPluginFlag = cli.BoolFlag{
|
||||
Name: "counter-plugin",
|
||||
Usage: "Enable the counter plugin",
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -35,8 +35,10 @@ func cmdIBCRegisterTx(c *cli.Context) error {
|
|||
|
||||
fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx)))
|
||||
|
||||
data := wire.BinaryBytes(ibcTx)
|
||||
name := "ibc"
|
||||
data := []byte(wire.BinaryBytes(struct {
|
||||
ibc.IBCTx `json:"unwrap"`
|
||||
}{ibcTx}))
|
||||
name := "IBC"
|
||||
|
||||
return appTx(parent, name, data)
|
||||
}
|
||||
|
@ -53,8 +55,8 @@ func cmdIBCUpdateTx(c *cli.Context) error {
|
|||
return errors.New(cmn.Fmt("Commit (%v) is invalid hex: %v", c.String("commit"), err))
|
||||
}
|
||||
|
||||
var header tmtypes.Header
|
||||
var commit tmtypes.Commit
|
||||
header := new(tmtypes.Header)
|
||||
commit := new(tmtypes.Commit)
|
||||
|
||||
if err := wire.ReadBinaryBytes(headerBytes, &header); err != nil {
|
||||
return errors.New(cmn.Fmt("Error unmarshalling header: %v", err))
|
||||
|
@ -64,14 +66,16 @@ func cmdIBCUpdateTx(c *cli.Context) error {
|
|||
}
|
||||
|
||||
ibcTx := ibc.IBCUpdateChainTx{
|
||||
Header: header,
|
||||
Commit: commit,
|
||||
Header: *header,
|
||||
Commit: *commit,
|
||||
}
|
||||
|
||||
fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx)))
|
||||
|
||||
data := wire.BinaryBytes(ibcTx)
|
||||
name := "ibc"
|
||||
data := []byte(wire.BinaryBytes(struct {
|
||||
ibc.IBCTx `json:"unwrap"`
|
||||
}{ibcTx}))
|
||||
name := "IBC"
|
||||
|
||||
return appTx(parent, name, data)
|
||||
}
|
||||
|
@ -102,9 +106,11 @@ func cmdIBCPacketCreateTx(c *cli.Context) error {
|
|||
|
||||
fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx)))
|
||||
|
||||
data := wire.BinaryBytes(ibcTx)
|
||||
data := []byte(wire.BinaryBytes(struct {
|
||||
ibc.IBCTx `json:"unwrap"`
|
||||
}{ibcTx}))
|
||||
|
||||
return appTx(c.Parent(), "ibc", data)
|
||||
return appTx(c.Parent(), "IBC", data)
|
||||
}
|
||||
|
||||
func cmdIBCPacketPostTx(c *cli.Context) error {
|
||||
|
@ -138,9 +144,11 @@ func cmdIBCPacketPostTx(c *cli.Context) error {
|
|||
|
||||
fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx)))
|
||||
|
||||
data := wire.BinaryBytes(ibcTx)
|
||||
data := []byte(wire.BinaryBytes(struct {
|
||||
ibc.IBCTx `json:"unwrap"`
|
||||
}{ibcTx}))
|
||||
|
||||
return appTx(c.Parent(), "ibc", data)
|
||||
return appTx(c.Parent(), "IBC", data)
|
||||
}
|
||||
|
||||
func getIBCSequence(c *cli.Context) (uint64, error) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
|
||||
"github.com/tendermint/basecoin/app"
|
||||
"github.com/tendermint/basecoin/plugins/counter"
|
||||
"github.com/tendermint/basecoin/plugins/ibc"
|
||||
)
|
||||
|
||||
var config cfg.Config
|
||||
|
@ -41,13 +42,13 @@ func cmdStart(c *cli.Context) error {
|
|||
// Create Basecoin app
|
||||
basecoinApp := app.NewBasecoin(eyesCli)
|
||||
|
||||
switch c.String("plugin") {
|
||||
case "counter":
|
||||
if c.Bool("counter-plugin") {
|
||||
basecoinApp.RegisterPlugin(counter.New("counter"))
|
||||
case "":
|
||||
// no plugins to register
|
||||
default:
|
||||
return errors.New(cmn.Fmt("Unknown plugin: %v", c.String("plugin")))
|
||||
}
|
||||
|
||||
if c.Bool("ibc-plugin") {
|
||||
basecoinApp.RegisterPlugin(ibc.New())
|
||||
|
||||
}
|
||||
|
||||
// If genesis file was specified, set key-value options
|
||||
|
|
|
@ -154,7 +154,7 @@ func (ibc *IBCPlugin) RunTx(store types.KVStore, ctx types.CallContext, txBytes
|
|||
var tx IBCTx
|
||||
err := wire.ReadBinaryBytes(txBytes, &tx)
|
||||
if err != nil {
|
||||
return abci.ErrBaseEncodingError.AppendLog("Error decoding tx: " + err.Error())
|
||||
return abci.ErrBaseEncodingError.AppendLog("Error decoding tx: " + err.Error()).PrependLog("IBCTx Error: ")
|
||||
}
|
||||
|
||||
// Validate tx
|
||||
|
|
Loading…
Reference in New Issue