1import { useEffect } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import { IndigoApp } from 'indigo-react';
5import Router from 'components/Router';
7import Provider from 'store/Provider';
9import { ROUTE_NAMES } from 'lib/routeNames';
10import { ROUTES } from 'lib/router';
11import { NETWORK_TYPES } from 'lib/network';
12import { walletFromMnemonic } from 'lib/wallet';
13import { isDevelopment, isMainnet, isRopsten } from 'lib/flags';
14import useImpliedTicket from 'lib/useImpliedTicket';
15import useHasDisclaimed from 'lib/useHasDisclaimed';
17import 'style/index.scss';
18import { ThemeProvider } from 'styled-components';
19import light from '@tlon/indigo-light';
21import WithErrorBoundary from 'components/WithErrorBoundary';
22import GlobalErrorBoundary from 'components/GlobalErrorBoundary';
23import Modal from 'components/L2/Modal';
24import { useRollerStore } from 'store/rollerStore';
25import { Box } from '@tlon/indigo-react';
26import LoadingOverlay from 'components/L2/LoadingOverlay';
27import { useRollerPoller } from 'lib/useRollerPoller';
28import { BrowserRouter, Route, Routes } from 'react-router-dom';
29import InviteCohort from 'views/Invite/Cohort';
31const INITIAL_NETWORK_TYPE = isRopsten
32 ? NETWORK_TYPES.ROPSTEN
33 : isDevelopment && !isMainnet
35 : NETWORK_TYPES.MAINNET;
37// NB(shrugs): modify these variables to change the default local state.
38const SHOULD_STUB_LOCAL = process.env.REACT_APP_STUB_LOCAL === 'true';
39const IS_STUBBED = isDevelopment && SHOULD_STUB_LOCAL;
41const INITIAL_WALLET = IS_STUBBED
43 process.env.REACT_APP_DEV_MNEMONIC as string,
44 process.env.REACT_APP_HD_PATH as string
47const INITIAL_MNEMONIC = IS_STUBBED
48 ? Just(process.env.REACT_APP_DEV_MNEMONIC)
50const INITIAL_POINT_CURSOR = IS_STUBBED ? Just(65792) : Nothing();
52function useInitialRoutes() {
53 const [hasDisclaimed] = useHasDisclaimed();
54 const { impliedTicket } = useImpliedTicket();
56 const isActivateUrl = window.location.pathname === '/activate';
60 { key: ROUTE_NAMES.LOGIN },
61 // { key: ROUTE_NAMES.POINTS },
62 // { key: ROUTE_NAMES.POINT },
66 if (impliedTicket || isActivateUrl) {
67 return [{ key: ROUTE_NAMES.ACTIVATE }];
71 return [{ key: ROUTE_NAMES.DISCLAIMER, data: { next: ROUTE_NAMES.LOGIN } }];
74 return [{ key: ROUTE_NAMES.LOGIN }];
84 const initialRoutes = useInitialRoutes();
85 const { loading, modalText, setModalText } = useRollerStore();
87 // full reload if the user changes their selected network in Metamask
90 if (window.ethereum) {
91 window.ethereum.on('chainChanged', () => {
92 document.location.reload();
99 render={(error: Error) => <GlobalErrorBoundary error={error} />}>
103 initialRoutes={initialRoutes}
104 initialNetworkType={INITIAL_NETWORK_TYPE}
105 initialWallet={INITIAL_WALLET}
106 initialMnemonic={INITIAL_MNEMONIC}
107 initialPointCursor={INITIAL_POINT_CURSOR}>
110 <ThemeProvider theme={light}>
113 <Route path="/" element={null} />
114 <Route path="/point/:point">
115 <Route path="invites" element={<InviteCohort />} />
120 <Modal show={modalText !== undefined} hide={() => setModalText('')}>
121 <Box width="280px">{modalText}</Box>
123 <LoadingOverlay loading={loading} />
131export default Bridge;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list