@@ -1,110 +1,101 @@
1−import Maybe from 'folktale/maybe';
2import React from 'react';
1import React from 'react';
2+import Maybe from 'folktale/maybe';
3−import { Button, H1, P } from '../components/old/Base';
4+import { H1, P } from '../components/old/Base';
4import { InnerLabelDropdown } from '../components/old/Base';
5import { InnerLabelDropdown } from '../components/old/Base';
7+import View from 'components/View';
8+import { ForwardButton } from 'components/Buttons';
10+import { useHistory } from '../store/history';
11+import { useWallet } from '../store/wallet';
6import { ROUTE_NAMES } from '../lib/routeNames';
13import { ROUTE_NAMES } from '../lib/routeNames';
7−import { withHistory } from '../store/history';
8import { WALLET_TYPES, renderWalletType } from '../lib/wallet';
14import { WALLET_TYPES, renderWalletType } from '../lib/wallet';
9−import { compose } from '../lib/lib';
15+import useLifecycle from 'lib/useLifecycle';
10−import { withWallet } from '../store/wallet';
11−import View from 'components/View';
13−class Wallet extends React.Component {
17+const kWalletOptions = [
14− componentDidMount() {
18+ {
15− const { setWallet } = this.props;
19+ title: 'Urbit Master Ticket',
16− setWallet(Maybe.Nothing());
20+ value: WALLET_TYPES.TICKET,
23+ title: 'Urbit Master Ticket (Shards)',
24+ value: WALLET_TYPES.SHARDS,
31+ value: WALLET_TYPES.LEDGER,
35+ value: WALLET_TYPES.TREZOR,
41+ title: 'BIP39 Mnemonic',
42+ value: WALLET_TYPES.MNEMONIC,
45+ title: 'Ethereum Private Key',
46+ value: WALLET_TYPES.PRIVATE_KEY,
49+ title: 'Ethereum Keystore File',
50+ value: WALLET_TYPES.KEYSTORE,
19− getWalletOptions() {
54+export default function Wallet() {
20− return [
55+ const history = useHistory();
21− {
56+ const { setWallet, walletType, setWalletType } = useWallet();
22− title: 'Urbit Master Ticket',
23− value: WALLET_TYPES.TICKET,
26− title: 'Urbit Master Ticket (Shards)',
27− value: WALLET_TYPES.SHARDS,
34− value: WALLET_TYPES.LEDGER,
38− value: WALLET_TYPES.TREZOR,
44− title: 'BIP39 Mnemonic',
45− value: WALLET_TYPES.MNEMONIC,
48− title: 'Ethereum Private Key',
49− value: WALLET_TYPES.PRIVATE_KEY,
52− title: 'Ethereum Keystore File',
53− value: WALLET_TYPES.KEYSTORE,
58− render() {
58+ // reset wallet when this component is mounted
59− const { props } = this;
59+ useLifecycle(() => setWallet(Maybe.Nothing()));
60− const walletOptions = this.getWalletOptions();
64− <H1>{'Unlock a Wallet'}</H1>
63+ <H1>Unlock a Wallet</H1>
67− {`To manage your assets, you need to unlock a wallet.
66+ To manage your assets, you need to unlock a wallet. Please select how
68− Please select how you would like to access your wallet.`}
67+ you would like to access your wallet.
71− <InnerLabelDropdown
70+ <InnerLabelDropdown
72− className={'mb-10 mt-6'}
73− title={'Wallet Type:'}
71+ title="Wallet Type:"
74− options={walletOptions}
72+ options={kWalletOptions}
75− handleUpdate={props.setWalletType}
73+ handleUpdate={setWalletType}
76− currentSelectionTitle={renderWalletType(props.walletType)}
74+ currentSelectionTitle={renderWalletType(walletType)}
79− <Button
77+ <ForwardButton
81− onClick={() =>
78+ onClick={() =>
82− props.history.push(
79+ history.push(
83− props.walletType === WALLET_TYPES.MNEMONIC
80+ walletType === WALLET_TYPES.MNEMONIC
84− ? ROUTE_NAMES.MNEMONIC
81+ ? ROUTE_NAMES.MNEMONIC
85− : props.walletType === WALLET_TYPES.TICKET
82+ : walletType === WALLET_TYPES.TICKET
86− ? ROUTE_NAMES.TICKET
83+ ? ROUTE_NAMES.TICKET
87− : props.walletType === WALLET_TYPES.SHARDS
84+ : walletType === WALLET_TYPES.SHARDS
88− ? ROUTE_NAMES.SHARDS
85+ ? ROUTE_NAMES.SHARDS
89− : props.walletType === WALLET_TYPES.LEDGER
86+ : walletType === WALLET_TYPES.LEDGER
90− ? ROUTE_NAMES.LEDGER
87+ ? ROUTE_NAMES.LEDGER
91− : props.walletType === WALLET_TYPES.TREZOR
88+ : walletType === WALLET_TYPES.TREZOR
92− ? ROUTE_NAMES.TREZOR
89+ ? ROUTE_NAMES.TREZOR
93− : props.walletType === WALLET_TYPES.PRIVATE_KEY
90+ : walletType === WALLET_TYPES.PRIVATE_KEY
94− ? ROUTE_NAMES.PRIVATE_KEY
91+ ? ROUTE_NAMES.PRIVATE_KEY
95− : props.walletType === WALLET_TYPES.KEYSTORE
92+ : walletType === WALLET_TYPES.KEYSTORE
96− ? ROUTE_NAMES.KEYSTORE
93+ ? ROUTE_NAMES.KEYSTORE
97− : ROUTE_NAMES.DEFAULT
94+ : ROUTE_NAMES.DEFAULT
100− {'Continue →'}
97+ Continue
101− </Button>
98+ </ForwardButton>
107−export default compose(