Skip to content

Commit 42e0a70

Browse files
committed
fix: attemps to remove reown if flag is not on
1 parent 253bddf commit 42e0a70

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

apps/cowswap-frontend/src/legacy/state/application/hooks.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { useCallback } from 'react'
22

3-
import { LAUNCH_DARKLY_VIEM_MIGRATION } from '@cowprotocol/common-const'
43
import { Command } from '@cowprotocol/types'
54

65
import { createAction } from '@reduxjs/toolkit'
7-
import { useAppKit } from '@reown/appkit/react'
86

97
import { ApplicationModal } from './reducer'
108

@@ -30,12 +28,14 @@ export function useCloseModal(_modal: ApplicationModal): Command {
3028
}
3129

3230
export function useToggleWalletModal(): Command {
33-
const { open } = useAppKit()
31+
// TODO M-7 COW-572
32+
// Readd this
33+
// const { open } = useAppKit()
3434
const toggleModal = useToggleModal(ApplicationModal.WALLET)
3535

36-
if (LAUNCH_DARKLY_VIEM_MIGRATION) {
37-
return () => open()
38-
}
36+
// if (LAUNCH_DARKLY_VIEM_MIGRATION) {
37+
// return () => open()
38+
// }
3939

4040
return toggleModal
4141
}

apps/cowswap-frontend/src/legacy/state/user/hooks.tsx

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

33
import { NATIVE_CURRENCIES, SupportedLocale, TokenWithLogo } from '@cowprotocol/common-const'
44
import { getIsNativeToken } from '@cowprotocol/common-utils'
55
import { SupportedChainId } from '@cowprotocol/cow-sdk'
66
import { Command } from '@cowprotocol/types'
77
import { Currency } from '@uniswap/sdk-core'
88

9-
import { useAppKitTheme } from '@reown/appkit/react'
109
import { shallowEqual } from 'react-redux'
1110

1211
import { updateHooksEnabled, updateUserDarkMode, updateUserLocale } from './reducer'
@@ -28,12 +27,14 @@ export function useIsDarkMode(): boolean {
2827

2928
export function useDarkModeManager(): [boolean, Command] {
3029
const dispatch = useAppDispatch()
31-
const { setThemeMode } = useAppKitTheme()
30+
// TODO M-7 COW-572
31+
// Readd this
32+
// const { setThemeMode } = useAppKitTheme()
3233
const darkMode = useIsDarkMode()
3334

34-
useEffect(() => {
35-
setThemeMode(darkMode ? 'dark' : 'light')
36-
}, [darkMode, setThemeMode])
35+
// useEffect(() => {
36+
// setThemeMode(darkMode ? 'dark' : 'light')
37+
// }, [darkMode, setThemeMode])
3738

3839
const toggleSetDarkMode = useCallback(() => {
3940
dispatch(updateUserDarkMode({ userDarkMode: !darkMode }))

libs/wallet/src/wagmi/Web3Provider.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { ReactNode } from 'react'
1+
import { ReactNode, useEffect } from 'react'
22

3+
import { LAUNCH_DARKLY_VIEM_MIGRATION } from '@cowprotocol/common-const'
34
import { SafeProvider } from '@safe-global/safe-apps-react-sdk'
45

6+
import { createAppKit } from '@reown/appkit/react'
57
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
68
import { WagmiProvider } from 'wagmi'
79

8-
import { wagmiAdapter } from './config'
10+
import { appKitParams, wagmiAdapter } from './config'
911

1012
const queryClient = new QueryClient()
1113

@@ -14,6 +16,19 @@ interface Web3ProviderProps {
1416
}
1517

1618
export function Web3Provider({ children }: Web3ProviderProps): React.ReactNode {
19+
useEffect(() => {
20+
if (LAUNCH_DARKLY_VIEM_MIGRATION) {
21+
// TODO M-7 COW-572
22+
// This will be moved back to config file on cleanup
23+
const appKit = createAppKit(appKitParams)
24+
25+
appKit.updateFeatures({
26+
connectorTypeOrder: ['recent', 'injected', 'featured', 'custom', 'external', 'recommended', 'walletConnect'],
27+
})
28+
appKit.close
29+
}
30+
}, [])
31+
1732
return (
1833
<WagmiProvider config={wagmiAdapter.wagmiConfig}>
1934
<QueryClientProvider client={queryClient}>

libs/wallet/src/wagmi/config.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LAUNCH_DARKLY_VIEM_MIGRATION, RPC_URLS } from '@cowprotocol/common-const'
22
import { SupportedChainId } from '@cowprotocol/cow-sdk'
33

4-
import { createAppKit } from '@reown/appkit/react'
4+
import { CreateAppKit } from '@reown/appkit/react'
55
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'
66
import { Chain, http } from 'viem'
77
import {
@@ -62,7 +62,7 @@ export const wagmiAdapter = new WagmiAdapter({
6262
projectId,
6363
})
6464

65-
const appKit = createAppKit({
65+
export const appKitParams: CreateAppKit = {
6666
adapters: [wagmiAdapter],
6767
// TODO M-7 COW-572
6868
// this will become false once the feature flag is removed
@@ -72,7 +72,6 @@ const appKit = createAppKit({
7272
enableWalletGuide: false,
7373
featuredWalletIds: [
7474
'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', // metamask
75-
'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393', // phantom
7675
'18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1', // rabby
7776
'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', // coinbase
7877
],
@@ -86,8 +85,4 @@ const appKit = createAppKit({
8685
projectId,
8786
termsConditionsUrl:
8887
'https://cow.fi/legal/cowswap-terms?utm_source=swap.cow.fi&utm_medium=web&utm_content=wallet-modal-terms-link',
89-
})
90-
91-
appKit.updateFeatures({
92-
connectorTypeOrder: ['recent', 'injected', 'featured', 'custom', 'external', 'recommended', 'walletConnect'],
93-
})
88+
}

0 commit comments

Comments
 (0)