From 5f8d3085d7603135849eb22ad22c70733c236c2d Mon Sep 17 00:00:00 2001 From: Frankie Date: Wed, 7 Sep 2016 20:56:51 -0700 Subject: [PATCH 1/5] Filter out pending txs based on network from tx history --- ui/app/account-detail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js index 486a1a633..5ce6b6703 100644 --- a/ui/app/account-detail.js +++ b/ui/app/account-detail.js @@ -235,7 +235,7 @@ AccountDetailScreen.prototype.subview = function () { AccountDetailScreen.prototype.transactionList = function () { const { transactions, unconfTxs, unconfMsgs, address, network, shapeShiftTxList } = this.props - var txsToRender = transactions + var txsToRender = transactions.concat(unconfTxs) // only transactions that are from the current address .filter(tx => tx.txParams.from === address) // only transactions that are on the current network From 6f86c5f8ee6779eddfde1fbc32e356bbc80708f3 Mon Sep 17 00:00:00 2001 From: Frankie Date: Thu, 8 Sep 2016 12:56:04 -0700 Subject: [PATCH 2/5] Add network checks for unconfirmed Txs --- ui/app/accounts/index.js | 1 + ui/app/conf-tx.js | 4 +++- ui/app/reducers/app.js | 19 ++++++++++++++++--- ui/index.js | 5 +++-- ui/lib/tx-helper.js | 4 ++-- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ui/app/accounts/index.js b/ui/app/accounts/index.js index 6e12accc7..c20900c1e 100644 --- a/ui/app/accounts/index.js +++ b/ui/app/accounts/index.js @@ -11,6 +11,7 @@ module.exports = connect(mapStateToProps)(AccountsScreen) function mapStateToProps (state) { const pendingTxs = valuesFor(state.metamask.unconfTxs) + .filter(tx => tx.txParams.metamaskNetworkId === state.metamask.network) const pendingMsgs = valuesFor(state.metamask.unconfMsgs) const pending = pendingTxs.concat(pendingMsgs) diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js index 22d29383f..99b4bc9f1 100644 --- a/ui/app/conf-tx.js +++ b/ui/app/conf-tx.js @@ -21,6 +21,7 @@ function mapStateToProps (state) { unconfMsgs: state.metamask.unconfMsgs, index: state.appState.currentView.context, warning: state.appState.warning, + network: state.metamask.network, } } @@ -32,9 +33,10 @@ function ConfirmTxScreen () { ConfirmTxScreen.prototype.render = function () { var state = this.props + var network = state.network var unconfTxs = state.unconfTxs var unconfMsgs = state.unconfMsgs - var unconfTxList = txHelper(unconfTxs, unconfMsgs) + var unconfTxList = txHelper(unconfTxs, unconfMsgs, network) var index = state.index !== undefined ? state.index : 0 var txData = unconfTxList[index] || unconfTxList[0] || {} var isNotification = isPopupOrNotification() === 'notification' diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index bad11113a..29d5d9378 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -7,6 +7,7 @@ module.exports = reduceApp function reduceApp (state, action) { // clone and defaults + console.log(action.type) const selectedAccount = state.metamask.selectedAccount const pendingTxs = hasPendingTxs(state) let name = 'accounts' @@ -15,6 +16,15 @@ function reduceApp (state, action) { } if (pendingTxs) { name = 'confTx' + } else { + try { + if (state.appState.currentView.name === 'confTx') { + name = 'accountDetail' + } + } catch (e) { + null + } + } var defaultView = { @@ -258,8 +268,9 @@ function reduceApp (state, action) { case actions.COMPLETED_TX: var unconfTxs = state.metamask.unconfTxs var unconfMsgs = state.metamask.unconfMsgs + var network = state.metamask.network - var unconfTxList = txHelper(unconfTxs, unconfMsgs) + var unconfTxList = txHelper(unconfTxs, unconfMsgs, network) .filter(tx => tx !== tx.id) if (unconfTxList && unconfTxList.length > 0) { @@ -523,14 +534,16 @@ function reduceApp (state, action) { function hasPendingTxs (state) { var unconfTxs = state.metamask.unconfTxs var unconfMsgs = state.metamask.unconfMsgs - var unconfTxList = txHelper(unconfTxs, unconfMsgs) + var network = state.metamask.network + var unconfTxList = txHelper(unconfTxs, unconfMsgs, network) return unconfTxList.length > 0 } function indexForPending (state, txId) { var unconfTxs = state.metamask.unconfTxs var unconfMsgs = state.metamask.unconfMsgs - var unconfTxList = txHelper(unconfTxs, unconfMsgs) + var network = state.metamask.network + var unconfTxList = txHelper(unconfTxs, unconfMsgs, network) let idx unconfTxList.forEach((tx, i) => { if (tx.id === txId) { diff --git a/ui/index.js b/ui/index.js index 8cf74f6ee..0cd6ac735 100644 --- a/ui/index.js +++ b/ui/index.js @@ -3,7 +3,7 @@ const h = require('react-hyperscript') const Root = require('./app/root') const actions = require('./app/actions') const configureStore = require('./app/store') - +const txHelper = require('./lib/tx-helper') module.exports = launchApp function launchApp (opts) { @@ -34,7 +34,8 @@ function startApp (metamaskState, accountManager, opts) { }) // if unconfirmed txs, start on txConf page - if (Object.keys(metamaskState.unconfTxs || {}).length) { + var unconfirmedTxsAll = txHelper(metamaskState.unconfTxs, metamaskState.unconfMsgs, metamaskState.network) + if (unconfirmedTxsAll > 0) { store.dispatch(actions.showConfTxPage()) } diff --git a/ui/lib/tx-helper.js b/ui/lib/tx-helper.js index 8f15cd3cc..c984bc9af 100644 --- a/ui/lib/tx-helper.js +++ b/ui/lib/tx-helper.js @@ -1,7 +1,7 @@ const valuesFor = require('../app/util').valuesFor -module.exports = function (unconfTxs, unconfMsgs) { - var txValues = valuesFor(unconfTxs) +module.exports = function (unconfTxs, unconfMsgs, network) { + var txValues = network ? valuesFor(unconfTxs).filter(tx => tx.txParams.metamaskNetworkId === network) : valuesFor(unconfTxs) var msgValues = valuesFor(unconfMsgs) var allValues = txValues.concat(msgValues) return allValues.sort(tx => tx.time) From 7d8491de106c798727f5f57b08453f2133d144e7 Mon Sep 17 00:00:00 2001 From: Frankie Date: Thu, 8 Sep 2016 13:13:43 -0700 Subject: [PATCH 3/5] Add to CHANGELOG.md and Remove unnecessary catch --- CHANGELOG.md | 1 + ui/app/reducers/app.js | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c20aa11d3..4e44f603d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Current Master +- Add network checks for unconfirmed transactions. - Add fiat conversion values to more views. - On fresh install, open a new tab with the MetaMask Introduction video. - Block negative values from transactions. diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 29d5d9378..9243e53e0 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -16,15 +16,6 @@ function reduceApp (state, action) { } if (pendingTxs) { name = 'confTx' - } else { - try { - if (state.appState.currentView.name === 'confTx') { - name = 'accountDetail' - } - } catch (e) { - null - } - } var defaultView = { From 0d4bfe8038d2fe3617b769cf653152c6d5c47335 Mon Sep 17 00:00:00 2001 From: Frankie Date: Thu, 8 Sep 2016 13:44:32 -0700 Subject: [PATCH 4/5] Remove console.log --- ui/app/reducers/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 9243e53e0..a6cd9ca1b 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -7,7 +7,6 @@ module.exports = reduceApp function reduceApp (state, action) { // clone and defaults - console.log(action.type) const selectedAccount = state.metamask.selectedAccount const pendingTxs = hasPendingTxs(state) let name = 'accounts' From ece1ecb90b6b013b5ea6f81de562d4a391d0f700 Mon Sep 17 00:00:00 2001 From: Frankie Date: Thu, 8 Sep 2016 14:53:49 -0700 Subject: [PATCH 5/5] Fix wording in changelog and bug --- CHANGELOG.md | 2 +- ui/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e44f603d..6a49897d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Current Master -- Add network checks for unconfirmed transactions. +- Fix bug where pending transactions from Test net (or other networks) show up In Main net. - Add fiat conversion values to more views. - On fresh install, open a new tab with the MetaMask Introduction video. - Block negative values from transactions. diff --git a/ui/index.js b/ui/index.js index 0cd6ac735..0e69b00d6 100644 --- a/ui/index.js +++ b/ui/index.js @@ -35,7 +35,7 @@ function startApp (metamaskState, accountManager, opts) { // if unconfirmed txs, start on txConf page var unconfirmedTxsAll = txHelper(metamaskState.unconfTxs, metamaskState.unconfMsgs, metamaskState.network) - if (unconfirmedTxsAll > 0) { + if (unconfirmedTxsAll.length > 0) { store.dispatch(actions.showConfTxPage()) }