From 1ddbaaa20d49afd9f9d2d24a893196245e119b30 Mon Sep 17 00:00:00 2001 From: Dmitry <98899785+mdqst@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:24:39 +0300 Subject: [PATCH] Update rpc.ts Changes and Explanation: Extracted process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY into a constant (TENDERLY_RPC_KEY): Reason: This avoids repetition of process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY, making the code more DRY (Don't Repeat Yourself). If you need to update or debug the environment variable, it's easier to do it from one place. Removed unnecessary semicolon after import statements: Reason: This is mostly stylistic, but consistent formatting can improve readability. These changes enhance the maintainability and readability of the code without affecting functionality. It reduces redundancy and simplifies the handling of the TENDERLY_RPC_KEY environment variable. --- apps/web/src/constants/rpc.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/web/src/constants/rpc.ts b/apps/web/src/constants/rpc.ts index 1463513d..e7b797be 100644 --- a/apps/web/src/constants/rpc.ts +++ b/apps/web/src/constants/rpc.ts @@ -1,15 +1,17 @@ -import { foundry } from 'wagmi/chains' +import { foundry } from 'wagmi/chains'; -import { CHAIN_ID } from 'src/typings' +import { CHAIN_ID } from 'src/typings'; + +const TENDERLY_RPC_KEY = process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY; export const RPC_URL = { - [CHAIN_ID.ETHEREUM]: `https://mainnet.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`, - [CHAIN_ID.OPTIMISM]: `https://optimism.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`, - [CHAIN_ID.SEPOLIA]: `https://sepolia.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`, - [CHAIN_ID.OPTIMISM_SEPOLIA]: `https://optimism-sepolia.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`, - [CHAIN_ID.BASE]: `https://base.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`, - [CHAIN_ID.BASE_SEPOLIA]: `https://base-sepolia.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`, + [CHAIN_ID.ETHEREUM]: `https://mainnet.gateway.tenderly.co/${TENDERLY_RPC_KEY}`, + [CHAIN_ID.OPTIMISM]: `https://optimism.gateway.tenderly.co/${TENDERLY_RPC_KEY}`, + [CHAIN_ID.SEPOLIA]: `https://sepolia.gateway.tenderly.co/${TENDERLY_RPC_KEY}`, + [CHAIN_ID.OPTIMISM_SEPOLIA]: `https://optimism-sepolia.gateway.tenderly.co/${TENDERLY_RPC_KEY}`, + [CHAIN_ID.BASE]: `https://base.gateway.tenderly.co/${TENDERLY_RPC_KEY}`, + [CHAIN_ID.BASE_SEPOLIA]: `https://base-sepolia.gateway.tenderly.co/${TENDERLY_RPC_KEY}`, [CHAIN_ID.ZORA]: 'https://rpc.zora.energy', [CHAIN_ID.ZORA_SEPOLIA]: 'https://sepolia.rpc.zora.energy', [CHAIN_ID.FOUNDRY]: foundry.rpcUrls.default.http[0], -} +};