diff --git a/.example.env b/.example.env index ca2d6f22bf..8f1a8414d8 100644 --- a/.example.env +++ b/.example.env @@ -62,3 +62,5 @@ DB_PROJECTS_WEBHOOK_URL= # Discord Webhook URL for /contact page. CONTACT_WEBHOOK_URL= + +NEXT_PUBLIC_V4_ENABLED=false \ No newline at end of file diff --git a/src/lib/api/supabase/projects/api.ts b/src/lib/api/supabase/projects/api.ts index 76b6193894..af682f74d6 100644 --- a/src/lib/api/supabase/projects/api.ts +++ b/src/lib/api/supabase/projects/api.ts @@ -50,14 +50,18 @@ export async function queryAllSGProjectsForServer() { chainId: readNetwork.chainId, } }) as unknown as Json>[] - const _resSepoliaV4 = resSepoliaV4.map(p => { - return { - ...p, - id: getSubgraphIdForProject(PV_V4, p.projectId), // Patch in the subgraph ID for V4 projects (to be consitent with legacy subgraph) - pv: PV_V4, // Patch in the PV for V4 projects, - chainId: sepolia.id, - } - }) as unknown as Json>[] + const _resSepoliaV4 = process.env.NEXT_PUBLIC_V4_ENABLED + ? (resSepoliaV4.map(p => { + return { + ...p, + id: getSubgraphIdForProject(PV_V4, p.projectId), // Patch in the subgraph ID for V4 projects (to be consitent with legacy subgraph) + pv: PV_V4, // Patch in the PV for V4 projects, + chainId: sepolia.id, + } + }) as unknown as Json< + Pick + >[]) + : [] return [..._res, ..._resSepoliaV4].map(formatSGProjectForDB) } diff --git a/src/pages/api/projects/trending.ts b/src/pages/api/projects/trending.ts index e4c122e1c0..095a215f3d 100644 --- a/src/pages/api/projects/trending.ts +++ b/src/pages/api/projects/trending.ts @@ -63,9 +63,11 @@ const handler: NextApiHandler = async (req, res) => { const projects = [ ...projectsRes.data.projects, - ...v4SepoliaProjectsRes.data.projects.map(p => { - return { ...p, chainId: sepolia.id, pv: PV_V4 } - }), + ...(process.env.NEXT_PUBLIC_V4_ENABLED + ? v4SepoliaProjectsRes.data.projects.map(p => { + return { ...p, chainId: sepolia.id, pv: PV_V4 } + }) + : []), ] try {