Handle reverted transactions in wallet transfer flow#2055
Merged
Conversation
useTransferToWallet's background receipt watcher fed the resolved waitForTransactionReceipt promise straight to TransactionStatus.SUCCESS, but viem resolves with the receipt regardless of execution outcome — a reverted on-chain tx returns receipt.status === 'reverted' rather than throwing. Connect-wallet add-funds activities therefore flipped to SUCCESS even when the user's transfer reverted on-chain, masking the failure in the activity list / detail page. Inspect receipt.status before promoting to SUCCESS; reverted receipts go through the same FAILED + error-metadata path the .catch() branch already uses, matching the contract pattern used in useTransactionReceiptPolling and other deposit hooks. https://claude.ai/code/session_01RxjZ6dUk9zmVbuPEXcvqaX
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed a bug in the wallet transfer flow where reverted on-chain transactions were incorrectly marked as successful. The code now properly checks the transaction receipt status and marks transactions as failed when they revert on-chain.
Key Changes
useTransferToWallethook to inspect the transaction receipt status returned bywaitForTransactionReceiptreceipt.status !== 'success'before marking transaction as successfulTransactionStatus.FAILEDstatus and includes error metadata with the failure reason and timestampImplementation Details
waitForTransactionReceiptresolves with the receipt regardless of execution outcome, so explicit status checking is requiredstatus: 'reverted'in the receipt objecthttps://claude.ai/code/session_01RxjZ6dUk9zmVbuPEXcvqaX