aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app
diff options
context:
space:
mode:
authorKevin Serrano <kevin.serrano@consensys.net>2017-10-06 06:26:03 +0800
committerKevin Serrano <kevin.serrano@consensys.net>2017-10-06 06:26:03 +0800
commite6a618b82d5ab75920763875cd0487e4431321a2 (patch)
tree3fe14f272e65bd92431fc836708d8ed468f4dec2 /ui/app
parent833d73da566f5d5d379f594c309318bab6eadbfb (diff)
downloadtangerine-wallet-browser-e6a618b82d5ab75920763875cd0487e4431321a2.tar
tangerine-wallet-browser-e6a618b82d5ab75920763875cd0487e4431321a2.tar.gz
tangerine-wallet-browser-e6a618b82d5ab75920763875cd0487e4431321a2.tar.bz2
tangerine-wallet-browser-e6a618b82d5ab75920763875cd0487e4431321a2.tar.lz
tangerine-wallet-browser-e6a618b82d5ab75920763875cd0487e4431321a2.tar.xz
tangerine-wallet-browser-e6a618b82d5ab75920763875cd0487e4431321a2.tar.zst
tangerine-wallet-browser-e6a618b82d5ab75920763875cd0487e4431321a2.zip
Fix precision to account for small wei increase.
Diffstat (limited to 'ui/app')
-rw-r--r--ui/app/components/bn-as-decimal-input.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js
index f3ace4720..d84834d06 100644
--- a/ui/app/components/bn-as-decimal-input.js
+++ b/ui/app/components/bn-as-decimal-input.js
@@ -31,7 +31,7 @@ BnAsDecimalInput.prototype.render = function () {
const suffix = props.suffix
const style = props.style
const valueString = value.toString(10)
- const newValue = this.downsize(valueString, scale, precision)
+ const newValue = this.downsize(valueString, scale)
return (
h('.flex-column', [
@@ -145,14 +145,17 @@ BnAsDecimalInput.prototype.constructWarning = function () {
}
-BnAsDecimalInput.prototype.downsize = function (number, scale, precision) {
+BnAsDecimalInput.prototype.downsize = function (number, scale) {
// if there is no scaling, simply return the number
if (scale === 0) {
return Number(number)
} else {
// if the scale is the same as the precision, account for this edge case.
- var decimals = (scale === precision) ? -1 : scale - precision
- return Number(number.slice(0, -scale) + '.' + number.slice(-scale, decimals))
+ var adjustedNumber = number
+ while (adjustedNumber.length < scale) {
+ adjustedNumber = '0' + adjustedNumber
+ }
+ return Number(adjustedNumber.slice(0, -scale) + '.' + adjustedNumber.slice(-scale))
}
}