|
|
@ -5,6 +5,8 @@ import { |
|
|
|
hideModal, |
|
|
|
hideModal, |
|
|
|
setGasLimit, |
|
|
|
setGasLimit, |
|
|
|
setGasPrice, |
|
|
|
setGasPrice, |
|
|
|
|
|
|
|
createSpeedUpTransaction, |
|
|
|
|
|
|
|
hideSidebar, |
|
|
|
} from '../../../actions' |
|
|
|
} from '../../../actions' |
|
|
|
import { |
|
|
|
import { |
|
|
|
setCustomGasPrice, |
|
|
|
setCustomGasPrice, |
|
|
@ -22,6 +24,7 @@ import { |
|
|
|
getCurrentCurrency, |
|
|
|
getCurrentCurrency, |
|
|
|
conversionRateSelector as getConversionRate, |
|
|
|
conversionRateSelector as getConversionRate, |
|
|
|
getSelectedToken, |
|
|
|
getSelectedToken, |
|
|
|
|
|
|
|
getCurrentEthBalance, |
|
|
|
} from '../../../selectors.js' |
|
|
|
} from '../../../selectors.js' |
|
|
|
import { |
|
|
|
import { |
|
|
|
formatTimeEstimate, |
|
|
|
formatTimeEstimate, |
|
|
@ -34,6 +37,9 @@ import { |
|
|
|
getEstimatedGasTimes, |
|
|
|
getEstimatedGasTimes, |
|
|
|
getRenderableBasicEstimateData, |
|
|
|
getRenderableBasicEstimateData, |
|
|
|
} from '../../../selectors/custom-gas' |
|
|
|
} from '../../../selectors/custom-gas' |
|
|
|
|
|
|
|
import { |
|
|
|
|
|
|
|
submittedPendingTransactionsSelector, |
|
|
|
|
|
|
|
} from '../../../selectors/transactions' |
|
|
|
import { |
|
|
|
import { |
|
|
|
formatCurrency, |
|
|
|
formatCurrency, |
|
|
|
} from '../../../helpers/confirm-transaction/util' |
|
|
|
} from '../../../helpers/confirm-transaction/util' |
|
|
@ -48,17 +54,19 @@ import { |
|
|
|
} from '../../../helpers/formatters' |
|
|
|
} from '../../../helpers/formatters' |
|
|
|
import { |
|
|
|
import { |
|
|
|
calcGasTotal, |
|
|
|
calcGasTotal, |
|
|
|
|
|
|
|
isBalanceSufficient, |
|
|
|
} from '../../send/send.utils' |
|
|
|
} from '../../send/send.utils' |
|
|
|
import { addHexPrefix } from 'ethereumjs-util' |
|
|
|
import { addHexPrefix } from 'ethereumjs-util' |
|
|
|
import { getAdjacentGasPrices, extrapolateY } from '../gas-price-chart/gas-price-chart.utils' |
|
|
|
import { getAdjacentGasPrices, extrapolateY } from '../gas-price-chart/gas-price-chart.utils' |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = state => { |
|
|
|
const mapStateToProps = (state, ownProps) => { |
|
|
|
|
|
|
|
const { transaction = {} } = ownProps |
|
|
|
const buttonDataLoading = getBasicGasEstimateLoadingStatus(state) |
|
|
|
const buttonDataLoading = getBasicGasEstimateLoadingStatus(state) |
|
|
|
const { gasPrice: currentGasPrice, gas: currentGasLimit, value } = getTxParams(state) |
|
|
|
const { gasPrice: currentGasPrice, gas: currentGasLimit, value } = getTxParams(state, transaction.id) |
|
|
|
const gasTotal = calcGasTotal(currentGasLimit, currentGasPrice) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const customModalGasPriceInHex = getCustomGasPrice(state) || currentGasPrice |
|
|
|
const customModalGasPriceInHex = getCustomGasPrice(state) || currentGasPrice |
|
|
|
const customModalGasLimitInHex = getCustomGasLimit(state) || currentGasLimit |
|
|
|
const customModalGasLimitInHex = getCustomGasLimit(state) || currentGasLimit |
|
|
|
|
|
|
|
const gasTotal = calcGasTotal(customModalGasLimitInHex, customModalGasPriceInHex) |
|
|
|
|
|
|
|
|
|
|
|
const customGasTotal = calcGasTotal(customModalGasLimitInHex, customModalGasPriceInHex) |
|
|
|
const customGasTotal = calcGasTotal(customModalGasLimitInHex, customModalGasPriceInHex) |
|
|
|
|
|
|
|
|
|
|
|
const gasButtonInfo = getRenderableBasicEstimateData(state) |
|
|
|
const gasButtonInfo = getRenderableBasicEstimateData(state) |
|
|
@ -74,6 +82,14 @@ const mapStateToProps = state => { |
|
|
|
|
|
|
|
|
|
|
|
const gasPrices = getEstimatedGasPrices(state) |
|
|
|
const gasPrices = getEstimatedGasPrices(state) |
|
|
|
const estimatedTimes = getEstimatedGasTimes(state) |
|
|
|
const estimatedTimes = getEstimatedGasTimes(state) |
|
|
|
|
|
|
|
const balance = getCurrentEthBalance(state) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const insufficientBalance = !isBalanceSufficient({ |
|
|
|
|
|
|
|
amount: value, |
|
|
|
|
|
|
|
gasTotal, |
|
|
|
|
|
|
|
balance, |
|
|
|
|
|
|
|
conversionRate, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
hideBasic, |
|
|
|
hideBasic, |
|
|
@ -104,6 +120,9 @@ const mapStateToProps = state => { |
|
|
|
transactionFee: addHexWEIsToRenderableEth('0x0', customGasTotal), |
|
|
|
transactionFee: addHexWEIsToRenderableEth('0x0', customGasTotal), |
|
|
|
sendAmount: addHexWEIsToRenderableEth(value, '0x0'), |
|
|
|
sendAmount: addHexWEIsToRenderableEth(value, '0x0'), |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
isSpeedUp: transaction.status === 'submitted', |
|
|
|
|
|
|
|
txId: transaction.id, |
|
|
|
|
|
|
|
insufficientBalance, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -125,18 +144,24 @@ const mapDispatchToProps = dispatch => { |
|
|
|
updateConfirmTxGasAndCalculate: (gasLimit, gasPrice) => { |
|
|
|
updateConfirmTxGasAndCalculate: (gasLimit, gasPrice) => { |
|
|
|
return dispatch(updateGasAndCalculate({ gasLimit, gasPrice })) |
|
|
|
return dispatch(updateGasAndCalculate({ gasLimit, gasPrice })) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
createSpeedUpTransaction: (txId, gasPrice) => { |
|
|
|
|
|
|
|
return dispatch(createSpeedUpTransaction(txId, gasPrice)) |
|
|
|
|
|
|
|
}, |
|
|
|
hideGasButtonGroup: () => dispatch(hideGasButtonGroup()), |
|
|
|
hideGasButtonGroup: () => dispatch(hideGasButtonGroup()), |
|
|
|
setCustomTimeEstimate: (timeEstimateInSeconds) => dispatch(setCustomTimeEstimate(timeEstimateInSeconds)), |
|
|
|
setCustomTimeEstimate: (timeEstimateInSeconds) => dispatch(setCustomTimeEstimate(timeEstimateInSeconds)), |
|
|
|
|
|
|
|
hideSidebar: () => dispatch(hideSidebar()), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const mergeProps = (stateProps, dispatchProps, ownProps) => { |
|
|
|
const mergeProps = (stateProps, dispatchProps, ownProps) => { |
|
|
|
const { gasPriceButtonGroupProps, isConfirm } = stateProps |
|
|
|
const { gasPriceButtonGroupProps, isConfirm, isSpeedUp, txId } = stateProps |
|
|
|
const { |
|
|
|
const { |
|
|
|
updateCustomGasPrice: dispatchUpdateCustomGasPrice, |
|
|
|
updateCustomGasPrice: dispatchUpdateCustomGasPrice, |
|
|
|
hideGasButtonGroup: dispatchHideGasButtonGroup, |
|
|
|
hideGasButtonGroup: dispatchHideGasButtonGroup, |
|
|
|
setGasData: dispatchSetGasData, |
|
|
|
setGasData: dispatchSetGasData, |
|
|
|
updateConfirmTxGasAndCalculate: dispatchUpdateConfirmTxGasAndCalculate, |
|
|
|
updateConfirmTxGasAndCalculate: dispatchUpdateConfirmTxGasAndCalculate, |
|
|
|
|
|
|
|
createSpeedUpTransaction: dispatchCreateSpeedUpTransaction, |
|
|
|
|
|
|
|
hideSidebar: dispatchHideSidebar, |
|
|
|
...otherDispatchProps |
|
|
|
...otherDispatchProps |
|
|
|
} = dispatchProps |
|
|
|
} = dispatchProps |
|
|
|
|
|
|
|
|
|
|
@ -144,12 +169,17 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => { |
|
|
|
...stateProps, |
|
|
|
...stateProps, |
|
|
|
...otherDispatchProps, |
|
|
|
...otherDispatchProps, |
|
|
|
...ownProps, |
|
|
|
...ownProps, |
|
|
|
onSubmit: isConfirm |
|
|
|
onSubmit: (gasLimit, gasPrice) => { |
|
|
|
? dispatchUpdateConfirmTxGasAndCalculate |
|
|
|
if (isConfirm) { |
|
|
|
: (newLimit, newPrice) => { |
|
|
|
dispatchUpdateConfirmTxGasAndCalculate(gasLimit, gasPrice) |
|
|
|
dispatchSetGasData(newLimit, newPrice) |
|
|
|
} else if (isSpeedUp) { |
|
|
|
|
|
|
|
dispatchCreateSpeedUpTransaction(txId, gasPrice) |
|
|
|
|
|
|
|
dispatchHideSidebar() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
dispatchSetGasData(gasLimit, gasPrice) |
|
|
|
dispatchHideGasButtonGroup() |
|
|
|
dispatchHideGasButtonGroup() |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
gasPriceButtonGroupProps: { |
|
|
|
gasPriceButtonGroupProps: { |
|
|
|
...gasPriceButtonGroupProps, |
|
|
|
...gasPriceButtonGroupProps, |
|
|
|
handleGasPriceSelection: dispatchUpdateCustomGasPrice, |
|
|
|
handleGasPriceSelection: dispatchUpdateCustomGasPrice, |
|
|
@ -171,9 +201,12 @@ function calcCustomGasLimit (customGasLimitInHex) { |
|
|
|
return parseInt(customGasLimitInHex, 16) |
|
|
|
return parseInt(customGasLimitInHex, 16) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getTxParams (state) { |
|
|
|
function getTxParams (state, transactionId) { |
|
|
|
const { confirmTransaction: { txData }, metamask: { send } } = state |
|
|
|
const { confirmTransaction: { txData }, metamask: { send } } = state |
|
|
|
return txData.txParams || { |
|
|
|
const pendingTransactions = submittedPendingTransactionsSelector(state) |
|
|
|
|
|
|
|
const pendingTransaction = pendingTransactions.find(({ id }) => id === transactionId) |
|
|
|
|
|
|
|
const { txParams: pendingTxParams } = pendingTransaction || {} |
|
|
|
|
|
|
|
return txData.txParams || pendingTxParams || { |
|
|
|
from: send.from, |
|
|
|
from: send.from, |
|
|
|
gas: send.gasLimit, |
|
|
|
gas: send.gasLimit, |
|
|
|
gasPrice: send.gasPrice || getAveragePriceEstimateInHexWEI(state), |
|
|
|
gasPrice: send.gasPrice || getAveragePriceEstimateInHexWEI(state), |
|
|
|