Commit ad90b48c authored by yann300's avatar yann300

add tx logger

parent 66357a22
'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)
}
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