Skip to content

feat: poll mctransactions for dropped tx detection#83

Merged
passandscore merged 4 commits intomainfrom
fast-tx-status-polling
Mar 24, 2026
Merged

feat: poll mctransactions for dropped tx detection#83
passandscore merged 4 commits intomainfrom
fast-tx-status-polling

Conversation

@passandscore
Copy link
Contributor

Summary

  • Problem: Dropped txs cause the swap spinner to hang for 60s — eth_getTransactionReceipt returns null forever and wagmi polls indefinitely. The only safety net was a timeout with a misleading "may have succeeded" message.
  • Fix: Poll the mctransactions table (via new /api/fast-tx-status/[hash] route) instead of eth_getTransactionReceipt. This table tracks the FastRPC preconfirmation lifecycle and reflects failed status immediately when a tx is dropped.
  • Bonus: confirmed status from mctransactions now triggers final success without waiting for wagmi, making the happy path faster too.

Changes

  • src/app/api/fast-tx-status/[hash]/route.ts — new API route querying mctransactions via StarRocks fastrpc catalog
  • src/lib/fast-tx-status.ts — client-side fetch wrapper (5s timeout, abort-aware)
  • src/hooks/use-wait-for-tx-confirmation.ts — replaced eth_getTransactionReceipt polling with fetchFastTxStatus; mctransactions confirmed now triggers onConfirmed directly

Test plan

  • Submit a swap, verify pre-confirmed → confirmed flow works via mctransactions polling
  • Trigger a dropped tx (e.g. 15 USDC self-send), verify spinner clears immediately with "Transaction was dropped by the network" error instead of 60s timeout
  • Test Postman: GET /api/fast-tx-status/{hash} returns correct status values
  • Verify non-swap txs (minting, WETH wrap) still work via wagmi fallback (mctransactions returns null for these)

…ctionReceipt

Dropped txs were invisible to the old polling (eth_getTransactionReceipt
returns null forever) causing the spinner to hang for 60s until timeout.

Now polls /api/fast-tx-status/[hash] which queries the mctransactions
table directly. This table tracks the preconfirmation lifecycle and
reflects "failed" status immediately when the RPC drops a tx.

- "failed" → fires onError instantly (no more 60s wait)
- "pre-confirmed" → fires onPreConfirmed, keeps polling
- "confirmed" → fires onConfirmed as final success
- Wagmi receipt watching unchanged as parallel fallback
@vercel
Copy link

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fastprotocolapp Ready Ready Preview, Comment Mar 24, 2026 9:59pm

Request Review

…ctransactions only

Phase 1: poll both eth_getTransactionReceipt and mctransactions in
parallel until pre-confirmed. Phase 2: stop RPC polling, poll only
mctransactions for confirmed/failed. Wagmi stays as parallel fallback.

Also fix toast text: "Pre-confirmed" → "Preconfirmed"
@passandscore passandscore merged commit b18f9cf into main Mar 24, 2026
3 checks passed
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.

1 participant