Skip to content

fix: canonical metadata #3787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions packages/data-layer/src/data-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@ export class DataLayer {
return null;
}

return response.applications[0];
const application = response.applications[0];
application.project.metadata = application.metadata.application.project;

return application;
}

async getApplicationsForExplorer({
Expand All @@ -485,7 +488,12 @@ export class DataLayer {
requestVariables,
);

return response.applications ?? [];
return (
response.applications.map((application) => {
application.project.metadata = application.metadata.application.project;
return application;
}) ?? []
);
}

/**
Expand Down Expand Up @@ -795,19 +803,25 @@ export class DataLayer {
},
);

return response.donations.filter((donation) => {
if (donation.round.strategyName !== "allov2.DirectAllocationStrategy") {
return (
donation.application !== null &&
donation.application?.project !== null
);
} else {
return (
// DirectAllocationStrategy donations are not linked to applications
donation.application === null
);
}
});
return response.donations
.filter((donation) => {
if (donation.round.strategyName !== "allov2.DirectAllocationStrategy") {
return (
donation.application !== null &&
donation.application?.project !== null
);
} else {
return (
// DirectAllocationStrategy donations are not linked to applications
donation.application === null
);
}
})
.map((donation) => {
donation.application.project.metadata =
donation.application.metadata.application.project;
return donation;
});
}

async getPayoutsByChainIdRoundIdProjectId(args: {
Expand Down
5 changes: 5 additions & 0 deletions packages/data-layer/src/data.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,11 @@ export type Contribution = {
strategyName: RoundPayoutType;
};
application: {
metadata: {
application: {
project: ProjectMetadata & { id: string };
};
};
project: {
name: string;
metadata?: ProjectMetadata;
Expand Down
9 changes: 3 additions & 6 deletions packages/data-layer/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ export const getApprovedApplication = gql`
project {
tags
id
metadata
anchorAddress
}
}
Expand Down Expand Up @@ -371,7 +370,6 @@ export const getApplicationsForExplorer = gql`
project {
tags
id
metadata
anchorAddress
}
}
Expand Down Expand Up @@ -689,7 +687,7 @@ export const getRoundForManager = gql`
query getRoundForManager($roundId: String!, $chainId: Int!) {
rounds(
limit: 1
where: {
where: {
id: { _eq: $roundId },
chainId: { _eq: $chainId },
roundMetadata: { _isNull: false }
Expand Down Expand Up @@ -723,7 +721,7 @@ export const getRoundsForManagerByAddress = gql`
limit: 100
where: {
roundMetadata: { _isNull: false },
chainId: { _in: $chainIds},
chainId: { _in: $chainIds},
roundRoles: {
address: {
_eq: $address
Expand Down Expand Up @@ -771,7 +769,6 @@ export const getRoundForExplorer = gql`
anchorAddress
project {
id
metadata
anchorAddress
}
}
Expand Down Expand Up @@ -805,9 +802,9 @@ export const getDonationsByDonorAddress = gql`
strategyName
}
application {
metadata
project {
name
metadata
projectType
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommunityCollection } from "./community";
import { Badge, BasicCard, CardHeader } from "../common/styles";
import { BasicCard, CardHeader } from "../common/styles";
import { CollectionBanner } from "../discovery/CardBanner";
import { collectionPath } from "common/src/routes/explorer";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from "common";
import { getDaysLeft, getRoundStates } from "../api/utils";
import {
Badge,
BasicCard,
CardContent,
CardDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { formatDateWithOrdinal } from "common";
import { useProject } from "../hooks/useProject";
import { beforeEach, expect, Mock } from "vitest";
import { DataLayer, v2Project } from "data-layer";
import { mock } from "@wagmi/core";

vi.mock("../../common/Navbar");
vi.mock("../../common/Auth");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from "react-router-dom";
import { renderToPlainText, useTokenPrice, TToken } from "common";
import { renderToPlainText } from "common";

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ const expectedProject: Application = {
id: faker.finance.ethereumAddress(),
metadata: {
application: {
project: {
id: faker.finance.ethereumAddress(),
createdAt: Date.now(),
title: "Project test",
description: "Best project in the world",
website: "test.com",
owners: [],
bannerImg: "banner!",
logoImg: "logo!",
projectTwitter: "twitter.com/project",
projectGithub: "github.com/project",
userGithub: "github.com/user",
lastUpdated: 0,
credentials: {},
},
answers: [
{
answer: "never gonna give you up",
Expand Down