parent
66357a2210
commit
ad90b48c8e
@ -0,0 +1,31 @@ |
||||
'use strict' |
||||
|
||||
module.exports = (opts = {}) => { |
||||
opts.events.txListener.register('newTransaction', (tx) => { |
||||
log(tx, opts.api) |
||||
}) |
||||
} |
||||
|
||||
function log (tx, api) { |
||||
var resolvedTransaction = api.resolvedTransaction(tx.hash) |
||||
if (resolvedTransaction) { |
||||
api.parseLogs(tx, resolvedTransaction.contractName, api.compiledContracts(), (error, logs) => { |
||||
if (!error) { |
||||
api.log(renderResolvedTransaction(tx, resolvedTransaction, logs)) |
||||
} |
||||
}) |
||||
} else { |
||||
// contract unknown - just displaying raw tx.
|
||||
api.log(renderTransaction(tx)) |
||||
} |
||||
} |
||||
|
||||
function renderResolvedTransaction (tx, resolvedTransaction, logs) { |
||||
console.log([tx, resolvedTransaction]) |
||||
return JSON.stringify([tx, resolvedTransaction]) |
||||
} |
||||
|
||||
function renderTransaction (tx) { |
||||
console.log(tx) |
||||
return JSON.stringify(tx) |
||||
} |
Loading…
Reference in new issue