Skip to content

Commit

Permalink
chore: add OnRecvPacket to IBCModule V2 interface
Browse files Browse the repository at this point in the history
  • Loading branch information
bznein committed Oct 8, 2024
1 parent 6a19337 commit 40fab60
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
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

0 comments on commit 40fab60

Please sign in to comment.