|
|
@ -11,14 +11,23 @@ class Recorder { |
|
|
|
self.clearAll() |
|
|
|
self.clearAll() |
|
|
|
}) |
|
|
|
}) |
|
|
|
var counter = 0 |
|
|
|
var counter = 0 |
|
|
|
|
|
|
|
function getIndex (accounts, address) { |
|
|
|
|
|
|
|
var index |
|
|
|
|
|
|
|
accounts.forEach((addr, idx) => { if (address === addr) index = idx }) |
|
|
|
|
|
|
|
if (!index) index = (++counter) |
|
|
|
|
|
|
|
return index |
|
|
|
|
|
|
|
} |
|
|
|
self._addressCache = {} |
|
|
|
self._addressCache = {} |
|
|
|
opts.events.udapp.register('initiatingTransaction', (timestamp, tx) => { |
|
|
|
opts.events.udapp.register('initiatingTransaction', (timestamp, tx) => { |
|
|
|
var { from, to, value, gas, data } = tx |
|
|
|
var { from, to, value, gas, data } = tx |
|
|
|
var record = { value, gas, data } |
|
|
|
var record = { value, gas, data } |
|
|
|
record.from = self._addressCache[from] || (self._addressCache[from] = `<account -${(++counter)}>`) |
|
|
|
self._api.getAccounts(function (err, accounts = []) { |
|
|
|
if (to === null) self.data._pendingCreation[timestamp] = record |
|
|
|
if (err) console.error(err) |
|
|
|
else record.to = self._addressCache[to] || (self._addressCache[to] = `<account -${(++counter)}>`) |
|
|
|
record.from = self._addressCache[from] || (self._addressCache[from] = `<account - ${getIndex(accounts, from)}>`) |
|
|
|
self.append(timestamp, record) |
|
|
|
if (to === null) self.data._pendingCreation[timestamp] = record |
|
|
|
|
|
|
|
else record.to = self._addressCache[to] || (self._addressCache[to] = `<account - ${getIndex(accounts, to)}>`) |
|
|
|
|
|
|
|
self.append(timestamp, record) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
opts.events.udapp.register('transactionExecuted', (...args) => { |
|
|
|
opts.events.udapp.register('transactionExecuted', (...args) => { |
|
|
|
var err = args[0] |
|
|
|
var err = args[0] |
|
|
|