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, isGoerli } 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 { useBrowser } from 'lib/useBrowser';
24import { BrowserWarning } from 'components/BrowserWarning';
26import Modal from 'components/L2/Modal';
27import { useRollerStore } from 'store/rollerStore';
28import { Box } from '@tlon/indigo-react';
29import LoadingOverlay from 'components/L2/LoadingOverlay';
30import { useRollerPoller } from 'lib/useRollerPoller';
32const INITIAL_NETWORK_TYPE = isGoerli
33 ? NETWORK_TYPES.GOERLI
34 : isDevelopment && !isMainnet
36 : NETWORK_TYPES.MAINNET;
38// NB(shrugs): modify these variables to change the default local state.
39const SHOULD_STUB_LOCAL = import.meta.env.VITE_STUB_LOCAL === 'true';
40const IS_STUBBED = isDevelopment && SHOULD_STUB_LOCAL;
42const INITIAL_WALLET = IS_STUBBED
44 import.meta.env.VITE_DEV_MNEMONIC as string,
45 import.meta.env.VITE_HD_PATH as string
48const INITIAL_MNEMONIC = IS_STUBBED
49 ? Just(import.meta.env.VITE_DEV_MNEMONIC)
51const INITIAL_POINT_CURSOR = IS_STUBBED ? Just(65792) : Nothing();
53function useInitialRoutes() {
54 const [hasDisclaimed] = useHasDisclaimed();
55 const { impliedTicket } = useImpliedTicket();
57 const isActivateUrl = window.location.pathname === '/activate';
61 { key: ROUTE_NAMES.LOGIN },
62 // { key: ROUTE_NAMES.POINTS },
63 // { key: ROUTE_NAMES.POINT },
67 if (impliedTicket || isActivateUrl) {
68 return [{ key: ROUTE_NAMES.ACTIVATE }];
72 return [{ key: ROUTE_NAMES.DISCLAIMER, data: { next: ROUTE_NAMES.LOGIN } }];
75 return [{ key: ROUTE_NAMES.LOGIN }];
85 const initialRoutes = useInitialRoutes();
86 const { loading, modalText, setModalText } = useRollerStore();
88 const browser = useBrowser();
89 const showBrowserWarning = browser && !browser.isChromium;
91 // full reload if the user changes their selected network in Metamask
94 if (window.ethereum) {
95 window.ethereum.on('chainChanged', () => {
96 document.location.reload();
103 render={(error: Error) => <GlobalErrorBoundary error={error} />}>
107 initialRoutes={initialRoutes}
108 initialNetworkType={INITIAL_NETWORK_TYPE}
109 initialWallet={INITIAL_WALLET}
110 initialMnemonic={INITIAL_MNEMONIC}
111 initialPointCursor={INITIAL_POINT_CURSOR}>
112 <BrowserWarning show={!!showBrowserWarning} />
114 <ThemeProvider theme={light}>
118 <Modal show={modalText !== undefined} hide={() => setModalText('')}>
119 <Box width="280px">{modalText}</Box>
121 <LoadingOverlay loading={loading} />
128export 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