uniswap-interface-uncensored/src/index.tsx

74 lines
2.3 KiB
TypeScript
Raw Normal View History

import React from 'react'
import ReactDOM from 'react-dom'
import ReactGA from 'react-ga'
import { Web3ReactProvider, createWeb3ReactRoot } from '@web3-react/core'
import { Web3Provider } from '@ethersproject/providers'
import { Provider } from 'react-redux'
import { NetworkContextName } from './constants'
import { isMobile } from 'react-device-detect'
import { Updater as LocalStorageContextUpdater } from './state/user/hooks'
import { Updater as TransactionContextUpdater } from './state/transactions/hooks'
import BalancesContextProvider, { Updater as BalancesContextUpdater } from './contexts/Balances'
import App from './pages/App'
import store from './state'
import { Updater as ApplicationContextUpdater } from './state/application/updater'
import ThemeProvider, { FixedGlobalStyle, ThemedGlobalStyle } from './theme'
import './i18n'
2018-03-11 08:50:54 +03:00
const Web3ProviderNetwork = createWeb3ReactRoot(NetworkContextName)
function getLibrary(provider): Web3Provider {
const library = new Web3Provider(provider)
library.pollingInterval = 10000
return library
}
if (process.env.NODE_ENV === 'production') {
ReactGA.initialize(process.env.REACT_APP_GOOGLE_ANALYTICS_ID)
ReactGA.set({
customBrowserType: !isMobile ? 'desktop' : 'web3' in window || 'ethereum' in window ? 'mobileWeb3' : 'mobileRegular'
})
} else {
ReactGA.initialize('test', { testMode: true, debug: true })
2018-10-28 14:12:59 +03:00
}
ReactGA.pageview(window.location.pathname + window.location.search)
2018-10-28 14:05:08 +03:00
2020-05-09 01:32:36 +03:00
function ContextProviders({ children }: { children: React.ReactNode }) {
return <BalancesContextProvider>{children}</BalancesContextProvider>
}
function Updaters() {
return (
<>
<LocalStorageContextUpdater />
<ApplicationContextUpdater />
<TransactionContextUpdater />
<BalancesContextUpdater />
</>
)
}
ReactDOM.render(
<>
<FixedGlobalStyle />
<Web3ReactProvider getLibrary={getLibrary}>
<Web3ProviderNetwork getLibrary={getLibrary}>
<Provider store={store}>
<ContextProviders>
<Updaters />
<ThemeProvider>
<>
<ThemedGlobalStyle />
<App />
</>
</ThemeProvider>
</ContextProviders>
</Provider>
</Web3ProviderNetwork>
</Web3ReactProvider>
</>,
document.getElementById('root')
)