1import React from 'react';
2import Maybe from 'folktale/maybe';
3import { azimuth } from 'azimuth-js';
4import * as need from '../../lib/need';
6import { ETH_ZERO_ADDR, CURVE_ZERO_ADDR, eqAddr } from '../../lib/wallet';
7import { H2, P } from '../../components/old/Base';
8import { Button } from '../../components/old/Base';
9import { ROUTE_NAMES } from '../../lib/routeNames';
10import { useHistory } from '../../store/history';
11import { useWallet } from '../../store/wallet';
12import { Grid } from 'indigo-react';
13import { usePointCursor } from 'store/pointCursor';
14import { usePointCache } from 'store/pointCache';
16const isPlanet = point =>
17 azimuth.getPointSize(point) === azimuth.PointSize.Planet;
19function Actions(props) {
20 const history = useHistory();
21 const { wallet } = useWallet();
22 const { pointCursor } = usePointCursor();
23 const point = need.pointCursor(pointCursor);
24 const { pointCache } = usePointCache();
25 const pointDetails = Maybe.Just(
26 need.fromPointCache(Maybe.Just(pointCache), point)
29 const addr = need.addressFromWallet(wallet);
31 const planet = isPlanet(point);
33 const isOwner = pointDetails.matchWith({
35 Just: details => eqAddr(details.value.owner, addr),
37 const isActive = pointDetails.matchWith({
39 Just: details => details.value.active,
41 const isActiveOwner = isOwner && isActive;
42 const canSetSpawnProxy = isActiveOwner && !planet;
43 const canSetManagementProxy = isActiveOwner;
47 pointDetails.matchWith({
49 Just: details => eqAddr(details.value.managementProxy, addr),
51 const canConfigureKeys = canManage && isActive;
53 const canIssueChild = pointDetails.matchWith({
56 const hasPermission = isOwner || eqAddr(details.value.spawnProxy, addr);
58 const isBooted = details.value.keyRevisionNumber > 0;
60 const isNotPlanet = !isPlanet(point);
62 return hasPermission && isBooted && isNotPlanet;
66 const canTransfer = pointDetails.matchWith({
69 eqAddr(deets.value.transferProxy, addr) ||
70 eqAddr(deets.value.owner, addr),
73 const canGenKeyfile = pointDetails.matchWith({
77 eqAddr(deets.value.owner, addr) ||
78 eqAddr(deets.value.managementProxy, addr);
80 const isBooted = deets.value.keyRevisionNumber > 0;
82 return hasPermission && isBooted;
86 const canAcceptTransfer = pointDetails.matchWith({
88 Just: deets => eqAddr(deets.value.transferProxy, addr),
91 const canCancelTransfer = pointDetails.matchWith({
94 eqAddr(deets.value.owner, addr) &&
95 !eqAddr(deets.value.transferProxy, ETH_ZERO_ADDR),
98 const displayReminder = pointDetails.matchWith({
102 deets.value.encryptionKey === CURVE_ZERO_ADDR &&
103 deets.value.authenticationKey === CURVE_ZERO_ADDR
112 <P>{`Before you can issue child points or generate your Arvo
113 keyfile, you need to set your public keys.`}</P>
118 <Grid.Item third={1}>
122 disabled={planet && !canIssueChild}
124 history.push(ROUTE_NAMES.ISSUE_CHILD);
132 disabled={!canAcceptTransfer}
134 history.push(ROUTE_NAMES.ACCEPT_TRANSFER);
136 {'Accept incoming transfer'}
142 disabled={!canCancelTransfer}
144 history.push(ROUTE_NAMES.CANCEL_TRANSFER);
146 {'Cancel outgoing transfer'}
152 disabled={!canGenKeyfile}
154 history.push(ROUTE_NAMES.GEN_KEYFILE);
156 {'Generate Arvo keyfile'}
159 <Grid.Item third={2}>
161 disabled={!canSetSpawnProxy}
165 history.push(ROUTE_NAMES.SET_SPAWN_PROXY);
167 {'Change spawn proxy'}
171 disabled={!canSetManagementProxy}
175 history.push(ROUTE_NAMES.SET_MANAGEMENT_PROXY);
177 {'Change management proxy'}
181 disabled={!canConfigureKeys}
185 history.push(ROUTE_NAMES.SET_KEYS);
191 disabled={!canTransfer}
195 history.push(ROUTE_NAMES.TRANSFER);
203 history.push(ROUTE_NAMES.INVITES_MANAGE);
213export 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