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.
This commit is contained in:
2018-04-07 20:33:41 +02:00
parent 939baec1a8
commit 0587559939
+3 -11
View File
@@ -116,7 +116,7 @@ export default Service.extend({
getContributorById(id) { getContributorById(id) {
return this.get('contributorsContract') return this.get('contributorsContract')
.then((contract) => contract.contributors(id)) .then((contract) => contract.getContributorById(id))
// Set basic data // Set basic data
.then(({ .then(({
account: address, account: address,
@@ -124,8 +124,8 @@ export default Service.extend({
hashSize, hashSize,
isCore, isCore,
profileHash: digest, profileHash: digest,
balance
}) => { }) => {
let isCurrentUser = this.get('currentUserAccounts').includes(address); let isCurrentUser = this.get('currentUserAccounts').includes(address);
let profileHash = this.getMultihashFromBytes32({ let profileHash = this.getMultihashFromBytes32({
digest, digest,
@@ -139,17 +139,9 @@ export default Service.extend({
isCore, isCore,
isCurrentUser, isCurrentUser,
profileHash, 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 // Fetch IPFS data if available
.then(this.loadContributorProfile.bind(this)) .then(this.loadContributorProfile.bind(this))
.then((attributes) => { .then((attributes) => {