Skip to content

Commit

Permalink
fix(statemachine)!: re-implement legacy msg interface (#3907)
Browse files Browse the repository at this point in the history
  • Loading branch information
crodriguezvega authored Jun 22, 2023
1 parent 43d771e commit f2b2249
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### State Machine Breaking

* [\#3907](https://github.com/cosmos/ibc-go/pull/3907) Re-implemented missing functions of `LegacyMsg` interface to fix transaction signing with ledger.

### Improvements

* (tests) [\#3138](https://github.com/cosmos/ibc-go/pull/3138) Support benchmarks and fuzz tests through `testing.TB`.
Expand Down
34 changes: 30 additions & 4 deletions modules/apps/29-fee/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@ import (
errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
legacytx "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"

channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors"
)

// msg types
const (
TypeMsgPayPacketFee = "payPacketFee"
TypeMsgPayPacketFeeAsync = "payPacketFeeAsync"
)

var (
_ sdk.Msg = (*MsgRegisterPayee)(nil)
_ sdk.Msg = (*MsgRegisterCounterpartyPayee)(nil)
_ sdk.Msg = (*MsgPayPacketFee)(nil)
_ sdk.Msg = (*MsgPayPacketFeeAsync)(nil)
_ legacytx.LegacyMsg = (*MsgPayPacketFee)(nil)
_ legacytx.LegacyMsg = (*MsgPayPacketFeeAsync)(nil)
)

// NewMsgRegisterPayee creates a new instance of MsgRegisterPayee
func NewMsgRegisterPayee(portID, channelID, relayerAddr, payeeAddr string) *MsgRegisterPayee {
return &MsgRegisterPayee{
Expand Down Expand Up @@ -146,12 +162,17 @@ func (msg MsgPayPacketFee) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{signer}
}

// Route implements sdk.Msg
// Type implements legacytx.LegacyMsg
func (msg MsgPayPacketFee) Type() string {
return TypeMsgPayPacketFee
}

// Route implements legacytx.LegacyMsg
func (msg MsgPayPacketFee) Route() string {
return RouterKey
}

// GetSignBytes implements sdk.Msg.
// GetSignBytes implements legacytx.LegacyMsg
func (msg MsgPayPacketFee) GetSignBytes() []byte {
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
}
Expand Down Expand Up @@ -183,12 +204,17 @@ func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{signer}
}

// Route implements sdk.Msg
// Type implements legacytx.LegacyMsg
func (msg MsgPayPacketFeeAsync) Type() string {
return TypeMsgPayPacketFeeAsync
}

// Route implements legacytx.LegacyMsg
func (msg MsgPayPacketFeeAsync) Route() string {
return RouterKey
}

// GetSignBytes implements sdk.Msg.
// GetSignBytes implements legacytx.LegacyMsg
func (msg MsgPayPacketFeeAsync) GetSignBytes() []byte {
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
}
21 changes: 18 additions & 3 deletions modules/apps/transfer/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ import (
errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
legacytx "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors"
)

var _ sdk.Msg = (*MsgUpdateParams)(nil)
// msg types
const (
TypeMsgTransfer = "transfer"
)

var (
_ sdk.Msg = (*MsgUpdateParams)(nil)
_ sdk.Msg = (*MsgTransfer)(nil)
_ legacytx.LegacyMsg = (*MsgTransfer)(nil)
)

// NewMsgUpdateParams creates a new MsgUpdateParams instance
func NewMsgUpdateParams(authority string, params Params) *MsgUpdateParams {
Expand Down Expand Up @@ -61,7 +71,12 @@ func NewMsgTransfer(
}
}

// Route implements sdk.Msg
// Type implements legacytx.LegacyMsg
func (MsgTransfer) Type() string {
return TypeMsgTransfer
}

// Route implements legacytx.LegacyMsg
func (MsgTransfer) Route() string {
return RouterKey
}
Expand Down Expand Up @@ -94,7 +109,7 @@ func (msg MsgTransfer) ValidateBasic() error {
return ValidateIBCDenom(msg.Token.Denom)
}

// GetSignBytes implements sdk.Msg.
// GetSignBytes implements legacytx.LegacyMsg
func (msg MsgTransfer) GetSignBytes() []byte {
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
}
Expand Down

0 comments on commit f2b2249

Please sign in to comment.