Skip to content

refactor: rewrite popup PendingTransactionWatcher to reactive useEffect pattern#2243

Merged
janek26 merged 1 commit intomasterfrom
03-16-refactor_rewrite_popup_pendingtransactionwatcher_to_reactive_useeffect_pattern
Mar 19, 2026
Merged

refactor: rewrite popup PendingTransactionWatcher to reactive useEffect pattern#2243
janek26 merged 1 commit intomasterfrom
03-16-refactor_rewrite_popup_pendingtransactionwatcher_to_reactive_useeffect_pattern

Conversation

@janek26
Copy link
Contributor

@janek26 janek26 commented Mar 17, 2026

Rewrite popup PendingTransactionWatcher to reactive useEffect pattern

The popup's PendingTransactionWatcher used usePoll + useWatchPendingTransactions to actively fetch receipts on a timer. Now that the background handles receipt checking, the popup no longer needs to poll — it just needs to react when the background marks a tx as confirmed.

This replaces the polling hook with a reactive useEffect that watches the pending store for non-pending (mined) transactions. When it sees one, it triggers React Query cache refetches, waits for the tx to appear in the consolidated cache, and then removes it from the pending store. The old useWatchPendingTransactions.ts (323 lines) is deleted.

Design choices & review focus

  • Reactive, not polling — The useEffect fires when minedTransactions changes (derived from usePendingTransactionsStore). Since the background writes to Chrome storage and the popup subscribes via Zustand, the popup sees updates automatically without its own timer.
  • Same cleanup delays — The 1.5s initial wait and 5s/16s follow-up refetches are preserved from the old implementation. These account for backend ingestion lag (the consolidated endpoint may not have the tx immediately after on-chain confirmation).
  • Two removal paths preserved — Supported-chain txs are removed only after they appear in the consolidated cache. Custom-chain txs are removed immediately (they aren't in the consolidated endpoint). This prevents the tx list from flickering.
  • invalidationTimeoutsRef cleanup — Timeouts are tracked in a ref and cleared on effect cleanup to prevent stale refetches if the address changes or component unmounts mid-cycle.

PR-Codex overview

This PR focuses on enhancing the PendingTransactionWatcher component to handle confirmed and failed transactions more effectively, updating the pending transactions in the store and improving the cleanup process for transactions.

Detailed summary

  • Deleted useWatchPendingTransactions hook.
  • Integrated transaction updates directly in watchPendingTransactions.
  • Enhanced PendingTransactionWatcher to:
    • Use currentCurrency and supportedChainIds.
    • Refetch queries for confirmed transactions.
    • Remove transactions from the pending store based on cache checks.
    • Added cleanup delays for transaction removal.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@janek26
Copy link
Contributor Author

janek26 commented Mar 17, 2026


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@janek26 janek26 force-pushed the 03-16-refactor_rewrite_popup_pendingtransactionwatcher_to_reactive_useeffect_pattern branch from 75602a9 to 03db031 Compare March 18, 2026 09:02
@janek26 janek26 force-pushed the 03-16-refactor_rewrite_popup_pendingtransactionwatcher_to_reactive_useeffect_pattern branch from 03db031 to 42dfaf0 Compare March 19, 2026 12:38
@janek26 janek26 force-pushed the 03-16-feat_add_chain-specific_tiered_polling_schedule_with_timeout_handling branch from e7790d0 to 16c4306 Compare March 19, 2026 12:38
@janek26 janek26 force-pushed the 03-16-feat_add_chain-specific_tiered_polling_schedule_with_timeout_handling branch 2 times, most recently from 86a9470 to 34dca1f Compare March 19, 2026 14:23
@janek26 janek26 force-pushed the 03-16-refactor_rewrite_popup_pendingtransactionwatcher_to_reactive_useeffect_pattern branch from 42dfaf0 to 30f364b Compare March 19, 2026 14:23
@janek26 janek26 changed the base branch from 03-16-feat_add_chain-specific_tiered_polling_schedule_with_timeout_handling to graphite-base/2243 March 19, 2026 14:56
@janek26 janek26 force-pushed the graphite-base/2243 branch from 34dca1f to d9ff4ec Compare March 19, 2026 14:56
@janek26 janek26 force-pushed the 03-16-refactor_rewrite_popup_pendingtransactionwatcher_to_reactive_useeffect_pattern branch from 30f364b to a3a4e82 Compare March 19, 2026 14:56
@graphite-app graphite-app bot changed the base branch from graphite-base/2243 to master March 19, 2026 14:57
@janek26 janek26 force-pushed the 03-16-refactor_rewrite_popup_pendingtransactionwatcher_to_reactive_useeffect_pattern branch from a3a4e82 to 44b6b72 Compare March 19, 2026 14:57
@janek26 janek26 merged commit 8ce8c33 into master Mar 19, 2026
36 of 38 checks passed
Copy link
Contributor Author

janek26 commented Mar 19, 2026

Merge activity

@janek26 janek26 deleted the 03-16-refactor_rewrite_popup_pendingtransactionwatcher_to_reactive_useeffect_pattern branch March 19, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants