aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/selectors
diff options
context:
space:
mode:
authorDan Miller <danjm.com@gmail.com>2018-09-13 16:47:05 +0800
committerDan Miller <danjm.com@gmail.com>2018-12-04 11:36:04 +0800
commit7de3f22d63748ed5a81e947755db056d4cdef3db (patch)
tree748482505ce65c3de4e71787d27b69d71156b522 /ui/app/selectors
parent6ada9b4a3c02014f8d00b1f45a149afbf47f700d (diff)
downloadtangerine-wallet-browser-7de3f22d63748ed5a81e947755db056d4cdef3db.tar
tangerine-wallet-browser-7de3f22d63748ed5a81e947755db056d4cdef3db.tar.gz
tangerine-wallet-browser-7de3f22d63748ed5a81e947755db056d4cdef3db.tar.bz2
tangerine-wallet-browser-7de3f22d63748ed5a81e947755db056d4cdef3db.tar.lz
tangerine-wallet-browser-7de3f22d63748ed5a81e947755db056d4cdef3db.tar.xz
tangerine-wallet-browser-7de3f22d63748ed5a81e947755db056d4cdef3db.tar.zst
tangerine-wallet-browser-7de3f22d63748ed5a81e947755db056d4cdef3db.zip
Connects remained of the gas customization component to redux.
Diffstat (limited to 'ui/app/selectors')
-rw-r--r--ui/app/selectors/custom-gas.js43
1 files changed, 21 insertions, 22 deletions
diff --git a/ui/app/selectors/custom-gas.js b/ui/app/selectors/custom-gas.js
index ff2fd0e05..61c0525df 100644
--- a/ui/app/selectors/custom-gas.js
+++ b/ui/app/selectors/custom-gas.js
@@ -1,9 +1,5 @@
import { pipe, partialRight } from 'ramda'
import {
- getConversionRate,
- getGasLimit,
-} from '../components/send/send.selectors'
-import {
conversionUtil,
multiplyCurrencies,
} from '../conversion-util'
@@ -14,6 +10,12 @@ import {
formatCurrency,
} from '../helpers/confirm-transaction/util'
import {
+ decEthToConvertedCurrency as ethTotalToConvertedCurrency,
+} from '../helpers/conversions.util'
+import {
+ formatETHFee,
+} from '../helpers/formatters'
+import {
calcGasTotal,
} from '../components/send/send.utils'
import { addHexPrefix } from 'ethereumjs-util'
@@ -25,6 +27,9 @@ const selectors = {
getCustomGasTotal,
getRenderableBasicEstimateData,
getBasicGasEstimateLoadingStatus,
+ getAveragePriceEstimateInHexWEI,
+ getDefaultActiveButtonIndex,
+ priceEstimateToWei,
}
module.exports = selectors
@@ -49,6 +54,16 @@ function getBasicGasEstimateLoadingStatus (state) {
return state.gas.basicEstimateIsLoading
}
+function getAveragePriceEstimateInHexWEI (state) {
+ const averagePriceEstimate = state.gas.basicEstimates.average
+ return getGasPriceInHexWei(averagePriceEstimate || '0x0')
+}
+
+function getDefaultActiveButtonIndex (gasButtonInfo, customGasPriceInHex, gasPrice) {
+ return gasButtonInfo.findIndex(({ priceInHexWei }) => {
+ return priceInHexWei === addHexPrefix(customGasPriceInHex || gasPrice)
+ })
+}
function apiEstimateModifiedToGWEI (estimate) {
return multiplyCurrencies(estimate, 0.10, {
@@ -68,21 +83,6 @@ function basicPriceEstimateToETHTotal (estimate, gasLimit) {
})
}
-function ethTotalToConvertedCurrency (ethTotal, convertedCurrency, conversionRate) {
- return conversionUtil(ethTotal, {
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- fromCurrency: 'ETH',
- toCurrency: convertedCurrency,
- numberOfDecimals: 2,
- conversionRate,
- })
-}
-
-function formatETHFee (ethFee) {
- return ethFee + ' ETH'
-}
-
function getRenderableEthFee (estimate, gasLimit) {
return pipe(
apiEstimateModifiedToGWEI,
@@ -150,9 +150,8 @@ function getRenderableBasicEstimateData (state) {
if (getBasicGasEstimateLoadingStatus(state)) {
return []
}
-
- const gasLimit = getGasLimit(state)
- const conversionRate = getConversionRate(state)
+ const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state)
+ const conversionRate = state.metamask.conversionRate
const currentCurrency = getCurrentCurrency(state)
const {
gas: {