forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit an event to indicate a successful acknowledgement in the ICA mod…
…ule (cosmos#1466)
- Loading branch information
Showing
4 changed files
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" | ||
"github.com/cosmos/ibc-go/v3/modules/core/exported" | ||
) | ||
|
||
// EmitWriteErrorAcknowledgementEvent emits an event signalling an error acknowledgement and including the error details | ||
func EmitWriteErrorAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, err error) { | ||
// EmitAcknowledgementEvent emits an event signalling a successful or failed acknowledgement and including the error | ||
// details if any. | ||
func EmitAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, ack exported.Acknowledgement, err error) { | ||
var errorMsg string | ||
if err != nil { | ||
errorMsg = err.Error() | ||
} | ||
|
||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
icatypes.EventTypePacket, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, icatypes.ModuleName), | ||
sdk.NewAttribute(icatypes.AttributeKeyAckError, err.Error()), | ||
sdk.NewAttribute(icatypes.AttributeKeyAckError, errorMsg), | ||
sdk.NewAttribute(icatypes.AttributeKeyHostChannelID, packet.GetDestChannel()), | ||
sdk.NewAttribute(icatypes.AttributeKeyAckSuccess, fmt.Sprintf("%t", ack.Success())), | ||
), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters