8import cn from 'classnames';
9import { Nothing } from 'folktale/maybe';
10import { Grid, Text, CheckboxInput, Button } from 'indigo-react';
11import * as azimuth from 'azimuth-js';
13import { useNetwork } from 'store/network';
14import { usePointCursor } from 'store/pointCursor';
15import { usePointCache } from 'store/pointCache';
16import { useWallet } from 'store/wallet';
18import * as need from 'lib/need';
19import useCurrentPointName from 'lib/useCurrentPointName';
20import useEthereumTransaction from 'lib/useEthereumTransaction';
21import { GAS_LIMITS } from 'lib/constants';
22import { useLocalRouter } from 'lib/LocalRouter';
23import { L1TxnType } from 'lib/types/PendingL1Transaction';
25import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
26import View from 'components/View';
27import Window from 'components/L2/Window/Window';
28import HeaderPane from 'components/L2/Window/HeaderPane';
29import BodyPane from 'components/L2/Window/BodyPane';
30import L2BackHeader from 'components/L2/Headers/L2BackHeader';
32import BridgeForm from 'form/BridgeForm';
33import { composeValidator, buildCheckboxValidator } from 'form/validators';
34import { Row } from '@tlon/indigo-react';
35import { useRollerStore } from 'store/rollerStore';
36import useRoller from 'lib/useRoller';
38function useAcceptTransfer() {
39 const { contracts }: any = useNetwork();
40 const { pointCursor }: any = usePointCursor();
41 const { syncExtras, syncControlledPoints }: any = usePointCache();
42 const { wallet }: any = useWallet();
44 const _contracts = need.contracts(contracts);
45 const _point = need.point(pointCursor);
46 const _address = need.addressFromWallet(wallet);
48 const transaction = useEthereumTransaction(
51 azimuth.ecliptic.transferPoint(_contracts, _point, _address, reset),
52 [_contracts, _point, _address]
55 () => Promise.all([syncExtras(_point), syncControlledPoints()]),
56 // eslint-disable-next-line react-hooks/exhaustive-deps
67export default function AcceptTransfer() {
68 const { pop }: any = useLocalRouter();
69 const { setPointCursor }: any = usePointCursor();
70 const { point } = useRollerStore();
71 const { transferPoint, checkForUpdates } = useRoller();
73 const { wallet }: any = useWallet();
74 const _address = need.addressFromWallet(wallet);
76 const name = useCurrentPointName();
78 const transferring = useRef(false);
79 const [reset, setReset] = useState(true);
87 } = useAcceptTransfer();
94 message: `${point.patp} has been transferred to you!`,
96 id: `accept-transfer-${point.value}`,
98 type: L1TxnType.cancelTransfer,
100 time: new Date().getTime(),
104 }, [completed]); // eslint-disable-line react-hooks/exhaustive-deps
106 const initialValues = useMemo(() => ({ noReset: false }), []);
108 const validate = useMemo(
109 () => composeValidator({ noReset: buildCheckboxValidator() }),
113 const onValues = useCallback(
114 ({ valid, values, form }) => {
115 construct(!values.noReset);
116 setReset(!values.noReset);
120 const goBack = useCallback(() => {
122 setPointCursor(Nothing());
123 }, [pop, setPointCursor]);
125 const acceptTransfer = useCallback(async () => {
126 if (transferring.current) {
130 transferring.current = true;
131 await transferPoint(_address, reset);
132 await checkForUpdates({
134 message: `${point.patp} has been transferred to you!`,
138 }, [goBack, transferPoint, checkForUpdates, point, _address, reset]);
144 className="cancel-transfer"
146 header={<L2BackHeader hideBalance={point.isL2} back={goBack} />}>
149 <Row className="header-row">
150 <h5>Accept Transfer</h5>
158 className={cn('f5 wrap', {
162 ? `${name} has been accepted.`
163 : `Accept the incoming transfer of ${name}.`}
169 initialValues={initialValues}
176 label="Retain proxies and key configuration, in case of transferring to self"
177 disabled={inputsLocked}
187 className="set-proxy mt4"
190 onClick={acceptTransfer}>
196 as={InlineEthereumTransaction}
198 onReturn={() => goBack()}
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