on 33c8b8d help sign in
bridge/src/views/RejectTransfer.js
93 lines 2.6 kB history raw
1import React, { useCallback } from 'react';
2import cn from 'classnames';
3import { Grid, Text } from 'indigo-react';
4import * as azimuth from 'azimuth-js';
6import { useNetwork } from 'store/network';
7import { usePointCursor } from 'store/pointCursor';
8import { usePointCache } from 'store/pointCache';
9import { useHistory } from 'store/history';
11import * as need from 'lib/need';
12import useCurrentPointName from 'lib/useCurrentPointName';
13import useEthereumTransaction from 'lib/useEthereumTransaction';
14import { GAS_LIMITS } from 'lib/constants';
15import { ETH_ZERO_ADDR } from 'lib/wallet';
16import useLifecycle from 'lib/useLifecycle';
18import ViewHeader from 'components/ViewHeader';
19import MiniBackButton from 'components/MiniBackButton';
20import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
21import View from 'components/View';
23function useRejectTransfer() {
24 const { contracts } = useNetwork();
25 const { pointCursor } = usePointCursor();
26 const { syncDetails, syncControlledPoints } = usePointCache();
28 const _contracts = need.contracts(contracts);
29 const _point = need.point(pointCursor);
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 );
44 useLifecycle(() => {
45 construct();
46 });
48 return {
49 ...rest,
50 };
53export default function RejectTransfer() {
54 const { pop } = useHistory();
55 const { getDetails } = usePointCache();
56 const { pointCursor } = usePointCursor();
57 const _point = need.point(pointCursor);
59 const name = useCurrentPointName();
60 const _details = need.details(getDetails(_point));
62 const { completed, bind } = useRejectTransfer();
64 return (
65 <View inset>
66 <Grid>
67 <Grid.Item full as={MiniBackButton} onClick={() => pop()} />
69 <Grid.Item full as={ViewHeader}>
70 Reject Incoming Transfer
71 </Grid.Item>
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>
84 <Grid.Item
85 full
86 as={InlineEthereumTransaction}
87 {...bind}
88 onReturn={() => pop()}
89 />
90 </Grid>
91 </View>
92 );