Skip to content

Commit

Permalink
Add notification for dropped retry transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
alextsg committed May 24, 2018
1 parent df38b0f commit f2eb35a
Show file tree
Hide file tree
Showing 16 changed files with 317 additions and 71 deletions.
9 changes: 6 additions & 3 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@
"infoHelp": {
"message": "Info & Help"
},
"initialTransactionConfirmed": {
"message": "Your initial transaction was confirmed by the network. Click OK to go back."
},
"insufficientFunds": {
"message": "Insufficient funds."
},
Expand Down Expand Up @@ -701,10 +704,10 @@
"save": {
"message": "Save"
},
"reprice_title": {
"message": "Reprice Transaction"
"speedUpTitle": {
"message": "Speed Up Transaction"
},
"reprice_subtitle": {
"speedUpSubtitle": {
"message": "Increase your gas price to attempt to overwrite and speed up your transaction"
},
"saveAsCsvFile": {
Expand Down
17 changes: 17 additions & 0 deletions app/images/check-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 16 additions & 8 deletions ui/app/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1397,16 +1397,24 @@ function markAccountsFound () {

function retryTransaction (txId) {
log.debug(`background.retryTransaction`)
let newTxId

return (dispatch) => {
background.retryTransaction(txId, (err, newState) => {
if (err) {
return dispatch(actions.displayWarning(err.message))
}
const { selectedAddressTxList } = newState
const { id: newTxId } = selectedAddressTxList[selectedAddressTxList.length - 1]
dispatch(actions.updateMetamaskState(newState))
dispatch(actions.viewPendingTx(newTxId))
return new Promise((resolve, reject) => {
background.retryTransaction(txId, (err, newState) => {
if (err) {
dispatch(actions.displayWarning(err.message))
reject(err)
}

const { selectedAddressTxList } = newState
const { id } = selectedAddressTxList[selectedAddressTxList.length - 1]
newTxId = id
resolve(newState)
})
})
.then(newState => dispatch(actions.updateMetamaskState(newState)))
.then(() => newTxId)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class App extends Component {
h(Authenticated, { path: REVEAL_SEED_ROUTE, exact, component: RevealSeedConfirmation }),
h(Authenticated, { path: SETTINGS_ROUTE, component: Settings }),
h(Authenticated, { path: NOTICE_ROUTE, exact, component: NoticeScreen }),
h(Authenticated, { path: CONFIRM_TRANSACTION_ROUTE, component: ConfirmTxScreen }),
h(Authenticated, { path: `${CONFIRM_TRANSACTION_ROUTE}/:id?`, component: ConfirmTxScreen }),
h(Authenticated, { path: SEND_ROUTE, exact, component: SendTransactionScreen2 }),
h(Authenticated, { path: ADD_TOKEN_ROUTE, exact, component: AddTokenPage }),
h(Authenticated, { path: CONFIRM_ADD_TOKEN_ROUTE, exact, component: ConfirmAddTokenPage }),
Expand Down
2 changes: 2 additions & 0 deletions ui/app/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
@import './info-box/index';

@import './pages/index';

@import './modals/index';
1 change: 1 addition & 0 deletions ui/app/components/modals/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './transaction-confirmed/index';
35 changes: 34 additions & 1 deletion ui/app/components/modals/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const HideTokenConfirmationModal = require('./hide-token-confirmation-modal')
const CustomizeGasModal = require('../customize-gas-modal')
const NotifcationModal = require('./notification-modal')
const ConfirmResetAccount = require('./notification-modals/confirm-reset-account')
const TransactionConfirmed = require('./transaction-confirmed')

const accountModalStyle = {
mobileModalStyle: {
Expand Down Expand Up @@ -265,6 +266,37 @@ const MODALS = {
},
},

TRANSACTION_CONFIRMED: {
disableBackdropClick: true,
contents: [
h(TransactionConfirmed, {}, []),
],
mobileModalStyle: {
width: '100%',
height: '100%',
transform: 'none',
left: '0',
right: '0',
margin: '0 auto',
boxShadow: '0 0 7px 0 rgba(0,0,0,0.08)',
top: '0',
display: 'flex',
},
laptopModalStyle: {
width: '344px',
transform: 'translate3d(-50%, 0, 0px)',
top: '15%',
border: '1px solid #CCCFD1',
borderRadius: '8px',
backgroundColor: '#FFFFFF',
boxShadow: '0 2px 22px 0 rgba(0,0,0,0.2)',
},
contentStyle: {
borderRadius: '8px',
height: '100%',
},
},

DEFAULT: {
contents: [],
mobileModalStyle: {},
Expand Down Expand Up @@ -306,7 +338,7 @@ module.exports = connect(mapStateToProps, mapDispatchToProps)(Modal)
Modal.prototype.render = function () {
const modal = MODALS[this.props.modalState.name || 'DEFAULT']

const children = modal.contents
const { contents: children, disableBackdropClick = false } = modal
const modalStyle = modal[isMobileView() ? 'mobileModalStyle' : 'laptopModalStyle']
const contentStyle = modal.contentStyle || {}

Expand All @@ -326,6 +358,7 @@ Modal.prototype.render = function () {
modalStyle,
contentStyle,
backdropStyle: BACKDROPSTYLE,
closeOnClick: !disableBackdropClick,
},
children,
)
Expand Down
2 changes: 2 additions & 0 deletions ui/app/components/modals/transaction-confirmed/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import TransactionConfirmed from './transaction-confirmed.container'
module.exports = TransactionConfirmed
21 changes: 21 additions & 0 deletions ui/app/components/modals/transaction-confirmed/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.transaction-confirmed {
display: flex;
flex-direction: column;
align-items: center;
padding: 32px;

&__title {
font-size: 2rem;
padding: 16px 0;
}

&__description {
text-align: center;
font-size: .875rem;
line-height: 1.5rem;
}

@media screen and (max-width: 575px) {
justify-content: center;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import Button from '../../button'

class TransactionConfirmed extends Component {
render () {
const { t } = this.context

return (
<div className="page-container page-container--full-width page-container--full-height">
<div className="page-container__content transaction-confirmed">
<img src="images/check-icon.svg" />
<div className="transaction-confirmed__title">
{ `${t('confirmed')}!` }
</div>
<div className="transaction-confirmed__description">
{ t('initialTransactionConfirmed') }
</div>
</div>
<div className="page-container__footer">
<Button
type="primary"
className="page-container__footer-button"
onClick={() => {
this.props.hideModal()
this.props.onHide()
}}
>
{ t('ok') }
</Button>
</div>
</div>
)
}
}

TransactionConfirmed.propTypes = {
hideModal: PropTypes.func.isRequired,
onHide: PropTypes.func.isRequired,
}

TransactionConfirmed.contextTypes = {
t: PropTypes.func,
}

export default TransactionConfirmed
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { connect } from 'react-redux'
import TransactionConfirmed from './transaction-confirmed.component'

const { hideModal } = require('../../../actions')

const mapStateToProps = state => {
const { appState: { modal: { modalState: { props } } } } = state
const { onHide } = props
return {
onHide,
}
}

const mapDispatchToProps = dispatch => {
return {
hideModal: () => dispatch(hideModal()),
}
}

export default connect(mapStateToProps, mapDispatchToProps)(TransactionConfirmed)
60 changes: 37 additions & 23 deletions ui/app/components/pending-tx/confirm-send-ether.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,48 @@ ConfirmSendEther.prototype.convertToRenderableCurrency = function (value, curren
: value
}

ConfirmSendEther.prototype.editTransaction = function (txMeta) {
ConfirmSendEther.prototype.editTransaction = function () {
const { editTransaction, history } = this.props
const txMeta = this.gatherTxMeta()
editTransaction(txMeta)
history.push(SEND_ROUTE)
}

ConfirmSendEther.prototype.renderNetworkDisplay = function () {
ConfirmSendEther.prototype.renderHeaderRow = function (isTxReprice) {
const windowType = window.METAMASK_UI_TYPE
const isFullScreen = windowType !== ENVIRONMENT_TYPE_NOTIFICATION &&
windowType !== ENVIRONMENT_TYPE_POPUP

return (windowType === ENVIRONMENT_TYPE_NOTIFICATION || windowType === ENVIRONMENT_TYPE_POPUP)
? h(NetworkDisplay)
: null
if (isTxReprice && isFullScreen) {
return null
}

return (
h('.page-container__header-row', [
h('span.page-container__back-button', {
onClick: () => this.editTransaction(),
style: {
visibility: isTxReprice ? 'hidden' : 'initial',
},
}, 'Edit'),
!isFullScreen && h(NetworkDisplay),
])
)
}

ConfirmSendEther.prototype.renderHeader = function (isTxReprice) {
const title = isTxReprice ? this.context.t('speedUpTitle') : this.context.t('confirm')
const subtitle = isTxReprice
? this.context.t('speedUpSubtitle')
: this.context.t('pleaseReviewTransaction')

return (
h('.page-container__header', [
this.renderHeaderRow(isTxReprice),
h('.page-container__title', title),
h('.page-container__subtitle', subtitle),
])
)
}

ConfirmSendEther.prototype.render = function () {
Expand All @@ -320,6 +350,7 @@ ConfirmSendEther.prototype.render = function () {
},
} = this.props
const txMeta = this.gatherTxMeta()
const isTxReprice = Boolean(txMeta.lastGasPrice)
const txParams = txMeta.txParams || {}

const {
Expand All @@ -338,11 +369,6 @@ ConfirmSendEther.prototype.render = function () {
totalInETH,
} = this.getData()

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.'

const convertedAmountInFiat = this.convertToRenderableCurrency(amountInFIAT, currentCurrency)
const convertedTotalInFiat = this.convertToRenderableCurrency(totalInFIAT, currentCurrency)

Expand All @@ -362,19 +388,7 @@ ConfirmSendEther.prototype.render = function () {
return (
// Main Send token Card
h('.page-container', [
h('.page-container__header', [
h('.page-container__header-row', [
h('span.page-container__back-button', {
onClick: () => this.editTransaction(txMeta),
style: {
visibility: !txMeta.lastGasPrice ? 'initial' : 'hidden',
},
}, 'Edit'),
this.renderNetworkDisplay(),
]),
h('.page-container__title', title),
h('.page-container__subtitle', subtitle),
]),
this.renderHeader(isTxReprice),
h('.page-container__content', [
h(SenderToRecipient, {
senderName: fromName,
Expand Down
Loading

0 comments on commit f2eb35a

Please sign in to comment.