@@ -22,12 +22,7 @@ import {
22} from 'store/storage/roller';
22} from 'store/storage/roller';
23import { usePointCache } from 'store/pointCache';
23import { usePointCache } from 'store/pointCache';
24import { getOutgoingPoints } from 'views/Points';
24import { getOutgoingPoints } from 'views/Points';
30−} from './utils/nonce';
25+import { getProxy } from './utils/proxy';
31import { isPlanet } from './utils/point';
26import { isPlanet } from './utils/point';
@@ -78,9 +73,6 @@ export default function useRoller() {
78 setPendingTransactions,
73 setPendingTransactions,
79 setInvites,
74 setInvites,
80 currentL2,
75 currentL2,
84 } = useRollerStore();
76 } = useRollerStore();
85 const [config, setConfig] = useState<Config | null>(null);
77 const [config, setConfig] = useState<Config | null>(null);
@@ -158,12 +150,9 @@ export default function useRoller() {
158 new Set<number>()
150 new Set<number>()
161− console.log(pendingTxs, pendingSpawns);
163 planets = planets.filter((point: number) => !pendingSpawns.has(point));
153 planets = planets.filter((point: number) => !pendingSpawns.has(point));
165− const starInfo = nonces[_point];
155+ const starInfo = await api.getPoint(_point);
166− console.log(starInfo);
167 const tickets: {
156 const tickets: {
168 ticket: string;
157 ticket: string;
169 planet: number;
158 planet: number;
@@ -171,16 +160,19 @@ export default function useRoller() {
171 }[] = [];
160 }[] = [];
172 const requests: Promise<string>[] = [];
161 const requests: Promise<string>[] = [];
175− getSpawnNonce(starInfo, _wallet.address) ||
176− getOwnerNonce(starInfo, _wallet.address);
163+ const proxy = getProxy(starInfo.ownership!, _wallet.address);
178− if (operator === undefined)
165+ if (proxy === undefined)
179 throw new Error("Error: Address doesn't match proxy");
166 throw new Error("Error: Address doesn't match proxy");
180− console.log('operator', operator);
167+
168+ const nonce = await api.getNonce({
181 for (let i = 0; i < numInvites && planets[i]; i++) {
173 for (let i = 0; i < numInvites && planets[i]; i++) {
182 const planet = planets[i];
174 const planet = planets[i];
183− const nonceInc = i + operator.nonce!;
175+ const nonceInc = i + nonce;
185 const { ticket, inviteWallet } = await generateInviteWallet(
177 const { ticket, inviteWallet } = await generateInviteWallet(
@@ -191,11 +183,10 @@ export default function useRoller() {
194− operator.proxy!,
186+ proxy,
195 nonceInc,
187 nonceInc,
198− increaseNonce(_point, operator.proxy!);
200 const networkSeed = await deriveNetworkSeedFromUrbitWallet(
191 const networkSeed = await deriveNetworkSeedFromUrbitWallet(
201 inviteWallet,
192 inviteWallet,
@@ -205,7 +196,7 @@ export default function useRoller() {
208− operator.proxy!,
199+ proxy,
210 networkSeed
201 networkSeed
@@ -214,7 +205,7 @@ export default function useRoller() {
217− operator.proxy!,
208+ proxy,
218 'manage',
209 'manage',
220 inviteWallet.management.keys.address
211 inviteWallet.management.keys.address
@@ -224,7 +215,7 @@ export default function useRoller() {
227− operator.proxy!,
218+ proxy,
229 inviteWallet.ownership.keys.address
220 inviteWallet.ownership.keys.address
@@ -250,7 +241,6 @@ export default function useRoller() {
250 status: 'pending',
241 status: 'pending',
253− console.log('latest update', nonces[_point]);
254 setPendingInvites(_point, pendingInvites);
244 setPendingInvites(_point, pendingInvites);
@@ -262,8 +252,6 @@ export default function useRoller() {
263 getDetails,
253 getDetails,
264 authMnemonic,
254 authMnemonic,
@@ -431,12 +419,17 @@ export default function useRoller() {
431 throw new Error('Internal Error: Missing Wallet/Details');
419 throw new Error('Internal Error: Missing Wallet/Details');
434− const pointDetails = nonces[_point];
422+ const pointDetails = await api.getPoint(_point);
435− const operator =
423+ const proxy = getProxy(pointDetails.ownership!, _wallet.address);
436− getManagementNonce(pointDetails, _wallet.address) ||
424+
437− getOwnerNonce(pointDetails, _wallet.address);
438− if (operator === undefined)
425+ if (proxy === undefined)
439 throw new Error("Error: Address doesn't match proxy");
426 throw new Error("Error: Address doesn't match proxy");
428+ const nonce = await api.getNonce({
440 const networkRevision = convertToInt(azimuthPoint.network.keys.life, 10);
433 const networkRevision = convertToInt(azimuthPoint.network.keys.life, 10);
441 const nextRevision = networkRevision + 1;
434 const nextRevision = networkRevision + 1;
442 const networkSeed = customNetworkSeed
435 const networkSeed = customNetworkSeed
@@ -454,8 +447,8 @@ export default function useRoller() {
457− operator.proxy!,
450+ proxy!,
458− operator.nonce!,
451+ nonce,
459 networkSeed,
452 networkSeed,
@@ -479,22 +472,10 @@ export default function useRoller() {
479 fromWallet,
472 fromWallet,
480 toWallet,
473 toWallet,
481 }: ReticketParams) => {
474 }: ReticketParams) => {
482− let pointDetails = nonces[point];
483 const azimuthPoint = await api.getPoint(point);
475 const azimuthPoint = await api.getPoint(point);
476+ const proxy = 'own';
477+ let nonce = await api.getNonce({ ship: point, proxy });
485− console.log(pointDetails);
486− if (pointDetails === undefined) {
487− // This is an invite acceptance
488− pointDetails = azimuthPoint.ownership!;
489− console.log(pointDetails);
491− const ownerAddress = pointDetails.owner?.address!;
492− const operator = pointDetails && getOwnerNonce(pointDetails, ownerAddress);
494− if (operator === undefined)
495− throw new Error("Error: Address doesn't match proxy");
497− let nonce = operator.nonce!;
498 let requests = [];
479 let requests = [];
500 // 1. Update networking keys
481 // 1. Update networking keys
@@ -508,12 +489,11 @@ export default function useRoller() {
509 fromWallet,
490 fromWallet,
511− operator.proxy!,
492+ proxy,
513 networkSeed
494 networkSeed
515 nonce = nonce + 1;
496 nonce = nonce + 1;
516− // increaseNonce(point, operator.proxy!);
517 requests.push(configureKeysRequest);
497 requests.push(configureKeysRequest);
519 // 2. Set Management Proxy
499 // 2. Set Management Proxy
@@ -521,13 +501,12 @@ export default function useRoller() {
522 fromWallet,
502 fromWallet,
524− operator.proxy!,
504+ proxy,
525 'manage',
505 'manage',
529 nonce = nonce + 1;
509 nonce = nonce + 1;
530− // increaseNonce(point, operator.proxy!);
531 requests.push(registerMgmtRequest);
510 requests.push(registerMgmtRequest);
533 // 3. Set Spawn Proxy
512 // 3. Set Spawn Proxy
@@ -536,13 +515,12 @@ export default function useRoller() {
537 fromWallet,
516 fromWallet,
539− operator.proxy!,
518+ proxy,
542 toWallet.spawn.keys.address
521 toWallet.spawn.keys.address
544 nonce = nonce + 1;
523 nonce = nonce + 1;
545− // increaseNonce(point, operator.proxy!);
546 requests.push(registerSpawnRequest);
524 requests.push(registerSpawnRequest);
548 // 4. Transfer point
526 // 4. Transfer point
@@ -550,12 +528,10 @@ export default function useRoller() {
551 fromWallet,
529 fromWallet,
553− operator.proxy!,
531+ proxy,
557− // increaseNonce(point, operator.proxy!);
558− setNonce(point, pointDetails, operator.proxy!, nonce);
559 requests.push(transferTxRequest);
535 requests.push(transferTxRequest);
561 const hashes = await Promise.all(requests);
537 const hashes = await Promise.all(requests);
@@ -572,21 +548,21 @@ export default function useRoller() {
572 throw new Error('Internal Error: Missing Wallet');
548 throw new Error('Internal Error: Missing Wallet');
575− const pointDetails = nonces[_point];
551+ const pointDetails = await api.getPoint(_point);
577− getManagementNonce(pointDetails, _wallet.address) ||
578− getOwnerNonce(pointDetails, _wallet.address);
552+ const proxy = getProxy(pointDetails.ownership!, _wallet.address);
580− if (operator === undefined)
554+ if (proxy === undefined)
581 throw new Error("Error: Address doesn't match proxy");
555 throw new Error("Error: Address doesn't match proxy");
557+ const nonce = await api.getNonce({ ship: _point, proxy });
583 const txHash = await registerProxyAddress(
559 const txHash = await registerProxyAddress(
587− operator.proxy!,
563+ proxy,
588 proxyType,
564 proxyType,
589− operator.nonce!,
565+ nonce,
@@ -594,7 +570,7 @@ export default function useRoller() {
595 return pendingTx;
571 return pendingTx;
597− [api, pointCursor, wallet, nonces]
573+ [api, pointCursor, wallet]
600 const transferPoint = useCallback(
576 const transferPoint = useCallback(
@@ -607,20 +583,20 @@ export default function useRoller() {
607 throw new Error('Internal Error: Missing Wallet');
583 throw new Error('Internal Error: Missing Wallet');
610− const pointDetails = nonces[_point];
586+ const pointDetails = await api.getPoint(_point);
612− getTransferNonce(pointDetails, _wallet.address) ||
613− getOwnerNonce(pointDetails, _wallet.address);
587+ const proxy = getProxy(pointDetails.ownership!, _wallet.address);
615− if (operator === undefined)
589+ if (proxy === undefined)
616 throw new Error("Error: Address doesn't match proxy");
590 throw new Error("Error: Address doesn't match proxy");
592+ const nonce = await api.getNonce({ ship: _point, proxy });
618 const txHash = await transferPointRequest(
594 const txHash = await transferPointRequest(
622− operator.proxy!,
598+ proxy,
623− operator.nonce!,
599+ nonce,
625 reset || false
601 reset || false
@@ -628,7 +604,7 @@ export default function useRoller() {
629 return pendingTx;
605 return pendingTx;
631− [api, pointCursor, wallet, nonces]
607+ [api, pointCursor, wallet]
634 // On load, get initial config
610 // On load, get initial config