Scope
File: src/hooks/useRetryQueue.ts
Problem
Transactions submitted to Soroban RPC may fail due to network congestion, sequence number collisions, or temporary node unavailability. The current approach shows a generic error toast and requires the user to manually retry. For critical operations like tariff updates or collateral deposits, automatic retry with exponential backoff is essential.
Requirements
- Implement a transaction retry queue with states:
pending → submitted → confirmed | failed.
- On
enqueue(id, maxRetries):
- Add a new transaction with
retryCount: 0.
- Set
status: "pending".
updateTxHash(id, txHash) transitions to submitted.
markConfirmed(id) finalizes.
markFailed(id, error):
- If
retryCount < maxRetries, schedule auto-retry with delays: [1s, 5s, 15s, 30s, 60s].
- Else mark as
failed permanently.
retry(id) manually triggers immediate retry.
purge() clears all pending timers and state.
Resolution Strategy
useRef<Map<string, setTimeout>> for active retry timers — cleanup on unmount.
maxRetries default: 5.
- Exponential delays capped at 60s.
- Queue is persisted across browser reloads via
localStorage (extract serialization).
Tags
hooks, transactions, retry, reliability
Scope
File:
src/hooks/useRetryQueue.tsProblem
Transactions submitted to Soroban RPC may fail due to network congestion, sequence number collisions, or temporary node unavailability. The current approach shows a generic error toast and requires the user to manually retry. For critical operations like tariff updates or collateral deposits, automatic retry with exponential backoff is essential.
Requirements
pending → submitted → confirmed | failed.enqueue(id, maxRetries):retryCount: 0.status: "pending".updateTxHash(id, txHash)transitions tosubmitted.markConfirmed(id)finalizes.markFailed(id, error):retryCount < maxRetries, schedule auto-retry with delays:[1s, 5s, 15s, 30s, 60s].failedpermanently.retry(id)manually triggers immediate retry.purge()clears all pending timers and state.Resolution Strategy
useRef<Map<string, setTimeout>>for active retry timers — cleanup on unmount.maxRetriesdefault: 5.localStorage(extract serialization).Tags
hooks, transactions, retry, reliability