FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
interface/src/utils/getLibrary.ts at main · sameepsi/interface · GitHub
sameepsi
/
interface
Public
forked from
Uniswap/interface
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
interface
/
src
/
utils
/
getLibrary.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (28 loc) · 1015 Bytes
Breadcrumbs
interface
/
src
/
utils
/
getLibrary.ts
Copy path
File metadata and controls
31 lines (28 loc) · 1015 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import
{
Web3Provider
}
from
'@ethersproject/providers'
import
ms
from
'ms.macro'
import
{
SupportedChainId
}
from
'../constants/chains'
const
NETWORK_POLLING_INTERVALS
:
{
[
chainId
:
number
]
:
number
}
=
{
[
SupportedChainId
.
ARBITRUM_ONE
]
:
ms
`1s`
,
[
SupportedChainId
.
ARBITRUM_RINKEBY
]
:
ms
`1s`
,
[
SupportedChainId
.
OPTIMISM
]
:
ms
`1s`
,
[
SupportedChainId
.
OPTIMISTIC_KOVAN
]
:
ms
`1s`
,
}
export
default
function
getLibrary
(
provider
:
any
)
:
Web3Provider
{
const
library
=
new
Web3Provider
(
provider
,
typeof
provider
.
chainId
===
'number'
?
provider
.
chainId
:
typeof
provider
.
chainId
===
'string'
?
parseInt
(
provider
.
chainId
)
:
'any'
)
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
}
Back
|
FazBrowse Home
|
New Git URL