Merge branch 'master' into regex

pull/5370/head
Rob 3 years ago committed by GitHub
commit 5913864204
  1. 50
      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'
}
} }
contracts.push(event)
} }
return event
} }
return null return contracts
} }
_stringifyBigNumber (value): string { _stringifyBigNumber (value): string {
@ -95,16 +96,23 @@ 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)
if (eventAbi) { for (const eventAbi of eventAbis) {
const decodedlog = eventAbi.abi.parseLog(log) try {
const decoded = {} if (eventAbi) {
for (const v in decodedlog.args) { const decodedlog = eventAbi.abi.parseLog(log)
decoded[v] = this._stringifyEvent(decodedlog.args[v]) const decoded = {}
for (const v in decodedlog.args) {
decoded[v] = this._stringifyEvent(decodedlog.args[v])
}
events.push({ from: log.address, topic: topicId, event: eventAbi.event, args: decoded })
} else {
events.push({ from: log.address, data: log.data, topics: log.topics })
}
break // if one of the iteration is successful
} catch (e) {
continue
} }
events.push({ from: log.address, topic: topicId, event: eventAbi.event, args: decoded })
} else {
events.push({ from: log.address, data: log.data, topics: log.topics })
} }
} }
cb(null, { decoded: events, raw: logs }) cb(null, { decoded: events, raw: logs })

Loading…
Cancel
Save