1import React, { useCallback, useEffect } from 'react';
2import cn from 'classnames';
3import { Grid, Text, Button } from 'indigo-react';
4import * as azimuth from 'azimuth-js';
5import { Nothing } from 'folktale/maybe';
7import { useNetwork } from 'store/network';
8import { usePointCursor } from 'store/pointCursor';
9import { usePointCache } from 'store/pointCache';
10import { useRollerStore } from 'store/rollerStore';
12import * as need from 'lib/need';
13import { useLocalRouter } from 'lib/LocalRouter';
14import useCurrentPointName from 'lib/useCurrentPointName';
15import useEthereumTransaction from 'lib/useEthereumTransaction';
16import { ETH_ZERO_ADDR, GAS_LIMITS } from 'lib/constants';
17import useLifecycle from 'lib/useLifecycle';
18import useRoller from 'lib/useRoller';
19import { L1TxnType } from 'lib/types/PendingL1Transaction';
21import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
22import View from 'components/View';
23import Window from 'components/L2/Window/Window';
24import HeaderPane from 'components/L2/Window/HeaderPane';
25import BodyPane from 'components/L2/Window/BodyPane';
26import L2BackHeader from 'components/L2/Headers/L2BackHeader';
28function useCancelTransfer() {
29 const { contracts }: any = useNetwork();
30 const { pointCursor }: any = usePointCursor();
31 const { syncDetails }: any = usePointCache();
33 const _contracts = need.contracts(contracts);
34 const _point = need.point(pointCursor);
36 const { construct, ...rest } = useEthereumTransaction(
39 azimuth.ecliptic.setTransferProxy(_contracts, _point, ETH_ZERO_ADDR),
42 useCallback(() => syncDetails(_point), [_point, syncDetails]),
55function AdminCancelTransfer() {
56 const { pop }: any = useLocalRouter();
57 const { getDetails }: any = usePointCache();
58 const { point } = useRollerStore();
59 const { setProxyAddress, checkForUpdates } = useRoller();
60 const { pointCursor, setPointCursor }: any = usePointCursor();
61 const _point = need.point(pointCursor);
63 const name = useCurrentPointName();
64 const _details = need.details(getDetails(_point));
66 const { completed, bind, txHashes } = useCancelTransfer();
72 message: `${point.patp} transfer cancelled`,
74 id: `cancel-${point.value}`,
76 type: L1TxnType.cancelTransfer,
78 time: new Date().getTime(),
82 }, [completed]); // eslint-disable-line react-hooks/exhaustive-deps
84 const goBack = useCallback(() => {
86 setPointCursor(Nothing());
87 }, [pop, setPointCursor]);
89 const cancelTransfer = useCallback(async () => {
90 await setProxyAddress('transfer', ETH_ZERO_ADDR);
91 await checkForUpdates({
93 message: `${point.patp} transfer cancelled`,
96 }, [setProxyAddress, goBack, checkForUpdates, point]);
98 const formattedName = <span className="mono">{name}</span>;
99 const formattedProxy = <span className="mono">{_details.transferProxy}</span>;
104 <h5>Cancel Outgoing Transfer</h5>
110 style={{ fontSize: 14 }}
111 className={cn('f5 wrap mb5', {
115 <>The outgoing transfer of {formattedName} has been cancelled.</>
118 Cancel the outgoing transfer of {formattedName} to{' '}
128 className="set-proxy mt4 w-full"
131 onClick={cancelTransfer}>
137 as={InlineEthereumTransaction}
139 onReturn={() => goBack()}
147export default function CancelTransfer() {
148 const { pop }: any = useLocalRouter();
149 const { setPointCursor }: any = usePointCursor();
150 const { point } = useRollerStore();
152 const goBack = useCallback(() => {
153 setPointCursor(Nothing());
155 }, [pop, setPointCursor]);
160 className="cancel-transfer"
162 header={<L2BackHeader hideBalance={point.isL2} back={goBack} />}>
163 <AdminCancelTransfer />
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list