diff --git a/lib/core/config.js b/lib/core/config.js index 16bc8ce6..b27ce0bf 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -3,6 +3,7 @@ var File = require('./file.js'); var Plugins = require('./plugins.js'); var utils = require('../utils/utils.js'); var Npm = require('../pipeline/npm.js'); +let currentWeb3Version = require('../../package.json').dependencies.web3.replace("^",""); // TODO: add wrapper for fs so it can also work in the browser // can work with both read and save @@ -250,7 +251,7 @@ Config.prototype.loadFiles = function(files) { if (self.blockchainConfig.enabled || self.communicationConfig.provider === 'whisper' || self.communicationConfig.available_providers.indexOf('whisper') >= 0) { let web3Version = self.contractsConfig.versions["web3.js"]; - if (web3Version) { + if (web3Version && web3Version != currentWeb3Version) { //if (false) { //readFiles.push(new File({filename: 'web3-' + web3Version + '.js', type: 'custom', resolver: function(callback) { readFiles.push(new File({filename: 'web3.js', type: 'custom', resolver: function(callback) { diff --git a/lib/dashboard/console.js b/lib/dashboard/console.js index 8e5ba80c..f76a4d0a 100644 --- a/lib/dashboard/console.js +++ b/lib/dashboard/console.js @@ -5,15 +5,11 @@ class Console { constructor(options) { this.plugins = options.plugins; this.version = options.version; + this.contractsConfig = options.contractsConfig; } runCode(code) { - try { - RunCode.doEval(code); // jshint ignore:line - } catch(e) { - console.log(code); - console.debug(e); - } + RunCode.doEval(code); // jshint ignore:line } processEmbarkCmd (cmd) { @@ -22,6 +18,7 @@ class Console { 'Welcome to Embark ' + this.version, '', 'possible commands are:', + 'versions - display versions in use for libraries and tools like web3 and solc', // TODO: only if the blockchain is actually active! // will need to pass te current embark state here 'web3 - instantiated web3.js object configured to the current environment', @@ -30,6 +27,20 @@ class Console { 'The web3 object and the interfaces for the deployed contracts and their methods are also available' ]; return helpText.join('\n'); + } else if (cmd === 'versions') { + //let currentSolcVersion = require('../../package.json').dependencies.solc; + let solcVersionInConfig = this.contractsConfig.versions.solc; + + //let web3Version = require('../../package.json').dependencies["web3.js"].replace("^",""); + let web3VersionInConfig = this.contractsConfig.versions["web3.js"]; + + let text = [ + 'versions in use:', + 'solc: ' + solcVersionInConfig, + 'web3.js: ' + web3VersionInConfig + ] + + return text.join('\n'); } else if (cmd === 'quit') { utils.exit(); } diff --git a/lib/dashboard/dashboard.js b/lib/dashboard/dashboard.js index 9aa48b0c..82a8c136 100644 --- a/lib/dashboard/dashboard.js +++ b/lib/dashboard/dashboard.js @@ -9,6 +9,7 @@ class Dashboard { this.plugins = options.plugins; this.version = options.version; this.env = options.env; + this.contractsConfig = options.contractsConfig; } start(done) { @@ -17,7 +18,7 @@ class Dashboard { async.waterfall([ function startConsole(callback) { - console = new Console({plugins: self.plugins, version: self.version}); + console = new Console({plugins: self.plugins, version: self.version, contractsConfig: self.contractsConfig}); callback(); }, function startMonitor(callback) { diff --git a/lib/index.js b/lib/index.js index 13b6b11e..9e931ac1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -76,7 +76,8 @@ class Embark { logger: engine.logger, plugins: engine.plugins, version: self.version, - env: engine.env + env: engine.env, + contractsConfig: engine.config.contractsConfig }); dashboard.start(function () { engine.events.on('code-generator-ready', function () {