import ProjectInfoCard from '@/components/ProjectInfoCard' import ProposalSelectSection from '@/components/ProposalSelectSection' import RequestModalContainer from '@/components/RequestModalContainer' import ModalStore from '@/store/ModalStore' import { eip155Addresses } from '@/utils/EIP155WalletUtil' import { isEIP155Chain } from '@/utils/HelperUtil' import { legacySignClient } from '@/utils/LegacyWalletConnectUtil' import { Button, Divider, Modal, Text } from '@nextui-org/react' import { getSdkError } from '@walletconnect/utils' import { Fragment, useState } from 'react' export default function LegacySessionProposalModal() { const [selectedAccounts, setSelectedAccounts] = useState>({}) const hasSelected = Object.keys(selectedAccounts).length // Get proposal data and wallet address from store const proposal = ModalStore.state.data?.legacyProposal // Ensure proposal is defined if (!proposal) { return Missing proposal data } // Get required proposal data const { id, params } = proposal const [{ chainId, peerMeta }] = params // Add / remove address from EIP155 selection function onSelectAccount(chain: string, account: string) { if (selectedAccounts[chain]?.includes(account)) { const newSelectedAccounts = selectedAccounts[chain]?.filter(a => a !== account) setSelectedAccounts(prev => ({ ...prev, [chain]: newSelectedAccounts })) } else { const prevChainAddresses = selectedAccounts[chain] ?? [] setSelectedAccounts(prev => ({ ...prev, [chain]: [...prevChainAddresses, account] })) } } // Hanlde approve action, construct session namespace async function onApprove() { if (proposal) { legacySignClient.approveSession({ accounts: selectedAccounts['eip155'], chainId: chainId ?? 1 }) } ModalStore.close() } // Handle reject action function onReject() { if (proposal) { legacySignClient.rejectSession(getSdkError('USER_REJECTED_METHODS')) } ModalStore.close() } // Render account selection checkboxes based on chain function renderAccountSelection(chain: string) { if (isEIP155Chain(chain)) { return ( ) } } return ( {renderAccountSelection('eip155')} ) }