aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-10-19 08:07:25 +0800
committerDan Finlay <dan@danfinlay.com>2017-10-19 08:07:25 +0800
commitbbe2c9f48dd617e0696db50a3113df920dcaa974 (patch)
treecde9e7a2cb61dcfa254a7651aa12441e5c63c0fb /app/scripts/lib
parentd89394a7c9a5139ed5708ce7022fbbe2809e612a (diff)
parent6eb27389579586dc06ce840444bcdb207707e0b2 (diff)
downloadtangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.gz
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.bz2
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.lz
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.xz
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.zst
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.zip
Merge remote-tracking branch 'origin/master' into i2348-SelectAccountOnNewVault
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/events-proxy.js10
-rw-r--r--app/scripts/lib/nonce-tracker.js10
-rw-r--r--app/scripts/lib/obj-proxy.js19
3 files changed, 12 insertions, 27 deletions
diff --git a/app/scripts/lib/events-proxy.js b/app/scripts/lib/events-proxy.js
index 840b06b1a..d1199a278 100644
--- a/app/scripts/lib/events-proxy.js
+++ b/app/scripts/lib/events-proxy.js
@@ -1,5 +1,6 @@
-module.exports = function createEventEmitterProxy(eventEmitter, eventHandlers = {}) {
+module.exports = function createEventEmitterProxy(eventEmitter, listeners) {
let target = eventEmitter
+ const eventHandlers = listeners || {}
const proxy = new Proxy({}, {
get: (obj, name) => {
// intercept listeners
@@ -13,12 +14,9 @@ module.exports = function createEventEmitterProxy(eventEmitter, eventHandlers =
return true
},
})
- proxy.setTarget(eventEmitter)
- return proxy
-
function setTarget (eventEmitter) {
target = eventEmitter
- // migrate eventHandlers
+ // migrate listeners
Object.keys(eventHandlers).forEach((name) => {
eventHandlers[name].forEach((handler) => target.on(name, handler))
})
@@ -28,4 +26,6 @@ module.exports = function createEventEmitterProxy(eventEmitter, eventHandlers =
eventHandlers[name].push(handler)
target.on(name, handler)
}
+ if (listeners) proxy.setTarget(eventEmitter)
+ return proxy
} \ No newline at end of file
diff --git a/app/scripts/lib/nonce-tracker.js b/app/scripts/lib/nonce-tracker.js
index 2af40a27f..0029ac953 100644
--- a/app/scripts/lib/nonce-tracker.js
+++ b/app/scripts/lib/nonce-tracker.js
@@ -4,9 +4,8 @@ const Mutex = require('await-semaphore').Mutex
class NonceTracker {
- constructor ({ provider, blockTracker, getPendingTransactions, getConfirmedTransactions }) {
+ constructor ({ provider, getPendingTransactions, getConfirmedTransactions }) {
this.provider = provider
- this.blockTracker = blockTracker
this.ethQuery = new EthQuery(provider)
this.getPendingTransactions = getPendingTransactions
this.getConfirmedTransactions = getConfirmedTransactions
@@ -54,7 +53,7 @@ class NonceTracker {
}
async _getCurrentBlock () {
- const blockTracker = this.blockTracker
+ const blockTracker = this._getBlockTracker()
const currentBlock = blockTracker.getCurrentBlock()
if (currentBlock) return currentBlock
return await Promise((reject, resolve) => {
@@ -140,6 +139,11 @@ class NonceTracker {
return { name: 'local', nonce: highest, details: { startPoint, highest } }
}
+ // this is a hotfix for the fact that the blockTracker will
+ // change when the network changes
+ _getBlockTracker () {
+ return this.provider._blockTracker
+ }
}
module.exports = NonceTracker
diff --git a/app/scripts/lib/obj-proxy.js b/app/scripts/lib/obj-proxy.js
deleted file mode 100644
index 29ca1269f..000000000
--- a/app/scripts/lib/obj-proxy.js
+++ /dev/null
@@ -1,19 +0,0 @@
-module.exports = function createObjectProxy(obj) {
- let target = obj
- const proxy = new Proxy({}, {
- get: (obj, name) => {
- // intercept setTarget
- if (name === 'setTarget') return setTarget
- return target[name]
- },
- set: (obj, name, value) => {
- target[name] = value
- return true
- },
- })
- return proxy
-
- function setTarget (obj) {
- target = obj
- }
-} \ No newline at end of file