diff options
author | Dan J Miller <danjm.com@gmail.com> | 2018-12-11 05:51:00 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-12-11 05:51:00 +0800 |
commit | 1fbdce8916151df2b31eebc5de29a1365e5dadff (patch) | |
tree | 2333aa889dd6a6ec83a1665591006daca8e68859 /ui/app/selectors | |
parent | 49971e9ec250888746546f62fa176ed129bf9c74 (diff) | |
download | tangerine-wallet-browser-1fbdce8916151df2b31eebc5de29a1365e5dadff.tar tangerine-wallet-browser-1fbdce8916151df2b31eebc5de29a1365e5dadff.tar.gz tangerine-wallet-browser-1fbdce8916151df2b31eebc5de29a1365e5dadff.tar.bz2 tangerine-wallet-browser-1fbdce8916151df2b31eebc5de29a1365e5dadff.tar.lz tangerine-wallet-browser-1fbdce8916151df2b31eebc5de29a1365e5dadff.tar.xz tangerine-wallet-browser-1fbdce8916151df2b31eebc5de29a1365e5dadff.tar.zst tangerine-wallet-browser-1fbdce8916151df2b31eebc5de29a1365e5dadff.zip |
Improve ux for low gas price set (#5862)
* Show user warning if they set gas price below safelow minimum, error if 0.
* Properly cache basic price estimate data.
* Default retry price to recommended price if original price was 0x0
* Use mock fetch in send-new-ui integration tests.
Diffstat (limited to 'ui/app/selectors')
-rw-r--r-- | ui/app/selectors/custom-gas.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ui/app/selectors/custom-gas.js b/ui/app/selectors/custom-gas.js index 59f240f9c..91c9109a5 100644 --- a/ui/app/selectors/custom-gas.js +++ b/ui/app/selectors/custom-gas.js @@ -2,6 +2,7 @@ import { pipe, partialRight } from 'ramda' import { conversionUtil, multiplyCurrencies, + conversionGreaterThan, } from '../conversion-util' import { getCurrentCurrency, @@ -38,6 +39,8 @@ const selectors = { getRenderableBasicEstimateData, getRenderableEstimateDataForSmallButtonsFromGWEI, priceEstimateToWei, + getSafeLowEstimate, + isCustomPriceSafe, } module.exports = selectors @@ -96,6 +99,39 @@ function getDefaultActiveButtonIndex (gasButtonInfo, customGasPriceInHex, gasPri }) } +function getSafeLowEstimate (state) { + const { + gas: { + basicEstimates: { + safeLow, + }, + }, + } = state + + return safeLow +} + +function isCustomPriceSafe (state) { + const safeLow = getSafeLowEstimate(state) + const customGasPrice = getCustomGasPrice(state) + + if (!customGasPrice) { + return true + } + + const customPriceSafe = conversionGreaterThan( + { + value: customGasPrice, + fromNumericBase: 'hex', + fromDenomination: 'WEI', + toDenomination: 'GWEI', + }, + { value: safeLow, fromNumericBase: 'dec' } + ) + + return customPriceSafe +} + function getBasicGasEstimateBlockTime (state) { return state.gas.basicEstimates.blockTime } |