From 4697aca02c669b1787e72f0648b3043270867799 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 23 Feb 2017 14:23:45 -0800 Subject: Got personal_sign working Also fixed bug where signing would not close popup. --- ui/app/reducers/app.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'ui/app/reducers/app.js') diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index de6536c2e..6d92764f1 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -6,6 +6,7 @@ const notification = require('../../../app/scripts/lib/notifications') module.exports = reduceApp function reduceApp (state, action) { + log.debug('App Reducer got ' + action.type) // clone and defaults const selectedAddress = state.metamask.selectedAddress const pendingTxs = hasPendingTxs(state) @@ -289,32 +290,36 @@ function reduceApp (state, action) { case actions.SHOW_CONF_TX_PAGE: return extend(appState, { currentView: { - name: 'confTx', + name: pendingTxs ? 'confTx' : 'account-detail', context: 0, }, transForward: action.transForward, warning: null, + isLoading: false, }) case actions.SHOW_CONF_MSG_PAGE: return extend(appState, { currentView: { - name: 'confTx', + name: pendingTxs ? 'confTx' : 'account-detail', context: 0, }, transForward: true, warning: null, + isLoading: false, }) case actions.COMPLETED_TX: - var unapprovedTxs = state.metamask.unapprovedTxs - var unapprovedMsgs = state.metamask.unapprovedMsgs - var network = state.metamask.network + log.debug('reducing COMPLETED_TX') + var { unapprovedTxs, unapprovedMsgs, + unapprovedPersonalMsgs, network } = state.metamask - var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, network) - .filter(tx => tx !== tx.id) + var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) + .filter(tx => tx !== tx.id) + log.debug(`actions - COMPLETED_TX with ${unconfTxList.length} txs`) if (unconfTxList && unconfTxList.length > 0) { + log.debug('reducer detected txs - rendering confTx view') return extend(appState, { transForward: false, currentView: { @@ -324,6 +329,7 @@ function reduceApp (state, action) { warning: null, }) } else { + log.debug('attempting to close popup') notification.closePopup() return extend(appState, { @@ -572,10 +578,12 @@ function reduceApp (state, action) { } function hasPendingTxs (state) { - var unapprovedTxs = state.metamask.unapprovedTxs - var unapprovedMsgs = state.metamask.unapprovedMsgs - var network = state.metamask.network - var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, network) + var { unapprovedTxs, unapprovedMsgs, + unapprovedPersonalMsgs, network } = state.metamask + + var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) + var has = unconfTxList.length > 0 + log.debug('checking if state has pending txs, concluded ' + has) return unconfTxList.length > 0 } -- cgit From 961a83769bd46334f5ecf72d00a32730d19866c3 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 23 Feb 2017 16:00:43 -0800 Subject: Fix cancel msg signing behavior. --- ui/app/reducers/app.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'ui/app/reducers/app.js') diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 6d92764f1..136326301 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -9,12 +9,13 @@ function reduceApp (state, action) { log.debug('App Reducer got ' + action.type) // clone and defaults const selectedAddress = state.metamask.selectedAddress - const pendingTxs = hasPendingTxs(state) + let pendingTxs = hasPendingTxs(state) let name = 'accounts' if (selectedAddress) { name = 'accountDetail' } if (pendingTxs) { + log.debug('pending txs detected, defaulting to conf-tx view.') name = 'confTx' } @@ -310,15 +311,16 @@ function reduceApp (state, action) { }) case actions.COMPLETED_TX: - log.debug('reducing COMPLETED_TX') + log.debug('reducing COMPLETED_TX for tx ' + action.value) var { unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network } = state.metamask var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) - .filter(tx => tx !== tx.id) - log.debug(`actions - COMPLETED_TX with ${unconfTxList.length} txs`) + .filter(tx => tx.id !== action.value ) - if (unconfTxList && unconfTxList.length > 0) { + pendingTxs = unconfTxList.length > 0 + + if (pendingTxs) { log.debug('reducer detected txs - rendering confTx view') return extend(appState, { transForward: false, @@ -583,8 +585,7 @@ function hasPendingTxs (state) { var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) var has = unconfTxList.length > 0 - log.debug('checking if state has pending txs, concluded ' + has) - return unconfTxList.length > 0 + return has } function indexForPending (state, txId) { -- cgit