1import { azimuth } from 'azimuth-js';
3import { usePointCache } from 'store/pointCache';
5import { eqAddr, ETH_ZERO_ADDR } from './wallet';
7const NULL_PERMISSIONS = {
14 isTransferProxy: false,
15 isManagementProxy: false,
17 isManagementProxySet: false,
18 isSpawnProxySet: false,
19 isVotingProxySet: false,
20 isTransferProxySet: false,
29 * @param {string} address
30 * @param {number} point
32export default function usePermissionsForPoint(address, point) {
33 const { getDetails } = usePointCache();
35 return getDetails(point).matchWith({
36 Nothing: () => NULL_PERMISSIONS,
37 Just: ({ value: details }) => {
38 const pointSize = azimuth.getPointSize(point);
39 const isPlanet = pointSize === azimuth.PointSize.Planet;
40 const isStar = pointSize === azimuth.PointSize.Star;
41 const isGalaxy = pointSize === azimuth.PointSize.Galaxy;
43 const isOwner = eqAddr(address, details.owner);
44 const isActiveOwner = isOwner && details.active;
45 const isManagementProxy = eqAddr(address, details.managementProxy);
46 const isSpawnProxy = eqAddr(address, details.spawnProxy);
47 const isVotingProxy = eqAddr(address, details.votingProxy);
48 const isTransferProxy = eqAddr(address, details.transferProxy);
50 const isManagementProxySet = !eqAddr(
52 details.managementProxy
54 const isSpawnProxySet = !eqAddr(ETH_ZERO_ADDR, details.spawnProxy);
55 const isVotingProxySet = !eqAddr(ETH_ZERO_ADDR, details.votingProxy);
56 const isTransferProxySet = !eqAddr(ETH_ZERO_ADDR, details.transferProxy);
58 const canManage = isOwner || isManagementProxy;
59 const canTransfer = isOwner || isTransferProxy;
60 const canSpawn = (isStar || isGalaxy) && (isOwner || isSpawnProxy);
61 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