From f3331b29d450c602eeb8a5ca90cc04061ef2d3ca Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 12:40:20 +0100 Subject: [PATCH] add VM type --- src/execution-context.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/execution-context.js b/src/execution-context.js index ea85682d3c..0c279a3b73 100644 --- a/src/execution-context.js +++ b/src/execution-context.js @@ -95,18 +95,22 @@ function ExecutionContext () { } this.detectNetwork = function (callback) { - this.web3().version.getNetwork((err, id) => { - var name = null - if (err) name = 'Unknown' - // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md - 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 }) - }) + if (this.isVM()) { + callback(null, { id: '-', name: 'VM' }) + } else { + this.web3().version.getNetwork((err, id) => { + var name = null + if (err) name = 'Unknown' + // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md + 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 = 'Custom' + callback(err, { id, name }) + }) + } } this.internalWeb3 = function () {