on e15c5fd help sign in
bridge/src/components/Inputs.js
103 lines 2.3 kB history raw
1import React from 'react';
2import { Input } from 'indigo-react';
3import * as bip39 from 'bip39';
5import { DEFAULT_HD_PATH } from 'lib/wallet';
6import {
7 validateNotEmpty,
8 validateMnemonic,
9 validatePoint,
10 validateTicket,
11} from 'lib/validators';
12import { prependSig } from 'lib/transformers';
14const kExampleMnemonic = bip39.generateMnemonic();
16// const RequiredInput = advancedInput({
17// WrappedComponent: Input,
18// validators: [validateNotEmpty],
19// });
21// const NetworkKeyInput = advancedInput({
22// WrappedComponent: Input,
23// validators: [validateNotEmpty, validateNetworkKey],
24// });
26// const NetworkSeedInput = advancedInput({
27// WrappedComponent: Input,
28// validators: [validateNotEmpty, validateNetworkSeed],
29// });
31// const AddressInput = advancedInput({
32// WrappedComponent: Input,
33// validators: [validateEthereumAddress, validateNotEmpty],
34// });
36export function PassphraseInput(props) {
37 return (
38 <Input
39 type="password"
40 autoComplete="off"
41 placeholder="Passphrase"
42 {...props}
43 />
44 );
47export function MnemonicInput(props) {
48 return (
49 <Input
50 type="text"
51 autoComplete="off"
52 placeholder={`e.g. ${kExampleMnemonic}`}
53 validators={[validateMnemonic, validateNotEmpty]}
54 {...props}
55 />
56 );
59export function HdPathInput(props) {
60 return (
61 <Input
62 type="text"
63 autoComplete="off"
64 placeholder={`${DEFAULT_HD_PATH}`}
65 validators={[validateNotEmpty]}
66 {...props}
67 />
68 );
71// const GalaxyInput = advancedInput({
72// WrappedComponent: Input,
73// validators: [validateGalaxy, validateNotEmpty],
74// transformers: [prependSig],
75// });
77export function PointInput(props) {
78 return (
79 <Input
80 type="text"
81 placeholder="e.g. ~zod"
82 initialValue={props.initialValue || '~'}
83 validators={[validatePoint, validateNotEmpty]}
84 transformers={[prependSig]}
85 mono
86 {...props}
87 />
88 );
91//TODO needs to be fancier, displaying sig and dashes instead of •ing all
92export function TicketInput(props) {
93 return (
94 <Input
95 type="password"
96 placeholder="~master-ticket"
97 validators={[validateTicket, validateNotEmpty]}
98 transformers={[prependSig]}
99 mono
100 {...props}
101 />
102 );