2020-05-20 20:12:06 +03:00
|
|
|
import { Web3Provider } from '@ethersproject/providers'
|
|
|
|
import { createWeb3ReactRoot, Web3ReactProvider } from '@web3-react/core'
|
2019-04-25 19:12:47 +03:00
|
|
|
import React from 'react'
|
2020-05-20 20:12:06 +03:00
|
|
|
import { isMobile } from 'react-device-detect'
|
2019-04-15 19:56:40 +03:00
|
|
|
import ReactDOM from 'react-dom'
|
|
|
|
import ReactGA from 'react-ga'
|
2020-05-12 01:23:01 +03:00
|
|
|
import { Provider } from 'react-redux'
|
2019-05-14 17:19:09 +03:00
|
|
|
|
2019-11-26 01:56:31 +03:00
|
|
|
import { NetworkContextName } from './constants'
|
2020-05-20 20:12:06 +03:00
|
|
|
import './i18n'
|
2019-04-15 19:56:40 +03:00
|
|
|
import App from './pages/App'
|
2020-05-12 01:23:01 +03:00
|
|
|
import store from './state'
|
2020-05-13 19:58:20 +03:00
|
|
|
import ApplicationUpdater from './state/application/updater'
|
|
|
|
import TransactionUpdater from './state/transactions/updater'
|
|
|
|
import UserUpdater from './state/user/updater'
|
2020-05-20 20:12:06 +03:00
|
|
|
import WalletUpdater from './state/wallet/updater'
|
2020-05-12 00:02:10 +03:00
|
|
|
import ThemeProvider, { FixedGlobalStyle, ThemedGlobalStyle } from './theme'
|
2018-03-11 08:50:54 +03:00
|
|
|
|
2019-11-26 01:56:31 +03:00
|
|
|
const Web3ProviderNetwork = createWeb3ReactRoot(NetworkContextName)
|
|
|
|
|
2020-05-20 20:12:06 +03:00
|
|
|
function getLibrary(provider: any): Web3Provider {
|
|
|
|
return new Web3Provider(provider)
|
2019-11-26 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
2020-05-20 20:12:06 +03:00
|
|
|
const GOOGLE_ANALYTICS_ID: string | undefined = process.env.REACT_APP_GOOGLE_ANALYTICS_ID
|
|
|
|
if (typeof GOOGLE_ANALYTICS_ID === 'string') {
|
|
|
|
ReactGA.initialize(GOOGLE_ANALYTICS_ID)
|
2019-12-31 23:27:51 +03:00
|
|
|
ReactGA.set({
|
2020-05-07 21:36:26 +03:00
|
|
|
customBrowserType: !isMobile ? 'desktop' : 'web3' in window || 'ethereum' in window ? 'mobileWeb3' : 'mobileRegular'
|
2019-12-31 23:27:51 +03:00
|
|
|
})
|
2019-04-16 03:06:39 +03:00
|
|
|
} else {
|
2020-05-07 21:36:26 +03:00
|
|
|
ReactGA.initialize('test', { testMode: true, debug: true })
|
2018-10-28 14:12:59 +03:00
|
|
|
}
|
2019-12-31 23:27:51 +03:00
|
|
|
|
2019-05-03 23:37:59 +03:00
|
|
|
function Updaters() {
|
|
|
|
return (
|
|
|
|
<>
|
2020-05-13 19:58:20 +03:00
|
|
|
<UserUpdater />
|
|
|
|
<ApplicationUpdater />
|
|
|
|
<TransactionUpdater />
|
2020-05-13 23:36:45 +03:00
|
|
|
<WalletUpdater />
|
2019-05-03 23:37:59 +03:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-04-16 03:06:39 +03:00
|
|
|
ReactDOM.render(
|
2020-05-12 00:02:10 +03:00
|
|
|
<>
|
|
|
|
<FixedGlobalStyle />
|
|
|
|
<Web3ReactProvider getLibrary={getLibrary}>
|
|
|
|
<Web3ProviderNetwork getLibrary={getLibrary}>
|
2020-05-12 01:23:01 +03:00
|
|
|
<Provider store={store}>
|
2020-05-13 23:36:45 +03:00
|
|
|
<Updaters />
|
|
|
|
<ThemeProvider>
|
|
|
|
<>
|
|
|
|
<ThemedGlobalStyle />
|
|
|
|
<App />
|
|
|
|
</>
|
|
|
|
</ThemeProvider>
|
2020-05-12 01:23:01 +03:00
|
|
|
</Provider>
|
2020-05-12 00:02:10 +03:00
|
|
|
</Web3ProviderNetwork>
|
|
|
|
</Web3ReactProvider>
|
|
|
|
</>,
|
2019-04-16 03:06:39 +03:00
|
|
|
document.getElementById('root')
|
|
|
|
)
|