File tree 4 files changed +1484
-1197
lines changed 4 files changed +1484
-1197
lines changed Original file line number Diff line number Diff line change 10
10
"@uniswap/sdk" : " ^1.0.0-beta.4" ,
11
11
"copy-to-clipboard" : " ^3.2.0" ,
12
12
"escape-string-regexp" : " ^2.0.0" ,
13
- "ethers" : " ^4.0.33 " ,
13
+ "ethers" : " ^4.0.36 " ,
14
14
"i18next" : " ^15.0.9" ,
15
15
"i18next-browser-languagedetector" : " ^3.0.1" ,
16
16
"i18next-xhr-backend" : " ^2.0.1" ,
27
27
"react-spring" : " ^8.0.20" ,
28
28
"react-switch" : " ^5.0.1" ,
29
29
"styled-components" : " ^4.2.0" ,
30
- "web3-react" : " ^ 5.0.4 "
30
+ "web3-react" : " 5.0.5 "
31
31
},
32
32
"scripts" : {
33
33
"start" : " react-scripts start" ,
Original file line number Diff line number Diff line change
1
+ import { ethers } from 'ethers'
2
+ import { Connectors } from 'web3-react'
3
+
4
+ const { Connector } = Connectors
5
+
6
+ function getFallbackProvider ( providerURL ) {
7
+ const etherscan = new ethers . providers . EtherscanProvider ( )
8
+ const infura = new ethers . providers . JsonRpcProvider ( providerURL )
9
+
10
+ const providers = [ infura , etherscan ]
11
+
12
+ return new ethers . providers . FallbackProvider ( providers )
13
+ }
14
+
15
+ export default class NetworkOnlyConnector extends Connector {
16
+ constructor ( kwargs ) {
17
+ const { providerURL, ...rest } = kwargs || { }
18
+ super ( rest )
19
+ this . providerURL = providerURL
20
+ }
21
+
22
+ async onActivation ( ) {
23
+ if ( ! this . engine ) {
24
+ const provider = getFallbackProvider ( this . providerURL )
25
+ provider . polling = false
26
+ provider . pollingInterval = 300000 // 5 minutes
27
+ this . engine = provider
28
+ }
29
+ }
30
+
31
+ async getNetworkId ( provider ) {
32
+ const networkId = await provider . getNetwork ( ) . then ( network => network . chainId )
33
+ return super . _validateNetworkId ( networkId )
34
+ }
35
+
36
+ async getProvider ( ) {
37
+ return this . engine
38
+ }
39
+
40
+ async getAccount ( ) {
41
+ return null
42
+ }
43
+ }
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import ReactDOM from 'react-dom'
3
3
import ReactGA from 'react-ga'
4
- import Web3Provider , { Connectors } from 'web3-react'
4
+ import Web3Provider from 'web3-react'
5
5
6
6
import ThemeProvider , { GlobalStyle } from './theme'
7
7
import LocalStorageContextProvider , { Updater as LocalStorageContextUpdater } from './contexts/LocalStorage'
@@ -13,6 +13,7 @@ import AllowancesContextProvider from './contexts/Allowances'
13
13
import AllBalancesContextProvider from './contexts/AllBalances'
14
14
15
15
import App from './pages/App'
16
+ import NetworkOnlyConnector from './NetworkOnlyConnector'
16
17
import InjectedConnector from './InjectedConnector'
17
18
18
19
import './i18n'
@@ -24,9 +25,8 @@ if (process.env.NODE_ENV === 'production') {
24
25
}
25
26
ReactGA . pageview ( window . location . pathname + window . location . search )
26
27
27
- const { NetworkOnlyConnector } = Connectors
28
- const Injected = new InjectedConnector ( { supportedNetworks : [ Number ( process . env . REACT_APP_NETWORK_ID || '1' ) ] } )
29
28
const Network = new NetworkOnlyConnector ( { providerURL : process . env . REACT_APP_NETWORK_URL || '' } )
29
+ const Injected = new InjectedConnector ( { supportedNetworks : [ Number ( process . env . REACT_APP_NETWORK_ID || '1' ) ] } )
30
30
const connectors = { Injected, Network }
31
31
32
32
function ContextProviders ( { children } ) {
You can’t perform that action at this time.
0 commit comments