|
|
@ -29,32 +29,36 @@ module.exports = { |
|
|
|
|
|
|
|
|
|
|
|
function transformState (state) { |
|
|
|
function transformState (state) { |
|
|
|
const newState = state |
|
|
|
const newState = state |
|
|
|
const transactions = newState.TransactionController.transactions |
|
|
|
const { TransactionController } = newState |
|
|
|
|
|
|
|
if (TransactionController && TransactionController.transactions) { |
|
|
|
|
|
|
|
|
|
|
|
newState.TransactionController.transactions = transactions.map((txMeta, _, txList) => { |
|
|
|
const transactions = newState.TransactionController.transactions |
|
|
|
if (txMeta.status !== 'submitted') return txMeta |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const confirmedTxs = txList.filter((tx) => tx.status === 'confirmed') |
|
|
|
newState.TransactionController.transactions = transactions.map((txMeta, _, txList) => { |
|
|
|
.filter((tx) => tx.txParams.from === txMeta.txParams.from) |
|
|
|
if (txMeta.status !== 'submitted') return txMeta |
|
|
|
.filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from) |
|
|
|
|
|
|
|
const highestConfirmedNonce = getHighestNonce(confirmedTxs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const pendingTxs = txList.filter((tx) => tx.status === 'submitted') |
|
|
|
const confirmedTxs = txList.filter((tx) => tx.status === 'confirmed') |
|
|
|
.filter((tx) => tx.txParams.from === txMeta.txParams.from) |
|
|
|
.filter((tx) => tx.txParams.from === txMeta.txParams.from) |
|
|
|
.filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from) |
|
|
|
.filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from) |
|
|
|
const highestContinuousNonce = getHighestContinuousFrom(pendingTxs, highestConfirmedNonce) |
|
|
|
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) { |
|
|
|
const maxNonce = Math.max(highestContinuousNonce, highestConfirmedNonce) |
|
|
|
txMeta.status = 'failed' |
|
|
|
|
|
|
|
txMeta.err = { |
|
|
|
if (parseInt(txMeta.txParams.nonce, 16) > maxNonce + 1) { |
|
|
|
message: 'nonce too high', |
|
|
|
txMeta.status = 'failed' |
|
|
|
note: 'migration 019 custom error', |
|
|
|
txMeta.err = { |
|
|
|
|
|
|
|
message: 'nonce too high', |
|
|
|
|
|
|
|
note: 'migration 019 custom error', |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return txMeta |
|
|
|
return txMeta |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
return newState |
|
|
|
return newState |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|