From d85d8c713b2db0d49d09ed1d9f362b7cf9f4890e Mon Sep 17 00:00:00 2001 From: Dimitar Petkov <796902+2dpetkov@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:50:09 +0300 Subject: [PATCH 1/3] replace the Alchemy API Key with a proxy URL --- .env.example | 2 -- README.md | 1 - public/configs/v1/env.json | 16 ++++++++++++++ src/lib/wagmi.ts | 43 +++++++++++++++++++++----------------- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.env.example b/.env.example index 30caf6923d..42cf0b16d7 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,5 @@ VITE_BASE_URL= -VITE_ALCHEMY_API_KEY= - VITE_PRIVY_APP_ID= VITE_PRIVY_APP_CLIENT_ID= diff --git a/README.md b/README.md index 805c36824d..31e4bfe2f5 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,6 @@ You'll need to provide a Wallet Connect project id to enable onboarding and wall Set environment variables via `.env`. - `VITE_BASE_URL` (required): The base URL of the deployment (e.g., `https://www.example.com`). -- `VITE_ALCHEMY_API_KEY` (optional): Add an Alchemy API key for EVM interactions; the app will fall back to public RPCs if not provided. - `VITE_PK_ENCRYPTION_KEY` (optional): AES encryption key used for signature obfuscation; necessary for enabling the "Remember Me" feature. - `VITE_V3_TOKEN_ADDRESS` (optional): Address of the V3 $DYDX token. - `VITE_TOKEN_MIGRATION_URI` (optional): The URL of the token migration website. diff --git a/public/configs/v1/env.json b/public/configs/v1/env.json index 5f42b3d4bd..d4206aabf3 100644 --- a/public/configs/v1/env.json +++ b/public/configs/v1/env.json @@ -453,6 +453,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -499,6 +500,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -542,6 +544,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -588,6 +591,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -634,6 +638,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -679,6 +684,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -724,6 +730,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -781,6 +788,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -825,6 +833,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -874,6 +883,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -920,6 +930,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -966,6 +977,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -1012,6 +1024,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -1058,6 +1071,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -1104,6 +1118,7 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", + "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -1151,6 +1166,7 @@ ], "skip": "[Skip endpoint for mainnet]", "solanaRpcUrl": "[Solana rpc url for mainnet]", + "alchemyRpcProxyUrl": "[Alchemy rpc proxy url for mainnet]", "metadataService": "[metadata service endpoint for mainnet]", "nobleValidator": "[noble validator endpoint for mainnet]", "osmosisValidator": "[osmosis validator endpoint for mainnet]", diff --git a/src/lib/wagmi.ts b/src/lib/wagmi.ts index e4cfc9d946..b30bd9b800 100644 --- a/src/lib/wagmi.ts +++ b/src/lib/wagmi.ts @@ -109,34 +109,44 @@ export enum ChainId { AVALANCHE_FUJI = '43113', } +const defaultSelectedNetwork = getLocalStorage({ + key: LocalStorageKey.SelectedNetwork, + defaultValue: DEFAULT_APP_ENVIRONMENT, + validateFn: validateAgainstAvailableEnvironments, +}); + export const getAlchemyRPCUrlForChainId = (chainId: ChainId) => { - const alchemyKey = import.meta.env.VITE_ALCHEMY_API_KEY; - if (!alchemyKey) return undefined; + const selectedNetworkEndpoints = ENVIRONMENT_CONFIG_MAP[defaultSelectedNetwork].endpoints as { + alchemyRpcProxyUrl?: string; + }; + const alchemyRpcProxyUrl = selectedNetworkEndpoints.alchemyRpcProxyUrl; + if (!alchemyRpcProxyUrl) return undefined; + switch (chainId) { case ChainId.ETH_MAINNET: - return `https://eth-mainnet.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/eth-mainnet/v2`; case ChainId.ETH_SEPOLIA: - return `https://eth-sepolia.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/eth-sepolia/v2`; case ChainId.POLYGON_MAINNET: - return `https://polygon-mainnet.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/polygon-mainnet/v2`; case ChainId.POLYGON_MUMBAI: - return `https://polygon-amoy.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/polygon-amoy/v2`; case ChainId.OPT_MAINNET: - return `https://opt-mainnet.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/opt-mainnet/v2`; case ChainId.OPT_SEPOLIA: - return `https://opt-sepolia.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/opt-sepolia/v2`; case ChainId.ARB_MAINNET: - return `https://arb-mainnet.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/arb-mainnet/v2`; case ChainId.ARB_SEPOLIA: - return `https://arb-sepolia.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/arb-sepolia/v2`; case ChainId.BASE_MAINNET: - return `https://base-mainnet.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/base-mainnet/v2`; case ChainId.BASE_SEPOLIA: - return `https://base-sepolia.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/base-sepolia/v2`; case ChainId.AVALANCHE_MAINNET: - return `https://avax-mainnet.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/avax-mainnet/v2`; case ChainId.AVALANCHE_FUJI: - return `https://avax-fuji.g.alchemy.com/v2/${alchemyKey}`; + return `${alchemyRpcProxyUrl}/avax-fuji/v2`; default: return undefined; } @@ -165,11 +175,6 @@ const RPCTransports = [mainnet, ...WAGMI_SUPPORTED_CHAINS].reduce( {} as Record> ); -const defaultSelectedNetwork = getLocalStorage({ - key: LocalStorageKey.SelectedNetwork, - defaultValue: DEFAULT_APP_ENVIRONMENT, - validateFn: validateAgainstAvailableEnvironments, -}); const defaultChainId = Number(ENVIRONMENT_CONFIG_MAP[defaultSelectedNetwork].ethereumChainId); export const privyConfig: PrivyClientConfig = { From a97f6f8c6925c2eb9e8682e78aa29009013f1478 Mon Sep 17 00:00:00 2001 From: Dimitar Petkov <796902+2dpetkov@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:58:30 +0300 Subject: [PATCH 2/3] switch to using env variable --- .env.example | 2 ++ README.md | 1 + public/configs/v1/env.json | 16 ---------------- src/lib/wagmi.ts | 5 +---- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index 42cf0b16d7..98e4d9707b 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,7 @@ VITE_BASE_URL= +VITE_ALCHEMY_RPC_PROXY_URL= + VITE_PRIVY_APP_ID= VITE_PRIVY_APP_CLIENT_ID= diff --git a/README.md b/README.md index 31e4bfe2f5..0d55f1411c 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ You'll need to provide a Wallet Connect project id to enable onboarding and wall Set environment variables via `.env`. - `VITE_BASE_URL` (required): The base URL of the deployment (e.g., `https://www.example.com`). +- `VITE_ALCHEMY_RPC_PROXY_URL` (optional): Base URL of your Alchemy proxy for EVM RPC requests; the proxy injects the secret Alchemy API key so it is not exposed in the web app (e.g., `https://proxy.example.com`). - `VITE_PK_ENCRYPTION_KEY` (optional): AES encryption key used for signature obfuscation; necessary for enabling the "Remember Me" feature. - `VITE_V3_TOKEN_ADDRESS` (optional): Address of the V3 $DYDX token. - `VITE_TOKEN_MIGRATION_URI` (optional): The URL of the token migration website. diff --git a/public/configs/v1/env.json b/public/configs/v1/env.json index d4206aabf3..5f42b3d4bd 100644 --- a/public/configs/v1/env.json +++ b/public/configs/v1/env.json @@ -453,7 +453,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -500,7 +499,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -544,7 +542,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -591,7 +588,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -638,7 +634,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -684,7 +679,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -730,7 +724,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -788,7 +781,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -833,7 +825,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -883,7 +874,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", @@ -930,7 +920,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -977,7 +966,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -1024,7 +1012,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -1071,7 +1058,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -1118,7 +1104,6 @@ ], "skip": "https://api.skip.build", "solanaRpcUrl": "https://mainnet.helius-rpc.com/?api-key=b446d8fe-aa37-4457-bf61-c742aa0a1c95", - "alchemyRpcProxyUrl": "https://alchemy-proxy-web-mainnet-preview.infrastructure-34d.workers.dev/ ", "nobleValidator": "https://noble-testnet-rpc.polkachu.com/", "osmosisValidator": "https://rpc.osmotest5.osmosis.zone/", "metadataService": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1", @@ -1166,7 +1151,6 @@ ], "skip": "[Skip endpoint for mainnet]", "solanaRpcUrl": "[Solana rpc url for mainnet]", - "alchemyRpcProxyUrl": "[Alchemy rpc proxy url for mainnet]", "metadataService": "[metadata service endpoint for mainnet]", "nobleValidator": "[noble validator endpoint for mainnet]", "osmosisValidator": "[osmosis validator endpoint for mainnet]", diff --git a/src/lib/wagmi.ts b/src/lib/wagmi.ts index b30bd9b800..66dfd9441c 100644 --- a/src/lib/wagmi.ts +++ b/src/lib/wagmi.ts @@ -116,10 +116,7 @@ const defaultSelectedNetwork = getLocalStorage({ }); export const getAlchemyRPCUrlForChainId = (chainId: ChainId) => { - const selectedNetworkEndpoints = ENVIRONMENT_CONFIG_MAP[defaultSelectedNetwork].endpoints as { - alchemyRpcProxyUrl?: string; - }; - const alchemyRpcProxyUrl = selectedNetworkEndpoints.alchemyRpcProxyUrl; + const alchemyRpcProxyUrl = import.meta.env.VITE_ALCHEMY_RPC_PROXY_URL; if (!alchemyRpcProxyUrl) return undefined; switch (chainId) { From 7d7da3d4eb39609df7e88337452778f846bc624d Mon Sep 17 00:00:00 2001 From: Dimitar Petkov <796902+2dpetkov@users.noreply.github.com> Date: Thu, 23 Apr 2026 22:09:19 +0300 Subject: [PATCH 3/3] clean up --- src/lib/wagmi.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/wagmi.ts b/src/lib/wagmi.ts index 66dfd9441c..0754913eae 100644 --- a/src/lib/wagmi.ts +++ b/src/lib/wagmi.ts @@ -109,12 +109,6 @@ export enum ChainId { AVALANCHE_FUJI = '43113', } -const defaultSelectedNetwork = getLocalStorage({ - key: LocalStorageKey.SelectedNetwork, - defaultValue: DEFAULT_APP_ENVIRONMENT, - validateFn: validateAgainstAvailableEnvironments, -}); - export const getAlchemyRPCUrlForChainId = (chainId: ChainId) => { const alchemyRpcProxyUrl = import.meta.env.VITE_ALCHEMY_RPC_PROXY_URL; if (!alchemyRpcProxyUrl) return undefined; @@ -172,6 +166,11 @@ const RPCTransports = [mainnet, ...WAGMI_SUPPORTED_CHAINS].reduce( {} as Record> ); +const defaultSelectedNetwork = getLocalStorage({ + key: LocalStorageKey.SelectedNetwork, + defaultValue: DEFAULT_APP_ENVIRONMENT, + validateFn: validateAgainstAvailableEnvironments, +}); const defaultChainId = Number(ENVIRONMENT_CONFIG_MAP[defaultSelectedNetwork].ethereumChainId); export const privyConfig: PrivyClientConfig = {