1import React, { useCallback, useMemo } from 'react';
2import { Just } from 'folktale/maybe';
3import { Text, Grid } from 'indigo-react';
4import * as keythereum from 'keythereum';
6import { useWallet } from 'store/wallet';
8import { EthereumWallet } from 'lib/wallet';
9import { WALLET_TYPES } from 'lib/constants';
10import useLoginView from 'lib/useLoginView';
12import { PassphraseInput } from 'form/Inputs';
15 buildPassphraseValidator,
17} from 'form/validators';
18import UploadInput from 'form/UploadInput';
19import SubmitButton from 'form/SubmitButton';
20import BridgeForm from 'form/BridgeForm';
21import { FORM_ERROR } from 'final-form';
22import FormError from 'form/FormError';
24export default function Keystore({ className, goHome }) {
25 useLoginView(WALLET_TYPES.KEYSTORE);
28 const { setWallet } = useWallet();
30 const validate = useMemo(
33 passphrase: buildPassphraseValidator(),
34 keystore: buildUploadValidator(),
39 const onSubmit = useCallback(
42 const json = JSON.parse(values.keystore);
43 const privateKey = keythereum.recover(values.passphrase, json);
45 const wallet = new EthereumWallet(privateKey);
46 setWallet(Just(wallet));
51 "Couldn't decrypt wallet. You may have entered an incorrect password.",
59 <Grid className={className}>
60 <Grid.Item full as={Text} className="f6 gray4 mb3">
61 Please upload your Ethereum keystore file. If your keystore file is
62 encrypted with a password, you'll also need to enter that below.
65 <BridgeForm validate={validate} onSubmit={onSubmit} afterSubmit={goHome}>
66 {({ handleSubmit }) => (
72 label="Upload Keystore file"
83 <Grid.Item full as={FormError} />
85 <Grid.Item full as={SubmitButton} handleSubmit={handleSubmit}>
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