Skip to content

Commit

Permalink
fix(x/swingset): amino encoding details
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc authored and mergify[bot] committed Oct 4, 2022
1 parent 19d8208 commit 9a2c435
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion golang/cosmos/x/swingset/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var (
NewMsgDeliverInbound = types.NewMsgDeliverInbound
NewMsgProvision = types.NewMsgProvision
NewMailbox = types.NewMailbox
ModuleCdc = types.ModuleCdc
RegisterCodec = types.RegisterCodec
)

Expand Down
4 changes: 2 additions & 2 deletions golang/cosmos/x/swingset/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
var (
amino = codec.NewLegacyAmino()

// ModuleCdc references the global x/deployment module codec. Note, the codec should
// ModuleCdc references the global x/swingset module codec. Note, the codec should
// ONLY be used in certain instances of tests and for JSON encoding as Amino is
// still used for that purpose.
//
// The actual codec used for serialization should be provided to x/swingset and
// defined at the application level.
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleAminoCdc = codec.NewAminoCodec(amino)
)

func init() {
Expand Down
8 changes: 4 additions & 4 deletions golang/cosmos/x/swingset/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (msg MsgDeliverInbound) GetSignBytes() []byte {
if msg.Nums == nil {
msg.Nums = []uint64{}
}
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleAminoCdc.MustMarshalJSON(&msg))
}

// GetSigners defines whose signature is required
Expand Down Expand Up @@ -125,7 +125,7 @@ func (msg MsgWalletAction) GetSigners() []sdk.AccAddress {

// GetSignBytes encodes the message for signing
func (msg MsgWalletAction) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleAminoCdc.MustMarshalJSON(&msg))
}

// Route should return the name of the module
Expand All @@ -142,7 +142,7 @@ func (msg MsgWalletSpendAction) Type() string { return "wallet_spend_action" }

// GetSignBytes encodes the message for signing
func (msg MsgWalletSpendAction) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleAminoCdc.MustMarshalJSON(&msg))
}

// ValidateBasic runs stateless checks on the message
Expand Down Expand Up @@ -228,7 +228,7 @@ func (msg MsgProvision) GetSignBytes() []byte {
if msg.PowerFlags == nil {
msg.PowerFlags = []string{}
}
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleAminoCdc.MustMarshalJSON(&msg))
}

// GetSigners defines whose signature is required
Expand Down

0 comments on commit 9a2c435

Please sign in to comment.