Merge branch 'master' into regex

pull/5370/head
Rob 3 years ago committed by GitHub
commit 5913864204
  1. 26
      libs/remix-lib/src/execution/eventsDecoder.ts

@ -56,21 +56,22 @@ export class EventsDecoder {
return eventsABI return eventsABI
} }
_event (hash: string, eventsABI: Record<string, unknown>, contractName: string) { _event (hash, eventsABI) {
const events = eventsABI[contractName] // get all the events responding to that hash.
if (!events) return null const contracts = []
for (const k in eventsABI) {
if (events[hash]) { if (eventsABI[k][hash]) {
const event = events[hash] const event = eventsABI[k][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'
input.baseType = 'bytes24' input.baseType = 'bytes24'
} }
} }
return event contracts.push(event)
}
} }
return null return contracts
} }
_stringifyBigNumber (value): string { _stringifyBigNumber (value): string {
@ -95,7 +96,9 @@ 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, contractName) const eventAbis = this._event(topicId.replace('0x', ''), eventsABI)
for (const eventAbi of eventAbis) {
try {
if (eventAbi) { if (eventAbi) {
const decodedlog = eventAbi.abi.parseLog(log) const decodedlog = eventAbi.abi.parseLog(log)
const decoded = {} const decoded = {}
@ -106,6 +109,11 @@ export class EventsDecoder {
} else { } else {
events.push({ from: log.address, data: log.data, topics: log.topics }) events.push({ from: log.address, data: log.data, topics: log.topics })
} }
break // if one of the iteration is successful
} catch (e) {
continue
}
}
} }
cb(null, { decoded: events, raw: logs }) cb(null, { decoded: events, raw: logs })
} }

Loading…
Cancel
Save