mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge branch 'retry-tx-refractor' of https://github.com/MetaMask/metamask-extension into retry-tx-refractor
This commit is contained in:
commit
e51ba2e75c
@ -233,6 +233,7 @@ CustomizeGasModal.prototype.render = function () {
|
|||||||
|
|
||||||
convertedGasPrice += convertedGasPrice.match(/[.]/) ? priceSigZeros : `${priceSigDec}${priceSigZeros}`
|
convertedGasPrice += convertedGasPrice.match(/[.]/) ? priceSigZeros : `${priceSigDec}${priceSigZeros}`
|
||||||
|
|
||||||
|
let newGasPrice = gasPrice
|
||||||
if (forceGasMin) {
|
if (forceGasMin) {
|
||||||
const convertedMinPrice = conversionUtil(forceGasMin, {
|
const convertedMinPrice = conversionUtil(forceGasMin, {
|
||||||
fromNumericBase: 'hex',
|
fromNumericBase: 'hex',
|
||||||
@ -242,6 +243,10 @@ CustomizeGasModal.prototype.render = function () {
|
|||||||
{ value: convertedMinPrice, fromNumericBase: 'dec' },
|
{ value: convertedMinPrice, fromNumericBase: 'dec' },
|
||||||
{ value: convertedGasPrice, fromNumericBase: 'dec' }
|
{ value: convertedGasPrice, fromNumericBase: 'dec' }
|
||||||
)
|
)
|
||||||
|
newGasPrice = conversionMax(
|
||||||
|
{ value: gasPrice, fromNumericBase: 'hex' },
|
||||||
|
{ value: forceGasMin, fromNumericBase: 'hex' }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedGasLimit = conversionUtil(gasLimit, {
|
const convertedGasLimit = conversionUtil(gasLimit, {
|
||||||
@ -302,7 +307,7 @@ CustomizeGasModal.prototype.render = function () {
|
|||||||
}, [t('cancel')]),
|
}, [t('cancel')]),
|
||||||
|
|
||||||
h(`div.send-v2__customize-gas__save${error ? '__error' : ''}.allcaps`, {
|
h(`div.send-v2__customize-gas__save${error ? '__error' : ''}.allcaps`, {
|
||||||
onClick: () => !error && this.save(gasPrice, gasLimit, gasTotal),
|
onClick: () => !error && this.save(newGasPrice, gasLimit, gasTotal),
|
||||||
}, [t('save')]),
|
}, [t('save')]),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
@ -68,13 +68,11 @@ function mapDispatchToProps (dispatch) {
|
|||||||
|
|
||||||
let forceGasMin
|
let forceGasMin
|
||||||
if (lastGasPrice) {
|
if (lastGasPrice) {
|
||||||
const stripped = ethUtil.stripHexPrefix(lastGasPrice)
|
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, {
|
||||||
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(stripped, 1.1, {
|
|
||||||
multiplicandBase: 16,
|
multiplicandBase: 16,
|
||||||
multiplierBase: 10,
|
multiplierBase: 10,
|
||||||
toNumericBase: 'hex',
|
toNumericBase: 'hex',
|
||||||
fromDenomination: 'WEI',
|
fromDenomination: 'WEI',
|
||||||
toDenomination: 'GWEI',
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +452,7 @@ ConfirmSendEther.prototype.render = function () {
|
|||||||
|
|
||||||
ConfirmSendEther.prototype.onSubmit = function (event) {
|
ConfirmSendEther.prototype.onSubmit = function (event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const txMeta = this.gatherTxMeta({ time: (new Date()).getTime() })
|
const txMeta = this.gatherTxMeta()
|
||||||
const valid = this.checkValidity()
|
const valid = this.checkValidity()
|
||||||
this.setState({ valid, submitting: true })
|
this.setState({ valid, submitting: true })
|
||||||
|
|
||||||
@ -489,21 +487,34 @@ ConfirmSendEther.prototype.getFormEl = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// After a customizable state value has been updated,
|
// After a customizable state value has been updated,
|
||||||
ConfirmSendEther.prototype.gatherTxMeta = function (opts) {
|
ConfirmSendEther.prototype.gatherTxMeta = function () {
|
||||||
const props = this.props
|
const props = this.props
|
||||||
const state = this.state
|
const state = this.state
|
||||||
const txData = clone(state.txData) || clone(props.txData)
|
const txData = clone(state.txData) || clone(props.txData)
|
||||||
|
|
||||||
if (txData.lastGasPrice) {
|
const { gasPrice: sendGasPrice, gas: sendGasLimit } = props.send
|
||||||
const { gasPrice: sendGasPrice, gas: sendGasLimit } = props.send
|
const {
|
||||||
const { gasPrice: txGasPrice, gas: txGasLimit } = txData.txParams
|
lastGasPrice,
|
||||||
|
txParams: {
|
||||||
|
gasPrice: txGasPrice,
|
||||||
|
gas: txGasLimit,
|
||||||
|
},
|
||||||
|
} = txData
|
||||||
|
|
||||||
txData.txParams.gasPrice = sendGasPrice || txGasPrice
|
let forceGasMin
|
||||||
txData.txParams.gas = sendGasLimit || txGasLimit
|
if (lastGasPrice) {
|
||||||
|
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, {
|
||||||
|
multiplicandBase: 16,
|
||||||
|
multiplierBase: 10,
|
||||||
|
toNumericBase: 'hex',
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
txData.txParams.gasPrice = sendGasPrice || forceGasMin || txGasPrice
|
||||||
|
txData.txParams.gas = sendGasLimit || txGasLimit
|
||||||
|
|
||||||
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
||||||
return Object.assign(txData, opts)
|
return txData
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmSendEther.prototype.verifyGasParams = function () {
|
ConfirmSendEther.prototype.verifyGasParams = function () {
|
||||||
|
@ -104,13 +104,11 @@ function mapDispatchToProps (dispatch, ownProps) {
|
|||||||
|
|
||||||
let forceGasMin
|
let forceGasMin
|
||||||
if (lastGasPrice) {
|
if (lastGasPrice) {
|
||||||
const stripped = ethUtil.stripHexPrefix(lastGasPrice)
|
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, {
|
||||||
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(stripped, 1.1, {
|
|
||||||
multiplicandBase: 16,
|
multiplicandBase: 16,
|
||||||
multiplierBase: 10,
|
multiplierBase: 10,
|
||||||
toNumericBase: 'hex',
|
toNumericBase: 'hex',
|
||||||
fromDenomination: 'WEI',
|
fromDenomination: 'WEI',
|
||||||
toDenomination: 'GWEI',
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,14 +485,27 @@ ConfirmSendToken.prototype.gatherTxMeta = function () {
|
|||||||
const state = this.state
|
const state = this.state
|
||||||
const txData = clone(state.txData) || clone(props.txData)
|
const txData = clone(state.txData) || clone(props.txData)
|
||||||
|
|
||||||
if (txData.lastGasPrice) {
|
const { gasPrice: sendGasPrice, gas: sendGasLimit } = props.send
|
||||||
const { gasPrice: sendGasPrice, gas: sendGasLimit } = props.send
|
const {
|
||||||
const { gasPrice: txGasPrice, gas: txGasLimit } = txData.txParams
|
lastGasPrice,
|
||||||
|
txParams: {
|
||||||
|
gasPrice: txGasPrice,
|
||||||
|
gas: txGasLimit,
|
||||||
|
},
|
||||||
|
} = txData
|
||||||
|
|
||||||
txData.txParams.gasPrice = sendGasPrice || txGasPrice
|
let forceGasMin
|
||||||
txData.txParams.gas = sendGasLimit || txGasLimit
|
if (lastGasPrice) {
|
||||||
|
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, {
|
||||||
|
multiplicandBase: 16,
|
||||||
|
multiplierBase: 10,
|
||||||
|
toNumericBase: 'hex',
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
txData.txParams.gasPrice = sendGasPrice || forceGasMin || txGasPrice
|
||||||
|
txData.txParams.gas = sendGasLimit || txGasLimit
|
||||||
|
|
||||||
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
||||||
return txData
|
return txData
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user