Skip to content

Conversation

@shoom3301
Copy link
Collaborator

@shoom3301 shoom3301 commented Dec 19, 2025

Summary

image

To Test

  1. Open widget configurator
  2. Input {"disableCrossChainSwap": true} to Raw JSON params
  3. Click "Update widget"
  • cross-chain swaps should not be avaliable in the widget

Summary by CodeRabbit

  • New Features
    • Widget configuration now supports an option to disable cross-chain swaps

✏️ Tip: You can customize this high-level summary in your review settings.

@shoom3301 shoom3301 requested review from a team December 19, 2025 11:51
@shoom3301 shoom3301 self-assigned this Dec 19, 2025
@vercel
Copy link

vercel bot commented Dec 19, 2025

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

Project Deployment Review Updated (UTC)
cowfi Ready Ready Preview Dec 19, 2025 1:59pm
explorer-dev Ready Ready Preview Dec 19, 2025 1:59pm
swap-dev Ready Ready Preview Dec 19, 2025 1:59pm
widget-configurator Ready Ready Preview Dec 19, 2025 1:59pm
2 Skipped Deployments
Project Deployment Review Updated (UTC)
cosmos Ignored Ignored Dec 19, 2025 1:59pm
sdk-tools Ignored Ignored Preview Dec 19, 2025 1:59pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

This PR relocates BridgingEnabledUpdater from common/updaters to the bridge module, introduces a new disableCrossChainSwap widget parameter, and updates the updater to respect this flag when determining bridging enablement on the swap route.

Changes

Cohort / File(s) Summary
Module reorganization
apps/cowswap-frontend/src/modules/application/containers/App/Updaters.tsx, apps/cowswap-frontend/src/modules/bridge/index.ts
Updated import path for BridgingEnabledUpdater from common/updaters to modules/bridge; added new public export of the updater through bridge module's index file
Updater logic enhancement
apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts
Integrated useInjectedWidgetParams hook to check disableCrossChainSwap flag; updated Routes import from relative to common/constants; modified bridging enabled condition to additionally require that disableCrossChainSwap is not true; removed ESLint disable comment
Widget API expansion
libs/widget-lib/src/types.ts
Added optional disableCrossChainSwap boolean property to CowSwapWidgetParams with documentation; minor style fix to FlexibleSlippageConfig type alias

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify the Routes import path change correctly references common/constants/routes
  • Confirm the updated bridging enabled condition logic (route === SWAP && !disableCrossChainSwap) aligns with intended behavior
  • Ensure the new widget parameter is properly threaded through the hook and documented

Possibly related PRs

Suggested labels

Bridge, preview-widget-cfg

Suggested reviewers

  • elena-zh
  • alfetopito
  • limitofzero

Poem

🐰 A flag hops into the widget's heart,
Cross-chains may pause, or play their part,
The updater moves to bridge module home,
Now swaps control their fate and roam! 🌉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The description is missing required sections: no 'Fixes #issueNumber' reference, no 'Background' section, and lacks detailed high-level explanation of the changes beyond testing steps. Add a high-level summary explaining what disableCrossChainSwap does, include issue reference if applicable, and optionally add Background section with context about the feature.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a widget option to disable bridging, which aligns with the implementation adding disableCrossChainSwap parameter.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/disable-bridge-in-widget

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
libs/widget-lib/src/types.ts (1)

261-265: Consider clarifying interaction with related parameters.

The new disableCrossChainSwap parameter is well-documented and follows naming conventions. However, consider documenting how it interacts with targetChainId (line 211) and hideBridgeInfo (line 301).

For example, if a user sets disableCrossChainSwap: true but also provides a targetChainId, what's the expected behavior? Should targetChainId be ignored, or should this combination be validated?

💡 Suggested documentation enhancement
  /**
   * Disables cross-chain swaps (bridging)
+  * When enabled, targetChainId will be ignored and cross-chain functionality will be unavailable.
   * Defaults to false.
   */
  disableCrossChainSwap?: boolean
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab4eb18 and e09ebb9.

📒 Files selected for processing (4)
  • apps/cowswap-frontend/src/modules/application/containers/App/Updaters.tsx (1 hunks)
  • apps/cowswap-frontend/src/modules/bridge/index.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts (1 hunks)
  • libs/widget-lib/src/types.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5443
File: apps/cowswap-frontend/src/modules/swap/containers/ConfirmSwapModalSetup/index.tsx:71-71
Timestamp: 2025-02-20T15:59:33.749Z
Learning: The swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in PR #5444 as part of the swap widget unification effort.
📚 Learning: 2025-09-25T08:49:32.256Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:62-67
Timestamp: 2025-09-25T08:49:32.256Z
Learning: In the cowswap-frontend codebase, when testing hooks that use multiple bridge providers, both providers are always properly mocked as complete jest.Mocked<BridgeProvider<BridgeQuoteResult>> objects with all required methods stubbed, ensuring no undefined returns that could break the hook logic.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts
📚 Learning: 2025-02-20T15:59:33.749Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5443
File: apps/cowswap-frontend/src/modules/swap/containers/ConfirmSwapModalSetup/index.tsx:71-71
Timestamp: 2025-02-20T15:59:33.749Z
Learning: The swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in PR #5444 as part of the swap widget unification effort.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts
  • libs/widget-lib/src/types.ts
  • apps/cowswap-frontend/src/modules/application/containers/App/Updaters.tsx
📚 Learning: 2025-09-19T11:38:59.206Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6232
File: apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx:199-200
Timestamp: 2025-09-19T11:38:59.206Z
Learning: The makeBuildClickEvent function in apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx takes five parameters: defaultChainId, contextLabel, mode, isSwapMode, and chainsCount. The chainsCount parameter is used to determine the CrossChain flag in analytics events.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts
📚 Learning: 2025-08-12T05:57:08.021Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6138
File: libs/hook-dapp-lib/src/hookDappsRegistry.ts:1-1
Timestamp: 2025-08-12T05:57:08.021Z
Learning: The matchHooksToDapps function in libs/hook-dapp-lib/src/utils.ts provides backward compatibility for permit hooks through function selector detection (EIP_2612_PERMIT_SELECTOR and DAI_PERMIT_SELECTOR) rather than dappId matching, making it robust against dappId changes.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts
  • apps/cowswap-frontend/src/modules/application/containers/App/Updaters.tsx
📚 Learning: 2025-06-23T07:03:50.760Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5859
File: apps/cowswap-frontend/src/modules/tradeQuote/hooks/useTradeQuotePolling.ts:76-82
Timestamp: 2025-06-23T07:03:50.760Z
Learning: In the useTradeQuotePolling hook, there are two useLayoutEffect hooks that work together: one resets the counter to 0 when the confirmation modal closes, and another automatically triggers pollQuote(false, true) whenever the counter reaches 0. This creates an intentional chain reaction for immediate quote updates.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts
📚 Learning: 2025-07-24T10:00:45.353Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/hooks/useHighFeeWarning.ts:36-36
Timestamp: 2025-07-24T10:00:45.353Z
Learning: In the CowSwap frontend, when there's a bridgeFee present in the transaction, the isSell flag is always true for business reasons. This means bridge transactions are always structured as sell operations, which ensures consistent currency handling in fee percentage calculations.

Applied to files:

  • libs/widget-lib/src/types.ts
📚 Learning: 2025-11-19T10:18:23.717Z
Learnt from: limitofzero
Repo: cowprotocol/cowswap PR: 6537
File: apps/cowswap-frontend/src/modules/trade/pure/PartnerFeeRow/index.tsx:33-35
Timestamp: 2025-11-19T10:18:23.717Z
Learning: In apps/cowswap-frontend/src/modules/trade/pure/PartnerFeeRow/index.tsx, when there is no partner fee (amount is null/undefined, bps is missing, or amount equals 0), FreeFeeRow is rendered with withTimelineDot={false} hardcoded. This is intentional design—free fee rows should not show the timeline dot regardless of what the parent component passes, as they have a distinct visual treatment from actual fee rows.

Applied to files:

  • libs/widget-lib/src/types.ts
🧬 Code graph analysis (1)
apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts (3)
apps/cowswap-frontend/src/modules/trade/hooks/useTradeTypeInfo.ts (1)
  • useTradeTypeInfo (6-8)
libs/common-hooks/src/useIsBridgingEnabled.ts (1)
  • useSetIsBridgingEnabled (9-11)
apps/cowswap-frontend/src/common/constants/routes.ts (1)
  • Routes (10-45)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Setup
  • GitHub Check: Cypress
🔇 Additional comments (5)
apps/cowswap-frontend/src/modules/application/containers/App/Updaters.tsx (1)

18-18: LGTM! Clean refactoring to move BridgingEnabledUpdater to the bridge module.

The import path update correctly reflects the relocation of BridgingEnabledUpdater from common/updaters to modules/bridge, which improves code organization by grouping bridge-related updaters together.

apps/cowswap-frontend/src/modules/bridge/index.ts (1)

12-12: LGTM! Public API correctly expanded.

The export properly exposes BridgingEnabledUpdater from the bridge module, consistent with the existing pattern for PendingBridgeOrdersUpdater.

apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts (2)

5-5: LGTM! Feature implementation is correct.

The updater now properly respects the disableCrossChainSwap widget parameter:

  • Defaults to false (bridging enabled by default) for backward compatibility
  • Bridging is enabled only when on the SWAP route AND cross-chain swaps are not disabled
  • The logic correctly implements the intended behavior

Also applies to: 13-15


8-8: LGTM! Import path improvement.

Using the centralized routes constant from common/constants/routes instead of a relative path improves maintainability.

libs/widget-lib/src/types.ts (1)

180-180: LGTM! Formatting cleanup.

Removing the trailing semicolon is a style improvement with no semantic impact.

Copy link
Contributor

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

Works, thank you!
Tested with this Json:

{"baseUrl": "https://swap-dev-git-feat-disable-bridge-in-widget-cowswap-dev.vercel.app/",
"disableCrossChainSwap": true}

Comment on lines +261 to +265
/**
* Disables cross-chain swaps (bridging)
* Defaults to false.
*/
disableCrossChainSwap?: boolean
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you!
Added it: cowprotocol/docs#581

@shoom3301 shoom3301 merged commit d1a453f into develop Dec 22, 2025
15 checks passed
@shoom3301 shoom3301 deleted the feat/disable-bridge-in-widget branch December 22, 2025 10:46
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants