Skip to content

Commit

Permalink
fix: add fallback rpc url
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoAguzzi committed Mar 19, 2024
1 parent 269b66e commit 496c2f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/client/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export const getAPIKeyForNetwork: Map<number, string | undefined> = 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);

Expand Down
7 changes: 5 additions & 2 deletions lib/wallet/wallet-config.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -17,7 +20,7 @@ export const { chains, webSocketPublicClient, publicClient } = configureChains(
[
jsonRpcProvider({
rpc: (chain) => ({
http: getCurrentNetworkHttpUrl(chain.id),
http: getCurrentNetworkHttpUrl(chain.id) || ALCHEMY_PUBLIC_RPC,
}),
}),
],
Expand Down

0 comments on commit 496c2f5

Please sign in to comment.