Files
kredits-web/app/routes/index.js
T
bumi 6dafc26deb 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)
2018-04-04 13:56:41 +02:00

35 lines
910 B
JavaScript

import Ember from 'ember';
export default Ember.Route.extend({
kredits: Ember.inject.service(),
beforeModel(transition) {
const kredits = this.get('kredits');
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() {
let newContributor = Ember.getOwner(this).lookup('model:contributor');
newContributor.set('kind', 'person');
let kredits = this.get('kredits');
let totalSupply = kredits.get('tokenContract')
.then((contract) => contract.totalSupply());
return Ember.RSVP.hash({
contributors: kredits.getContributors(),
proposals: kredits.getProposals(),
totalSupply,
newContributor: newContributor,
});
}
});