From 276d80d48f2fbb568851bc3521b66623a1222cb0 Mon Sep 17 00:00:00 2001 From: mulili Date: Tue, 11 Sep 2018 01:47:29 +0300 Subject: [PATCH] changes requested --- .../assets/js/lib/smart_contract/wei_ether_converter.js | 9 +++++---- apps/block_scout_web/assets/package-lock.json | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/assets/js/lib/smart_contract/wei_ether_converter.js b/apps/block_scout_web/assets/js/lib/smart_contract/wei_ether_converter.js index a045b8ffb4..557e0e33a5 100644 --- a/apps/block_scout_web/assets/js/lib/smart_contract/wei_ether_converter.js +++ b/apps/block_scout_web/assets/js/lib/smart_contract/wei_ether_converter.js @@ -1,5 +1,6 @@ import $ from 'jquery' import { BigNumber } from 'bignumber.js' +import numeral from 'numeral' const weiToEtherConverter = (element, event) => { const weiUnit = new BigNumber('1000000000000000000') @@ -12,13 +13,13 @@ const weiToEtherConverter = (element, event) => { if (event.target.checked) { $conversionTextWei.hide() $conversionTextEth.show() - unitVal = unitVal.dividedBy(weiUnit) - $conversionUnit.html(String(unitVal > 0 ? unitVal : unitVal.toFixed(3))) + unitVal = unitVal.dividedBy(weiUnit).toNumber() + $conversionUnit.html(String(unitVal > 0 ? numeral(unitVal).format('0,0') : numeral(unitVal).format('0.0[00000]'))) } else { $conversionTextWei.show() $conversionTextEth.hide() - unitVal = unitVal.multipliedBy(weiUnit) - $conversionUnit.html(unitVal) + unitVal = unitVal.multipliedBy(weiUnit).toNumber() + $conversionUnit.html(String(numeral(unitVal).format('0,0'))) } } diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index caf95acc73..673ff37677 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -6623,6 +6623,14 @@ "resolved": "https://registry.npmjs.org/numeral/-/numeral-2.0.6.tgz", "integrity": "sha1-StCAk21EPCVhrtnyGX7//iX05QY=" }, + "numeral-es6": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/numeral-es6/-/numeral-es6-1.0.0.tgz", + "integrity": "sha1-xzqgKkvcp6CZ2pm2b03Kw5mkhk4=", + "requires": { + "numeral": "*" + } + }, "nwsapi": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.4.tgz",