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:
+6
-9
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user