1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

nonce-tracker - hotfix for provider proxying

This commit is contained in:
kumavis 2017-07-26 11:37:00 -07:00
parent b15a2baaf3
commit 35a128db1e
2 changed files with 11 additions and 5 deletions

View File

@ -24,7 +24,6 @@ module.exports = class TransactionController extends EventEmitter {
this.blockTracker = opts.blockTracker
this.nonceTracker = new NonceTracker({
provider: this.provider,
blockTracker: this.provider._blockTracker,
getPendingTransactions: (address) => {
return this.getFilteredTxList({
from: address,

View File

@ -4,8 +4,8 @@ const Mutex = require('await-semaphore').Mutex
class NonceTracker {
constructor ({ blockTracker, provider, getPendingTransactions }) {
this.blockTracker = blockTracker
constructor ({ provider, getPendingTransactions }) {
this.provider = provider
this.ethQuery = new EthQuery(provider)
this.getPendingTransactions = getPendingTransactions
this.lockMap = {}
@ -45,10 +45,11 @@ class NonceTracker {
}
async _getCurrentBlock () {
const currentBlock = this.blockTracker.getCurrentBlock()
const blockTracker = this._getBlockTracker()
const currentBlock = blockTracker.getCurrentBlock()
if (currentBlock) return currentBlock
return await Promise((reject, resolve) => {
this.blockTracker.once('latest', resolve)
blockTracker.once('latest', resolve)
})
}
@ -82,6 +83,12 @@ class NonceTracker {
return mutex
}
// this is a hotfix for the fact that the blockTracker will
// change when the network changes
_getBlockTracker () {
return this.provider._blockTracker
}
}
module.exports = NonceTracker