@@ -80,6 +80,7 @@ export default function useRoller() {
80 currentL2,
80 currentL2,
82 increaseNonce,
82 increaseNonce,
83 } = useRollerStore();
84 } = useRollerStore();
84 const [config, setConfig] = useState<Config | null>(null);
85 const [config, setConfig] = useState<Config | null>(null);
@@ -463,7 +464,7 @@ export default function useRoller() {
463 return pendingTx;
464 return pendingTx;
466− interface AcceptInviteParams {
467+ interface ReticketParams {
467 point: Ship;
468 point: Ship;
468 to: EthAddress;
469 to: EthAddress;
469 manager: EthAddress;
470 manager: EthAddress;
@@ -471,25 +472,30 @@ export default function useRoller() {
471 toWallet: any; // TODO: wallet type
472 toWallet: any; // TODO: wallet type
474− const acceptInvite = async ({
475+ const performL2Reticket = async ({
478 fromWallet,
479 fromWallet,
479 toWallet,
480 toWallet,
480− }: AcceptInviteParams) => {
481+ }: ReticketParams) => {
482+ let pointDetails = nonces[point];
481 const azimuthPoint = await api.getPoint(point);
483 const azimuthPoint = await api.getPoint(point);
482− console.log('azimuthPoint', azimuthPoint);
483− const ownerAddress = azimuthPoint?.ownership?.owner?.address!;
485− const operator =
485+ console.log(pointDetails);
486− azimuthPoint.ownership &&
486+ if (pointDetails === undefined) {
487+ // This is an invite acceptance
488+ pointDetails = azimuthPoint.ownership!;
489+ console.log(pointDetails);
491+ const ownerAddress = pointDetails.owner?.address!;
487− getOwnerNonce(azimuthPoint.ownership, ownerAddress);
492+ const operator = pointDetails && getOwnerNonce(pointDetails, ownerAddress);
489 if (operator === undefined)
494 if (operator === undefined)
490 throw new Error("Error: Address doesn't match proxy");
495 throw new Error("Error: Address doesn't match proxy");
492− const nonce = operator.nonce!;
497+ let nonce = operator.nonce!;
494 // 1. Update networking keys
500 // 1. Update networking keys
495 const networkRevision = convertToInt(azimuthPoint.network.keys.life, 10);
501 const networkRevision = convertToInt(azimuthPoint.network.keys.life, 10);
@@ -506,36 +512,53 @@ export default function useRoller() {
507 networkSeed
513 networkSeed
509−
515+ nonce = nonce + 1;
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)
512 // increaseNonce(point, operator.proxy!);
516 // increaseNonce(point, operator.proxy!);
517+ requests.push(configureKeysRequest);
514 // 2. Set Management Proxy
519 // 2. Set Management Proxy
515− const registerProxyAddressRequest = await registerProxyAddress(
520+ const registerMgmtRequest = await registerProxyAddress(
517 fromWallet,
522 fromWallet,
519 operator.proxy!,
524 operator.proxy!,
520 'manage',
525 'manage',
521− nonce + 1,
526+ nonce,
530+ // increaseNonce(point, operator.proxy!);
531+ requests.push(registerMgmtRequest);
533+ // 3. Set Spawn Proxy
534+ if (!isPlanet(Number(point))) {
535+ const registerSpawnRequest = await registerProxyAddress(
542+ toWallet.spawn.keys.address
545+ // increaseNonce(point, operator.proxy!);
546+ requests.push(registerSpawnRequest);
525− // 3. Transfer point
548+ // 4. Transfer point
526 const transferTxRequest = await transferPointRequest(
549 const transferTxRequest = await transferPointRequest(
528 fromWallet,
551 fromWallet,
530 operator.proxy!,
553 operator.proxy!,
531− nonce + 2,
554+ nonce,
557+ // increaseNonce(point, operator.proxy!);
558+ setNonce(point, pointDetails, operator.proxy!, nonce);
559+ requests.push(transferTxRequest);
534− const hashes = await Promise.all([
561+ const hashes = await Promise.all(requests);
535− configureKeysRequest,
536− registerProxyAddressRequest,
539 return hashes;
562 return hashes;
@@ -636,7 +659,7 @@ export default function useRoller() {
639− acceptInvite,
662+ performL2Reticket,
641 getPoints,
664 getPoints,
642 getInvites,
665 getInvites,