diff options
author | frankiebee <frankie.diamond@gmail.com> | 2018-04-06 10:28:53 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2018-04-06 10:33:10 +0800 |
commit | d4e30040a2186a1320a44f86849506729b2dafad (patch) | |
tree | 33c8a0cbe3fccfd6d27c3ea06bd242c05bdeb293 /app/scripts/migrations/019.js | |
parent | 7d243aacf9db9dc8e3e2e3acfc54298ffc06fe12 (diff) | |
download | tangerine-wallet-browser-d4e30040a2186a1320a44f86849506729b2dafad.tar tangerine-wallet-browser-d4e30040a2186a1320a44f86849506729b2dafad.tar.gz tangerine-wallet-browser-d4e30040a2186a1320a44f86849506729b2dafad.tar.bz2 tangerine-wallet-browser-d4e30040a2186a1320a44f86849506729b2dafad.tar.lz tangerine-wallet-browser-d4e30040a2186a1320a44f86849506729b2dafad.tar.xz tangerine-wallet-browser-d4e30040a2186a1320a44f86849506729b2dafad.tar.zst tangerine-wallet-browser-d4e30040a2186a1320a44f86849506729b2dafad.zip |
migrations - back fixes
Diffstat (limited to 'app/scripts/migrations/019.js')
-rw-r--r-- | app/scripts/migrations/019.js | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/app/scripts/migrations/019.js b/app/scripts/migrations/019.js index 072c96370..ce5da6859 100644 --- a/app/scripts/migrations/019.js +++ b/app/scripts/migrations/019.js @@ -29,32 +29,36 @@ module.exports = { function transformState (state) { const newState = state - const transactions = newState.TransactionController.transactions + const { TransactionController } = newState + if (TransactionController && TransactionController.transactions) { - newState.TransactionController.transactions = transactions.map((txMeta, _, txList) => { - if (txMeta.status !== 'submitted') return txMeta + const transactions = newState.TransactionController.transactions - const confirmedTxs = txList.filter((tx) => tx.status === 'confirmed') - .filter((tx) => tx.txParams.from === txMeta.txParams.from) - .filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from) - const highestConfirmedNonce = getHighestNonce(confirmedTxs) + newState.TransactionController.transactions = transactions.map((txMeta, _, txList) => { + if (txMeta.status !== 'submitted') return txMeta - const pendingTxs = txList.filter((tx) => tx.status === 'submitted') - .filter((tx) => tx.txParams.from === txMeta.txParams.from) - .filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from) - const highestContinuousNonce = getHighestContinuousFrom(pendingTxs, highestConfirmedNonce) + const confirmedTxs = txList.filter((tx) => tx.status === 'confirmed') + .filter((tx) => tx.txParams.from === txMeta.txParams.from) + .filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from) + const highestConfirmedNonce = getHighestNonce(confirmedTxs) - const maxNonce = Math.max(highestContinuousNonce, highestConfirmedNonce) + const pendingTxs = txList.filter((tx) => tx.status === 'submitted') + .filter((tx) => tx.txParams.from === txMeta.txParams.from) + .filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from) + const highestContinuousNonce = getHighestContinuousFrom(pendingTxs, highestConfirmedNonce) - if (parseInt(txMeta.txParams.nonce, 16) > maxNonce + 1) { - txMeta.status = 'failed' - txMeta.err = { - message: 'nonce too high', - note: 'migration 019 custom error', + const maxNonce = Math.max(highestContinuousNonce, highestConfirmedNonce) + + if (parseInt(txMeta.txParams.nonce, 16) > maxNonce + 1) { + txMeta.status = 'failed' + txMeta.err = { + message: 'nonce too high', + note: 'migration 019 custom error', + } } - } - return txMeta - }) + return txMeta + }) + } return newState } |