1import React, { useCallback, useMemo } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import { Grid } from 'indigo-react';
5import { useWallet } from 'store/wallet';
7import { EthereumWallet } from 'lib/wallet';
8import { stripHexPrefix } from 'lib/utils/address';
9import { WALLET_TYPES } from 'lib/constants';
10import useLoginView from 'lib/useLoginView';
12import FormError from 'form/FormError';
13import BridgeForm from 'form/BridgeForm';
14import { PrivateKeyInput } from 'form/Inputs';
15import { composeValidator, buildPrivateKeyValidator } from 'form/validators';
17import SubmitButton from 'form/SubmitButton';
19export default function PrivateKey({ className, goHome }) {
20 useLoginView(WALLET_TYPES.PRIVATE_KEY);
22 const { setWallet } = useWallet();
24 const validate = useMemo(
27 privateKey: buildPrivateKeyValidator(64),
32 const onValues = useCallback(
33 ({ valid, values }) => {
35 const sec = Buffer.from(stripHexPrefix(values.privateKey), 'hex');
36 const newWallet = new EthereumWallet(sec);
37 setWallet(Just(newWallet));
46 <Grid className={className}>
47 <BridgeForm validate={validate} onValues={onValues} afterSubmit={goHome}>
48 {({ handleSubmit }) => (
56 <Grid.Item full as={FormError} />
57 <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