From f279a5538d049b55ff7792f6a4a4d13dec8b154c Mon Sep 17 00:00:00 2001 From: mossid Date: Thu, 15 Mar 2018 12:38:17 +0100 Subject: [PATCH] done: wire -> json --- x/ibc/commands/helpers.go | 7 ++++--- x/ibc/commands/relay.go | 17 +++++++++-------- x/ibc/commands/root.go | 16 ---------------- x/ibc/commands/send.go | 8 ++++---- 4 files changed, 17 insertions(+), 31 deletions(-) delete mode 100644 x/ibc/commands/root.go diff --git a/x/ibc/commands/helpers.go b/x/ibc/commands/helpers.go index 590fb8b5d5..c69bc556d6 100644 --- a/x/ibc/commands/helpers.go +++ b/x/ibc/commands/helpers.go @@ -1,6 +1,7 @@ package commands import ( + "encoding/json" "fmt" "github.com/spf13/viper" @@ -8,10 +9,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/keys" sdk "github.com/cosmos/cosmos-sdk/types" - wire "github.com/tendermint/go-amino" + // wire "github.com/tendermint/go-amino" ) -func buildTx(cdc *wire.Codec, msg sdk.Msg, name string) ([]byte, error) { +func buildTx(msg sdk.Msg, name string) ([]byte, error) { keybase, err := keys.GetKeyBase() if err != nil { return nil, err @@ -36,7 +37,7 @@ func buildTx(cdc *wire.Codec, msg sdk.Msg, name string) ([]byte, error) { tx := sdk.NewStdTx(msg, sigs) - txBytes, err := cdc.MarshalBinary(tx) + txBytes, err := json.Marshal(tx) if err != nil { return nil, err } diff --git a/x/ibc/commands/relay.go b/x/ibc/commands/relay.go index 2fe5cf0333..4d1f2261a7 100644 --- a/x/ibc/commands/relay.go +++ b/x/ibc/commands/relay.go @@ -1,6 +1,7 @@ package commands import ( + "encoding/json" "fmt" "time" @@ -10,13 +11,13 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/builder" - wire "github.com/tendermint/go-amino" + //wire "github.com/tendermint/go-amino" "github.com/cosmos/cosmos-sdk/x/ibc" ) -func IBCRelayCmd(cdc *wire.Codec) *cobra.Command { - cmdr := relayCommander{cdc, "ibc"} +func IBCRelayCmd() *cobra.Command { + cmdr := relayCommander{"ibc"} cmd := &cobra.Command{ Use: "relay", @@ -27,7 +28,7 @@ func IBCRelayCmd(cdc *wire.Codec) *cobra.Command { } type relayCommander struct { - cdc *wire.Codec + // cdc *wire.Codec ibcStore string } @@ -59,7 +60,7 @@ func broadcastTx(id string, tx []byte) error { func (c relayCommander) refine(bz []byte, sequence int64) []byte { var packet ibc.IBCPacket - if err := c.cdc.UnmarshalBinary(bz, &packet); err != nil { + if err := json.Unmarshal(bz, &packet); err != nil { panic(err) } @@ -71,7 +72,7 @@ func (c relayCommander) refine(bz []byte, sequence int64) []byte { Relayer: address, Sequence: sequence, } - res, err := buildTx(c.cdc, msg, name) + res, err := buildTx(msg, name) if err != nil { panic(err) } @@ -87,7 +88,7 @@ func (c relayCommander) loop(fromID, toID string) { } var processed int64 - if err = c.cdc.UnmarshalBinary(processedbz, &processed); err != nil { + if err = json.Unmarshal(processedbz, &processed); err != nil { panic(err) } @@ -102,7 +103,7 @@ OUTER: continue OUTER } var egressLength int64 - if err = c.cdc.UnmarshalBinary(egressLengthbz, &egressLength); err != nil { + if err = json.Unmarshal(egressLengthbz, &egressLength); err != nil { panic(err) } diff --git a/x/ibc/commands/root.go b/x/ibc/commands/root.go deleted file mode 100644 index 0011f11f26..0000000000 --- a/x/ibc/commands/root.go +++ /dev/null @@ -1,16 +0,0 @@ -package commands - -import ( - "github.com/spf13/cobra" - - wire "github.com/tendermint/go-amino" -) - -func AddCommands(cmd *cobra.Command) { - cdc := wire.NewCodec() - - cmd.AddCommand( - IBCTransferCmd(cdc), - IBCRelayCmd(cdc), - ) -} diff --git a/x/ibc/commands/send.go b/x/ibc/commands/send.go index d6737219c2..6f42329546 100644 --- a/x/ibc/commands/send.go +++ b/x/ibc/commands/send.go @@ -16,8 +16,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc" ) -func IBCTransferCmd(cdc *wire.Codec) *cobra.Command { - cmdr := sendCommander{cdc} +func IBCTransferCmd() *cobra.Command { + cmdr := sendCommander{} cmd := &cobra.Command{ Use: "transfer", @@ -37,7 +37,7 @@ func IBCTransferCmd(cdc *wire.Codec) *cobra.Command { } type sendCommander struct { - cdc *wire.Codec + // cdc *wire.Codec } func (c sendCommander) runIBCTransfer(cmd *cobra.Command, args []string) error { @@ -49,7 +49,7 @@ func (c sendCommander) runIBCTransfer(cmd *cobra.Command, args []string) error { return err } - txBytes, err := buildTx(c.cdc, msg, keyname) + txBytes, err := buildTx(msg, keyname) if err != nil { return err }