Skip to content

[DRAFT] refactor: enhance useGetReceipt hook to support multiple providers an…#7121

Draft
fairlighteth wants to merge 2 commits into
developfrom
fix/eth-flow-order-status
Draft

[DRAFT] refactor: enhance useGetReceipt hook to support multiple providers an…#7121
fairlighteth wants to merge 2 commits into
developfrom
fix/eth-flow-order-status

Conversation

@fairlighteth

Copy link
Copy Markdown
Contributor

Summary

Fixes #6157

Improve ETH-flow transaction finalization when the wallet provider fails to return a tx receipt. useGetReceipt now falls back to the app public RPC provider before giving up, which helps prevent ETH-flow creation orders from getting stuck in a local creating state when the tx was already mined or refunded on-chain.

This PR also adds targeted tests for:

  • wallet-provider receipt failure -> public RPC fallback
  • no wallet provider -> public RPC lookup
  • failed ETH-flow creation receipt -> order invalidation through checkOnChainTransaction

To Test

  1. Run the targeted automated checks
  • pnpx nx run cowswap-frontend:typecheck passes
  • pnpx nx run cowswap-frontend:lint --files=apps/cowswap-frontend/src/common/hooks/useGetReceipt.ts,apps/cowswap-frontend/src/common/hooks/useGetReceipt.test.ts,apps/cowswap-frontend/src/modules/
    onchainTransactions/updaters/FinalizeTxUpdater/services/checkOnChainTransaction.test.ts passes
  • ./node_modules/.bin/jest --config apps/cowswap-frontend/jest.config.ts --runInBand apps/cowswap-frontend/src/common/hooks/useGetReceipt.test.ts apps/cowswap-frontend/src/modules/onchainTransactions/updaters/
    FinalizeTxUpdater/services/checkOnChainTransaction.test.ts passes
  1. Verify the ETH-flow failure path behavior
  • When wallet receipt lookup fails but public RPC can fetch the receipt, the tx is still finalized
  • A failed ETH-flow creation receipt invalidates the local order instead of leaving it stuck in creating
  • A successful receipt lookup path still behaves as before
  1. Optional manual validation on Base with MetaMask + WalletConnect
  • Create an ETH-flow order in a setup where the wallet provider is flaky or rate-limited
  • Confirm the app recovers via public RPC receipt lookup when possible
  • Confirm the UI does not keep a stale local ETH-flow order after a failed/refunded creation tx

Background

The investigation suggests the problematic case is not the normal backend-driven order status flow after an order already exists in the API. The risky path is earlier: ETH-flow creation can fail before the order
is ever available in the backend, and in that case the frontend depends on tx receipt polling to invalidate the local order.

Before this change, that receipt polling depended only on the wallet provider. If the wallet stopped returning receipts, the local ETH-flow order could remain stuck even though the chain already had the final result. This PR narrows that gap by falling back to the app RPC provider for receipt reads.

@vercel

vercel Bot commented Mar 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
cowfi Ready Ready Preview Mar 10, 2026 0:29am
explorer-dev Ready Ready Preview Mar 10, 2026 0:29am
swap-dev Ready Ready Preview Mar 10, 2026 0:29am
widget-configurator Ready Ready Preview Mar 10, 2026 0:29am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
cosmos Ignored Ignored Mar 10, 2026 0:29am
sdk-tools Ignored Ignored Preview Mar 10, 2026 0:29am

Request Review

@fairlighteth fairlighteth self-assigned this Mar 9, 2026
@coderabbitai

coderabbitai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 912d4c3f-285b-47c4-84be-4d77981266c5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/eth-flow-order-status

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@elena-zh elena-zh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@fairlighteth fairlighteth changed the title refactor: enhance useGetReceipt hook to support multiple providers an… [DRAFT] refactor: enhance useGetReceipt hook to support multiple providers an… Apr 13, 2026
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.

ETH-flow order status is not correct when place it connected to MM+WC

3 participants