@metamask-previews/wallet-cli 0.0.0-preview-9de9aa4 → 0.0.0-preview-153490ebd
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/CHANGELOG.md +2 -5
- package/dist/daemon/types.cjs.map +1 -1
- package/dist/daemon/types.d.cts +0 -28
- package/dist/daemon/types.d.cts.map +1 -1
- package/dist/daemon/types.d.mts +0 -28
- package/dist/daemon/types.d.mts.map +1 -1
- package/dist/daemon/types.mjs.map +1 -1
- package/package.json +2 -4
- package/dist/daemon/daemon-client.cjs +0 -140
- package/dist/daemon/daemon-client.cjs.map +0 -1
- package/dist/daemon/daemon-client.d.cts +0 -79
- package/dist/daemon/daemon-client.d.cts.map +0 -1
- package/dist/daemon/daemon-client.d.mts +0 -79
- package/dist/daemon/daemon-client.d.mts.map +0 -1
- package/dist/daemon/daemon-client.mjs +0 -135
- package/dist/daemon/daemon-client.mjs.map +0 -1
- package/dist/daemon/daemon-spawn.cjs +0 -106
- package/dist/daemon/daemon-spawn.cjs.map +0 -1
- package/dist/daemon/daemon-spawn.d.cts +0 -28
- package/dist/daemon/daemon-spawn.d.cts.map +0 -1
- package/dist/daemon/daemon-spawn.d.mts +0 -28
- package/dist/daemon/daemon-spawn.d.mts.map +0 -1
- package/dist/daemon/daemon-spawn.mjs +0 -102
- package/dist/daemon/daemon-spawn.mjs.map +0 -1
- package/dist/daemon/prompts.cjs +0 -21
- package/dist/daemon/prompts.cjs.map +0 -1
- package/dist/daemon/prompts.d.cts +0 -11
- package/dist/daemon/prompts.d.cts.map +0 -1
- package/dist/daemon/prompts.d.mts +0 -11
- package/dist/daemon/prompts.d.mts.map +0 -1
- package/dist/daemon/prompts.mjs +0 -17
- package/dist/daemon/prompts.mjs.map +0 -1
- package/dist/daemon/rpc-socket-server.cjs +0 -271
- package/dist/daemon/rpc-socket-server.cjs.map +0 -1
- package/dist/daemon/rpc-socket-server.d.cts +0 -44
- package/dist/daemon/rpc-socket-server.d.cts.map +0 -1
- package/dist/daemon/rpc-socket-server.d.mts +0 -44
- package/dist/daemon/rpc-socket-server.d.mts.map +0 -1
- package/dist/daemon/rpc-socket-server.mjs +0 -267
- package/dist/daemon/rpc-socket-server.mjs.map +0 -1
- package/dist/daemon/socket-line.cjs +0 -89
- package/dist/daemon/socket-line.cjs.map +0 -1
- package/dist/daemon/socket-line.d.cts +0 -19
- package/dist/daemon/socket-line.d.cts.map +0 -1
- package/dist/daemon/socket-line.d.mts +0 -19
- package/dist/daemon/socket-line.d.mts.map +0 -1
- package/dist/daemon/socket-line.mjs +0 -84
- package/dist/daemon/socket-line.mjs.map +0 -1
- package/dist/daemon/stop-daemon.cjs +0 -103
- package/dist/daemon/stop-daemon.cjs.map +0 -1
- package/dist/daemon/stop-daemon.d.cts +0 -18
- package/dist/daemon/stop-daemon.d.cts.map +0 -1
- package/dist/daemon/stop-daemon.d.mts +0 -18
- package/dist/daemon/stop-daemon.d.mts.map +0 -1
- package/dist/daemon/stop-daemon.mjs +0 -99
- package/dist/daemon/stop-daemon.mjs.map +0 -1
- package/dist/daemon/utils.cjs +0 -109
- package/dist/daemon/utils.cjs.map +0 -1
- package/dist/daemon/utils.d.cts +0 -50
- package/dist/daemon/utils.d.cts.map +0 -1
- package/dist/daemon/utils.d.mts +0 -50
- package/dist/daemon/utils.d.mts.map +0 -1
- package/dist/daemon/utils.mjs +0 -101
- package/dist/daemon/utils.mjs.map +0 -1
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureDaemon = void 0;
|
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
const daemon_client_1 = require("./daemon-client.cjs");
|
|
8
|
-
const paths_1 = require("./paths.cjs");
|
|
9
|
-
const POLL_INTERVAL_MS = 100;
|
|
10
|
-
const MAX_POLLS = 300; // 30 seconds
|
|
11
|
-
/**
|
|
12
|
-
* Ensure the daemon is running. If a responsive daemon already exists, return
|
|
13
|
-
* `'already-running'` (caller decides how to surface that). Otherwise spawn
|
|
14
|
-
* one as a detached process and wait until the socket becomes responsive.
|
|
15
|
-
*
|
|
16
|
-
* Refuses to spawn when pinging the existing socket fails with anything other
|
|
17
|
-
* than `ENOENT` (wedged or foreign daemon) — taking over could orphan the
|
|
18
|
-
* existing process and corrupt its PID file.
|
|
19
|
-
*
|
|
20
|
-
* @param config - Spawn configuration.
|
|
21
|
-
* @returns The state of the daemon and the socket path it's listening on.
|
|
22
|
-
*/
|
|
23
|
-
async function ensureDaemon(config) {
|
|
24
|
-
const { socketPath } = (0, paths_1.getDaemonPaths)(config.dataDir);
|
|
25
|
-
const initialPing = await (0, daemon_client_1.pingDaemon)(socketPath);
|
|
26
|
-
if (initialPing.status === 'responsive') {
|
|
27
|
-
return { state: 'already-running', socketPath };
|
|
28
|
-
}
|
|
29
|
-
if (initialPing.status === 'unreachable') {
|
|
30
|
-
if (initialPing.reason === 'permission') {
|
|
31
|
-
throw new Error(`Refusing to start: the socket at ${socketPath} is owned by another user. ` +
|
|
32
|
-
`Choose a different data directory (MM_DAEMON_DATA_DIR) or remove the socket manually. ` +
|
|
33
|
-
`(${initialPing.error.message})`);
|
|
34
|
-
}
|
|
35
|
-
throw new Error(`Refusing to start: a daemon socket already exists at ${socketPath} but is unresponsive. ` +
|
|
36
|
-
`Run \`mm daemon stop\` (or \`mm daemon purge\`) before starting a new daemon. ` +
|
|
37
|
-
`(${initialPing.error.message})`);
|
|
38
|
-
}
|
|
39
|
-
process.stderr.write('Starting daemon...\n');
|
|
40
|
-
const { entryPath, args } = resolveEntryPoint(config.packageRoot);
|
|
41
|
-
const child = (0, node_child_process_1.spawn)(process.execPath, [...args, entryPath], {
|
|
42
|
-
detached: true,
|
|
43
|
-
stdio: 'ignore',
|
|
44
|
-
env: {
|
|
45
|
-
...process.env,
|
|
46
|
-
MM_DAEMON_DATA_DIR: config.dataDir,
|
|
47
|
-
MM_DAEMON_SOCKET_PATH: socketPath,
|
|
48
|
-
INFURA_PROJECT_ID: config.infuraProjectId,
|
|
49
|
-
MM_WALLET_PASSWORD: config.password,
|
|
50
|
-
MM_WALLET_SRP: config.srp,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
const exitInfo = { value: null };
|
|
54
|
-
// A failed spawn (bad interpreter, EACCES, ENOENT) emits 'error' and may
|
|
55
|
-
// never emit 'exit'. Capture it so the readiness loop can surface the real
|
|
56
|
-
// cause immediately instead of hanging for the full timeout.
|
|
57
|
-
const spawnError = { value: null };
|
|
58
|
-
child.on('error', (error) => {
|
|
59
|
-
process.stderr.write(`Failed to spawn daemon process: ${String(error)}\n`);
|
|
60
|
-
spawnError.value = error;
|
|
61
|
-
});
|
|
62
|
-
child.on('exit', (code, signal) => {
|
|
63
|
-
exitInfo.value = { code, signal };
|
|
64
|
-
});
|
|
65
|
-
child.unref();
|
|
66
|
-
for (let i = 0; i < MAX_POLLS; i++) {
|
|
67
|
-
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
68
|
-
if (spawnError.value !== null) {
|
|
69
|
-
throw new Error(`Failed to spawn daemon process: ${spawnError.value.message}. ` +
|
|
70
|
-
`Check the daemon log at ${(0, paths_1.getDaemonPaths)(config.dataDir).logPath}.`);
|
|
71
|
-
}
|
|
72
|
-
if (exitInfo.value !== null) {
|
|
73
|
-
const { code, signal } = exitInfo.value;
|
|
74
|
-
throw new Error(`Daemon process exited during startup (code=${String(code)}, signal=${String(signal)}). ` +
|
|
75
|
-
`Check the daemon log at ${(0, paths_1.getDaemonPaths)(config.dataDir).logPath}.`);
|
|
76
|
-
}
|
|
77
|
-
const ping = await (0, daemon_client_1.pingDaemon)(socketPath);
|
|
78
|
-
if (ping.status === 'responsive') {
|
|
79
|
-
process.stderr.write('Daemon ready.\n');
|
|
80
|
-
return { state: 'started', socketPath };
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
throw new Error(`Daemon did not start within ${(MAX_POLLS * POLL_INTERVAL_MS) / 1000}s`);
|
|
84
|
-
}
|
|
85
|
-
exports.ensureDaemon = ensureDaemon;
|
|
86
|
-
/**
|
|
87
|
-
* Resolve the daemon entry point path and any extra Node.js args needed.
|
|
88
|
-
*
|
|
89
|
-
* In production, uses the compiled dist output. In development, uses tsx
|
|
90
|
-
* to run TypeScript source directly.
|
|
91
|
-
*
|
|
92
|
-
* @param packageRoot - The root directory of the wallet-cli package.
|
|
93
|
-
* @returns The entry path and any extra node args.
|
|
94
|
-
*/
|
|
95
|
-
function resolveEntryPoint(packageRoot) {
|
|
96
|
-
const distEntry = (0, node_path_1.join)(packageRoot, 'dist', 'daemon', 'daemon-entry.mjs');
|
|
97
|
-
if ((0, node_fs_1.existsSync)(distEntry)) {
|
|
98
|
-
return { entryPath: distEntry, args: [] };
|
|
99
|
-
}
|
|
100
|
-
const srcEntry = (0, node_path_1.join)(packageRoot, 'src', 'daemon', 'daemon-entry.ts');
|
|
101
|
-
return {
|
|
102
|
-
entryPath: srcEntry,
|
|
103
|
-
args: ['--import', 'tsx'],
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=daemon-spawn.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-spawn.cjs","sourceRoot":"","sources":["../../src/daemon/daemon-spawn.ts"],"names":[],"mappings":";;;AAAA,2DAA2C;AAC3C,qCAAqC;AACrC,yCAAiC;AAEjC,uDAA6C;AAC7C,uCAAyC;AAGzC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,aAAa;AAgBpC;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,YAAY,CAChC,MAAyB;IAEzB,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,sBAAc,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IA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CAAC,OAAO,GAAG,CACvE,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAA,0BAAU,EAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;YACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YACxC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,+BAA+B,CAAC,SAAS,GAAG,gBAAgB,CAAC,GAAG,IAAI,GAAG,CACxE,CAAC;AACJ,CAAC;AAlFD,oCAkFC;AAED;;;;;;;;GAQG;AACH,SAAS,iBAAiB,CAAC,WAAmB;IAI5C,MAAM,SAAS,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC1E,IAAI,IAAA,oBAAU,EAAC,SAAS,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC5C,CAAC;IAED,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IACvE,OAAO;QACL,SAAS,EAAE,QAAQ;QACnB,IAAI,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport { pingDaemon } from './daemon-client';\nimport { getDaemonPaths } from './paths';\nimport type { DaemonSpawnConfig } from './types';\n\nconst POLL_INTERVAL_MS = 100;\nconst MAX_POLLS = 300; // 30 seconds\n\n/**\n * Outcome of {@link ensureDaemon}.\n *\n * - `'already-running'`: a responsive daemon was found at the configured\n * socket path. The supplied flags (`infuraProjectId`, `password`, `srp`)\n * were NOT applied to that daemon; the caller should surface this so a\n * user who is trying to change them isn't silently ignored.\n * - `'started'`: a new daemon was spawned and is now responsive.\n */\nexport type EnsureDaemonResult = {\n state: 'already-running' | 'started';\n socketPath: string;\n};\n\n/**\n * Ensure the daemon is running. If a responsive daemon already exists, return\n * `'already-running'` (caller decides how to surface that). Otherwise spawn\n * one as a detached process and wait until the socket becomes responsive.\n *\n * Refuses to spawn when pinging the existing socket fails with anything other\n * than `ENOENT` (wedged or foreign daemon) — taking over could orphan the\n * existing process and corrupt its PID file.\n *\n * @param config - Spawn configuration.\n * @returns The state of the daemon and the socket path it's listening on.\n */\nexport async function ensureDaemon(\n config: DaemonSpawnConfig,\n): Promise<EnsureDaemonResult> {\n const { socketPath } = getDaemonPaths(config.dataDir);\n\n const initialPing = await pingDaemon(socketPath);\n if (initialPing.status === 'responsive') {\n return { state: 'already-running', socketPath };\n }\n if (initialPing.status === 'unreachable') {\n if (initialPing.reason === 'permission') {\n throw new Error(\n `Refusing to start: the socket at ${socketPath} is owned by another user. ` +\n `Choose a different data directory (MM_DAEMON_DATA_DIR) or remove the socket manually. ` +\n `(${initialPing.error.message})`,\n );\n }\n throw new Error(\n `Refusing to start: a daemon socket already exists at ${socketPath} but is unresponsive. ` +\n `Run \\`mm daemon stop\\` (or \\`mm daemon purge\\`) before starting a new daemon. ` +\n `(${initialPing.error.message})`,\n );\n }\n\n process.stderr.write('Starting daemon...\\n');\n\n const { entryPath, args } = resolveEntryPoint(config.packageRoot);\n\n const child = spawn(process.execPath, [...args, entryPath], {\n detached: true,\n stdio: 'ignore',\n env: {\n ...process.env,\n MM_DAEMON_DATA_DIR: config.dataDir,\n MM_DAEMON_SOCKET_PATH: socketPath,\n INFURA_PROJECT_ID: config.infuraProjectId,\n MM_WALLET_PASSWORD: config.password,\n MM_WALLET_SRP: config.srp,\n },\n });\n\n type ExitInfo = { code: number | null; signal: NodeJS.Signals | null };\n const exitInfo: { value: ExitInfo | null } = { value: null };\n // A failed spawn (bad interpreter, EACCES, ENOENT) emits 'error' and may\n // never emit 'exit'. Capture it so the readiness loop can surface the real\n // cause immediately instead of hanging for the full timeout.\n const spawnError: { value: Error | null } = { value: null };\n\n child.on('error', (error: Error) => {\n process.stderr.write(`Failed to spawn daemon process: ${String(error)}\\n`);\n spawnError.value = error;\n });\n child.on('exit', (code, signal) => {\n exitInfo.value = { code, signal };\n });\n child.unref();\n\n for (let i = 0; i < MAX_POLLS; i++) {\n await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));\n if (spawnError.value !== null) {\n throw new Error(\n `Failed to spawn daemon process: ${spawnError.value.message}. ` +\n `Check the daemon log at ${getDaemonPaths(config.dataDir).logPath}.`,\n );\n }\n if (exitInfo.value !== null) {\n const { code, signal } = exitInfo.value;\n throw new Error(\n `Daemon process exited during startup (code=${String(code)}, signal=${String(signal)}). ` +\n `Check the daemon log at ${getDaemonPaths(config.dataDir).logPath}.`,\n );\n }\n const ping = await pingDaemon(socketPath);\n if (ping.status === 'responsive') {\n process.stderr.write('Daemon ready.\\n');\n return { state: 'started', socketPath };\n }\n }\n\n throw new Error(\n `Daemon did not start within ${(MAX_POLLS * POLL_INTERVAL_MS) / 1000}s`,\n );\n}\n\n/**\n * Resolve the daemon entry point path and any extra Node.js args needed.\n *\n * In production, uses the compiled dist output. In development, uses tsx\n * to run TypeScript source directly.\n *\n * @param packageRoot - The root directory of the wallet-cli package.\n * @returns The entry path and any extra node args.\n */\nfunction resolveEntryPoint(packageRoot: string): {\n entryPath: string;\n args: string[];\n} {\n const distEntry = join(packageRoot, 'dist', 'daemon', 'daemon-entry.mjs');\n if (existsSync(distEntry)) {\n return { entryPath: distEntry, args: [] };\n }\n\n const srcEntry = join(packageRoot, 'src', 'daemon', 'daemon-entry.ts');\n return {\n entryPath: srcEntry,\n args: ['--import', 'tsx'],\n };\n}\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { DaemonSpawnConfig } from "./types.cjs";
|
|
2
|
-
/**
|
|
3
|
-
* Outcome of {@link ensureDaemon}.
|
|
4
|
-
*
|
|
5
|
-
* - `'already-running'`: a responsive daemon was found at the configured
|
|
6
|
-
* socket path. The supplied flags (`infuraProjectId`, `password`, `srp`)
|
|
7
|
-
* were NOT applied to that daemon; the caller should surface this so a
|
|
8
|
-
* user who is trying to change them isn't silently ignored.
|
|
9
|
-
* - `'started'`: a new daemon was spawned and is now responsive.
|
|
10
|
-
*/
|
|
11
|
-
export type EnsureDaemonResult = {
|
|
12
|
-
state: 'already-running' | 'started';
|
|
13
|
-
socketPath: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Ensure the daemon is running. If a responsive daemon already exists, return
|
|
17
|
-
* `'already-running'` (caller decides how to surface that). Otherwise spawn
|
|
18
|
-
* one as a detached process and wait until the socket becomes responsive.
|
|
19
|
-
*
|
|
20
|
-
* Refuses to spawn when pinging the existing socket fails with anything other
|
|
21
|
-
* than `ENOENT` (wedged or foreign daemon) — taking over could orphan the
|
|
22
|
-
* existing process and corrupt its PID file.
|
|
23
|
-
*
|
|
24
|
-
* @param config - Spawn configuration.
|
|
25
|
-
* @returns The state of the daemon and the socket path it's listening on.
|
|
26
|
-
*/
|
|
27
|
-
export declare function ensureDaemon(config: DaemonSpawnConfig): Promise<EnsureDaemonResult>;
|
|
28
|
-
//# sourceMappingURL=daemon-spawn.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-spawn.d.cts","sourceRoot":"","sources":["../../src/daemon/daemon-spawn.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAgB;AAKjD;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,kBAAkB,CAAC,CAgF7B"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { DaemonSpawnConfig } from "./types.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* Outcome of {@link ensureDaemon}.
|
|
4
|
-
*
|
|
5
|
-
* - `'already-running'`: a responsive daemon was found at the configured
|
|
6
|
-
* socket path. The supplied flags (`infuraProjectId`, `password`, `srp`)
|
|
7
|
-
* were NOT applied to that daemon; the caller should surface this so a
|
|
8
|
-
* user who is trying to change them isn't silently ignored.
|
|
9
|
-
* - `'started'`: a new daemon was spawned and is now responsive.
|
|
10
|
-
*/
|
|
11
|
-
export type EnsureDaemonResult = {
|
|
12
|
-
state: 'already-running' | 'started';
|
|
13
|
-
socketPath: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Ensure the daemon is running. If a responsive daemon already exists, return
|
|
17
|
-
* `'already-running'` (caller decides how to surface that). Otherwise spawn
|
|
18
|
-
* one as a detached process and wait until the socket becomes responsive.
|
|
19
|
-
*
|
|
20
|
-
* Refuses to spawn when pinging the existing socket fails with anything other
|
|
21
|
-
* than `ENOENT` (wedged or foreign daemon) — taking over could orphan the
|
|
22
|
-
* existing process and corrupt its PID file.
|
|
23
|
-
*
|
|
24
|
-
* @param config - Spawn configuration.
|
|
25
|
-
* @returns The state of the daemon and the socket path it's listening on.
|
|
26
|
-
*/
|
|
27
|
-
export declare function ensureDaemon(config: DaemonSpawnConfig): Promise<EnsureDaemonResult>;
|
|
28
|
-
//# sourceMappingURL=daemon-spawn.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-spawn.d.mts","sourceRoot":"","sources":["../../src/daemon/daemon-spawn.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAgB;AAKjD;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,kBAAkB,CAAC,CAgF7B"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { pingDaemon } from "./daemon-client.mjs";
|
|
5
|
-
import { getDaemonPaths } from "./paths.mjs";
|
|
6
|
-
const POLL_INTERVAL_MS = 100;
|
|
7
|
-
const MAX_POLLS = 300; // 30 seconds
|
|
8
|
-
/**
|
|
9
|
-
* Ensure the daemon is running. If a responsive daemon already exists, return
|
|
10
|
-
* `'already-running'` (caller decides how to surface that). Otherwise spawn
|
|
11
|
-
* one as a detached process and wait until the socket becomes responsive.
|
|
12
|
-
*
|
|
13
|
-
* Refuses to spawn when pinging the existing socket fails with anything other
|
|
14
|
-
* than `ENOENT` (wedged or foreign daemon) — taking over could orphan the
|
|
15
|
-
* existing process and corrupt its PID file.
|
|
16
|
-
*
|
|
17
|
-
* @param config - Spawn configuration.
|
|
18
|
-
* @returns The state of the daemon and the socket path it's listening on.
|
|
19
|
-
*/
|
|
20
|
-
export async function ensureDaemon(config) {
|
|
21
|
-
const { socketPath } = getDaemonPaths(config.dataDir);
|
|
22
|
-
const initialPing = await pingDaemon(socketPath);
|
|
23
|
-
if (initialPing.status === 'responsive') {
|
|
24
|
-
return { state: 'already-running', socketPath };
|
|
25
|
-
}
|
|
26
|
-
if (initialPing.status === 'unreachable') {
|
|
27
|
-
if (initialPing.reason === 'permission') {
|
|
28
|
-
throw new Error(`Refusing to start: the socket at ${socketPath} is owned by another user. ` +
|
|
29
|
-
`Choose a different data directory (MM_DAEMON_DATA_DIR) or remove the socket manually. ` +
|
|
30
|
-
`(${initialPing.error.message})`);
|
|
31
|
-
}
|
|
32
|
-
throw new Error(`Refusing to start: a daemon socket already exists at ${socketPath} but is unresponsive. ` +
|
|
33
|
-
`Run \`mm daemon stop\` (or \`mm daemon purge\`) before starting a new daemon. ` +
|
|
34
|
-
`(${initialPing.error.message})`);
|
|
35
|
-
}
|
|
36
|
-
process.stderr.write('Starting daemon...\n');
|
|
37
|
-
const { entryPath, args } = resolveEntryPoint(config.packageRoot);
|
|
38
|
-
const child = spawn(process.execPath, [...args, entryPath], {
|
|
39
|
-
detached: true,
|
|
40
|
-
stdio: 'ignore',
|
|
41
|
-
env: {
|
|
42
|
-
...process.env,
|
|
43
|
-
MM_DAEMON_DATA_DIR: config.dataDir,
|
|
44
|
-
MM_DAEMON_SOCKET_PATH: socketPath,
|
|
45
|
-
INFURA_PROJECT_ID: config.infuraProjectId,
|
|
46
|
-
MM_WALLET_PASSWORD: config.password,
|
|
47
|
-
MM_WALLET_SRP: config.srp,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
const exitInfo = { value: null };
|
|
51
|
-
// A failed spawn (bad interpreter, EACCES, ENOENT) emits 'error' and may
|
|
52
|
-
// never emit 'exit'. Capture it so the readiness loop can surface the real
|
|
53
|
-
// cause immediately instead of hanging for the full timeout.
|
|
54
|
-
const spawnError = { value: null };
|
|
55
|
-
child.on('error', (error) => {
|
|
56
|
-
process.stderr.write(`Failed to spawn daemon process: ${String(error)}\n`);
|
|
57
|
-
spawnError.value = error;
|
|
58
|
-
});
|
|
59
|
-
child.on('exit', (code, signal) => {
|
|
60
|
-
exitInfo.value = { code, signal };
|
|
61
|
-
});
|
|
62
|
-
child.unref();
|
|
63
|
-
for (let i = 0; i < MAX_POLLS; i++) {
|
|
64
|
-
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
65
|
-
if (spawnError.value !== null) {
|
|
66
|
-
throw new Error(`Failed to spawn daemon process: ${spawnError.value.message}. ` +
|
|
67
|
-
`Check the daemon log at ${getDaemonPaths(config.dataDir).logPath}.`);
|
|
68
|
-
}
|
|
69
|
-
if (exitInfo.value !== null) {
|
|
70
|
-
const { code, signal } = exitInfo.value;
|
|
71
|
-
throw new Error(`Daemon process exited during startup (code=${String(code)}, signal=${String(signal)}). ` +
|
|
72
|
-
`Check the daemon log at ${getDaemonPaths(config.dataDir).logPath}.`);
|
|
73
|
-
}
|
|
74
|
-
const ping = await pingDaemon(socketPath);
|
|
75
|
-
if (ping.status === 'responsive') {
|
|
76
|
-
process.stderr.write('Daemon ready.\n');
|
|
77
|
-
return { state: 'started', socketPath };
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
throw new Error(`Daemon did not start within ${(MAX_POLLS * POLL_INTERVAL_MS) / 1000}s`);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Resolve the daemon entry point path and any extra Node.js args needed.
|
|
84
|
-
*
|
|
85
|
-
* In production, uses the compiled dist output. In development, uses tsx
|
|
86
|
-
* to run TypeScript source directly.
|
|
87
|
-
*
|
|
88
|
-
* @param packageRoot - The root directory of the wallet-cli package.
|
|
89
|
-
* @returns The entry path and any extra node args.
|
|
90
|
-
*/
|
|
91
|
-
function resolveEntryPoint(packageRoot) {
|
|
92
|
-
const distEntry = join(packageRoot, 'dist', 'daemon', 'daemon-entry.mjs');
|
|
93
|
-
if (existsSync(distEntry)) {
|
|
94
|
-
return { entryPath: distEntry, args: [] };
|
|
95
|
-
}
|
|
96
|
-
const srcEntry = join(packageRoot, 'src', 'daemon', 'daemon-entry.ts');
|
|
97
|
-
return {
|
|
98
|
-
entryPath: srcEntry,
|
|
99
|
-
args: ['--import', 'tsx'],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=daemon-spawn.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-spawn.mjs","sourceRoot":"","sources":["../../src/daemon/daemon-spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,2BAA2B;AAC3C,OAAO,EA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;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport { pingDaemon } from './daemon-client';\nimport { getDaemonPaths } from './paths';\nimport type { DaemonSpawnConfig } from './types';\n\nconst POLL_INTERVAL_MS = 100;\nconst MAX_POLLS = 300; // 30 seconds\n\n/**\n * Outcome of {@link ensureDaemon}.\n *\n * - `'already-running'`: a responsive daemon was found at the configured\n * socket path. The supplied flags (`infuraProjectId`, `password`, `srp`)\n * were NOT applied to that daemon; the caller should surface this so a\n * user who is trying to change them isn't silently ignored.\n * - `'started'`: a new daemon was spawned and is now responsive.\n */\nexport type EnsureDaemonResult = {\n state: 'already-running' | 'started';\n socketPath: string;\n};\n\n/**\n * Ensure the daemon is running. If a responsive daemon already exists, return\n * `'already-running'` (caller decides how to surface that). Otherwise spawn\n * one as a detached process and wait until the socket becomes responsive.\n *\n * Refuses to spawn when pinging the existing socket fails with anything other\n * than `ENOENT` (wedged or foreign daemon) — taking over could orphan the\n * existing process and corrupt its PID file.\n *\n * @param config - Spawn configuration.\n * @returns The state of the daemon and the socket path it's listening on.\n */\nexport async function ensureDaemon(\n config: DaemonSpawnConfig,\n): Promise<EnsureDaemonResult> {\n const { socketPath } = getDaemonPaths(config.dataDir);\n\n const initialPing = await pingDaemon(socketPath);\n if (initialPing.status === 'responsive') {\n return { state: 'already-running', socketPath };\n }\n if (initialPing.status === 'unreachable') {\n if (initialPing.reason === 'permission') {\n throw new Error(\n `Refusing to start: the socket at ${socketPath} is owned by another user. ` +\n `Choose a different data directory (MM_DAEMON_DATA_DIR) or remove the socket manually. ` +\n `(${initialPing.error.message})`,\n );\n }\n throw new Error(\n `Refusing to start: a daemon socket already exists at ${socketPath} but is unresponsive. ` +\n `Run \\`mm daemon stop\\` (or \\`mm daemon purge\\`) before starting a new daemon. ` +\n `(${initialPing.error.message})`,\n );\n }\n\n process.stderr.write('Starting daemon...\\n');\n\n const { entryPath, args } = resolveEntryPoint(config.packageRoot);\n\n const child = spawn(process.execPath, [...args, entryPath], {\n detached: true,\n stdio: 'ignore',\n env: {\n ...process.env,\n MM_DAEMON_DATA_DIR: config.dataDir,\n MM_DAEMON_SOCKET_PATH: socketPath,\n INFURA_PROJECT_ID: config.infuraProjectId,\n MM_WALLET_PASSWORD: config.password,\n MM_WALLET_SRP: config.srp,\n },\n });\n\n type ExitInfo = { code: number | null; signal: NodeJS.Signals | null };\n const exitInfo: { value: ExitInfo | null } = { value: null };\n // A failed spawn (bad interpreter, EACCES, ENOENT) emits 'error' and may\n // never emit 'exit'. Capture it so the readiness loop can surface the real\n // cause immediately instead of hanging for the full timeout.\n const spawnError: { value: Error | null } = { value: null };\n\n child.on('error', (error: Error) => {\n process.stderr.write(`Failed to spawn daemon process: ${String(error)}\\n`);\n spawnError.value = error;\n });\n child.on('exit', (code, signal) => {\n exitInfo.value = { code, signal };\n });\n child.unref();\n\n for (let i = 0; i < MAX_POLLS; i++) {\n await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));\n if (spawnError.value !== null) {\n throw new Error(\n `Failed to spawn daemon process: ${spawnError.value.message}. ` +\n `Check the daemon log at ${getDaemonPaths(config.dataDir).logPath}.`,\n );\n }\n if (exitInfo.value !== null) {\n const { code, signal } = exitInfo.value;\n throw new Error(\n `Daemon process exited during startup (code=${String(code)}, signal=${String(signal)}). ` +\n `Check the daemon log at ${getDaemonPaths(config.dataDir).logPath}.`,\n );\n }\n const ping = await pingDaemon(socketPath);\n if (ping.status === 'responsive') {\n process.stderr.write('Daemon ready.\\n');\n return { state: 'started', socketPath };\n }\n }\n\n throw new Error(\n `Daemon did not start within ${(MAX_POLLS * POLL_INTERVAL_MS) / 1000}s`,\n );\n}\n\n/**\n * Resolve the daemon entry point path and any extra Node.js args needed.\n *\n * In production, uses the compiled dist output. In development, uses tsx\n * to run TypeScript source directly.\n *\n * @param packageRoot - The root directory of the wallet-cli package.\n * @returns The entry path and any extra node args.\n */\nfunction resolveEntryPoint(packageRoot: string): {\n entryPath: string;\n args: string[];\n} {\n const distEntry = join(packageRoot, 'dist', 'daemon', 'daemon-entry.mjs');\n if (existsSync(distEntry)) {\n return { entryPath: distEntry, args: [] };\n }\n\n const srcEntry = join(packageRoot, 'src', 'daemon', 'daemon-entry.ts');\n return {\n entryPath: srcEntry,\n args: ['--import', 'tsx'],\n };\n}\n"]}
|
package/dist/daemon/prompts.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.confirmPurge = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Ask the user to confirm the destructive `daemon purge` operation.
|
|
6
|
-
*
|
|
7
|
-
* Wraps `@inquirer/confirm` in a dynamic import so this CommonJS-compiled
|
|
8
|
-
* package can interop with that ESM-only dependency, and so tests can mock
|
|
9
|
-
* the prompt without going through jest's ESM mock machinery.
|
|
10
|
-
*
|
|
11
|
-
* @returns True if the user confirmed.
|
|
12
|
-
*/
|
|
13
|
-
async function confirmPurge() {
|
|
14
|
-
const { default: confirm } = await import("@inquirer/confirm");
|
|
15
|
-
return confirm({
|
|
16
|
-
message: 'This will stop the daemon and delete all state. Continue?',
|
|
17
|
-
default: false,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
exports.confirmPurge = confirmPurge;
|
|
21
|
-
//# sourceMappingURL=prompts.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.cjs","sourceRoot":"","sources":["../../src/daemon/prompts.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACI,KAAK,UAAU,YAAY;IAChC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,qBAAqB,CAAC;IAC/D,OAAO,OAAO,CAAC;QACb,OAAO,EAAE,2DAA2D;QACpE,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;AACL,CAAC;AAND,oCAMC","sourcesContent":["/**\n * Ask the user to confirm the destructive `daemon purge` operation.\n *\n * Wraps `@inquirer/confirm` in a dynamic import so this CommonJS-compiled\n * package can interop with that ESM-only dependency, and so tests can mock\n * the prompt without going through jest's ESM mock machinery.\n *\n * @returns True if the user confirmed.\n */\nexport async function confirmPurge(): Promise<boolean> {\n const { default: confirm } = await import('@inquirer/confirm');\n return confirm({\n message: 'This will stop the daemon and delete all state. Continue?',\n default: false,\n });\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ask the user to confirm the destructive `daemon purge` operation.
|
|
3
|
-
*
|
|
4
|
-
* Wraps `@inquirer/confirm` in a dynamic import so this CommonJS-compiled
|
|
5
|
-
* package can interop with that ESM-only dependency, and so tests can mock
|
|
6
|
-
* the prompt without going through jest's ESM mock machinery.
|
|
7
|
-
*
|
|
8
|
-
* @returns True if the user confirmed.
|
|
9
|
-
*/
|
|
10
|
-
export declare function confirmPurge(): Promise<boolean>;
|
|
11
|
-
//# sourceMappingURL=prompts.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.cts","sourceRoot":"","sources":["../../src/daemon/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAMrD"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ask the user to confirm the destructive `daemon purge` operation.
|
|
3
|
-
*
|
|
4
|
-
* Wraps `@inquirer/confirm` in a dynamic import so this CommonJS-compiled
|
|
5
|
-
* package can interop with that ESM-only dependency, and so tests can mock
|
|
6
|
-
* the prompt without going through jest's ESM mock machinery.
|
|
7
|
-
*
|
|
8
|
-
* @returns True if the user confirmed.
|
|
9
|
-
*/
|
|
10
|
-
export declare function confirmPurge(): Promise<boolean>;
|
|
11
|
-
//# sourceMappingURL=prompts.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.mts","sourceRoot":"","sources":["../../src/daemon/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAMrD"}
|
package/dist/daemon/prompts.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ask the user to confirm the destructive `daemon purge` operation.
|
|
3
|
-
*
|
|
4
|
-
* Wraps `@inquirer/confirm` in a dynamic import so this CommonJS-compiled
|
|
5
|
-
* package can interop with that ESM-only dependency, and so tests can mock
|
|
6
|
-
* the prompt without going through jest's ESM mock machinery.
|
|
7
|
-
*
|
|
8
|
-
* @returns True if the user confirmed.
|
|
9
|
-
*/
|
|
10
|
-
export async function confirmPurge() {
|
|
11
|
-
const { default: confirm } = await import("@inquirer/confirm");
|
|
12
|
-
return confirm({
|
|
13
|
-
message: 'This will stop the daemon and delete all state. Continue?',
|
|
14
|
-
default: false,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=prompts.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.mjs","sourceRoot":"","sources":["../../src/daemon/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,qBAAqB,CAAC;IAC/D,OAAO,OAAO,CAAC;QACb,OAAO,EAAE,2DAA2D;QACpE,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Ask the user to confirm the destructive `daemon purge` operation.\n *\n * Wraps `@inquirer/confirm` in a dynamic import so this CommonJS-compiled\n * package can interop with that ESM-only dependency, and so tests can mock\n * the prompt without going through jest's ESM mock machinery.\n *\n * @returns True if the user confirmed.\n */\nexport async function confirmPurge(): Promise<boolean> {\n const { default: confirm } = await import('@inquirer/confirm');\n return confirm({\n message: 'This will stop the daemon and delete all state. Continue?',\n default: false,\n });\n}\n"]}
|