From 46ee2ac0ae660678d8b83abf4ab69b4752a1f364 Mon Sep 17 00:00:00 2001 From: Ben Wolski Date: Mon, 22 Jul 2024 07:53:02 -0700 Subject: [PATCH] fix sepolia rpc endpoint --- src/ambient-utils/constants/index.ts | 5 +++++ .../constants/networks/ethereumSepolia.ts | 13 +++++++------ src/contexts/ChainDataContext.tsx | 13 ++++++++----- src/contexts/CrocEnvContext.tsx | 16 +++++++++++----- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/ambient-utils/constants/index.ts b/src/ambient-utils/constants/index.ts index 390986df45..7befedf046 100644 --- a/src/ambient-utils/constants/index.ts +++ b/src/ambient-utils/constants/index.ts @@ -68,6 +68,11 @@ export const SCROLL_RPC_URL = ? import.meta.env.VITE_SCROLL_RPC_URL : 'https://rpc.scroll.io/'; +export const SEPOLIA_RPC_URL = + import.meta.env.VITE_SEPOLIA_RPC_URL !== undefined + ? import.meta.env.VITE_SEPOLIA_RPC_URL + : 'https://ethereum-sepolia-rpc.publicnode.com'; + export const ALCHEMY_API_KEY = import.meta.env.VITE_ALCHEMY_API_KEY !== undefined ? import.meta.env.VITE_ALCHEMY_API_KEY diff --git a/src/ambient-utils/constants/networks/ethereumSepolia.ts b/src/ambient-utils/constants/networks/ethereumSepolia.ts index 8a0de28f33..bf5131e9a4 100644 --- a/src/ambient-utils/constants/networks/ethereumSepolia.ts +++ b/src/ambient-utils/constants/networks/ethereumSepolia.ts @@ -6,23 +6,24 @@ import { GCGO_TESTNET_URL } from '../gcgo'; import { Provider } from 'ethers'; import { bigIntToFloat } from '@crocswap-libs/sdk'; -const PROVIDER_KEY = - import.meta.env.NODE_ENV === 'test' - ? import.meta.env.PROVIDER_KEY - : import.meta.env.VITE_INFURA_KEY; +// const PROVIDER_KEY = +// import.meta.env.NODE_ENV === 'test' +// ? import.meta.env.PROVIDER_KEY +// : import.meta.env.VITE_INFURA_KEY; const chain = { chainId: 11155111, name: 'Sepolia', currency: 'ETH', - rpcUrl: 'https://rpc.sepolia.org', + rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com', explorerUrl: 'https://sepolia.etherscan.io', }; export const ethereumSepolia: NetworkIF = { chainId: '0xaa36a7', graphCacheUrl: GCGO_TESTNET_URL, - evmRpcUrl: 'https://sepolia.infura.io/v3/' + PROVIDER_KEY, + evmRpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com', + // evmRpcUrl: 'https://sepolia.infura.io/v3/' + PROVIDER_KEY, chain: chain, shouldPollBlock: false, marketData: '0x1', diff --git a/src/contexts/ChainDataContext.tsx b/src/contexts/ChainDataContext.tsx index 0c7b55d50d..c6bba112e0 100644 --- a/src/contexts/ChainDataContext.tsx +++ b/src/contexts/ChainDataContext.tsx @@ -13,6 +13,7 @@ import { IS_LOCAL_ENV, MAINNET_RPC_URL, SCROLL_RPC_URL, + SEPOLIA_RPC_URL, SHOULD_NON_CANDLE_SUBSCRIPTIONS_RECONNECT, supportedNetworks, } from '../ambient-utils/constants'; @@ -124,11 +125,13 @@ export const ChainDataContextProvider = (props: { async function pollBlockNum(): Promise { const nodeUrl = ['0x1'].includes(chainData.chainId) ? MAINNET_RPC_URL - : ['0x13e31'].includes(chainData.chainId) // use blast env variable for blast network - ? BLAST_RPC_URL - : ['0x82750'].includes(chainData.chainId) // use scroll env variable for scroll network - ? SCROLL_RPC_URL - : blockPollingUrl; + : ['0xaa36a7'].includes(chainData.chainId) + ? SEPOLIA_RPC_URL + : ['0x13e31'].includes(chainData.chainId) // use blast env variable for blast network + ? BLAST_RPC_URL + : ['0x82750'].includes(chainData.chainId) // use scroll env variable for scroll network + ? SCROLL_RPC_URL + : blockPollingUrl; // const nodeUrl = // chainData.nodeUrl.toLowerCase().includes('infura') && // import.meta.env.VITE_INFURA_KEY diff --git a/src/contexts/CrocEnvContext.tsx b/src/contexts/CrocEnvContext.tsx index d078614349..fff88cbea6 100644 --- a/src/contexts/CrocEnvContext.tsx +++ b/src/contexts/CrocEnvContext.tsx @@ -28,6 +28,7 @@ import { getDefaultPairForChain, BLAST_RPC_URL, MAINNET_RPC_URL, + SEPOLIA_RPC_URL, SCROLL_RPC_URL, } from '../ambient-utils/constants'; import { UserDataContext } from './UserDataContext'; @@ -77,6 +78,9 @@ const scrollProvider = new BatchedJsonRpcProvider(SCROLL_RPC_URL, 534352, { const blastProvider = new BatchedJsonRpcProvider(BLAST_RPC_URL, 81457, { staticNetwork: true, }); +const sepoliaProvider = new BatchedJsonRpcProvider(SEPOLIA_RPC_URL, 11155111, { + staticNetwork: true, +}); export const CrocEnvContextProvider = (props: { children: ReactNode }) => { const { cachedFetchTokenPrice } = useContext(CachedDataContext); @@ -195,11 +199,13 @@ export const CrocEnvContextProvider = (props: { children: ReactNode }) => { ? scrollProvider : chainData.chainId === '0x13e31' ? blastProvider - : new BatchedJsonRpcProvider( - nodeUrl, - parseInt(chainData.chainId), - { staticNetwork: true }, - ), + : chainData.chainId === '0xaa36a7' + ? sepoliaProvider + : new BatchedJsonRpcProvider( + nodeUrl, + parseInt(chainData.chainId), + { staticNetwork: true }, + ), [chainData.chainId], );