@@ -19,7 +19,6 @@ import {
19 setStoredInvites,
19 setStoredInvites,
20} from 'store/storage/roller';
20} from 'store/storage/roller';
21import { usePointCache } from 'store/pointCache';
21import { usePointCache } from 'store/pointCache';
22−import { getOutgoingPoints } from 'views/Points';
24import { getUpdatedPointMessage, isPlanet, toL1Details } from './utils/point';
23import { getUpdatedPointMessage, isPlanet, toL1Details } from './utils/point';
25import { convertToInt } from './convertToInt';
24import { convertToInt } from './convertToInt';
@@ -30,9 +29,6 @@ import {
30 submitL2Transaction,
29 submitL2Transaction,
31 getTimeToNextBatch,
30 getTimeToNextBatch,
32 registerProxyAddress,
31 registerProxyAddress,
36 isL2Spawn,
32 isL2Spawn,
37} from './utils/roller';
33} from './utils/roller';
38import { ETH_ZERO_ADDR, ROLLER_HOSTS, TEN_SECONDS } from './constants';
34import { ETH_ZERO_ADDR, ROLLER_HOSTS, TEN_SECONDS } from './constants';
@@ -81,7 +77,6 @@ export default function useRoller() {
81 const { pointCursor }: any = usePointCursor();
77 const { pointCursor }: any = usePointCursor();
82 const { web3, contracts }: any = useNetwork();
78 const { web3, contracts }: any = useNetwork();
83 const allPoints: any = usePointCache();
79 const allPoints: any = usePointCache();
84− const controlledPoints = allPoints?.controlledPoints;
85 const getDetails = allPoints?.getDetails;
80 const getDetails = allPoints?.getDetails;
87 const { setNextRoll } = useTimerStore();
82 const { setNextRoll } = useTimerStore();
@@ -90,6 +85,7 @@ export default function useRoller() {
90 nextBatchTime,
85 nextBatchTime,
93 nextQuotaTime,
89 nextQuotaTime,
94 removeInvite,
90 removeInvite,
95 setNextBatchTime,
91 setNextBatchTime,
@@ -263,7 +259,7 @@ export default function useRoller() {
265 const spawnPoint = useCallback(
261 const spawnPoint = useCallback(
266− async (pointToSpawn: number) => {
262+ async (pointToSpawn: number, destinationAddress: string) => {
267 if (quotaReached()) {
263 if (quotaReached()) {
@@ -291,7 +287,7 @@ export default function useRoller() {
292 await submitL2Transaction({
288 await submitL2Transaction({
294− address: _wallet.address,
290+ address: destinationAddress,
295 wallet: _wallet,
291 wallet: _wallet,
296 ship: _point,
292 ship: _point,
@@ -347,10 +343,11 @@ export default function useRoller() {
350− const outgoingPoints = getOutgoingPoints(
346+ const outgoingPoints = pointList
351− controlledPoints,
347+ .filter(
353− ).filter((p: number) => isPlanet(p) && availablePoints.includes(p));
348+ ({ value, isPlanet }) => isPlanet && availablePoints.includes(value)
350+ .map(({ value }) => value);
355 const invitePlanets = spawnedPoints
352 const invitePlanets = spawnedPoints
@@ -405,11 +402,10 @@ export default function useRoller() {
406 authToken,
403 authToken,
407 contracts,
404 contracts,
410 pointCursor,
405 pointCursor,
413 removeInvite,
409 removeInvite,
414 setInvites,
410 setInvites,
415 setInvitesLoading,
411 setInvitesLoading,
@@ -789,75 +785,40 @@ export default function useRoller() {
789 [api, connector, point, wallet, web3, walletType, quotaReached]
785 [api, connector, point, wallet, web3, walletType, quotaReached]
792− const adoptPoint = useCallback(
788+ const changeSponsorship = useCallback(
793− async (ship: Ship) => {
789+ async (sponsee: Ship, type: 'adopt' | 'detach' | 'reject') => {
794 if (quotaReached()) {
790 if (quotaReached()) {
798 const _wallet = wallet.getOrElse(null);
794 const _wallet = wallet.getOrElse(null);
795+ const _web3 = web3.getOrElse(null);
796+ const ship = point.value;
800 const proxy = point.getManagerProxy();
798 const proxy = point.getManagerProxy();
802 if (proxy === undefined)
800 if (proxy === undefined)
803 throw new Error("Error: Address doesn't match expected proxy");
801 throw new Error("Error: Address doesn't match expected proxy");
805− const nonce = await api.getNonce({ ship: point.value, proxy });
803+ const nonce = await api.getNonce({ ship, proxy });
806− const txHash = await adopt(api, _wallet, point.value, proxy, nonce, ship);
804+ // const txHash = await adopt(api, _wallet, point.value, proxy, nonce, ship);
807−
805+ const txHash = await submitL2Transaction({
808− return api.getPendingTx(txHash);
806+ api,
809− },
807+ wallet: _wallet,
810− [api, point, wallet, quotaReached]
808+ ship,
813− const kickPoint = useCallback(
811+ nonce,
814− async (ship: Ship) => {
812+ address: _wallet.address,
815− if (quotaReached()) {
813+ type,
816− return;
814+ walletType,
819− if (point.isDefault) {
817+ });
820− throw new Error('Internal Error: point is default');
823− const sponsor = point.value;
824− const _wallet = wallet.getOrElse(null);
825− const proxy = point.getManagerProxy();
827− if (proxy === undefined)
828− throw new Error("Error: Address doesn't match expected proxy");
830− const nonce = await api.getNonce({ ship: sponsor, proxy });
831− const txHash = await detach(api, _wallet, sponsor, proxy, nonce, ship);
833− return api.getPendingTx(txHash);
835− [api, point, wallet, quotaReached]
838− const rejectPoint = useCallback(
839− async (ship: Ship) => {
840− if (quotaReached()) {
844− if (point.isDefault) {
845− throw new Error('Internal Error: point is default');
848− const sponsor = point.value;
849− const _wallet = wallet.getOrElse(null);
850− const proxy = point.getManagerProxy();
852− if (proxy === undefined)
853− throw new Error("Error: Address doesn't match expected proxy");
855− const nonce = await api.getNonce({ ship: sponsor, proxy });
856− const txHash = await reject(api, _wallet, sponsor, proxy, nonce, ship);
858 return api.getPendingTx(txHash);
819 return api.getPendingTx(txHash);
860− [api, point, wallet, quotaReached]
821+ [api, point, wallet, walletType, web3, connector, quotaReached]
863 const transferPoint = useCallback(
824 const transferPoint = useCallback(
@@ -960,6 +921,34 @@ export default function useRoller() {
960 [api, point, sendL2Transaction, wallet]
921 [api, point, sendL2Transaction, wallet]
924+ const cancelEscape = useCallback(async () => {
925+ if (point.isDefault) {
926+ throw new Error('Internal Error: point is default');
929+ const curPoint = point.value;
930+ const _wallet = wallet.getOrElse(null);
933+ // not using need because we want a custom error
934+ throw new Error('Internal Error: Missing Wallet');
937+ const proxy = point.getManagerProxy();
939+ if (proxy === undefined)
940+ throw new Error("Error: Address doesn't match proxy");
942+ const nonce = await api.getNonce({ ship: curPoint, proxy });
944+ return sendL2Transaction({
947+ type: 'cancelEscape',
950+ }, [api, point, sendL2Transaction, wallet]);
963 const getPointsDetails = useCallback(
952 const getPointsDetails = useCallback(
965 ownedPoints: number[],
954 ownedPoints: number[],
@@ -1029,9 +1018,10 @@ export default function useRoller() {
1029 }, [point, nextBatchTime, getPendingTransactions, getInvites]); // eslint-disable-line react-hooks/exhaustive-deps
1018 }, [point, nextBatchTime, getPendingTransactions, getInvites]); // eslint-disable-line react-hooks/exhaustive-deps
1031 return {
1020 return {
1034 changeSponsor,
1023 changeSponsor,
1035 checkForUpdates,
1025 checkForUpdates,
1037 configureNetworkingKeys,
1027 configureNetworkingKeys,
@@ -1040,10 +1030,8 @@ export default function useRoller() {
1040 getPoints,
1030 getPoints,
1041 getPointsDetails,
1031 getPointsDetails,
1042 getPendingTransactions,
1032 getPendingTransactions,
1045 performL2Reticket,
1034 performL2Reticket,
1047 setProxyAddress,
1035 setProxyAddress,
1048 spawnPoint,
1036 spawnPoint,
1049 transferPoint,
1037 transferPoint,