|
|
@ -5,6 +5,8 @@ const connect = require('react-redux').connect |
|
|
|
const actions = require('../../actions') |
|
|
|
const actions = require('../../actions') |
|
|
|
const GasModalCard = require('./gas-modal-card') |
|
|
|
const GasModalCard = require('./gas-modal-card') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
|
MIN_GAS_PRICE_DEC, |
|
|
|
MIN_GAS_PRICE_DEC, |
|
|
|
MIN_GAS_LIMIT_DEC, |
|
|
|
MIN_GAS_LIMIT_DEC, |
|
|
@ -19,6 +21,7 @@ const { |
|
|
|
conversionUtil, |
|
|
|
conversionUtil, |
|
|
|
multiplyCurrencies, |
|
|
|
multiplyCurrencies, |
|
|
|
conversionGreaterThan, |
|
|
|
conversionGreaterThan, |
|
|
|
|
|
|
|
subtractCurrencies, |
|
|
|
} = require('../../conversion-util') |
|
|
|
} = require('../../conversion-util') |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
@ -30,6 +33,7 @@ const { |
|
|
|
getSendFrom, |
|
|
|
getSendFrom, |
|
|
|
getCurrentAccountWithSendEtherInfo, |
|
|
|
getCurrentAccountWithSendEtherInfo, |
|
|
|
getSelectedTokenToFiatRate, |
|
|
|
getSelectedTokenToFiatRate, |
|
|
|
|
|
|
|
getSendMaxModeState, |
|
|
|
} = require('../../selectors') |
|
|
|
} = require('../../selectors') |
|
|
|
|
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
|
function mapStateToProps (state) { |
|
|
@ -42,6 +46,7 @@ function mapStateToProps (state) { |
|
|
|
gasLimit: getGasLimit(state), |
|
|
|
gasLimit: getGasLimit(state), |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
amount: getSendAmount(state), |
|
|
|
amount: getSendAmount(state), |
|
|
|
|
|
|
|
maxModeOn: getSendMaxModeState(state), |
|
|
|
balance: currentAccount.balance, |
|
|
|
balance: currentAccount.balance, |
|
|
|
primaryCurrency: selectedToken && selectedToken.symbol, |
|
|
|
primaryCurrency: selectedToken && selectedToken.symbol, |
|
|
|
selectedToken, |
|
|
|
selectedToken, |
|
|
@ -55,6 +60,7 @@ function mapDispatchToProps (dispatch) { |
|
|
|
updateGasPrice: newGasPrice => dispatch(actions.updateGasPrice(newGasPrice)), |
|
|
|
updateGasPrice: newGasPrice => dispatch(actions.updateGasPrice(newGasPrice)), |
|
|
|
updateGasLimit: newGasLimit => dispatch(actions.updateGasLimit(newGasLimit)), |
|
|
|
updateGasLimit: newGasLimit => dispatch(actions.updateGasLimit(newGasLimit)), |
|
|
|
updateGasTotal: newGasTotal => dispatch(actions.updateGasTotal(newGasTotal)), |
|
|
|
updateGasTotal: newGasTotal => dispatch(actions.updateGasTotal(newGasTotal)), |
|
|
|
|
|
|
|
updateSendAmount: newAmount => dispatch(actions.updateSendAmount(newAmount)), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -93,8 +99,21 @@ CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) { |
|
|
|
updateGasLimit, |
|
|
|
updateGasLimit, |
|
|
|
hideModal, |
|
|
|
hideModal, |
|
|
|
updateGasTotal, |
|
|
|
updateGasTotal, |
|
|
|
|
|
|
|
maxModeOn, |
|
|
|
|
|
|
|
selectedToken, |
|
|
|
|
|
|
|
balance, |
|
|
|
|
|
|
|
updateSendAmount, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (maxModeOn && !selectedToken) { |
|
|
|
|
|
|
|
const maxAmount = subtractCurrencies( |
|
|
|
|
|
|
|
ethUtil.addHexPrefix(balance), |
|
|
|
|
|
|
|
ethUtil.addHexPrefix(gasTotal), |
|
|
|
|
|
|
|
{ toNumericBase: 'hex' } |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
updateSendAmount(maxAmount) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateGasPrice(gasPrice) |
|
|
|
updateGasPrice(gasPrice) |
|
|
|
updateGasLimit(gasLimit) |
|
|
|
updateGasLimit(gasLimit) |
|
|
|
updateGasTotal(gasTotal) |
|
|
|
updateGasTotal(gasTotal) |
|
|
@ -112,12 +131,13 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) { |
|
|
|
selectedToken, |
|
|
|
selectedToken, |
|
|
|
amountConversionRate, |
|
|
|
amountConversionRate, |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
|
|
|
|
maxModeOn, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|
let error = null |
|
|
|
let error = null |
|
|
|
|
|
|
|
|
|
|
|
const balanceIsSufficient = isBalanceSufficient({ |
|
|
|
const balanceIsSufficient = isBalanceSufficient({ |
|
|
|
amount: selectedToken ? '0' : amount, |
|
|
|
amount: selectedToken || maxModeOn ? '0' : amount, |
|
|
|
gasTotal, |
|
|
|
gasTotal, |
|
|
|
balance, |
|
|
|
balance, |
|
|
|
selectedToken, |
|
|
|
selectedToken, |
|
|
|