From d83ea3976cd77b292fa5532550b2a6f149e29800 Mon Sep 17 00:00:00 2001 From: Sergej Date: Thu, 11 Apr 2024 09:38:36 +0200 Subject: [PATCH] Fix wallet connect issue --- src/components/Modals/WalletConnect/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/Modals/WalletConnect/index.tsx b/src/components/Modals/WalletConnect/index.tsx index dbca7c32..64e71e4a 100644 --- a/src/components/Modals/WalletConnect/index.tsx +++ b/src/components/Modals/WalletConnect/index.tsx @@ -18,6 +18,7 @@ import Image from 'next/image'; import { useCoretimeApi, useRelayApi } from '@/contexts/apis'; import styles from './index.module.scss'; +import { useEffect, useState } from 'react'; interface WalletModalProps { open: boolean; @@ -25,16 +26,27 @@ interface WalletModalProps { } export const WalletModal = (props: WalletModalProps) => { - const { connect: connectContract, activeChain } = useInkathon(); + const { connect: connectContract, activeChain, isConnected } = useInkathon(); const { connectRelay } = useRelayApi(); const { connectCoretime } = useCoretimeApi(); + + const [wallet, setWallet] = useState(null); + const onConnect = async (wallet: SubstrateWallet) => { + setWallet(wallet); if (!connectContract) return; connectRelay(); connectCoretime(); connectContract(activeChain, wallet); props.onClose(); }; + + useEffect(() => { + if (wallet) { + onConnect(wallet); + } + }, [isConnected]); + return ( Choose your wallet extension