mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-02 17:03:36 +00:00
detect web3 version and get accounts correctly
This commit is contained in:
parent
9e1778f62c
commit
7686ad561f
@ -34,3 +34,20 @@ function __reduce(arr, memo, iteratee, cb) {
|
|||||||
});
|
});
|
||||||
})(0, memo);
|
})(0, memo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function __isNewWeb3_1() {
|
||||||
|
return (typeof(web3.version) === "string");
|
||||||
|
};
|
||||||
|
|
||||||
|
function __getAccounts(cb) {
|
||||||
|
if (__isNewWeb3_1()) {
|
||||||
|
web3.eth.getAccounts().then(function(accounts) {
|
||||||
|
cb(null, accounts);
|
||||||
|
}).catch(function(err) {
|
||||||
|
cb(err);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
web3.eth.getAccounts(cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ __reduce(<%- connectionList %>,function(prev, value, next) {
|
|||||||
return next(null, '');
|
return next(null, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
web3.eth.getAccounts(function(err, account) {
|
__getAccounts(function(err, account) {
|
||||||
if (err) {
|
if (err) {
|
||||||
next(null, true)
|
next(null, true)
|
||||||
} else {
|
} else {
|
||||||
@ -24,7 +24,7 @@ __reduce(<%- connectionList %>,function(prev, value, next) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, function(err, _result) {
|
}, function(err, _result) {
|
||||||
web3.eth.getAccounts(function(err, accounts) {
|
__getAccounts(function(err, accounts) {
|
||||||
web3.eth.defaultAccount = accounts[0];
|
web3.eth.defaultAccount = accounts[0];
|
||||||
<%- done %>
|
<%- done %>
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user