-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
191 lines (179 loc) · 7.44 KB
/
App.tsx
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import React, { lazy } from 'react'
import { Router, Redirect, Route, Switch } from 'react-router-dom'
import { ResetCSS } from '@pancakeswap/uikit'
import { useWeb3React } from '@web3-react/core'
import BigNumber from 'bignumber.js'
import useEagerConnect from 'hooks/useEagerConnect'
import useUserAgent from 'hooks/useUserAgent'
import useScrollOnRouteChange from 'hooks/useScrollOnRouteChange'
import { usePollBlockNumber } from 'state/block/hooks'
import { usePollCoreFarmData } from 'state/farms/hooks'
import { useFetchProfile } from 'state/profile/hooks'
import { DatePickerPortal } from 'components/DatePicker'
import { nftsBaseUrl } from 'views/Nft/market/constants'
import GlobalStyle from './style/Global'
import Menu from './components/Menu'
import SuspenseWithChunkError from './components/SuspenseWithChunkError'
import { ToastListener } from './contexts/ToastsContext'
import PageLoader from './components/Loader/PageLoader'
import EasterEgg from './components/EasterEgg'
import GlobalCheckClaimStatus from './components/GlobalCheckClaimStatus'
import history from './routerHistory'
// Views included in the main bundle
import Pools from './views/Pools'
import Swap from './views/Swap'
import {
RedirectDuplicateTokenIds,
RedirectOldAddLiquidityPathStructure,
RedirectToAddLiquidity,
} from './views/AddLiquidity/redirects'
import RedirectOldRemoveLiquidityPathStructure from './views/RemoveLiquidity/redirects'
import { RedirectPathToSwapOnly, RedirectToSwap } from './views/Swap/redirects'
// Route-based code splitting
// Only pool is included in the main bundle because of it's the most visited page
const Home = lazy(() => import('./views/Home'))
const Farms = lazy(() => import('./views/Farms'))
// const FarmAuction = lazy(() => import('./views/FarmAuction'))
// const Lottery = lazy(() => import('./views/Lottery'))
const Ifos = lazy(() => import('./views/Ifos'))
const NotFound = lazy(() => import('./views/NotFound'))
// const Teams = lazy(() => import('./views/Teams'))
// const Team = lazy(() => import('./views/Teams/Team'))
// const TradingCompetition = lazy(() => import('./views/TradingCompetition'))
// const Predictions = lazy(() => import('./views/Predictions'))
// const PredictionsLeaderboard = lazy(() => import('./views/Predictions/Leaderboard'))
// const Voting = lazy(() => import('./views/Voting'))
// const Proposal = lazy(() => import('./views/Voting/Proposal'))
// const CreateProposal = lazy(() => import('./views/Voting/CreateProposal'))
const AddLiquidity = lazy(() => import('./views/AddLiquidity'))
const Liquidity = lazy(() => import('./views/Pool'))
const PoolFinder = lazy(() => import('./views/PoolFinder'))
const RemoveLiquidity = lazy(() => import('./views/RemoveLiquidity'))
// const Info = lazy(() => import('./views/Info'))
// const NftMarket = lazy(() => import('./views/Nft/market'))
const ProfileCreation = lazy(() => import('./views/ProfileCreation'))
// const PancakeSquad = lazy(() => import('./views/PancakeSquad'))
// This config is required for number formatting
BigNumber.config({
EXPONENTIAL_AT: 1000,
DECIMAL_PLACES: 80,
})
const App: React.FC = () => {
const { account } = useWeb3React()
usePollBlockNumber()
useEagerConnect()
// useFetchProfile()
usePollCoreFarmData()
useScrollOnRouteChange()
useUserAgent()
return (
<Router history={history}>
<ResetCSS />
<GlobalStyle />
<GlobalCheckClaimStatus excludeLocations={[]} />
<Menu>
<SuspenseWithChunkError fallback={<PageLoader />}>
<Switch>
<Route path="/" exact>
<Home />
</Route>
{/* <Route exact path="/farms/auction">
<FarmAuction />
</Route> */}
<Route path="/farms">
<Farms />
</Route>
<Route path="/pools">
{/* <Farms tokenMode/> */}
<Pools />
</Route>
<Route path="/launchpad">
<Ifos />
</Route>
{/* <Route path="/lottery">
<Lottery />
</Route>
<Route exact path="/teams">
<Teams />
</Route>
<Route path="/teams/:id">
<Team />
</Route> */}
{/* <Route path="/create-profile">
<ProfileCreation />
</Route> */}
{/* <Route path="/competition">
<TradingCompetition />
</Route>
<Route exact path="/prediction">
<Predictions />
</Route>
<Route path="/prediction/leaderboard">
<PredictionsLeaderboard />
</Route>
<Route exact path="/voting">
<Voting />
</Route>
<Route exact path="/voting/proposal/create">
<CreateProposal />
</Route>
<Route path="/voting/proposal/:id">
<Proposal />
</Route> */}
{/* NFT */}
{/* <Route path="/nfts">
<NftMarket />
</Route>
<Route path="/pancake-squad">
<PancakeSquad />
</Route> */}
{/* Info pages */}
{/* <Route path="/info">
<Info />
</Route> */}
{/* Using this format because these components use routes injected props. We need to rework them with hooks */}
<Route exact strict path="/swap" component={Swap} />
<Route exact strict path="/swap/:outputCurrency" component={RedirectToSwap} />
<Route exact strict path="/send" component={RedirectPathToSwapOnly} />
<Route exact strict path="/find" component={PoolFinder} />
<Route exact strict path="/liquidity" component={Liquidity} />
<Route exact strict path="/create" component={RedirectToAddLiquidity} />
<Route exact path="/add" component={AddLiquidity} />
<Route exact path="/add/:currencyIdA" component={RedirectOldAddLiquidityPathStructure} />
<Route exact path="/add/:currencyIdA/:currencyIdB" component={RedirectDuplicateTokenIds} />
<Route exact path="/create" component={AddLiquidity} />
<Route exact path="/create/:currencyIdA" component={RedirectOldAddLiquidityPathStructure} />
<Route exact path="/create/:currencyIdA/:currencyIdB" component={RedirectDuplicateTokenIds} />
<Route exact strict path="/remove/:tokens" component={RedirectOldRemoveLiquidityPathStructure} />
<Route exact strict path="/remove/:currencyIdA/:currencyIdB" component={RemoveLiquidity} />
{/* Redirect */}
{/* <Route path="/" exact>
<Redirect to="/swap" />
</Route> */}
<Route path="/pool">
<Redirect to="/liquidity" />
</Route>
<Route path="/staking">
<Redirect to="/pools" />
</Route>
<Route path="/syrup">
<Redirect to="/pools" />
</Route>
{/* <Route path="/collectibles">
<Redirect to="/nfts" />
</Route> */}
<Route path="/profile">
<Redirect to={`${nftsBaseUrl}/profile/${account?.toLowerCase() || ''}`} />
</Route>
{/* 404 */}
<Route component={NotFound} />
</Switch>
</SuspenseWithChunkError>
</Menu>
<EasterEgg iterations={2} />
<ToastListener />
<DatePickerPortal />
</Router>
)
}
export default React.memo(App)