@@ -1,4 +1,4 @@
1−import React, { useCallback } from 'react';
1+import React, { useCallback, useMemo } from 'react';
2import { Input, AccessoryIcon } from 'indigo-react';
2import { Input, AccessoryIcon } from 'indigo-react';
4import View from 'components/View';
4import View from 'components/View';
@@ -6,31 +6,35 @@ import { useTicketInput } from 'components/Inputs';
6import { ForwardButton } from 'components/Buttons';
6import { ForwardButton } from 'components/Buttons';
8import { useLocalRouter } from 'lib/LocalRouter';
8import { useLocalRouter } from 'lib/LocalRouter';
9+import { validateExactly } from 'lib/validators';
11+const STUB_VERIFY_TICKET = process.env.NODE_ENV === 'development';
13+//TODO deduplicate with PassportVerify
10export default function Verify({ STEP_NAMES, newWallet }) {
14export default function Verify({ STEP_NAMES, newWallet }) {
11 const { push } = useLocalRouter();
15 const { push } = useLocalRouter();
17+ const ticket = newWallet.value.wallet.ticket;
18+ const validators = useMemo(
19+ () => [validateExactly(ticket, 'Does not match expected master ticket.')],
13 const ticketInput = useTicketInput({
22 const ticketInput = useTicketInput({
14 name: 'ticket',
23 name: 'ticket',
15 label: 'New master ticket',
24 label: 'New master ticket',
25+ initialValue: STUB_VERIFY_TICKET ? ticket : undefined,
17− const ticket = ticketInput.data;
29+ const { pass } = ticketInput;
19 const next = useCallback(() => push(STEP_NAMES.RETICKET), [push, STEP_NAMES]);
31 const next = useCallback(() => push(STEP_NAMES.RETICKET), [push, STEP_NAMES]);
21− const matches = newWallet.value.wallet.ticket === ticket;
23− const displayTicketStatus = matches ? (
24− <AccessoryIcon.Success />
26− <AccessoryIcon.Failure />
31 Prove that you downloaded the new secrets!
35 Prove that you downloaded the new secrets!
32− <Input {...ticketInput} accessory={displayTicketStatus} />
36+ <Input {...ticketInput} />
33− <ForwardButton disabled={!matches} onClick={next}>
37+ <ForwardButton disabled={!pass} onClick={next}>
35 </ForwardButton>
39 </ForwardButton>