From d6b52e143c07ef3ae2c24a592964c5313b4a754e Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 28 Feb 2024 16:58:16 -0500 Subject: [PATCH 1/4] Use wagmi public client as requestor in proxy target request function parameter --- src/components/ui/forms/ABISelector.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/ui/forms/ABISelector.tsx b/src/components/ui/forms/ABISelector.tsx index b886e0c75e..1daeb21148 100644 --- a/src/components/ui/forms/ABISelector.tsx +++ b/src/components/ui/forms/ABISelector.tsx @@ -4,7 +4,7 @@ import { isAddress } from 'ethers/lib/utils'; import detectProxyTarget from 'evm-proxy-detection'; import { useMemo, useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { useEnsAddress } from 'wagmi'; +import { useEnsAddress, usePublicClient } from 'wagmi'; import { logError } from '../../../helpers/errorLogging'; import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider'; import { useEIP1193Providers } from '../../../providers/NetworkConfig/utils'; @@ -32,13 +32,14 @@ export default function ABISelector({ target, onChange, onFetchABI }: IABISelect const { t } = useTranslation('common'); const { eip1193InfuraProvider } = useEIP1193Providers(); const { data: ensAddress } = useEnsAddress({ name: target }); + const client = usePublicClient(); useEffect(() => { const loadABI = async () => { if (target && ((ensAddress && isAddress(ensAddress)) || isAddress(target))) { try { - const requestFunc = ({ method, params }: { method: string; params: any[] }) => - eip1193InfuraProvider.send(method, params); + const requestFunc = ({ method, params }: { method: any; params: any }) => + client.request({ method, params }); const proxy = await detectProxyTarget(ensAddress || target, requestFunc); @@ -71,7 +72,7 @@ export default function ABISelector({ target, onChange, onFetchABI }: IABISelect } }; loadABI(); - }, [target, ensAddress, etherscanAPIBaseUrl, onFetchABI, eip1193InfuraProvider]); + }, [target, ensAddress, etherscanAPIBaseUrl, onFetchABI, client]); /* * This makes component quite scoped to proposal / proposal template creation From a40b61e036ee1cd6e63db3105c9f1e7bc1a3f280 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 28 Feb 2024 16:58:53 -0500 Subject: [PATCH 2/4] Remove unused references to Infura EIP1193Provider --- src/components/ui/forms/ABISelector.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/ui/forms/ABISelector.tsx b/src/components/ui/forms/ABISelector.tsx index 1daeb21148..e7ee44c602 100644 --- a/src/components/ui/forms/ABISelector.tsx +++ b/src/components/ui/forms/ABISelector.tsx @@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next'; import { useEnsAddress, usePublicClient } from 'wagmi'; import { logError } from '../../../helpers/errorLogging'; import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider'; -import { useEIP1193Providers } from '../../../providers/NetworkConfig/utils'; import { LabelComponent } from './InputComponent'; export type ABIElement = { @@ -30,7 +29,6 @@ export default function ABISelector({ target, onChange, onFetchABI }: IABISelect const [abi, setABI] = useState([]); const { etherscanAPIBaseUrl } = useNetworkConfig(); const { t } = useTranslation('common'); - const { eip1193InfuraProvider } = useEIP1193Providers(); const { data: ensAddress } = useEnsAddress({ name: target }); const client = usePublicClient(); From b24e97c755b54fd4a0914bd79da6d849a06bacf1 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 28 Feb 2024 16:59:05 -0500 Subject: [PATCH 3/4] Delete unused useEIP1193Providers hook --- src/providers/NetworkConfig/utils.ts | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 src/providers/NetworkConfig/utils.ts diff --git a/src/providers/NetworkConfig/utils.ts b/src/providers/NetworkConfig/utils.ts deleted file mode 100644 index b45225025a..0000000000 --- a/src/providers/NetworkConfig/utils.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { InfuraProvider } from '@ethersproject/providers'; -import { useMemo } from 'react'; -import { useNetworkConfig } from './NetworkConfigProvider'; - -export const useEIP1193Providers = () => { - const { chainId } = useNetworkConfig(); - - // Unfortunately, usePublicClient from wagmi package does not return instance that compatible with EIP1193 standard - // And that's required for Proxy Detection - const eip1193InfuraProvider = useMemo( - () => new InfuraProvider(chainId, process.env.NEXT_PUBLIC_INFURA_API_KEY!), - [chainId] - ); - - return { eip1193InfuraProvider }; -}; From ca8067216137df4e6d35c65e4da58a1b9ae4bfa3 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 28 Feb 2024 16:59:22 -0500 Subject: [PATCH 4/4] Remove reference to unused NEXT_PUBLIC_INFURA_API_KEY env var --- .env | 2 -- 1 file changed, 2 deletions(-) diff --git a/.env b/.env index 455c7f30e0..df3aabc62a 100644 --- a/.env +++ b/.env @@ -6,8 +6,6 @@ NEXT_PUBLIC_ALCHEMY_SEPOLIA_API_KEY="" NEXT_PUBLIC_ALCHEMY_TESTING_API_KEY="" # ABI selector (*) NEXT_PUBLIC_ETHERSCAN_API_KEY="" -# wallet providers (*) -NEXT_PUBLIC_INFURA_API_KEY="" # IPFS pinning (*) NEXT_PUBLIC_INFURA_IPFS_API_KEY="" # IPFS pinning (*)