aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/customize-gas-modal/index.js
diff options
context:
space:
mode:
authorChi Kei Chan <chikeichan@gmail.com>2017-11-16 05:33:47 +0800
committerGitHub <noreply@github.com>2017-11-16 05:33:47 +0800
commitb944a63ff89e3c45f7d7e49b2d93a5442cde4462 (patch)
treebcd8ce2e0de5aef5edff1267d892cb66410a77c7 /ui/app/components/customize-gas-modal/index.js
parentaa538c52a747b4ab0ed6cdf3d7b7acf5a2972f86 (diff)
parentfbd04a6af6e9eda22eebaae27d712ae08272c131 (diff)
downloadtangerine-wallet-browser-b944a63ff89e3c45f7d7e49b2d93a5442cde4462.tar.gz
tangerine-wallet-browser-b944a63ff89e3c45f7d7e49b2d93a5442cde4462.tar.zst
tangerine-wallet-browser-b944a63ff89e3c45f7d7e49b2d93a5442cde4462.zip
Merge pull request #2591 from MetaMask/NewUI-flat
Release 4.0.4
Diffstat (limited to 'ui/app/components/customize-gas-modal/index.js')
-rw-r--r--ui/app/components/customize-gas-modal/index.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/ui/app/components/customize-gas-modal/index.js b/ui/app/components/customize-gas-modal/index.js
index 101a19d9f..485dacf90 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: '',
}
}
@@ -107,7 +109,6 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) {
const {
amount,
balance,
- primaryCurrency,
selectedToken,
amountConversionRate,
conversionRate,
@@ -116,10 +117,9 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) {
let error = null
const balanceIsSufficient = isBalanceSufficient({
- amount,
+ amount: selectedToken ? '0' : amount,
gasTotal,
balance,
- primaryCurrency,
selectedToken,
amountConversionRate,
conversionRate,
@@ -170,6 +170,13 @@ CustomizeGasModal.prototype.convertAndSetGasLimit = function (newGasLimit) {
CustomizeGasModal.prototype.convertAndSetGasPrice = function (newGasPrice) {
const { gasLimit } = this.state
+ 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',
@@ -191,15 +198,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',
@@ -224,7 +233,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.',