forked from BitGo/wallet-recovery-wizard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHederaForm.tsx
More file actions
141 lines (136 loc) · 4.66 KB
/
HederaForm.tsx
File metadata and controls
141 lines (136 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import { Form, FormikHelpers, FormikProvider, useFormik } from 'formik';
import { Link } from 'react-router-dom';
import * as Yup from 'yup';
import { Button, FormikTextfield } from '~/components';
const validationSchema = Yup.object({
backupKey: Yup.string().required(),
backupKeyId: Yup.string().optional(),
userKey: Yup.string().required(),
userKeyId: Yup.string().optional(),
recoveryDestination: Yup.string().required(),
rootAddress: Yup.string().required(),
maxFee: Yup.number().optional(),
startTime: Yup.number()
.required()
.min(Date.now() / 1000, 'Start time must be in the future'),
nodeId: Yup.string().optional(),
}).required();
export type HederaFormProps = {
onSubmit: (
values: HederaFormValues,
formikHelpers: FormikHelpers<HederaFormValues>
) => void | Promise<void>;
};
type HederaFormValues = Yup.Asserts<typeof validationSchema>;
export function HederaForm({ onSubmit }: HederaFormProps) {
const formik = useFormik<HederaFormValues>({
onSubmit,
initialValues: {
userKey: '',
userKeyId: '',
backupKey: '',
backupKeyId: '',
recoveryDestination: '',
rootAddress: '',
maxFee: undefined,
nodeId: undefined,
startTime: 0,
},
validationSchema,
});
return (
<FormikProvider value={formik}>
<Form>
<h4 className="tw-text-body tw-font-semibold tw-border-b-0.5 tw-border-solid tw-border-gray-700 tw-mb-4">
Self-Managed Cold Wallet
</h4>
<div className="tw-mb-4">
<FormikTextfield
HelperText="Your public user key (box A on your KeyCard)"
Label="Public User Key"
name="userKey"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="Your user key ID (check on your KeyCard). Note: most wallets don’t have this."
Label="User Key ID (Optional)"
name="userKeyId"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="Your public backup key (box B on your KeyCard)"
Label="Backup Public Key"
name="backupKey"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="Your backup key ID (check on your KeyCard). Note: most wallets don’t have this."
Label="Backup Key ID (Optional"
name="backupKeyId"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The base address of the wallet (also known as root address)"
Label="Base Address"
name="rootAddress"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The recipient address for the recovery transaction. If a memo ID is required, append it to the address. For example: 0.0.1234?memoId=3"
Label="Destination Address"
name="recoveryDestination"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="Specify when the recovery transaction starts, using a future UNIX timestamp in seconds. Once started, the validity window lasts for 180 seconds."
Label="Validity Window Start Time"
name="startTime"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The maximum fee that you’re willing to pay for the recovery transaction. Defaults to 10000000 tinybars (0.1 Hbar)"
Label="Maximum Fee in Base Units (Optional)"
name="maxFee"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The account ID of your preferred consensus node. If empty, defaults to node account ID 0.0.3."
Label="Node Account ID (Optional)"
name="nodeId"
Width="fill"
/>
</div>
<div className="tw-flex tw-flex-col-reverse sm:tw-justify-between sm:tw-flex-row tw-gap-1 tw-mt-4">
<Button Tag={Link} to="/" Variant="secondary" Width="hug">
Cancel
</Button>
<Button
Variant="primary"
Width="hug"
type="submit"
Disabled={formik.isSubmitting}
disabled={formik.isSubmitting}
>
{formik.isSubmitting ? 'Building...' : 'Build Transaction'}
</Button>
</div>
</Form>
</FormikProvider>
);
}