diff --git a/usecase/parser/ibc/msg.go b/usecase/parser/ibc/msg.go index 3e874362..263faa58 100644 --- a/usecase/parser/ibc/msg.go +++ b/usecase/parser/ibc/msg.go @@ -927,50 +927,57 @@ func ParseMsgTransfer( } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) - event := log.GetEventByType("send_packet") - if event == nil { - panic("missing `send_packet` event in TxsResult log") - } if parserParams.IsEthereumTxInnerMsg { - // Transfer application, MsgTransfer - packetData := event.MustGetAttributeByKey("packet_data") - var fungiblePacketData ibc_model.FungibleTokenPacketData + events := log.GetEventsByType("send_packet") + for _, event := range events { + // Transfer application, MsgTransfer + packetData := event.MustGetAttributeByKey("packet_data") - if unmarshalErr := jsoniter.Unmarshal([]byte(packetData), &fungiblePacketData); unmarshalErr != nil { - panic("unable to parse `send_packet` event, key `packet_data`") - } + var fungiblePacketData *ibc_model.FungibleTokenPacketData + if unmarshalErr := jsoniter.Unmarshal([]byte(packetData), &fungiblePacketData); unmarshalErr != nil { + panic("unable to parse `send_packet` event, key `packet_data`") + } - msgTransferParams := ibc_model.MsgTransferParams{ - RawMsgTransfer: ibc_model.RawMsgTransfer{ - Token: ibc_model.MsgTransferToken{ - Denom: fungiblePacketData.Denom, - Amount: fungiblePacketData.Amount, - }, - Sender: fungiblePacketData.Sender, - Receiver: fungiblePacketData.Receiver, - SourcePort: event.MustGetAttributeByKey("packet_src_port"), - SourceChannel: event.MustGetAttributeByKey("packet_src_channel"), - TimeoutHeight: MustParseHeight(event.MustGetAttributeByKey("packet_timeout_height")), - TimeoutTimestamp: event.MustGetAttributeByKey("packet_timeout_timestamp"), - }, + if fungiblePacketData != nil { + msgTransferParams := ibc_model.MsgTransferParams{ + RawMsgTransfer: ibc_model.RawMsgTransfer{ + Token: ibc_model.MsgTransferToken{ + Denom: fungiblePacketData.Denom, + Amount: fungiblePacketData.Amount, + }, + Sender: fungiblePacketData.Sender, + Receiver: fungiblePacketData.Receiver, + SourcePort: event.MustGetAttributeByKey("packet_src_port"), + SourceChannel: event.MustGetAttributeByKey("packet_src_channel"), + TimeoutHeight: MustParseHeight(event.MustGetAttributeByKey("packet_timeout_height")), + TimeoutTimestamp: event.MustGetAttributeByKey("packet_timeout_timestamp"), + }, - PacketSequence: typeconv.MustAtou64(event.MustGetAttributeByKey("packet_sequence")), - DestinationPort: event.MustGetAttributeByKey("packet_dst_port"), - DestinationChannel: event.MustGetAttributeByKey("packet_dst_channel"), - ChannelOrdering: event.MustGetAttributeByKey("packet_channel_ordering"), - ConnectionID: event.MustGetAttributeByKey("packet_connection"), - PacketData: fungiblePacketData, - } - // Getting possible signer address from Msg - var possibleSignerAddresses []string - possibleSignerAddresses = append(possibleSignerAddresses, msgTransferParams.Sender) + PacketSequence: typeconv.MustAtou64(event.MustGetAttributeByKey("packet_sequence")), + DestinationPort: event.MustGetAttributeByKey("packet_dst_port"), + DestinationChannel: event.MustGetAttributeByKey("packet_dst_channel"), + ChannelOrdering: event.MustGetAttributeByKey("packet_channel_ordering"), + ConnectionID: event.MustGetAttributeByKey("packet_connection"), + PacketData: *fungiblePacketData, + } - return []command.Command{command_usecase.NewCreateMsgIBCTransferTransfer( - parserParams.MsgCommonParams, + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgTransferParams.Sender) - msgTransferParams, - )}, possibleSignerAddresses + return []command.Command{command_usecase.NewCreateMsgIBCTransferTransfer( + parserParams.MsgCommonParams, + + msgTransferParams, + )}, possibleSignerAddresses + } + } + } + + event := log.GetEventByType("send_packet") + if event == nil { + panic("missing `send_packet` event in TxsResult log") } packetData := event.MustGetAttributeByKey("packet_data") diff --git a/usecase/parser/msg.go b/usecase/parser/msg.go index e32d1a6c..39eaa87f 100644 --- a/usecase/parser/msg.go +++ b/usecase/parser/msg.go @@ -2505,7 +2505,8 @@ func ParseMsgEthereumTx( // parse msgTransfer case log.HasEvent("send_packet"): { - if log.GetEventByType("send_packet") != nil { + sendEvents := log.GetEventsByType("send_packet") + if len(sendEvents) > 0 { parserParams.IsEthereumTxInnerMsg = true cmds, signers := ibc.ParseMsgTransfer(parserParams) commands = append(commands, cmds...)