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,7 +163,6 @@ 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);
|
||||
@ -176,27 +179,12 @@ 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) {
|
||||
@ -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