diff --git a/src/repositories/projectRepository.ts b/src/repositories/projectRepository.ts index d500b41bb..91dec1ff0 100644 --- a/src/repositories/projectRepository.ts +++ b/src/repositories/projectRepository.ts @@ -83,6 +83,7 @@ export type FilterProjectQueryInputParams = { qfRoundId?: number; activeQfRoundId?: number; qfRoundSlug?: string; + includeUnlisted?: boolean; }; export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => { const { @@ -97,6 +98,7 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => { qfRoundId, qfRoundSlug, activeQfRoundId, + includeUnlisted, } = params; let query = Project.createQueryBuilder('project') @@ -122,11 +124,16 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => { 'projectPower.totalPower', 'projectPower.powerRank', 'projectPower.round', - ]) - .where( + ]); + + if (includeUnlisted) { + query = query.where(`project.statusId = ${ProjStatus.active}`); + } else { + query = query.where( `project.statusId = ${ProjStatus.active} AND project.reviewStatus = :reviewStatus`, { reviewStatus: ReviewStatus.Listed }, ); + } const isFilterByQF = !!filters?.find(f => f === FilterField.ActiveQfRound) && activeQfRoundId; @@ -255,7 +262,6 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => { break; case SortingField.BestMatch: break; - default: query .addOrderBy('projectInstantPower.totalPower', OrderDirection.DESC) diff --git a/src/resolvers/anchorContractAddressResolver.ts b/src/resolvers/anchorContractAddressResolver.ts index b45fd4c2b..70f09fe08 100644 --- a/src/resolvers/anchorContractAddressResolver.ts +++ b/src/resolvers/anchorContractAddressResolver.ts @@ -14,6 +14,9 @@ import { ApolloContext } from '../types/ApolloContext'; import { findUserById } from '../repositories/userRepository'; import { getProvider } from '../provider'; import { logger } from '../utils/logger'; +import { ChainType } from '../types/network'; +import { addBulkNewProjectAddress } from '../repositories/projectAddressRepository'; +import { validateProjectRelatedAddresses } from '../utils/validators/projectValidator'; @Resolver(_of => AnchorContractAddress) export class AnchorContractAddressResolver { @@ -24,6 +27,7 @@ export class AnchorContractAddressResolver { @Arg('networkId', () => Int) networkId: number, @Arg('address', () => String) address: string, @Arg('txHash', () => String) txHash: string, + @Arg('recipientAddress', { nullable: true }) recipientAddress?: string, ): Promise { const userId = ctx?.req?.user?.userId; const creatorUser = await findUserById(userId); @@ -53,11 +57,29 @@ export class AnchorContractAddressResolver { projectAddress.isRecipient === true, ) ) { - throw new Error( - i18n.__( - translationErrorMessagesKeys.PROJECT_DOESNT_HAVE_RECIPIENT_ADDRESS_ON_THIS_NETWORK, - ), - ); + if (recipientAddress) { + const recipientAddressInput = { + project, + user: creatorUser, + address: recipientAddress!, + chainType: ChainType.EVM, + networkId: networkId, + isRecipient: true, + }; + + await validateProjectRelatedAddresses( + [recipientAddressInput], + projectId, + ); + + await addBulkNewProjectAddress([recipientAddressInput]); + } else { + throw new Error( + i18n.__( + translationErrorMessagesKeys.PROJECT_DOESNT_HAVE_RECIPIENT_ADDRESS_ON_THIS_NETWORK, + ), + ); + } } const web3Provider = getProvider(networkId); diff --git a/src/resolvers/projectResolver.ts b/src/resolvers/projectResolver.ts index e9740260d..051683924 100644 --- a/src/resolvers/projectResolver.ts +++ b/src/resolvers/projectResolver.ts @@ -268,6 +268,9 @@ class GetProjectsArgs { @Field(_type => String, { nullable: true }) qfRoundSlug?: string; + + @Field({ nullable: true }) + includeUnlisted?: boolean; } @ObjectType() @@ -740,6 +743,7 @@ export class ProjectResolver { campaignSlug, qfRoundId, qfRoundSlug, + includeUnlisted, }: GetProjectsArgs, @Ctx() { req: { user }, projectsFiltersThreadPool }: ApolloContext, ): Promise { @@ -766,6 +770,7 @@ export class ProjectResolver { qfRoundId, qfRoundSlug, activeQfRoundId, + includeUnlisted, }; let campaign; if (campaignSlug) {