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 'components/Grid';
13const isPlanet = point =>
14 azimuth.getPointSize(point) === azimuth.PointSize.Planet;
15const isStar = point => azimuth.getPointSize(point) === azimuth.PointSize.Star;
17function Actions(props) {
18 const history = useHistory();
19 const { wallet } = useWallet();
20 const { online, point, pointDetails, invites } = props;
22 const addr = need.addressFromWallet(wallet);
24 const planet = isPlanet(point);
25 const star = isStar(point);
27 const isOwner = pointDetails.matchWith({
29 Just: details => eqAddr(details.value.owner, addr),
31 const isActive = pointDetails.matchWith({
33 Just: details => details.value.active,
35 const isActiveOwner = isOwner && isActive;
36 const canSetSpawnProxy = isActiveOwner && !planet;
37 const canSetManagementProxy = isActiveOwner;
41 pointDetails.matchWith({
43 Just: details => eqAddr(details.value.managementProxy, addr),
45 const canConfigureKeys = canManage && isActive;
47 const canIssueChild = pointDetails.matchWith({
50 const hasPermission = isOwner || eqAddr(details.value.spawnProxy, addr);
52 const isBooted = details.value.keyRevisionNumber > 0;
54 const isNotPlanet = !isPlanet(point);
56 return hasPermission && isBooted && isNotPlanet;
60 const hasInvites = invites.matchWith({
62 Just: count => count.value > 0,
65 const canTransfer = pointDetails.matchWith({
68 eqAddr(deets.value.transferProxy, addr) ||
69 eqAddr(deets.value.owner, addr),
72 const canGenKeyfile = pointDetails.matchWith({
76 eqAddr(deets.value.owner, addr) ||
77 eqAddr(deets.value.managementProxy, addr);
79 const isBooted = deets.value.keyRevisionNumber > 0;
81 return hasPermission && isBooted;
85 const canAcceptTransfer = pointDetails.matchWith({
87 Just: deets => eqAddr(deets.value.transferProxy, addr),
90 const canCancelTransfer = pointDetails.matchWith({
93 eqAddr(deets.value.owner, addr) &&
94 !eqAddr(deets.value.transferProxy, ETH_ZERO_ADDR),
97 const displayReminder = pointDetails.matchWith({
101 deets.value.encryptionKey === CURVE_ZERO_ADDR &&
102 deets.value.authenticationKey === CURVE_ZERO_ADDR
107 let inviteAction = null;
111 disabled={!isActiveOwner || !online || !hasInvites}
114 onClick={() => history.push(ROUTE_NAMES.INVITES_SEND)}>
118 Just: count => count.value,
127 disabled={!(isActiveOwner && canIssueChild) || !online}
131 history.push(ROUTE_NAMES.INVITES_MANAGE);
142 <P>{`Before you can issue child points or generate your Arvo
143 keyfile, you need to set your public keys.`}</P>
148 <Grid.Item third={1}>
152 disabled={(online || planet) && !canIssueChild}
154 history.push(ROUTE_NAMES.ISSUE_CHILD);
162 disabled={online && !canAcceptTransfer}
164 history.push(ROUTE_NAMES.ACCEPT_TRANSFER);
166 {'Accept incoming transfer'}
172 disabled={online && !canCancelTransfer}
174 history.push(ROUTE_NAMES.CANCEL_TRANSFER);
176 {'Cancel outgoing transfer'}
182 disabled={online && !canGenKeyfile}
184 history.push(ROUTE_NAMES.GEN_KEYFILE);
186 {'Generate Arvo keyfile'}
189 <Grid.Item third={2}>
191 disabled={online && !canSetSpawnProxy}
195 history.push(ROUTE_NAMES.SET_SPAWN_PROXY);
197 {'Change spawn proxy'}
201 disabled={online && !canSetManagementProxy}
205 history.push(ROUTE_NAMES.SET_MANAGEMENT_PROXY);
207 {'Change management proxy'}
211 disabled={online && !canConfigureKeys}
215 history.push(ROUTE_NAMES.SET_KEYS);
221 disabled={online && !canTransfer}
225 history.push(ROUTE_NAMES.TRANSFER);
230 <Grid.Item third={3}>{inviteAction}</Grid.Item>
236export 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