Fix window ethereum (#89)

This commit is contained in:
Szymon Szlachtowicz 2021-09-23 11:20:08 +02:00 committed by GitHub
parent 02aa702bca
commit 02f2634bae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -43,7 +43,7 @@ export function WakuPolling({ appName, signer, theme }: WakuPollingProps) {
<CreateButton <CreateButton
theme={theme} theme={theme}
onClick={() => { onClick={() => {
if ((window as any).ethereum) { if ((window as any)?.ethereum) {
activateBrowserWallet() activateBrowserWallet()
} else setSelectConnect(true) } else setSelectConnect(true)
}} }}

View File

@ -31,7 +31,7 @@ function ProposalListHeader({ votesLength, theme, wakuVoting, tokenBalance, acco
}, [mobileVersion]) }, [mobileVersion])
const onConnectClick = useCallback(() => { const onConnectClick = useCallback(() => {
if ((window as any).ethereum) { if ((window as any)?.ethereum) {
activateBrowserWallet() activateBrowserWallet()
} else setShowConnectionModal(true) } else setShowConnectionModal(true)
}, []) }, [])

View File

@ -18,8 +18,8 @@ export function useWakuProposal(
const network = await provider?.getNetwork() const network = await provider?.getNetwork()
setChainId(network?.chainId ?? 0) setChainId(network?.chainId ?? 0)
} }
;(window as any).ethereum.on('chainChanged', updateChainId) ;(window as any)?.ethereum?.on('chainChanged', updateChainId)
return () => (window as any).ethereum.removeListener('chainChanged', updateChainId) return () => (window as any)?.ethereum?.removeListener('chainChanged', updateChainId)
}, []) }, [])
useEffect(() => { useEffect(() => {

View File

@ -48,7 +48,7 @@ export function TopBar({ logo, title, theme, activate, deactivate, account }: To
<ConnectButton <ConnectButton
theme={theme} theme={theme}
onClick={() => { onClick={() => {
if ((window as any).ethereum) { if ((window as any)?.ethereum) {
activate() activate()
} else setSelectConnect(true) } else setSelectConnect(true)
}} }}