@@ -22,12 +22,7 @@ import {
2222} from 'store/storage/roller';
2323import { usePointCache } from 'store/pointCache';
2424import { getOutgoingPoints } from 'views/Points';
25−import {
26− getSpawnNonce,
27− getOwnerNonce,
28− getManagementNonce,
29− getTransferNonce,
30−} from './utils/nonce';
25+import { getProxy } from './utils/proxy';
3126import { isPlanet } from './utils/point';
3227
3328import {
@@ -78,9 +73,6 @@ export default function useRoller() {
7873 setPendingTransactions,
7974 setInvites,
8075 currentL2,
81− nonces,
82− increaseNonce,
83− setNonce,
8476 } = useRollerStore();
8577 const [config, setConfig] = useState<Config | null>(null);
8678
@@ -158,12 +150,9 @@ export default function useRoller() {
158150 new Set<number>()
159151 );
160152
161− console.log(pendingTxs, pendingSpawns);
162−
163153 planets = planets.filter((point: number) => !pendingSpawns.has(point));
164154
165− const starInfo = nonces[_point];
166− console.log(starInfo);
155+ const starInfo = await api.getPoint(_point);
167156 const tickets: {
168157 ticket: string;
169158 planet: number;
@@ -171,16 +160,19 @@ export default function useRoller() {
171160 }[] = [];
172161 const requests: Promise<string>[] = [];
173162
174− const operator =
175− getSpawnNonce(starInfo, _wallet.address) ||
176− getOwnerNonce(starInfo, _wallet.address);
163+ const proxy = getProxy(starInfo.ownership!, _wallet.address);
177164
178− if (operator === undefined)
165+ if (proxy === undefined)
179166 throw new Error("Error: Address doesn't match proxy");
180− console.log('operator', operator);
167+
168+ const nonce = await api.getNonce({
169+ ship: _point,
170+ proxy: proxy,
171+ });
172+
181173 for (let i = 0; i < numInvites && planets[i]; i++) {
182174 const planet = planets[i];
183− const nonceInc = i + operator.nonce!;
175+ const nonceInc = i + nonce;
184176
185177 const { ticket, inviteWallet } = await generateInviteWallet(
186178 planet,
@@ -191,11 +183,10 @@ export default function useRoller() {
191183 api,
192184 _wallet,
193185 _point,
194− operator.proxy!,
186+ proxy,
195187 nonceInc,
196188 planet
197189 );
198− increaseNonce(_point, operator.proxy!);
199190
200191 const networkSeed = await deriveNetworkSeedFromUrbitWallet(
201192 inviteWallet,
@@ -205,7 +196,7 @@ export default function useRoller() {
205196 api,
206197 _wallet,
207198 planet,
208− operator.proxy!,
199+ proxy,
209200 0,
210201 networkSeed
211202 );
@@ -214,7 +205,7 @@ export default function useRoller() {
214205 api,
215206 _wallet,
216207 planet,
217− operator.proxy!,
208+ proxy,
218209 'manage',
219210 1,
220211 inviteWallet.management.keys.address
@@ -224,7 +215,7 @@ export default function useRoller() {
224215 api,
225216 _wallet,
226217 planet,
227− operator.proxy!,
218+ proxy,
228219 2,
229220 inviteWallet.ownership.keys.address
230221 );
@@ -250,7 +241,6 @@ export default function useRoller() {
250241 status: 'pending',
251242 }));
252243
253− console.log('latest update', nonces[_point]);
254244 setPendingInvites(_point, pendingInvites);
255245 },
256246 [
@@ -262,8 +252,6 @@ export default function useRoller() {
262252 web3,
263253 getDetails,
264254 authMnemonic,
265− nonces,
266− increaseNonce,
267255 ]
268256 );
269257
@@ -431,12 +419,17 @@ export default function useRoller() {
431419 throw new Error('Internal Error: Missing Wallet/Details');
432420 }
433421
434− const pointDetails = nonces[_point];
435− const operator =
436− getManagementNonce(pointDetails, _wallet.address) ||
437− getOwnerNonce(pointDetails, _wallet.address);
438− if (operator === undefined)
422+ const pointDetails = await api.getPoint(_point);
423+ const proxy = getProxy(pointDetails.ownership!, _wallet.address);
424+
425+ if (proxy === undefined)
439426 throw new Error("Error: Address doesn't match proxy");
427+
428+ const nonce = await api.getNonce({
429+ ship: _point,
430+ proxy: proxy,
431+ });
432+
440433 const networkRevision = convertToInt(azimuthPoint.network.keys.life, 10);
441434 const nextRevision = networkRevision + 1;
442435 const networkSeed = customNetworkSeed
@@ -454,8 +447,8 @@ export default function useRoller() {
454447 api,
455448 _wallet,
456449 _point,
457− operator.proxy!,
458− operator.nonce!,
450+ proxy!,
451+ nonce,
459452 networkSeed,
460453 breach
461454 );
@@ -479,22 +472,10 @@ export default function useRoller() {
479472 fromWallet,
480473 toWallet,
481474 }: ReticketParams) => {
482− let pointDetails = nonces[point];
483475 const azimuthPoint = await api.getPoint(point);
476+ const proxy = 'own';
477+ let nonce = await api.getNonce({ ship: point, proxy });
484478
485− console.log(pointDetails);
486− if (pointDetails === undefined) {
487− // This is an invite acceptance
488− pointDetails = azimuthPoint.ownership!;
489− console.log(pointDetails);
490− }
491− const ownerAddress = pointDetails.owner?.address!;
492− const operator = pointDetails && getOwnerNonce(pointDetails, ownerAddress);
493−
494− if (operator === undefined)
495− throw new Error("Error: Address doesn't match proxy");
496−
497− let nonce = operator.nonce!;
498479 let requests = [];
499480
500481 // 1. Update networking keys
@@ -508,12 +489,11 @@ export default function useRoller() {
508489 api,
509490 fromWallet,
510491 point,
511− operator.proxy!,
492+ proxy,
512493 nonce,
513494 networkSeed
514495 );
515496 nonce = nonce + 1;
516− // increaseNonce(point, operator.proxy!);
517497 requests.push(configureKeysRequest);
518498
519499 // 2. Set Management Proxy
@@ -521,13 +501,12 @@ export default function useRoller() {
521501 api,
522502 fromWallet,
523503 point,
524− operator.proxy!,
504+ proxy,
525505 'manage',
526506 nonce,
527507 manager
528508 );
529509 nonce = nonce + 1;
530− // increaseNonce(point, operator.proxy!);
531510 requests.push(registerMgmtRequest);
532511
533512 // 3. Set Spawn Proxy
@@ -536,13 +515,12 @@ export default function useRoller() {
536515 api,
537516 fromWallet,
538517 point,
539− operator.proxy!,
518+ proxy,
540519 'spawn',
541520 nonce,
542521 toWallet.spawn.keys.address
543522 );
544523 nonce = nonce + 1;
545− // increaseNonce(point, operator.proxy!);
546524 requests.push(registerSpawnRequest);
547525 }
548526 // 4. Transfer point
@@ -550,12 +528,10 @@ export default function useRoller() {
550528 api,
551529 fromWallet,
552530 point,
553− operator.proxy!,
531+ proxy,
554532 nonce,
555533 to
556534 );
557− // increaseNonce(point, operator.proxy!);
558− setNonce(point, pointDetails, operator.proxy!, nonce);
559535 requests.push(transferTxRequest);
560536
561537 const hashes = await Promise.all(requests);
@@ -572,21 +548,21 @@ export default function useRoller() {
572548 throw new Error('Internal Error: Missing Wallet');
573549 }
574550
575− const pointDetails = nonces[_point];
576− const operator =
577− getManagementNonce(pointDetails, _wallet.address) ||
578− getOwnerNonce(pointDetails, _wallet.address);
551+ const pointDetails = await api.getPoint(_point);
552+ const proxy = getProxy(pointDetails.ownership!, _wallet.address);
579553
580− if (operator === undefined)
554+ if (proxy === undefined)
581555 throw new Error("Error: Address doesn't match proxy");
582556
557+ const nonce = await api.getNonce({ ship: _point, proxy });
558+
583559 const txHash = await registerProxyAddress(
584560 api,
585561 _wallet,
586562 _point,
587− operator.proxy!,
563+ proxy,
588564 proxyType,
589− operator.nonce!,
565+ nonce,
590566 address
591567 );
592568
@@ -594,7 +570,7 @@ export default function useRoller() {
594570
595571 return pendingTx;
596572 },
597− [api, pointCursor, wallet, nonces]
573+ [api, pointCursor, wallet]
598574 );
599575
600576 const transferPoint = useCallback(
@@ -607,20 +583,20 @@ export default function useRoller() {
607583 throw new Error('Internal Error: Missing Wallet');
608584 }
609585
610− const pointDetails = nonces[_point];
611− const operator =
612− getTransferNonce(pointDetails, _wallet.address) ||
613− getOwnerNonce(pointDetails, _wallet.address);
586+ const pointDetails = await api.getPoint(_point);
587+ const proxy = getProxy(pointDetails.ownership!, _wallet.address);
614588
615− if (operator === undefined)
589+ if (proxy === undefined)
616590 throw new Error("Error: Address doesn't match proxy");
617591
592+ const nonce = await api.getNonce({ ship: _point, proxy });
593+
618594 const txHash = await transferPointRequest(
619595 api,
620596 _wallet,
621597 _point,
622− operator.proxy!,
623− operator.nonce!,
598+ proxy,
599+ nonce,
624600 address,
625601 reset || false
626602 );
@@ -628,7 +604,7 @@ export default function useRoller() {
628604
629605 return pendingTx;
630606 },
631− [api, pointCursor, wallet, nonces]
607+ [api, pointCursor, wallet]
632608 );
633609
634610 // On load, get initial config