on master help sign in
Added isPlanet helper function
commit918709a4e145e4ac1540b32509815a578f75f182 authorWill Galebach <willbach@gmail.com> dateMon 13 Sep 2021, 21:55 (5 years ago) parent91efb05
8 files changed+20−22
src/components/L2/Dropdowns/AccountsDropdown.tsx+2−2 src/lib/reticket.js+2−3 src/lib/useRoller.ts+3−8 src/lib/utils/point.ts+3 src/store/lib/useResidentsStore.ts+2−1 src/views/Invite/Cohort.js+2−2 src/views/Point/MigrateL2.tsx+2−3 src/views/Point/Point.js+4−3
src/components/L2/Dropdowns/AccountsDropdown.tsx+2−2
@@ -24,6 +24,7 @@ import Dropdown from './Dropdown';
2424import './AccountsDropdown.scss';
2525import Modal from '../Modal';
2626import { convertToInt } from 'lib/convertToInt';
27+import { isPlanet } from 'lib/utils/point';
2728
2829interface AccountsDropdownProps {
2930 showMigrate: boolean;
@@ -43,9 +44,8 @@ const AccountsDropdown = ({ showMigrate = false }: AccountsDropdownProps) => {
4344 let networkKeysNotSet = true;
4445
4546 if (point) {
46− const pointSize = azimuth.getPointSize(point);
4747 const details = need.details(getDetails(point));
48− const isStarOrGalaxy = pointSize !== azimuth.PointSize.Planet;
48+ const isStarOrGalaxy = !isPlanet(point);
4949 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
5050 networkKeysNotSet = !currentL2 && isStarOrGalaxy && networkRevision === 0;
5151 }
src/lib/reticket.js+2−3
@@ -17,6 +17,7 @@ import getSuggestedGasPrice from './getSuggestedGasPrice';
1717import { GAS_LIMITS } from './constants';
1818import { toBN } from 'web3-utils';
1919import { safeToWei } from './lib';
20+import { isPlanet } from './utils/point';
2021
2122// the initial network key revision is always 1
2223const INITIAL_NETWORK_KEY_REVISION = 1;
@@ -109,9 +110,7 @@ export async function reticketPointBetweenWallets({
109110 // set spawn & voting proxies situationally
110111
111112 let txs = [transferTmpTx, keysTx, managementTx];
112− if (
113− azimuth.azimuth.getPointSize(point) !== azimuth.azimuth.PointSize.Planet
114− ) {
113+ if (!isPlanet(point)) {
115114 const spawnTx = azimuth.ecliptic.setSpawnProxy(
116115 contracts,
117116 point,
src/lib/useRoller.ts+3−8
@@ -31,6 +31,7 @@ import {
3131} from 'store/storage/roller';
3232import { usePointCache } from 'store/pointCache';
3333import { getOutgoingPoints, maybeGetResult } from 'views/Points';
34+import { isPlanet } from './utils/point';
3435
3536const hasPoint = (point: number) => (invite: Invite) => invite.planet === point;
3637
@@ -264,10 +265,7 @@ export default function useRoller() {
264265 []
265266 );
266267 possibleMissingInvites = allSpawned.filter(
267− (p: number) =>
268− ownedPoints.includes(p) &&
269− azimuth.azimuth.getPointSize(p) ===
270− azimuth.azimuth.PointSize.Planet
268+ (p: number) => ownedPoints.includes(p) && isPlanet(p)
271269 );
272270 }
273271
@@ -283,10 +281,7 @@ export default function useRoller() {
283281
284282 possibleMissingInvites = possibleMissingInvites.concat(
285283 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)
290285 )
291286 );
292287
src/lib/utils/point.ts+3
@@ -2,3 +2,6 @@ import { azimuth } from 'azimuth-js';
22
33export const isStar = (point: number) =>
44 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';
66import { useNetwork } from 'store/network';
77
88import * as need from 'lib/need';
9+import { isPlanet } from 'lib/utils/point';
910
1011const emptyCacheEntry = {
1112 residentCount: Nothing(),
@@ -71,7 +72,7 @@ export default function useResidents() {
7172
7273 const syncResidents = useCallback(
7374 async point => {
74− if (azimuth.getPointSize(point) === azimuth.PointSize.Planet) {
75+ if (isPlanet(point)) {
7576 addToResidentCache(point, {
7677 residentCount: Just(0),
7778 requestCount: Just(0),
src/views/Invite/Cohort.js+2−2
@@ -30,6 +30,7 @@ import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
3030import './Cohort.scss';
3131import { getStoredInvites } from 'store/storage/roller';
3232import { ETH_ZERO_ADDR } from 'lib/constants';
33+import { isPlanet } from 'lib/utils/point';
3334
3435const INVITES_PER_PAGE = 7;
3536const DEFAULT_NUM_INVITES = 5;
@@ -78,8 +79,7 @@ export default function InviteCohort() {
7879 const p = possiblePoints[i];
7980 if (
8081 !invites.find(({ planet }) => planet === p) &&
81− azimuth.azimuth.getPointSize(p) ===
82− azimuth.azimuth.PointSize.Planet &&
82+ isPlanet(p) &&
8383 (await azimuth.azimuth.getOwner(_contracts, p)) === ETH_ZERO_ADDR
8484 ) {
8585 invitePoint = p;
src/views/Point/MigrateL2.tsx+2−3
@@ -29,7 +29,7 @@ import { GAS_LIMITS } from 'lib/constants';
2929import Dropdown from 'components/L2/Dropdowns/Dropdown';
3030import { PointLayer } from 'lib/types/PointLayer';
3131import Sigil from 'components/Sigil';
32−import { isStar } from 'lib/utils/point';
32+import { isPlanet, isStar } from 'lib/utils/point';
3333
3434const DUMMY_L2_ADDRESS = '0x1111111111111111111111111111111111111111';
3535
@@ -64,8 +64,7 @@ const useMigrate = () => {
6464 useCallback(
6565 (selectedPoint: number, transfer: boolean) => {
6666 setSelectedPoint(selectedPoint);
67− return transfer ||
68− azimuth.getPointSize(selectedPoint) === azimuth.PointSize.Planet
67+ return transfer || isPlanet(selectedPoint)
6968 ? ecliptic.transferPoint(
7069 _contracts,
7170 selectedPoint,
src/views/Point/Point.js+4−3
@@ -35,6 +35,7 @@ import { isDevelopment } from 'lib/flags';
3535import { convertToInt } from 'lib/convertToInt';
3636import { usePointCache } from 'store/pointCache';
3737import Modal from 'components/L2/Modal';
38+import { isPlanet } from 'lib/utils/point';
3839
3940function InviteForm({
4041 showInviteForm,
@@ -208,7 +209,7 @@ export default function Point() {
208209 push,
209210 ]);
210211
211− const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
212+ const planet = isPlanet(point);
212213
213214 const [showInviteForm, setShowInviteForm] = useState(false);
214215
@@ -282,7 +283,7 @@ export default function Point() {
282283 />
283284 </Grid.Item>
284285 )}
285− {isPlanet && hasInvites && (
286+ {planet && hasInvites && (
286287 <InviteForm
287288 showInviteForm={showInviteForm}
288289 setShowInviteForm={setShowInviteForm}
@@ -295,7 +296,7 @@ export default function Point() {
295296 showInvites={showInvites}
296297 />
297298 )}
298− {!loadedInvites && isPlanet && (
299+ {!loadedInvites && planet && (
299300 <Grid.Item className="mv2" full>
300301 Invite Group <Blinky />
301302 </Grid.Item>