Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(statemachine)!: re-implement legacy msg interface (backport #3907) #3938

Merged
merged 2 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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

### Features
Expand Down
37 changes: 33 additions & 4 deletions modules/apps/29-fee/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,31 @@
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
<<<<<<< HEAD

Check failure on line 7 in modules/apps/29-fee/types/msgs.go

View workflow job for this annotation

GitHub Actions / lint

expected 'STRING', found '<<' (typecheck)

Check failure on line 7 in modules/apps/29-fee/types/msgs.go

View workflow job for this annotation

GitHub Actions / build (amd64)

expected 'STRING', found '<<'

Check failure on line 7 in modules/apps/29-fee/types/msgs.go

View workflow job for this annotation

GitHub Actions / build (amd64)

expected 'STRING', found '<<'

Check failure on line 7 in modules/apps/29-fee/types/msgs.go

View workflow job for this annotation

GitHub Actions / build (arm64)

expected 'STRING', found '<<'

Check failure on line 7 in modules/apps/29-fee/types/msgs.go

View workflow job for this annotation

GitHub Actions / build (arm64)

expected 'STRING', found '<<'
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
=======

Check failure on line 9 in modules/apps/29-fee/types/msgs.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
legacytx "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
>>>>>>> f2b22491 (fix(statemachine)!: re-implement legacy msg interface (#3907))

Check failure on line 11 in modules/apps/29-fee/types/msgs.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

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

// 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 @@ -148,12 +167,17 @@
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 @@ -189,12 +213,17 @@
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))
}
55 changes: 53 additions & 2 deletions modules/apps/transfer/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,58 @@
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
<<<<<<< HEAD

Check failure on line 7 in modules/apps/transfer/types/msgs.go

View workflow job for this annotation

GitHub Actions / lint

expected 'STRING', found '<<' (typecheck)

Check failure on line 7 in modules/apps/transfer/types/msgs.go

View workflow job for this annotation

GitHub Actions / build (amd64)

expected 'STRING', found '<<'

Check failure on line 7 in modules/apps/transfer/types/msgs.go

View workflow job for this annotation

GitHub Actions / build (amd64)

expected 'STRING', found '<<'

Check failure on line 7 in modules/apps/transfer/types/msgs.go

View workflow job for this annotation

GitHub Actions / build (arm64)

expected 'STRING', found '<<'

Check failure on line 7 in modules/apps/transfer/types/msgs.go

View workflow job for this annotation

GitHub Actions / build (arm64)

expected 'STRING', found '<<'
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
=======

Check failure on line 9 in modules/apps/transfer/types/msgs.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
legacytx "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
>>>>>>> f2b22491 (fix(statemachine)!: re-implement legacy msg interface (#3907))

Check failure on line 11 in modules/apps/transfer/types/msgs.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

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

<<<<<<< HEAD
=======
// 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove MsgUpdateParams stuff as its not being introduced until v8.

return &MsgUpdateParams{
Authority: authority,
Params: params,
}
}

// ValidateBasic implements sdk.Msg
func (msg MsgUpdateParams) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Authority)
if err != nil {
return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err)
}

return nil
}

// GetSigners implements sdk.Msg
func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress {
accAddr, err := sdk.AccAddressFromBech32(msg.Authority)
if err != nil {
panic(err)
}

return []sdk.AccAddress{accAddr}
}

>>>>>>> f2b22491 (fix(statemachine)!: re-implement legacy msg interface (#3907))

Check failure on line 58 in modules/apps/transfer/types/msgs.go

View workflow job for this annotation

GitHub Actions / lint

expected declaration, found '>>' (typecheck)
// NewMsgTransfer creates a new MsgTransfer instance
//
//nolint:interfacer
Expand All @@ -31,7 +77,12 @@
}
}

// 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 @@ -64,7 +115,7 @@
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
Loading