diff --git a/app/routes/application.js b/app/routes/application.js index a7470a0..00efaab 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -7,14 +7,12 @@ export default class ApplicationRoute extends Route { @service communityFunds; beforeModel(/* transition */) { - const kredits = this.kredits; - - return kredits.setup().then(() => { - kredits.kredits.preflightChecks().catch((error) => { + return this.kredits.setup().then(() => { + this.kredits.kredits.preflightChecks().catch(error => { console.error('Kredits preflight check failed!'); console.error(error); }); - }).catch((error) => { + }).catch(error => { console.log('Error initializing Kredits', error); }); } diff --git a/app/services/kredits.js b/app/services/kredits.js index 2721da0..776b7d0 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -111,28 +111,23 @@ export default Service.extend({ }); }, - setup () { - return this.getEthProvider().then((providerAndSigner) => { - let kredits = new Kredits(providerAndSigner.ethProvider, providerAndSigner.ethSigner, { - addresses: { Kernel: config.kreditsKernelAddress }, - apm: config.kreditsApmDomain, + async setup () { + const kredits = await this.getEthProvider().then((providerAndSigner) => { + return new Kredits(providerAndSigner.ethProvider, providerAndSigner.ethSigner, { ipfsConfig: config.ipfs - }); - return kredits - .init() - .then(async (kredits) => { - this.set('kredits', kredits); - this.set('currentBlock', await kredits.provider.getBlockNumber()); - - if (this.currentUserAccounts && this.currentUserAccounts.length > 0) { - this.getCurrentUser.then((contributorData) => { - this.set('currentUser', contributorData); - }); - } - - return kredits; - }); + }).init(); }); + + this.set('kredits', kredits); + this.set('currentBlock', await kredits.provider.getBlockNumber()); + + if (this.currentUserAccounts && this.currentUserAccounts.length > 0) { + this.getCurrentUser.then(contributorData => { + this.set('currentUser', contributorData); + }); + } + + return kredits; }, getCurrentUser: computed('kredits.provider', 'currentUserAccounts.[]', function() {