From ab0c097dcbcc3dc81345e9c9c957f8726d2b62c9 Mon Sep 17 00:00:00 2001 From: imhson Date: Thu, 8 Aug 2024 17:31:56 +0700 Subject: [PATCH] fix bug --- src/components/Modal/ConnectWalletModal.tsx | 6 ++++-- src/context/index.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Modal/ConnectWalletModal.tsx b/src/components/Modal/ConnectWalletModal.tsx index 15070089..1cb4ade9 100644 --- a/src/components/Modal/ConnectWalletModal.tsx +++ b/src/components/Modal/ConnectWalletModal.tsx @@ -10,7 +10,7 @@ import { sepolia } from 'viem/chains' import { Connector, useConnect, useDisconnect } from 'wagmi' export default function ConnectWalletModal() { const { connectWalletOpen: show } = useContext(ModalContext) - const { connectHandler } = useContext(Context) + const { connectHandler, account } = useContext(Context) const { connectors, connectAsync: wagmiConnect } = useConnect() const { disconnect: wagmiDisconnect, disconnectAsync } = useDisconnect() const [installed, setInstalled] = useState([]) @@ -96,7 +96,9 @@ export default function ConnectWalletModal() { { onSuccess: (data) => { setLoading(false) - connectHandler(data) + if (data?.accounts[0] == account?.activeWalletAddress) { + connectHandler(data) + } }, onError: (props) => { diff --git a/src/context/index.tsx b/src/context/index.tsx index bb07f99f..5c1c3ca0 100644 --- a/src/context/index.tsx +++ b/src/context/index.tsx @@ -153,7 +153,7 @@ function ContextProvider({ children }: any) { chainId: config.CHAIN_INFO.evmChainId, }, { - onSuccess: signConnectMessage, + onSuccess: () => signConnectMessage(data), onError: (error) => console.error(error), } )