Skip to content

Commit

Permalink
fix resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 16, 2023
1 parent 4e40884 commit 1b7c023
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions relayer/chains/parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,61 +76,47 @@ func IbcMessagesFromEvents(
return messages
}

type messageInfo interface {
ibcMessageInfo
ParseAttrs(log *zap.Logger, attrs []sdk.Attribute)
}

func parseIBCMessageFromEvent(
log *zap.Logger,
event sdk.StringEvent,
chainID string,
height uint64,
) *IbcMessage {
var msgInfo messageInfo
switch event.Type {
case chantypes.EventTypeSendPacket, chantypes.EventTypeRecvPacket, chantypes.EventTypeWriteAck,
chantypes.EventTypeAcknowledgePacket, chantypes.EventTypeTimeoutPacket,
chantypes.EventTypeTimeoutPacketOnClose:
pi := &PacketInfo{Height: height}
pi.ParseAttrs(log, event.Attributes)
return &IbcMessage{
EventType: event.Type,
Info: pi,
}
msgInfo = &PacketInfo{Height: height}
case chantypes.EventTypeChannelOpenInit, chantypes.EventTypeChannelOpenTry,
chantypes.EventTypeChannelOpenAck, chantypes.EventTypeChannelOpenConfirm,
chantypes.EventTypeChannelCloseInit, chantypes.EventTypeChannelClosed, chantypes.EventTypeChannelCloseConfirm:
ci := &ChannelInfo{Height: height}
ci.ParseAttrs(log, event.Attributes)
return &IbcMessage{
EventType: event.Type,
Info: ci,
}
msgInfo = &ChannelInfo{Height: height}
case conntypes.EventTypeConnectionOpenInit, conntypes.EventTypeConnectionOpenTry,
conntypes.EventTypeConnectionOpenAck, conntypes.EventTypeConnectionOpenConfirm:
ci := &ConnectionInfo{Height: height}
ci.ParseAttrs(log, event.Attributes)
return &IbcMessage{
EventType: event.Type,
Info: ci,
}
msgInfo = &ConnectionInfo{Height: height}
case clienttypes.EventTypeCreateClient, clienttypes.EventTypeUpdateClient,
clienttypes.EventTypeUpgradeClient, clienttypes.EventTypeSubmitMisbehaviour,
clienttypes.EventTypeUpdateClientProposal:
ci := new(ClientInfo)
ci.ParseAttrs(log, event.Attributes)
return &IbcMessage{
EventType: event.Type,
Info: ci,
}

msgInfo = new(ClientInfo)
case string(processor.ClientICQTypeRequest), string(processor.ClientICQTypeResponse):
ci := &ClientICQInfo{
msgInfo = &ClientICQInfo{
Height: height,
Source: chainID,
}
ci.ParseAttrs(log, event.Attributes)
return &IbcMessage{
EventType: event.Type,
Info: ci,
}
default:
return nil
}
msgInfo.ParseAttrs(log, event.Attributes)
return &IbcMessage{
EventType: event.Type,
Info: msgInfo,
}
return nil
}

func (msg *IbcMessage) parseIBCPacketReceiveMessageFromEvent(
Expand Down

0 comments on commit 1b7c023

Please sign in to comment.