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) {
|
} catch (e) {
|
||||||
_err = e;
|
_err = e;
|
||||||
} finally {
|
} finally {
|
||||||
_err ? reject(_err) : resolve();
|
if (_err) {
|
||||||
|
reject(_err);
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -159,7 +163,6 @@ Blockchain.doConnect = function(connectionList, opts, doneCb) {
|
|||||||
|
|
||||||
let connectionErrs = {};
|
let connectionErrs = {};
|
||||||
|
|
||||||
this.doFirst(function(cb) {
|
|
||||||
reduce(connectionList, false, function(result, connectionString, next) {
|
reduce(connectionList, false, function(result, connectionString, next) {
|
||||||
if (result.connected) {
|
if (result.connected) {
|
||||||
return next(null, result);
|
return next(null, result);
|
||||||
@ -176,27 +179,12 @@ Blockchain.doConnect = function(connectionList, opts, doneCb) {
|
|||||||
}
|
}
|
||||||
}, async function(_err, result) {
|
}, async function(_err, result) {
|
||||||
if (!result.connected || result.error) {
|
if (!result.connected || result.error) {
|
||||||
const connectionError = new BlockchainConnectionError(connectionErrs);
|
return doneCb(new BlockchainConnectionError(connectionErrs));
|
||||||
let _connectionError = connectionError;
|
|
||||||
try {
|
|
||||||
await cb(_connectionError);
|
|
||||||
} catch (e) {
|
|
||||||
_connectionError = e;
|
|
||||||
} finally {
|
|
||||||
return doneCb(_connectionError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.blockchainConnector.getAccounts(async (err, accounts) => {
|
self.blockchainConnector.getAccounts(async (err, accounts) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
let _err = err;
|
return doneCb(err);
|
||||||
try {
|
|
||||||
await cb(_err);
|
|
||||||
} catch (e) {
|
|
||||||
_err = e;
|
|
||||||
} finally {
|
|
||||||
return doneCb(_err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const currentProv = self.blockchainConnector.getCurrentProvider();
|
const currentProv = self.blockchainConnector.getCurrentProvider();
|
||||||
if (opts.warnAboutMetamask && currentProv && currentProv.isMetaMask) {
|
if (opts.warnAboutMetamask && currentProv && currentProv.isMetaMask) {
|
||||||
@ -215,11 +203,9 @@ Blockchain.doConnect = function(connectionList, opts, doneCb) {
|
|||||||
self.blockchainConnector.setDefaultAccount(accounts[0]);
|
self.blockchainConnector.setDefaultAccount(accounts[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
await cb();
|
|
||||||
doneCb();
|
doneCb();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockchain.enableEthereum = function() {
|
Blockchain.enableEthereum = function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user