aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js')
-rw-r--r--ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js51
1 files changed, 46 insertions, 5 deletions
diff --git a/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js b/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
index 977f8ab3c..b32928b75 100644
--- a/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
+++ b/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
@@ -4,32 +4,59 @@ import {
getCurrentCurrency,
getGasTotal,
getGasPrice,
+ getGasLimit,
+ getSendAmount,
} from '../../send.selectors.js'
import {
+ isBalanceSufficient,
+ calcGasTotal,
+} from '../../send.utils.js'
+import {
getBasicGasEstimateLoadingStatus,
getRenderableEstimateDataForSmallButtonsFromGWEI,
getDefaultActiveButtonIndex,
} from '../../../../selectors/custom-gas'
import {
+ decGWEIToHexWEI,
+ decimalToHex,
+ convertGasPriceForInputs,
+ convertGasLimitForInputs,
+} from '../../../../helpers/conversions.util'
+import {
showGasButtonGroup,
} from '../../../../ducks/send.duck'
import {
resetCustomData,
} from '../../../../ducks/gas.duck'
import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js'
-import { showModal, setGasPrice } from '../../../../actions'
+import { showModal, setGasPrice, setGasLimit, setGasTotal } from '../../../../actions'
+import { getAdvancedInlineGasShown, getCurrentEthBalance } from '../../../../selectors'
import SendGasRow from './send-gas-row.component'
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SendGasRow)
function mapStateToProps (state) {
const gasButtonInfo = getRenderableEstimateDataForSmallButtonsFromGWEI(state)
- const activeButtonIndex = getDefaultActiveButtonIndex(gasButtonInfo, getGasPrice(state))
+ const gasPrice = getGasPrice(state)
+ const activeButtonIndex = getDefaultActiveButtonIndex(gasButtonInfo, gasPrice)
+ const renderableGasPrice = convertGasPriceForInputs(gasPrice)
+ const renderableGasLimit = convertGasLimitForInputs(getGasLimit(state))
+
+ const gasTotal = getGasTotal(state)
+ const conversionRate = getConversionRate(state)
+ const balance = getCurrentEthBalance(state)
+
+ const insufficientBalance = !isBalanceSufficient({
+ amount: getSendAmount(state),
+ gasTotal,
+ balance,
+ conversionRate,
+ })
return {
- conversionRate: getConversionRate(state),
+ conversionRate,
convertedCurrency: getCurrentCurrency(state),
- gasTotal: getGasTotal(state),
+ gasTotal,
gasFeeError: gasFeeIsInError(state),
gasLoadingError: getGasLoadingError(state),
gasPriceButtonGroupProps: {
@@ -39,13 +66,26 @@ function mapStateToProps (state) {
gasButtonInfo,
},
gasButtonGroupShown: getGasButtonGroupShown(state),
+ advancedInlineGasShown: getAdvancedInlineGasShown(state),
+ gasPrice: renderableGasPrice,
+ gasLimit: renderableGasLimit,
+ insufficientBalance,
}
}
function mapDispatchToProps (dispatch) {
return {
showCustomizeGasModal: () => dispatch(showModal({ name: 'CUSTOMIZE_GAS', hideBasic: true })),
- setGasPrice: newPrice => dispatch(setGasPrice(newPrice)),
+ setGasPrice: (newPrice, gasLimit) => {
+ newPrice = decGWEIToHexWEI(newPrice)
+ dispatch(setGasPrice(newPrice))
+ dispatch(setGasTotal(calcGasTotal(gasLimit, newPrice)))
+ },
+ setGasLimit: (newLimit, gasPrice) => {
+ newLimit = decimalToHex(newLimit)
+ dispatch(setGasLimit(newLimit))
+ dispatch(setGasTotal(calcGasTotal(newLimit, gasPrice)))
+ },
showGasButtonGroup: () => dispatch(showGasButtonGroup()),
resetCustomData: () => dispatch(resetCustomData()),
}
@@ -74,5 +114,6 @@ function mergeProps (stateProps, dispatchProps, ownProps) {
dispatchSetGasPrice(gasButtonInfo[1].priceInHexWei)
dispatchShowGasButtonGroup()
},
+ setGasPrice: dispatchSetGasPrice,
}
}