1import React, { useCallback, useMemo, useState } from 'react';
2import cn from 'classnames';
3import { Grid, Text, Button } from 'indigo-react';
4import * as azimuth from 'azimuth-js';
5import { Row } from '@tlon/indigo-react';
7import { useNetwork } from 'store/network';
8import { usePointCursor } from 'store/pointCursor';
9import { usePointCache } from 'store/pointCache';
10import { useStarReleaseCache } from 'store/starRelease';
11import { useRollerStore } from 'store/rollerStore';
13import * as need from 'lib/need';
14import { useLocalRouter } from 'lib/LocalRouter';
15import useCurrentPointName from 'lib/useCurrentPointName';
16import useEthereumTransaction from 'lib/useEthereumTransaction';
17import { GAS_LIMITS } from 'lib/constants';
18import useRoller from 'lib/useRoller';
20import NoticeBox from 'components/NoticeBox';
21import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
22import { AddressInput } from 'form/Inputs';
23import { composeValidator, buildAddressValidator } from 'form/validators';
24import BridgeForm from 'form/BridgeForm';
25import FormError from 'form/FormError';
26import Window from 'components/L2/Window/Window';
27import HeaderPane from 'components/L2/Window/HeaderPane';
28import BodyPane from 'components/L2/Window/BodyPane';
30function useTransfer() {
31 const { contracts } = useNetwork();
32 const { pointCursor } = usePointCursor();
33 const { syncDetails } = usePointCache();
35 const _contracts = need.contracts(contracts);
36 const _point = need.point(pointCursor);
38 return useEthereumTransaction(
40 address => azimuth.ecliptic.setTransferProxy(_contracts, _point, address),
43 useCallback(() => syncDetails(_point), [_point, syncDetails]),
48export default function AdminTransfer() {
49 const { pop } = useLocalRouter();
50 const name = useCurrentPointName();
51 const { pointCursor } = usePointCursor();
52 const { starReleaseDetails } = useStarReleaseCache();
56 const { setProxyAddress, getPendingTransactions } = useRoller();
57 const [owner, setNewOwner] = useState('');
67 const point = need.point(pointCursor);
69 const needLockupWarning = useMemo(() => {
70 const az = azimuth.azimuth;
72 az.getPointSize(point) === az.PointSize.Galaxy &&
73 starReleaseDetails.map(a => a.kind).getOrElse('none') !== 'none'
75 }, [starReleaseDetails, point]);
77 const validate = useMemo(
78 () => composeValidator({ address: buildAddressValidator() }),
82 const transferPoint = useCallback(async () => {
84 if (owner === '') return;
86 await setProxyAddress('transfer', owner);
87 getPendingTransactions(point);
94 }, [owner, getPendingTransactions, point, pop, setProxyAddress]);
96 const onValues = useCallback(
97 ({ valid, values }) => {
99 construct(values.address);
100 setNewOwner(values.address);
106 [construct, unconstruct, setNewOwner]
112 <Row className="header-row">
113 <h5>Transfer Point</h5>
117 <Grid style={{ width: '100%' }} full gap={1}>
118 <BridgeForm validate={validate} onValues={onValues}>
119 {({ handleSubmit, values }) => (
122 <Grid.Item full as={Text} className={cn('f5 wrap')}>
123 Transfer {name} to a new owner.
126 {!completed && needLockupWarning && (
127 <Grid.Item full as={NoticeBox}>
128 You have stars in lockup. These will not transfer with the{' '}
129 galaxy. If you wish, you must transfer the lockup
135 <Grid.Item full as={Text} className="wrap">
136 Started transferring <span className="mono">{name}</span>
139 <Grid.Item full as={Text}>
140 <span className="mono gray4">{values.address}</span>
142 <Grid.Item full as={Text} className="mt6">
143 Until they accept the transfer, you still own{' '}
144 <span className="mono">{name}</span>
155 label="Ethereum Address"
156 disabled={inputsLocked}
160 <Grid.Item full as={FormError} />
166 className="set-proxy"
169 disabled={values.unset}
170 onClick={transferPoint}>
176 as={InlineEthereumTransaction}
178 onReturn={() => pop()}
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