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

chore: add OnRecvPacket to IBCModule V2 interface #7415

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions modules/core/05-port/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"
"strings"

"cosmossdk.io/log"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
8 changes: 7 additions & 1 deletion modules/core/api/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ type IBCModule interface {
signer sdk.AccAddress,
) error

// OnRecvPacket
OnRecvPacket(
ctx context.Context,
sourceID string,
destinationID string,
data channeltypesv2.PacketData,
relayer sdk.AccAddress,
) channeltypesv2.RecvPacketResult

// OnAcknowledgementPacket

Expand Down
1 change: 1 addition & 0 deletions testing/mock/v2/ibc_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ import (

type IBCApp struct {
OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error
OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult
}
17 changes: 11 additions & 6 deletions testing/mock/v2/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"
"github.com/cosmos/ibc-go/v9/modules/core/api"
mockv1 "github.com/cosmos/ibc-go/v9/testing/mock"
)

var _ api.IBCModule = (*IBCModule)(nil)
Expand Down Expand Up @@ -38,12 +39,16 @@ func (im IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinati
return nil
}

// func (im IBCModule) OnRecvPacket() error {
// if im.IBCApp.OnRecvPacket != nil {
// return im.IBCApp.OnRecvPacket(...)
// }
// return nil
// }
func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult {
if im.IBCApp.OnRecvPacket != nil {
return im.IBCApp.OnRecvPacket(ctx, sourceID, destinationID, data, relayer)
}
return channeltypesv2.RecvPacketResult{
Status: channeltypesv2.PacketStatus_Success,
Acknowledgement: mockv1.MockPacketData,
}
}

//
// func (im IBCModule) OnAcknowledgementPacket() error {
// if im.IBCApp.OnAcknowledgementPacket != nil {
Expand Down
Loading