diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-01-05 06:01:32 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-01-05 06:01:32 +0800 |
commit | 3588aabdf2639f65a5896f2f249c1277f3c95b84 (patch) | |
tree | db4a34bd512339d1f6bb1f8405540326ec4ba910 /app/scripts/lib | |
parent | 08351f801abd1bfd2a8c7071c6a3b0bd40570a4e (diff) | |
download | tangerine-wallet-browser-3588aabdf2639f65a5896f2f249c1277f3c95b84.tar tangerine-wallet-browser-3588aabdf2639f65a5896f2f249c1277f3c95b84.tar.gz tangerine-wallet-browser-3588aabdf2639f65a5896f2f249c1277f3c95b84.tar.bz2 tangerine-wallet-browser-3588aabdf2639f65a5896f2f249c1277f3c95b84.tar.lz tangerine-wallet-browser-3588aabdf2639f65a5896f2f249c1277f3c95b84.tar.xz tangerine-wallet-browser-3588aabdf2639f65a5896f2f249c1277f3c95b84.tar.zst tangerine-wallet-browser-3588aabdf2639f65a5896f2f249c1277f3c95b84.zip |
Removed reliance on eth-store internal custom eth-query
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/eth-store.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/scripts/lib/eth-store.js b/app/scripts/lib/eth-store.js index aeb5667e5..e2451408c 100644 --- a/app/scripts/lib/eth-store.js +++ b/app/scripts/lib/eth-store.js @@ -34,7 +34,7 @@ EthereumStore.prototype.addAccount = function(address){ self._currentState.accounts[address] = {} self._didUpdate() if (!self.currentBlockNumber) return - self._updateAccountForBlock(self.currentBlockNumber, address, noop) + self._updateAccount(self.currentBlockNumber, address, noop) } EthereumStore.prototype.removeAccount = function(address){ @@ -73,7 +73,7 @@ EthereumStore.prototype._updateForBlock = function(block) { var blockNumber = '0x'+block.number.toString('hex') self.currentBlockNumber = blockNumber async.parallel([ - self._updateAccountsForBlock.bind(self, blockNumber), + self._updateAccounts.bind(self), self._updateTransactions.bind(self, blockNumber), ], function(err){ if (err) return console.error(err) @@ -81,17 +81,17 @@ EthereumStore.prototype._updateForBlock = function(block) { }) } -EthereumStore.prototype._updateAccountsForBlock = function(block, cb) { +EthereumStore.prototype._updateAccounts = function(cb) { const self = this var accountsState = self._currentState.accounts var addresses = Object.keys(accountsState) - async.each(addresses, self._updateAccountForBlock.bind(self, block), cb) + async.each(addresses, self._updateAccount.bind(self), cb) } -EthereumStore.prototype._updateAccountForBlock = function(block, address, cb) { +EthereumStore.prototype._updateAccount = function(address, cb) { const self = this var accountsState = self._currentState.accounts - self._query.getAccount(address, block, function(err, result){ + self._query.getAccount(address, function(err, result){ if (err) return cb(err) result.address = address // only populate if the entry is still present @@ -103,6 +103,15 @@ EthereumStore.prototype._updateAccountForBlock = function(block, address, cb) { }) } +EthereumStore.prototype.getAccount = function(address, cb){ + const block = 'latest' + async.parallel({ + balance: this._query.getBalance.bind(this, address, block), + nonce: this._query.getNonce.bind(this, address, block), + code: this._query.getCode.bind(this, address, block), + }, cb) +} + EthereumStore.prototype._updateTransactions = function(block, cb) { const self = this var transactionsState = self._currentState.transactions |