diff --git a/src/config.ts b/src/config.ts index f5100770..1dfabe7e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -55,6 +55,19 @@ export const semaphoreEthersChain = (): string => { } }; +/** + * Get the RPC URL based on the network we are connected to + * @returns the alchemy RPC URL + */ +export const getRPCURL = (): string | undefined => { + switch (process.env.NEXT_PUBLIC_CHAIN_NAME) { + case "optimismSepolia": + return `https://opt-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID!}`; + default: + return undefined; + } +}; + export const config = { logoUrl: "/Logo.svg", pageSize: 3 * 4, diff --git a/src/features/applications/components/ImpactTags.tsx b/src/features/applications/components/ImpactTags.tsx index a40c0cba..aa08efab 100644 --- a/src/features/applications/components/ImpactTags.tsx +++ b/src/features/applications/components/ImpactTags.tsx @@ -14,7 +14,6 @@ export const ImpactTags = (): JSX.Element => { control, }); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition const selected = watch("impactCategory") ?? []; const error = formState.errors.impactCategory; diff --git a/src/providers/index.tsx b/src/providers/index.tsx index b412660c..aa45e622 100644 --- a/src/providers/index.tsx +++ b/src/providers/index.tsx @@ -63,9 +63,7 @@ function createWagmiConfig() { ssr: false, chains: activeChains as unknown as readonly [Chain, ...Chain[]], transports: { - [appConfig.config.network.id]: http( - `https://opt-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID!}`, - ), + [appConfig.config.network.id]: http(appConfig.getRPCURL()), }, }); diff --git a/src/utils/semaphore.ts b/src/utils/semaphore.ts index b660e489..49ad980b 100644 --- a/src/utils/semaphore.ts +++ b/src/utils/semaphore.ts @@ -3,7 +3,7 @@ import { SemaphoreEthers } from "@semaphore-protocol/data"; import { AbiCoder, JsonRpcSigner } from "ethers"; import { getSemaphoreGatekeeperData } from "maci-cli/sdk"; -import { config, semaphoreEthersChain } from "~/config"; +import { config, getRPCURL, semaphoreEthersChain } from "~/config"; /** * Encodes the Semaphore Proof to be sent on chain @@ -33,7 +33,7 @@ export const getSemaphoreProof = async (signer: JsonRpcSigner, identity: Identit maciAddress: config.maciAddress!, }); - const semaphore = new SemaphoreEthers(semaphoreEthersChain(), { + const semaphore = new SemaphoreEthers(getRPCURL() ?? semaphoreEthersChain(), { address: semaphoreContractAddress, });