2019-04-25 19:12:47 +03:00
|
|
|
import React from 'react'
|
2019-04-15 19:56:40 +03:00
|
|
|
import ReactDOM from 'react-dom'
|
|
|
|
import ReactGA from 'react-ga'
|
2019-04-25 19:12:47 +03:00
|
|
|
import Web3Provider, { Connectors } from 'web3-react'
|
2019-05-14 17:19:09 +03:00
|
|
|
|
|
|
|
import ThemeProvider, { GlobalStyle } from './theme'
|
2019-07-27 01:02:48 +03:00
|
|
|
import LocalStorageContextProvider, { Updater as LocalStorageContextUpdater } from './contexts/LocalStorage'
|
2019-05-03 23:37:59 +03:00
|
|
|
import ApplicationContextProvider, { Updater as ApplicationContextUpdater } from './contexts/Application'
|
2019-05-14 17:19:09 +03:00
|
|
|
import TransactionContextProvider, { Updater as TransactionContextUpdater } from './contexts/Transactions'
|
|
|
|
import TokensContextProvider from './contexts/Tokens'
|
|
|
|
import BalancesContextProvider from './contexts/Balances'
|
|
|
|
import AllowancesContextProvider from './contexts/Allowances'
|
2019-08-13 03:37:32 +03:00
|
|
|
import AllBalancesContextProvider from './contexts/AllBalances'
|
2019-04-16 03:06:39 +03:00
|
|
|
|
2019-04-15 19:56:40 +03:00
|
|
|
import App from './pages/App'
|
2019-05-30 23:42:25 +03:00
|
|
|
import InjectedConnector from './InjectedConnector'
|
2019-05-03 23:37:59 +03:00
|
|
|
|
|
|
|
import './i18n'
|
2018-03-11 08:50:54 +03:00
|
|
|
|
2019-04-16 03:06:39 +03:00
|
|
|
if (process.env.NODE_ENV === 'production') {
|
2019-04-15 19:56:40 +03:00
|
|
|
ReactGA.initialize('UA-128182339-1')
|
2019-04-16 03:06:39 +03:00
|
|
|
} else {
|
|
|
|
ReactGA.initialize('test', { testMode: true })
|
2018-10-28 14:12:59 +03:00
|
|
|
}
|
2019-04-15 19:56:40 +03:00
|
|
|
ReactGA.pageview(window.location.pathname + window.location.search)
|
2018-10-28 14:05:08 +03:00
|
|
|
|
2019-05-30 23:42:25 +03:00
|
|
|
const { NetworkOnlyConnector } = Connectors
|
|
|
|
const Injected = new InjectedConnector({ supportedNetworks: [Number(process.env.REACT_APP_NETWORK_ID || '1')] })
|
|
|
|
const Network = new NetworkOnlyConnector({ providerURL: process.env.REACT_APP_NETWORK_URL || '' })
|
|
|
|
const connectors = { Injected, Network }
|
2019-04-25 19:12:47 +03:00
|
|
|
|
2019-05-03 23:37:59 +03:00
|
|
|
function ContextProviders({ children }) {
|
|
|
|
return (
|
2019-07-27 01:02:48 +03:00
|
|
|
<LocalStorageContextProvider>
|
|
|
|
<ApplicationContextProvider>
|
|
|
|
<TransactionContextProvider>
|
|
|
|
<TokensContextProvider>
|
|
|
|
<BalancesContextProvider>
|
2019-08-13 03:37:32 +03:00
|
|
|
<AllBalancesContextProvider>
|
|
|
|
<AllowancesContextProvider>{children}</AllowancesContextProvider>
|
|
|
|
</AllBalancesContextProvider>
|
2019-07-27 01:02:48 +03:00
|
|
|
</BalancesContextProvider>
|
|
|
|
</TokensContextProvider>
|
|
|
|
</TransactionContextProvider>
|
|
|
|
</ApplicationContextProvider>
|
|
|
|
</LocalStorageContextProvider>
|
2019-05-03 23:37:59 +03:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function Updaters() {
|
|
|
|
return (
|
|
|
|
<>
|
2019-07-27 01:02:48 +03:00
|
|
|
<LocalStorageContextUpdater />
|
2019-05-03 23:37:59 +03:00
|
|
|
<ApplicationContextUpdater />
|
2019-05-14 17:19:09 +03:00
|
|
|
<TransactionContextUpdater />
|
2019-05-03 23:37:59 +03:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-04-16 03:06:39 +03:00
|
|
|
ReactDOM.render(
|
2019-07-31 21:11:58 +03:00
|
|
|
<Web3Provider connectors={connectors} libraryName="ethers.js">
|
|
|
|
<ContextProviders>
|
|
|
|
<Updaters />
|
|
|
|
<ThemeProvider>
|
|
|
|
<>
|
|
|
|
<GlobalStyle />
|
2019-05-14 17:19:09 +03:00
|
|
|
<App />
|
2019-07-31 21:11:58 +03:00
|
|
|
</>
|
|
|
|
</ThemeProvider>
|
|
|
|
</ContextProviders>
|
|
|
|
</Web3Provider>,
|
2019-04-16 03:06:39 +03:00
|
|
|
document.getElementById('root')
|
|
|
|
)
|