Skip to content

Commit

Permalink
fix: deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Sep 3, 2023
1 parent 746a162 commit 9d97b32
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/contexts/useWeb3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {useAccount, useConnect, useDisconnect, useEnsName, useNetwork, usePublic
import {useIsMounted, useUpdateEffect} from '@react-hookz/web';
import {EthereumClient} from '@web3modal/ethereum';
import {Web3Modal} from '@web3modal/react';
import {useConnectModal} from '@rainbow-me/rainbowkit';

import {toAddress} from '../utils/address';
import {getConfig, getSupportedProviders} from '../utils/wagmi/config';
Expand All @@ -16,7 +17,6 @@ import type {Config, PublicClient, WebSocketPublicClient} from 'wagmi';
import type {TWeb3Context, TWeb3Options} from '../types/contexts';
import type {Chain} from '@wagmi/core';
import {toast} from '../components/yToast';
import { useConnectModal } from '@rainbow-me/rainbowkit';

const defaultState = {
address: undefined,
Expand Down Expand Up @@ -55,6 +55,7 @@ export const Web3ContextAppWrapper = ({children, options}: {children: ReactEleme
const publicClient = usePublicClient();
const isMounted = useIsMounted();
const web3Options = deepMerge(defaultOptions, options) as TWeb3Options;
const {openConnectModal} = useConnectModal()

const supportedChainsID = useMemo((): number[] => {
const injectedConnector = connectors.find((e): boolean => (e.id).toLocaleLowerCase() === 'injected');
Expand All @@ -69,12 +70,12 @@ export const Web3ContextAppWrapper = ({children, options}: {children: ReactEleme
}, [chain]);

const onConnect = useCallback(async (): Promise<void> => {
if (useConnectModal) {
useConnectModal();
if (openConnectModal) {
openConnectModal();
} else {
toast({type: 'warning', content: 'Impossible to open login modal'})
}
}, [useConnectModal]);
}, [openConnectModal]);

const onDesactivate = useCallback((): void => {
disconnect();
Expand All @@ -91,12 +92,12 @@ export const Web3ContextAppWrapper = ({children, options}: {children: ReactEleme
}, [switchNetwork, isConnected]);

const openLoginModal = useCallback(async (): Promise<void> => {
if (useConnectModal) {
useConnectModal();
if (openConnectModal) {
openConnectModal();
} else {
toast({type: 'warning', content: 'Impossible to open login modal'})
}
}, [useConnectModal]);
}, [openConnectModal]);

const contextValue = {
address: address ? toAddress(address) : undefined,
Expand Down

0 comments on commit 9d97b32

Please sign in to comment.