Commit be2ce18b authored by Moody Salem's avatar Moody Salem Committed by GitHub

fix: change polling interval per network (#1898)

parent fe13b29e
import { Web3Provider } from '@ethersproject/providers'
import { SupportedChainId } from '../constants/chains'
const NETWORK_POLLING_INTERVALS: { [chainId: number]: number } = {
[SupportedChainId.ARBITRUM_ONE]: 1_000,
[SupportedChainId.ARBITRUM_KOVAN]: 1_000,
}
export default function getLibrary(provider: any): Web3Provider {
const library = new Web3Provider(
......@@ -9,7 +15,13 @@ export default function getLibrary(provider: any): Web3Provider {
? parseInt(provider.chainId)
: 'any'
)
// TODO: this should depend on the network block time
library.pollingInterval = 15_000
library.detectNetwork().then((network) => {
const networkPollingInterval = NETWORK_POLLING_INTERVALS[network.chainId]
if (networkPollingInterval) {
console.debug('Setting polling interval', networkPollingInterval)
library.pollingInterval = networkPollingInterval
}
})
return library
}
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