fix counting

This commit is contained in:
callebtc 2022-11-06 00:39:37 +01:00 committed by dni ⚡
parent a030b16471
commit e39b4c3f5a

View file

@ -1003,16 +1003,18 @@
.reduce((sum, el) => (sum += el.amount), 0)
},
getTokenList: function () {
const x = this.proofs
.map(t => t.amount)
.reduce((acc, amount) => {
acc[amount] = acc[amount] + amount || 1
return acc
}, {})
return Object.keys(x).map(k => ({
console.log(this.proofs)
const amounts = this.proofs.map(t => t.amount)
const counts = {};
for (const num of amounts) {
counts[num] = counts[num] ? counts[num] + 1 : 1;
}
console.log("counts", counts)
return Object.keys(counts).map(k => ({
value: parseInt(k),
count: x[k],
sum: k * x[k]
count: parseInt(counts[k]),
sum: k * counts[k]
}))
},