on df1910f help sign in
bridge/src/components/Inputs.js
118 lines 2.7 kB history raw
1import React from 'react';
2import { Input } from 'indigo-react';
3import * as bip39 from 'bip39';
5import InputSigil from 'components/InputSigil';
7import { DEFAULT_HD_PATH } from 'lib/wallet';
8import {
9 validateNotEmpty,
10 validateMnemonic,
11 validatePoint,
12 validateTicket,
13} from 'lib/validators';
14import { prependSig } from 'lib/transformers';
16const kExampleMnemonic = bip39.generateMnemonic();
18// const RequiredInput = advancedInput({
19// WrappedComponent: Input,
20// validators: [validateNotEmpty],
21// });
23// const NetworkKeyInput = advancedInput({
24// WrappedComponent: Input,
25// validators: [validateNotEmpty, validateNetworkKey],
26// });
28// const NetworkSeedInput = advancedInput({
29// WrappedComponent: Input,
30// validators: [validateNotEmpty, validateNetworkSeed],
31// });
33// const AddressInput = advancedInput({
34// WrappedComponent: Input,
35// validators: [validateEthereumAddress, validateNotEmpty],
36// });
38export function PassphraseInput(props) {
39 return (
40 <Input
41 type="password"
42 autoComplete="off"
43 placeholder="Passphrase"
44 {...props}
45 />
46 );
49export function MnemonicInput(props) {
50 return (
51 <Input
52 type="text"
53 autoComplete="off"
54 placeholder={`e.g. ${kExampleMnemonic}`}
55 validators={[validateMnemonic, validateNotEmpty]}
56 {...props}
57 />
58 );
61export function HdPathInput(props) {
62 return (
63 <Input
64 type="text"
65 autoComplete="off"
66 placeholder={`${DEFAULT_HD_PATH}`}
67 validators={[validateNotEmpty]}
68 {...props}
69 />
70 );
73// const GalaxyInput = advancedInput({
74// WrappedComponent: Input,
75// validators: [validateGalaxy, validateNotEmpty],
76// transformers: [prependSig],
77// });
79export function PointInput(props) {
80 return (
81 <Input
82 type="text"
83 placeholder="e.g. ~zod"
84 initialValue={props.initialValue || '~'}
85 validators={[validatePoint, validateNotEmpty]}
86 transformers={[prependSig]}
87 mono
88 accessory={
89 <InputSigil
90 patp={props.initialValue || '~'}
91 size={68}
92 margin={8}
93 pass={props.pass}
94 onPass={props.setPass}
95 focused={props.focused}
96 onFocus={props.setFocused}
97 error={props.error}
98 onError={props.setError}
99 />
100 }
101 {...props}
102 />
103 );
106//TODO needs to be fancier, displaying sig and dashes instead of •ing all
107export function TicketInput(props) {
108 return (
109 <Input
110 type="password"
111 placeholder="~master-ticket"
112 validators={[validateTicket, validateNotEmpty]}
113 transformers={[prependSig]}
114 mono
115 {...props}
116 />
117 );