import React, { useEffect } from 'react'; import { Image, TouchableOpacity, View } from 'react-native'; import { List, Text } from 'react-native-paper'; import { getSdkError } from '@walletconnect/utils'; import { useWalletConnect } from '../context/WalletConnectContext'; import { web3wallet } from '../utils/wallet-connect/WalletConnectUtils'; import styles from '../styles/stylesheet'; export default function WalletConnect() { const { activeSessions, setActiveSessions } = useWalletConnect(); const disconnect = async (sessionId: string) => { await web3wallet.disconnectSession({ topic: sessionId, reason: getSdkError('USER_DISCONNECTED'), }); const sessions = await web3wallet?.getActiveSessions(); setActiveSessions(sessions); return; }; useEffect(() => { const sessions = web3wallet.getActiveSessions(); setActiveSessions(sessions); }, []); return ( {Object.keys(activeSessions).length > 0 ? ( <> Active Sessions {Object.entries(activeSessions).map( ([sessionId, session], index) => ( ( )} right={() => ( disconnect(sessionId)} style={{ display: 'flex', justifyContent: 'center' }}> )} /> ), )} ) : ( You have no active sessions )} ); }