1import { azimuth } from 'azimuth-js';
3import { usePointCache } from 'store/pointCache';
4import { useNetwork } from 'store/network';
6import * as need from 'lib/need';
8import { eqAddr, ETH_ZERO_ADDR } from './wallet';
10const NULL_PERMISSIONS = {
17 isTransferProxy: false,
18 isManagementProxy: false,
20 isManagementProxySet: false,
21 isSpawnProxySet: false,
22 isVotingProxySet: false,
23 isTransferProxySet: false,
30 spawnIsDelegatedSending: false,
34 * @param {string} address
35 * @param {number} point
37export default function usePermissionsForPoint(address, point) {
38 const { getDetails } = usePointCache();
39 const { contracts } = useNetwork();
41 return getDetails(point).matchWith({
42 Nothing: () => NULL_PERMISSIONS,
43 Just: ({ value: details }) => {
44 const _contracts = need.contracts(contracts);
46 const pointSize = azimuth.getPointSize(point);
47 const isPlanet = pointSize === azimuth.PointSize.Planet;
48 const isStar = pointSize === azimuth.PointSize.Star;
49 const isGalaxy = pointSize === azimuth.PointSize.Galaxy;
51 const isOwner = eqAddr(address, details.owner);
52 const isActiveOwner = isOwner && details.active;
53 const isManagementProxy = eqAddr(address, details.managementProxy);
54 const isSpawnProxy = eqAddr(address, details.spawnProxy);
55 const isVotingProxy = eqAddr(address, details.votingProxy);
56 const isTransferProxy = eqAddr(address, details.transferProxy);
58 const isManagementProxySet = !eqAddr(
60 details.managementProxy
62 const isSpawnProxySet = !eqAddr(ETH_ZERO_ADDR, details.spawnProxy);
63 const isVotingProxySet = !eqAddr(ETH_ZERO_ADDR, details.votingProxy);
64 const isTransferProxySet = !eqAddr(ETH_ZERO_ADDR, details.transferProxy);
66 const canManage = isOwner || isManagementProxy;
67 const canTransfer = isOwner || isTransferProxy;
68 const canSpawn = (isStar || isGalaxy) && (isOwner || isSpawnProxy);
69 const canVote = isGalaxy && (isOwner || isVotingProxy);
71 const spawnIsDelegatedSending = eqAddr(
72 _contracts.delegatedSending.address,
96 spawnIsDelegatedSending,
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