Skip to content

Commit

Permalink
chore: remove GetSignBytes from 29-fee and transfer msgs (#4570)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Sep 7, 2023
1 parent 5ca37ef commit 7be1785
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 234 deletions.
67 changes: 35 additions & 32 deletions modules/apps/29-fee/types/fee.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 4 additions & 43 deletions modules/apps/29-fee/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,17 @@ 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/v8/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
ibcerrors "github.com/cosmos/ibc-go/v8/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)
_ sdk.Msg = (*MsgRegisterPayee)(nil)
_ sdk.Msg = (*MsgRegisterCounterpartyPayee)(nil)
_ sdk.Msg = (*MsgPayPacketFee)(nil)
_ sdk.Msg = (*MsgPayPacketFeeAsync)(nil)
)

// NewMsgRegisterPayee creates a new instance of MsgRegisterPayee
Expand Down Expand Up @@ -162,21 +153,6 @@ func (msg MsgPayPacketFee) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{signer}
}

// Type implements legacytx.LegacyMsg
func (MsgPayPacketFee) Type() string {
return TypeMsgPayPacketFee
}

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

// GetSignBytes implements legacytx.LegacyMsg
func (msg MsgPayPacketFee) GetSignBytes() []byte {
return sdk.MustSortJSON(amino.MustMarshalJSON(&msg))
}

// NewMsgPayPacketAsync creates a new instance of MsgPayPacketFee
func NewMsgPayPacketFeeAsync(packetID channeltypes.PacketId, packetFee PacketFee) *MsgPayPacketFeeAsync {
return &MsgPayPacketFeeAsync{
Expand All @@ -203,18 +179,3 @@ func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress {
}
return []sdk.AccAddress{signer}
}

// Type implements legacytx.LegacyMsg
func (MsgPayPacketFeeAsync) Type() string {
return TypeMsgPayPacketFeeAsync
}

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

// GetSignBytes implements legacytx.LegacyMsg
func (msg MsgPayPacketFeeAsync) GetSignBytes() []byte {
return sdk.MustSortJSON(amino.MustMarshalJSON(&msg))
}
31 changes: 0 additions & 31 deletions modules/apps/29-fee/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,6 @@ func TestPayPacketFeeGetSigners(t *testing.T) {
require.Equal(t, []sdk.AccAddress{refundAddr}, msg.GetSigners())
}

func TestMsgPayPacketFeeRoute(t *testing.T) {
var msg types.MsgPayPacketFee
require.Equal(t, types.RouterKey, msg.Route())
}

func TestMsgPayPacketFeeGetSignBytes(t *testing.T) {
fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee)
msg := types.NewMsgPayPacketFee(fee, ibctesting.MockFeePort, ibctesting.FirstChannelID, defaultAccAddress, nil)

require.NotPanics(t, func() {
_ = msg.GetSignBytes()
})
}

func TestMsgPayPacketFeeAsyncValidation(t *testing.T) {
var msg *types.MsgPayPacketFeeAsync

Expand Down Expand Up @@ -382,20 +368,3 @@ func TestPayPacketFeeAsyncGetSigners(t *testing.T) {

require.Equal(t, []sdk.AccAddress{refundAddr}, msg.GetSigners())
}

func TestMsgPayPacketFeeAsyncRoute(t *testing.T) {
var msg types.MsgPayPacketFeeAsync
require.Equal(t, types.RouterKey, msg.Route())
}

func TestMsgPayPacketFeeAsyncGetSignBytes(t *testing.T) {
packetID := channeltypes.NewPacketID(ibctesting.MockFeePort, ibctesting.FirstChannelID, 1)
fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee)
packetFee := types.NewPacketFee(fee, defaultAccAddress, nil)

msg := types.NewMsgPayPacketFeeAsync(packetID, packetFee)

require.NotPanics(t, func() {
_ = msg.GetSignBytes()
})
}
88 changes: 46 additions & 42 deletions modules/apps/29-fee/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7be1785

Please sign in to comment.