Commit 77366bf8 authored by lynn's avatar lynn Committed by GitHub

feat: configure blocks per fetch for l2s (#4028)

* init commit

* update redux multicall version to 1.1.5 in package.json

* fix respond to zzmp comments

* update optimism blocks per fetch to 15

* simplify
Co-authored-by: default avatarLynn Yu <lynn.yu@uniswap.org>
parent cd8b0488
import { createMulticall } from '@uniswap/redux-multicall'
import { createMulticall, ListenerOptions } from '@uniswap/redux-multicall'
import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import { useInterfaceMulticall } from 'hooks/useContract'
import useBlockNumber from 'lib/hooks/useBlockNumber'
import { useMemo } from 'react'
import { combineReducers, createStore } from 'redux'
const multicall = createMulticall()
......@@ -10,9 +12,33 @@ export const store = createStore(reducer)
export default multicall
function getBlocksPerFetchForChainId(chainId: number | undefined): number {
switch (chainId) {
case SupportedChainId.ARBITRUM_ONE:
case SupportedChainId.OPTIMISM:
return 15
default:
return 1
}
}
export function MulticallUpdater() {
const { chainId } = useWeb3React()
const latestBlockNumber = useBlockNumber()
const contract = useInterfaceMulticall()
return <multicall.Updater chainId={chainId} latestBlockNumber={latestBlockNumber} contract={contract} />
const listenerOptions: ListenerOptions = useMemo(
() => ({
blocksPerFetch: getBlocksPerFetchForChainId(chainId),
}),
[chainId]
)
return (
<multicall.Updater
chainId={chainId}
latestBlockNumber={latestBlockNumber}
contract={contract}
listenerOptions={listenerOptions}
/>
)
}
......@@ -4507,10 +4507,10 @@
resolved "https://registry.npmjs.org/@uniswap/merkle-distributor/-/merkle-distributor-1.0.1.tgz"
integrity sha512-5gDiTI5hrXIh5UWTrxKYjw30QQDnpl8ckDSpefldNenDlYO1RKkdUYMYpvrqGi2r7YzLYTlO6+TDlNs6O7hDRw==
"@uniswap/redux-multicall@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@uniswap/redux-multicall/-/redux-multicall-1.1.1.tgz#095285a9f9951d92ca0f8785bc4d2270676c309c"
integrity sha512-sXX2pAbxJj1OrErSc7zMEFo7j1EXqTBbllYuUDEWCZ/A12sK/4RXgXW2+zSoXOHCN6djyVUc3FmEt0v3x2jLSw==
"@uniswap/redux-multicall@^1.1.5":
version "1.1.5"
resolved "https://registry.yarnpkg.com/@uniswap/redux-multicall/-/redux-multicall-1.1.5.tgz#7c097047d489c1624038c0fbbd3d76dc705bf153"
integrity sha512-RSMhfuAX2rPimnevvAAiwoyV2bCGTIKhVHEBOLTMF+oVxYcKKe9hCwx/cffY12t/usXWHlEJ//V7JoxTKI1Lyg==
"@uniswap/router-sdk@^1.0.3", "@uniswap/router-sdk@^1.0.5":
version "1.0.5"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment