diff options
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.
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r-- | app/scripts/background.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index cf5d0ff26..172e3819d 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -52,6 +52,7 @@ function setupTrustedCommunication(connectionStream){ var providerConfig = configManager.getProvider() var idStore = new IdentityStore() + var providerOpts = { rpcUrl: configManager.getCurrentRpcAddress(), getAccounts: function(cb){ @@ -64,6 +65,8 @@ var providerOpts = { } var provider = MetaMaskProvider(providerOpts) var web3 = new Web3(provider) +idStore.web3 = web3 +idStore.getNetwork(3) // log new blocks provider.on('block', function(block){ @@ -207,18 +210,12 @@ function updateBadge(state){ // function addUnconfirmedTx(txParams, cb){ - - web3.version.getNetwork(function(err, network) { - if (err) return cb(err) - - txParams.metamaskNetworkId = network - var txId = idStore.addUnconfirmedTransaction(txParams, cb) - createTxNotification({ - title: 'New Unsigned Transaction', - txParams: txParams, - confirm: idStore.approveTransaction.bind(idStore, txId, noop), - cancel: idStore.cancelTransaction.bind(idStore, txId), - }) + var txId = idStore.addUnconfirmedTransaction(txParams, cb) + createTxNotification({ + title: 'New Unsigned Transaction', + txParams: txParams, + confirm: idStore.approveTransaction.bind(idStore, txId, noop), + cancel: idStore.cancelTransaction.bind(idStore, txId), }) } @@ -230,6 +227,7 @@ function addUnconfirmedTx(txParams, cb){ function setRpcTarget(rpcTarget){ configManager.setRpcTarget(rpcTarget) chrome.runtime.reload() + idStore.getNetwork(3) // 3 retry attempts } function useEtherscanProvider() { |