Add kredits-formatter and additionally format balance
This adds a `balanceInt` value to the contributor data that has the token balance formatted as full Kredits. (similar to Ether)
This commit is contained in:
10
lib/utils/kredits-formatter.js
Normal file
10
lib/utils/kredits-formatter.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const ethersUtils = require('ethers').utils;
|
||||
|
||||
module.exports = function (value, options = {}) {
|
||||
let etherValue = ethersUtils.formatEther(value);
|
||||
if (options.asFloat) {
|
||||
return parseFloat(etherValue);
|
||||
} else {
|
||||
return parseInt(etherValue);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user