1import React from 'react';
2import { azimuth } from 'azimuth-js';
3import * as need from '../../lib/need';
5import { ETH_ZERO_ADDR, CURVE_ZERO_ADDR, eqAddr } from '../../lib/wallet';
6import { H2, P } from '../../components/old/Base';
7import { Button } from '../../components/old/Base';
8import { ROUTE_NAMES } from '../../lib/routeNames';
9import { useHistory } from '../../store/history';
10import { useWallet } from '../../store/wallet';
11import { Grid } from 'indigo-react';
12import { usePointCursor } from 'store/pointCursor';
13import { usePointCache } from 'store/pointCache';
15const isPlanet = point =>
16 azimuth.getPointSize(point) === azimuth.PointSize.Planet;
19 const history = useHistory();
20 const { wallet } = useWallet();
21 const { pointCursor } = usePointCursor();
22 const point = need.pointCursor(pointCursor);
23 const { getDetails } = usePointCache();
24 const pointDetails = getDetails(point);
26 const addr = need.addressFromWallet(wallet);
28 const planet = isPlanet(point);
30 const isOwner = pointDetails.matchWith({
32 Just: details => eqAddr(details.value.owner, addr),
34 const isActive = pointDetails.matchWith({
36 Just: details => details.value.active,
38 const isActiveOwner = isOwner && isActive;
39 const canSetSpawnProxy = isActiveOwner && !planet;
40 const canSetManagementProxy = isActiveOwner;
44 pointDetails.matchWith({
46 Just: details => eqAddr(details.value.managementProxy, addr),
48 const canConfigureKeys = canManage && isActive;
50 const canIssueChild = pointDetails.matchWith({
53 const hasPermission = isOwner || eqAddr(details.value.spawnProxy, addr);
55 const isBooted = details.value.keyRevisionNumber > 0;
57 const isNotPlanet = !isPlanet(point);
59 return hasPermission && isBooted && isNotPlanet;
63 const canTransfer = pointDetails.matchWith({
66 eqAddr(deets.value.transferProxy, addr) ||
67 eqAddr(deets.value.owner, addr),
70 const canGenKeyfile = pointDetails.matchWith({
74 eqAddr(deets.value.owner, addr) ||
75 eqAddr(deets.value.managementProxy, addr);
77 const isBooted = deets.value.keyRevisionNumber > 0;
79 return hasPermission && isBooted;
83 const canAcceptTransfer = pointDetails.matchWith({
85 Just: deets => eqAddr(deets.value.transferProxy, addr),
88 const canCancelTransfer = pointDetails.matchWith({
91 eqAddr(deets.value.owner, addr) &&
92 !eqAddr(deets.value.transferProxy, ETH_ZERO_ADDR),
95 const displayReminder = pointDetails.matchWith({
99 deets.value.encryptionKey === CURVE_ZERO_ADDR &&
100 deets.value.authenticationKey === CURVE_ZERO_ADDR
109 <P>{`Before you can issue child points or generate your Arvo
110 keyfile, you need to set your public keys.`}</P>
115 <Grid.Item third={1}>
119 disabled={planet && !canIssueChild}
121 history.push(ROUTE_NAMES.ISSUE_CHILD);
129 disabled={!canAcceptTransfer}
131 history.push(ROUTE_NAMES.ACCEPT_TRANSFER);
133 {'Accept incoming transfer'}
139 disabled={!canCancelTransfer}
141 history.push(ROUTE_NAMES.CANCEL_TRANSFER);
143 {'Cancel outgoing transfer'}
149 disabled={!canGenKeyfile}
151 history.push(ROUTE_NAMES.GEN_KEYFILE);
153 {'Generate Arvo keyfile'}
156 <Grid.Item third={2}>
158 disabled={!canSetSpawnProxy}
162 history.push(ROUTE_NAMES.SET_SPAWN_PROXY);
164 {'Change spawn proxy'}
168 disabled={!canSetManagementProxy}
172 history.push(ROUTE_NAMES.SET_MANAGEMENT_PROXY);
174 {'Change management proxy'}
178 disabled={!canConfigureKeys}
182 history.push(ROUTE_NAMES.SET_KEYS);
188 disabled={!canTransfer}
192 history.push(ROUTE_NAMES.TRANSFER);
200 history.push(ROUTE_NAMES.INVITES_MANAGE);
210export default Actions;
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