Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TradingSdkUpdater } from 'tradingSdk/TradingSdkUpdater'

import { UploadToIpfsUpdater } from 'modules/appData/updater/UploadToIpfsUpdater'
import { CommonPriorityBalancesAndAllowancesUpdater } from 'modules/balancesAndAllowances'
import { PendingBridgeOrdersUpdater } from 'modules/bridge'
import { PendingBridgeOrdersUpdater, BridgingEnabledUpdater } from 'modules/bridge'
import { BalancesCombinedUpdater } from 'modules/combinedBalances/updater/BalancesCombinedUpdater'
import { InFlightOrderFinalizeUpdater } from 'modules/ethFlow'
import { CowEventsUpdater, InjectedWidgetUpdater, useInjectedWidgetParams } from 'modules/injectedWidget'
Expand All @@ -33,7 +33,6 @@ import { LpTokensWithBalancesUpdater, PoolsInfoUpdater, VampireAttackUpdater } f

import { TotalSurplusUpdater } from 'common/state/totalSurplusState'
import { AnnouncementsUpdater } from 'common/updaters/AnnouncementsUpdater'
import { BridgingEnabledUpdater } from 'common/updaters/BridgingEnabledUpdater'
import { ConnectionStatusUpdater } from 'common/updaters/ConnectionStatusUpdater'
import { FeatureFlagsUpdater } from 'common/updaters/FeatureFlagsUpdater'
import { GasUpdater } from 'common/updaters/GasUpdater'
Expand Down
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/modules/bridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {
} from './pure/StopStatus'

export { PendingBridgeOrdersUpdater } from './updaters/PendingBridgeOrdersUpdater'
export { BridgingEnabledUpdater } from './updaters/BridgingEnabledUpdater'
export { QuoteDetails } from './pure/QuoteDetails'
export { ProgressDetails } from './pure/ProgressDetails'
export { BridgeAccordionSummary } from './pure/BridgeAccordionSummary'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useEffect } from 'react'

import { useSetIsBridgingEnabled } from '@cowprotocol/common-hooks'

import { useInjectedWidgetParams } from 'modules/injectedWidget'
import { useTradeTypeInfo } from 'modules/trade'

import { Routes } from '../constants/routes'
import { Routes } from 'common/constants/routes'

export function BridgingEnabledUpdater(): null {
const tradeTypeInfo = useTradeTypeInfo()
const setIsBridgingEnabled = useSetIsBridgingEnabled()
const { disableCrossChainSwap = false } = useInjectedWidgetParams()

const shouldEnableBridging = tradeTypeInfo?.route === Routes.SWAP
const shouldEnableBridging = tradeTypeInfo?.route === Routes.SWAP && !disableCrossChainSwap

useEffect(() => {
setIsBridgingEnabled(shouldEnableBridging)
Expand Down
7 changes: 6 additions & 1 deletion libs/widget-lib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export interface SlippageConfig {
defaultValue?: number
}

export type FlexibleSlippageConfig = FlexibleConfig<SlippageConfig>;
export type FlexibleSlippageConfig = FlexibleConfig<SlippageConfig>

export interface CowSwapWidgetParams {
/**
Expand Down Expand Up @@ -258,6 +258,11 @@ export interface CowSwapWidgetParams {
*/
partnerFee?: PartnerFee

/**
* Disables cross-chain swaps (bridging)
* Defaults to false.
*/
disableCrossChainSwap?: boolean
Comment on lines +261 to +265
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

/**
* Disables showing the confirmation modal you get after posting an order.
* Defaults to false.
Expand Down