Fallback to eth.getAccounts() if personal.listAccounts() fails

pull/1/head
Alex Beregszaszi 9 years ago
parent 9439b087f0
commit 1d4cf17b8b
  1. 13
      src/universal-dapp.js

@ -84,7 +84,18 @@ UniversalDApp.prototype.getAccounts = function (cb) {
var self = this;
if (!self.executionContext.isVM()) {
self.web3.personal.getAccounts(cb);
// TOOD: remove the try/catch if this is fixed: https://github.com/ethereum/web3.js/issues/442
try {
self.web3.personal.listAccounts(function (err, res) {
if (err) {
self.web3.eth.getAccounts(cb);
} else {
cb(err, res);
}
});
} catch (e) {
self.web3.eth.getAccounts(cb);
}
} else {
if (!self.accounts) {
return cb('No accounts?');

Loading…
Cancel
Save