From 8809fc581b71da7d9430b431d999fa4c1b561034 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 5 Nov 2025 11:51:37 +0000 Subject: [PATCH] fix(gcr): fix syntax error in isFirstConnection function Fixed critical syntax error in the isFirstConnection method that was preventing TypeScript compilation. The if-else chain was malformed with orphaned braces and unreachable code. Changes: - Restructured the if-else chain to properly handle web2, ud, and web3 types - Changed condition from `if (type !== "web3")` to `if (type !== "web3" && type !== "ud")` - Removed orphaned closing braces and unreachable return statement - Fixed indentation for the web3 (else) block This resolves the following TypeScript errors: - TS1068: Unexpected token - TS1005: ',' expected - TS1128: Declaration or statement expected The UD identity integration will now function correctly with proper first-time connection detection for incentive points. --- .../gcr/gcr_routines/GCRIdentityRoutines.ts | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/libs/blockchain/gcr/gcr_routines/GCRIdentityRoutines.ts b/src/libs/blockchain/gcr/gcr_routines/GCRIdentityRoutines.ts index 2597fa413..659c47cae 100644 --- a/src/libs/blockchain/gcr/gcr_routines/GCRIdentityRoutines.ts +++ b/src/libs/blockchain/gcr/gcr_routines/GCRIdentityRoutines.ts @@ -890,7 +890,8 @@ export default class GCRIdentityRoutines { gcrMainRepository: Repository, currentAccount?: string, ): Promise { - if (type !== "web3") { + if (type !== "web3" && type !== "ud") { + // Handle web2 identity types: twitter, github, telegram, discord const queryTemplate = ` EXISTS (SELECT 1 FROM jsonb_array_elements(COALESCE(gcr.identities->'web2'->'${type}', '[]'::jsonb)) as ${type}_id WHERE ${type}_id->>'userId' = :userId) ` @@ -901,9 +902,6 @@ export default class GCRIdentityRoutines { .andWhere("gcr.pubkey != :currentAccount", { currentAccount }) .getOne() - return !result - } - /** * Return true if no account has this userId */ @@ -932,23 +930,23 @@ export default class GCRIdentityRoutines { const addressToCheck = data.chain === "evm" ? data.address.toLowerCase() : data.address - const result = await gcrMainRepository - .createQueryBuilder("gcr") - .where( - "EXISTS (SELECT 1 FROM jsonb_array_elements(gcr.identities->'xm'->:chain->:subchain) as xm_id WHERE xm_id->>'address' = :address)", - { - chain: data.chain, - subchain: data.subchain, - address: addressToCheck, - }, - ) - .andWhere("gcr.pubkey != :currentAccount", { currentAccount }) - .getOne() + const result = await gcrMainRepository + .createQueryBuilder("gcr") + .where( + "EXISTS (SELECT 1 FROM jsonb_array_elements(gcr.identities->'xm'->:chain->:subchain) as xm_id WHERE xm_id->>'address' = :address)", + { + chain: data.chain, + subchain: data.subchain, + address: addressToCheck, + }, + ) + .andWhere("gcr.pubkey != :currentAccount", { currentAccount }) + .getOne() - /** - * Return true if this is the first connection - */ - return !result - // } + /** + * Return true if this is the first connection + */ + return !result + } } }