|
|
@ -33,6 +33,7 @@ const { |
|
|
|
const { |
|
|
|
const { |
|
|
|
getGasPrice, |
|
|
|
getGasPrice, |
|
|
|
getGasLimit, |
|
|
|
getGasLimit, |
|
|
|
|
|
|
|
getGasIsLoading, |
|
|
|
getForceGasMin, |
|
|
|
getForceGasMin, |
|
|
|
conversionRateSelector, |
|
|
|
conversionRateSelector, |
|
|
|
getSendAmount, |
|
|
|
getSendAmount, |
|
|
@ -51,6 +52,7 @@ function mapStateToProps (state) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
gasPrice: getGasPrice(state), |
|
|
|
gasPrice: getGasPrice(state), |
|
|
|
gasLimit: getGasLimit(state), |
|
|
|
gasLimit: getGasLimit(state), |
|
|
|
|
|
|
|
gasIsLoading: getGasIsLoading(state), |
|
|
|
forceGasMin: getForceGasMin(state), |
|
|
|
forceGasMin: getForceGasMin(state), |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
amount: getSendAmount(state), |
|
|
|
amount: getSendAmount(state), |
|
|
@ -73,7 +75,7 @@ function mapDispatchToProps (dispatch) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getOriginalState (props) { |
|
|
|
function getFreshState (props) { |
|
|
|
const gasPrice = props.gasPrice || MIN_GAS_PRICE_DEC |
|
|
|
const gasPrice = props.gasPrice || MIN_GAS_PRICE_DEC |
|
|
|
const gasLimit = props.gasLimit || MIN_GAS_LIMIT_DEC |
|
|
|
const gasLimit = props.gasLimit || MIN_GAS_LIMIT_DEC |
|
|
|
|
|
|
|
|
|
|
@ -97,7 +99,11 @@ inherits(CustomizeGasModal, Component) |
|
|
|
function CustomizeGasModal (props) { |
|
|
|
function CustomizeGasModal (props) { |
|
|
|
Component.call(this) |
|
|
|
Component.call(this) |
|
|
|
|
|
|
|
|
|
|
|
this.state = getOriginalState(props) |
|
|
|
const originalState = getFreshState(props) |
|
|
|
|
|
|
|
this.state = { |
|
|
|
|
|
|
|
...originalState, |
|
|
|
|
|
|
|
originalState, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CustomizeGasModal.contextTypes = { |
|
|
|
CustomizeGasModal.contextTypes = { |
|
|
@ -106,6 +112,36 @@ CustomizeGasModal.contextTypes = { |
|
|
|
|
|
|
|
|
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(CustomizeGasModal) |
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(CustomizeGasModal) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CustomizeGasModal.prototype.componentWillReceiveProps = function (nextProps) { |
|
|
|
|
|
|
|
const currentState = getFreshState(this.props) |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
gasPrice: currentGasPrice, |
|
|
|
|
|
|
|
gasLimit: currentGasLimit, |
|
|
|
|
|
|
|
} = currentState |
|
|
|
|
|
|
|
const newState = getFreshState(nextProps) |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
gasPrice: newGasPrice, |
|
|
|
|
|
|
|
gasLimit: newGasLimit, |
|
|
|
|
|
|
|
gasTotal: newGasTotal, |
|
|
|
|
|
|
|
} = newState |
|
|
|
|
|
|
|
const gasPriceChanged = currentGasPrice !== newGasPrice |
|
|
|
|
|
|
|
const gasLimitChanged = currentGasLimit !== newGasLimit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (gasPriceChanged) { |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
gasPrice: newGasPrice, |
|
|
|
|
|
|
|
gasTotal: newGasTotal, |
|
|
|
|
|
|
|
priceSigZeros: '', |
|
|
|
|
|
|
|
priceSigDec: '', |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (gasLimitChanged) { |
|
|
|
|
|
|
|
this.setState({ gasLimit: newGasLimit, gasTotal: newGasTotal }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (gasLimitChanged || gasPriceChanged) { |
|
|
|
|
|
|
|
this.validate({ gasLimit: newGasLimit, gasTotal: newGasTotal }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) { |
|
|
|
CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) { |
|
|
|
const { |
|
|
|
const { |
|
|
@ -137,7 +173,7 @@ CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CustomizeGasModal.prototype.revert = function () { |
|
|
|
CustomizeGasModal.prototype.revert = function () { |
|
|
|
this.setState(getOriginalState(this.props)) |
|
|
|
this.setState(this.state.originalState) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) { |
|
|
|
CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) { |
|
|
@ -233,7 +269,7 @@ CustomizeGasModal.prototype.convertAndSetGasPrice = function (newGasPrice) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CustomizeGasModal.prototype.render = function () { |
|
|
|
CustomizeGasModal.prototype.render = function () { |
|
|
|
const { hideModal, forceGasMin } = this.props |
|
|
|
const { hideModal, forceGasMin, gasIsLoading } = this.props |
|
|
|
const { gasPrice, gasLimit, gasTotal, error, priceSigZeros, priceSigDec } = this.state |
|
|
|
const { gasPrice, gasLimit, gasTotal, error, priceSigZeros, priceSigDec } = this.state |
|
|
|
|
|
|
|
|
|
|
|
let convertedGasPrice = conversionUtil(gasPrice, { |
|
|
|
let convertedGasPrice = conversionUtil(gasPrice, { |
|
|
@ -266,7 +302,7 @@ CustomizeGasModal.prototype.render = function () { |
|
|
|
toNumericBase: 'dec', |
|
|
|
toNumericBase: 'dec', |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return h('div.send-v2__customize-gas', {}, [ |
|
|
|
return !gasIsLoading && h('div.send-v2__customize-gas', {}, [ |
|
|
|
h('div.send-v2__customize-gas__content', { |
|
|
|
h('div.send-v2__customize-gas__content', { |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
h('div.send-v2__customize-gas__header', {}, [ |
|
|
|
h('div.send-v2__customize-gas__header', {}, [ |
|
|
@ -288,6 +324,7 @@ CustomizeGasModal.prototype.render = function () { |
|
|
|
onChange: value => this.convertAndSetGasPrice(value), |
|
|
|
onChange: value => this.convertAndSetGasPrice(value), |
|
|
|
title: this.context.t('gasPrice'), |
|
|
|
title: this.context.t('gasPrice'), |
|
|
|
copy: this.context.t('gasPriceCalculation'), |
|
|
|
copy: this.context.t('gasPriceCalculation'), |
|
|
|
|
|
|
|
gasIsLoading, |
|
|
|
}), |
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
h(GasModalCard, { |
|
|
|
h(GasModalCard, { |
|
|
@ -297,6 +334,7 @@ CustomizeGasModal.prototype.render = function () { |
|
|
|
onChange: value => this.convertAndSetGasLimit(value), |
|
|
|
onChange: value => this.convertAndSetGasLimit(value), |
|
|
|
title: this.context.t('gasLimit'), |
|
|
|
title: this.context.t('gasLimit'), |
|
|
|
copy: this.context.t('gasLimitCalculation'), |
|
|
|
copy: this.context.t('gasLimitCalculation'), |
|
|
|
|
|
|
|
gasIsLoading, |
|
|
|
}), |
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
]), |
|
|
|
]), |
|
|
|