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 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';
29const INITIAL_NETWORK_TYPE = isGoerli
30 ? NETWORK_TYPES.GOERLI
31 : isDevelopment && !isMainnet
33 : NETWORK_TYPES.MAINNET;
35// NB(shrugs): modify these variables to change the default local state.
36const SHOULD_STUB_LOCAL = import.meta.env.VITE_STUB_LOCAL === 'true';
37const IS_STUBBED = isDevelopment && SHOULD_STUB_LOCAL;
39const INITIAL_WALLET = IS_STUBBED
41 import.meta.env.VITE_DEV_MNEMONIC as string,
42 import.meta.env.VITE_HD_PATH as string
45const INITIAL_MNEMONIC = IS_STUBBED
46 ? Just(import.meta.env.VITE_DEV_MNEMONIC)
48const INITIAL_POINT_CURSOR = IS_STUBBED ? Just(65792) : Nothing();
50function useInitialRoutes() {
51 const [hasDisclaimed] = useHasDisclaimed();
52 const { impliedTicket } = useImpliedTicket();
54 const isActivateUrl = window.location.pathname === '/activate';
58 { key: ROUTE_NAMES.LOGIN },
59 // { key: ROUTE_NAMES.POINTS },
60 // { key: ROUTE_NAMES.POINT },
64 if (impliedTicket || isActivateUrl) {
65 return [{ key: ROUTE_NAMES.ACTIVATE }];
69 return [{ key: ROUTE_NAMES.DISCLAIMER, data: { next: ROUTE_NAMES.LOGIN } }];
72 return [{ key: ROUTE_NAMES.LOGIN }];
82 const initialRoutes = useInitialRoutes();
83 const { loading, modalText, setModalText } = useRollerStore();
85 // full reload if the user changes their selected network in Metamask
88 if (window.ethereum) {
89 window.ethereum.on('chainChanged', () => {
90 document.location.reload();
97 render={(error: Error) => <GlobalErrorBoundary error={error} />}>
101 initialRoutes={initialRoutes}
102 initialNetworkType={INITIAL_NETWORK_TYPE}
103 initialWallet={INITIAL_WALLET}
104 initialMnemonic={INITIAL_MNEMONIC}
105 initialPointCursor={INITIAL_POINT_CURSOR}>
107 <ThemeProvider theme={light}>
111 <Modal show={modalText !== undefined} hide={() => setModalText('')}>
112 <Box width="280px">{modalText}</Box>
114 <LoadingOverlay loading={loading} />
121export 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