mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-03 01:13:55 +00:00
fix(embarkjs/blockchain): only call doFirst once on connect
This commit is contained in:
parent
5ab3e46947
commit
a0d336e49e
@ -30,7 +30,11 @@ Blockchain.connect = function(options, callback) {
|
||||
} catch (e) {
|
||||
_err = e;
|
||||
} finally {
|
||||
_err ? reject(_err) : resolve();
|
||||
if (_err) {
|
||||
reject(_err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -159,11 +163,10 @@ Blockchain.doConnect = function(connectionList, opts, doneCb) {
|
||||
|
||||
let connectionErrs = {};
|
||||
|
||||
this.doFirst(function(cb) {
|
||||
reduce(connectionList, false, function(result, connectionString, next) {
|
||||
if (result.connected) {
|
||||
return next(null, result);
|
||||
} else if(result) {
|
||||
} else if (result) {
|
||||
connectionErrs[result.connectionString] = result.error;
|
||||
}
|
||||
|
||||
@ -176,37 +179,22 @@ Blockchain.doConnect = function(connectionList, opts, doneCb) {
|
||||
}
|
||||
}, async function(_err, result) {
|
||||
if (!result.connected || result.error) {
|
||||
const connectionError = new BlockchainConnectionError(connectionErrs);
|
||||
let _connectionError = connectionError;
|
||||
try {
|
||||
await cb(_connectionError);
|
||||
} catch (e) {
|
||||
_connectionError = e;
|
||||
} finally {
|
||||
return doneCb(_connectionError);
|
||||
}
|
||||
return doneCb(new BlockchainConnectionError(connectionErrs));
|
||||
}
|
||||
|
||||
self.blockchainConnector.getAccounts(async (err, accounts) => {
|
||||
if (err) {
|
||||
let _err = err;
|
||||
try {
|
||||
await cb(_err);
|
||||
} catch (e) {
|
||||
_err = e;
|
||||
} finally {
|
||||
return doneCb(_err);
|
||||
}
|
||||
return doneCb(err);
|
||||
}
|
||||
const currentProv = self.blockchainConnector.getCurrentProvider();
|
||||
if (opts.warnAboutMetamask && currentProv && currentProv.isMetaMask) {
|
||||
// if we are using metamask, ask embark to turn on dev_funds
|
||||
// embark will only do this if geth is our client and we are in
|
||||
// dev mode
|
||||
if(opts.blockchainClient === 'geth') {
|
||||
if (opts.blockchainClient === 'geth') {
|
||||
console.warn("%cNote: There is a known issue with Geth that may cause transactions to get stuck when using Metamask. Please log in to the cockpit (http://localhost:8000/embark?enableRegularTxs=true) to enable a workaround. Once logged in, the workaround will automatically be enabled.", "font-size: 2em");
|
||||
}
|
||||
if(opts.blockchainClient === 'parity') {
|
||||
if (opts.blockchainClient === 'parity') {
|
||||
console.warn("%cNote: Parity blocks the connection from browser extensions like Metamask. To resolve this problem, go to https://embark.status.im/docs/blockchain_configuration.html#Using-Parity-and-Metamask", "font-size: 2em");
|
||||
}
|
||||
console.warn("%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");
|
||||
@ -215,11 +203,9 @@ Blockchain.doConnect = function(connectionList, opts, doneCb) {
|
||||
self.blockchainConnector.setDefaultAccount(accounts[0]);
|
||||
}
|
||||
|
||||
await cb();
|
||||
doneCb();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Blockchain.enableEthereum = function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user