From 81117f118fe2b0c6a451e97e4fc64f7bdbda753d Mon Sep 17 00:00:00 2001 From: cedoor Date: Thu, 27 Jun 2024 14:15:32 +0100 Subject: [PATCH] fix(web-app): add infura api key (project id) --- apps/web-app/.env.production | 1 + apps/web-app/src/app/api/feedback/route.ts | 18 +++--------------- apps/web-app/src/app/api/join/route.ts | 18 +++--------------- apps/web-app/src/context/SemaphoreContext.tsx | 6 ++++-- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/apps/web-app/.env.production b/apps/web-app/.env.production index d07a05d..a612295 100644 --- a/apps/web-app/.env.production +++ b/apps/web-app/.env.production @@ -1,4 +1,5 @@ NEXT_PUBLIC_DEFAULT_NETWORK=sepolia +NEXT_PUBLIC_INFURA_API_KEY=abf67af1010b4b8d877e04244f1eac3d NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS=0xAB851D8cc255A244c58Ae152bCa8d2E55BF013d6 NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS=0x0A09FB3f63c13F1C54F2fA41AFB1e7a98cffc774 NEXT_PUBLIC_OPENZEPPELIN_AUTOTASK_WEBHOOK=https://api.defender.openzeppelin.com/actions/20fce2ae-844b-4ec0-a6a2-90a3350a9d2c/runs/webhook/303216d1-fa7d-4fca-8c5b-7ba1ba544fc7/2T7i9xrkZA5j37hoaQLUuw diff --git a/apps/web-app/src/app/api/feedback/route.ts b/apps/web-app/src/app/api/feedback/route.ts index 3b19e1e..45698f5 100644 --- a/apps/web-app/src/app/api/feedback/route.ts +++ b/apps/web-app/src/app/api/feedback/route.ts @@ -3,26 +3,14 @@ import { NextRequest } from "next/server" import Feedback from "../../../../contract-artifacts/Feedback.json" export async function POST(req: NextRequest) { - if (typeof process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS !== "string") { - throw new Error("Please, define NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS in your .env file") - } - - if (typeof process.env.NEXT_PUBLIC_DEFAULT_NETWORK !== "string") { - throw new Error("Please, define NEXT_PUBLIC_DEFAULT_NETWORK in your .env file") - } - - if (typeof process.env.INFURA_API_KEY !== "string") { - throw new Error("Please, define INFURA_API_KEY in your .env file") - } - if (typeof process.env.ETHEREUM_PRIVATE_KEY !== "string") { throw new Error("Please, define ETHEREUM_PRIVATE_KEY in your .env file") } const ethereumPrivateKey = process.env.ETHEREUM_PRIVATE_KEY - const ethereumNetwork = process.env.NEXT_PUBLIC_DEFAULT_NETWORK - const infuraApiKey = process.env.INFURA_API_KEY - const contractAddress = process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS + const ethereumNetwork = process.env.NEXT_PUBLIC_DEFAULT_NETWORK as string + const infuraApiKey = process.env.NEXT_PUBLIC_INFURA_API_KEY as string + const contractAddress = process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS as string const provider = ethereumNetwork === "localhost" diff --git a/apps/web-app/src/app/api/join/route.ts b/apps/web-app/src/app/api/join/route.ts index 126d5d9..1d0ee24 100644 --- a/apps/web-app/src/app/api/join/route.ts +++ b/apps/web-app/src/app/api/join/route.ts @@ -3,26 +3,14 @@ import { NextRequest } from "next/server" import Feedback from "../../../../contract-artifacts/Feedback.json" export async function POST(req: NextRequest) { - if (typeof process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS !== "string") { - throw new Error("Please, define NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS in your .env file") - } - - if (typeof process.env.NEXT_PUBLIC_DEFAULT_NETWORK !== "string") { - throw new Error("Please, define NEXT_PUBLIC_DEFAULT_NETWORK in your .env file") - } - - if (typeof process.env.INFURA_API_KEY !== "string") { - throw new Error("Please, define INFURA_API_KEY in your .env file") - } - if (typeof process.env.ETHEREUM_PRIVATE_KEY !== "string") { throw new Error("Please, define ETHEREUM_PRIVATE_KEY in your .env file") } const ethereumPrivateKey = process.env.ETHEREUM_PRIVATE_KEY - const ethereumNetwork = process.env.NEXT_PUBLIC_DEFAULT_NETWORK - const infuraApiKey = process.env.INFURA_API_KEY - const contractAddress = process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS + const ethereumNetwork = process.env.NEXT_PUBLIC_DEFAULT_NETWORK as string + const infuraApiKey = process.env.NEXT_PUBLIC_INFURA_API_KEY as string + const contractAddress = process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS as string const provider = ethereumNetwork === "localhost" diff --git a/apps/web-app/src/context/SemaphoreContext.tsx b/apps/web-app/src/context/SemaphoreContext.tsx index f10562b..425b545 100644 --- a/apps/web-app/src/context/SemaphoreContext.tsx +++ b/apps/web-app/src/context/SemaphoreContext.tsx @@ -30,7 +30,8 @@ export const SemaphoreContextProvider: React.FC = ({ children }) const refreshUsers = useCallback(async (): Promise => { const semaphore = new SemaphoreEthers(ethereumNetwork, { - address: process.env.NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS + address: process.env.NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS, + projectId: process.env.NEXT_PUBLIC_INFURA_API_KEY }) const members = await semaphore.getGroupMembers(process.env.NEXT_PUBLIC_GROUP_ID as string) @@ -47,7 +48,8 @@ export const SemaphoreContextProvider: React.FC = ({ children }) const refreshFeedback = useCallback(async (): Promise => { const semaphore = new SemaphoreEthers(ethereumNetwork, { - address: process.env.NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS + address: process.env.NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS, + projectId: process.env.NEXT_PUBLIC_INFURA_API_KEY }) const proofs = await semaphore.getGroupValidatedProofs(process.env.NEXT_PUBLIC_GROUP_ID as string)