@@ -40,7 +40,7 @@ import {
4040 detach,
4141 reject,
4242} from './utils/roller';
43−import { ROLLER_HOSTS } from './constants';
43+import { ETH_ZERO_ADDR, ROLLER_HOSTS } from './constants';
4444
4545import {
4646 Config,
@@ -89,12 +89,9 @@ export default function useRoller() {
8989 const {
9090 nextBatchTime,
9191 point,
92− invitePoints,
93− removeInvite,
9492 setNextBatchTime,
9593 setPendingTransactions,
9694 setInvites,
97− setInvitePoints,
9895 setInviteGeneratingNum,
9996 setPoints,
10097 updateInvite,
@@ -319,17 +316,19 @@ export default function useRoller() {
319316 };
320317
321318 const getInvites = useCallback(
322− async (isL2: boolean, getAll = false) => {
319+ async (isL2: boolean) => {
323320 try {
324321 const curPoint: number = Number(need.point(pointCursor));
325− setInvites(invitePoints.map(p => inviteTemplate(p)));
326−
327322 const _authToken = authToken.getOrElse(null);
328323 const _contracts = contracts.getOrElse(null);
329324
330325 if (_authToken && _contracts) {
331326 const spawnedPoints = isL2 ? await api.getSpawned(curPoint) : [];
332327
328+ const newPending = await api.getPendingByShip(curPoint);
329+ setPendingTransactions(newPending);
330+ const pendingSpawns = getPendingSpawns(newPending);
331+
333332 const availablePoints = await azimuth.azimuth.getUnspawnedChildren(
334333 _contracts,
335334 curPoint
@@ -340,9 +339,11 @@ export default function useRoller() {
340339 getDetails
341340 ).filter((p: number) => isPlanet(p) && availablePoints.includes(p));
342341
343− const invitePlanets = spawnedPoints.concat(
344− outgoingPoints.filter((p: number) => !spawnedPoints.includes(p))
345− );
342+ const invitePlanets = spawnedPoints
343+ .concat(
344+ outgoingPoints.filter((p: number) => !spawnedPoints.includes(p))
345+ )
346+ .filter((p: number) => !pendingSpawns.has(p));
346347
347348 const newInvites: Invite[] = [];
348349 // Iterate over all of the stored invites, generating wallet info as necessary
@@ -351,22 +352,28 @@ export default function useRoller() {
351352 for (let i = 0; i < invitePlanets.length; i++) {
352353 setInviteGeneratingNum(i + 1);
353354 const planet = invitePlanets[i];
355+ const storedInvite = storedInvites[planet];
354356 const invite =
355− storedInvites[planet] ||
356− (await generateInviteInfo(planet, _authToken));
357+ storedInvite || (await generateInviteInfo(planet, _authToken));
357358
358359 // TODO: check if the invite point's owner still matches the deterministic wallet address
359360 const planetInfo = await api.getPoint(planet);
360− if (invite.owner === planetInfo.ownership?.transferProxy?.address) {
361+ setStoredInvite(ls, invite);
362+
363+ if (
364+ invite.owner.toLowerCase() ===
365+ planetInfo.ownership?.owner?.address ||
366+ planetInfo.ownership?.transferProxy?.address !== ETH_ZERO_ADDR
367+ ) {
361368 newInvites.push(invite);
362− updateInvite(invite);
369+ updateInvite(curPoint, invite);
370+ }
371+
372+ if (storedInvite) {
363373 setStoredInvite(ls, invite);
364− } else {
365− removeInvite(planet);
366374 }
367375 }
368− setStoredInvites(ls, newInvites);
369− setInvites(newInvites);
376+ setInvites(curPoint, newInvites);
370377
371378 return newInvites;
372379 }
@@ -381,64 +388,11 @@ export default function useRoller() {
381388 controlledPoints,
382389 getDetails,
383390 pointCursor,
384− invitePoints,
385391 ls,
386− removeInvite,
387392 setInvites,
388393 setInviteGeneratingNum,
389− updateInvite,
390− ]
391− );
392−
393− const getNumInvites = useCallback(
394− async (isL2: boolean) => {
395− try {
396− const curPoint: number = Number(need.point(pointCursor));
397− const _authToken = authToken.getOrElse(null);
398− const _contracts = contracts.getOrElse(null);
399−
400− if (_authToken && _contracts) {
401− let spawnedPoints = isL2 ? await api.getSpawned(curPoint) : [];
402−
403− const availablePoints = await azimuth.azimuth.getUnspawnedChildren(
404− _contracts,
405− curPoint
406− );
407−
408− const newPending = await api.getPendingByShip(curPoint);
409− const pendingSpawns = getPendingSpawns(newPending);
410−
411− const outgoingPoints = getOutgoingPoints(
412− controlledPoints,
413− getDetails
414− ).filter((p: number) => isPlanet(p) && availablePoints.includes(p));
415−
416− const invitePoints = spawnedPoints
417− .concat(
418− outgoingPoints.filter((p: number) => !spawnedPoints.includes(p))
419− )
420− .filter((p: number) => !pendingSpawns.has(p));
421−
422− setPendingTransactions(newPending);
423− setInvitePoints(invitePoints);
424−
425− return invitePoints;
426− }
427− } catch (e) {
428− if (isDevelopment) {
429− console.warn(e);
430− }
431− }
432− },
433− [
434− api,
435− pointCursor,
436− authToken,
437− contracts,
438− controlledPoints,
439− getDetails,
440− setInvitePoints,
441394 setPendingTransactions,
395+ updateInvite,
442396 ]
443397 );
444398
@@ -851,7 +805,6 @@ export default function useRoller() {
851805 if (nextBatchTime - ONE_SECOND <= new Date().getTime()) {
852806 api.getRollerConfig().then(response => {
853807 setNextBatchTime(response.nextBatch);
854− getNumInvites(!!point?.isL2);
855808 });
856809 }
857810 }, 10000000);
@@ -866,7 +819,6 @@ export default function useRoller() {
866819 config,
867820 configureNetworkingKeys,
868821 getInvites,
869− getNumInvites,
870822 getPoints,
871823 getPointDetails,
872824 getPendingTransactions,