aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/conversion-util.js
diff options
context:
space:
mode:
authorDan J Miller <danjm.com@gmail.com>2018-06-05 03:08:01 +0800
committerGitHub <noreply@github.com>2018-06-05 03:08:01 +0800
commit139f930185f134ef50d547ca07a580e11b5cf731 (patch)
tree4e184b7dc5f97d9d4da28e6b72b256e955b0a937 /ui/app/conversion-util.js
parent2ca084b0557242b34733107701a14ba0724363b3 (diff)
parentada59054c9d102cc99b950f1377256cac5545649 (diff)
downloadtangerine-wallet-browser-139f930185f134ef50d547ca07a580e11b5cf731.tar.gz
tangerine-wallet-browser-139f930185f134ef50d547ca07a580e11b5cf731.tar.zst
tangerine-wallet-browser-139f930185f134ef50d547ca07a580e11b5cf731.zip
Merge pull request #4350 from MetaMask/i3914-fix-newui-send-gas-estimation
NewUI gas estimation produces same results as old-ui (exception: contract addresses)
Diffstat (limited to 'ui/app/conversion-util.js')
-rw-r--r--ui/app/conversion-util.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/ui/app/conversion-util.js b/ui/app/conversion-util.js
index d484ed16d..100402d95 100644
--- a/ui/app/conversion-util.js
+++ b/ui/app/conversion-util.js
@@ -11,7 +11,8 @@
* @param {string} [options.fromNumericBase = 'hex' | 'dec' | 'BN'] The numeric basic of the passed value.
* @param {string} [options.toNumericBase = 'hex' | 'dec' | 'BN'] The desired numeric basic of the result.
* @param {string} [options.fromDenomination = 'WEI'] The denomination of the passed value
-* @param {number} [options.numberOfDecimals] The desired number of in the result
+* @param {string} [options.numberOfDecimals] The desired number of decimals in the result
+* @param {string} [options.roundDown] The desired number of decimals to round down to
* @param {number} [options.conversionRate] The rate to use to make the fromCurrency -> toCurrency conversion
* @returns {(number | string | BN)}
*
@@ -38,6 +39,7 @@ const BIG_NUMBER_GWEI_MULTIPLIER = new BigNumber('1000000000')
// Individual Setters
const convert = R.invoker(1, 'times')
const round = R.invoker(2, 'round')(R.__, BigNumber.ROUND_HALF_DOWN)
+const roundDown = R.invoker(2, 'round')(R.__, BigNumber.ROUND_DOWN)
const invertConversionRate = conversionRate => () => new BigNumber(1.0).div(conversionRate)
const decToBigNumberViaString = n => R.pipe(String, toBigNumber['dec'])
@@ -104,6 +106,7 @@ const converter = R.pipe(
whenPredSetWithPropAndSetter(fromAndToCurrencyPropsNotEqual, 'conversionRate', convert),
whenPropApplySetterMap('toDenomination', toSpecifiedDenomination),
whenPredSetWithPropAndSetter(R.prop('numberOfDecimals'), 'numberOfDecimals', round),
+ whenPredSetWithPropAndSetter(R.prop('roundDown'), 'roundDown', roundDown),
whenPropApplySetterMap('toNumericBase', baseChange),
R.view(R.lensProp('value'))
)