@@ -8,9 +8,7 @@ import * as need from 'lib/need';
8import { eqAddr, isZeroAddress } from './wallet';
8import { eqAddr, isZeroAddress } from './wallet';
10const NULL_PERMISSIONS = {
10const NULL_PERMISSIONS = {
11− isPlanet: false,
11+ isActive: false,
15 isOwner: false,
13 isOwner: false,
16 isActiveOwner: false,
14 isActiveOwner: false,
@@ -40,69 +38,70 @@ export default function usePermissionsForPoint(address, point) {
40 const { getDetails } = usePointCache();
38 const { getDetails } = usePointCache();
41 const { contracts } = useNetwork();
39 const { contracts } = useNetwork();
43− return getDetails(point).matchWith({
41+ const pointSize = azimuth.getPointSize(point);
44− Nothing: () => NULL_PERMISSIONS,
42+ const isPlanet = pointSize === azimuth.PointSize.Planet;
45− Just: ({ value: details }) => {
43+ const isStar = pointSize === azimuth.PointSize.Star;
46− const _contracts = need.contracts(contracts);
44+ const isGalaxy = pointSize === azimuth.PointSize.Galaxy;
45+ const isParent = isStar || isGalaxy;
46+ const staticPermissions = { isPlanet, isStar, isGalaxy, isParent };
48− const pointSize = azimuth.getPointSize(point);
48+ return {
49− const isPlanet = pointSize === azimuth.PointSize.Planet;
49+ ...staticPermissions,
50− const isStar = pointSize === azimuth.PointSize.Star;
50+ ...getDetails(point).matchWith({
51− const isGalaxy = pointSize === azimuth.PointSize.Galaxy;
51+ Nothing: () => NULL_PERMISSIONS,
52− const isParent = isStar || isGalaxy;
52+ Just: ({ value: details }) => {
53+ const _contracts = need.contracts(contracts);
54− const isActive = details.active;
55+ const isActive = details.active;
56− const isOwner = eqAddr(address, details.owner);
57+ const isOwner = eqAddr(address, details.owner);
57− const isActiveOwner = isOwner && isActive;
58+ const isActiveOwner = isOwner && isActive;
58− const isManagementProxy = eqAddr(address, details.managementProxy);
59+ const isManagementProxy = eqAddr(address, details.managementProxy);
59− const isSpawnProxy = eqAddr(address, details.spawnProxy);
60+ const isSpawnProxy = eqAddr(address, details.spawnProxy);
60− const isVotingProxy = eqAddr(address, details.votingProxy);
61+ const isVotingProxy = eqAddr(address, details.votingProxy);
61− const isTransferProxy = eqAddr(address, details.transferProxy);
62+ const isTransferProxy = eqAddr(address, details.transferProxy);
63− const isManagementProxySet = !isZeroAddress(details.managementProxy);
64+ const isManagementProxySet = !isZeroAddress(details.managementProxy);
64− const isSpawnProxySet = !isZeroAddress(details.spawnProxy);
65+ const isSpawnProxySet = !isZeroAddress(details.spawnProxy);
65− const isVotingProxySet = !isZeroAddress(details.votingProxy);
66+ const isVotingProxySet = !isZeroAddress(details.votingProxy);
66− const isTransferProxySet = !isZeroAddress(details.transferProxy);
67+ const isTransferProxySet = !isZeroAddress(details.transferProxy);
68− const canManage = isOwner || isManagementProxy;
69+ const canManage = isOwner || isManagementProxy;
69− const canTransfer = isOwner || isTransferProxy;
70+ const canTransfer = isOwner || isTransferProxy;
70− const canSpawn =
71+ const canSpawn =
73+ (isOwner || isSpawnProxy) &&
71− isParent && (isOwner || isSpawnProxy) && details.keyRevisionNumber > 0;
74+ details.keyRevisionNumber > 0;
72− const canVote = isGalaxy && isActive && (isOwner || isVotingProxy);
75+ const canVote = isGalaxy && isActive && (isOwner || isVotingProxy);
74− const spawnIsDelegatedSending = eqAddr(
77+ const spawnIsDelegatedSending = eqAddr(
75− _contracts.delegatedSending.address,
78+ _contracts.delegatedSending.address,
76− details.spawnProxy
79+ details.spawnProxy
85− isActive,
83+ isActive,
88− isActiveOwner,
86+ isActiveOwner,
89− isManagementProxy,
87+ isManagementProxy,
90− isSpawnProxy,
88+ isSpawnProxy,
91− isVotingProxy,
89+ isVotingProxy,
92− isTransferProxy,
90+ isTransferProxy,
94− isManagementProxySet,
92+ isManagementProxySet,
95− isSpawnProxySet,
93+ isSpawnProxySet,
96− isVotingProxySet,
94+ isVotingProxySet,
97− isTransferProxySet,
95+ isTransferProxySet,
99− canManage,
97+ canManage,
100− canTransfer,
98+ canTransfer,
101− canSpawn,
99+ canSpawn,
102− canVote,
100+ canVote,
104− spawnIsDelegatedSending,
102+ spawnIsDelegatedSending,