@@ -1,4 +1,4 @@
1−import { UnspawnedPoints } from '@urbit/roller-api';
1+import { SpawnedPoints, UnspawnedPoints } from '@urbit/roller-api';
2import { POINT_DOMINIONS } from 'lib/constants';
2import { POINT_DOMINIONS } from 'lib/constants';
3import { deriveNetworkSeedFromUrbitWallet } from 'lib/keys';
3import { deriveNetworkSeedFromUrbitWallet } from 'lib/keys';
4import * as need from 'lib/need';
4import * as need from 'lib/need';
@@ -26,6 +26,7 @@ import { useWallet } from 'store/wallet';
26import { usePointCache } from 'store/pointCache';
26import { usePointCache } from 'store/pointCache';
27import create from 'zustand';
27import create from 'zustand';
28import { generateCsvLine } from 'lib/utils/invite';
28import { generateCsvLine } from 'lib/utils/invite';
29+import Point from 'lib/types/Point';
30const inviteTemplate = (
31const inviteTemplate = (
31 planet: number,
32 planet: number,
@@ -97,7 +98,7 @@ export function useInvites() {
97 const { web3, contracts }: any = useNetwork();
98 const { web3, contracts }: any = useNetwork();
98 const allPoints: any = usePointCache();
99 const allPoints: any = usePointCache();
99 const getDetails = allPoints?.getDetails;
100 const getDetails = allPoints?.getDetails;
100− const { api, ls } = useRoller();
101+ const { api, ls, performL2Reticket } = useRoller();
101 const { point, pointList, setPendingTransactions } = useRollerStore();
102 const { point, pointList, setPendingTransactions } = useRollerStore();
@@ -209,15 +210,17 @@ export function useInvites() {
211 const generateInviteCodes = useCallback(
212 const generateInviteCodes = useCallback(
212− async (numInvites: number) => {
213+ async (
213− const _point = need.point(pointCursor);
214+ point: Point,
215+ planets: SpawnedPoints | UnspawnedPoints,
216+ spawn: boolean = true
214 const _contracts = contracts.getOrElse(null);
218 const _contracts = contracts.getOrElse(null);
215 const _web3 = web3.getOrElse(null);
219 const _web3 = web3.getOrElse(null);
216 const _wallet = wallet.getOrElse(null);
220 const _wallet = wallet.getOrElse(null);
217 const _authToken = authToken.getOrElse(null);
221 const _authToken = authToken.getOrElse(null);
218− const _details = getDetails(_point);
220− if (!_contracts || !_web3 || !_wallet || !_authToken || !_details) {
223+ if (!_contracts || !_web3 || !_wallet || !_authToken) {
221 // not using need because we want a custom error
224 // not using need because we want a custom error
222 throw new Error('Internal Error: Missing Contracts/Web3/Wallet');
225 throw new Error('Internal Error: Missing Contracts/Web3/Wallet');
@@ -228,13 +231,6 @@ export function useInvites() {
228 // "Auth key Error: A management mnemonic can't create invite codes"
231 // "Auth key Error: A management mnemonic can't create invite codes"
231− let planets: UnspawnedPoints = await api.getUnspawned(_point);
233− const pendingTxs = await api.getPendingByShip(_point);
235− const pendingSpawns = getPendingSpawns(pendingTxs);
237− planets = planets.filter((point: number) => !pendingSpawns.has(point));
239 const invites: Invite[] = [];
235 const invites: Invite[] = [];
@@ -244,11 +240,11 @@ export function useInvites() {
244 throw new Error("Error: Address doesn't match proxy");
240 throw new Error("Error: Address doesn't match proxy");
246 const nonce = await api.getNonce({
242 const nonce = await api.getNonce({
247− ship: _point,
243+ ship: point.value,
251− for (let i = 0; i < numInvites && planets[i]; i++) {
247+ for (let i = 0; i < planets.length; i++) {
252 updateJob(point.value, { generatingNum: i + 1 });
248 updateJob(point.value, { generatingNum: i + 1 });
253 const planet = planets[i];
249 const planet = planets[i];
254 const nonceInc = i + nonce;
250 const nonceInc = i + nonce;
@@ -258,62 +254,72 @@ export function useInvites() {
258 _authToken
254 _authToken
260+ to: inviteWallet.ownership.keys.address,
261+ manager: inviteWallet.management.keys.address,
262+ fromWallet: _wallet,
263+ toWallet: inviteWallet,
261− await submitL2Transaction({
266+ await submitL2Transaction({
263− address: _wallet.address,
268+ address: _wallet.address,
264− wallet: _wallet,
269+ wallet: _wallet,
265− ship: _point,
270+ ship: point.value,
267− nonce: nonceInc,
272+ nonce: nonceInc,
268− pointToSpawn: planet,
273+ pointToSpawn: planet,
269− type: 'spawn',
274+ type: 'spawn',
270− walletType,
275+ walletType,
271− web3: _web3,
276+ web3: _web3,
272− connector,
277+ connector,
275− const networkSeed = await deriveNetworkSeedFromUrbitWallet(
280+ const networkSeed = await deriveNetworkSeedFromUrbitWallet(
276− inviteWallet,
281+ inviteWallet,
279− await submitL2Transaction({
284+ await submitL2Transaction({
281− wallet: _wallet,
286+ wallet: _wallet,
282− ship: planet,
287+ ship: planet,
283− proxy: 'own',
288+ proxy: 'own',
284− nonce: 0,
289+ nonce: 0,
285− networkSeed,
290+ networkSeed,
286− type: 'configureKeys',
291+ type: 'configureKeys',
287− walletType,
292+ walletType,
288− web3: _web3,
293+ web3: _web3,
289− connector,
294+ connector,
292− await registerProxyAddress(
297+ await registerProxyAddress(
294− _wallet,
299+ _wallet,
297− 'manage',
302+ 'manage',
299− inviteWallet.management.keys.address,
304+ inviteWallet.management.keys.address,
300− walletType,
305+ walletType,
302− connector
307+ connector
305− await submitL2Transaction({
310+ await submitL2Transaction({
307− wallet: _wallet,
312+ wallet: _wallet,
308− ship: planet,
313+ ship: planet,
309− proxy: 'own',
314+ proxy: 'own',
310− type: 'transferPoint',
315+ type: 'transferPoint',
311− nonce: 2,
316+ nonce: 2,
312− address: inviteWallet.ownership.keys.address,
317+ address: inviteWallet.ownership.keys.address,
313− walletType,
318+ walletType,
314− web3: _web3,
319+ web3: _web3,
315− connector,
320+ connector,
318 invites.push({
324 invites.push({
319 hash: '',
325 hash: '',
@@ -344,6 +350,7 @@ export function useInvites() {
345 getInvites,
351 getInvites,
346 updateJob,
352 updateJob,