Refactor web3 initialization

This changes how we wait for web3 and accounts to be available and
renames web3Provider to ethProvider as we could be able to swap the
different providers (ethers.js vs. web3)
This commit is contained in:
2018-04-04 13:56:41 +02:00
parent a418ddbe52
commit 6dafc26deb
4 changed files with 49 additions and 52 deletions
+6 -9
View File
@@ -6,16 +6,13 @@ export default Ember.Route.extend({
beforeModel(transition) {
const kredits = this.get('kredits');
if (kredits.get('web3') && kredits.get('web3Provided')) {
kredits.get('listAccounts').then((accounts) => {
if (accounts.length === 0) {
if (confirm('It looks like you have an Ethereum wallet available. Please unlock your account.')) {
transition.retry();
}
return kredits.initEthProvider().then((ethProvider) => {
if (kredits.get('accountNeedsUnlock')) {
if (confirm('It looks like you have an Ethereum wallet available. Please unlock your account.')) {
transition.retry();
}
});
}
}
});
},
model() {