@@ -1,6 +1,6 @@
1−import React, { useCallback } from 'react';
1+import React, { useCallback, useMemo } from 'react';
22import cn from 'classnames';
3−import { Grid, Text } from 'indigo-react';
3+import { Grid, Text, CheckboxInput } from 'indigo-react';
44import * as azimuth from 'azimuth-js';
55
66import { useNetwork } from 'store/network';
@@ -19,6 +19,9 @@ import ViewHeader from 'components/ViewHeader';
1919import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
2020import View from 'components/View';
2121
22+import BridgeForm from 'form/BridgeForm';
23+import { composeValidator, buildCheckboxValidator } from 'form/validators';
24+
2225function useAcceptTransfer() {
2326 const { contracts } = useNetwork();
2427 const { pointCursor } = usePointCursor();
@@ -29,15 +32,10 @@ function useAcceptTransfer() {
2932 const _point = need.point(pointCursor);
3033 const _address = need.addressFromWallet(wallet);
3134
32− const { construct, ...rest } = useEthereumTransaction(
35+ const transaction = useEthereumTransaction(
3336 useCallback(
34− () =>
35− azimuth.ecliptic.transferPoint(
36− _contracts,
37− _point,
38− _address,
39− /* reset */ true
40− ),
37+ reset =>
38+ azimuth.ecliptic.transferPoint(_contracts, _point, _address, reset),
4139 [_contracts, _point, _address]
4240 ),
4341 useCallback(
@@ -47,12 +45,8 @@ function useAcceptTransfer() {
4745 GAS_LIMITS.TRANSFER
4846 );
4947
50− useLifecycle(() => {
51− construct();
52− });
53−
5448 return {
55− ...rest,
49+ ...transaction,
5650 };
5751}
5852
@@ -61,7 +55,21 @@ export default function AcceptTransfer() {
6155
6256 const name = useCurrentPointName();
6357
64− const { completed, bind } = useAcceptTransfer();
58+ const { completed, bind, inputsLocked, construct } = useAcceptTransfer();
59+
60+ const initialValues = useMemo(() => ({ noReset: false }), []);
61+
62+ const validate = useMemo(
63+ () => composeValidator({ noReset: buildCheckboxValidator() }),
64+ []
65+ );
66+
67+ const onValues = useCallback(
68+ ({ valid, values, form }) => {
69+ construct(!values.noReset);
70+ },
71+ [construct]
72+ );
6573
6674 return (
6775 <View pop={pop} inset>
@@ -81,6 +89,21 @@ export default function AcceptTransfer() {
8189 : `Accept the incoming transfer of ${name}.`}
8290 </Grid.Item>
8391
92+ <BridgeForm
93+ validate={validate}
94+ initialValues={initialValues}
95+ onValues={onValues}>
96+ {() => (
97+ <Grid.Item
98+ full
99+ as={CheckboxInput}
100+ name="noReset"
101+ label="Retain proxies and key configuration, in case of transferring to self"
102+ disabled={inputsLocked}
103+ />
104+ )}
105+ </BridgeForm>
106+
84107 <Grid.Item
85108 full
86109 as={InlineEthereumTransaction}