From 1be36668df3e833debb826c9518e554317c3b2cd Mon Sep 17 00:00:00 2001 From: serapath Date: Wed, 4 Oct 2017 16:15:37 +0200 Subject: [PATCH] REFACTOR names & FIX argument bugs --- src/recorder.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/recorder.js b/src/recorder.js index 5506309c89..141ecac45a 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -6,26 +6,27 @@ class Recorder { var self = this self._api = opts.api self.event = new EventManager() - self.data = { journal: [], _pending: {} } + self.data = { journal: [], _pendingCreation: {} } opts.events.executioncontext.register('contextChanged', function () { self.clearAll() }) - var counter = 1 + var counter = 0 self._addressCache = {} - opts.events.udapp.register('initiatingTransaction', (stamp, tx) => { + opts.events.udapp.register('initiatingTransaction', (timestamp, tx) => { var { from, to, value, gas, data } = tx var record = { value, gas, data } record.from = self._addressCache[from] || (self._addressCache[from] = ``) - if (to === null) self.data._pending[stamp] = record + if (to === null) self.data._pendingCreation[timestamp] = record else record.to = self._addressCache[to] || (self._addressCache[to] = ``) - self.append(stamp, record) + self.append(timestamp, record) }) - opts.events.udapp.register('transactionExecuted', args => { + opts.events.udapp.register('transactionExecuted', (...args) => { var err = args[0] if (err) console.error(err) - var stamp = args[6] - var record = self._pending[stamp] - delete self._pending[stamp] + var timestamp = args[6] + // update transaction which was pending with correct `to` address + var record = self._pendingCreation[timestamp] + delete self._pendingCreation[timestamp] if (!record) return var to = args[2] record.to = self._addressCache[to] || (self._addressCache[to] = ``)