From b2fafac17a0d1f7a635a4874c065b8b96f9ed16c Mon Sep 17 00:00:00 2001 From: storywithoutend Date: Wed, 21 Aug 2024 04:29:18 +0900 Subject: [PATCH 1/4] update for new credential changes --- e2e/specs/stateless/verifications.spec.ts | 13 +++++++++++-- .../utils/parseVerifiedCredential.test.ts | 2 +- .../utils/parseVerifiedCredential.ts | 7 ++++++- test/mock/makeMockVerifiablePresentationData.ts | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/e2e/specs/stateless/verifications.spec.ts b/e2e/specs/stateless/verifications.spec.ts index 504ae9443..706bb1848 100644 --- a/e2e/specs/stateless/verifications.spec.ts +++ b/e2e/specs/stateless/verifications.spec.ts @@ -17,7 +17,9 @@ import { createAccounts } from '../../../playwright/fixtures/accounts' import { testClient } from '../../../playwright/fixtures/contracts/utils/addTestContracts' const makeMockVPToken = ( - records: Array<'com.twitter' | 'com.github' | 'com.discord' | 'org.telegram' | 'personhood'>, + records: Array< + 'com.twitter' | 'com.github' | 'com.discord' | 'org.telegram' | 'personhood' | 'email' + >, ) => { return records.map((record) => ({ type: [ @@ -27,7 +29,8 @@ const makeMockVPToken = ( 'com.github': 'VerifiedGithubAccount', 'com.discord': 'VerifiedDiscordAccount', 'org.telegram': 'VerifiedTelegramAccount', - personhood: 'VerifiedIdentity', + personhood: 'VerifiedPersonhood', + email: 'VerifiedEmail', }[record], ], credentialSubject: { @@ -36,6 +39,7 @@ const makeMockVPToken = ( ...(['com.twitter', 'com.github', 'com.discord', 'org.telegram'].includes(record) ? { name: 'name' } : {}), + ...(record === 'email' ? { verifiedEmail: 'name@email.com' } : {}), }, })) } @@ -64,6 +68,10 @@ test.describe('Verified records', () => { key: 'com.github', value: 'name', }, + { + key: 'email', + value: 'name@email.com', + }, { key: VERIFICATION_RECORD_KEY, value: JSON.stringify([ @@ -91,6 +99,7 @@ test.describe('Verified records', () => { 'com.discord', 'org.telegram', 'personhood', + 'email', ]), }), }) diff --git a/src/hooks/verification/useVerifiedRecords/utils/parseVerifiedCredential.test.ts b/src/hooks/verification/useVerifiedRecords/utils/parseVerifiedCredential.test.ts index 60cbf5471..9084593cf 100644 --- a/src/hooks/verification/useVerifiedRecords/utils/parseVerifiedCredential.test.ts +++ b/src/hooks/verification/useVerifiedRecords/utils/parseVerifiedCredential.test.ts @@ -76,7 +76,7 @@ describe('parseVerifiedCredential', () => { it('should parse personhood verified credential', async () => { expect( await parseVerifiableCredential({ - type: ['VerifiedIdentity'], + type: ['VerifiedPersonhood'], credentialSubject: { name: 'name' }, } as any), ).toEqual({ diff --git a/src/hooks/verification/useVerifiedRecords/utils/parseVerifiedCredential.ts b/src/hooks/verification/useVerifiedRecords/utils/parseVerifiedCredential.ts index 8ae383371..ff3236036 100644 --- a/src/hooks/verification/useVerifiedRecords/utils/parseVerifiedCredential.ts +++ b/src/hooks/verification/useVerifiedRecords/utils/parseVerifiedCredential.ts @@ -35,7 +35,7 @@ export const parseVerifiableCredential = async ( key: 'com.github', value: vc?.credentialSubject?.name || '', })) - .with({ type: P.when((type) => type?.includes('VerifiedIdentity')) }, () => ({ + .with({ type: P.when((type) => type?.includes('VerifiedPersonhood')) }, () => ({ issuer: 'dentity', key: 'personhood', value: '', @@ -45,6 +45,11 @@ export const parseVerifiableCredential = async ( key: 'org.telegram', value: vc?.credentialSubject?.name || '', })) + .with({ type: P.when((type) => type?.includes('VerifiedEmail')) }, (vc) => ({ + issuer: 'dentity', + key: 'email', + value: vc?.credentialSubject?.verifiedEmail || '', + })) .otherwise(() => null) if (!baseResult) return null diff --git a/test/mock/makeMockVerifiablePresentationData.ts b/test/mock/makeMockVerifiablePresentationData.ts index f52a8a0bf..61da73a43 100644 --- a/test/mock/makeMockVerifiablePresentationData.ts +++ b/test/mock/makeMockVerifiablePresentationData.ts @@ -59,7 +59,7 @@ export const makeMockVerifiablePresentationData = (type: MakeMockVerifiablePrese }, ], id: 'urn:vc', - type: ['VerifiedIdentity', 'VerifiableCredential'], + type: ['VerifiedPersonhood', 'VerifiableCredential'], credentialSchema: { id: 'https://schema.trinsic.cloud/dentity-staging/verified-identity', type: 'JsonSchemaValidator2018', From a4c094452569070e0e34ea37580322adef28881f Mon Sep 17 00:00:00 2001 From: storywithoutend Date: Wed, 21 Aug 2024 10:11:55 +0900 Subject: [PATCH 2/4] remove params not needed on useVerifiedRecords --- src/components/pages/profile/[name]/tabs/ProfileTab.tsx | 2 -- .../verification/useVerifiedRecords/useVerifiedRecords.ts | 4 +--- .../input/VerifyProfile/VerifyProfile-flow.tsx | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/pages/profile/[name]/tabs/ProfileTab.tsx b/src/components/pages/profile/[name]/tabs/ProfileTab.tsx index 74f44b0ab..0f75b4be3 100644 --- a/src/components/pages/profile/[name]/tabs/ProfileTab.tsx +++ b/src/components/pages/profile/[name]/tabs/ProfileTab.tsx @@ -78,8 +78,6 @@ const ProfileTab = ({ nameDetails, name }: Props) => { }) const { data: verifiedData, appendVerificationProps } = useVerifiedRecords({ - name: normalisedName, - address: owners?.find(({ label }) => ['name.owner', 'name.dnsOwner'].includes(label))?.address, verificationsRecord: profile?.texts?.find(({ key }) => key === VERIFICATION_RECORD_KEY)?.value, }) diff --git a/src/hooks/verification/useVerifiedRecords/useVerifiedRecords.ts b/src/hooks/verification/useVerifiedRecords/useVerifiedRecords.ts index 297c6e52f..5caac58ac 100644 --- a/src/hooks/verification/useVerifiedRecords/useVerifiedRecords.ts +++ b/src/hooks/verification/useVerifiedRecords/useVerifiedRecords.ts @@ -13,8 +13,6 @@ import { } from './utils/parseVerificationData/parseVerificationData' type UseVerifiedRecordsParameters = { - name?: string - address?: string verificationsRecord?: string } @@ -76,7 +74,7 @@ export const useVerifiedRecords = const preparedOptions = prepareQueryOptions({ queryKey: initialOptions.queryKey, queryFn: initialOptions.queryFn, - enabled: enabled && !!params.name && !!params.address && !!params.verificationsRecord, + enabled: enabled && !!params.verificationsRecord, gcTime, staleTime, }) diff --git a/src/transaction-flow/input/VerifyProfile/VerifyProfile-flow.tsx b/src/transaction-flow/input/VerifyProfile/VerifyProfile-flow.tsx index 29ad14bfd..49bc388f3 100644 --- a/src/transaction-flow/input/VerifyProfile/VerifyProfile-flow.tsx +++ b/src/transaction-flow/input/VerifyProfile/VerifyProfile-flow.tsx @@ -30,8 +30,6 @@ const VerifyProfile = ({ data: { name }, dispatch, onDismiss }: Props) => { const { address } = useAccount() const { data: verificationData, isLoading: isVerificationLoading } = useVerifiedRecords({ - name, - address: profile?.coins?.find(({ id }) => id === 60)?.value, verificationsRecord: profile?.texts?.find(({ key }) => key === VERIFICATION_RECORD_KEY)?.value, }) From 04f31f0fc8d59b7496c09e15ab11f7d3b45b72a1 Mon Sep 17 00:00:00 2001 From: storywithoutend Date: Wed, 18 Sep 2024 00:42:03 +0800 Subject: [PATCH 3/4] switch to staging --- src/constants/verification.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/verification.ts b/src/constants/verification.ts index 2ea762961..ef7cc46e6 100644 --- a/src/constants/verification.ts +++ b/src/constants/verification.ts @@ -51,7 +51,7 @@ const DENTITY_ENV_CONFIGS = { type DentityEnvironment = keyof typeof DENTITY_ENV_CONFIGS -const DENTITY_ENV: DentityEnvironment = 'production' +const DENTITY_ENV: DentityEnvironment = 'staging' export const DENTITY_BASE_ENDPOINT = DENTITY_ENV_CONFIGS[DENTITY_ENV].endpoint From 39616a9b29345906abb087145880533f9fdff6c9 Mon Sep 17 00:00:00 2001 From: storywithoutend Date: Thu, 7 Nov 2024 17:19:31 +0800 Subject: [PATCH 4/4] Update verification.ts --- src/constants/verification.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/verification.ts b/src/constants/verification.ts index ef7cc46e6..2409c9d55 100644 --- a/src/constants/verification.ts +++ b/src/constants/verification.ts @@ -15,7 +15,7 @@ const VERIFICATION_ENV_CONFIGS = { type VerificationEnv = keyof typeof VERIFICATION_ENV_CONFIGS -const VERIFICATION_ENV: VerificationEnv = 'production' +const VERIFICATION_ENV: VerificationEnv = 'staging' export const VERIFICATION_RECORD_KEY = 'verifications'