Removed reliance on eth-store internal custom eth-query

feature/default_network_editable
Dan Finlay 8 years ago
parent 08351f801a
commit 3588aabdf2
  1. 21
      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

Loading…
Cancel
Save