1import React, { useCallback, useEffect, useMemo } from 'react';
2import { Grid } from 'indigo-react';
3import * as ob from 'urbit-ob';
4import { ecliptic } from 'azimuth-js';
6import View from 'components/View';
7import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
8import ViewHeader from 'components/ViewHeader';
10import { useNetwork } from 'store/network';
11import { usePointCache } from 'store/pointCache';
12import { usePointCursor } from 'store/pointCursor';
13import { useHistory } from 'store/history';
15import { GAS_LIMITS } from 'lib/constants';
16import useEthereumTransaction from 'lib/useEthereumTransaction';
17import * as need from 'lib/need';
20 const { contracts } = useNetwork();
21 const _contracts = need.contracts(contracts);
23 const { pointCursor } = usePointCursor();
24 const point = need.point(pointCursor);
26 const { syncResidents } = usePointCache();
28 return useEthereumTransaction(
32 ? ecliptic.reject(_contracts, adoptee)
33 : ecliptic.adopt(_contracts, adoptee),
36 useCallback(() => syncResidents(point), [syncResidents, point]),
41export default function Adopt() {
42 const { pop, data } = useHistory();
44 const { adoptee, denied } = data;
46 const patp = useMemo(() => ob.patp(adoptee), [adoptee]);
48 const { construct, bind, completed } = useAdopt();
54 {completed ? 'Denied' : 'Denying'} adoption request to{' '}
55 <span className="mono">{patp}</span>
59 {completed ? 'Approved' : 'Approving'} adoption request to{' '}
60 <span className="mono">{patp}</span>
63 [patp, denied, completed]
67 construct(adoptee, denied);
68 }, [construct, adoptee, denied]);
71 <View pop={() => pop()} inset>
73 <Grid.Item full as={ViewHeader} className="mb2">
76 <Grid.Item full className="gray4 f5 mv2">
82 as={InlineEthereumTransaction}
83 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