From e9cdd37062154d01fbb4331c0ff4e48d0d498f59 Mon Sep 17 00:00:00 2001 From: Ioannis Tourkogiorgis Date: Wed, 30 Oct 2024 13:54:35 +0100 Subject: [PATCH] refactor: add unclaimed project owner field resolves: https://github.com/drips-network/graphql-api/issues/35 --- src/project/projectResolvers.ts | 3 +++ src/project/projectTypeDef.ts | 1 + src/project/projectUtils.ts | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/src/project/projectResolvers.ts b/src/project/projectResolvers.ts index a9b4f37..29107a8 100644 --- a/src/project/projectResolvers.ts +++ b/src/project/projectResolvers.ts @@ -469,6 +469,9 @@ const projectResolvers = { parentProjectInfo: { projectId, projectChain }, }: ResolverUnClaimedProjectData) => getWithdrawableBalancesOnChain(projectId, projectChain), + owner: ( + projectData: ResolverClaimedProjectData, + ): AddressDriverAccount | null => projectData.owner, }, Avatar: { __resolveType(parent: { cid: string } | { emoji: string }) { diff --git a/src/project/projectTypeDef.ts b/src/project/projectTypeDef.ts index 8671787..132f0fd 100644 --- a/src/project/projectTypeDef.ts +++ b/src/project/projectTypeDef.ts @@ -54,6 +54,7 @@ const projectTypeDef = gql` verificationStatus: ProjectVerificationStatus! support: [SupportItem!]! withdrawableBalances: [WithdrawableBalance!]! + owner: AddressDriverAccount! } input ProjectWhereInput { diff --git a/src/project/projectUtils.ts b/src/project/projectUtils.ts index 605003a..b38d441 100644 --- a/src/project/projectUtils.ts +++ b/src/project/projectUtils.ts @@ -1,3 +1,4 @@ +import { ZeroAddress } from 'ethers'; import type { DbSchema, Forge, @@ -125,6 +126,8 @@ export async function toProjectRepresentation( project.verificationStatus ?? ProjectVerificationStatus.Unclaimed, isValid: true, chain: project.chain, + ownerAddress: project.ownerAddress || ZeroAddress, + ownerAccountId: project.ownerAccountId || '0', } as ProjectDataValues; } @@ -190,6 +193,11 @@ function mapUnClaimedProjectChainData( support: [], // Will be populated by the resolver. totalEarned: [], // Will be populated by the resolver. withdrawableBalances: [], // Will be populated by the resolver. + owner: { + driver: Driver.ADDRESS, + accountId: fakeUnclaimedProject.ownerAccountId || '0', + address: (fakeUnclaimedProject.ownerAddress as string) || ZeroAddress, + }, } as ResolverUnClaimedProjectData; }