|
|
@ -8,6 +8,7 @@ abiDecoder.addABI(tokenAbi) |
|
|
|
const actions = require('../../actions') |
|
|
|
const actions = require('../../actions') |
|
|
|
const clone = require('clone') |
|
|
|
const clone = require('clone') |
|
|
|
const Identicon = require('../identicon') |
|
|
|
const Identicon = require('../identicon') |
|
|
|
|
|
|
|
const GasFeeDisplay = require('../send/gas-fee-display-v2.js') |
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
const BN = ethUtil.BN |
|
|
|
const BN = ethUtil.BN |
|
|
|
const { |
|
|
|
const { |
|
|
@ -88,6 +89,42 @@ function mapDispatchToProps (dispatch, ownProps) { |
|
|
|
})) |
|
|
|
})) |
|
|
|
dispatch(actions.showSendTokenPage()) |
|
|
|
dispatch(actions.showSendTokenPage()) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
showCustomizeGasModal: (txMeta, sendGasLimit, sendGasPrice, sendGasTotal) => { |
|
|
|
|
|
|
|
const { id, txParams, lastGasPrice } = txMeta |
|
|
|
|
|
|
|
const { gas: txGasLimit, gasPrice: txGasPrice } = txParams |
|
|
|
|
|
|
|
const tokenData = txParams.data && abiDecoder.decodeMethod(txParams.data) |
|
|
|
|
|
|
|
const { params = [] } = tokenData |
|
|
|
|
|
|
|
const { value: to } = params[0] || {} |
|
|
|
|
|
|
|
const { value: tokenAmountInDec } = params[1] || {} |
|
|
|
|
|
|
|
const tokenAmountInHex = conversionUtil(tokenAmountInDec, { |
|
|
|
|
|
|
|
fromNumericBase: 'dec', |
|
|
|
|
|
|
|
toNumericBase: 'hex', |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let forceGasMin |
|
|
|
|
|
|
|
let nonce |
|
|
|
|
|
|
|
if (lastGasPrice) { |
|
|
|
|
|
|
|
const stripped = ethUtil.stripHexPrefix(lastGasPrice) |
|
|
|
|
|
|
|
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(stripped, 1.1, { |
|
|
|
|
|
|
|
multiplicandBase: 16, |
|
|
|
|
|
|
|
multiplierBase: 10, |
|
|
|
|
|
|
|
toNumericBase: 'hex', |
|
|
|
|
|
|
|
fromDenomination: 'WEI', |
|
|
|
|
|
|
|
toDenomination: 'GWEI', |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(actions.updateSend({ |
|
|
|
|
|
|
|
gasLimit: sendGasLimit || txGasLimit, |
|
|
|
|
|
|
|
gasPrice: sendGasPrice || txGasPrice, |
|
|
|
|
|
|
|
editingTransactionId: id, |
|
|
|
|
|
|
|
gasTotal: sendGasTotal, |
|
|
|
|
|
|
|
to, |
|
|
|
|
|
|
|
amount: tokenAmountInHex, |
|
|
|
|
|
|
|
forceGasMin, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
dispatch(actions.showModal({ name: 'CUSTOMIZE_GAS' })) |
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -187,6 +224,7 @@ ConfirmSendToken.prototype.getGasFee = function () { |
|
|
|
token: tokenExchangeRate |
|
|
|
token: tokenExchangeRate |
|
|
|
? tokenGas |
|
|
|
? tokenGas |
|
|
|
: null, |
|
|
|
: null, |
|
|
|
|
|
|
|
gasFeeInHex: gasTotal.toString(16), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -239,19 +277,31 @@ ConfirmSendToken.prototype.renderHeroAmount = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ConfirmSendToken.prototype.renderGasFee = function () { |
|
|
|
ConfirmSendToken.prototype.renderGasFee = function () { |
|
|
|
const { token: { symbol }, currentCurrency } = this.props |
|
|
|
const { |
|
|
|
const { fiat: fiatGas, token: tokenGas, eth: ethGas } = this.getGasFee() |
|
|
|
token: { symbol }, |
|
|
|
|
|
|
|
currentCurrency: convertedCurrency, |
|
|
|
|
|
|
|
conversionRate, |
|
|
|
|
|
|
|
send: { gasTotal, gasLimit: sendGasLimit, gasPrice: sendGasPrice }, |
|
|
|
|
|
|
|
showCustomizeGasModal, |
|
|
|
|
|
|
|
} = this.props |
|
|
|
|
|
|
|
const txMeta = this.gatherTxMeta() |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
fiat: fiatGas, |
|
|
|
|
|
|
|
token: tokenGas, |
|
|
|
|
|
|
|
eth: ethGas, |
|
|
|
|
|
|
|
gasFeeInHex |
|
|
|
|
|
|
|
} = this.getGasFee() |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
h('section.flex-row.flex-center.confirm-screen-row', [ |
|
|
|
h('section.flex-row.flex-center.confirm-screen-row', [ |
|
|
|
h('span.confirm-screen-label.confirm-screen-section-column', [ 'Gas Fee' ]), |
|
|
|
h('span.confirm-screen-label.confirm-screen-section-column', [ 'Gas Fee' ]), |
|
|
|
h('div.confirm-screen-section-column', [ |
|
|
|
h('div.confirm-screen-section-column', [ |
|
|
|
h('div.confirm-screen-row-info', `${fiatGas} ${currentCurrency}`), |
|
|
|
h(GasFeeDisplay, { |
|
|
|
|
|
|
|
gasTotal: gasTotal || gasFeeInHex, |
|
|
|
h( |
|
|
|
conversionRate, |
|
|
|
'div.confirm-screen-row-detail', |
|
|
|
convertedCurrency, |
|
|
|
tokenGas ? `${tokenGas} ${symbol}` : `${ethGas} ETH` |
|
|
|
onClick: () => showCustomizeGasModal(txMeta, sendGasLimit, sendGasPrice, gasTotal), |
|
|
|
), |
|
|
|
}), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]) |
|
|
|
]) |
|
|
|
) |
|
|
|
) |
|
|
@ -307,16 +357,21 @@ ConfirmSendToken.prototype.render = function () { |
|
|
|
|
|
|
|
|
|
|
|
this.inputs = [] |
|
|
|
this.inputs = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const title = txMeta.lastGasPrice ? 'Reprice Transaction' : 'Confirm' |
|
|
|
|
|
|
|
const subtitle = txMeta.lastGasPrice |
|
|
|
|
|
|
|
? 'Increase your gas fee to attempt to overwrite and speed up your transaction' |
|
|
|
|
|
|
|
: 'Please review your transaction.' |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
h('div.confirm-screen-container.confirm-send-token', [ |
|
|
|
h('div.confirm-screen-container.confirm-send-token', [ |
|
|
|
// Main Send token Card
|
|
|
|
// Main Send token Card
|
|
|
|
h('div.page-container', [ |
|
|
|
h('div.page-container', [ |
|
|
|
h('div.page-container__header', [ |
|
|
|
h('div.page-container__header', [ |
|
|
|
h('button.confirm-screen-back-button', { |
|
|
|
!txMeta.lastGasPrice && h('button.confirm-screen-back-button', { |
|
|
|
onClick: () => editTransaction(txMeta), |
|
|
|
onClick: () => editTransaction(txMeta), |
|
|
|
}, 'Edit'), |
|
|
|
}, 'Edit'), |
|
|
|
h('div.page-container__title', 'Confirm'), |
|
|
|
h('div.page-container__title', title), |
|
|
|
h('div.page-container__subtitle', `Please review your transaction.`), |
|
|
|
h('div.page-container__subtitle', subtitle), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.flex-row.flex-center.confirm-screen-identicons', [ |
|
|
|
h('div.flex-row.flex-center.confirm-screen-identicons', [ |
|
|
|
h('div.confirm-screen-account-wrapper', [ |
|
|
|
h('div.confirm-screen-account-wrapper', [ |
|
|
@ -438,6 +493,14 @@ 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: txGasPrice, gas: txGasLimit } = txData.txParams |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
txData.txParams.gasPrice = sendGasPrice || 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 |
|
|
|
} |
|
|
|
} |
|
|
|