Skip to content

Commit 9ee30ac

Browse files
committed
fix: stop overriding library for getLogs
1 parent 24d4a24 commit 9ee30ac

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/hooks/get-logs.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
import { ethers } from 'ethers'
21
import { useMemo } from 'react'
32

3+
// once upon a time, infura was giving timeout errors.
4+
// alchemy was used as a result. but users tend to use
5+
// metamask, which defaults to infura as rpc provider,
6+
// and thus these errors kept happening.
7+
// the solution then was to override the library used to
8+
// fetch the logs, and use the once provided in the env.
9+
10+
// alchemy is now giving 429 errors a bit too frequently,
11+
// and infura somehow works seamlessly again, so this function
12+
// doesn't seem to do anything anymore. but, it's there in case
13+
// these overrides come useful again. plus, refactoring it out
14+
// would be time consuming.
415
const useGetLogs = library => {
5-
const key = JSON.parse(process.env.REACT_APP_RPC_URLS)[1]
6-
const provider = new ethers.providers.JsonRpcProvider(key)
716
const getLogs = useMemo(
817
() => async query => {
9-
if (library.network.chainId === 1) {
10-
const mainnetResult = await provider.getLogs(query)
11-
return mainnetResult
12-
} else {
13-
const defResult = await library.getLogs(query)
14-
return defResult
15-
}
18+
const defResult = await library.getLogs(query)
19+
return defResult
1620
},
1721
// eslint-disable-next-line react-hooks/exhaustive-deps
1822
[library, library.network]

0 commit comments

Comments
 (0)