Skip to content

Commit

Permalink
Fix wallet connect issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Apr 11, 2024
1 parent 892109e commit d83ea39
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/Modals/WalletConnect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,35 @@ 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;
onClose: () => void;
}

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<SubstrateWallet | null>(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 (
<Dialog {...props} fullWidth maxWidth='sm'>
<DialogTitle>Choose your wallet extension</DialogTitle>
Expand Down

0 comments on commit d83ea39

Please sign in to comment.