From d87a751215720da213bd1662e4e03089e0598f53 Mon Sep 17 00:00:00 2001 From: jtourkos Date: Tue, 19 Aug 2025 13:51:11 +0200 Subject: [PATCH 1/5] refactor: handle partially indexed support --- src/drip-list/dripListResolvers.ts | 36 ++++++++--- src/ecosystem/ecosystemResolvers.ts | 36 ++++++++--- src/project/projectResolvers.ts | 98 ++++++++++++++++++++--------- src/user/userResolvers.ts | 50 ++++++++++----- 4 files changed, 161 insertions(+), 59 deletions(-) diff --git a/src/drip-list/dripListResolvers.ts b/src/drip-list/dripListResolvers.ts index 0955a86..0c8f44f 100644 --- a/src/drip-list/dripListResolvers.ts +++ b/src/drip-list/dripListResolvers.ts @@ -347,7 +347,7 @@ const dripListResolvers = { dripListChain, ); - const projectsAndDripListsSupport = await Promise.all( + const supportItems = await Promise.all( splitReceivers.map(async (receiver) => { const { senderAccountId, blockTimestamp, senderAccountType } = receiver; @@ -383,12 +383,30 @@ const dripListResolvers = { }, date: blockTimestamp, totalSplit: [], - dripList: await toResolverDripList( - dripListChain, - (await dripListsDataSource.getDripListById(senderAccountId, [ - dripListChain, - ])) || shouldNeverHappen(), - ), + project: await toResolverProject([dripListChain], projectData), + }; + } + if (senderAccountType === 'drip_list') { + assertIsNftDriverId(senderAccountId); + + const dripListData = await dripListsDataSource.getDripListById( + senderAccountId, + [dripListChain], + ); + + if (!dripListData) { + return null; + } + + return { + ...receiver, + account: { + driver: Driver.NFT, + accountId: receiverAccountId, + }, + date: blockTimestamp, + totalSplit: [], + dripList: await toResolverDripList(dripListChain, dripListData), }; } @@ -487,6 +505,10 @@ const dripListResolvers = { }), ); + const projectsAndDripListsSupport = supportItems.filter( + (item) => item !== null, + ); + const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( dripListId, diff --git a/src/ecosystem/ecosystemResolvers.ts b/src/ecosystem/ecosystemResolvers.ts index 9fe8e92..e72bdce 100644 --- a/src/ecosystem/ecosystemResolvers.ts +++ b/src/ecosystem/ecosystemResolvers.ts @@ -292,7 +292,7 @@ const ecosystemResolvers = { ecosystemChain, ); - const projectsAndDripListsSupport = await Promise.all( + const supportItems = await Promise.all( splitReceivers.map(async (receiver) => { const { senderAccountId, blockTimestamp, senderAccountType } = receiver; @@ -328,12 +328,30 @@ const ecosystemResolvers = { }, date: blockTimestamp, totalSplit: [], - dripList: await toResolverDripList( - ecosystemChain, - (await dripListsDataSource.getDripListById(senderAccountId, [ - ecosystemChain, - ])) || shouldNeverHappen(), - ), + project: await toResolverProject([ecosystemChain], projectData), + }; + } + if (senderAccountType === 'drip_list') { + assertIsNftDriverId(senderAccountId); + + const dripListData = await dripListsDataSource.getDripListById( + senderAccountId, + [ecosystemChain], + ); + + if (!dripListData) { + return null; + } + + return { + ...receiver, + account: { + driver: Driver.NFT, + accountId: receiverAccountId, + }, + date: blockTimestamp, + totalSplit: [], + dripList: await toResolverDripList(ecosystemChain, dripListData), }; } @@ -432,6 +450,10 @@ const ecosystemResolvers = { }), ); + const projectsAndDripListsSupport = supportItems.filter( + (item) => item !== null, + ); + const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( ecosystemId, diff --git a/src/project/projectResolvers.ts b/src/project/projectResolvers.ts index a4a8539..d314100 100644 --- a/src/project/projectResolvers.ts +++ b/src/project/projectResolvers.ts @@ -414,7 +414,7 @@ const projectResolvers = { projectChain, ); - const support = await Promise.all( + const supportItems = await Promise.all( splitReceivers.map(async (receiver) => { const { senderAccountId, blockTimestamp, senderAccountType } = receiver; @@ -450,17 +450,44 @@ const projectResolvers = { }, date: blockTimestamp, totalSplit: [], - dripList: await toResolverDripList( - projectChain, - (await dripListsDataSource.getDripListById(senderAccountId, [ - projectChain, - ])) || shouldNeverHappen(), - ), + project: await toResolverProject([projectChain], projectData), + }; + } + if (senderAccountType === 'drip_list') { + assertIsNftDriverId(senderAccountId); + + const dripListData = await dripListsDataSource.getDripListById( + senderAccountId, + [projectChain], + ); + + if (!dripListData) { + return null; + } + + return { + ...receiver, + account: { + driver: Driver.NFT, + accountId: receiverAccountId, + }, + date: blockTimestamp, + totalSplit: [], + dripList: await toResolverDripList(projectChain, dripListData), }; } if (senderAccountType === 'ecosystem_main_account') { assertIsNftDriverId(senderAccountId); + const ecosystemData = await ecosystemsDataSource.getEcosystemById( + senderAccountId, + [projectChain], + ); + + if (!ecosystemData) { + return null; + } + return { ...receiver, account: { @@ -471,9 +498,7 @@ const projectResolvers = { totalSplit: [], ecosystemMainAccount: await toResolverEcosystem( projectChain, - (await ecosystemsDataSource.getEcosystemById(senderAccountId, [ - projectChain, - ])) || shouldNeverHappen(), + ecosystemData, ), }; } @@ -484,6 +509,8 @@ const projectResolvers = { }), ); + const support = supportItems.filter((item) => item !== null); + const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( projectId, @@ -539,11 +566,20 @@ const projectResolvers = { projectChain, ); - const support = await Promise.all( + const supportItems = await Promise.all( splitsReceivers.map(async (s) => { const { senderAccountId, senderAccountType, blockTimestamp } = s; if (senderAccountType === 'project') { + const projectData = await projectsDataSource.getProjectByIdOnChain( + senderAccountId as RepoDriverId, + projectChain, + ); + + if (!projectData) { + return null; + } + return { ...s, account: { @@ -553,16 +589,19 @@ const projectResolvers = { date: blockTimestamp, totalSplit: [], splitsToSubAccount: s.splitsToRepoDriverSubAccount, - project: await toResolverProject( - [projectChain], - (await projectsDataSource.getProjectByIdOnChain( - senderAccountId as RepoDriverId, - projectChain, - )) || shouldNeverHappen(), - ), + project: await toResolverProject([projectChain], projectData), }; } if (senderAccountType === 'drip_list') { + const dripListData = await dripListsDataSource.getDripListById( + senderAccountId as NftDriverId, + [projectChain], + ); + + if (!dripListData) { + return null; + } + return { ...s, account: { @@ -571,18 +610,21 @@ const projectResolvers = { }, date: blockTimestamp, totalSplit: [], - dripList: await toResolverDripList( - projectChain, - (await dripListsDataSource.getDripListById( - senderAccountId as NftDriverId, - [projectChain], - )) || shouldNeverHappen(), - ), + dripList: await toResolverDripList(projectChain, dripListData), }; } if (senderAccountType === 'ecosystem_main_account') { assertIsNftDriverId(senderAccountId); + const ecosystemData = await ecosystemsDataSource.getEcosystemById( + senderAccountId, + [projectChain], + ); + + if (!ecosystemData) { + return null; + } + return { ...s, account: { @@ -593,9 +635,7 @@ const projectResolvers = { totalSplit: [], ecosystemMainAccount: await toResolverEcosystem( projectChain, - (await ecosystemsDataSource.getEcosystemById(senderAccountId, [ - projectChain, - ])) || shouldNeverHappen(), + ecosystemData, ), }; } @@ -675,6 +715,8 @@ const projectResolvers = { }), ); + const support = supportItems.filter((item) => item !== null); + // `GivenEventModelDataValues`s that represent one time donations to the Project. const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( diff --git a/src/user/userResolvers.ts b/src/user/userResolvers.ts index eaa7452..e72acd9 100644 --- a/src/user/userResolvers.ts +++ b/src/user/userResolvers.ts @@ -225,7 +225,7 @@ const userResolvers = { s === 'sub_list', ); - const support = await Promise.all( + const supportItems = await Promise.all( splitsReceivers.map(async (receiver) => { const { senderAccountId, senderAccountType, blockTimestamp } = receiver; @@ -233,6 +233,15 @@ const userResolvers = { if (senderAccountType === 'project') { assertIsRepoDriverId(senderAccountId); + const projectData = await projectsDataSource.getProjectByIdOnChain( + senderAccountId, + userChain, + ); + + if (!projectData) { + return null; + } + return { ...receiver, account: { @@ -242,19 +251,22 @@ const userResolvers = { date: blockTimestamp, totalSplit: [], splitsToSubAccount: receiver.splitsToRepoDriverSubAccount, - project: await toResolverProject( - [userChain], - (await projectsDataSource.getProjectByIdOnChain( - senderAccountId, - userChain, - )) || shouldNeverHappen(), - ), + project: await toResolverProject([userChain], projectData), }; } if (senderAccountType === 'drip_list') { assertIsNftDriverId(senderAccountId); + const dripListData = await dripListsDataSource.getDripListById( + senderAccountId, + [userChain], + ); + + if (!dripListData) { + return null; + } + return { ...receiver, account: { @@ -263,18 +275,22 @@ const userResolvers = { }, date: blockTimestamp, totalSplit: [], - dripList: await toResolverDripList( - userChain, - (await dripListsDataSource.getDripListById(senderAccountId, [ - userChain, - ])) || shouldNeverHappen(), - ), + dripList: await toResolverDripList(userChain, dripListData), }; } if (senderAccountType === 'ecosystem_main_account') { assertIsNftDriverId(senderAccountId); + const ecosystemData = await ecosystemsDataSource.getEcosystemById( + senderAccountId, + [userChain], + ); + + if (!ecosystemData) { + return null; + } + return { ...receiver, account: { @@ -285,9 +301,7 @@ const userResolvers = { totalSplit: [], ecosystemMainAccount: await toResolverEcosystem( userChain, - (await ecosystemsDataSource.getEcosystemById(senderAccountId, [ - userChain, - ])) || shouldNeverHappen(), + ecosystemData, ), }; } @@ -369,6 +383,8 @@ const userResolvers = { }), ); + const support = supportItems.filter((item) => item !== null); + const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( accountId as AccountId, From e05ca156e2cc30b2911597290d4741b0253c8e85 Mon Sep 17 00:00:00 2001 From: Morgan Brown Date: Thu, 21 Aug 2025 14:32:57 +0200 Subject: [PATCH 2/5] Update isOrcidId to comply with ORCID iD rules --- src/utils/assert.ts | 54 ++++++++++++++++++++++++++++++++++---- tests/utils/assert.test.ts | 9 +++---- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/utils/assert.ts b/src/utils/assert.ts index b6b7faf..f823d08 100644 --- a/src/utils/assert.ts +++ b/src/utils/assert.ts @@ -293,9 +293,53 @@ export function isAccountId(id: string): boolean { ); } -// ORCID -export function isOrcidId(id: string): boolean { - // ORCID ID format: 0000-0000-0000-000X where X can be 0-9 or X - const orcidPattern = /^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/; - return orcidPattern.test(id); +/** + * Validates an ORCID iD. + * + * An ORCID iD is a 16-character string that follows a specific structure: + * - It consists of 15 digits followed by a check digit (0-9 or 'X'). + * - It is often formatted with hyphens, e.g., "0000-0002-1825-0097". + * - The validation uses the ISO 7064 11,2 checksum algorithm. + * + * @param {string} orcid The ORCID iD string to validate. + * @returns {boolean} True if the ORCID iD is valid, false otherwise. + */ +export function isOrcidId(orcidId: string): boolean { + if (typeof orcidId !== 'string') { + return false; + } + + // Remove hyphens and whitespace to get the base 16 characters. + const baseStr: string = orcidId.replace(/[-\s]/g, ''); + + // An ORCID must be 16 characters long and match the pattern: + // 15 digits followed by a final character that is a digit or 'X'. + const orcidPattern: RegExp = /^\d{15}[\dX]$/; + if (!orcidPattern.test(baseStr.toUpperCase())) { + return false; + } + + // --- Checksum Calculation (ISO 7064 11,2) --- + + let total: number = 0; + // Iterate over the first 15 digits of the ORCID. + for (let i = 0; i < 15; i++) { + const digit: number = parseInt(baseStr[i], 10); + total = (total + digit) * 2; + } + + // Calculate the remainder when divided by 11. + const remainder: number = total % 11; + // Subtract the remainder from 12. + const result: number = (12 - remainder) % 11; + + // Determine the correct check digit from the result. + // If the result is 10, the check digit is 'X'. Otherwise, it's the digit itself. + const calculatedCheckDigit: string = result === 10 ? 'X' : String(result); + + // Get the actual check digit from the input string. + const actualCheckDigit: string = baseStr.charAt(15).toUpperCase(); + + // Compare the calculated check digit with the actual one. + return calculatedCheckDigit === actualCheckDigit; } diff --git a/tests/utils/assert.test.ts b/tests/utils/assert.test.ts index e447958..e9143e4 100644 --- a/tests/utils/assert.test.ts +++ b/tests/utils/assert.test.ts @@ -4,11 +4,8 @@ import { isOrcidId } from '../../src/utils/assert'; describe('isOrcidId', () => { test('should return true for valid ORCID IDs', () => { // Valid ORCID ID patterns - expect(isOrcidId('0000-0000-0000-0000')).toBe(true); - expect(isOrcidId('0000-0000-0000-000X')).toBe(true); - expect(isOrcidId('1234-5678-9012-3456')).toBe(true); - expect(isOrcidId('0000-0002-1825-009X')).toBe(true); - expect(isOrcidId('0000-0003-1527-0030')).toBe(true); + expect(isOrcidId('0009-0007-1106-8413')).toBe(true); + expect(isOrcidId('0000-0002-9079-593X')).toBe(true); }); test('should return false for invalid ORCID IDs', () => { @@ -31,5 +28,7 @@ describe('isOrcidId', () => { expect(isOrcidId('')).toBe(false); // Empty string expect(isOrcidId('abc-def-ghi-jkl')).toBe(false); // Letters instead of digits expect(isOrcidId('0000-0000-0000-000@')).toBe(false); // Invalid special character + expect(isOrcidId('0000-0001-5109-370X')).toBe(false); // Incorrect X position + expect(isOrcidId('0000-0002-1825-0098')).toBe(false); // Fails checksum }); }); From 497e1dabe88a02ed0759a6242627e8bdcbb2051e Mon Sep 17 00:00:00 2001 From: Morgan Brown Date: Tue, 26 Aug 2025 15:11:25 +0200 Subject: [PATCH 3/5] Update error message for invalid ORCID iDs --- src/orcid-account/orcidAccountResolvers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/orcid-account/orcidAccountResolvers.ts b/src/orcid-account/orcidAccountResolvers.ts index 86613d3..a596478 100644 --- a/src/orcid-account/orcidAccountResolvers.ts +++ b/src/orcid-account/orcidAccountResolvers.ts @@ -73,7 +73,7 @@ const orcidAccountResolvers = { ): Promise => { if (!isOrcidId(id)) { throw new Error( - `Invalid ORCID identifier: '${id}'. Expected format: 0000-0000-0000-000X`, + `Invalid ORCID identifier: '${id}'. See https://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier.`, ); } From c2b168cfa15784e17ba5cae3d1e3bf0b5e6cf2a8 Mon Sep 17 00:00:00 2001 From: Morgan Brown Date: Tue, 26 Aug 2025 15:35:04 +0200 Subject: [PATCH 4/5] Rebase orcid-split-receivers --- src/drip-list/dripListResolvers.ts | 36 +++-------- src/ecosystem/ecosystemResolvers.ts | 36 +++-------- src/project/projectResolvers.ts | 98 +++++++++-------------------- 3 files changed, 42 insertions(+), 128 deletions(-) diff --git a/src/drip-list/dripListResolvers.ts b/src/drip-list/dripListResolvers.ts index 0c8f44f..0955a86 100644 --- a/src/drip-list/dripListResolvers.ts +++ b/src/drip-list/dripListResolvers.ts @@ -347,7 +347,7 @@ const dripListResolvers = { dripListChain, ); - const supportItems = await Promise.all( + const projectsAndDripListsSupport = await Promise.all( splitReceivers.map(async (receiver) => { const { senderAccountId, blockTimestamp, senderAccountType } = receiver; @@ -383,30 +383,12 @@ const dripListResolvers = { }, date: blockTimestamp, totalSplit: [], - project: await toResolverProject([dripListChain], projectData), - }; - } - if (senderAccountType === 'drip_list') { - assertIsNftDriverId(senderAccountId); - - const dripListData = await dripListsDataSource.getDripListById( - senderAccountId, - [dripListChain], - ); - - if (!dripListData) { - return null; - } - - return { - ...receiver, - account: { - driver: Driver.NFT, - accountId: receiverAccountId, - }, - date: blockTimestamp, - totalSplit: [], - dripList: await toResolverDripList(dripListChain, dripListData), + dripList: await toResolverDripList( + dripListChain, + (await dripListsDataSource.getDripListById(senderAccountId, [ + dripListChain, + ])) || shouldNeverHappen(), + ), }; } @@ -505,10 +487,6 @@ const dripListResolvers = { }), ); - const projectsAndDripListsSupport = supportItems.filter( - (item) => item !== null, - ); - const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( dripListId, diff --git a/src/ecosystem/ecosystemResolvers.ts b/src/ecosystem/ecosystemResolvers.ts index e72bdce..9fe8e92 100644 --- a/src/ecosystem/ecosystemResolvers.ts +++ b/src/ecosystem/ecosystemResolvers.ts @@ -292,7 +292,7 @@ const ecosystemResolvers = { ecosystemChain, ); - const supportItems = await Promise.all( + const projectsAndDripListsSupport = await Promise.all( splitReceivers.map(async (receiver) => { const { senderAccountId, blockTimestamp, senderAccountType } = receiver; @@ -328,30 +328,12 @@ const ecosystemResolvers = { }, date: blockTimestamp, totalSplit: [], - project: await toResolverProject([ecosystemChain], projectData), - }; - } - if (senderAccountType === 'drip_list') { - assertIsNftDriverId(senderAccountId); - - const dripListData = await dripListsDataSource.getDripListById( - senderAccountId, - [ecosystemChain], - ); - - if (!dripListData) { - return null; - } - - return { - ...receiver, - account: { - driver: Driver.NFT, - accountId: receiverAccountId, - }, - date: blockTimestamp, - totalSplit: [], - dripList: await toResolverDripList(ecosystemChain, dripListData), + dripList: await toResolverDripList( + ecosystemChain, + (await dripListsDataSource.getDripListById(senderAccountId, [ + ecosystemChain, + ])) || shouldNeverHappen(), + ), }; } @@ -450,10 +432,6 @@ const ecosystemResolvers = { }), ); - const projectsAndDripListsSupport = supportItems.filter( - (item) => item !== null, - ); - const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( ecosystemId, diff --git a/src/project/projectResolvers.ts b/src/project/projectResolvers.ts index d314100..a4a8539 100644 --- a/src/project/projectResolvers.ts +++ b/src/project/projectResolvers.ts @@ -414,7 +414,7 @@ const projectResolvers = { projectChain, ); - const supportItems = await Promise.all( + const support = await Promise.all( splitReceivers.map(async (receiver) => { const { senderAccountId, blockTimestamp, senderAccountType } = receiver; @@ -450,44 +450,17 @@ const projectResolvers = { }, date: blockTimestamp, totalSplit: [], - project: await toResolverProject([projectChain], projectData), - }; - } - if (senderAccountType === 'drip_list') { - assertIsNftDriverId(senderAccountId); - - const dripListData = await dripListsDataSource.getDripListById( - senderAccountId, - [projectChain], - ); - - if (!dripListData) { - return null; - } - - return { - ...receiver, - account: { - driver: Driver.NFT, - accountId: receiverAccountId, - }, - date: blockTimestamp, - totalSplit: [], - dripList: await toResolverDripList(projectChain, dripListData), + dripList: await toResolverDripList( + projectChain, + (await dripListsDataSource.getDripListById(senderAccountId, [ + projectChain, + ])) || shouldNeverHappen(), + ), }; } if (senderAccountType === 'ecosystem_main_account') { assertIsNftDriverId(senderAccountId); - const ecosystemData = await ecosystemsDataSource.getEcosystemById( - senderAccountId, - [projectChain], - ); - - if (!ecosystemData) { - return null; - } - return { ...receiver, account: { @@ -498,7 +471,9 @@ const projectResolvers = { totalSplit: [], ecosystemMainAccount: await toResolverEcosystem( projectChain, - ecosystemData, + (await ecosystemsDataSource.getEcosystemById(senderAccountId, [ + projectChain, + ])) || shouldNeverHappen(), ), }; } @@ -509,8 +484,6 @@ const projectResolvers = { }), ); - const support = supportItems.filter((item) => item !== null); - const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( projectId, @@ -566,20 +539,11 @@ const projectResolvers = { projectChain, ); - const supportItems = await Promise.all( + const support = await Promise.all( splitsReceivers.map(async (s) => { const { senderAccountId, senderAccountType, blockTimestamp } = s; if (senderAccountType === 'project') { - const projectData = await projectsDataSource.getProjectByIdOnChain( - senderAccountId as RepoDriverId, - projectChain, - ); - - if (!projectData) { - return null; - } - return { ...s, account: { @@ -589,19 +553,16 @@ const projectResolvers = { date: blockTimestamp, totalSplit: [], splitsToSubAccount: s.splitsToRepoDriverSubAccount, - project: await toResolverProject([projectChain], projectData), + project: await toResolverProject( + [projectChain], + (await projectsDataSource.getProjectByIdOnChain( + senderAccountId as RepoDriverId, + projectChain, + )) || shouldNeverHappen(), + ), }; } if (senderAccountType === 'drip_list') { - const dripListData = await dripListsDataSource.getDripListById( - senderAccountId as NftDriverId, - [projectChain], - ); - - if (!dripListData) { - return null; - } - return { ...s, account: { @@ -610,21 +571,18 @@ const projectResolvers = { }, date: blockTimestamp, totalSplit: [], - dripList: await toResolverDripList(projectChain, dripListData), + dripList: await toResolverDripList( + projectChain, + (await dripListsDataSource.getDripListById( + senderAccountId as NftDriverId, + [projectChain], + )) || shouldNeverHappen(), + ), }; } if (senderAccountType === 'ecosystem_main_account') { assertIsNftDriverId(senderAccountId); - const ecosystemData = await ecosystemsDataSource.getEcosystemById( - senderAccountId, - [projectChain], - ); - - if (!ecosystemData) { - return null; - } - return { ...s, account: { @@ -635,7 +593,9 @@ const projectResolvers = { totalSplit: [], ecosystemMainAccount: await toResolverEcosystem( projectChain, - ecosystemData, + (await ecosystemsDataSource.getEcosystemById(senderAccountId, [ + projectChain, + ])) || shouldNeverHappen(), ), }; } @@ -715,8 +675,6 @@ const projectResolvers = { }), ); - const support = supportItems.filter((item) => item !== null); - // `GivenEventModelDataValues`s that represent one time donations to the Project. const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( From 23f4aebf8a8761fd250d75afdedb5138c4ace646 Mon Sep 17 00:00:00 2001 From: Morgan Brown Date: Tue, 2 Sep 2025 12:37:31 -0400 Subject: [PATCH 5/5] Restoring userResolvers.ts to base branch --- src/user/userResolvers.ts | 50 +++++++++++++-------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/src/user/userResolvers.ts b/src/user/userResolvers.ts index e72acd9..eaa7452 100644 --- a/src/user/userResolvers.ts +++ b/src/user/userResolvers.ts @@ -225,7 +225,7 @@ const userResolvers = { s === 'sub_list', ); - const supportItems = await Promise.all( + const support = await Promise.all( splitsReceivers.map(async (receiver) => { const { senderAccountId, senderAccountType, blockTimestamp } = receiver; @@ -233,15 +233,6 @@ const userResolvers = { if (senderAccountType === 'project') { assertIsRepoDriverId(senderAccountId); - const projectData = await projectsDataSource.getProjectByIdOnChain( - senderAccountId, - userChain, - ); - - if (!projectData) { - return null; - } - return { ...receiver, account: { @@ -251,22 +242,19 @@ const userResolvers = { date: blockTimestamp, totalSplit: [], splitsToSubAccount: receiver.splitsToRepoDriverSubAccount, - project: await toResolverProject([userChain], projectData), + project: await toResolverProject( + [userChain], + (await projectsDataSource.getProjectByIdOnChain( + senderAccountId, + userChain, + )) || shouldNeverHappen(), + ), }; } if (senderAccountType === 'drip_list') { assertIsNftDriverId(senderAccountId); - const dripListData = await dripListsDataSource.getDripListById( - senderAccountId, - [userChain], - ); - - if (!dripListData) { - return null; - } - return { ...receiver, account: { @@ -275,22 +263,18 @@ const userResolvers = { }, date: blockTimestamp, totalSplit: [], - dripList: await toResolverDripList(userChain, dripListData), + dripList: await toResolverDripList( + userChain, + (await dripListsDataSource.getDripListById(senderAccountId, [ + userChain, + ])) || shouldNeverHappen(), + ), }; } if (senderAccountType === 'ecosystem_main_account') { assertIsNftDriverId(senderAccountId); - const ecosystemData = await ecosystemsDataSource.getEcosystemById( - senderAccountId, - [userChain], - ); - - if (!ecosystemData) { - return null; - } - return { ...receiver, account: { @@ -301,7 +285,9 @@ const userResolvers = { totalSplit: [], ecosystemMainAccount: await toResolverEcosystem( userChain, - ecosystemData, + (await ecosystemsDataSource.getEcosystemById(senderAccountId, [ + userChain, + ])) || shouldNeverHappen(), ), }; } @@ -383,8 +369,6 @@ const userResolvers = { }), ); - const support = supportItems.filter((item) => item !== null); - const oneTimeDonationSupport = await supportDataSource.getOneTimeDonationSupportByAccountIdOnChain( accountId as AccountId,