Skip to content

Commit

Permalink
feat: filter out duplicate bot rounds
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavaparoksham committed Feb 16, 2024
1 parent 70ea0f0 commit d60a18a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/data-layer/src/data.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export type V2Round = {

export type V2RoundWithRoles = V2Round & {
roles: AddressAndRole[];
createdByAddress: string;
};

export type ProjectEvents = {
Expand Down
1 change: 1 addition & 0 deletions packages/data-layer/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export const getRoundsByProgramIdAndUserAddress = gql`
applicationMetadataCid
strategyAddress
strategyName
createdByAddress
roles {
role
address
Expand Down
15 changes: 14 additions & 1 deletion packages/round-manager/src/features/api/round.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ function indexerV2RoundToRound(round: V2RoundWithRoles): Round {
ownedBy: round.projectId,
operatorWallets: operatorWallets,
finalized: false,
createdByAddress: round.createdByAddress,
};
}

Expand All @@ -324,14 +325,26 @@ export async function listRounds(args: {
}): Promise<{ rounds: Round[] }> {
const { chainId, userAddress, dataLayer, programId } = args;

const rounds = await dataLayer
let rounds = await dataLayer
.getRoundsByProgramIdAndUserAddress({
chainId: chainId,
programId,
userAddress,
})
.then((rounds) => rounds.map(indexerV2RoundToRound));

console.log("rounds", rounds);

// filter out rounds operatorWallets does not include round.createdByAddress

rounds = rounds.filter((round) => {
// Check if createdByAddress is defined and if operatorWallets array includes createdByAddress
return (
round.createdByAddress &&
round.operatorWallets?.includes(round.createdByAddress)
);
});

return { rounds };
}

Expand Down
6 changes: 5 additions & 1 deletion packages/round-manager/src/features/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { VerifiableCredential } from "@gitcoinco/passport-sdk-types";
import { BigNumber } from "ethers";
import { SchemaQuestion } from "./utils";
import { RoundVisibilityType } from "common";
import { Address } from "viem";
import { Address } from "viem";

export type Network = "optimism" | "fantom" | "pgn";

Expand Down Expand Up @@ -253,6 +253,10 @@ export interface Round {
finalized: boolean;
protocolFeePercentage?: number;
roundFeePercentage?: number;
/**
* CreatedByAddress
*/
createdByAddress?: string;
}

export type MatchingStatsData = {
Expand Down

0 comments on commit d60a18a

Please sign in to comment.