aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/customize-gas-modal/index.js
diff options
context:
space:
mode:
authorDaniel Tsui <szehungdanieltsui@gmail.com>2017-11-08 08:35:18 +0800
committerGitHub <noreply@github.com>2017-11-08 08:35:18 +0800
commitda2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c (patch)
tree99151d2b40844d5e90a4175550a4b37950d6c744 /ui/app/components/customize-gas-modal/index.js
parent9f70762434deb1c973665a76623838289e655f22 (diff)
parentc57d504794b6020d42dcdabe08a13ed412450fc1 (diff)
downloadtangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar
tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.gz
tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.bz2
tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.lz
tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.xz
tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.zst
tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.zip
Merge pull request #2510 from danjm/NewUI-flat-token-balance
[NewUI] Improving gas precision and send (token) balance validation; max amount feature
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..b77e1990f 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,19 +109,17 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) {
const {
amount,
balance,
- primaryCurrency,
selectedToken,
amountConversionRate,
conversionRate,
} = this.props
let error = null
-
+
const balanceIsSufficient = isBalanceSufficient({
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.',