@@ -47,7 +51,7 @@ const ProjectDetails = ({
{attestation?.name}
-
+ {appState === EAppState.VOTING && }
diff --git a/src/pages/projects/[projectId]/Project.tsx b/src/pages/projects/[projectId]/Project.tsx
index caf6ef72..b31e2552 100644
--- a/src/pages/projects/[projectId]/Project.tsx
+++ b/src/pages/projects/[projectId]/Project.tsx
@@ -2,7 +2,7 @@ import { type GetServerSideProps } from "next";
import { useMemo } from "react";
import { ReviewBar } from "~/features/applications/components/ReviewBar";
-import { useApprovedApplications } from "~/features/applications/hooks/useApprovedApplications";
+import { useLatestApprovedApplications } from "~/features/applications/hooks/useApprovedApplications";
import ProjectDetails from "~/features/projects/components/ProjectDetails";
import { useProjectById } from "~/features/projects/hooks/useProjects";
import { LayoutWithSidebar } from "~/layouts/DefaultLayout";
@@ -15,7 +15,7 @@ export interface IProjectDetailsProps {
const ProjectDetailsPage = ({ projectId = "" }: IProjectDetailsProps): JSX.Element => {
const projects = useProjectById(projectId);
- const approved = useApprovedApplications();
+ const approved = useLatestApprovedApplications();
const { name } = projects.data?.[0] ?? {};
const appState = useAppState();
diff --git a/src/server/api/routers/applications.ts b/src/server/api/routers/applications.ts
index 2d457501..7a3c9b64 100644
--- a/src/server/api/routers/applications.ts
+++ b/src/server/api/routers/applications.ts
@@ -2,7 +2,7 @@ import { z } from "zod";
import { config, eas } from "~/config";
import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";
-import { createDataFilter, fetchAttestations } from "~/utils/fetchAttestations";
+import { createDataFilter, fetchAttestations, fetchAttestationsWithoutCache } from "~/utils/fetchAttestations";
export const FilterSchema = z.object({
limit: z.number().default(3 * 8),
@@ -19,6 +19,15 @@ export const applicationsRouter = createTRPCRouter({
},
}),
),
+ latestApprovals: publicProcedure.input(z.object({ ids: z.array(z.string()).optional() })).query(async ({ input }) =>
+ fetchAttestationsWithoutCache([eas.schemas.approval], {
+ where: {
+ attester: { equals: config.admin },
+ refUID: input.ids ? { in: input.ids } : undefined,
+ AND: [createDataFilter("type", "bytes32", "application"), createDataFilter("round", "bytes32", config.roundId)],
+ },
+ }),
+ ),
list: publicProcedure.input(FilterSchema).query(async () =>
fetchAttestations([eas.schemas.metadata], {
orderBy: [{ time: "desc" }],
diff --git a/src/utils/fetchAttestations.ts b/src/utils/fetchAttestations.ts
index dfc5b860..b7e02632 100644
--- a/src/utils/fetchAttestations.ts
+++ b/src/utils/fetchAttestations.ts
@@ -7,6 +7,8 @@ import { createCachedFetch } from "./fetch";
const cachedFetch = createCachedFetch({ ttl: 1000 * 60 * 10 });
+const uncachedFetch = createCachedFetch({ ttl: 0 });
+
export interface AttestationWithMetadata {
id: string;
refUID: string;
@@ -85,6 +87,29 @@ export async function fetchAttestations(schema: string[], filter?: AttestationsF
}).then((r) => r.data.attestations.map(parseAttestation));
}
+export async function fetchAttestationsWithoutCache(
+ schema: string[],
+ filter?: AttestationsFilter,
+): Promise
{
+ const startsAt = config.startsAt && Math.floor(+config.startsAt / 1000);
+
+ return uncachedFetch<{ attestations: AttestationWithMetadata[] }>(eas.url, {
+ method: "POST",
+ body: JSON.stringify({
+ query: AttestationsQuery,
+ variables: {
+ ...filter,
+ where: {
+ schemaId: { in: schema },
+ revoked: { equals: false },
+ time: { gte: startsAt },
+ ...filter?.where,
+ },
+ },
+ }),
+ }).then((r) => r.data.attestations.map(parseAttestation));
+}
+
export async function fetchApprovedVoter(address: string): Promise {
if (config.skipApprovedVoterCheck) {
return true;