fix retrieving events abi

pull/5370/head
yann300 3 years ago
parent 0850267267
commit f68dbbdd1e
  1. 13
      libs/remix-lib/src/execution/eventsDecoder.ts

@ -56,10 +56,12 @@ export class EventsDecoder {
return eventsABI return eventsABI
} }
_event (hash, eventsABI) { _event (hash: string, eventsABI: Record<string, unknown>, contractName: string) {
for (const k in eventsABI) { const events = eventsABI[contractName]
if (eventsABI[k][hash]) { if (!events) return null
const event = eventsABI[k][hash]
if (events[hash]) {
const event = events[hash]
for (const input of event.inputs) { for (const input of event.inputs) {
if (input.type === 'function') { if (input.type === 'function') {
input.type = 'bytes24' input.type = 'bytes24'
@ -68,7 +70,6 @@ export class EventsDecoder {
} }
return event return event
} }
}
return null return null
} }
@ -94,7 +95,7 @@ export class EventsDecoder {
// [address, topics, mem] // [address, topics, mem]
const log = logs[i] const log = logs[i]
const topicId = log.topics[0] const topicId = log.topics[0]
const eventAbi = this._event(topicId.replace('0x', ''), eventsABI) const eventAbi = this._event(topicId.replace('0x', ''), eventsABI, contractName)
if (eventAbi) { if (eventAbi) {
const decodedlog = eventAbi.abi.parseLog(log) const decodedlog = eventAbi.abi.parseLog(log)
const decoded = {} const decoded = {}

Loading…
Cancel
Save