Skip to content

Commit

Permalink
Fix wallet connect issue (#63)
Browse files Browse the repository at this point in the history
* Fix wallet connect issue

* fix imports
  • Loading branch information
Szegoo authored Apr 11, 2024
1 parent 892109e commit e88561b
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 @@ -14,6 +14,7 @@ import {
useInkathon,
} from '@scio-labs/use-inkathon';
import Image from 'next/image';
import { useEffect, useState } from 'react';

import { useCoretimeApi, useRelayApi } from '@/contexts/apis';

Expand All @@ -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<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 e88561b

Please sign in to comment.