Skip to content

Commit 00c1f69

Browse files
authored
fix(bridge): allow bridging when wallet not connected (#6281)
1 parent 8dc8aed commit 00c1f69

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
import { useEffect } from 'react'
22

33
import { useFeatureFlags, useSetIsBridgingEnabled } from '@cowprotocol/common-hooks'
4-
import { useIsSmartContractWallet } from '@cowprotocol/wallet'
4+
import { useIsSmartContractWallet, useWalletInfo } from '@cowprotocol/wallet'
55

66
import { useTradeTypeInfo } from 'modules/trade'
77

88
import { Routes } from '../constants/routes'
99

1010
export function BridgingEnabledUpdater(): null {
11+
const { account } = useWalletInfo()
1112
const { isBridgingEnabled } = useFeatureFlags()
1213
const tradeTypeInfo = useTradeTypeInfo()
1314
const isSmartContractWallet = useIsSmartContractWallet()
1415
const setIsBridgingEnabled = useSetIsBridgingEnabled()
1516

1617
const isSwapRoute = tradeTypeInfo?.route === Routes.SWAP
1718

18-
function shouldEnableBridging(
19-
featureFlagEnabled: boolean,
20-
scWallet: boolean | undefined,
21-
swapRoute: boolean,
22-
): boolean {
23-
// Only enable bridging once we definitively know it's an EOA (strict false)
24-
return featureFlagEnabled && scWallet === false && swapRoute
25-
}
19+
const isWalletCompatible = Boolean(account ? isSmartContractWallet === false : true)
20+
const shouldEnableBridging = isBridgingEnabled && isWalletCompatible && isSwapRoute
2621

2722
useEffect(() => {
28-
setIsBridgingEnabled(shouldEnableBridging(isBridgingEnabled, isSmartContractWallet, isSwapRoute))
29-
}, [setIsBridgingEnabled, isBridgingEnabled, isSmartContractWallet, isSwapRoute])
23+
setIsBridgingEnabled(shouldEnableBridging)
24+
}, [setIsBridgingEnabled, shouldEnableBridging])
3025

3126
return null
3227
}

0 commit comments

Comments
 (0)