diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index 7fba4b5be..41a6b891d 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -27,6 +27,7 @@ class CodeGenerator { this.storageConfig = options.storageConfig || {}; this.communicationConfig = options.communicationConfig || {}; this.namesystemConfig = options.namesystemConfig || {}; + this.env = options.env; // TODO: this should also be removed and use events instead this.contractsManager = options.contractsManager; this.plugins = options.plugins; @@ -159,7 +160,11 @@ class CodeGenerator { web3Load = Templates.define_web3_simple({url: connection, done: 'done();'}); } else { let connectionList = "[" + this.contractsConfig.dappConnection.map((x) => '"' + x + '"').join(',') + "]"; - web3Load = Templates.web3_connector({connectionList: connectionList, done: 'done();'}); + if (self.env === 'development') { + web3Load = Templates.web3_connector({connectionList: connectionList, done: 'done();', warnAboutMetamask: true}); + } else { + web3Load = Templates.web3_connector({connectionList: connectionList, done: 'done();'}); + } } result += Templates.do_when_loaded({block: web3Load}); diff --git a/lib/contracts/code_templates/web3-connector.js.ejs b/lib/contracts/code_templates/web3-connector.js.ejs index be3e33519..9c176e433 100644 --- a/lib/contracts/code_templates/web3-connector.js.ejs +++ b/lib/contracts/code_templates/web3-connector.js.ejs @@ -26,6 +26,11 @@ __reduce(<%- connectionList %>,function(prev, value, next) { }, function(err, _result) { __getAccounts(function(err, accounts) { web3.eth.defaultAccount = accounts[0]; + <% if (warnAboutMetaMask) { %> + if (web3.eth.currentProvider.isMetamask === true) { + console.log("Note: Embark has detected you are in the development environment and using Metamask, please make it's connecting to your local node"); + } + <% } %> <%- done %> }); }); diff --git a/lib/core/engine.js b/lib/core/engine.js index 4a84b234d..66d5f579b 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -175,7 +175,8 @@ class Engine { storageConfig: self.config.storageConfig, namesystemConfig: self.config.namesystemConfig, communicationConfig: self.config.communicationConfig, - events: self.events + events: self.events, + env: self.env }); this.codeGenerator.listenToCommands();