Skip to content

fix(bridging): query across status by deposit tx hash, not order id - #992

Open
gomesalexandre wants to merge 1 commit into
cowprotocol:mainfrom
gomesalexandre:fix_bungee_across_status_deposit_hash
Open

fix(bridging): query across status by deposit tx hash, not order id#992
gomesalexandre wants to merge 1 commit into
cowprotocol:mainfrom
gomesalexandre:fix_bungee_across_status_deposit_hash

Conversation

@gomesalexandre

@gomesalexandre gomesalexandre commented Sep 5, 2026

Copy link
Copy Markdown

tl;dr getBridgingStatusFromEvents was asking Across about the CoW order UID instead of the actual deposit tx hash, so an expired/refunded Bungee+Across bridge was never detected.

What's broken

In packages/bridging/src/providers/bungee/getBridgingStatusFromEvents.ts, when a Bungee event's source leg is COMPLETED and the destination leg is still PENDING for an Across-routed bridge, the code asks the Across API for the deposit status:

const acrossStatus = await getAcrossStatus(event.orderId)

getAcrossStatus (see BungeeApi.ts) hits Across's /deposit/status?depositTxHash=... endpoint - it needs the on-chain deposit transaction hash, not orderId (which is CoW's own order UID / Bungee's request identifier and has no meaning to Across).

Since Across never recognizes the order UID as a deposit hash, the lookup fails, the error is swallowed by the surrounding try/catch (console.error only), and the function falls through to IN_PROGRESS. Net effect: a bridge that Across has actually marked expired or refunded is reported as perpetually IN_PROGRESS and never surfaces BridgeStatus.EXPIRED / BridgeStatus.REFUND to callers.

Also added a guard for the case srcTransactionHash is undefined (per the type, only guaranteed once srcTxStatus === COMPLETED, but TS still types it optional) so this compiles cleanly and doesn't attempt a lookup with undefined.

Fix

Pass event.srcTransactionHash (the real deposit tx hash) instead of event.orderId. Also renamed the misleading callback parameter name at both call sites in BungeeBridgeProvider.ts (it was itself named orderId, which is likely how this slipped in) to depositTxHash to match what the callback's type signature actually expects.

receipts

no runtime changes visually - this is backend/status-polling logic with no UI surface. Added a regression test (BungeeBridgeProvider.test.ts) that:

  • asserts getAcrossStatus is called with the deposit tx hash ('0x123'), never the order id ('123')
  • asserts the resulting status correctly comes back as EXPIRED (previously would have been swallowed into IN_PROGRESS)

Confirmed the added test fails against the pre-fix code (wrong arg passed) and passes after the fix, across all 3 SDK adapters (ethers v5, ethers v6, viem).

Test plan

  • pnpm jest BungeeBridgeProvider.test.ts - 48/48 passing across all adapters
  • pnpm turbo run typecheck --filter=@cowprotocol/sdk-bridging
  • pnpm turbo run lint --filter=@cowprotocol/sdk-bridging
  • Verified new test fails on old code (reverted fix locally, re-ran - confirmed the exact mismatch: expected deposit tx hash, received order id) and passes on the fix

Summary by CodeRabbit

  • Bug Fixes
    • Bridge status checks now use the deposit transaction hash when querying Across.
    • Pending destination events without a source transaction hash no longer trigger an invalid status lookup.
    • Expired bridge responses are correctly reported with the associated deposit transaction hash.

getBridgingStatusFromEvents() asked the Across "/deposit/status" API
about event.orderId (the CoW order UID) instead of
event.srcTransactionHash (the actual on-chain deposit tx). Across has
no record of the order UID, so the lookup effectively never resolves
a real deposit, the error is swallowed by the surrounding try/catch,
and a Bungee-routed Across bridge that actually expired or got
refunded is reported as IN_PROGRESS forever instead of EXPIRED/REFUND.
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 280b03cc-725a-43dc-82e0-3a331107d454

📥 Commits

Reviewing files that changed from the base of the PR and between 9057b6d and 8a5bff9.

📒 Files selected for processing (3)
  • packages/bridging/src/providers/bungee/BungeeBridgeProvider.test.ts
  • packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts
  • packages/bridging/src/providers/bungee/getBridgingStatusFromEvents.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The Bungee bridge status flow now uses the deposit transaction hash for Across status queries. It requires a source transaction hash and adds coverage for expired destination events.

Changes

Bungee status lookup

Layer / File(s) Summary
Use the deposit transaction hash for Across status
packages/bridging/src/providers/bungee/getBridgingStatusFromEvents.ts, packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts, packages/bridging/src/providers/bungee/BungeeBridgeProvider.test.ts
Across status queries now require and use srcTransactionHash. Provider callbacks pass the deposit transaction hash. Tests verify that an expired response returns BridgeStatus.EXPIRED.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 8a5bf

Across bridge status polling now uses the on-chain deposit transaction hash, allowing expired or refunded deposits to resolve correctly instead of remaining in progress. The change includes coverage for this behavior and has no remaining merge-blocking risk.

Suggested reviewers: shoom3301

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary fix: querying Across status with the deposit transaction hash instead of the order ID.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/bridging/src/providers/bungee/BungeeBridgeProvider.test.ts

Parsing error: Unable to parse the specified 'tsconfig' file. Ensure it's correct and has valid syntax.

packages/app-data/tsconfig.json(2,14): error TS6053: File '@cow-sdk/typescript-config/base.json' not found.

packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts

Parsing error: Unable to parse the specified 'tsconfig' file. Ensure it's correct and has valid syntax.

packages/app-data/tsconfig.json(2,14): error TS6053: File '@cow-sdk/typescript-config/base.json' not found.

packages/bridging/src/providers/bungee/getBridgingStatusFromEvents.ts

Parsing error: Unable to parse the specified 'tsconfig' file. Ensure it's correct and has valid syntax.

packages/app-data/tsconfig.json(2,14): error TS6053: File '@cow-sdk/typescript-config/base.json' not found.


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.

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.

1 participant