1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Adds inline opening of gas customization to confirm-send-ether screen.

This commit is contained in:
Dan 2018-03-09 02:03:36 -03:30
parent 5433d2fe3a
commit 2d6b378bf8
3 changed files with 63 additions and 10 deletions

View File

@ -9,6 +9,7 @@ const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN const BN = ethUtil.BN
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn') const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
const { conversionUtil, addCurrencies } = require('../../conversion-util') const { conversionUtil, addCurrencies } = require('../../conversion-util')
const GasFeeDisplay = require('../send/gas-fee-display-v2')
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
@ -73,6 +74,18 @@ function mapDispatchToProps (dispatch) {
dispatch(actions.showSendPage()) dispatch(actions.showSendPage())
}, },
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })), cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
showCustomizeGasModal: (txMeta, sendGasLimit, sendGasPrice, sendGasTotal) => {
const { id, txParams } = txMeta
const { gas: txGasLimit, gasPrice: txGasPrice } = txParams
dispatch(actions.updateSend({
gasLimit: sendGasLimit || txGasLimit,
gasPrice: sendGasPrice || txGasPrice,
editingTransactionId: id,
gasTotal: sendGasTotal,
}))
dispatch(actions.showModal({ name: 'CUSTOMIZE_GAS' }))
},
} }
} }
@ -157,6 +170,7 @@ ConfirmSendEther.prototype.getGasFee = function () {
return { return {
FIAT, FIAT,
ETH, ETH,
gasFeeInHex: txFeeBn.toString(16),
} }
} }
@ -164,7 +178,7 @@ ConfirmSendEther.prototype.getData = function () {
const { identities } = this.props const { identities } = this.props
const txMeta = this.gatherTxMeta() const txMeta = this.gatherTxMeta()
const txParams = txMeta.txParams || {} const txParams = txMeta.txParams || {}
const { FIAT: gasFeeInFIAT, ETH: gasFeeInETH } = this.getGasFee() const { FIAT: gasFeeInFIAT, ETH: gasFeeInETH, gasFeeInHex } = this.getGasFee()
const { FIAT: amountInFIAT, ETH: amountInETH } = this.getAmount() const { FIAT: amountInFIAT, ETH: amountInETH } = this.getAmount()
const totalInFIAT = addCurrencies(gasFeeInFIAT, amountInFIAT, { const totalInFIAT = addCurrencies(gasFeeInFIAT, amountInFIAT, {
@ -192,11 +206,20 @@ ConfirmSendEther.prototype.getData = function () {
amountInETH, amountInETH,
totalInFIAT, totalInFIAT,
totalInETH, totalInETH,
gasFeeInHex,
} }
} }
ConfirmSendEther.prototype.render = function () { ConfirmSendEther.prototype.render = function () {
const { editTransaction, currentCurrency, clearSend } = this.props const {
editTransaction,
currentCurrency,
clearSend,
conversionRate,
currentCurrency: convertedCurrency,
showCustomizeGasModal,
send: { gasTotal, gasLimit: sendGasLimit, gasPrice: sendGasPrice },
} = this.props
const txMeta = this.gatherTxMeta() const txMeta = this.gatherTxMeta()
const txParams = txMeta.txParams || {} const txParams = txMeta.txParams || {}
@ -212,11 +235,17 @@ ConfirmSendEther.prototype.render = function () {
memo, memo,
gasFeeInFIAT, gasFeeInFIAT,
gasFeeInETH, gasFeeInETH,
gasFeeInHex,
amountInFIAT, amountInFIAT,
totalInFIAT, totalInFIAT,
totalInETH, totalInETH,
} = this.getData() } = this.getData()
const title = txMeta.lastGasPrice ? 'Overwrite Transaction' : 'Confirm'
const subtitle = txMeta.lastGasPrice
? 'Increase your gas fee to attempt to overwrite and speed up your transaction'
: 'Please review your transaction.'
// This is from the latest master // This is from the latest master
// It handles some of the errors that we are not currently handling // It handles some of the errors that we are not currently handling
// Leaving as comments fo reference // Leaving as comments fo reference
@ -235,11 +264,11 @@ ConfirmSendEther.prototype.render = function () {
// 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', [
@ -302,9 +331,12 @@ ConfirmSendEther.prototype.render = function () {
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', `${gasFeeInFIAT} ${currentCurrency.toUpperCase()}`), h(GasFeeDisplay, {
gasTotal: gasTotal || gasFeeInHex,
h('div.confirm-screen-row-detail', `${gasFeeInETH} ETH`), conversionRate,
convertedCurrency,
onClick: () => showCustomizeGasModal(txMeta, sendGasLimit, sendGasPrice, gasTotal),
}),
]), ]),
]), ]),

View File

@ -32,11 +32,11 @@ GasFeeDisplay.prototype.render = function () {
}) })
: h('div.currency-display', 'Loading...'), : h('div.currency-display', 'Loading...'),
h('button.send-v2__sliders-icon-container', { h('button.sliders-icon-container', {
onClick, onClick,
disabled: !gasTotal, disabled: !gasTotal,
}, [ }, [
h('i.fa.fa-sliders.send-v2__sliders-icon'), h('i.fa.fa-sliders.sliders-icon'),
]), ]),
]) ])

View File

@ -660,6 +660,7 @@
&__gas-fee-display { &__gas-fee-display {
width: 100%; width: 100%;
position: relative;
} }
&__sliders-icon-container { &__sliders-icon-container {
@ -885,3 +886,23 @@
} }
} }
} }
.sliders-icon-container {
display: flex;
align-items: center;
justify-content: center;
height: 24px;
width: 24px;
border: 1px solid $curious-blue;
border-radius: 4px;
background-color: $white;
position: absolute;
right: 15px;
top: 14px;
cursor: pointer;
font-size: 1em;
}
.sliders-icon {
color: $curious-blue;
}