1import React, { useCallback, useState } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import * as azimuth from 'azimuth-js';
4import { H4, Grid } from 'indigo-react';
6import { useHistory } from 'store/history';
7import { useNetwork } from 'store/network';
8import { useWallet } from 'store/wallet';
9import { usePointCursor } from 'store/pointCursor';
11import * as need from 'lib/need';
12import { WALLET_TYPES } from 'lib/wallet';
14import View from 'components/View';
15import Tabs from 'components/Tabs';
16import Crumbs from 'components/Crumbs';
17import Footer from 'components/Footer';
18import { ForwardButton, OfflineButton } from 'components/Buttons';
20import Ticket from './Login/Ticket';
21import Mnemonic from './Login/Mnemonic';
22import Advanced from './Login/Advanced';
23import Hardware from './Login/Hardware';
33 [NAMES.TICKET]: Ticket,
34 [NAMES.MNEMONIC]: Mnemonic,
35 [NAMES.HARDWARE]: Hardware,
36 [NAMES.ADVANCED]: Advanced,
40 { text: 'Master Ticket', value: NAMES.TICKET },
41 { text: 'Mnemonic', value: NAMES.MNEMONIC },
42 { text: 'Hardware', value: NAMES.HARDWARE },
43 { text: 'Advanced', value: NAMES.ADVANCED },
46const walletTypeToViewName = walletType => {
48 case WALLET_TYPES.MNEMONIC:
49 return NAMES.MNEMONIC;
50 case WALLET_TYPES.LEDGER:
51 case WALLET_TYPES.TREZOR:
52 return NAMES.HARDWARE;
53 case WALLET_TYPES.KEYSTORE:
54 case WALLET_TYPES.PRIVATE_KEY:
55 return NAMES.ADVANCED;
56 case WALLET_TYPES.TICKET:
57 case WALLET_TYPES.SHARDS:
64export default function Login() {
66 const { pop, push, names } = useHistory();
67 const { contracts } = useNetwork();
68 const { wallet, walletType } = useWallet();
69 const { pointCursor, setPointCursor } = usePointCursor();
72 const [currentTab, setCurrentTab] = useState(
73 walletTypeToViewName(walletType)
76 const goToActivate = useCallback(() => push(names.ACTIVATE), [
81 const goToPoints = useCallback(() => {
85 const goToPoint = useCallback(() => {
88 }, [goToPoints, push, names]);
90 const goHome = useCallback(async () => {
91 const _wallet = need.wallet(wallet);
92 const _contracts = need.contracts(contracts);
94 let deduced = pointCursor;
95 // if no point cursor set by login logic, try to deduce it
96 if (Nothing.hasInstance(deduced)) {
97 const owned = await azimuth.azimuth.getOwnedPoints(
101 if (owned.length === 1) {
102 deduced = Just(owned[0]);
106 // if we have a deduced point or one in the global context,
107 // navigate to that specific point, otherwise navigate to list of points
108 if (Just.hasInstance(deduced)) {
109 setPointCursor(deduced);
114 }, [contracts, pointCursor, setPointCursor, wallet, goToPoint, goToPoints]);
117 <View pop={pop} inset>
119 <Grid.Item full as={Crumbs} routes={[{ text: 'Multipass' }]} />
120 <Grid.Item full as={H4} className="mt4">
131 currentTab={currentTab}
132 onTabChange={setCurrentTab}
141 <Grid.Item full as={ForwardButton} onClick={goToActivate}>
145 <Grid.Item full as={OfflineButton} />
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