mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
nonce-tracker - use blockTracker directly
This commit is contained in:
parent
f0713d4b1a
commit
dcf10f3d75
@ -46,6 +46,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
this.txStateManager.on('tx:status-update', this.emit.bind(this, 'tx:status-update'))
|
this.txStateManager.on('tx:status-update', this.emit.bind(this, 'tx:status-update'))
|
||||||
this.nonceTracker = new NonceTracker({
|
this.nonceTracker = new NonceTracker({
|
||||||
provider: this.provider,
|
provider: this.provider,
|
||||||
|
blockTracker: this.blockTracker,
|
||||||
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
|
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
|
||||||
getConfirmedTransactions: (address) => {
|
getConfirmedTransactions: (address) => {
|
||||||
return this.txStateManager.getFilteredTxList({
|
return this.txStateManager.getFilteredTxList({
|
||||||
|
@ -4,8 +4,9 @@ const Mutex = require('await-semaphore').Mutex
|
|||||||
|
|
||||||
class NonceTracker {
|
class NonceTracker {
|
||||||
|
|
||||||
constructor ({ provider, getPendingTransactions, getConfirmedTransactions }) {
|
constructor ({ provider, blockTracker, getPendingTransactions, getConfirmedTransactions }) {
|
||||||
this.provider = provider
|
this.provider = provider
|
||||||
|
this.blockTracker = blockTracker
|
||||||
this.ethQuery = new EthQuery(provider)
|
this.ethQuery = new EthQuery(provider)
|
||||||
this.getPendingTransactions = getPendingTransactions
|
this.getPendingTransactions = getPendingTransactions
|
||||||
this.getConfirmedTransactions = getConfirmedTransactions
|
this.getConfirmedTransactions = getConfirmedTransactions
|
||||||
@ -53,7 +54,7 @@ class NonceTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _getCurrentBlock () {
|
async _getCurrentBlock () {
|
||||||
const blockTracker = this._getBlockTracker()
|
const blockTracker = this.blockTracker
|
||||||
const currentBlock = blockTracker.getCurrentBlock()
|
const currentBlock = blockTracker.getCurrentBlock()
|
||||||
if (currentBlock) return currentBlock
|
if (currentBlock) return currentBlock
|
||||||
return await Promise((reject, resolve) => {
|
return await Promise((reject, resolve) => {
|
||||||
@ -139,11 +140,6 @@ class NonceTracker {
|
|||||||
return { name: 'local', nonce: highest, details: { startPoint, highest } }
|
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
|
module.exports = NonceTracker
|
||||||
|
@ -190,12 +190,13 @@ function generateNonceTrackerWith (pending, confirmed, providerStub = '0x0') {
|
|||||||
providerResultStub.result = providerStub
|
providerResultStub.result = providerStub
|
||||||
const provider = {
|
const provider = {
|
||||||
sendAsync: (_, cb) => { cb(undefined, providerResultStub) },
|
sendAsync: (_, cb) => { cb(undefined, providerResultStub) },
|
||||||
_blockTracker: {
|
}
|
||||||
|
const blockTracker = {
|
||||||
getCurrentBlock: () => '0x11b568',
|
getCurrentBlock: () => '0x11b568',
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return new NonceTracker({
|
return new NonceTracker({
|
||||||
provider,
|
provider,
|
||||||
|
blockTracker,
|
||||||
getPendingTransactions,
|
getPendingTransactions,
|
||||||
getConfirmedTransactions,
|
getConfirmedTransactions,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user