From 954284ddeab48198d345180e4cfbb2d328f6ba3c Mon Sep 17 00:00:00 2001 From: Mark Grothe Date: Fri, 3 Jan 2025 10:29:55 -0600 Subject: [PATCH] fix: provide fallback rpcs (#2303) --- src/ui-config/wagmiConfig.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ui-config/wagmiConfig.ts b/src/ui-config/wagmiConfig.ts index 40a2056d5e..6f5e6e5e4c 100644 --- a/src/ui-config/wagmiConfig.ts +++ b/src/ui-config/wagmiConfig.ts @@ -8,7 +8,7 @@ import { networkConfigs, } from 'src/utils/marketsAndNetworksConfig'; import { type Chain } from 'viem'; -import { createConfig, CreateConfigParameters, injected } from 'wagmi'; +import { createConfig, CreateConfigParameters, http, injected } from 'wagmi'; import { arbitrum, arbitrumSepolia, @@ -88,9 +88,17 @@ const cypressConfig = createConfig( }) ); +const getTransport = (chainId: number) => { + return networkConfigs[chainId].publicJsonRPCUrl[0]; +}; + +const buildTransports = (chains: CreateConfigParameters['chains']) => + Object.fromEntries(chains.map((chain) => [chain.id, http(getTransport(chain.id))])); + const prodConfig = createConfig( getDefaultConfig({ chains: ENABLE_TESTNET ? testnetChains : prodChains, + transports: ENABLE_TESTNET ? undefined : buildTransports(prodChains), ...defaultConfig, }) );