template correction to check for development environment and whether metamask is engaged and log that it is

Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
VoR0220 2018-05-28 12:26:53 -05:00
parent 0858092306
commit 90b42bccb2
3 changed files with 13 additions and 2 deletions

View File

@ -27,6 +27,7 @@ class CodeGenerator {
this.storageConfig = options.storageConfig || {}; this.storageConfig = options.storageConfig || {};
this.communicationConfig = options.communicationConfig || {}; this.communicationConfig = options.communicationConfig || {};
this.namesystemConfig = options.namesystemConfig || {}; this.namesystemConfig = options.namesystemConfig || {};
this.env = options.env;
// TODO: this should also be removed and use events instead // TODO: this should also be removed and use events instead
this.contractsManager = options.contractsManager; this.contractsManager = options.contractsManager;
this.plugins = options.plugins; this.plugins = options.plugins;
@ -159,8 +160,12 @@ class CodeGenerator {
web3Load = Templates.define_web3_simple({url: connection, done: 'done();'}); web3Load = Templates.define_web3_simple({url: connection, done: 'done();'});
} else { } else {
let connectionList = "[" + this.contractsConfig.dappConnection.map((x) => '"' + x + '"').join(',') + "]"; let connectionList = "[" + this.contractsConfig.dappConnection.map((x) => '"' + x + '"').join(',') + "]";
if (self.env === 'development') {
web3Load = Templates.web3_connector({connectionList: connectionList, done: 'done();', warnAboutMetamask: true});
} else {
web3Load = Templates.web3_connector({connectionList: connectionList, done: 'done();'}); web3Load = Templates.web3_connector({connectionList: connectionList, done: 'done();'});
} }
}
result += Templates.do_when_loaded({block: web3Load}); result += Templates.do_when_loaded({block: web3Load});
} }

View File

@ -26,6 +26,11 @@ __reduce(<%- connectionList %>,function(prev, value, next) {
}, function(err, _result) { }, function(err, _result) {
__getAccounts(function(err, accounts) { __getAccounts(function(err, accounts) {
web3.eth.defaultAccount = accounts[0]; 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 %> <%- done %>
}); });
}); });

View File

@ -175,7 +175,8 @@ class Engine {
storageConfig: self.config.storageConfig, storageConfig: self.config.storageConfig,
namesystemConfig: self.config.namesystemConfig, namesystemConfig: self.config.namesystemConfig,
communicationConfig: self.config.communicationConfig, communicationConfig: self.config.communicationConfig,
events: self.events events: self.events,
env: self.env
}); });
this.codeGenerator.listenToCommands(); this.codeGenerator.listenToCommands();