Feat/transaction timeout wrapwithtoast#19
Feat/transaction timeout wrapwithtoast#19ManiBAJPAI22 wants to merge 3 commits intokleros:masterfrom
Conversation
👷 Deploy request for kleros-governor-v2 pending review.Visit the deploys page to approve it
|
WalkthroughA single utility file is updated to introduce transaction receipt timeout handling with a 5-minute deadline, replacing promise chains with try/catch flow, and adding standardized toast notification functions (info, success, error) for improved user feedback across different transaction outcomes. Changes
Sequence DiagramsequenceDiagram
actor User
participant App as Transaction Handler
participant wrapWithToast as wrapWithToast Function
participant RPC as RPC / waitForTransactionReceipt
participant Toast as Toast Notification System
User->>App: Triggers transaction
App->>wrapWithToast: Call with tx hash
wrapWithToast->>wrapWithToast: Emit infoToast (processing)
par Timeout Race
wrapWithToast->>RPC: waitForTransactionReceipt(hash)
wrapWithToast->>wrapWithToast: setTimeout(5 min)
end
alt Receipt arrives in time
RPC-->>wrapWithToast: Returns receipt with status
alt Status = success
wrapWithToast->>Toast: successToast()
else Status = revert/fail
wrapWithToast->>Toast: errorToast(revert message)
end
else Timeout occurs first
wrapWithToast->>Toast: errorToast(timeout message + explorer guidance)
else Other error
wrapWithToast->>wrapWithToast: parseWagmiError()
wrapWithToast->>Toast: errorToast(parsed error message)
end
Toast-->>User: Display notification
wrapWithToast-->>App: Return { status: bool }
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add Transaction Confirmation Timeout to wrapWithToast
What does this PR do?
Enhances the
wrapWithToastutility to include a timeout for transaction confirmations. If a transaction is not confirmed within 5 minutes, the user is notified with a toast suggesting they check the blockchain explorer for status.Why is this change needed?
Previously, users could be left waiting indefinitely if a transaction was delayed or stuck, with no indication of what was happening. This change improves user experience by providing a clear, time-bounded feedback loop and guidance in case of slow or pending transactions.
How does it work?
Promise.racebetweenwaitForTransactionReceiptand a timeout promise.“Transaction is taking longer than expected. It may still confirm. Please check the transaction status on the blockchain explorer.”
What stays the same?
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.