diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js
index d4866b1063..7b18169e0c 100644
--- a/src/app/tabs/run-tab.js
+++ b/src/app/tabs/run-tab.js
@@ -1,7 +1,6 @@
'use strict'
var $ = require('jquery')
var yo = require('yo-yo')
-var detectNetwork = require('../../lib/detect-network')
var helper = require('../../lib/helper.js')
var txExecution = require('../execution/txExecution')
var txFormat = require('../execution/txFormat')
@@ -383,12 +382,9 @@ function settings (appAPI, appEvents) {
// SETTINGS HTML
var net = yo``
const updateNetwork = () => {
- detectNetwork((err, { id, name } = {}) => {
+ executionContext.detectNetwork((err, { id, name } = {}) => {
if (err) console.error(err)
- console.log(`update network[${id}] name: ${name}`)
- net.innerHTML = `
- ${name}(${id || '-'})
- `
+ net.innerHTML = ` ${name}(${id || '-'})`
})
}
updateNetwork()
diff --git a/src/execution-context.js b/src/execution-context.js
index c9dcaafa90..811a8e2505 100644
--- a/src/execution-context.js
+++ b/src/execution-context.js
@@ -91,7 +91,21 @@ function ExecutionContext () {
}
this.web3 = function () {
- return this.isVM() ? web3VM : web3
+ return this.isVM() ? web3VM.web3 : web3
+ }
+
+ this.detectNetwork = function (callback) {
+ this.web3().version.getNetwork((err, id) => {
+ var name = null
+ if (err) name = 'Unknown'
+ else if (id === '1') name = 'Main'
+ else if (id === '2') name = 'Morden (deprecated)'
+ else if (id === '3') name = 'Ropsten'
+ else if (id === '4') name = 'Rinkeby'
+ else if (id === '42') name = 'Kovan'
+ else name = 'Unknown'
+ callback(err, { id, name })
+ })
}
this.internalWeb3 = function () {
diff --git a/src/lib/detect-network.js b/src/lib/detect-network.js
deleted file mode 100644
index e9063dde7b..0000000000
--- a/src/lib/detect-network.js
+++ /dev/null
@@ -1,19 +0,0 @@
-var executionContext = require('../execution-context')
-window.executionContext = executionContext
-module.exports = detectNetwork
-
-function detectNetwork (callback) {
- var web3provider = executionContext.web3()
- var get = web3provider.version ? web3provider.version.getNetwork : web3provider.web3.version.getNetwork
- get((err, id) => {
- var name = null
- if (err) name = 'Unknown'
- else if (id === '1') name = 'Main'
- else if (id === '2') name = 'Morden (deprecated)'
- else if (id === '3') name = 'Ropsten'
- else if (id === '4') name = 'Rinkeby'
- else if (id === '42') name = 'Kovan'
- else name = 'Unknown'
- callback(err, { id, name })
- })
-}