From 16d55937b5f31db87d3d92e8ae3b6cbaf89ce9d8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 7 May 2026 11:50:08 +0000 Subject: [PATCH] fix(add-funds): mark reverted on-chain transfers as FAILED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- hooks/useTransferToWallet.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hooks/useTransferToWallet.ts b/hooks/useTransferToWallet.ts index b99ed0b8..5c1cda43 100644 --- a/hooks/useTransferToWallet.ts +++ b/hooks/useTransferToWallet.ts @@ -184,7 +184,21 @@ const useTransferToWallet = ( waitForTransactionReceipt(publicClient(srcChainId), { hash: txHash as `0x${string}`, }) - .then(() => { + .then(receipt => { + // viem resolves with the receipt regardless of execution outcome. + // A reverted on-chain transaction is `status: 'reverted'` — treat + // that as FAILED, not SUCCESS. + if (receipt.status !== 'success') { + updateActivity(capturedTrackingId!, { + status: TransactionStatus.FAILED, + metadata: { + error: 'Transaction reverted on-chain', + failedAt: new Date().toISOString(), + }, + }); + return; + } + updateActivity(capturedTrackingId!, { status: TransactionStatus.SUCCESS }); track(TRACKING_EVENTS.DEPOSIT_COMPLETED, {