on faa39fb help sign in
bridge/src/views/Wallet.js
101 lines 2.5 kB history raw
1import React from 'react';
2import Maybe from 'folktale/maybe';
4import { H1, P } from '../components/old/Base';
5import { InnerLabelDropdown } from '../components/old/Base';
7import View from 'components/View';
8import { ForwardButton } from 'components/Buttons';
10import { useHistory } from '../store/history';
11import { useWallet } from '../store/wallet';
13import { ROUTE_NAMES } from '../lib/routeNames';
14import { WALLET_TYPES, renderWalletType } from '../lib/wallet';
15import useLifecycle from 'lib/useLifecycle';
17const kWalletOptions = [
18 {
19 title: 'Urbit Master Ticket',
20 value: WALLET_TYPES.TICKET,
21 },
22 {
23 title: 'Urbit Master Ticket (Shards)',
24 value: WALLET_TYPES.SHARDS,
25 },
26 {
27 type: 'divider',
28 },
29 {
30 title: 'Ledger',
31 value: WALLET_TYPES.LEDGER,
32 },
33 {
34 title: 'Trezor',
35 value: WALLET_TYPES.TREZOR,
36 },
37 {
38 type: 'divider',
39 },
40 {
41 title: 'BIP39 Mnemonic',
42 value: WALLET_TYPES.MNEMONIC,
43 },
44 {
45 title: 'Ethereum Private Key',
46 value: WALLET_TYPES.PRIVATE_KEY,
47 },
48 {
49 title: 'Ethereum Keystore File',
50 value: WALLET_TYPES.KEYSTORE,
51 },
52];
54export default function Wallet() {
55 const history = useHistory();
56 const { setWallet, walletType, setWalletType } = useWallet();
58 // reset wallet when this component is mounted
59 useLifecycle(() => setWallet(Maybe.Nothing()));
61 return (
62 <View>
63 <H1>Unlock a Wallet</H1>
65 <P>
66 To manage your assets, you need to unlock a wallet. Please select how
67 you would like to access your wallet.
68 </P>
70 <InnerLabelDropdown
71 title="Wallet Type:"
72 options={kWalletOptions}
73 handleUpdate={setWalletType}
74 currentSelectionTitle={renderWalletType(walletType)}
75 />
77 <ForwardButton
78 onClick={() =>
79 history.push(
80 walletType === WALLET_TYPES.MNEMONIC
81 ? ROUTE_NAMES.MNEMONIC
82 : walletType === WALLET_TYPES.TICKET
83 ? ROUTE_NAMES.TICKET
84 : walletType === WALLET_TYPES.SHARDS
85 ? ROUTE_NAMES.SHARDS
86 : walletType === WALLET_TYPES.LEDGER
87 ? ROUTE_NAMES.LEDGER
88 : walletType === WALLET_TYPES.TREZOR
89 ? ROUTE_NAMES.TREZOR
90 : walletType === WALLET_TYPES.PRIVATE_KEY
91 ? ROUTE_NAMES.PRIVATE_KEY
92 : walletType === WALLET_TYPES.KEYSTORE
93 ? ROUTE_NAMES.KEYSTORE
94 : ROUTE_NAMES.DEFAULT
95 )
96 }>
97 Continue
98 </ForwardButton>
99 </View>
100 );