Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/contracts/code_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,15 @@ class CodeGenerator {
result += plugin.generateProvider(self) + "\n";
});
} else {

let web3Load;

if (isDeployment) {
let connection = "http://" + this.contractsConfig.deployment.host + ":" + this.contractsConfig.deployment.port;
web3Load = Templates.define_web3_simple({url: connection, done: 'done();'});
} else {
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();', warnAboutMetamask: true});
}
let isDev = (self.env === 'development');
web3Load = Templates.web3_connector({connectionList: connectionList, done: 'done(err);', warnAboutMetamask: isDev});
}

result += Templates.do_when_loaded({block: web3Load});
Expand Down
6 changes: 3 additions & 3 deletions lib/contracts/code_templates/load-manager.js.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__mainContext.__LoadManager = function() { this.list = []; this.done = false; }
__mainContext.__LoadManager.prototype.execWhenReady = function(cb) { if (this.done) { cb(); } else { this.list.push(cb) } }
__mainContext.__LoadManager.prototype.doFirst = function(todo) { var self = this; todo(function() { self.done = true; self.list.map((x) => x.apply()) }) }
__mainContext.__LoadManager = function() { this.list = []; this.done = false; this.err = null; }
__mainContext.__LoadManager.prototype.execWhenReady = function(cb) { if (this.done) { cb(this.err); } else { this.list.push(cb) } }
__mainContext.__LoadManager.prototype.doFirst = function(todo) { var self = this; todo(function(err) { self.done = true; self.err = err; self.list.map((x) => x.apply(x, [self.err])) }) }
__mainContext.__loadManagerInstance = new __mainContext.__LoadManager();
8 changes: 5 additions & 3 deletions lib/contracts/code_templates/web3-connector.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ __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) {
console.log("Note: Embark has detected you are in the development environment and using Metamask, please make sure Metamask is connected to your local node");
if (web3.eth.currentProvider && web3.eth.currentProvider.isMetaMask) {
console.log("%cNote: Embark has detected you are in the development environment and using Metamask, please make sure Metamask is connected to your local node", "font-size: 2em");
}
<% } %>
if (accounts) {
web3.eth.defaultAccount = accounts[0];
}
<%- done %>
});
});