From d017c2844165939f41613e1ae6141c8531422c44 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 27 Apr 2016 18:04:33 -0700 Subject: Filter transaction list for current blockchain network When starting up, we now create a `web3` inside the `background.js` process, which we pass to the `idStore` and ask for the current `network`. We include the `network` on `app.metamask.network` in the state object. We re-request the network when changing provider. We filter the transaction list for transactions that match the current network. --- app/scripts/lib/idStore.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'app/scripts/lib/idStore.js') diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 92d0f9668..e9aaed82e 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -16,11 +16,11 @@ module.exports = IdentityStore inherits(IdentityStore, EventEmitter) -function IdentityStore(ethStore) { +function IdentityStore(opts = {}) { EventEmitter.call(this) // we just use the ethStore to auto-add accounts - this._ethStore = ethStore + this._ethStore = opts.ethStore // lightwallet key store this._keyStore = null // lightwallet wrapper @@ -110,6 +110,16 @@ IdentityStore.prototype.setSelectedAddress = function(address){ this._didUpdate() } +IdentityStore.prototype.getNetwork = function(tries) { + if (tries === 0) return + this.web3.version.getNetwork((err, network) => { + if (err) { + return this.getNetwork(tries - 1, cb) + } + this._currentState.network = network + }) +} + IdentityStore.prototype.setLocked = function(cb){ delete this._keyStore delete this._idmgmt @@ -137,6 +147,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function(txParams, cb){ var time = (new Date()).getTime() var txId = createId() txParams.metamaskId = txId + txParams.metamaskNetworkId = this._currentState.network var txData = { id: txId, txParams: txParams, -- cgit v1.2.3