From 9172b368b98dc0c17128cfbf654beb2f51544fca Mon Sep 17 00:00:00 2001 From: Ben Kremer Date: Mon, 14 Feb 2022 16:58:57 +0100 Subject: [PATCH] refactor: abstract into `DEFAULT_INFURA_ID` --- dapps/react-dapp-v2-with-ethers/.env.local.example | 1 + dapps/react-dapp-v2-with-ethers/src/constants/default.ts | 2 ++ .../src/contexts/ClientContext.tsx | 9 +++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dapps/react-dapp-v2-with-ethers/.env.local.example b/dapps/react-dapp-v2-with-ethers/.env.local.example index 2116fd1..68e3f38 100644 --- a/dapps/react-dapp-v2-with-ethers/.env.local.example +++ b/dapps/react-dapp-v2-with-ethers/.env.local.example @@ -1,3 +1,4 @@ REACT_APP_PROJECT_ID=39bc93c4affb2e20cb6f8d36ca107dd9 +REACT_APP_INFURA_ID=5dc0df... REACT_APP_RELAY_URL=wss://relay.dev.walletconnect.com diff --git a/dapps/react-dapp-v2-with-ethers/src/constants/default.ts b/dapps/react-dapp-v2-with-ethers/src/constants/default.ts index 078c280..045a94a 100644 --- a/dapps/react-dapp-v2-with-ethers/src/constants/default.ts +++ b/dapps/react-dapp-v2-with-ethers/src/constants/default.ts @@ -21,6 +21,8 @@ export const DEFAULT_CHAINS = [...DEFAULT_MAIN_CHAINS, ...DEFAULT_TEST_CHAINS]; export const DEFAULT_PROJECT_ID = process.env.REACT_APP_PROJECT_ID; +export const DEFAULT_INFURA_ID = process.env.REACT_APP_INFURA_ID; + export const DEFAULT_RELAY_URL = process.env.REACT_APP_RELAY_URL; export const DEFAULT_EIP155_METHODS = ["eth_sendTransaction", "personal_sign", "eth_signTypedData"]; diff --git a/dapps/react-dapp-v2-with-ethers/src/contexts/ClientContext.tsx b/dapps/react-dapp-v2-with-ethers/src/contexts/ClientContext.tsx index 5350bff..aab7062 100644 --- a/dapps/react-dapp-v2-with-ethers/src/contexts/ClientContext.tsx +++ b/dapps/react-dapp-v2-with-ethers/src/contexts/ClientContext.tsx @@ -10,7 +10,12 @@ import { useMemo, useState, } from "react"; -import { DEFAULT_LOGGER, DEFAULT_PROJECT_ID, DEFAULT_RELAY_URL } from "../constants"; +import { + DEFAULT_INFURA_ID, + DEFAULT_LOGGER, + DEFAULT_PROJECT_ID, + DEFAULT_RELAY_URL, +} from "../constants"; import { ERROR } from "@walletconnect/utils"; import EthereumProvider from "@walletconnect/ethereum-provider"; import { providers, utils } from "ethers"; @@ -138,7 +143,7 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac const ethereumProvider = new EthereumProvider({ chainId: Number(chainId), rpc: { - infuraId: "5dc0df7abe4645dfb06a9a8c39ede422", + infuraId: DEFAULT_INFURA_ID, }, // FIXME: `signer-connection` sub-dep is already specifying beta.23 -> typings mismatch. // @ts-ignore