aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app')
-rw-r--r--ui/app/actions.js23
-rw-r--r--ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js2
-rw-r--r--ui/app/components/tx-list-item.js8
-rw-r--r--ui/app/components/tx-list.js18
-rw-r--r--ui/app/constants/error-keys.js2
-rw-r--r--ui/app/first-time/init-menu.js2
-rw-r--r--ui/app/reducers/app.js6
-rw-r--r--ui/app/selectors/confirm-transaction.js10
8 files changed, 59 insertions, 12 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 7a8d9667d..9edb3511a 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -143,6 +143,8 @@ var actions = {
exportAccountComplete,
SET_ACCOUNT_LABEL: 'SET_ACCOUNT_LABEL',
setAccountLabel,
+ updateNetworkNonce,
+ SET_NETWORK_NONCE: 'SET_NETWORK_NONCE',
// tx conf screen
COMPLETED_TX: 'COMPLETED_TX',
TRANSACTION_ERROR: 'TRANSACTION_ERROR',
@@ -1483,11 +1485,12 @@ function showAccountDetail (address) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
log.debug(`background.setSelectedAddress`)
- background.setSelectedAddress(address, (err) => {
+ background.setSelectedAddress(address, (err, tokens) => {
dispatch(actions.hideLoadingIndication())
if (err) {
return dispatch(actions.displayWarning(err.message))
}
+ dispatch(updateTokens(tokens))
dispatch({
type: actions.SHOW_ACCOUNT_DETAIL,
value: address,
@@ -2115,6 +2118,24 @@ function updateFeatureFlags (updatedFeatureFlags) {
}
}
+function setNetworkNonce (networkNonce) {
+ return {
+ type: actions.SET_NETWORK_NONCE,
+ value: networkNonce,
+ }
+}
+
+function updateNetworkNonce (address) {
+ return (dispatch) => {
+ return new Promise((resolve, reject) => {
+ global.ethQuery.getTransactionCount(address, (err, data) => {
+ dispatch(setNetworkNonce(data))
+ resolve(data)
+ })
+ })
+ }
+}
+
function setMouseUserState (isMouseUser) {
return {
type: actions.SET_MOUSE_USER_STATE,
diff --git a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js
index b170880b4..961aa304e 100644
--- a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js
+++ b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js
@@ -124,7 +124,7 @@ export default class ConfirmTransactionBase extends Component {
if (simulationFails) {
return {
- valid: false,
+ valid: true,
errorKey: TRANSACTION_ERROR_KEY,
}
}
diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js
index 7513ba267..474d62638 100644
--- a/ui/app/components/tx-list-item.js
+++ b/ui/app/components/tx-list-item.js
@@ -35,6 +35,7 @@ function mapStateToProps (state) {
currentCurrency: getCurrentCurrency(state),
contractExchangeRates: state.metamask.contractExchangeRates,
selectedAddressTxList: state.metamask.selectedAddressTxList,
+ networkNonce: state.appState.networkNonce,
}
}
@@ -209,6 +210,7 @@ TxListItem.prototype.showRetryButton = function () {
selectedAddressTxList,
transactionId,
txParams,
+ networkNonce,
} = this.props
if (!txParams) {
return false
@@ -222,11 +224,7 @@ TxListItem.prototype.showRetryButton = function () {
const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce &&
lastSubmittedTxWithCurrentNonce.id === transactionId
if (currentSubmittedTxs.length > 0) {
- const earliestSubmitted = currentSubmittedTxs.reduce((tx1, tx2) => {
- if (tx1.submittedTime < tx2.submittedTime) return tx1
- return tx2
- })
- currentTxSharesEarliestNonce = currentNonce === earliestSubmitted.txParams.nonce
+ currentTxSharesEarliestNonce = currentNonce === networkNonce
}
return currentTxSharesEarliestNonce && currentTxIsLatestWithNonce && Date.now() - transactionSubmittedTime > 30000
diff --git a/ui/app/components/tx-list.js b/ui/app/components/tx-list.js
index 554febcff..d8c4a9d19 100644
--- a/ui/app/components/tx-list.js
+++ b/ui/app/components/tx-list.js
@@ -8,7 +8,7 @@ const selectors = require('../selectors')
const TxListItem = require('./tx-list-item')
const ShiftListItem = require('./shift-list-item')
const { formatDate } = require('../util')
-const { showConfTxPage } = require('../actions')
+const { showConfTxPage, updateNetworkNonce } = require('../actions')
const classnames = require('classnames')
const { tokenInfoGetter } = require('../token-util')
const { withRouter } = require('react-router-dom')
@@ -28,12 +28,14 @@ function mapStateToProps (state) {
return {
txsToRender: selectors.transactionsSelector(state),
conversionRate: selectors.conversionRateSelector(state),
+ selectedAddress: selectors.getSelectedAddress(state),
}
}
function mapDispatchToProps (dispatch) {
return {
showConfTxPage: ({ id }) => dispatch(showConfTxPage({ id })),
+ updateNetworkNonce: (address) => dispatch(updateNetworkNonce(address)),
}
}
@@ -44,6 +46,20 @@ function TxList () {
TxList.prototype.componentWillMount = function () {
this.tokenInfoGetter = tokenInfoGetter()
+ this.props.updateNetworkNonce(this.props.selectedAddress)
+}
+
+TxList.prototype.componentDidUpdate = function (prevProps) {
+ const oldTxsToRender = prevProps.txsToRender
+ const {
+ txsToRender: newTxsToRender,
+ selectedAddress,
+ updateNetworkNonce,
+ } = this.props
+
+ if (newTxsToRender.length > oldTxsToRender.length) {
+ updateNetworkNonce(selectedAddress)
+ }
}
TxList.prototype.render = function () {
diff --git a/ui/app/constants/error-keys.js b/ui/app/constants/error-keys.js
index 1b89be62e..f70ed3b19 100644
--- a/ui/app/constants/error-keys.js
+++ b/ui/app/constants/error-keys.js
@@ -1,3 +1,3 @@
export const INSUFFICIENT_FUNDS_ERROR_KEY = 'insufficientFunds'
export const GAS_LIMIT_TOO_LOW_ERROR_KEY = 'gasLimitTooLow'
-export const TRANSACTION_ERROR = 'transactionError'
+export const TRANSACTION_ERROR_KEY = 'transactionError'
diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js
index c20ba2d77..e7bbfb225 100644
--- a/ui/app/first-time/init-menu.js
+++ b/ui/app/first-time/init-menu.js
@@ -130,7 +130,7 @@ class InitializeMenuScreen extends Component {
textDecoration: 'underline',
marginTop: '32px',
},
- }, 'Use classic interface'),
+ }, this.context.t('classicInterface')),
]),
])
diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js
index 50d8bcba7..e4e4c8581 100644
--- a/ui/app/reducers/app.js
+++ b/ui/app/reducers/app.js
@@ -65,6 +65,7 @@ function reduceApp (state, action) {
buyView: {},
isMouseUser: false,
gasIsLoading: false,
+ networkNonce: null,
}, state.appState)
switch (action.type) {
@@ -701,6 +702,11 @@ function reduceApp (state, action) {
gasIsLoading: false,
})
+ case actions.SET_NETWORK_NONCE:
+ return extend(appState, {
+ networkNonce: action.value,
+ })
+
default:
return appState
}
diff --git a/ui/app/selectors/confirm-transaction.js b/ui/app/selectors/confirm-transaction.js
index 9548cf75e..aa1fc5404 100644
--- a/ui/app/selectors/confirm-transaction.js
+++ b/ui/app/selectors/confirm-transaction.js
@@ -147,14 +147,20 @@ export const tokenAmountAndToAddressSelector = createSelector(
export const approveTokenAmountAndToAddressSelector = createSelector(
tokenDataParamsSelector,
- params => {
+ tokenDecimalsSelector,
+ (params, tokenDecimals) => {
let toAddress = ''
let tokenAmount = 0
if (params && params.length) {
toAddress = params.find(param => param.name === TOKEN_PARAM_SPENDER).value
const value = Number(params.find(param => param.name === TOKEN_PARAM_VALUE).value)
- tokenAmount = roundExponential(value)
+
+ if (tokenDecimals) {
+ tokenAmount = calcTokenAmount(value, tokenDecimals)
+ }
+
+ tokenAmount = roundExponential(tokenAmount)
}
return {