diff --git a/packages/data-layer/src/data-layer.test.ts b/packages/data-layer/src/data-layer.test.ts index 25ab32cd46..609b9e9f98 100644 --- a/packages/data-layer/src/data-layer.test.ts +++ b/packages/data-layer/src/data-layer.test.ts @@ -33,6 +33,7 @@ const mockProjects: v2Project[] = [ nodeId: "WyJwcm9qZWN0cyIsIjB4OGE3OTI0OWI2MzM5NWMyNWJkMTIxYmE2ZmYyODAxOThjMzk5ZDRmYjNmOTUxZmMzYzQyMTk3YjU0YTZkYjZhNiIsMTExNTUxMTFd", // note: This is moved to roles also + createdByAddress: "0x0000", createdAtBlock: "5146499", updatedAtBlock: "5146499", projectNumber: null, @@ -584,12 +585,16 @@ describe("projects retrieval", () => { expect(project?.project.id).toEqual(mockProject.id); expect(project?.project.nodeId).toEqual(mockProject.nodeId); expect(project?.project.chainId).toEqual(mockProject.chainId); - expect(project?.project.registryAddress).toEqual(mockProject.registryAddress); + expect(project?.project.registryAddress).toEqual( + mockProject.registryAddress, + ); expect(project?.project.projectNumber).toEqual(mockProject.projectNumber); expect(project?.project.tags).toEqual(mockProject.tags); expect(project?.project.roles).toEqual(mockProject.roles); expect(project?.project.name).toEqual(mockProject.name); - expect(project?.project.metadata.description).toEqual(mockProject.metadata.description); + expect(project?.project.metadata.description).toEqual( + mockProject.metadata.description, + ); }); test("can retrieve all projects for a network", async () => { diff --git a/packages/data-layer/src/data.types.ts b/packages/data-layer/src/data.types.ts index 67925e72a7..84fdadec88 100644 --- a/packages/data-layer/src/data.types.ts +++ b/packages/data-layer/src/data.types.ts @@ -169,6 +169,10 @@ export type v2Project = { * The tags are used to filter the projects based on the version of Allo. */ tags: ("allo-v1" | "allo-v2" | "program")[]; + /** + * Address which created the project + */ + createdByAddress: string; /** * The block the project was created at */ diff --git a/packages/data-layer/src/queries.ts b/packages/data-layer/src/queries.ts index 43991288f7..7581eb8d93 100644 --- a/packages/data-layer/src/queries.ts +++ b/packages/data-layer/src/queries.ts @@ -22,6 +22,7 @@ export const getProgramByUserAndTag = gql` metadata metadataCid tags + createdByAddress roles { address role @@ -53,6 +54,7 @@ export const getProgramByIdAndUser = gql` metadata metadataCid tags + createdByAddress roles { address role diff --git a/packages/round-manager/src/features/api/program.ts b/packages/round-manager/src/features/api/program.ts index c6e1c550e7..5fe499b598 100644 --- a/packages/round-manager/src/features/api/program.ts +++ b/packages/round-manager/src/features/api/program.ts @@ -39,7 +39,7 @@ export async function listPrograms( throw Error("Unable to fetch programs"); } - const programs: Program[] = []; + let programs: Program[] = []; for (const program of programsRes.programs) { programs.push({ @@ -53,9 +53,19 @@ export async function listPrograms( name: CHAINS[chainId]?.name, logo: CHAINS[chainId]?.logo, }, + createdByAddress: program.createdByAddress, }); } + // Filter out programs where operatorWallets does not include round.createdByAddress. + // This is to filter out spam rounds created by bots + programs = programs.filter((program) => { + return ( + program.createdByAddress && + program.operatorWallets?.includes(program.createdByAddress) + ); + }); + return programs; } catch (error) { datadogLogs.logger.error(`error: listPrograms - ${error}`); diff --git a/packages/round-manager/src/features/api/round.ts b/packages/round-manager/src/features/api/round.ts index 1f2fed7403..b9b63c8eb7 100644 --- a/packages/round-manager/src/features/api/round.ts +++ b/packages/round-manager/src/features/api/round.ts @@ -333,12 +333,9 @@ export async function listRounds(args: { }) .then((rounds) => rounds.map(indexerV2RoundToRound)); - console.log("rounds", rounds); - - // filter out rounds operatorWallets does not include round.createdByAddress - + // Filter out rounds where operatorWallets does not include round.createdByAddress + // This is to filter out spam rounds created by bots rounds = rounds.filter((round) => { - // Check if createdByAddress is defined and if operatorWallets array includes createdByAddress return ( round.createdByAddress && round.operatorWallets?.includes(round.createdByAddress) diff --git a/packages/round-manager/src/features/api/types.ts b/packages/round-manager/src/features/api/types.ts index 0da25da3e2..53c4be49ad 100644 --- a/packages/round-manager/src/features/api/types.ts +++ b/packages/round-manager/src/features/api/types.ts @@ -95,6 +95,10 @@ export interface Program { * Addresses of wallets that will have admin privileges to operate the Grant program */ operatorWallets: Array; + /** + * Address which created the program + */ + createdByAddress?: string; /** * Network Chain Information */