From cc61e94ea63b34065aebdd0a980464f4de7f4ce7 Mon Sep 17 00:00:00 2001 From: Rinat Date: Tue, 10 Dec 2024 22:34:20 +0100 Subject: [PATCH] chore: move default alchemy api key to the variable --- packages/nextjs/scaffold.config.ts | 4 +++- packages/nextjs/services/web3/wagmiConfig.tsx | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/nextjs/scaffold.config.ts b/packages/nextjs/scaffold.config.ts index 86c737a21..356076851 100644 --- a/packages/nextjs/scaffold.config.ts +++ b/packages/nextjs/scaffold.config.ts @@ -8,6 +8,8 @@ export type ScaffoldConfig = { onlyLocalBurnerWallet: boolean; }; +export const DEFAULT_ALCHEMY_API_KEY = "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF"; + const scaffoldConfig = { // The networks on which your DApp is live targetNetworks: [chains.hardhat], @@ -20,7 +22,7 @@ const scaffoldConfig = { // You can get your own at https://dashboard.alchemyapi.io // It's recommended to store it in an env variable: // .env.local for local testing, and in the Vercel/system env config for live apps. - alchemyApiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY || "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF", + alchemyApiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY || DEFAULT_ALCHEMY_API_KEY, // This is ours WalletConnect's default project ID. // You can get your own at https://cloud.walletconnect.com diff --git a/packages/nextjs/services/web3/wagmiConfig.tsx b/packages/nextjs/services/web3/wagmiConfig.tsx index ae0d03918..37253daf4 100644 --- a/packages/nextjs/services/web3/wagmiConfig.tsx +++ b/packages/nextjs/services/web3/wagmiConfig.tsx @@ -2,7 +2,7 @@ import { wagmiConnectors } from "./wagmiConnectors"; import { Chain, createClient, fallback, http } from "viem"; import { hardhat, mainnet } from "viem/chains"; import { createConfig } from "wagmi"; -import scaffoldConfig from "~~/scaffold.config"; +import scaffoldConfig, { DEFAULT_ALCHEMY_API_KEY } from "~~/scaffold.config"; import { getAlchemyHttpUrl } from "~~/utils/scaffold-eth"; const { targetNetworks } = scaffoldConfig; @@ -21,7 +21,7 @@ export const wagmiConfig = createConfig({ const alchemyHttpUrl = getAlchemyHttpUrl(chain.id); if (alchemyHttpUrl) { - const isUsingDefaultKey = scaffoldConfig.alchemyApiKey === "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF"; + const isUsingDefaultKey = scaffoldConfig.alchemyApiKey === DEFAULT_ALCHEMY_API_KEY; // If using default Scaffold-ETH 2 API key, we prioritize the default RPC rpcFallbacks = isUsingDefaultKey ? [http(), http(alchemyHttpUrl)] : [http(alchemyHttpUrl), http()]; }