create-mn-app 0.3.15 → 0.3.17
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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"compile": "compact compile contracts/hello-world.compact contracts/managed/hello-world",
|
|
10
10
|
"build": "npx tsc --noEmit || true",
|
|
11
|
-
"setup": "docker compose up -d &&
|
|
11
|
+
"setup": "docker compose up -d && npm run compile && npm run deploy",
|
|
12
12
|
"deploy": "npx tsx src/deploy.ts",
|
|
13
13
|
"cli": "npx tsx src/cli.ts",
|
|
14
14
|
"check-balance": "npx tsx src/check-balance.ts",
|
|
@@ -43,6 +43,35 @@ const CONFIG = {
|
|
|
43
43
|
faucetUrl: 'https://faucet.preprod.midnight.network/',
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
// ─── Proof Server Health Check ─────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
async function waitForProofServer(maxAttempts = 30, delayMs = 2000): Promise<boolean> {
|
|
49
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
50
|
+
try {
|
|
51
|
+
// Try a simple GET - any response (even 404) means server is up
|
|
52
|
+
const response = await fetch(CONFIG.proofServer, {
|
|
53
|
+
method: 'GET',
|
|
54
|
+
signal: AbortSignal.timeout(3000),
|
|
55
|
+
});
|
|
56
|
+
// Any response means the server is running
|
|
57
|
+
return true;
|
|
58
|
+
} catch (err: any) {
|
|
59
|
+
// Check if it's a connection refused vs other error
|
|
60
|
+
const errMsg = err?.cause?.code || err?.code || '';
|
|
61
|
+
if (errMsg !== 'ECONNREFUSED' && errMsg !== 'UND_ERR_CONNECT_TIMEOUT') {
|
|
62
|
+
// Got some other error - server might be up but returning errors
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
// Server not ready yet
|
|
66
|
+
}
|
|
67
|
+
if (attempt < maxAttempts) {
|
|
68
|
+
process.stdout.write(`\r Waiting for proof server... (${attempt}/${maxAttempts}) `);
|
|
69
|
+
await new Promise((r) => setTimeout(r, delayMs));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
46
75
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
47
76
|
const zkConfigPath = path.resolve(__dirname, '..', 'contracts', 'managed', 'hello-world');
|
|
48
77
|
|
|
@@ -280,6 +309,31 @@ async function main() {
|
|
|
280
309
|
|
|
281
310
|
// 4. Deploy contract
|
|
282
311
|
console.log('─── Step 4: Deploy Contract ────────────────────────────────────\n');
|
|
312
|
+
|
|
313
|
+
// Check proof server is running
|
|
314
|
+
console.log(' Checking proof server...');
|
|
315
|
+
const proofServerReady = await waitForProofServer();
|
|
316
|
+
if (!proofServerReady) {
|
|
317
|
+
console.log('\n ❌ Proof server not responding\n');
|
|
318
|
+
console.log(' The proof server is required to generate zk-proofs for transactions.\n');
|
|
319
|
+
console.log(' ┌─ Start it with ──────────────────────────────────────────────┐');
|
|
320
|
+
console.log(' │ │');
|
|
321
|
+
console.log(' │ $ docker compose up -d │');
|
|
322
|
+
console.log(' │ │');
|
|
323
|
+
console.log(' │ Then retry: $ npm run deploy │');
|
|
324
|
+
console.log(' │ │');
|
|
325
|
+
console.log(' └──────────────────────────────────────────────────────────────┘\n');
|
|
326
|
+
|
|
327
|
+
// Save seed for retry
|
|
328
|
+
const partialInfo = { seed, address, network: 'preprod', status: 'proof_server_unavailable' };
|
|
329
|
+
fs.writeFileSync('deployment.json', JSON.stringify(partialInfo, null, 2));
|
|
330
|
+
console.log(' Wallet saved to deployment.json\n');
|
|
331
|
+
|
|
332
|
+
await walletCtx.wallet.stop();
|
|
333
|
+
process.exit(1);
|
|
334
|
+
}
|
|
335
|
+
process.stdout.write('\r Proof server ready! \n');
|
|
336
|
+
|
|
283
337
|
console.log(' Setting up providers...');
|
|
284
338
|
const providers = await createProviders(walletCtx);
|
|
285
339
|
|
|
@@ -300,9 +354,33 @@ async function main() {
|
|
|
300
354
|
break; // Success - exit retry loop
|
|
301
355
|
} catch (err: any) {
|
|
302
356
|
const errMsg = err?.message || err?.toString() || '';
|
|
357
|
+
const errCause = err?.cause?.message || err?.cause?.toString() || '';
|
|
358
|
+
const fullError = `${errMsg} ${errCause}`;
|
|
359
|
+
|
|
360
|
+
// Check for proof server errors first
|
|
361
|
+
if (fullError.includes('Failed to connect to Proof Server') ||
|
|
362
|
+
fullError.includes('Failed to prove') ||
|
|
363
|
+
fullError.includes('127.0.0.1:6300')) {
|
|
364
|
+
console.log(' ❌ Proof server error\n');
|
|
365
|
+
console.log(' The proof server may have stopped or crashed.\n');
|
|
366
|
+
console.log(' ┌─ Fix ────────────────────────────────────────────────────────┐');
|
|
367
|
+
console.log(' │ │');
|
|
368
|
+
console.log(' │ 1. Check if running: $ docker ps │');
|
|
369
|
+
console.log(' │ 2. Restart: $ docker compose up -d │');
|
|
370
|
+
console.log(' │ 3. Retry: $ npm run deploy │');
|
|
371
|
+
console.log(' │ │');
|
|
372
|
+
console.log(' └──────────────────────────────────────────────────────────────┘\n');
|
|
373
|
+
|
|
374
|
+
const partialInfo = { seed, address, network: 'preprod', status: 'proof_server_error' };
|
|
375
|
+
fs.writeFileSync('deployment.json', JSON.stringify(partialInfo, null, 2));
|
|
376
|
+
console.log(' Wallet saved to deployment.json\n');
|
|
377
|
+
|
|
378
|
+
await walletCtx.wallet.stop();
|
|
379
|
+
process.exit(1);
|
|
380
|
+
}
|
|
303
381
|
|
|
304
|
-
// Check if it's a DUST-related error
|
|
305
|
-
if (
|
|
382
|
+
// Check if it's a DUST-related error (must check "Not enough Dust" specifically)
|
|
383
|
+
if (fullError.includes('Not enough Dust')) {
|
|
306
384
|
// Get current DUST balance
|
|
307
385
|
const currentState = await Rx.firstValueFrom(walletCtx.wallet.state().pipe(Rx.filter((s) => s.isSynced)));
|
|
308
386
|
const dustBalance = currentState.dust.walletBalance(new Date());
|