create-mn-app 0.3.23 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -89,14 +89,15 @@ async function main() {
|
|
|
89
89
|
|
|
90
90
|
const deployment = JSON.parse(fs.readFileSync('deployment.json', 'utf-8'));
|
|
91
91
|
|
|
92
|
-
if (!
|
|
93
|
-
console.error('❌ No
|
|
92
|
+
if (!fs.existsSync('.midnight-seed')) {
|
|
93
|
+
console.error('❌ No .midnight-seed file found! Run: npm run deploy\n');
|
|
94
94
|
process.exit(1);
|
|
95
95
|
}
|
|
96
|
+
const seed = fs.readFileSync('.midnight-seed', 'utf-8').trim();
|
|
96
97
|
|
|
97
98
|
try {
|
|
98
99
|
console.log(' Building wallet...');
|
|
99
|
-
const { wallet, unshieldedKeystore } = await createWallet(
|
|
100
|
+
const { wallet, unshieldedKeystore } = await createWallet(seed);
|
|
100
101
|
|
|
101
102
|
console.log(' Syncing with network...');
|
|
102
103
|
const state = await Rx.firstValueFrom(
|
|
@@ -176,8 +176,14 @@ async function main() {
|
|
|
176
176
|
|
|
177
177
|
try {
|
|
178
178
|
// Create wallet from saved seed
|
|
179
|
+
if (!fs.existsSync('.midnight-seed')) {
|
|
180
|
+
console.error('❌ No .midnight-seed file found! Run: npm run deploy\n');
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
const seed = fs.readFileSync('.midnight-seed', 'utf-8').trim();
|
|
184
|
+
|
|
179
185
|
console.log(' Connecting to wallet...');
|
|
180
|
-
const walletCtx = await createWallet(
|
|
186
|
+
const walletCtx = await createWallet(seed);
|
|
181
187
|
|
|
182
188
|
console.log(' Syncing with network...');
|
|
183
189
|
const state = await Rx.firstValueFrom(walletCtx.wallet.state().pipe(Rx.throttleTime(5000), Rx.filter((s) => s.isSynced)));
|
|
@@ -196,14 +196,21 @@ async function main() {
|
|
|
196
196
|
const rl = createInterface({ input: stdin, output: stdout });
|
|
197
197
|
|
|
198
198
|
try {
|
|
199
|
-
// Check for existing deployment
|
|
199
|
+
// Check for existing deployment and seed
|
|
200
200
|
let existingSeed: string | undefined;
|
|
201
201
|
let existingContract: string | undefined;
|
|
202
202
|
|
|
203
|
+
if (fs.existsSync('.midnight-seed')) {
|
|
204
|
+
try {
|
|
205
|
+
existingSeed = fs.readFileSync('.midnight-seed', 'utf-8').trim();
|
|
206
|
+
} catch {
|
|
207
|
+
// Ignore read errors
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
203
211
|
if (fs.existsSync('deployment.json')) {
|
|
204
212
|
try {
|
|
205
213
|
const existing = JSON.parse(fs.readFileSync('deployment.json', 'utf-8'));
|
|
206
|
-
if (existing.seed) existingSeed = existing.seed;
|
|
207
214
|
if (existing.contractAddress) existingContract = existing.contractAddress;
|
|
208
215
|
} catch {
|
|
209
216
|
// Ignore parse errors
|
|
@@ -241,7 +248,10 @@ async function main() {
|
|
|
241
248
|
: toHex(Buffer.from(generateRandomSeed()));
|
|
242
249
|
|
|
243
250
|
if (choice.trim() !== '2') {
|
|
244
|
-
|
|
251
|
+
fs.writeFileSync('.midnight-seed', seed, { mode: 0o600 });
|
|
252
|
+
console.log('\n ⚠️ A new wallet seed has been generated.');
|
|
253
|
+
console.log(' It has been saved to .midnight-seed (chmod 600).');
|
|
254
|
+
console.log(' Back it up securely and never commit this file.\n');
|
|
245
255
|
}
|
|
246
256
|
}
|
|
247
257
|
} else {
|
|
@@ -251,7 +261,10 @@ async function main() {
|
|
|
251
261
|
: toHex(Buffer.from(generateRandomSeed()));
|
|
252
262
|
|
|
253
263
|
if (choice.trim() !== '2') {
|
|
254
|
-
|
|
264
|
+
fs.writeFileSync('.midnight-seed', seed, { mode: 0o600 });
|
|
265
|
+
console.log('\n ⚠️ A new wallet seed has been generated.');
|
|
266
|
+
console.log(' It has been saved to .midnight-seed (chmod 600).');
|
|
267
|
+
console.log(' Back it up securely and never commit this file.\n');
|
|
255
268
|
}
|
|
256
269
|
}
|
|
257
270
|
|
|
@@ -325,9 +338,10 @@ async function main() {
|
|
|
325
338
|
console.log(' └──────────────────────────────────────────────────────────────┘\n');
|
|
326
339
|
|
|
327
340
|
// Save seed for retry
|
|
328
|
-
|
|
341
|
+
fs.writeFileSync('.midnight-seed', seed, { mode: 0o600 });
|
|
342
|
+
const partialInfo = { address, network: 'preprod', status: 'proof_server_unavailable' };
|
|
329
343
|
fs.writeFileSync('deployment.json', JSON.stringify(partialInfo, null, 2));
|
|
330
|
-
console.log(' Wallet saved to deployment.json\n');
|
|
344
|
+
console.log(' Wallet saved to .midnight-seed and deployment.json\n');
|
|
331
345
|
|
|
332
346
|
await walletCtx.wallet.stop();
|
|
333
347
|
process.exit(1);
|
|
@@ -371,9 +385,10 @@ async function main() {
|
|
|
371
385
|
console.log(' │ │');
|
|
372
386
|
console.log(' └──────────────────────────────────────────────────────────────┘\n');
|
|
373
387
|
|
|
374
|
-
|
|
388
|
+
fs.writeFileSync('.midnight-seed', seed, { mode: 0o600 });
|
|
389
|
+
const partialInfo = { address, network: 'preprod', status: 'proof_server_error' };
|
|
375
390
|
fs.writeFileSync('deployment.json', JSON.stringify(partialInfo, null, 2));
|
|
376
|
-
console.log(' Wallet saved to deployment.json\n');
|
|
391
|
+
console.log(' Wallet saved to .midnight-seed and deployment.json\n');
|
|
377
392
|
|
|
378
393
|
await walletCtx.wallet.stop();
|
|
379
394
|
process.exit(1);
|
|
@@ -414,15 +429,15 @@ async function main() {
|
|
|
414
429
|
console.log(' └───────────────────────────────────────────────────────────┘\n');
|
|
415
430
|
|
|
416
431
|
// Save partial deployment info so user can resume
|
|
432
|
+
fs.writeFileSync('.midnight-seed', seed, { mode: 0o600 });
|
|
417
433
|
const partialInfo = {
|
|
418
|
-
seed,
|
|
419
434
|
address,
|
|
420
435
|
network: 'preprod',
|
|
421
436
|
status: 'pending_dust',
|
|
422
437
|
lastAttempt: new Date().toISOString(),
|
|
423
438
|
};
|
|
424
439
|
fs.writeFileSync('deployment.json', JSON.stringify(partialInfo, null, 2));
|
|
425
|
-
console.log(' Wallet saved to deployment.json\n');
|
|
440
|
+
console.log(' Wallet saved to .midnight-seed and deployment.json\n');
|
|
426
441
|
|
|
427
442
|
await walletCtx.wallet.stop();
|
|
428
443
|
process.exit(1);
|
|
@@ -443,9 +458,9 @@ async function main() {
|
|
|
443
458
|
console.log(` Contract Address: ${contractAddress}\n`);
|
|
444
459
|
|
|
445
460
|
// 5. Save deployment info
|
|
461
|
+
fs.writeFileSync('.midnight-seed', seed, { mode: 0o600 });
|
|
446
462
|
const deploymentInfo = {
|
|
447
463
|
contractAddress,
|
|
448
|
-
seed,
|
|
449
464
|
network: 'preprod',
|
|
450
465
|
deployedAt: new Date().toISOString(),
|
|
451
466
|
};
|