Skip to content

Commit a23e3c7

Browse files
authored
fix: missing canonical metadata (#3787)
* fix: missing canonical metadata getApprovedApplication getApplicationsForExplorer getDonationsByDonorAddress * chore: removed unused imports * fix: lint
1 parent be5145d commit a23e3c7

File tree

8 files changed

+54
-25
lines changed

8 files changed

+54
-25
lines changed

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

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,10 @@ export class DataLayer {
464464
return null;
465465
}
466466

467-
return response.applications[0];
467+
const application = response.applications[0];
468+
application.project.metadata = application.metadata.application.project;
469+
470+
return application;
468471
}
469472

470473
async getApplicationsForExplorer({
@@ -485,7 +488,12 @@ export class DataLayer {
485488
requestVariables,
486489
);
487490

488-
return response.applications ?? [];
491+
return (
492+
response.applications.map((application) => {
493+
application.project.metadata = application.metadata.application.project;
494+
return application;
495+
}) ?? []
496+
);
489497
}
490498

491499
/**
@@ -795,19 +803,25 @@ export class DataLayer {
795803
},
796804
);
797805

798-
return response.donations.filter((donation) => {
799-
if (donation.round.strategyName !== "allov2.DirectAllocationStrategy") {
800-
return (
801-
donation.application !== null &&
802-
donation.application?.project !== null
803-
);
804-
} else {
805-
return (
806-
// DirectAllocationStrategy donations are not linked to applications
807-
donation.application === null
808-
);
809-
}
810-
});
806+
return response.donations
807+
.filter((donation) => {
808+
if (donation.round.strategyName !== "allov2.DirectAllocationStrategy") {
809+
return (
810+
donation.application !== null &&
811+
donation.application?.project !== null
812+
);
813+
} else {
814+
return (
815+
// DirectAllocationStrategy donations are not linked to applications
816+
donation.application === null
817+
);
818+
}
819+
})
820+
.map((donation) => {
821+
donation.application.project.metadata =
822+
donation.application.metadata.application.project;
823+
return donation;
824+
});
811825
}
812826

813827
async getPayoutsByChainIdRoundIdProjectId(args: {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,11 @@ export type Contribution = {
790790
strategyName: RoundPayoutType;
791791
};
792792
application: {
793+
metadata: {
794+
application: {
795+
project: ProjectMetadata & { id: string };
796+
};
797+
};
793798
project: {
794799
name: string;
795800
metadata?: ProjectMetadata;

packages/data-layer/src/queries.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ export const getApprovedApplication = gql`
332332
project {
333333
tags
334334
id
335-
metadata
336335
anchorAddress
337336
}
338337
}
@@ -371,7 +370,6 @@ export const getApplicationsForExplorer = gql`
371370
project {
372371
tags
373372
id
374-
metadata
375373
anchorAddress
376374
}
377375
}
@@ -689,7 +687,7 @@ export const getRoundForManager = gql`
689687
query getRoundForManager($roundId: String!, $chainId: Int!) {
690688
rounds(
691689
limit: 1
692-
where: {
690+
where: {
693691
id: { _eq: $roundId },
694692
chainId: { _eq: $chainId },
695693
roundMetadata: { _isNull: false }
@@ -723,7 +721,7 @@ export const getRoundsForManagerByAddress = gql`
723721
limit: 100
724722
where: {
725723
roundMetadata: { _isNull: false },
726-
chainId: { _in: $chainIds},
724+
chainId: { _in: $chainIds},
727725
roundRoles: {
728726
address: {
729727
_eq: $address
@@ -771,7 +769,6 @@ export const getRoundForExplorer = gql`
771769
anchorAddress
772770
project {
773771
id
774-
metadata
775772
anchorAddress
776773
}
777774
}
@@ -805,9 +802,9 @@ export const getDonationsByDonorAddress = gql`
805802
strategyName
806803
}
807804
application {
805+
metadata
808806
project {
809807
name
810-
metadata
811808
projectType
812809
}
813810
}

packages/grant-explorer/src/features/collections/CollectionCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommunityCollection } from "./community";
2-
import { Badge, BasicCard, CardHeader } from "../common/styles";
2+
import { BasicCard, CardHeader } from "../common/styles";
33
import { CollectionBanner } from "../discovery/CardBanner";
44
import { collectionPath } from "common/src/routes/explorer";
55

packages/grant-explorer/src/features/discovery/RoundCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from "common";
77
import { getDaysLeft, getRoundStates } from "../api/utils";
88
import {
9-
Badge,
109
BasicCard,
1110
CardContent,
1211
CardDescription,

packages/grant-explorer/src/features/projects/__tests__/ViewProject.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { formatDateWithOrdinal } from "common";
55
import { useProject } from "../hooks/useProject";
66
import { beforeEach, expect, Mock } from "vitest";
77
import { DataLayer, v2Project } from "data-layer";
8-
import { mock } from "@wagmi/core";
98

109
vi.mock("../../common/Navbar");
1110
vi.mock("../../common/Auth");

packages/grant-explorer/src/features/round/ViewRoundPage/ProjectCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Link } from "react-router-dom";
2-
import { renderToPlainText, useTokenPrice, TToken } from "common";
2+
import { renderToPlainText } from "common";
33

44
import { CartProject, Project, Round } from "../../api/types";
55

packages/grant-explorer/src/features/round/__tests__/ViewProjectDetails.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ const expectedProject: Application = {
7777
id: faker.finance.ethereumAddress(),
7878
metadata: {
7979
application: {
80+
project: {
81+
id: faker.finance.ethereumAddress(),
82+
createdAt: Date.now(),
83+
title: "Project test",
84+
description: "Best project in the world",
85+
website: "test.com",
86+
owners: [],
87+
bannerImg: "banner!",
88+
logoImg: "logo!",
89+
projectTwitter: "twitter.com/project",
90+
projectGithub: "github.com/project",
91+
userGithub: "github.com/user",
92+
lastUpdated: 0,
93+
credentials: {},
94+
},
8095
answers: [
8196
{
8297
answer: "never gonna give you up",

0 commit comments

Comments
 (0)