1import React, { useCallback, useMemo } 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 { useStarReleaseCache } from 'store/starRelease';
11import * as need from 'lib/need';
12import { useLocalRouter } from 'lib/LocalRouter';
13import useCurrentPointName from 'lib/useCurrentPointName';
14import useEthereumTransaction from 'lib/useEthereumTransaction';
15import { GAS_LIMITS } from 'lib/constants';
17import ViewHeader from 'components/ViewHeader';
18import NoticeBox from 'components/NoticeBox';
19import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
20import { AddressInput } from 'form/Inputs';
21import { composeValidator, buildAddressValidator } from 'form/validators';
22import BridgeForm from 'form/BridgeForm';
23import FormError from 'form/FormError';
25function useTransfer() {
26 const { contracts } = useNetwork();
27 const { pointCursor } = usePointCursor();
28 const { syncDetails } = usePointCache();
30 const _contracts = need.contracts(contracts);
31 const _point = need.point(pointCursor);
33 return useEthereumTransaction(
35 address => azimuth.ecliptic.setTransferProxy(_contracts, _point, address),
38 useCallback(() => syncDetails(_point), [_point, syncDetails]),
43export default function AdminTransfer() {
44 const { pop } = useLocalRouter();
45 const name = useCurrentPointName();
46 const { pointCursor } = usePointCursor();
47 const { starReleaseDetails } = useStarReleaseCache();
57 const needLockupWarning = useMemo(() => {
58 const point = need.point(pointCursor);
59 const az = azimuth.azimuth;
61 az.getPointSize(point) === az.PointSize.Galaxy &&
62 starReleaseDetails.map(a => a.kind).getOrElse('none') !== 'none'
64 }, [pointCursor, starReleaseDetails]);
66 const validate = useMemo(
67 () => composeValidator({ address: buildAddressValidator() }),
71 const onValues = useCallback(
72 ({ valid, values }) => {
74 construct(values.address);
79 [construct, unconstruct]
84 <Grid.Item full as={ViewHeader}>
88 <BridgeForm validate={validate} onValues={onValues}>
89 {({ handleSubmit, values }) => (
92 <Grid.Item full as={Text} className={cn('f5 wrap')}>
93 Transfer {name} to a new owner.
96 {!completed && needLockupWarning && (
97 <Grid.Item full as={NoticeBox}>
98 You have stars in lockup. These will not transfer with the{' '}
99 galaxy. If you wish, you must transfer the lockup separately.
104 <Grid.Item full as={Text} className="wrap">
105 Started transferring <span className="mono">{name}</span> to{' '}
107 <Grid.Item full as={Text}>
108 <span className="mono gray4">{values.address}</span>
110 <Grid.Item full as={Text} className="mt6">
111 Until they accept the transfer, you still own{' '}
112 <span className="mono">{name}</span>
123 label="Ethereum Address"
124 disabled={inputsLocked}
128 <Grid.Item full as={FormError} />
132 as={InlineEthereumTransaction}
134 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