diff options
author | Dan <danjm.com@gmail.com> | 2017-10-31 05:46:56 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2017-11-07 03:37:02 +0800 |
commit | 716bbf67d7180ffe0f59d07484d30231ed5f5e49 (patch) | |
tree | 490719eef5a8aab92c3ebb70389eb9e1f8408bb5 /ui/app/components/customize-gas-modal | |
parent | b16946723f94b855ab70469dca5899ad80f129b3 (diff) | |
download | tangerine-wallet-browser-716bbf67d7180ffe0f59d07484d30231ed5f5e49.tar.gz tangerine-wallet-browser-716bbf67d7180ffe0f59d07484d30231ed5f5e49.tar.zst tangerine-wallet-browser-716bbf67d7180ffe0f59d07484d30231ed5f5e49.zip |
Set gas price allows for WEI precision.
Diffstat (limited to 'ui/app/components/customize-gas-modal')
-rw-r--r-- | ui/app/components/customize-gas-modal/index.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/ui/app/components/customize-gas-modal/index.js b/ui/app/components/customize-gas-modal/index.js index 5bd6c54cb..dcb058690 100644 --- a/ui/app/components/customize-gas-modal/index.js +++ b/ui/app/components/customize-gas-modal/index.js @@ -73,6 +73,8 @@ function getOriginalState (props) { gasLimit, gasTotal, error: null, + priceSigZeros: '', + priceSigDec: '', } } @@ -167,7 +169,15 @@ CustomizeGasModal.prototype.convertAndSetGasLimit = function (newGasLimit) { } CustomizeGasModal.prototype.convertAndSetGasPrice = function (newGasPrice) { - const { gasLimit } = this.state + const { gasLimit, priceSigZeros } = this.state + const priceStrLength = newGasPrice.length + const sigZeros = String(newGasPrice).match(/^\d+[.]\d*?(0+)$/) + const sigDec = String(newGasPrice).match(/^\d+([.])0*$/) + + this.setState({ + priceSigZeros: sigZeros && sigZeros[1] || '', + priceSigDec: sigDec && sigDec[1] || '', + }) const gasPrice = conversionUtil(newGasPrice, { fromNumericBase: 'dec', @@ -189,15 +199,17 @@ CustomizeGasModal.prototype.convertAndSetGasPrice = function (newGasPrice) { CustomizeGasModal.prototype.render = function () { const { hideModal } = this.props - const { gasPrice, gasLimit, gasTotal, error } = this.state + const { gasPrice, gasLimit, gasTotal, error, priceSigZeros, priceSigDec } = this.state - const convertedGasPrice = conversionUtil(gasPrice, { + let convertedGasPrice = conversionUtil(gasPrice, { fromNumericBase: 'hex', toNumericBase: 'dec', fromDenomination: 'WEI', toDenomination: 'GWEI', }) + convertedGasPrice += convertedGasPrice.match(/[.]/) ? priceSigZeros : `${priceSigDec}${priceSigZeros}` + const convertedGasLimit = conversionUtil(gasLimit, { fromNumericBase: 'hex', toNumericBase: 'dec', @@ -222,7 +234,7 @@ CustomizeGasModal.prototype.render = function () { value: convertedGasPrice, min: MIN_GAS_PRICE_GWEI, // max: 1000, - step: MIN_GAS_PRICE_GWEI, + step: multiplyCurrencies(MIN_GAS_PRICE_GWEI, 10), onChange: value => this.convertAndSetGasPrice(value), title: 'Gas Price (GWEI)', copy: 'We calculate the suggested gas prices based on network success rates.', |