1import React, { useCallback, useMemo } from 'react';
2import { Just } from 'folktale/maybe';
3import { P, Grid } from 'indigo-react';
4import * as keythereum from 'keythereum';
6import { useWallet } from 'store/wallet';
8import { EthereumWallet, WALLET_TYPES } from 'lib/wallet';
9import useLoginView from 'lib/useLoginView';
11import { PassphraseInput } from 'form/Inputs';
14 buildPassphraseValidator,
16} from 'form/validators';
17import UploadInput from 'form/UploadInput';
18import ContinueButton from './ContinueButton';
19import BridgeForm from 'form/BridgeForm';
20import { FORM_ERROR } from 'final-form';
21import FormError from 'form/FormError';
23export default function Keystore({ className, goHome }) {
24 useLoginView(WALLET_TYPES.KEYSTORE);
27 const { setWallet } = useWallet();
29 const validate = useMemo(
32 passphrase: buildPassphraseValidator(),
33 keystore: buildUploadValidator(),
38 const onSubmit = useCallback(
41 const json = JSON.parse(values.keystore);
42 const privateKey = keythereum.recover(values.passphrase, json);
44 const wallet = new EthereumWallet(privateKey);
45 setWallet(Just(wallet));
50 "Couldn't decrypt wallet. You may have entered an incorrect password.",
58 <Grid className={className}>
59 <Grid.Item full as={P}>
60 Please upload your Ethereum keystore file. If your keystore file is
61 encrypted with a password, you'll also need to enter that below.
64 <BridgeForm validate={validate} onSubmit={onSubmit} afterSubmit={goHome}>
65 {({ handleSubmit }) => (
71 label="Upload Keystore file"
82 <Grid.Item full as={FormError} />
84 <Grid.Item full as={ContinueButton} 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