aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-04-28 06:29:10 +0800
committerDan Finlay <dan@danfinlay.com>2016-04-28 06:29:10 +0800
commit29718a82b6bae5957b6f772585419ebdc2c851cb (patch)
treea4806bb27c8a5fdd733cdf15c61790f126d06e50 /app
parent39a84c0e47f35bc0e7c2a632683dc9ae802900b3 (diff)
downloadtangerine-wallet-browser-29718a82b6bae5957b6f772585419ebdc2c851cb.tar
tangerine-wallet-browser-29718a82b6bae5957b6f772585419ebdc2c851cb.tar.gz
tangerine-wallet-browser-29718a82b6bae5957b6f772585419ebdc2c851cb.tar.bz2
tangerine-wallet-browser-29718a82b6bae5957b6f772585419ebdc2c851cb.tar.lz
tangerine-wallet-browser-29718a82b6bae5957b6f772585419ebdc2c851cb.tar.xz
tangerine-wallet-browser-29718a82b6bae5957b6f772585419ebdc2c851cb.tar.zst
tangerine-wallet-browser-29718a82b6bae5957b6f772585419ebdc2c851cb.zip
Record current network on each persisted transaction
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 1519f63db..cf5d0ff26 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -11,6 +11,7 @@ const createTxNotification = require('./lib/tx-notification.js')
const configManager = require('./lib/config-manager-singleton')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const HostStore = require('./lib/remote-store.js').HostStore
+const Web3 = require('web3')
//
// connect to other contexts
@@ -62,6 +63,7 @@ var providerOpts = {
signTransaction: idStore.signTransaction.bind(idStore),
}
var provider = MetaMaskProvider(providerOpts)
+var web3 = new Web3(provider)
// log new blocks
provider.on('block', function(block){
@@ -205,12 +207,18 @@ function updateBadge(state){
//
function addUnconfirmedTx(txParams, cb){
- 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),
+
+ 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),
+ })
})
}