Refactor kredits setup code a bit
This commit is contained in:
@@ -7,14 +7,12 @@ export default class ApplicationRoute extends Route {
|
|||||||
@service communityFunds;
|
@service communityFunds;
|
||||||
|
|
||||||
beforeModel(/* transition */) {
|
beforeModel(/* transition */) {
|
||||||
const kredits = this.kredits;
|
return this.kredits.setup().then(() => {
|
||||||
|
this.kredits.kredits.preflightChecks().catch(error => {
|
||||||
return kredits.setup().then(() => {
|
|
||||||
kredits.kredits.preflightChecks().catch((error) => {
|
|
||||||
console.error('Kredits preflight check failed!');
|
console.error('Kredits preflight check failed!');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch(error => {
|
||||||
console.log('Error initializing Kredits', error);
|
console.log('Error initializing Kredits', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-11
@@ -111,28 +111,23 @@ export default Service.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setup () {
|
async setup () {
|
||||||
return this.getEthProvider().then((providerAndSigner) => {
|
const kredits = await this.getEthProvider().then((providerAndSigner) => {
|
||||||
let kredits = new Kredits(providerAndSigner.ethProvider, providerAndSigner.ethSigner, {
|
return new Kredits(providerAndSigner.ethProvider, providerAndSigner.ethSigner, {
|
||||||
addresses: { Kernel: config.kreditsKernelAddress },
|
|
||||||
apm: config.kreditsApmDomain,
|
|
||||||
ipfsConfig: config.ipfs
|
ipfsConfig: config.ipfs
|
||||||
|
}).init();
|
||||||
});
|
});
|
||||||
return kredits
|
|
||||||
.init()
|
|
||||||
.then(async (kredits) => {
|
|
||||||
this.set('kredits', kredits);
|
this.set('kredits', kredits);
|
||||||
this.set('currentBlock', await kredits.provider.getBlockNumber());
|
this.set('currentBlock', await kredits.provider.getBlockNumber());
|
||||||
|
|
||||||
if (this.currentUserAccounts && this.currentUserAccounts.length > 0) {
|
if (this.currentUserAccounts && this.currentUserAccounts.length > 0) {
|
||||||
this.getCurrentUser.then((contributorData) => {
|
this.getCurrentUser.then(contributorData => {
|
||||||
this.set('currentUser', contributorData);
|
this.set('currentUser', contributorData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return kredits;
|
return kredits;
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurrentUser: computed('kredits.provider', 'currentUserAccounts.[]', function() {
|
getCurrentUser: computed('kredits.provider', 'currentUserAccounts.[]', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user