@@ -1,27 +1,27 @@
11import React, { useCallback, useState } from 'react';
22import { Just, Nothing } from 'folktale/maybe';
33import * as azimuth from 'azimuth-js';
4−
54import { H4, Grid } from 'indigo-react';
65
7−import Ticket from './Login/Ticket';
8−import Mnemonic from './Login/Mnemonic';
9−import Advanced from './Login/Advanced';
10−import Hardware from './Login/Hardware';
11−
12−import * as need from 'lib/need';
13−
146import { useHistory } from 'store/history';
157import { useNetwork } from 'store/network';
168import { useWallet } from 'store/wallet';
179import { usePointCursor } from 'store/pointCursor';
1810
11+import * as need from 'lib/need';
12+import { WALLET_TYPES } from 'lib/wallet';
13+
1914import View from 'components/View';
2015import Tabs from 'components/Tabs';
2116import Crumbs from 'components/Crumbs';
2217import Footer from 'components/Footer';
2318import { ForwardButton, OfflineButton } from 'components/Buttons';
2419
20+import Ticket from './Login/Ticket';
21+import Mnemonic from './Login/Mnemonic';
22+import Advanced from './Login/Advanced';
23+import Hardware from './Login/Hardware';
24+
2525const NAMES = {
2626 TICKET: 'TICKET',
2727 MNEMONIC: 'MNEMONIC',
@@ -43,17 +43,37 @@ const OPTIONS = [
4343 { text: 'Advanced', value: NAMES.ADVANCED },
4444];
4545
46+const walletTypeToViewName = walletType => {
47+ switch (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:
58+ return NAMES.TICKET;
59+ default:
60+ return NAMES.TICKET;
61+ }
62+};
63+
4664export default function Login() {
4765 // globals
4866 const { push, replaceWith, names } = useHistory();
4967 const { contracts } = useNetwork();
50− const { wallet } = useWallet();
68+ const { wallet, walletType } = useWallet();
5169 const { pointCursor, setPointCursor } = usePointCursor();
5270
5371 const [deducing, setDeducing] = useState(false);
5472
5573 // inputs
56− const [currentTab, setCurrentTab] = useState(NAMES.TICKET);
74+ const [currentTab, setCurrentTab] = useState(
75+ walletTypeToViewName(walletType)
76+ );
5777
5878 const goToActivate = useCallback(
5979 () => replaceWith([{ key: names.LANDING }, { key: names.ACTIVATE }]),
@@ -75,8 +95,8 @@ export default function Login() {
7595
7696 setDeducing(true);
7797
78− // if no point cursor set by login logic, try to deduce it
7998 let deduced = pointCursor;
99+ // if no point cursor set by login logic, try to deduce it
80100 if (Nothing.hasInstance(deduced)) {
81101 const owned = await azimuth.azimuth.getOwnedPoints(
82102 _contracts,
@@ -84,14 +104,6 @@ export default function Login() {
84104 );
85105 if (owned.length === 1) {
86106 deduced = Just(owned[0]);
87− } else if (owned.length === 0) {
88− const canOwn = await azimuth.azimuth.getTransferringFor(
89− _contracts,
90− _wallet.address
91− );
92− if (canOwn.length === 1) {
93− deduced = Just(canOwn[0]);
94− }
95107 }
96108 }
97109