import React, { useEffect, useState, useCallback } from 'react'; import Typography from '../../components/ui/Typography'; import { Button } from '../../components/ui/Button'; import { useWalletStore } from '../../stores/walletStore'; import { useConfigStore } from '../../stores/configStore'; import { Logger } from '@hashgraphonline/standards-sdk'; interface WalletSettingsProps {} /** * Wallet settings panel for connecting HashPack via WalletConnect. */ export const WalletSettings: React.FC = () => { const { isConnected, isInitializing, error, accountId, network, balance, connect, disconnect, refreshBalance, } = useWalletStore(); const appNet = useConfigStore((s) => s.config?.hedera?.network || 'testnet'); const mismatched = isConnected && network !== appNet; const [projectId, setProjectId] = useState(''); useEffect(() => { let mounted = true; window.electron .getEnvironmentConfig() .then((envCfg: any) => { if (!mounted) return; const id = envCfg?.walletConnect?.projectId ? String(envCfg.walletConnect.projectId) : ''; setProjectId(id.trim()); }) .catch(() => { setProjectId(''); }); return () => { mounted = false; }; }, []); return (
Wallet Connect HashPack via WalletConnect to approve transactions without storing private keys locally.
{isConnected ? ( ) : ( )} {isConnected ? ( ) : null}
{!projectId && !isConnected && !isInitializing && ( WalletConnect project ID is not set. Add WALLETCONNECT_PROJECT_ID to your environment to enable connection. )} {error ? ( {error} ) : null}
Status {isConnected ? 'Connected' : 'Disconnected'}
Account {accountId || '—'}
Network {network} {mismatched ? ( Wallet network differs from app network ({appNet}). Update one before approving. ) : null}
Balance (HBAR) {balance ?? '—'}
); }; export default WalletSettings;