From da82ca0ebd76f8330f2afe67da20d1bf424939d4 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Thu, 13 Jun 2019 09:37:35 -0600 Subject: [PATCH] msgs.go: use MustMarshalJSON fixes #21 --- x/swingset/codec.go | 3 +++ x/swingset/msgs.go | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/x/swingset/codec.go b/x/swingset/codec.go index ea3824c82ba..a5a7d523e90 100644 --- a/x/swingset/codec.go +++ b/x/swingset/codec.go @@ -4,7 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) +var ModuleCdc *codec.Codec + // RegisterCodec registers concrete types on the Amino codec func RegisterCodec(cdc *codec.Codec) { + ModuleCdc = cdc cdc.RegisterConcrete(MsgDeliverInbound{}, "swingset/DeliverInbound", nil) } diff --git a/x/swingset/msgs.go b/x/swingset/msgs.go index 11ada37a413..3157ff6aaa4 100644 --- a/x/swingset/msgs.go +++ b/x/swingset/msgs.go @@ -1,8 +1,6 @@ package swingset import ( - "encoding/json" - sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -65,11 +63,7 @@ func (msg MsgDeliverInbound) GetSignBytes() []byte { if msg.Nums == nil { msg.Nums = []int{} } - b, err := json.Marshal(msg) - if err != nil { - panic(err) - } - return sdk.MustSortJSON(b) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required