mirror of https://github.com/embarklabs/embark.git
39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
__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')) {
|
|
web3.setProvider(web3.givenProvider);
|
|
} else if (value !== '$WEB3' && (typeof Web3 !== 'undefined' && ((typeof web3 === 'undefined') || (typeof web3 !== 'undefined' && (!web3.isConnected || (web3.isConnected && !web3.isConnected())))))) {
|
|
if (value.indexOf('ws://') >= 0) {
|
|
web3.setProvider(new Web3.providers.WebsocketProvider(value));
|
|
} else {
|
|
web3.setProvider(new Web3.providers.HttpProvider(value));
|
|
}
|
|
} else if (value === '$WEB3') {
|
|
return next(null, '');
|
|
}
|
|
|
|
__getAccounts(function(err, account) {
|
|
if (err) {
|
|
next(null, true)
|
|
} else {
|
|
next(null, false)
|
|
}
|
|
});
|
|
}, function(err, _result) {
|
|
__getAccounts(function(err, accounts) {
|
|
<% if (warnAboutMetamask) { %>
|
|
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 %>
|
|
});
|
|
});
|