aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-01-05 06:05:00 +0800
committerDan Finlay <dan@danfinlay.com>2017-01-05 06:05:00 +0800
commit381a60695d218d2ae965df9a9a2566029302d133 (patch)
tree1708b4a1336e82c569d7444aa3c25cada6009bb2 /app
parent0fab22082a4583f2ca8b39c8a73ee338302d6561 (diff)
downloadtangerine-wallet-browser-381a60695d218d2ae965df9a9a2566029302d133.tar
tangerine-wallet-browser-381a60695d218d2ae965df9a9a2566029302d133.tar.gz
tangerine-wallet-browser-381a60695d218d2ae965df9a9a2566029302d133.tar.bz2
tangerine-wallet-browser-381a60695d218d2ae965df9a9a2566029302d133.tar.lz
tangerine-wallet-browser-381a60695d218d2ae965df9a9a2566029302d133.tar.xz
tangerine-wallet-browser-381a60695d218d2ae965df9a9a2566029302d133.tar.zst
tangerine-wallet-browser-381a60695d218d2ae965df9a9a2566029302d133.zip
Linted
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/eth-store.js39
1 files changed, 17 insertions, 22 deletions
diff --git a/app/scripts/lib/eth-store.js b/app/scripts/lib/eth-store.js
index e2451408c..0ed7ef545 100644
--- a/app/scripts/lib/eth-store.js
+++ b/app/scripts/lib/eth-store.js
@@ -24,12 +24,12 @@ function EthereumStore(engine) {
// public
//
-EthereumStore.prototype.getState = function(){
+EthereumStore.prototype.getState = function () {
const self = this
return clone(self._currentState)
}
-EthereumStore.prototype.addAccount = function(address){
+EthereumStore.prototype.addAccount = function (address) {
const self = this
self._currentState.accounts[address] = {}
self._didUpdate()
@@ -37,13 +37,13 @@ EthereumStore.prototype.addAccount = function(address){
self._updateAccount(self.currentBlockNumber, address, noop)
}
-EthereumStore.prototype.removeAccount = function(address){
+EthereumStore.prototype.removeAccount = function (address) {
const self = this
delete self._currentState.accounts[address]
self._didUpdate()
}
-EthereumStore.prototype.addTransaction = function(txHash){
+EthereumStore.prototype.addTransaction = function (txHash) {
const self = this
self._currentState.transactions[txHash] = {}
self._didUpdate()
@@ -51,7 +51,7 @@ EthereumStore.prototype.addTransaction = function(txHash){
self._updateTransaction(self.currentBlockNumber, txHash, noop)
}
-EthereumStore.prototype.removeTransaction = function(address){
+EthereumStore.prototype.removeTransaction = function (address) {
const self = this
delete self._currentState.transactions[address]
self._didUpdate()
@@ -62,36 +62,36 @@ EthereumStore.prototype.removeTransaction = function(address){
// private
//
-EthereumStore.prototype._didUpdate = function() {
+EthereumStore.prototype._didUpdate = function () {
const self = this
var state = self.getState()
self.emit('update', state)
}
-EthereumStore.prototype._updateForBlock = function(block) {
+EthereumStore.prototype._updateForBlock = function (block) {
const self = this
var blockNumber = '0x'+block.number.toString('hex')
self.currentBlockNumber = blockNumber
async.parallel([
self._updateAccounts.bind(self),
self._updateTransactions.bind(self, blockNumber),
- ], function(err){
+ ], function (err) {
if (err) return console.error(err)
self.emit('block', self.getState())
})
}
-EthereumStore.prototype._updateAccounts = function(cb) {
+EthereumStore.prototype._updateAccounts = function (cb) {
const self = this
var accountsState = self._currentState.accounts
var addresses = Object.keys(accountsState)
async.each(addresses, self._updateAccount.bind(self), cb)
}
-EthereumStore.prototype._updateAccount = function(address, cb) {
+EthereumStore.prototype._updateAccount = function (address, cb) {
const self = this
var accountsState = self._currentState.accounts
- self._query.getAccount(address, 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,7 +103,7 @@ EthereumStore.prototype._updateAccount = function(address, cb) {
})
}
-EthereumStore.prototype.getAccount = function(address, cb){
+EthereumStore.prototype.getAccount = function (address, cb) {
const block = 'latest'
async.parallel({
balance: this._query.getBalance.bind(this, address, block),
@@ -112,21 +112,20 @@ EthereumStore.prototype.getAccount = function(address, cb){
}, cb)
}
-EthereumStore.prototype._updateTransactions = function(block, cb) {
+EthereumStore.prototype._updateTransactions = function (block, cb) {
const self = this
var transactionsState = self._currentState.transactions
var txHashes = Object.keys(transactionsState)
async.each(txHashes, self._updateTransaction.bind(self, block), cb)
}
-EthereumStore.prototype._updateTransaction = function(block, txHash, cb) {
+EthereumStore.prototype._updateTransaction = function (block, txHash, cb) {
const self = this
// would use the block here to determine how many confirmations the tx has
var transactionsState = self._currentState.transactions
- self._query.getTransaction(txHash, function(err, result){
+ self._query.getTransaction(txHash, function (err, result) {
if (err) return cb(err)
- // only populate if the entry is still present
- if (transactionsState[txHash]) {
+ // only populate if the entry is still present if (transactionsState[txHash]) {
transactionsState[txHash] = result
self._didUpdate()
}
@@ -134,8 +133,4 @@ EthereumStore.prototype._updateTransaction = function(block, txHash, cb) {
})
}
-function valuesFor(obj){
- return Object.keys(obj).map(function(key){ return obj[key] })
-}
-
-function noop(){}
+function noop() {}