1import React, { useCallback, useMemo } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import { Grid } from 'indigo-react';
5import { useWallet } from 'store/wallet';
7import { EthereumWallet, WALLET_TYPES, stripHexPrefix } from 'lib/wallet';
8import useLoginView from 'lib/useLoginView';
10import FormError from 'form/FormError';
11import BridgeForm from 'form/BridgeForm';
12import { PrivateKeyInput } from 'form/Inputs';
13import { composeValidator, buildPrivateKeyValidator } from 'form/validators';
15import SubmitButton from 'form/SubmitButton';
17export default function PrivateKey({ className, goHome }) {
18 useLoginView(WALLET_TYPES.PRIVATE_KEY);
20 const { setWallet } = useWallet();
22 const validate = useMemo(
25 privateKey: buildPrivateKeyValidator(64),
30 const onValues = useCallback(
31 ({ valid, values }) => {
33 const sec = Buffer.from(stripHexPrefix(values.privateKey), 'hex');
34 const newWallet = new EthereumWallet(sec);
35 setWallet(Just(newWallet));
44 <Grid className={className}>
45 <BridgeForm validate={validate} onValues={onValues} afterSubmit={goHome}>
46 {({ handleSubmit }) => (
54 <Grid.Item full as={FormError} />
55 <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