2017-10-14 00:01:35 +00:00
__mainContext.web3 = undefined;
__reduce(<%- connectionList %>,function(prev, value, next) {
if (prev === false) {
return next(null, false);
}
if (value === '$WEB3' && (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined')) {
2017-12-26 14:07:57 +00:00
web3.setProvider(web3.givenProvider);
2017-10-14 00:01:35 +00:00
} else if (value !== '$WEB3' && (typeof Web3 !== 'undefined' && ((typeof web3 === 'undefined') || (typeof web3 !== 'undefined' && (!web3.isConnected || (web3.isConnected && !web3.isConnected())))))) {
2018-02-08 00:41:11 +00:00
if (value.indexOf('ws://') >= 0) {
web3.setProvider(new Web3.providers.WebsocketProvider(value));
} else {
web3.setProvider(new Web3.providers.HttpProvider(value));
}
2017-10-14 00:01:35 +00:00
} else if (value === '$WEB3') {
return next(null, '');
}
2018-05-11 12:20:03 +00:00
__getAccounts(function(err, account) {
2017-10-14 00:01:35 +00:00
if (err) {
next(null, true)
} else {
next(null, false)
}
});
}, function(err, _result) {
2018-05-11 12:20:03 +00:00
__getAccounts(function(err, accounts) {
2018-05-28 17:45:14 +00:00
<% if (warnAboutMetamask) { %>
2018-06-29 21:49:17 +00:00
if (web3.eth.currentProvider && web3.eth.currentProvider.isMetaMask) {
2018-06-28 13:50:09 +00:00
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");
2018-05-28 18:22:48 +00:00
}
2018-05-28 17:26:53 +00:00
<% } %>
2018-06-29 21:49:17 +00:00
if (accounts) {
web3.eth.defaultAccount = accounts[0];
}
2017-10-14 00:01:35 +00:00
<%- done %>
});
});