From 02f64b26c4b71ca825f0a87188e10a079080085b Mon Sep 17 00:00:00 2001 From: Kheops <26880866+0xKheops@users.noreply.github.com> Date: Mon, 3 Jul 2023 07:59:32 +0700 Subject: [PATCH] chore: remove api key replacement for evm (#900) --- .../src/ui/domains/Ethereum/Networks/helpers.ts | 3 +-- apps/extension/src/ui/util/getRpcUrlWithApiKey.ts | 15 --------------- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 apps/extension/src/ui/util/getRpcUrlWithApiKey.ts diff --git a/apps/extension/src/ui/domains/Ethereum/Networks/helpers.ts b/apps/extension/src/ui/domains/Ethereum/Networks/helpers.ts index 98d2c4a84..448544cdd 100644 --- a/apps/extension/src/ui/domains/Ethereum/Networks/helpers.ts +++ b/apps/extension/src/ui/domains/Ethereum/Networks/helpers.ts @@ -1,5 +1,4 @@ import { EvmNetworkId } from "@talismn/chaindata-provider" -import { getRpcUrlWithApiKey } from "@ui/util/getRpcUrlWithApiKey" import { ethers } from "ethers" // because of validation the same query is done 3 times minimum per url, make all await same promise @@ -13,7 +12,7 @@ export const getRpcChainId = (rpcUrl: string) => { rpcChainIdCache.set( rpcUrl, new Promise((resolve) => { - const provider = new ethers.providers.StaticJsonRpcProvider(getRpcUrlWithApiKey(rpcUrl)) + const provider = new ethers.providers.StaticJsonRpcProvider(rpcUrl) provider .send("eth_chainId", []) .then((hexChainId) => { diff --git a/apps/extension/src/ui/util/getRpcUrlWithApiKey.ts b/apps/extension/src/ui/util/getRpcUrlWithApiKey.ts deleted file mode 100644 index e720e8c9f..000000000 --- a/apps/extension/src/ui/util/getRpcUrlWithApiKey.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { API_KEY_ONFINALITY } from "@core/constants" - -export const getRpcUrlWithApiKey = (rpcUrl: string) => { - if (!API_KEY_ONFINALITY) return rpcUrl - // inject api key before using an rpc url because we don't want them in the store (user can modify urls of rpcs) - return rpcUrl - .replace( - /^https:\/\/([A-z-]+)\.api\.onfinality\.io\/public-ws\/?$/, - `https://$1.api.onfinality.io/ws?apikey=${API_KEY_ONFINALITY}` - ) - .replace( - /^https:\/\/([A-z-]+)\.api\.onfinality\.io\/rpc\/?$/, - `https://$1.api.onfinality.io/rpc?apikey=${API_KEY_ONFINALITY}` - ) -}