mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Add network checks for unconfirmed Txs
This commit is contained in:
parent
5f8d3085d7
commit
6f86c5f8ee
@ -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)
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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) {
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user