Skip to content

Commit

Permalink
imp: updated events to remove channels (#7874)
Browse files Browse the repository at this point in the history
* imp: updated channel v2 events

* fix: removed event
  • Loading branch information
srdtrk authored Jan 24, 2025
1 parent 016a98e commit d7d25e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
20 changes: 10 additions & 10 deletions modules/core/04-channel/v2/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func emitSendPacketEvents(ctx context.Context, packet types.Packet) {
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSendPacket,
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)),
sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)),
Expand All @@ -49,8 +49,8 @@ func emitRecvPacketEvents(ctx context.Context, packet types.Packet) {
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeRecvPacket,
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)),
sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)),
Expand Down Expand Up @@ -79,8 +79,8 @@ func emitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ac
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeWriteAck,
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)),
sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)),
Expand All @@ -105,8 +105,8 @@ func emitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) {
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeAcknowledgePacket,
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)),
sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)),
Expand All @@ -130,8 +130,8 @@ func emitTimeoutPacketEvents(ctx context.Context, packet types.Packet) {
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeTimeoutPacket,
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySrcClient, packet.SourceClient),
sdk.NewAttribute(types.AttributeKeyDstClient, packet.DestinationClient),
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)),
sdk.NewAttribute(types.AttributeKeyEncodedPacketHex, hex.EncodeToString(encodedPacket)),
Expand Down
31 changes: 13 additions & 18 deletions modules/core/04-channel/v2/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,23 @@ import (
ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported"
)

// IBC channel events
// IBC Eureka core events
const (
EventTypeCreateChannel = "create_channel"
EventTypeRegisterCounterparty = "register_counterparty"
EventTypeSendPacket = "send_packet"
EventTypeRecvPacket = "recv_packet"
EventTypeTimeoutPacket = "timeout_packet"
EventTypeAcknowledgePacket = "acknowledge_packet"
EventTypeWriteAck = "write_acknowledgement"
EventTypeSendPacket = "send_packet"
EventTypeRecvPacket = "recv_packet"
EventTypeTimeoutPacket = "timeout_packet"
EventTypeAcknowledgePacket = "acknowledge_packet"
EventTypeWriteAck = "write_acknowledgement"

AttributeKeyChannelID = "channel_id"
AttributeKeyClientID = "client_id"
AttributeKeyCounterpartyChannelID = "counterparty_channel_id"
AttributeKeySrcChannel = "packet_source_channel"
AttributeKeyDstChannel = "packet_dest_channel"
AttributeKeySequence = "packet_sequence"
AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp"
AttributeKeyEncodedPacketHex = "encoded_packet_hex"
AttributeKeyEncodedAckHex = "encoded_acknowledgement_hex"
AttributeKeySrcClient = "packet_source_client"
AttributeKeyDstClient = "packet_dest_client"
AttributeKeySequence = "packet_sequence"
AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp"
AttributeKeyEncodedPacketHex = "encoded_packet_hex"
AttributeKeyEncodedAckHex = "encoded_acknowledgement_hex"
)

// IBC channel events vars
// IBC Eureka core events vars
var (
AttributeValueCategory = fmt.Sprintf("%s_%s", ibcexported.ModuleName, SubModuleName)
)
3 changes: 1 addition & 2 deletions testing/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"
)

// ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the
Expand Down Expand Up @@ -48,7 +47,7 @@ func ParseConnectionIDFromEvents(events []abci.Event) (string, error) {
// MsgChannelOpenTry or a MsgCreateChannel and returns the channel identifier.
func ParseChannelIDFromEvents(events []abci.Event) (string, error) {
for _, ev := range events {
if ev.Type == channeltypesv2.EventTypeCreateChannel || ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry {
if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry {
if attribute, found := attributeByKey(ev.Attributes, channeltypes.AttributeKeyChannelID); found {
return attribute.Value, nil
}
Expand Down

0 comments on commit d7d25e6

Please sign in to comment.