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