Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channel: add channel ordering to events #4

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions modules/core/04-channel/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ func EmitChannelOpenInitEvent(ctx sdk.Context, portID string, channelID string,

// EmitChannelOpenTryEvent emits a channel open try or pending event
func EmitChannelOpenTryEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) {
eventType := types.EventTypeChannelOpenTry
event := sdk.NewEvent(
types.EventTypeChannelOpenTry,
sdk.NewAttribute(types.AttributeKeyPortID, portID),
sdk.NewAttribute(types.AttributeKeyChannelID, channelID),
sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId),
sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId),
sdk.NewAttribute(types.AttributeKeyConnectionID, types.FormatConnectionID(channel.ConnectionHops)),
sdk.NewAttribute(types.AttributeVersion, channel.Version),
)
if channel.State == types.TRY_PENDING {
eventType = types.EventTypeChannelOpenTryPending
event.Type = types.EventTypeChannelOpenTryPending
event = event.AppendAttributes(sdk.NewAttribute(types.AttributeOrdering, channel.Ordering.String()))
}
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
eventType,
sdk.NewAttribute(types.AttributeKeyPortID, portID),
sdk.NewAttribute(types.AttributeKeyChannelID, channelID),
sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId),
sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId),
sdk.NewAttribute(types.AttributeKeyConnectionID, types.FormatConnectionID(channel.ConnectionHops)),
sdk.NewAttribute(types.AttributeVersion, channel.Version),
),
event,
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
Expand All @@ -65,6 +66,7 @@ func EmitChannelOpenAckEvent(ctx sdk.Context, portID string, channelID string, c
if channel.State == types.ACK_PENDING {
event.Type = types.EventTypeChannelOpenAckPending
event = event.AppendAttributes(sdk.NewAttribute(types.AttributeVersion, channel.Version))
event = event.AppendAttributes(sdk.NewAttribute(types.AttributeOrdering, channel.Ordering.String()))
}
ctx.EventManager().EmitEvents(sdk.Events{
event,
Expand All @@ -88,6 +90,7 @@ func EmitChannelOpenConfirmEvent(ctx sdk.Context, portID string, channelID strin
if channel.State == types.CONFIRM_PENDING {
event.Type = types.EventTypeChannelOpenConfirmPending
event = event.AppendAttributes(sdk.NewAttribute(types.AttributeVersion, channel.Version))
event = event.AppendAttributes(sdk.NewAttribute(types.AttributeOrdering, channel.Ordering.String()))
}
ctx.EventManager().EmitEvents(sdk.Events{
event,
Expand Down
1 change: 1 addition & 0 deletions modules/core/04-channel/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
AttributeVersion = "version"
AttributeCounterpartyPortID = "counterparty_port_id"
AttributeCounterpartyChannelID = "counterparty_channel_id"
AttributeOrdering = "ordering"

EventTypeSendPacket = "send_packet"
EventTypeRecvPacket = "recv_packet"
Expand Down
Loading