1import { azimuth } from 'azimuth-js';
3import { usePointCache } from 'store/pointCache';
5import { eqAddr } from './wallet';
7const NULL_PERMISSIONS = {
9 isTransferProxy: false,
10 isManagementProxy: false,
18 * @param {string} address
19 * @param {number} point
21export default function usePermissionsForPoint(address, point) {
22 const { getDetails } = usePointCache();
24 return getDetails(point).matchWith({
25 Nothing: () => NULL_PERMISSIONS,
26 Just: ({ value: details }) => {
27 const pointSize = azimuth.getPointSize(point);
28 const isPlanet = pointSize === azimuth.PointSize.Planet;
29 const isStar = pointSize === azimuth.PointSize.Star;
30 const isGalaxy = pointSize === azimuth.PointSize.Galaxy;
32 const isOwner = eqAddr(address, details.owner);
33 const isTransferProxy = eqAddr(address, details.transferProxy);
34 const isManagementProxy = eqAddr(address, details.managementProxy);
35 const isSpawnProxy = eqAddr(address, details.spawnProxy);
36 const isVotingProxy = eqAddr(address, details.votingProxy);
38 const canManage = isOwner || isManagementProxy;
39 const canTransfer = isOwner || isTransferProxy;
41 const canSpawn = (isStar || isGalaxy) && (isOwner || isSpawnProxy);
42 const canVote = isGalaxy && (isOwner || isVotingProxy);
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