@@ -1,27 +1,27 @@
1import React, { useCallback, useState } from 'react';
1import React, { useCallback, useState } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
2import { Just, Nothing } from 'folktale/maybe';
3import * as azimuth from 'azimuth-js';
3import * as azimuth from 'azimuth-js';
5import { H4, Grid } from 'indigo-react';
4import { H4, Grid } from 'indigo-react';
7−import Ticket from './Login/Ticket';
8−import Mnemonic from './Login/Mnemonic';
9−import Advanced from './Login/Advanced';
10−import Hardware from './Login/Hardware';
12−import * as need from 'lib/need';
14import { useHistory } from 'store/history';
6import { useHistory } from 'store/history';
15import { useNetwork } from 'store/network';
7import { useNetwork } from 'store/network';
16import { useWallet } from 'store/wallet';
8import { useWallet } from 'store/wallet';
17import { usePointCursor } from 'store/pointCursor';
9import { usePointCursor } from 'store/pointCursor';
11+import * as need from 'lib/need';
12+import { WALLET_TYPES } from 'lib/wallet';
19import View from 'components/View';
14import View from 'components/View';
20import Tabs from 'components/Tabs';
15import Tabs from 'components/Tabs';
21import Crumbs from 'components/Crumbs';
16import Crumbs from 'components/Crumbs';
22import Footer from 'components/Footer';
17import Footer from 'components/Footer';
23import { ForwardButton, OfflineButton } from 'components/Buttons';
18import { ForwardButton, OfflineButton } from 'components/Buttons';
20+import Ticket from './Login/Ticket';
21+import Mnemonic from './Login/Mnemonic';
22+import Advanced from './Login/Advanced';
23+import Hardware from './Login/Hardware';
25const NAMES = {
25const NAMES = {
26 TICKET: 'TICKET',
26 TICKET: 'TICKET',
27 MNEMONIC: 'MNEMONIC',
27 MNEMONIC: 'MNEMONIC',
@@ -43,17 +43,37 @@ const OPTIONS = [
43 { text: 'Advanced', value: NAMES.ADVANCED },
43 { text: 'Advanced', value: NAMES.ADVANCED },
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:
46export default function Login() {
64export default function Login() {
47 // globals
65 // globals
48 const { push, replaceWith, names } = useHistory();
66 const { push, replaceWith, names } = useHistory();
49 const { contracts } = useNetwork();
67 const { contracts } = useNetwork();
50− const { wallet } = useWallet();
68+ const { wallet, walletType } = useWallet();
51 const { pointCursor, setPointCursor } = usePointCursor();
69 const { pointCursor, setPointCursor } = usePointCursor();
53 const [deducing, setDeducing] = useState(false);
71 const [deducing, setDeducing] = useState(false);
56− const [currentTab, setCurrentTab] = useState(NAMES.TICKET);
74+ const [currentTab, setCurrentTab] = useState(
75+ walletTypeToViewName(walletType)
58 const goToActivate = useCallback(
78 const goToActivate = useCallback(
59 () => replaceWith([{ key: names.LANDING }, { key: names.ACTIVATE }]),
79 () => replaceWith([{ key: names.LANDING }, { key: names.ACTIVATE }]),
@@ -75,8 +95,8 @@ export default function Login() {
76 setDeducing(true);
96 setDeducing(true);
78− // if no point cursor set by login logic, try to deduce it
79 let deduced = pointCursor;
98 let deduced = pointCursor;
99+ // if no point cursor set by login logic, try to deduce it
80 if (Nothing.hasInstance(deduced)) {
100 if (Nothing.hasInstance(deduced)) {
81 const owned = await azimuth.azimuth.getOwnedPoints(
101 const owned = await azimuth.azimuth.getOwnedPoints(
82 _contracts,
102 _contracts,
@@ -84,14 +104,6 @@ export default function Login() {
85 if (owned.length === 1) {
105 if (owned.length === 1) {
86 deduced = Just(owned[0]);
106 deduced = Just(owned[0]);
87− } else if (owned.length === 0) {
88− const canOwn = await azimuth.azimuth.getTransferringFor(
92− if (canOwn.length === 1) {
93− deduced = Just(canOwn[0]);