Skip to content

Commit 39082ea

Browse files
authored
fix matching distribution (#3798)
1 parent 5b48fab commit 39082ea

File tree

4 files changed

+33
-34
lines changed

4 files changed

+33
-34
lines changed

packages/data-layer/src/data.types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,7 @@ export type DistributionMatch = {
381381
};
382382

383383
export type RoundForManager = V2RoundWithProject & {
384-
matchingDistribution: {
385-
matchingDistribution: DistributionMatch[];
386-
} | null;
384+
matchingDistribution: DistributionMatch[];
387385
tags: string[];
388386
matchAmount: string;
389387
matchAmountInUsd: number;

packages/round-manager/src/features/api/payoutStrategy/payoutStrategy.ts

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,28 @@ export const useGroupProjectsByPaymentStatus = (
6262

6363
const allProjects: MatchingStatsData[] = useMemo(
6464
() =>
65-
round.matchingDistribution?.matchingDistribution.map(
66-
(matchingStatsData) => {
67-
return {
68-
projectName: matchingStatsData.projectName,
69-
contributionsCount: matchingStatsData.contributionsCount,
70-
matchPoolPercentage: matchingStatsData.matchPoolPercentage,
71-
projectId: matchingStatsData.projectId,
72-
applicationId: matchingStatsData.applicationId,
73-
anchorAddress: applications?.find(
74-
(application) =>
75-
application.projectId === matchingStatsData.projectId
76-
)?.anchorAddress,
77-
matchAmountInToken: BigNumber.from(
78-
matchingStatsData.matchAmountInToken
79-
),
80-
originalMatchAmountInToken: BigNumber.from(
81-
matchingStatsData.originalMatchAmountInToken
82-
),
83-
projectPayoutAddress: matchingStatsData.projectPayoutAddress,
84-
};
85-
}
86-
) ?? [],
87-
[round.matchingDistribution?.matchingDistribution, applications]
65+
round.matchingDistribution?.map((matchingStatsData) => {
66+
const anchorAddress = applications?.find(
67+
(application) => application.projectId === matchingStatsData.projectId
68+
)?.anchorAddress;
69+
70+
return {
71+
projectName: matchingStatsData.projectName,
72+
contributionsCount: matchingStatsData.contributionsCount,
73+
matchPoolPercentage: matchingStatsData.matchPoolPercentage,
74+
projectId: matchingStatsData.projectId,
75+
applicationId: matchingStatsData.applicationId,
76+
anchorAddress,
77+
matchAmountInToken: BigNumber.from(
78+
matchingStatsData.matchAmountInToken
79+
),
80+
originalMatchAmountInToken: BigNumber.from(
81+
matchingStatsData.originalMatchAmountInToken
82+
),
83+
projectPayoutAddress: matchingStatsData.projectPayoutAddress,
84+
};
85+
}) ?? [],
86+
[round.matchingDistribution, applications]
8887
);
8988

9089
useEffect(() => {
@@ -103,11 +102,13 @@ export const useGroupProjectsByPaymentStatus = (
103102
let tmpProject = project;
104103

105104
if (projectStatus === "paid") {
105+
const hash = paidProjects?.find(
106+
(p) => p.projectId === project.projectId
107+
)?.distributionTransaction;
108+
106109
tmpProject = {
107110
...project,
108-
hash:
109-
paidProjects?.find((p) => p.projectId === project.projectId)
110-
?.distributionTransaction || undefined,
111+
hash: hash || undefined,
111112
status: "",
112113
};
113114
}
@@ -118,7 +119,7 @@ export const useGroupProjectsByPaymentStatus = (
118119
}
119120

120121
fetchData();
121-
// eslint-disable-next-line react-hooks/exhaustive-deps
122-
}, [allProjects]);
122+
}, [allProjects, paidProjects, paidProjectIds]);
123+
123124
return groupedProjects;
124125
};

packages/round-manager/src/features/round/ViewRoundResults/ViewRoundResults.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function useRevisedMatchingFunds(
8282
round.matchingDistribution !== null &&
8383
round.readyForPayoutTransaction !== null
8484
) {
85-
return round.matchingDistribution.matchingDistribution.map((m) => {
85+
return round.matchingDistribution.map((m) => {
8686
return {
8787
applicationId: m.applicationId,
8888
payoutAddress: m.projectPayoutAddress,

packages/round-manager/src/test-utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ export const makeRoundData = (overrides: Partial<Round> = {}): Round => {
124124
matchAmountInUsd: 0,
125125
fundedAmount: 0n,
126126
fundedAmountInUsd: 0,
127-
matchingDistribution: null,
128127
readyForPayoutTransaction: null,
128+
matchingDistribution: [],
129129
...overrides,
130130
};
131131
};
@@ -192,7 +192,7 @@ export const makeDirectGrantRoundData = (
192192
matchAmountInUsd: 0,
193193
fundedAmount: 0n,
194194
fundedAmountInUsd: 0,
195-
matchingDistribution: null,
195+
matchingDistribution: [],
196196
readyForPayoutTransaction: null,
197197
...overrides,
198198
};

0 commit comments

Comments
 (0)