@@ -80,6 +80,7 @@ export default function useRoller() {
8080 currentL2,
8181 nonces,
8282 increaseNonce,
83+ setNonce,
8384 } = useRollerStore();
8485 const [config, setConfig] = useState<Config | null>(null);
8586
@@ -463,7 +464,7 @@ export default function useRoller() {
463464 return pendingTx;
464465 };
465466
466− interface AcceptInviteParams {
467+ interface ReticketParams {
467468 point: Ship;
468469 to: EthAddress;
469470 manager: EthAddress;
@@ -471,25 +472,30 @@ export default function useRoller() {
471472 toWallet: any; // TODO: wallet type
472473 }
473474
474− const acceptInvite = async ({
475+ const performL2Reticket = async ({
475476 point,
476477 to,
477478 manager,
478479 fromWallet,
479480 toWallet,
480− }: AcceptInviteParams) => {
481+ }: ReticketParams) => {
482+ let pointDetails = nonces[point];
481483 const azimuthPoint = await api.getPoint(point);
482− console.log('azimuthPoint', azimuthPoint);
483− const ownerAddress = azimuthPoint?.ownership?.owner?.address!;
484484
485− const operator =
486− azimuthPoint.ownership &&
487− getOwnerNonce(azimuthPoint.ownership, ownerAddress);
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);
488493
489494 if (operator === undefined)
490495 throw new Error("Error: Address doesn't match proxy");
491496
492− const nonce = operator.nonce!;
497+ let nonce = operator.nonce!;
498+ let requests = [];
493499
494500 // 1. Update networking keys
495501 const networkRevision = convertToInt(azimuthPoint.network.keys.life, 10);
@@ -506,36 +512,53 @@ export default function useRoller() {
506512 nonce,
507513 networkSeed
508514 );
509−
510− // TODO: not needed? next time we operate with this point we will login, and get
511− // the latest nonce (updated with any nonce increase from possible pending txs)
515+ nonce = nonce + 1;
512516 // increaseNonce(point, operator.proxy!);
517+ requests.push(configureKeysRequest);
513518
514519 // 2. Set Management Proxy
515− const registerProxyAddressRequest = await registerProxyAddress(
520+ const registerMgmtRequest = await registerProxyAddress(
516521 api,
517522 fromWallet,
518523 point,
519524 operator.proxy!,
520525 'manage',
521− nonce + 1,
526+ nonce,
522527 manager
523528 );
529+ nonce = nonce + 1;
530+ // increaseNonce(point, operator.proxy!);
531+ requests.push(registerMgmtRequest);
524532
525− // 3. Transfer point
533+ // 3. Set Spawn Proxy
534+ if (!isPlanet(Number(point))) {
535+ const registerSpawnRequest = await registerProxyAddress(
536+ api,
537+ fromWallet,
538+ point,
539+ operator.proxy!,
540+ 'spawn',
541+ nonce,
542+ toWallet.spawn.keys.address
543+ );
544+ nonce = nonce + 1;
545+ // increaseNonce(point, operator.proxy!);
546+ requests.push(registerSpawnRequest);
547+ }
548+ // 4. Transfer point
526549 const transferTxRequest = await transferPointRequest(
527550 api,
528551 fromWallet,
529552 point,
530553 operator.proxy!,
531− nonce + 2,
554+ nonce,
532555 to
533556 );
534− const hashes = await Promise.all([
535− configureKeysRequest,
536− registerProxyAddressRequest,
537− transferTxRequest,
538− ]);
557+ // increaseNonce(point, operator.proxy!);
558+ setNonce(point, pointDetails, operator.proxy!, nonce);
559+ requests.push(transferTxRequest);
560+
561+ const hashes = await Promise.all(requests);
539562 return hashes;
540563 };
541564
@@ -636,7 +659,7 @@ export default function useRoller() {
636659
637660 return {
638661 api,
639− acceptInvite,
662+ performL2Reticket,
640663 config,
641664 getPoints,
642665 getInvites,