@@ -0,0 +1,93 @@
1+import React, { useCallback } from 'react';
2+import cn from 'classnames';
3+import { Grid, Text } from 'indigo-react';
4+import * as azimuth from 'azimuth-js';
5+
6+import { useNetwork } from 'store/network';
7+import { usePointCursor } from 'store/pointCursor';
8+import { usePointCache } from 'store/pointCache';
9+import { useHistory } from 'store/history';
10+
11+import * as need from 'lib/need';
12+import useCurrentPointName from 'lib/useCurrentPointName';
13+import useEthereumTransaction from 'lib/useEthereumTransaction';
14+import { GAS_LIMITS } from 'lib/constants';
15+import { ETH_ZERO_ADDR } from 'lib/wallet';
16+import useLifecycle from 'lib/useLifecycle';
17+
18+import ViewHeader from 'components/ViewHeader';
19+import MiniBackButton from 'components/MiniBackButton';
20+import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
21+import View from 'components/View';
22+
23+function useRejectTransfer() {
24+ const { contracts } = useNetwork();
25+ const { pointCursor } = usePointCursor();
26+ const { syncDetails, syncControlledPoints } = usePointCache();
27+
28+ const _contracts = need.contracts(contracts);
29+ const _point = need.point(pointCursor);
30+
31+ const { construct, ...rest } = useEthereumTransaction(
32+ useCallback(
33+ () =>
34+ azimuth.ecliptic.setTransferProxy(_contracts, _point, ETH_ZERO_ADDR),
35+ [_contracts, _point]
36+ ),
37+ useCallback(
38+ () => Promise.all([syncDetails(_point), syncControlledPoints()]),
39+ [_point, syncControlledPoints, syncDetails]
40+ ),
41+ GAS_LIMITS.SET_PROXY
42+ );
43+
44+ useLifecycle(() => {
45+ construct();
46+ });
47+
48+ return {
49+ ...rest,
50+ };
51+}
52+
53+export default function RejectTransfer() {
54+ const { pop } = useHistory();
55+ const { getDetails } = usePointCache();
56+ const { pointCursor } = usePointCursor();
57+ const _point = need.point(pointCursor);
58+
59+ const name = useCurrentPointName();
60+ const _details = need.details(getDetails(_point));
61+
62+ const { completed, bind } = useRejectTransfer();
63+
64+ return (
65+ <View inset>
66+ <Grid>
67+ <Grid.Item full as={MiniBackButton} onClick={() => pop()} />
68+
69+ <Grid.Item full as={ViewHeader}>
70+ Reject Incoming Transfer
71+ </Grid.Item>
72+
73+ <Grid.Item
74+ full
75+ as={Text}
76+ className={cn('f5', {
77+ green3: completed,
78+ })}>
79+ {completed
80+ ? `The incoming transfer of ${name} has been rejected.`
81+ : `Reject the incoming transfer of ${name} from ${_details.owner}.`}
82+ </Grid.Item>
83+
84+ <Grid.Item
85+ full
86+ as={InlineEthereumTransaction}
87+ {...bind}
88+ onReturn={() => pop()}
89+ />
90+ </Grid>
91+ </View>
92+ );
93+}