on master help sign in
Added isPlanet helper function
918709aWill Galebach
src/components/L2/Dropdowns/AccountsDropdown.tsx+2−2
@@ -24,6 +24,7 @@ import Dropdown from './Dropdown';
24import './AccountsDropdown.scss';
24import './AccountsDropdown.scss';
25import Modal from '../Modal';
25import Modal from '../Modal';
26import { convertToInt } from 'lib/convertToInt';
26import { convertToInt } from 'lib/convertToInt';
27+import { isPlanet } from 'lib/utils/point';
27
28
28interface AccountsDropdownProps {
29interface AccountsDropdownProps {
29 showMigrate: boolean;
30 showMigrate: boolean;
@@ -43,9 +44,8 @@ const AccountsDropdown = ({ showMigrate = false }: AccountsDropdownProps) => {
43 let networkKeysNotSet = true;
44 let networkKeysNotSet = true;
44
45
45 if (point) {
46 if (point) {
46− const pointSize = azimuth.getPointSize(point);
47 const details = need.details(getDetails(point));
47 const details = need.details(getDetails(point));
48− const isStarOrGalaxy = pointSize !== azimuth.PointSize.Planet;
48+ const isStarOrGalaxy = !isPlanet(point);
49 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
49 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
50 networkKeysNotSet = !currentL2 && isStarOrGalaxy && networkRevision === 0;
50 networkKeysNotSet = !currentL2 && isStarOrGalaxy && networkRevision === 0;
51 }
51 }
src/lib/reticket.js+2−3
@@ -17,6 +17,7 @@ import getSuggestedGasPrice from './getSuggestedGasPrice';
17import { GAS_LIMITS } from './constants';
17import { GAS_LIMITS } from './constants';
18import { toBN } from 'web3-utils';
18import { toBN } from 'web3-utils';
19import { safeToWei } from './lib';
19import { safeToWei } from './lib';
20+import { isPlanet } from './utils/point';
20
21
21// the initial network key revision is always 1
22// the initial network key revision is always 1
22const INITIAL_NETWORK_KEY_REVISION = 1;
23const INITIAL_NETWORK_KEY_REVISION = 1;
@@ -109,9 +110,7 @@ export async function reticketPointBetweenWallets({
109 // set spawn & voting proxies situationally
110 // set spawn & voting proxies situationally
110
111
111 let txs = [transferTmpTx, keysTx, managementTx];
112 let txs = [transferTmpTx, keysTx, managementTx];
112− if (
113+ if (!isPlanet(point)) {
113− azimuth.azimuth.getPointSize(point) !== azimuth.azimuth.PointSize.Planet
114− ) {
115 const spawnTx = azimuth.ecliptic.setSpawnProxy(
114 const spawnTx = azimuth.ecliptic.setSpawnProxy(
116 contracts,
115 contracts,
117 point,
116 point,
src/lib/useRoller.ts+3−8
@@ -31,6 +31,7 @@ import {
31} from 'store/storage/roller';
31} from 'store/storage/roller';
32import { usePointCache } from 'store/pointCache';
32import { usePointCache } from 'store/pointCache';
33import { getOutgoingPoints, maybeGetResult } from 'views/Points';
33import { getOutgoingPoints, maybeGetResult } from 'views/Points';
34+import { isPlanet } from './utils/point';
34
35
35const hasPoint = (point: number) => (invite: Invite) => invite.planet === point;
36const hasPoint = (point: number) => (invite: Invite) => invite.planet === point;
36
37
@@ -264,10 +265,7 @@ export default function useRoller() {
264 []
265 []
265 );
266 );
266 possibleMissingInvites = allSpawned.filter(
267 possibleMissingInvites = allSpawned.filter(
267− (p: number) =>
268− ownedPoints.includes(p) &&
268+ (p: number) => ownedPoints.includes(p) && isPlanet(p)
269− azimuth.azimuth.getPointSize(p) ===
270− azimuth.azimuth.PointSize.Planet
271 );
269 );
272 }
270 }
273
271
@@ -283,10 +281,7 @@ export default function useRoller() {
283
281
284 possibleMissingInvites = possibleMissingInvites.concat(
282 possibleMissingInvites = possibleMissingInvites.concat(
285 outgoingPoints.filter(
283 outgoingPoints.filter(
286− (p: number) =>
287− azimuth.azimuth.getPointSize(p) ===
288− azimuth.azimuth.PointSize.Planet &&
289− availablePoints.includes(p)
284+ (p: number) => isPlanet(p) && availablePoints.includes(p)
290 )
285 )
291 );
286 );
292
287
src/lib/utils/point.ts+3
@@ -2,3 +2,6 @@ import { azimuth } from 'azimuth-js';
2
2
3export const isStar = (point: number) =>
3export const isStar = (point: number) =>
4 azimuth.getPointSize(point) === azimuth.PointSize.Star;
4 azimuth.getPointSize(point) === azimuth.PointSize.Star;
5+
6+export const isPlanet = (point: number) =>
7+ azimuth.getPointSize(point) === azimuth.PointSize.Planet;
src/store/lib/useResidentsStore.ts+2−1
@@ -6,6 +6,7 @@ import { azimuth } from 'azimuth-js';
6import { useNetwork } from 'store/network';
6import { useNetwork } from 'store/network';
7
7
8import * as need from 'lib/need';
8import * as need from 'lib/need';
9+import { isPlanet } from 'lib/utils/point';
9
10
10const emptyCacheEntry = {
11const emptyCacheEntry = {
11 residentCount: Nothing(),
12 residentCount: Nothing(),
@@ -71,7 +72,7 @@ export default function useResidents() {
71
72
72 const syncResidents = useCallback(
73 const syncResidents = useCallback(
73 async point => {
74 async point => {
74− if (azimuth.getPointSize(point) === azimuth.PointSize.Planet) {
75+ if (isPlanet(point)) {
75 addToResidentCache(point, {
76 addToResidentCache(point, {
76 residentCount: Just(0),
77 residentCount: Just(0),
77 requestCount: Just(0),
78 requestCount: Just(0),
src/views/Invite/Cohort.js+2−2
@@ -30,6 +30,7 @@ import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
30import './Cohort.scss';
30import './Cohort.scss';
31import { getStoredInvites } from 'store/storage/roller';
31import { getStoredInvites } from 'store/storage/roller';
32import { ETH_ZERO_ADDR } from 'lib/constants';
32import { ETH_ZERO_ADDR } from 'lib/constants';
33+import { isPlanet } from 'lib/utils/point';
33
34
34const INVITES_PER_PAGE = 7;
35const INVITES_PER_PAGE = 7;
35const DEFAULT_NUM_INVITES = 5;
36const DEFAULT_NUM_INVITES = 5;
@@ -78,8 +79,7 @@ export default function InviteCohort() {
78 const p = possiblePoints[i];
79 const p = possiblePoints[i];
79 if (
80 if (
80 !invites.find(({ planet }) => planet === p) &&
81 !invites.find(({ planet }) => planet === p) &&
81− azimuth.azimuth.getPointSize(p) ===
82+ isPlanet(p) &&
82− azimuth.azimuth.PointSize.Planet &&
83 (await azimuth.azimuth.getOwner(_contracts, p)) === ETH_ZERO_ADDR
83 (await azimuth.azimuth.getOwner(_contracts, p)) === ETH_ZERO_ADDR
84 ) {
84 ) {
85 invitePoint = p;
85 invitePoint = p;
src/views/Point/MigrateL2.tsx+2−3
@@ -29,7 +29,7 @@ import { GAS_LIMITS } from 'lib/constants';
29import Dropdown from 'components/L2/Dropdowns/Dropdown';
29import Dropdown from 'components/L2/Dropdowns/Dropdown';
30import { PointLayer } from 'lib/types/PointLayer';
30import { PointLayer } from 'lib/types/PointLayer';
31import Sigil from 'components/Sigil';
31import Sigil from 'components/Sigil';
32−import { isStar } from 'lib/utils/point';
32+import { isPlanet, isStar } from 'lib/utils/point';
33
33
34const DUMMY_L2_ADDRESS = '0x1111111111111111111111111111111111111111';
34const DUMMY_L2_ADDRESS = '0x1111111111111111111111111111111111111111';
35
35
@@ -64,8 +64,7 @@ const useMigrate = () => {
64 useCallback(
64 useCallback(
65 (selectedPoint: number, transfer: boolean) => {
65 (selectedPoint: number, transfer: boolean) => {
66 setSelectedPoint(selectedPoint);
66 setSelectedPoint(selectedPoint);
67− return transfer ||
67+ return transfer || isPlanet(selectedPoint)
68− azimuth.getPointSize(selectedPoint) === azimuth.PointSize.Planet
69 ? ecliptic.transferPoint(
68 ? ecliptic.transferPoint(
70 _contracts,
69 _contracts,
71 selectedPoint,
70 selectedPoint,
src/views/Point/Point.js+4−3
@@ -35,6 +35,7 @@ import { isDevelopment } from 'lib/flags';
35import { convertToInt } from 'lib/convertToInt';
35import { convertToInt } from 'lib/convertToInt';
36import { usePointCache } from 'store/pointCache';
36import { usePointCache } from 'store/pointCache';
37import Modal from 'components/L2/Modal';
37import Modal from 'components/L2/Modal';
38+import { isPlanet } from 'lib/utils/point';
38
39
39function InviteForm({
40function InviteForm({
40 showInviteForm,
41 showInviteForm,
@@ -208,7 +209,7 @@ export default function Point() {
208 push,
209 push,
209 ]);
210 ]);
210
211
211− const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
212+ const planet = isPlanet(point);
212
213
213 const [showInviteForm, setShowInviteForm] = useState(false);
214 const [showInviteForm, setShowInviteForm] = useState(false);
214
215
@@ -282,7 +283,7 @@ export default function Point() {
282 />
283 />
283 </Grid.Item>
284 </Grid.Item>
284 )}
285 )}
285− {isPlanet && hasInvites && (
286+ {planet && hasInvites && (
286 <InviteForm
287 <InviteForm
287 showInviteForm={showInviteForm}
288 showInviteForm={showInviteForm}
288 setShowInviteForm={setShowInviteForm}
289 setShowInviteForm={setShowInviteForm}
@@ -295,7 +296,7 @@ export default function Point() {
295 showInvites={showInvites}
296 showInvites={showInvites}
296 />
297 />
297 )}
298 )}
298− {!loadedInvites && isPlanet && (
299+ {!loadedInvites && planet && (
299 <Grid.Item className="mv2" full>
300 <Grid.Item className="mv2" full>
300 Invite Group <Blinky />
301 Invite Group <Blinky />
301 </Grid.Item>
302 </Grid.Item>