|
|
|
@ -56,21 +56,22 @@ export class EventsDecoder { |
|
|
|
|
return eventsABI |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_event (hash: string, eventsABI: Record<string, unknown>, contractName: string) { |
|
|
|
|
const events = eventsABI[contractName] |
|
|
|
|
if (!events) return null |
|
|
|
|
|
|
|
|
|
if (events[hash]) { |
|
|
|
|
const event = events[hash] |
|
|
|
|
_event (hash, eventsABI) { |
|
|
|
|
// get all the events responding to that hash.
|
|
|
|
|
const contracts = [] |
|
|
|
|
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' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return event |
|
|
|
|
contracts.push(event) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return null |
|
|
|
|
return contracts |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_stringifyBigNumber (value): string { |
|
|
|
@ -95,7 +96,9 @@ export class EventsDecoder { |
|
|
|
|
// [address, topics, mem]
|
|
|
|
|
const log = logs[i] |
|
|
|
|
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) { |
|
|
|
|
const decodedlog = eventAbi.abi.parseLog(log) |
|
|
|
|
const decoded = {} |
|
|
|
@ -106,6 +109,11 @@ export class EventsDecoder { |
|
|
|
|
} else { |
|
|
|
|
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 }) |
|
|
|
|
} |
|
|
|
|