From 05875599390d02f0a98e6694cdb4db222141b2a2 Mon Sep 17 00:00:00 2001 From: bumi Date: Sat, 7 Apr 2018 20:33:41 +0200 Subject: [PATCH] Use getContributorById call to get contributor data This new call also returns the balance of the contributor so we don't have to make an extra call to the token contract. --- app/services/kredits.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/services/kredits.js b/app/services/kredits.js index 868e5d2..af9c2d8 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -116,7 +116,7 @@ export default Service.extend({ getContributorById(id) { return this.get('contributorsContract') - .then((contract) => contract.contributors(id)) + .then((contract) => contract.getContributorById(id)) // Set basic data .then(({ account: address, @@ -124,8 +124,8 @@ export default Service.extend({ hashSize, isCore, profileHash: digest, + balance }) => { - let isCurrentUser = this.get('currentUserAccounts').includes(address); let profileHash = this.getMultihashFromBytes32({ digest, @@ -139,17 +139,9 @@ export default Service.extend({ isCore, isCurrentUser, profileHash, + balance: balance.toNumber() }; }) - // Add the balance - .then((data) => { - return this.get('tokenContract') - .then((contract) => contract.balanceOf(data.address)) - .then((balance) => { - data.balance = balance.toNumber(); - return data; - }); - }) // Fetch IPFS data if available .then(this.loadContributorProfile.bind(this)) .then((attributes) => {