diff options
author | Dan <danjm.com@gmail.com> | 2018-05-22 23:16:53 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2018-05-31 07:24:31 +0800 |
commit | 4f0b4eef5030575e8ebdf35ca19fbc77376c70b9 (patch) | |
tree | ec8c1307ffa573765dc6a3155554a87a41fd2a51 /ui/app/conversion-util.js | |
parent | 166fda58777748141859c0a674a5fce454cfc3d3 (diff) | |
download | dexon-wallet-4f0b4eef5030575e8ebdf35ca19fbc77376c70b9.tar.gz dexon-wallet-4f0b4eef5030575e8ebdf35ca19fbc77376c70b9.tar.zst dexon-wallet-4f0b4eef5030575e8ebdf35ca19fbc77376c70b9.zip |
Estimate gas using same algorithm as backend.
Diffstat (limited to 'ui/app/conversion-util.js')
-rw-r--r-- | ui/app/conversion-util.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ui/app/conversion-util.js b/ui/app/conversion-util.js index d484ed16..100402d9 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')) ) |