From 496c2f5c5dcffcd0c6e47d32f11849aaea4b19dd Mon Sep 17 00:00:00 2001 From: "frankind.eth" Date: Tue, 19 Mar 2024 12:16:00 -0300 Subject: [PATCH] fix: add fallback rpc url --- lib/client/constants.ts | 2 ++ lib/wallet/wallet-config.ts | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/client/constants.ts b/lib/client/constants.ts index 64613a31..30526369 100644 --- a/lib/client/constants.ts +++ b/lib/client/constants.ts @@ -148,6 +148,8 @@ export const getAPIKeyForNetwork: Map = new Map([ [ChainInfo.MUMBAI.id, process.env.NEXT_PUBLIC_ALCHEMY_MUMBAI_KEY], ]); +export const ALCHEMY_PUBLIC_RPC = "https://eth-mainnet.g.alchemy.com/v2/demo"; + export const getCurrentNetworkHttpUrl = (chainId: number) => { const httpUrl = getRpcHttpUrlForNetwork.get(chainId); diff --git a/lib/wallet/wallet-config.ts b/lib/wallet/wallet-config.ts index 3c45b12d..f34d9b05 100644 --- a/lib/wallet/wallet-config.ts +++ b/lib/wallet/wallet-config.ts @@ -1,4 +1,7 @@ -import { getCurrentNetworkHttpUrl } from "../client/constants"; +import { + ALCHEMY_PUBLIC_RPC, + getCurrentNetworkHttpUrl, +} from "../client/constants"; import { sepolia } from "@wagmi/core/chains"; import { configureChains, createConfig } from "wagmi"; import { @@ -17,7 +20,7 @@ export const { chains, webSocketPublicClient, publicClient } = configureChains( [ jsonRpcProvider({ rpc: (chain) => ({ - http: getCurrentNetworkHttpUrl(chain.id), + http: getCurrentNetworkHttpUrl(chain.id) || ALCHEMY_PUBLIC_RPC, }), }), ],