1import React from 'react';
2import { useEffect } from 'react';
3import { Just, Nothing } from 'folktale/maybe';
4import { IndigoApp } from 'indigo-react';
6import Router from 'components/Router';
8import Provider from 'store/Provider';
10import { ROUTE_NAMES } from 'lib/routeNames';
11import { ROUTES } from 'lib/router';
12import { NETWORK_TYPES } from 'lib/network';
13import { walletFromMnemonic } from 'lib/wallet';
14import { isDevelopment, isMainnet, isRopsten } from 'lib/flags';
15import useImpliedTicket from 'lib/useImpliedTicket';
16import useHasDisclaimed from 'lib/useHasDisclaimed';
18import 'style/index.scss';
19import { ThemeProvider } from 'styled-components';
20import light from '@tlon/indigo-light';
22import WithErrorBoundary from 'components/WithErrorBoundary';
23import GlobalErrorBoundary from 'components/GlobalErrorBoundary';
24import Modal from 'components/L2/Modal';
25import { useRollerStore } from 'store/rollerStore';
26import { Box } from '@tlon/indigo-react';
27import LoadingOverlay from 'components/L2/LoadingOverlay';
29const INITIAL_NETWORK_TYPE = isRopsten
30 ? NETWORK_TYPES.ROPSTEN
31 : isDevelopment && !isMainnet
33 : NETWORK_TYPES.MAINNET;
35// NB(shrugs): modify these variables to change the default local state.
36const SHOULD_STUB_LOCAL = process.env.REACT_APP_STUB_LOCAL === 'true';
37const IS_STUBBED = isDevelopment && SHOULD_STUB_LOCAL;
39const INITIAL_WALLET = IS_STUBBED
41 process.env.REACT_APP_DEV_MNEMONIC,
42 process.env.REACT_APP_HD_PATH
45const INITIAL_MNEMONIC = IS_STUBBED
46 ? Just(process.env.REACT_APP_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 }];
76 const initialRoutes = useInitialRoutes();
77 const { loading, modalText, setModalText } = useRollerStore();
79 // full reload if the user changes their selected network in Metamask
82 if (window.ethereum) {
83 window.ethereum.on('chainChanged', () => {
84 document.location.reload();
90 <WithErrorBoundary render={error => <GlobalErrorBoundary error={error} />}>
94 initialRoutes={initialRoutes}
95 initialNetworkType={INITIAL_NETWORK_TYPE}
96 initialWallet={INITIAL_WALLET}
97 initialMnemonic={INITIAL_MNEMONIC}
98 initialPointCursor={INITIAL_POINT_CURSOR}>
100 <ThemeProvider theme={light}>
104 <Modal show={modalText !== undefined} hide={() => setModalText()}>
105 <Box width="280px">{modalText}</Box>
107 <LoadingOverlay loading={loading} />
113export 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