-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.ts
47 lines (39 loc) · 1.52 KB
/
index.ts
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { InjectedConnector } from "@web3-react/injected-connector"
import { NetworkConnector } from "@web3-react/network-connector"
import { WalletConnectConnector } from "@web3-react/walletconnect-connector"
import { WalletLinkConnector } from "@web3-react/walletlink-connector"
import { Web3Provider } from "@ethersproject/providers"
const NETWORK_URL = process.env.REACT_APP_NETWORK_URL
export const NETWORK_CHAIN_ID: number = parseInt(
process.env.REACT_APP_CHAIN_ID ?? "1",
)
if (typeof NETWORK_URL === "undefined") {
throw new Error(
`REACT_APP_NETWORK_URL must be a defined environment variable`,
)
}
export const network = new NetworkConnector({
urls: { [NETWORK_CHAIN_ID]: NETWORK_URL },
defaultChainId: NETWORK_CHAIN_ID,
})
// eslint-disable-next-line @typescript-eslint/unbound-method
const { getProvider } = network
let networkLibrary: Web3Provider | undefined
export function getNetworkLibrary(): Web3Provider {
return (networkLibrary = networkLibrary ?? new Web3Provider(getProvider))
}
export const injected = new InjectedConnector({
// mainnet, ropsten, rinkeby, goerli, kovan, local buidler
// see: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md
supportedChainIds: [43113, 43114],
})
export const walletconnect = new WalletConnectConnector({
rpc: { [NETWORK_CHAIN_ID]: NETWORK_URL },
bridge: "https://bridge.walletconnect.org",
qrcode: true,
// pollingInterval: POLLING_INTERVAL / 12000
})
export const walletlink = new WalletLinkConnector({
url: NETWORK_URL,
appName: "Saddle",
})