|
|
@ -35,8 +35,8 @@ class EventsDecoder { |
|
|
|
this._decodeEvents(tx, receipt.logs, contract, contracts, cb) |
|
|
|
this._decodeEvents(tx, receipt.logs, contract, contracts, cb) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_eventABI (contractName, compiledContracts) { |
|
|
|
_eventABI (contractabi) { |
|
|
|
var contractabi = JSON.parse(compiledContracts[contractName].interface) |
|
|
|
contractabi = JSON.parse(contractabi.interface) |
|
|
|
var eventABI = {} |
|
|
|
var eventABI = {} |
|
|
|
contractabi.forEach(function (funABI, i) { |
|
|
|
contractabi.forEach(function (funABI, i) { |
|
|
|
if (funABI.type !== 'event') { |
|
|
|
if (funABI.type !== 'event') { |
|
|
@ -48,13 +48,30 @@ class EventsDecoder { |
|
|
|
return eventABI |
|
|
|
return eventABI |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_eventsABI (compiledContracts) { |
|
|
|
|
|
|
|
var eventsABI = {} |
|
|
|
|
|
|
|
for (var contract in compiledContracts) { |
|
|
|
|
|
|
|
eventsABI[contract] = this._eventABI(compiledContracts[contract]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return eventsABI |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_event (hash, eventsABI) { |
|
|
|
|
|
|
|
for (var k in eventsABI) { |
|
|
|
|
|
|
|
if (eventsABI[k][hash]) { |
|
|
|
|
|
|
|
return eventsABI[k][hash] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_decodeEvents (tx, logs, contractName, compiledContracts, cb) { |
|
|
|
_decodeEvents (tx, logs, contractName, compiledContracts, cb) { |
|
|
|
var eventABI = this._eventABI(contractName, 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 abi = eventABI[log.topics[0].replace('0x', '')] |
|
|
|
var abi = this._event(log.topics[0].replace('0x', ''), eventsABI) |
|
|
|
if (abi) { |
|
|
|
if (abi) { |
|
|
|
var event |
|
|
|
var event |
|
|
|
try { |
|
|
|
try { |
|
|
|