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
theme={theme}
onClick={() => {
if ((window as any).ethereum) {
if ((window as any)?.ethereum) {
activateBrowserWallet()
} else setSelectConnect(true)
}}

View File

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

View File

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

View File

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