Display contribution balances not token balances #107

Merged
bumi merged 3 commits from feature/use-contribution-balances into master 2019-04-24 08:57:25 +00:00
6 changed files with 18 additions and 8 deletions
Showing only changes of commit d1791cadfe - Show all commits
+1 -1
View File
@@ -6,7 +6,7 @@
{{contributor.name}}
</td>
<td class="kredits">
<span class="amount">{{contributor.balance}}</span>
<span class="amount">{{contributor.totalKreditsEarned}}</span>
<span class="symbol">₭S</span>
</td>
</tr>
+2 -2
View File
@@ -9,9 +9,9 @@ export default Controller.extend({
contributors: alias('kredits.contributors'),
contributorsWithKredits: filter('contributors', function(contributor) {
return contributor.get('balanceRaw').gt(0);
return contributor.get('totalKreditsEarnedRaw').gt(0);
}),
contributorsSorting: Object.freeze(['balance:desc']),
contributorsSorting: Object.freeze(['totalKreditsEarned:desc']),
contributorsSorted: sort('contributorsWithKredits', 'contributorsSorting'),
contributions: alias('kredits.contributions'),
+2
View File
@@ -8,6 +8,8 @@ export default EmberObject.extend({
id: bignumber('idRaw', 'toString'),
account: null,
balance: kreditsValue('balanceRaw'),
totalKreditsEarned: bignumber('totalKreditsEarnedRaw', 'toNumber'),
contributionsCount: bignumber('contributionsCountRaw', 'toNumber'),
isCore: false,
ipfsHash: null,
+8
View File
@@ -116,6 +116,14 @@ export default Service.extend({
})
raucao commented 2019-04-23 11:04:50 +00:00 (Migrated from github.com)
Review

Can be written more concise:

  .then(total => total.toNumber());
Can be written more concise: ```js .then(total => total.toNumber()); ```
}),
totalKreditsEarned: computed(function() {
return this.kredits.Contribution.functions.totalKreditsEarned(true)
raucao commented 2019-04-23 11:07:32 +00:00 (Migrated from github.com)
Review

Not a fan of the unnamed true in this new function call, because the meaning is completely hidden, until one finds and reads the Solidity source code of it.

Not a fan of the unnamed `true` in this new function call, because the meaning is completely hidden, until one finds and reads the Solidity source code of it.
bumi commented 2019-04-23 11:50:12 +00:00 (Migrated from github.com)
Review

yes, me neither. but it is a contract call and generated from the wrapper.
could at some write our own function in the wrapper class.

yes, me neither. but it is a contract call and generated from the wrapper. could at some write our own function in the wrapper class.
raucao commented 2019-04-23 12:00:03 +00:00 (Migrated from github.com)
Review

Ah, yes.

Ah, yes.
.then(total => {
return total.toNumber();
});
}),
loadInitialData() {
return this.getContributors()
.then(contributors => this.contributors.pushObjects(contributors))
+1 -1
View File
@@ -9,7 +9,7 @@
{{contributor-list contributors=contributorsSorted}}
<p class="stats">
<span class="number">{{await kredits.totalSupply}}</span> kredits issued and distributed among
<span class="number">{{await kredits.totalKreditsEarned}}</span> kredits issued and distributed among
<span class="number">{{contributorsWithKredits.length}}</span> contributors.
</p>
</div>
+4 -4
View File
@@ -8,10 +8,10 @@ module('Unit | Controller | index', function(hooks) {
let addFixtures = function(controller) {
[
{ github_username: "neo", github_uid: "318", balance: 10000 },
{ github_username: "morpheus", github_uid: "843", balance: 15000 },
{ github_username: "trinity", github_uid: "123", balance: 5000 },
{ github_username: "mouse", github_uid: "696", balance: 0 }
{ github_username: "neo", github_uid: "318", totalKreditsEarned: 10000 },
{ github_username: "morpheus", github_uid: "843", totalKreditsEarned: 15000 },
{ github_username: "trinity", github_uid: "123", totalKreditsEarned: 5000 },
{ github_username: "mouse", github_uid: "696", totalKreditsEarned: 0 }
].forEach(fixture => {
controller.get('kredits.contributors').push(Contributor.create(fixture));
});