Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove txs pending too long #2146

Merged
merged 2 commits into from
Aug 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/state/transactions/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { revokePermit } from 'state/user/actions'
import { findTx } from 'utils'
import { includes } from 'utils/array'

import { checkedTransaction, finalizeTransaction, replaceTx } from './actions'
import { checkedTransaction, finalizeTransaction, removeTx, replaceTx } from './actions'
import { SerializableTransactionReceipt, TRANSACTION_TYPE, TransactionDetails } from './type'

function shouldCheck(
Expand Down Expand Up @@ -83,7 +83,12 @@ export default function Updater(): null {
const transaction = findTx(transactions, hash)
if (!transaction || !res) return // !res this mean tx was drop

const { sentAtBlock, from, to, nonce, data } = transaction
const { sentAtBlock, from, to, nonce, data, addedTime } = transaction
const checkRemoveTxs = () => {
// pending >1 days
if (Date.now() - addedTime > 86_400_000) dispatch(removeTx({ chainId, hash }))
}

if (sentAtBlock && from && to && nonce && data)
findReplacementTx(readProvider, sentAtBlock, {
from,
Expand All @@ -103,10 +108,10 @@ export default function Updater(): null {
}
})
.catch(() => {
// dispatch(removeTx({ chainId, hash }))
checkRemoveTxs()
})
else {
// dispatch(removeTx({ chainId, hash }))
checkRemoveTxs()
}
})
.catch(console.warn)
Expand Down
Loading