Skip to content

Commit

Permalink
chore: Add OnAcknowledgmentPacket to IBCModule V2 Interface (#7438)
Browse files Browse the repository at this point in the history
* Add OnAcknowledgmentPacket to IBCModule V2 Interface

* chore: fix typo
  • Loading branch information
bznein authored Oct 14, 2024
1 parent 5fdd344 commit 4ed7543
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
12 changes: 10 additions & 2 deletions modules/core/api/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ type IBCModule interface {
relayer sdk.AccAddress,
) channeltypesv2.RecvPacketResult

// OnAcknowledgementPacket

// OnTimeoutPacket is executed when a packet has timed out on the receiving chain.
OnTimeoutPacket(
ctx context.Context,
Expand All @@ -41,4 +39,14 @@ type IBCModule interface {
data channeltypesv2.PacketData,
relayer sdk.AccAddress,
) error

// OnAcknowledgementPacket is executed when a packet gets acknowledged
OnAcknowledgementPacket(
ctx context.Context,
sourceID string,
destinationID string,
data channeltypesv2.PacketData,
acknowledgement []byte,
relayer sdk.AccAddress,
) error
}
7 changes: 4 additions & 3 deletions testing/mock/v2/ibc_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ 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
OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error
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
OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error
OnAcknowledgementPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error
}
14 changes: 6 additions & 8 deletions testing/mock/v2/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,12 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinati
}
}

//
// func (im IBCModule) OnAcknowledgementPacket() error {
// if im.IBCApp.OnAcknowledgementPacket != nil {
// return im.IBCApp.OnAcknowledgementPacket(...)
// }
// return nil
// }
//
func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error {
if im.IBCApp.OnAcknowledgementPacket != nil {
return im.IBCApp.OnAcknowledgementPacket(ctx, sourceID, destinationID, data, acknowledgement, relayer)
}
return nil
}

func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error {
if im.IBCApp.OnTimeoutPacket != nil {
Expand Down

0 comments on commit 4ed7543

Please sign in to comment.