github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/modules/apps/27-interchain-accounts/controller/keeper/events.go (about)

     1  package keeper
     2  
     3  import (
     4  	"fmt"
     5  
     6  	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
     7  	icatypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/apps/27-interchain-accounts/types"
     8  	"github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/exported"
     9  )
    10  
    11  // EmitAcknowledgementEvent emits an event signalling a successful or failed acknowledgement and including the error
    12  // details if any.
    13  func EmitAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, ack exported.Acknowledgement, err error) {
    14  	attributes := []sdk.Attribute{
    15  		sdk.NewAttribute(sdk.AttributeKeyModule, icatypes.ModuleName),
    16  		sdk.NewAttribute(icatypes.AttributeKeyControllerChannelID, packet.GetDestChannel()),
    17  		sdk.NewAttribute(icatypes.AttributeKeyAckSuccess, fmt.Sprintf("%t", ack.Success())),
    18  	}
    19  
    20  	if err != nil {
    21  		attributes = append(attributes, sdk.NewAttribute(icatypes.AttributeKeyAckError, err.Error()))
    22  	}
    23  
    24  	ctx.EventManager().EmitEvent(
    25  		sdk.NewEvent(
    26  			icatypes.EventTypePacket,
    27  			attributes...,
    28  		),
    29  	)
    30  }