11import { useEffect , useState } from 'react' ;
22import { useAccount , useConnect , useChains } from 'wagmi' ;
3- import { EmbeddedWallet } from '@apillon/wallet-react ' ;
4- import { useWallet } from '@apillon/wallet-react' ;
3+ import { type Network } from '@apillon/wallet-sdk ' ;
4+ import { EmbeddedWallet , useWallet } from '@apillon/wallet-react' ;
55import { useWalletConnect } from '../hooks/useWalletConnect' ;
66import { EMBEDDED_WALLET_CLIENT } from '../lib/config' ;
77import { shortHash } from '../lib/strings' ;
@@ -22,9 +22,9 @@ export default function WalletConnect() {
2222 const networks = chains . map ( ( chain ) => ( {
2323 name : chain . name ,
2424 id : chain . id ,
25- rpcUrl : chain . rpcUrls . default . http [ 0 ] ,
26- explorerUrl : chain . blockExplorers ?. default ?. url ,
27- } ) ) ;
25+ rpcUrl : chain . rpcUrls . default . http [ 0 ] || '' ,
26+ explorerUrl : chain . blockExplorers ?. default ?. url || '' ,
27+ } as Network ) ) ;
2828
2929 function openModal ( ) {
3030 scrollLock . enable ( ) ;
@@ -53,6 +53,14 @@ export default function WalletConnect() {
5353 setConnectorName ( conn . name ) ;
5454 connect ( { connector : conn } ) ;
5555 } ;
56+
57+ const disconnect = ( ) => {
58+ if ( isConnected ) {
59+ disconnectWallet ( ) ;
60+ } else if ( wallet ) {
61+ wallet . events . emit ( 'open' , true ) ;
62+ }
63+ }
5664
5765 useEffect ( ( ) => {
5866 if ( isConnected ) closeWallet ( ) ;
@@ -68,7 +76,7 @@ export default function WalletConnect() {
6876 variant = 'secondary'
6977 disabled = { false }
7078 loading = { false }
71- onClick = { ( ) => disconnectWallet ( ) }
79+ onClick = { ( ) => disconnect ( ) }
7280 >
7381 Disconnect
7482 </ Btn >
0 commit comments