Commit d314cb04 authored by yann300's avatar yann300

fix bug: return array event and not the last one

parent a39d874e
...@@ -66,16 +66,20 @@ class EventsDecoder { ...@@ -66,16 +66,20 @@ class EventsDecoder {
_decodeEvents (tx, logs, contractName, compiledContracts, cb) { _decodeEvents (tx, logs, contractName, compiledContracts, cb) {
var eventsABI = this._eventsABI(compiledContracts) var eventsABI = this._eventsABI(compiledContracts)
var events = {} var events = []
for (var i in logs) { for (var i in logs) {
// [address, topics, mem] // [address, topics, mem]
var log = logs[i] var log = logs[i]
var topicId = log.topics[0] var topicId = log.topics[0]
var abi = this._event(topicId.replace('0x', ''), eventsABI) var abi = this._event(topicId.replace('0x', ''), eventsABI)
if (abi) {
var topics = log.topics.map((value) => { var topics = log.topics.map((value) => {
return value.indexOf('0x') === 0 ? value : '0x' + value return value.indexOf('0x') === 0 ? value : '0x' + value
}) })
events = abi.object.parse(topics, '0x' + log.data) events.push({ topic: topicId, event: abi.event, args: abi.object.parse(topics, '0x' + log.data) })
} else {
events.push({ data: log.data, topics: log.topics })
}
} }
cb(null, { decoded: events, raw: logs }) cb(null, { decoded: events, raw: logs })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment