diff options
Diffstat (limited to 'ui/app/util.js')
-rw-r--r-- | ui/app/util.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ui/app/util.js b/ui/app/util.js index 18862fade..bacf00c66 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -28,6 +28,7 @@ module.exports = { ethToWei: ethToWei, weiToEth: weiToEth, normalizeToWei: normalizeToWei, + normalizeNumberToWei: normalizeNumberToWei, valueTable: valueTable, bnTable: bnTable, } @@ -85,13 +86,20 @@ function dataSize(data) { // returns a BN in wei function normalizeToWei(amount, currency) { try { - var ether = amount.div(bnTable[currency]) - var wei = ether.mul(bnTable.wei) - return wei + return amount.mul(bnTable.wei).div(bnTable[currency]) } catch (e) {} return amount } +var multiple = new ethUtil.BN('1000', 10) +function normalizeNumberToWei(n, currency) { + var enlarged = n * 1000 + console.log(`Enlarged, we have ${enlarged}`) + var amount = new ethUtil.BN(String(enlarged), 10) + console.log("Amount inside is "+ amount.toString(10)) + return normalizeToWei(amount, currency).div(multiple) +} + function readableDate(ms) { var date = new Date(ms) var month = date.getMonth() |