diff --git a/package-lock.json b/package-lock.json index 7859b21..c615510 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,8 @@ "@fontsource/space-mono": "^5.2.5", "@graphql-codegen/introspection": "^4.0.3", "@iexec/dataprotector": "^2.0.0-beta.18", - "@iexec/web3mail": "^1.3.1", - "@iexec/web3telegram": "^0.1.0-alpha.2", + "@iexec/web3mail": "^1.4.0", + "@iexec/web3telegram": "^0.1.0-alpha.3", "@radix-ui/react-dialog": "^1.1.6", "@radix-ui/react-label": "^2.1.2", "@radix-ui/react-select": "^2.1.6", @@ -2497,9 +2497,9 @@ } }, "node_modules/@iexec/web3mail": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@iexec/web3mail/-/web3mail-1.3.1.tgz", - "integrity": "sha512-eOqgBTD1u9yUXNRkEHGkzCd8nulGMLYHNLTsCeU6v613NsohE67bj1+Ac/YRtgLuqKtvWcfMJLa/hRfAjbGd4w==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@iexec/web3mail/-/web3mail-1.4.0.tgz", + "integrity": "sha512-lRBstdOBPQXqSuoAIJtoZFgPZXNsusSv1Bk89taZNO3xSE/1Kb8Qa1JCn1rxf/1FHgK4lp73JEzUQ2jlm/rjEA==", "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", @@ -2535,9 +2535,9 @@ } }, "node_modules/@iexec/web3telegram": { - "version": "0.1.0-alpha.2", - "resolved": "https://registry.npmjs.org/@iexec/web3telegram/-/web3telegram-0.1.0-alpha.2.tgz", - "integrity": "sha512-oN8RbukwMONjXxifkIp7X6R1qykEwH4wH8FVw3UfROzdpUJgXs6MocrnC9rxFVxQ2Cc8U9roGRGgtCz5FyPUJA==", + "version": "0.1.0-alpha.3", + "resolved": "https://registry.npmjs.org/@iexec/web3telegram/-/web3telegram-0.1.0-alpha.3.tgz", + "integrity": "sha512-HLWyDmAzyMd5mHlIjKlYYgz9znao/ITMCcrzu2BOSZwD0FHcgjHyOJ0G/qugFH5DdyvEsv4I5igGXgJRCmLOwA==", "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", @@ -12520,9 +12520,9 @@ } }, "node_modules/ora/node_modules/chalk": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", - "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.5.0.tgz", + "integrity": "sha512-1tm8DTaJhPBG3bIkVeZt1iZM9GfSX2lzOeDVZH9R9ffRHpmHvxZ/QhgQH/aDTkswQVt+YHdXAdS/In/30OjCbg==", "license": "MIT", "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" @@ -15007,9 +15007,9 @@ "license": "MIT" }, "node_modules/undici": { - "version": "7.12.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-7.12.0.tgz", - "integrity": "sha512-GrKEsc3ughskmGA9jevVlIOPMiiAHJ4OFUtaAH+NhfTUSiZ1wMPIQqQvAJUrJspFXJt3EBWgpAeoHEDVT1IBug==", + "version": "7.13.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.13.0.tgz", + "integrity": "sha512-l+zSMssRqrzDcb3fjMkjjLGmuiiK2pMIcV++mJaAc9vhjSGpvM7h43QgP+OAMb1GImHmbPyG2tBXeuyG5iY4gA==", "license": "MIT", "peer": true, "engines": { @@ -15881,9 +15881,9 @@ } }, "node_modules/yup": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/yup/-/yup-1.6.1.tgz", - "integrity": "sha512-JED8pB50qbA4FOkDol0bYF/p60qSEDQqBD0/qeIrUCG1KbPBIQ776fCUNb9ldbPcSTxA69g/47XTo4TqWiuXOA==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/yup/-/yup-1.7.0.tgz", + "integrity": "sha512-VJce62dBd+JQvoc+fCVq+KZfPHr+hXaxCcVgotfwWvlR0Ja3ffYKaJBT8rptPOSKOGJDCUnW2C2JWpud7aRP6Q==", "license": "MIT", "dependencies": { "property-expr": "^2.0.5", diff --git a/package.json b/package.json index 168a779..e398b95 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "@fontsource/space-mono": "^5.2.5", "@graphql-codegen/introspection": "^4.0.3", "@iexec/dataprotector": "^2.0.0-beta.18", - "@iexec/web3mail": "^1.3.1", - "@iexec/web3telegram": "^0.1.0-alpha.2", + "@iexec/web3mail": "^1.4.0", + "@iexec/web3telegram": "^0.1.0-alpha.3", "@radix-ui/react-dialog": "^1.1.6", "@radix-ui/react-label": "^2.1.2", "@radix-ui/react-select": "^2.1.6", diff --git a/src/modules/send-message/ContactItem.tsx b/src/modules/send-message/ContactItem.tsx index 9e1ce44..c7bea81 100644 --- a/src/modules/send-message/ContactItem.tsx +++ b/src/modules/send-message/ContactItem.tsx @@ -1,14 +1,7 @@ -import { - WEB3MAIL_IDAPPS_WHITELIST_SC, - WEB3TELEGRAM_IDAPPS_WHITELIST_SC, -} from '@/config/config'; import { Contact as Web3mailContact } from '@iexec/web3mail'; import { Contact as Web3telegramContact } from '@iexec/web3telegram'; -import { useQuery } from '@tanstack/react-query'; import { Link } from 'react-router-dom'; -import { LoadingSpinner } from '@/components/LoadingSpinner'; import { Button } from '@/components/ui/button'; -import { getDataProtectorCoreClient } from '@/externals/iexecSdkClient'; import useUserStore from '@/stores/useUser.store'; import { cn } from '@/utils/style.utils'; @@ -18,63 +11,16 @@ interface ContactItemProps { }; } -const fetchContactDetails = async ( - contact: (Web3telegramContact | Web3mailContact) & { - contactType: 'mail' | 'telegram'; - }, - userAddress: string -) => { - const dataProtectorCore = await getDataProtectorCoreClient(); - - const contactProtectedData = await dataProtectorCore.getProtectedData({ - protectedDataAddress: contact.address, - }); - - const grantedAccess = await dataProtectorCore.getGrantedAccess({ - protectedData: contact.address, - authorizedUser: userAddress, - authorizedApp: - contact.contactType === 'mail' - ? WEB3MAIL_IDAPPS_WHITELIST_SC - : WEB3TELEGRAM_IDAPPS_WHITELIST_SC, - }); - - return { - ...contactProtectedData[0], - contactType: contact.contactType, - volume: grantedAccess.grantedAccess[0].volume, - }; -}; - export default function ContactItem({ contact }: ContactItemProps) { const { address: userAddress } = useUserStore(); - const { - data: contactDetails, - isLoading, - isError, - } = useQuery({ - queryKey: ['contactDetails', contact.address, userAddress], - queryFn: () => fetchContactDetails(contact, userAddress as string), - enabled: !!userAddress, - refetchOnWindowFocus: false, - staleTime: 5 * 60 * 1000, // 5 minutes - }); - - if (isError) { - // TODO: Handle error more gracefully. Do not display error in the UI. - console.error('Error loading contact details:', contact.address); - } - return (
-
- {isLoading ? : contactDetails?.name || '(No name)'} -
+
{contact.name || '(No name)'}
{contact.address}
@@ -86,7 +32,9 @@ export default function ContactItem({ contact }: ContactItemProps) {
- {isLoading ? : contactDetails?.volume || 'N/A'} + {contact.remainingAccess !== undefined + ? contact.remainingAccess + : 'N/A'}
{contact.contactType}