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

Record current network on each persisted transaction

This commit is contained in:
Dan Finlay 2016-04-27 15:29:10 -07:00
parent 39a84c0e47
commit 29718a82b6

View File

@ -11,6 +11,7 @@ const createTxNotification = require('./lib/tx-notification.js')
const configManager = require('./lib/config-manager-singleton') const configManager = require('./lib/config-manager-singleton')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const HostStore = require('./lib/remote-store.js').HostStore const HostStore = require('./lib/remote-store.js').HostStore
const Web3 = require('web3')
// //
// connect to other contexts // connect to other contexts
@ -62,6 +63,7 @@ var providerOpts = {
signTransaction: idStore.signTransaction.bind(idStore), signTransaction: idStore.signTransaction.bind(idStore),
} }
var provider = MetaMaskProvider(providerOpts) var provider = MetaMaskProvider(providerOpts)
var web3 = new Web3(provider)
// log new blocks // log new blocks
provider.on('block', function(block){ provider.on('block', function(block){
@ -205,6 +207,11 @@ function updateBadge(state){
// //
function addUnconfirmedTx(txParams, cb){ function addUnconfirmedTx(txParams, cb){
web3.version.getNetwork(function(err, network) {
if (err) return cb(err)
txParams.metamaskNetworkId = network
var txId = idStore.addUnconfirmedTransaction(txParams, cb) var txId = idStore.addUnconfirmedTransaction(txParams, cb)
createTxNotification({ createTxNotification({
title: 'New Unsigned Transaction', title: 'New Unsigned Transaction',
@ -212,6 +219,7 @@ function addUnconfirmedTx(txParams, cb){
confirm: idStore.approveTransaction.bind(idStore, txId, noop), confirm: idStore.approveTransaction.bind(idStore, txId, noop),
cancel: idStore.cancelTransaction.bind(idStore, txId), cancel: idStore.cancelTransaction.bind(idStore, txId),
}) })
})
} }
// //