on cbb04ce help sign in
bridge/src/views/Admin/AdminTransfer.js
92 lines 2.6 kB history raw
1import React, { useCallback, useEffect } from 'react';
2import cn from 'classnames';
3import { Grid, Text, Input } from 'indigo-react';
4import * as azimuth from 'azimuth-js';
6import { useNetwork } from 'store/network';
7import { usePointCursor } from 'store/pointCursor';
8import { usePointCache } from 'store/pointCache';
10import * as need from 'lib/need';
11import { useLocalRouter } from 'lib/LocalRouter';
12import { useAddressInput } from 'lib/useInputs';
13import useCurrentPointName from 'lib/useCurrentPointName';
14import useEthereumTransaction from 'lib/useEthereumTransaction';
15import { GAS_LIMITS } from 'lib/constants';
17import ViewHeader from 'components/ViewHeader';
18import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
20function useTransfer() {
21 const { contracts } = useNetwork();
22 const { pointCursor } = usePointCursor();
23 const { syncDetails } = usePointCache();
25 const _contracts = need.contracts(contracts);
26 const _point = need.point(pointCursor);
28 return useEthereumTransaction(
29 useCallback(
30 address => azimuth.ecliptic.setTransferProxy(_contracts, _point, address),
31 [_contracts, _point]
32 ),
33 useCallback(() => syncDetails(_point), [_point, syncDetails]),
34 GAS_LIMITS.SET_PROXY
35 );
38export default function AdminTransfer() {
39 const { pop } = useLocalRouter();
40 const name = useCurrentPointName();
42 const {
43 construct,
44 unconstruct,
45 completed,
46 inputsLocked,
47 bind,
48 } = useTransfer();
50 const [addressInput, { pass, data: address }] = useAddressInput({
51 name: 'address',
52 label: `Ethereum Address`,
53 disabled: inputsLocked,
54 });
56 useEffect(() => {
57 if (pass) {
58 construct(address);
59 } else {
60 unconstruct();
61 }
62 }, [pass, address, construct, unconstruct]);
64 return (
65 <Grid>
66 <Grid.Item full as={ViewHeader}>
67 Transfer Point
68 </Grid.Item>
69 <Grid.Item
70 full
71 as={Text}
72 className={cn('f5', {
73 green3: completed,
74 })}>
75 {completed
76 ? `${address} is now the Transfer Proxy for ${name} and can accept the transfer by logging into Multipass themselves. Until they accept your transfer, you will still have ownership over ${name}.`
77 : `Transfer ${name} to a new owner.`}
78 </Grid.Item>
80 {!completed && (
81 <Grid.Item full as={Input} {...addressInput} className="mv4" />
82 )}
84 <Grid.Item
85 full
86 as={InlineEthereumTransaction}
87 {...bind}
88 onReturn={() => pop()}
89 />
90 </Grid>
91 );