Skip to content

Commit 9a60a15

Browse files
refactor: remove provider from wallet info
1 parent 3eee6e7 commit 9a60a15

4 files changed

Lines changed: 5 additions & 28 deletions

File tree

libs/wallet/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"@cowprotocol/iframe-transport": "workspace:*",
4242
"@cowprotocol/types": "workspace:*",
4343
"@cowprotocol/ui": "workspace:*",
44-
"@cowprotocol/wallet-provider": "workspace:*",
4544
"@ethereumjs/util": "10.1.0",
4645
"@metamask/jazzicon": "2.0.0",
4746
"@metamask/sdk": "0.31.4",

libs/wallet/src/api/types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { SupportedChainId } from '@cowprotocol/cow-sdk'
2-
import { WidgetEthereumProvider } from '@cowprotocol/iframe-transport'
32
import type { SafeInfoResponse } from '@safe-global/api-kit'
43

5-
import { EIP1193Provider, PublicClient } from 'viem'
64
import { Connector as WagmiConnector } from 'wagmi'
75
import { injected, walletConnect, coinbaseWallet, safe } from 'wagmi/connectors'
86

@@ -20,8 +18,6 @@ export interface WalletInfo {
2018
account?: string
2119
active?: boolean
2220
connector?: WagmiConnector
23-
provider?: EIP1193Provider | WidgetEthereumProvider | PublicClient
24-
isConnectionRestoring?: boolean
2521
}
2622

2723
export interface WalletDetails {

libs/wallet/src/wagmi/updater.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { getCurrentChainIdFromUrl, getRawCurrentChainIdFromUrl, logSafeApi } fro
55
import { getSafeInfo, normalizeSafeError, SAFE_RATE_LIMIT_MSG } from '@cowprotocol/core'
66
import { SupportedChainId } from '@cowprotocol/cow-sdk'
77
import { AccountType } from '@cowprotocol/types'
8-
import { useWalletProvider } from '@cowprotocol/wallet-provider'
98
import type { SafeInfoResponse } from '@safe-global/api-kit'
109
import type { SafeInfoExtended } from '@safe-global/safe-apps-sdk'
1110

@@ -46,8 +45,7 @@ function useBrowserUrlKey(): string {
4645
function useWalletInfo(): WalletInfo {
4746
// TODO: Replace urlKey with locationNetworkAtom, which will also trigger the useMemo below less often.
4847
const urlKey = useBrowserUrlKey()
49-
const { address, chainId, isConnected, status, connector } = useAccountState()
50-
const isConnectionRestoring = status === 'reconnecting'
48+
const { address, chainId, isConnected, connector } = useAccountState()
5149
const isChainIdUnsupported = !!chainId && !(chainId in SupportedChainId)
5250
const [lastStableChainId, setLastStableChainId] = useState<SupportedChainId | undefined>(undefined)
5351
const [lastResolvedChainId, setLastResolvedChainId] = useState<SupportedChainId>(() => getCurrentChainIdFromUrl())
@@ -83,19 +81,8 @@ function useWalletInfo(): WalletInfo {
8381
active: isConnected,
8482
account: address,
8583
connector,
86-
isConnectionRestoring,
8784
}
88-
}, [
89-
address,
90-
chainId,
91-
isConnected,
92-
connector,
93-
isChainIdUnsupported,
94-
isConnectionRestoring,
95-
lastStableChainId,
96-
lastResolvedChainId,
97-
urlKey,
98-
])
85+
}, [address, chainId, isConnected, connector, isChainIdUnsupported, lastStableChainId, lastResolvedChainId, urlKey])
9986

10087
useEffect(() => {
10188
setLastResolvedChainId(walletInfo.chainId)
@@ -140,7 +127,7 @@ let shortSafeInfoInterval: ReturnType<typeof setInterval> | null = null
140127
let longSafeInfoInterval: ReturnType<typeof setInterval> | null = null
141128

142129
export function WalletUpdater(): null {
143-
const { chainId, active, account, connector, isConnectionRestoring } = useWalletInfo()
130+
const { chainId, active, account, connector } = useWalletInfo()
144131

145132
const walletDetails = useWalletDetails(account)
146133
const gnosisSafeInfo = useSafeInfo()
@@ -149,11 +136,9 @@ export function WalletUpdater(): null {
149136
const setWalletDetails = useSetAtom(walletDetailsAtom)
150137
const setGnosisSafeInfo = useSetAtom(gnosisSafeInfoAtom)
151138

152-
const provider = useWalletProvider()
153-
154139
useEffect(() => {
155-
setWalletInfo({ chainId, active, account, connector, isConnectionRestoring, provider })
156-
}, [chainId, active, account, connector, isConnectionRestoring, provider, setWalletInfo])
140+
setWalletInfo({ chainId, active, account, connector })
141+
}, [chainId, active, account, connector, setWalletInfo])
157142

158143
useEffect(() => {
159144
const walletType = getWalletType({ gnosisSafeInfo, isSmartContractWallet: walletDetails.isSmartContractWallet })

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)