From 53ad0354653933786e737664d535a957191afa80 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 18 Feb 2022 19:55:11 +0100 Subject: [PATCH] fix retrieving events abi --- libs/remix-lib/src/execution/eventsDecoder.ts | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libs/remix-lib/src/execution/eventsDecoder.ts b/libs/remix-lib/src/execution/eventsDecoder.ts index 833cf189f0..4622b245fd 100644 --- a/libs/remix-lib/src/execution/eventsDecoder.ts +++ b/libs/remix-lib/src/execution/eventsDecoder.ts @@ -56,18 +56,19 @@ export class EventsDecoder { return eventsABI } - _event (hash, eventsABI) { - for (const k in eventsABI) { - if (eventsABI[k][hash]) { - const event = eventsABI[k][hash] - for (const input of event.inputs) { - if (input.type === 'function') { - input.type = 'bytes24' - input.baseType = 'bytes24' - } + _event (hash: string, eventsABI: Record, contractName: string) { + const events = eventsABI[contractName] + if (!events) return null + + if (events[hash]) { + const event = events[hash] + for (const input of event.inputs) { + if (input.type === 'function') { + input.type = 'bytes24' + input.baseType = 'bytes24' } - return event } + return event } return null } @@ -94,7 +95,7 @@ export class EventsDecoder { // [address, topics, mem] const log = logs[i] const topicId = log.topics[0] - const eventAbi = this._event(topicId.replace('0x', ''), eventsABI) + const eventAbi = this._event(topicId.replace('0x', ''), eventsABI, contractName) if (eventAbi) { const decodedlog = eventAbi.abi.parseLog(log) const decoded = {}