diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 1c2140d2835..7940cc15ff7 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -49,3 +49,21 @@ func (*Keeper) emitCreateChannelEvent(ctx context.Context, channelID, clientID s ), }) } + +// emitRegisterCounterpartyEvent emits a register counterparty event. +func (*Keeper) emitRegisterCounterpartyEvent(ctx context.Context, channelID string, channel types.Channel) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRegisterCounterparty, + sdk.NewAttribute(types.AttributeKeyChannelID, channelID), + sdk.NewAttribute(types.AttributeKeyClientID, channel.ClientId), + sdk.NewAttribute(types.AttributeKeyCounterpartyChannelID, channel.CounterpartyChannelId), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) +} diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 39d376aac30..a4b6c19d9ff 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -57,6 +57,8 @@ func (k *Keeper) RegisterCounterparty(goCtx context.Context, msg *types.MsgRegis // Delete client creator from state as it is not needed after this point. k.DeleteCreator(ctx, msg.ChannelId) + k.emitRegisterCounterpartyEvent(goCtx, msg.ChannelId, channel) + return &types.MsgRegisterCounterpartyResponse{}, nil } diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index 78bf04df189..35496926d0e 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -8,13 +8,15 @@ import ( // IBC channel events const ( - AttributeKeyChannelID = "channel_id" - AttributeKeyClientID = "client_id" + AttributeKeyChannelID = "channel_id" + AttributeKeyClientID = "client_id" + AttributeKeyCounterpartyChannelID = "counterparty_channel_id" ) // IBC channel events vars var ( - EventTypeCreateChannel = "create_channel" + EventTypeCreateChannel = "create_channel" + EventTypeRegisterCounterparty = "register_counterparty" AttributeValueCategory = fmt.Sprintf("%s_%s", ibcexported.ModuleName, SubModuleName) )