@metamask-previews/wallet-cli 0.0.0-preview-a1f454c3a → 0.0.0-preview-eb182b860
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 -0
- package/README.md +27 -0
- package/dist/commands/daemon/call.cjs +83 -0
- package/dist/commands/daemon/call.cjs.map +1 -0
- package/dist/commands/daemon/call.d.cts +14 -0
- package/dist/commands/daemon/call.d.cts.map +1 -0
- package/dist/commands/daemon/call.d.mts +14 -0
- package/dist/commands/daemon/call.d.mts.map +1 -0
- package/dist/commands/daemon/call.mjs +81 -0
- package/dist/commands/daemon/call.mjs.map +1 -0
- package/dist/commands/daemon/purge.cjs +58 -0
- package/dist/commands/daemon/purge.cjs.map +1 -0
- package/dist/commands/daemon/purge.d.cts +10 -0
- package/dist/commands/daemon/purge.d.cts.map +1 -0
- package/dist/commands/daemon/purge.d.mts +10 -0
- package/dist/commands/daemon/purge.d.mts.map +1 -0
- package/dist/commands/daemon/purge.mjs +56 -0
- package/dist/commands/daemon/purge.mjs.map +1 -0
- package/dist/commands/daemon/start.cjs +48 -0
- package/dist/commands/daemon/start.cjs.map +1 -0
- package/dist/commands/daemon/start.d.cts +12 -0
- package/dist/commands/daemon/start.d.cts.map +1 -0
- package/dist/commands/daemon/start.d.mts +12 -0
- package/dist/commands/daemon/start.d.mts.map +1 -0
- package/dist/commands/daemon/start.mjs +46 -0
- package/dist/commands/daemon/start.mjs.map +1 -0
- package/dist/commands/daemon/status.cjs +59 -0
- package/dist/commands/daemon/status.cjs.map +1 -0
- package/dist/commands/daemon/status.d.cts +7 -0
- package/dist/commands/daemon/status.d.cts.map +1 -0
- package/dist/commands/daemon/status.d.mts +7 -0
- package/dist/commands/daemon/status.d.mts.map +1 -0
- package/dist/commands/daemon/status.mjs +57 -0
- package/dist/commands/daemon/status.mjs.map +1 -0
- package/dist/commands/daemon/stop.cjs +26 -0
- package/dist/commands/daemon/stop.cjs.map +1 -0
- package/dist/commands/daemon/stop.d.cts +7 -0
- package/dist/commands/daemon/stop.d.cts.map +1 -0
- package/dist/commands/daemon/stop.d.mts +7 -0
- package/dist/commands/daemon/stop.d.mts.map +1 -0
- package/dist/commands/daemon/stop.mjs +24 -0
- package/dist/commands/daemon/stop.mjs.map +1 -0
- package/dist/daemon/daemon-entry.cjs +245 -0
- package/dist/daemon/daemon-entry.cjs.map +1 -0
- package/dist/daemon/daemon-entry.d.cts +2 -0
- package/dist/daemon/daemon-entry.d.cts.map +1 -0
- package/dist/daemon/daemon-entry.d.mts +2 -0
- package/dist/daemon/daemon-entry.d.mts.map +1 -0
- package/dist/daemon/daemon-entry.mjs +243 -0
- package/dist/daemon/daemon-entry.mjs.map +1 -0
- package/dist/daemon/data-dir.cjs +23 -0
- package/dist/daemon/data-dir.cjs.map +1 -0
- package/dist/daemon/data-dir.d.cts +14 -0
- package/dist/daemon/data-dir.d.cts.map +1 -0
- package/dist/daemon/data-dir.d.mts +14 -0
- package/dist/daemon/data-dir.d.mts.map +1 -0
- package/dist/daemon/data-dir.mjs +19 -0
- package/dist/daemon/data-dir.mjs.map +1 -0
- package/dist/daemon/types.cjs.map +1 -1
- package/dist/daemon/types.d.cts +5 -0
- package/dist/daemon/types.d.cts.map +1 -1
- package/dist/daemon/types.d.mts +5 -0
- package/dist/daemon/types.d.mts.map +1 -1
- package/dist/daemon/types.mjs.map +1 -1
- package/dist/daemon/wallet-factory.cjs +234 -0
- package/dist/daemon/wallet-factory.cjs.map +1 -0
- package/dist/daemon/wallet-factory.d.cts +55 -0
- package/dist/daemon/wallet-factory.d.cts.map +1 -0
- package/dist/daemon/wallet-factory.d.mts +55 -0
- package/dist/daemon/wallet-factory.d.mts.map +1 -0
- package/dist/daemon/wallet-factory.mjs +230 -0
- package/dist/daemon/wallet-factory.mjs.map +1 -0
- package/dist/persistence/persistence.cjs.map +1 -1
- package/dist/persistence/persistence.d.cts +1 -1
- package/dist/persistence/persistence.d.cts.map +1 -1
- package/dist/persistence/persistence.d.mts +1 -1
- package/dist/persistence/persistence.d.mts.map +1 -1
- package/dist/persistence/persistence.mjs.map +1 -1
- package/dist/test/run-command.cjs +73 -0
- package/dist/test/run-command.cjs.map +1 -0
- package/dist/test/run-command.d.cts +27 -0
- package/dist/test/run-command.d.cts.map +1 -0
- package/dist/test/run-command.d.mts +27 -0
- package/dist/test/run-command.d.mts.map +1 -0
- package/dist/test/run-command.mjs +69 -0
- package/dist/test/run-command.mjs.map +1 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- Add the `mm daemon` command suite (`start`, `stop`, `status`, `purge`, and `call`) for running the wallet daemon and dispatching messenger actions over its socket ([#9255](https://github.com/MetaMask/core/pull/9255))
|
|
13
|
+
- Add a wallet factory and daemon entry point that construct a `@metamask/wallet` `Wallet` backed by the SQLite key-value store, hydrate it from persisted state, run controller initialization (aborting startup if any step fails), import the secret recovery phrase on first run, and expose a `dispose` teardown handle ([#9226](https://github.com/MetaMask/core/pull/9226))
|
|
12
14
|
- Add a daemon transport layer: a JSON-RPC client and server over a Unix socket, plus daemon spawn/stop lifecycle helpers ([#9108](https://github.com/MetaMask/core/pull/9108))
|
|
13
15
|
- Add SQLite-backed persistence for wallet controller state ([#9067](https://github.com/MetaMask/core/pull/9067))
|
|
14
16
|
- Initial package scaffold for `@metamask/wallet-cli`, an [oclif](https://oclif.io)-based `mm` CLI for `@metamask/wallet` ([#9065](https://github.com/MetaMask/core/pull/9065)).
|
package/README.md
CHANGED
|
@@ -10,6 +10,33 @@ or
|
|
|
10
10
|
|
|
11
11
|
`npm install @metamask/wallet-cli`
|
|
12
12
|
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
The CLI drives a long-lived background **daemon** that holds an unlocked `@metamask/wallet` in memory and exposes its messenger over a per-user Unix socket. All commands live under the `mm daemon` topic; run `mm --help` (or `mm daemon <command> --help`) for the full reference.
|
|
16
|
+
|
|
17
|
+
Start the daemon (flags may also be supplied as the `INFURA_PROJECT_ID`, `MM_WALLET_PASSWORD`, and `MM_WALLET_SRP` environment variables — preferred for secrets):
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
mm daemon start --infura-project-id <key> --password <pw> --srp "<phrase>"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Call any messenger action on the running wallet (positional JSON array for arguments, optional `--timeout`):
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
mm daemon call AccountsController:listAccounts
|
|
27
|
+
mm daemon call KeyringController:getState --timeout 10000
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Inspect or tear it down:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
mm daemon status # PID + uptime, or why the socket is unreachable
|
|
34
|
+
mm daemon stop # graceful shutdown (falls back to SIGTERM/SIGKILL)
|
|
35
|
+
mm daemon purge # stop, then delete all daemon state files (--force to skip the prompt)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
State (socket, PID file, log, and the SQLite database) lives in the per-user oclif data directory; override it with `MM_DATA_DIR`.
|
|
39
|
+
|
|
13
40
|
## Troubleshooting
|
|
14
41
|
|
|
15
42
|
### Rebuilding `better-sqlite3`
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@metamask/utils");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const daemon_client_1 = require("../../daemon/daemon-client.cjs");
|
|
6
|
+
const paths_1 = require("../../daemon/paths.cjs");
|
|
7
|
+
const utils_2 = require("../../daemon/utils.cjs");
|
|
8
|
+
class DaemonCall extends core_1.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
const { args, flags } = await this.parse(DaemonCall);
|
|
11
|
+
const { action } = args;
|
|
12
|
+
const timeoutMs = flags.timeout;
|
|
13
|
+
// The daemon's `call` RPC expects `[action, ...args]`. `JSON.parse` returns
|
|
14
|
+
// `unknown`, but anything it produces is structurally `Json`, so we cast to
|
|
15
|
+
// `Json[]` once we've confirmed the parsed payload is an array.
|
|
16
|
+
const rpcParams = [action];
|
|
17
|
+
if (args.params !== undefined) {
|
|
18
|
+
let parsed;
|
|
19
|
+
try {
|
|
20
|
+
parsed = JSON.parse(args.params);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
this.error('params must be valid JSON');
|
|
24
|
+
}
|
|
25
|
+
if (!Array.isArray(parsed)) {
|
|
26
|
+
this.error('params must be a JSON array');
|
|
27
|
+
}
|
|
28
|
+
rpcParams.push(...parsed);
|
|
29
|
+
}
|
|
30
|
+
const { socketPath } = (0, paths_1.getDaemonPaths)(this.config.dataDir);
|
|
31
|
+
let response;
|
|
32
|
+
try {
|
|
33
|
+
response = await (0, daemon_client_1.sendCommand)({
|
|
34
|
+
socketPath,
|
|
35
|
+
method: 'call',
|
|
36
|
+
params: rpcParams,
|
|
37
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if ((0, utils_2.isErrorWithCode)(error, 'ENOENT') ||
|
|
42
|
+
(0, utils_2.isErrorWithCode)(error, 'ECONNREFUSED')) {
|
|
43
|
+
this.error('Daemon is not running. Start it with `mm daemon start`.');
|
|
44
|
+
}
|
|
45
|
+
this.error(error instanceof Error ? error.message : String(error));
|
|
46
|
+
}
|
|
47
|
+
if ((0, utils_1.isJsonRpcFailure)(response)) {
|
|
48
|
+
this.error(`${response.error.message} (code ${String(response.error.code)})`);
|
|
49
|
+
}
|
|
50
|
+
const isTTY = process.stdout.isTTY ?? false;
|
|
51
|
+
if (isTTY) {
|
|
52
|
+
this.log(JSON.stringify(response.result, null, 2));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
process.stdout.write(`${JSON.stringify(response.result)}\n`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
DaemonCall.description = 'Call a messenger action on the wallet daemon';
|
|
60
|
+
DaemonCall.examples = [
|
|
61
|
+
'<%= config.bin %> daemon call KeyringController:getState',
|
|
62
|
+
'<%= config.bin %> daemon call NetworkController:getState',
|
|
63
|
+
'<%= config.bin %> daemon call ApprovalController:getState --timeout 10000',
|
|
64
|
+
];
|
|
65
|
+
DaemonCall.args = {
|
|
66
|
+
action: core_1.Args.string({
|
|
67
|
+
description: 'The messenger action name (e.g. AccountsController:listAccounts)',
|
|
68
|
+
required: true,
|
|
69
|
+
}),
|
|
70
|
+
params: core_1.Args.string({
|
|
71
|
+
description: 'JSON-encoded arguments array (e.g. \'["arg1", "arg2"]\')',
|
|
72
|
+
required: false,
|
|
73
|
+
}),
|
|
74
|
+
};
|
|
75
|
+
DaemonCall.flags = {
|
|
76
|
+
timeout: core_1.Flags.integer({
|
|
77
|
+
char: 't',
|
|
78
|
+
description: 'Response timeout in milliseconds',
|
|
79
|
+
required: false,
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
exports.default = DaemonCall;
|
|
83
|
+
//# sourceMappingURL=call.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.cjs","sourceRoot":"","sources":["../../../src/commands/daemon/call.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Json } from '@metamask/utils';\nimport { isJsonRpcFailure } from '@metamask/utils';\nimport { Args, Command, Flags } from '@oclif/core';\n\nimport { sendCommand } from '../../daemon/daemon-client';\nimport { getDaemonPaths } from '../../daemon/paths';\nimport { isErrorWithCode } from '../../daemon/utils';\n\nexport default class DaemonCall extends Command {\n static override description = 'Call a messenger action on the wallet daemon';\n\n static override examples = [\n '<%= config.bin %> daemon call KeyringController:getState',\n '<%= config.bin %> daemon call NetworkController:getState',\n '<%= config.bin %> daemon call ApprovalController:getState --timeout 10000',\n ];\n\n static override args = {\n action: Args.string({\n description:\n 'The messenger action name (e.g. AccountsController:listAccounts)',\n required: true,\n }),\n params: Args.string({\n description: 'JSON-encoded arguments array (e.g. \\'[\"arg1\", \"arg2\"]\\')',\n required: false,\n }),\n };\n\n static override flags = {\n timeout: Flags.integer({\n char: 't',\n description: 'Response timeout in milliseconds',\n required: false,\n }),\n };\n\n public async run(): Promise<void> {\n const { args, flags } = await this.parse(DaemonCall);\n const { action } = args;\n const timeoutMs = flags.timeout;\n\n // The daemon's `call` RPC expects `[action, ...args]`. `JSON.parse` returns\n // `unknown`, but anything it produces is structurally `Json`, so we cast to\n // `Json[]` once we've confirmed the parsed payload is an array.\n const rpcParams: Json[] = [action];\n if (args.params !== undefined) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(args.params);\n } catch {\n this.error('params must be valid JSON');\n }\n\n if (!Array.isArray(parsed)) {\n this.error('params must be a JSON array');\n }\n\n rpcParams.push(...(parsed as Json[]));\n }\n\n const { socketPath } = getDaemonPaths(this.config.dataDir);\n\n let response;\n try {\n response = await sendCommand({\n socketPath,\n method: 'call',\n params: rpcParams,\n ...(timeoutMs === undefined ? {} : { timeoutMs }),\n });\n } catch (error) {\n if (\n isErrorWithCode(error, 'ENOENT') ||\n isErrorWithCode(error, 'ECONNREFUSED')\n ) {\n this.error('Daemon is not running. Start it with `mm daemon start`.');\n }\n this.error(error instanceof Error ? error.message : String(error));\n }\n\n if (isJsonRpcFailure(response)) {\n this.error(\n `${response.error.message} (code ${String(response.error.code)})`,\n );\n }\n\n const isTTY = process.stdout.isTTY ?? false;\n if (isTTY) {\n this.log(JSON.stringify(response.result, null, 2));\n } else {\n process.stdout.write(`${JSON.stringify(response.result)}\\n`);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class DaemonCall extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
action: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
params: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
timeout: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=call.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.d.cts","sourceRoot":"","sources":["../../../src/commands/daemon/call.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,OAAO,EAAS,oBAAoB;AAMnD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAC7C,OAAgB,WAAW,SAAkD;IAE7E,OAAgB,QAAQ,WAItB;IAEF,OAAgB,IAAI;;;MAUlB;IAEF,OAAgB,KAAK;;MAMnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyDlC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class DaemonCall extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
action: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
params: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
timeout: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=call.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.d.mts","sourceRoot":"","sources":["../../../src/commands/daemon/call.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,OAAO,EAAS,oBAAoB;AAMnD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAC7C,OAAgB,WAAW,SAAkD;IAE7E,OAAgB,QAAQ,WAItB;IAEF,OAAgB,IAAI;;;MAUlB;IAEF,OAAgB,KAAK;;MAMnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyDlC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { isJsonRpcFailure } from "@metamask/utils";
|
|
2
|
+
import { Args, Command, Flags } from "@oclif/core";
|
|
3
|
+
import { sendCommand } from "../../daemon/daemon-client.mjs";
|
|
4
|
+
import { getDaemonPaths } from "../../daemon/paths.mjs";
|
|
5
|
+
import { isErrorWithCode } from "../../daemon/utils.mjs";
|
|
6
|
+
class DaemonCall extends Command {
|
|
7
|
+
async run() {
|
|
8
|
+
const { args, flags } = await this.parse(DaemonCall);
|
|
9
|
+
const { action } = args;
|
|
10
|
+
const timeoutMs = flags.timeout;
|
|
11
|
+
// The daemon's `call` RPC expects `[action, ...args]`. `JSON.parse` returns
|
|
12
|
+
// `unknown`, but anything it produces is structurally `Json`, so we cast to
|
|
13
|
+
// `Json[]` once we've confirmed the parsed payload is an array.
|
|
14
|
+
const rpcParams = [action];
|
|
15
|
+
if (args.params !== undefined) {
|
|
16
|
+
let parsed;
|
|
17
|
+
try {
|
|
18
|
+
parsed = JSON.parse(args.params);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
this.error('params must be valid JSON');
|
|
22
|
+
}
|
|
23
|
+
if (!Array.isArray(parsed)) {
|
|
24
|
+
this.error('params must be a JSON array');
|
|
25
|
+
}
|
|
26
|
+
rpcParams.push(...parsed);
|
|
27
|
+
}
|
|
28
|
+
const { socketPath } = getDaemonPaths(this.config.dataDir);
|
|
29
|
+
let response;
|
|
30
|
+
try {
|
|
31
|
+
response = await sendCommand({
|
|
32
|
+
socketPath,
|
|
33
|
+
method: 'call',
|
|
34
|
+
params: rpcParams,
|
|
35
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (isErrorWithCode(error, 'ENOENT') ||
|
|
40
|
+
isErrorWithCode(error, 'ECONNREFUSED')) {
|
|
41
|
+
this.error('Daemon is not running. Start it with `mm daemon start`.');
|
|
42
|
+
}
|
|
43
|
+
this.error(error instanceof Error ? error.message : String(error));
|
|
44
|
+
}
|
|
45
|
+
if (isJsonRpcFailure(response)) {
|
|
46
|
+
this.error(`${response.error.message} (code ${String(response.error.code)})`);
|
|
47
|
+
}
|
|
48
|
+
const isTTY = process.stdout.isTTY ?? false;
|
|
49
|
+
if (isTTY) {
|
|
50
|
+
this.log(JSON.stringify(response.result, null, 2));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
process.stdout.write(`${JSON.stringify(response.result)}\n`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
DaemonCall.description = 'Call a messenger action on the wallet daemon';
|
|
58
|
+
DaemonCall.examples = [
|
|
59
|
+
'<%= config.bin %> daemon call KeyringController:getState',
|
|
60
|
+
'<%= config.bin %> daemon call NetworkController:getState',
|
|
61
|
+
'<%= config.bin %> daemon call ApprovalController:getState --timeout 10000',
|
|
62
|
+
];
|
|
63
|
+
DaemonCall.args = {
|
|
64
|
+
action: Args.string({
|
|
65
|
+
description: 'The messenger action name (e.g. AccountsController:listAccounts)',
|
|
66
|
+
required: true,
|
|
67
|
+
}),
|
|
68
|
+
params: Args.string({
|
|
69
|
+
description: 'JSON-encoded arguments array (e.g. \'["arg1", "arg2"]\')',
|
|
70
|
+
required: false,
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
DaemonCall.flags = {
|
|
74
|
+
timeout: Flags.integer({
|
|
75
|
+
char: 't',
|
|
76
|
+
description: 'Response timeout in milliseconds',
|
|
77
|
+
required: false,
|
|
78
|
+
}),
|
|
79
|
+
};
|
|
80
|
+
export default DaemonCall;
|
|
81
|
+
//# sourceMappingURL=call.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.mjs","sourceRoot":"","sources":["../../../src/commands/daemon/call.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Json } from '@metamask/utils';\nimport { isJsonRpcFailure } from '@metamask/utils';\nimport { Args, Command, Flags } from '@oclif/core';\n\nimport { sendCommand } from '../../daemon/daemon-client';\nimport { getDaemonPaths } from '../../daemon/paths';\nimport { isErrorWithCode } from '../../daemon/utils';\n\nexport default class DaemonCall extends Command {\n static override description = 'Call a messenger action on the wallet daemon';\n\n static override examples = [\n '<%= config.bin %> daemon call KeyringController:getState',\n '<%= config.bin %> daemon call NetworkController:getState',\n '<%= config.bin %> daemon call ApprovalController:getState --timeout 10000',\n ];\n\n static override args = {\n action: Args.string({\n description:\n 'The messenger action name (e.g. AccountsController:listAccounts)',\n required: true,\n }),\n params: Args.string({\n description: 'JSON-encoded arguments array (e.g. \\'[\"arg1\", \"arg2\"]\\')',\n required: false,\n }),\n };\n\n static override flags = {\n timeout: Flags.integer({\n char: 't',\n description: 'Response timeout in milliseconds',\n required: false,\n }),\n };\n\n public async run(): Promise<void> {\n const { args, flags } = await this.parse(DaemonCall);\n const { action } = args;\n const timeoutMs = flags.timeout;\n\n // The daemon's `call` RPC expects `[action, ...args]`. `JSON.parse` returns\n // `unknown`, but anything it produces is structurally `Json`, so we cast to\n // `Json[]` once we've confirmed the parsed payload is an array.\n const rpcParams: Json[] = [action];\n if (args.params !== undefined) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(args.params);\n } catch {\n this.error('params must be valid JSON');\n }\n\n if (!Array.isArray(parsed)) {\n this.error('params must be a JSON array');\n }\n\n rpcParams.push(...(parsed as Json[]));\n }\n\n const { socketPath } = getDaemonPaths(this.config.dataDir);\n\n let response;\n try {\n response = await sendCommand({\n socketPath,\n method: 'call',\n params: rpcParams,\n ...(timeoutMs === undefined ? {} : { timeoutMs }),\n });\n } catch (error) {\n if (\n isErrorWithCode(error, 'ENOENT') ||\n isErrorWithCode(error, 'ECONNREFUSED')\n ) {\n this.error('Daemon is not running. Start it with `mm daemon start`.');\n }\n this.error(error instanceof Error ? error.message : String(error));\n }\n\n if (isJsonRpcFailure(response)) {\n this.error(\n `${response.error.message} (code ${String(response.error.code)})`,\n );\n }\n\n const isTTY = process.stdout.isTTY ?? false;\n if (isTTY) {\n this.log(JSON.stringify(response.result, null, 2));\n } else {\n process.stdout.write(`${JSON.stringify(response.result)}\\n`);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const daemon_client_1 = require("../../daemon/daemon-client.cjs");
|
|
6
|
+
const paths_1 = require("../../daemon/paths.cjs");
|
|
7
|
+
const prompts_1 = require("../../daemon/prompts.cjs");
|
|
8
|
+
const stop_daemon_1 = require("../../daemon/stop-daemon.cjs");
|
|
9
|
+
class DaemonPurge extends core_1.Command {
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(DaemonPurge);
|
|
12
|
+
if (!flags.force) {
|
|
13
|
+
const confirmed = await (0, prompts_1.confirmPurge)();
|
|
14
|
+
if (!confirmed) {
|
|
15
|
+
this.log('Aborted.');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const paths = (0, paths_1.getDaemonPaths)(this.config.dataDir);
|
|
20
|
+
const stopped = await (0, stop_daemon_1.stopDaemon)(paths.socketPath, paths.pidPath, (message) => this.log(message));
|
|
21
|
+
if (!stopped) {
|
|
22
|
+
// Purge is the escape hatch for a daemon that wouldn't shut down cleanly,
|
|
23
|
+
// so proceed once we've confirmed it isn't responsive — deleting state
|
|
24
|
+
// out from under a live daemon would risk corrupting it.
|
|
25
|
+
const ping = await (0, daemon_client_1.pingDaemon)(paths.socketPath);
|
|
26
|
+
if (ping.status === 'responsive') {
|
|
27
|
+
this.error('Refusing to delete state while the daemon is still responsive.');
|
|
28
|
+
}
|
|
29
|
+
this.log('Could not confirm clean shutdown; proceeding to delete state anyway.');
|
|
30
|
+
}
|
|
31
|
+
// Whitelist only the daemon-owned files rather than rm'ing the entire
|
|
32
|
+
// oclif dataDir, which may hold unrelated state (caches, oclif lock
|
|
33
|
+
// files, future config). `force: true` makes ENOENT a no-op for any
|
|
34
|
+
// file already removed by stopDaemon.
|
|
35
|
+
await Promise.all([
|
|
36
|
+
paths.pidPath,
|
|
37
|
+
paths.socketPath,
|
|
38
|
+
paths.logPath,
|
|
39
|
+
paths.dbPath,
|
|
40
|
+
`${paths.dbPath}-wal`,
|
|
41
|
+
`${paths.dbPath}-shm`,
|
|
42
|
+
].map(async (path) => (0, promises_1.rm)(path, { force: true })));
|
|
43
|
+
this.log('All daemon state deleted.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
DaemonPurge.description = 'Stop the daemon and delete all daemon state files';
|
|
47
|
+
DaemonPurge.examples = [
|
|
48
|
+
'<%= config.bin %> daemon purge',
|
|
49
|
+
'<%= config.bin %> daemon purge --force',
|
|
50
|
+
];
|
|
51
|
+
DaemonPurge.flags = {
|
|
52
|
+
force: core_1.Flags.boolean({
|
|
53
|
+
char: 'f',
|
|
54
|
+
description: 'Skip confirmation prompt',
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
exports.default = DaemonPurge;
|
|
58
|
+
//# sourceMappingURL=purge.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purge.cjs","sourceRoot":"","sources":["../../../src/commands/daemon/purge.ts"],"names":[],"mappings":";;AAAA,sCAA6C;AAC7C,+CAAsC;AAEtC,kEAAwD;AACxD,kDAAoD;AACpD,sDAAoD;AACpD,8DAAsD;AAEtD,MAAqB,WAAY,SAAQ,cAAO;IAgBvC,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAEhD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,IAAA,sBAAY,GAAE,CAAC;YACvC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACrB,OAAO;YACT,CAAC;QACH,CAAC;QAED,MAAM,KAAK,GAAG,IAAA,sBAAc,EAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAElD,MAAM,OAAO,GAAG,MAAM,IAAA,wBAAU,EAC9B,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,OAAO,EACb,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAC/B,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,0EAA0E;YAC1E,uEAAuE;YACvE,yDAAyD;YACzD,MAAM,IAAI,GAAG,MAAM,IAAA,0BAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAChD,IAAI,IAAI,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;gBACjC,IAAI,CAAC,KAAK,CACR,gEAAgE,CACjE,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,GAAG,CACN,sEAAsE,CACvE,CAAC;QACJ,CAAC;QAED,sEAAsE;QACtE,oEAAoE;QACpE,oEAAoE;QACpE,sCAAsC;QACtC,MAAM,OAAO,CAAC,GAAG,CACf;YACE,KAAK,CAAC,OAAO;YACb,KAAK,CAAC,UAAU;YAChB,KAAK,CAAC,OAAO;YACb,KAAK,CAAC,MAAM;YACZ,GAAG,KAAK,CAAC,MAAM,MAAM;YACrB,GAAG,KAAK,CAAC,MAAM,MAAM;SACtB,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAA,aAAE,EAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CACjD,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACxC,CAAC;;AAjEe,uBAAW,GACzB,mDAAmD,CAAC;AAEtC,oBAAQ,GAAG;IACzB,gCAAgC;IAChC,wCAAwC;CACzC,CAAC;AAEc,iBAAK,GAAG;IACtB,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC;QACnB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,0BAA0B;KACxC,CAAC;CACH,CAAC;kBAdiB,WAAW","sourcesContent":["import { Command, Flags } from '@oclif/core';\nimport { rm } from 'node:fs/promises';\n\nimport { pingDaemon } from '../../daemon/daemon-client';\nimport { getDaemonPaths } from '../../daemon/paths';\nimport { confirmPurge } from '../../daemon/prompts';\nimport { stopDaemon } from '../../daemon/stop-daemon';\n\nexport default class DaemonPurge extends Command {\n static override description =\n 'Stop the daemon and delete all daemon state files';\n\n static override examples = [\n '<%= config.bin %> daemon purge',\n '<%= config.bin %> daemon purge --force',\n ];\n\n static override flags = {\n force: Flags.boolean({\n char: 'f',\n description: 'Skip confirmation prompt',\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(DaemonPurge);\n\n if (!flags.force) {\n const confirmed = await confirmPurge();\n if (!confirmed) {\n this.log('Aborted.');\n return;\n }\n }\n\n const paths = getDaemonPaths(this.config.dataDir);\n\n const stopped = await stopDaemon(\n paths.socketPath,\n paths.pidPath,\n (message) => this.log(message),\n );\n\n if (!stopped) {\n // Purge is the escape hatch for a daemon that wouldn't shut down cleanly,\n // so proceed once we've confirmed it isn't responsive — deleting state\n // out from under a live daemon would risk corrupting it.\n const ping = await pingDaemon(paths.socketPath);\n if (ping.status === 'responsive') {\n this.error(\n 'Refusing to delete state while the daemon is still responsive.',\n );\n }\n this.log(\n 'Could not confirm clean shutdown; proceeding to delete state anyway.',\n );\n }\n\n // Whitelist only the daemon-owned files rather than rm'ing the entire\n // oclif dataDir, which may hold unrelated state (caches, oclif lock\n // files, future config). `force: true` makes ENOENT a no-op for any\n // file already removed by stopDaemon.\n await Promise.all(\n [\n paths.pidPath,\n paths.socketPath,\n paths.logPath,\n paths.dbPath,\n `${paths.dbPath}-wal`,\n `${paths.dbPath}-shm`,\n ].map(async (path) => rm(path, { force: true })),\n );\n\n this.log('All daemon state deleted.');\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class DaemonPurge extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=purge.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purge.d.cts","sourceRoot":"","sources":["../../../src/commands/daemon/purge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,oBAAoB;AAQ7C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;IAC9C,OAAgB,WAAW,SAC2B;IAEtD,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,KAAK;;MAKnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmDlC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class DaemonPurge extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=purge.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purge.d.mts","sourceRoot":"","sources":["../../../src/commands/daemon/purge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,oBAAoB;AAQ7C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;IAC9C,OAAgB,WAAW,SAC2B;IAEtD,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,KAAK;;MAKnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmDlC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { pingDaemon } from "../../daemon/daemon-client.mjs";
|
|
4
|
+
import { getDaemonPaths } from "../../daemon/paths.mjs";
|
|
5
|
+
import { confirmPurge } from "../../daemon/prompts.mjs";
|
|
6
|
+
import { stopDaemon } from "../../daemon/stop-daemon.mjs";
|
|
7
|
+
class DaemonPurge extends Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const { flags } = await this.parse(DaemonPurge);
|
|
10
|
+
if (!flags.force) {
|
|
11
|
+
const confirmed = await confirmPurge();
|
|
12
|
+
if (!confirmed) {
|
|
13
|
+
this.log('Aborted.');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const paths = getDaemonPaths(this.config.dataDir);
|
|
18
|
+
const stopped = await stopDaemon(paths.socketPath, paths.pidPath, (message) => this.log(message));
|
|
19
|
+
if (!stopped) {
|
|
20
|
+
// Purge is the escape hatch for a daemon that wouldn't shut down cleanly,
|
|
21
|
+
// so proceed once we've confirmed it isn't responsive — deleting state
|
|
22
|
+
// out from under a live daemon would risk corrupting it.
|
|
23
|
+
const ping = await pingDaemon(paths.socketPath);
|
|
24
|
+
if (ping.status === 'responsive') {
|
|
25
|
+
this.error('Refusing to delete state while the daemon is still responsive.');
|
|
26
|
+
}
|
|
27
|
+
this.log('Could not confirm clean shutdown; proceeding to delete state anyway.');
|
|
28
|
+
}
|
|
29
|
+
// Whitelist only the daemon-owned files rather than rm'ing the entire
|
|
30
|
+
// oclif dataDir, which may hold unrelated state (caches, oclif lock
|
|
31
|
+
// files, future config). `force: true` makes ENOENT a no-op for any
|
|
32
|
+
// file already removed by stopDaemon.
|
|
33
|
+
await Promise.all([
|
|
34
|
+
paths.pidPath,
|
|
35
|
+
paths.socketPath,
|
|
36
|
+
paths.logPath,
|
|
37
|
+
paths.dbPath,
|
|
38
|
+
`${paths.dbPath}-wal`,
|
|
39
|
+
`${paths.dbPath}-shm`,
|
|
40
|
+
].map(async (path) => rm(path, { force: true })));
|
|
41
|
+
this.log('All daemon state deleted.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
DaemonPurge.description = 'Stop the daemon and delete all daemon state files';
|
|
45
|
+
DaemonPurge.examples = [
|
|
46
|
+
'<%= config.bin %> daemon purge',
|
|
47
|
+
'<%= config.bin %> daemon purge --force',
|
|
48
|
+
];
|
|
49
|
+
DaemonPurge.flags = {
|
|
50
|
+
force: Flags.boolean({
|
|
51
|
+
char: 'f',
|
|
52
|
+
description: 'Skip confirmation prompt',
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
export default DaemonPurge;
|
|
56
|
+
//# sourceMappingURL=purge.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purge.mjs","sourceRoot":"","sources":["../../../src/commands/daemon/purge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB;AAC7C,OAAO,EAAE,EAAE,EAAE,yBAAyB;AAEtC,OAAO,EAAE,UAAU,EAAE,uCAAmC;AACxD,OAAO,EAAE,cAAc,EAAE,+BAA2B;AACpD,OAAO,EAAE,YAAY,EAAE,iCAA6B;AACpD,OAAO,EAAE,UAAU,EAAE,qCAAiC;AAEtD,MAAqB,WAAY,SAAQ,OAAO;IAgBvC,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAEhD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,YAAY,EAAE,CAAC;YACvC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACrB,OAAO;YACT,CAAC;QACH,CAAC;QAED,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAElD,MAAM,OAAO,GAAG,MAAM,UAAU,CAC9B,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,OAAO,EACb,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAC/B,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,0EAA0E;YAC1E,uEAAuE;YACvE,yDAAyD;YACzD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAChD,IAAI,IAAI,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;gBACjC,IAAI,CAAC,KAAK,CACR,gEAAgE,CACjE,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,GAAG,CACN,sEAAsE,CACvE,CAAC;QACJ,CAAC;QAED,sEAAsE;QACtE,oEAAoE;QACpE,oEAAoE;QACpE,sCAAsC;QACtC,MAAM,OAAO,CAAC,GAAG,CACf;YACE,KAAK,CAAC,OAAO;YACb,KAAK,CAAC,UAAU;YAChB,KAAK,CAAC,OAAO;YACb,KAAK,CAAC,MAAM;YACZ,GAAG,KAAK,CAAC,MAAM,MAAM;YACrB,GAAG,KAAK,CAAC,MAAM,MAAM;SACtB,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CACjD,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACxC,CAAC;;AAjEe,uBAAW,GACzB,mDAAmD,CAAC;AAEtC,oBAAQ,GAAG;IACzB,gCAAgC;IAChC,wCAAwC;CACzC,CAAC;AAEc,iBAAK,GAAG;IACtB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACnB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,0BAA0B;KACxC,CAAC;CACH,CAAC;eAdiB,WAAW","sourcesContent":["import { Command, Flags } from '@oclif/core';\nimport { rm } from 'node:fs/promises';\n\nimport { pingDaemon } from '../../daemon/daemon-client';\nimport { getDaemonPaths } from '../../daemon/paths';\nimport { confirmPurge } from '../../daemon/prompts';\nimport { stopDaemon } from '../../daemon/stop-daemon';\n\nexport default class DaemonPurge extends Command {\n static override description =\n 'Stop the daemon and delete all daemon state files';\n\n static override examples = [\n '<%= config.bin %> daemon purge',\n '<%= config.bin %> daemon purge --force',\n ];\n\n static override flags = {\n force: Flags.boolean({\n char: 'f',\n description: 'Skip confirmation prompt',\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(DaemonPurge);\n\n if (!flags.force) {\n const confirmed = await confirmPurge();\n if (!confirmed) {\n this.log('Aborted.');\n return;\n }\n }\n\n const paths = getDaemonPaths(this.config.dataDir);\n\n const stopped = await stopDaemon(\n paths.socketPath,\n paths.pidPath,\n (message) => this.log(message),\n );\n\n if (!stopped) {\n // Purge is the escape hatch for a daemon that wouldn't shut down cleanly,\n // so proceed once we've confirmed it isn't responsive — deleting state\n // out from under a live daemon would risk corrupting it.\n const ping = await pingDaemon(paths.socketPath);\n if (ping.status === 'responsive') {\n this.error(\n 'Refusing to delete state while the daemon is still responsive.',\n );\n }\n this.log(\n 'Could not confirm clean shutdown; proceeding to delete state anyway.',\n );\n }\n\n // Whitelist only the daemon-owned files rather than rm'ing the entire\n // oclif dataDir, which may hold unrelated state (caches, oclif lock\n // files, future config). `force: true` makes ENOENT a no-op for any\n // file already removed by stopDaemon.\n await Promise.all(\n [\n paths.pidPath,\n paths.socketPath,\n paths.logPath,\n paths.dbPath,\n `${paths.dbPath}-wal`,\n `${paths.dbPath}-shm`,\n ].map(async (path) => rm(path, { force: true })),\n );\n\n this.log('All daemon state deleted.');\n }\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const daemon_spawn_1 = require("../../daemon/daemon-spawn.cjs");
|
|
5
|
+
class DaemonStart extends core_1.Command {
|
|
6
|
+
async run() {
|
|
7
|
+
const { flags } = await this.parse(DaemonStart);
|
|
8
|
+
const infuraProjectId = flags['infura-project-id'];
|
|
9
|
+
const { password, srp } = flags;
|
|
10
|
+
const { state, socketPath } = await (0, daemon_spawn_1.ensureDaemon)({
|
|
11
|
+
dataDir: this.config.dataDir,
|
|
12
|
+
infuraProjectId,
|
|
13
|
+
password,
|
|
14
|
+
srp,
|
|
15
|
+
packageRoot: this.config.root,
|
|
16
|
+
});
|
|
17
|
+
if (state === 'already-running') {
|
|
18
|
+
this.log(`Daemon already running. Socket: ${socketPath}. ` +
|
|
19
|
+
`The provided flags were not applied; run \`mm daemon stop\` and start again to change them.`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
this.log(`Daemon running. Socket: ${socketPath}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
DaemonStart.description = 'Start the wallet daemon';
|
|
26
|
+
DaemonStart.examples = [
|
|
27
|
+
'<%= config.bin %> daemon start --infura-project-id <key> --password <pw> --srp <phrase>',
|
|
28
|
+
'INFURA_PROJECT_ID=<key> MM_WALLET_PASSWORD=<pw> MM_WALLET_SRP=<phrase> <%= config.bin %> daemon start',
|
|
29
|
+
];
|
|
30
|
+
DaemonStart.flags = {
|
|
31
|
+
'infura-project-id': core_1.Flags.string({
|
|
32
|
+
description: 'Infura project ID for network access',
|
|
33
|
+
env: 'INFURA_PROJECT_ID',
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
password: core_1.Flags.string({
|
|
37
|
+
description: 'Wallet password (testing only — use MM_WALLET_PASSWORD env var in production)',
|
|
38
|
+
env: 'MM_WALLET_PASSWORD',
|
|
39
|
+
required: true,
|
|
40
|
+
}),
|
|
41
|
+
srp: core_1.Flags.string({
|
|
42
|
+
description: 'Secret recovery phrase (testing only — use MM_WALLET_SRP env var in production)',
|
|
43
|
+
env: 'MM_WALLET_SRP',
|
|
44
|
+
required: true,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
exports.default = DaemonStart;
|
|
48
|
+
//# sourceMappingURL=start.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.cjs","sourceRoot":"","sources":["../../../src/commands/daemon/start.ts"],"names":[],"mappings":";;AAAA,sCAA6C;AAE7C,gEAAyD;AAEzD,MAAqB,WAAY,SAAQ,cAAO;IA4BvC,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAChD,MAAM,eAAe,GAAG,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACnD,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;QAEhC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,2BAAY,EAAC;YAC/C,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,eAAe;YACf,QAAQ;YACR,GAAG;YACH,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;SAC9B,CAAC,CAAC;QAEH,IAAI,KAAK,KAAK,iBAAiB,EAAE,CAAC;YAChC,IAAI,CAAC,GAAG,CACN,mCAAmC,UAAU,IAAI;gBAC/C,6FAA6F,CAChG,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;IACpD,CAAC;;AAjDe,uBAAW,GAAG,yBAAyB,CAAC;AAExC,oBAAQ,GAAG;IACzB,yFAAyF;IACzF,uGAAuG;CACxG,CAAC;AAEc,iBAAK,GAAG;IACtB,mBAAmB,EAAE,YAAK,CAAC,MAAM,CAAC;QAChC,WAAW,EAAE,sCAAsC;QACnD,GAAG,EAAE,mBAAmB;QACxB,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,QAAQ,EAAE,YAAK,CAAC,MAAM,CAAC;QACrB,WAAW,EACT,+EAA+E;QACjF,GAAG,EAAE,oBAAoB;QACzB,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,GAAG,EAAE,YAAK,CAAC,MAAM,CAAC;QAChB,WAAW,EACT,iFAAiF;QACnF,GAAG,EAAE,eAAe;QACpB,QAAQ,EAAE,IAAI;KACf,CAAC;CACH,CAAC;kBA1BiB,WAAW","sourcesContent":["import { Command, Flags } from '@oclif/core';\n\nimport { ensureDaemon } from '../../daemon/daemon-spawn';\n\nexport default class DaemonStart extends Command {\n static override description = 'Start the wallet daemon';\n\n static override examples = [\n '<%= config.bin %> daemon start --infura-project-id <key> --password <pw> --srp <phrase>',\n 'INFURA_PROJECT_ID=<key> MM_WALLET_PASSWORD=<pw> MM_WALLET_SRP=<phrase> <%= config.bin %> daemon start',\n ];\n\n static override flags = {\n 'infura-project-id': Flags.string({\n description: 'Infura project ID for network access',\n env: 'INFURA_PROJECT_ID',\n required: true,\n }),\n password: Flags.string({\n description:\n 'Wallet password (testing only — use MM_WALLET_PASSWORD env var in production)',\n env: 'MM_WALLET_PASSWORD',\n required: true,\n }),\n srp: Flags.string({\n description:\n 'Secret recovery phrase (testing only — use MM_WALLET_SRP env var in production)',\n env: 'MM_WALLET_SRP',\n required: true,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(DaemonStart);\n const infuraProjectId = flags['infura-project-id'];\n const { password, srp } = flags;\n\n const { state, socketPath } = await ensureDaemon({\n dataDir: this.config.dataDir,\n infuraProjectId,\n password,\n srp,\n packageRoot: this.config.root,\n });\n\n if (state === 'already-running') {\n this.log(\n `Daemon already running. Socket: ${socketPath}. ` +\n `The provided flags were not applied; run \\`mm daemon stop\\` and start again to change them.`,\n );\n return;\n }\n\n this.log(`Daemon running. Socket: ${socketPath}`);\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class DaemonStart extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
'infura-project-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
password: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
srp: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=start.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.cts","sourceRoot":"","sources":["../../../src/commands/daemon/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,oBAAoB;AAI7C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;IAC9C,OAAgB,WAAW,SAA6B;IAExD,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,KAAK;;;;MAkBnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAuBlC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class DaemonStart extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
'infura-project-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
password: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
srp: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=start.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.mts","sourceRoot":"","sources":["../../../src/commands/daemon/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,oBAAoB;AAI7C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;IAC9C,OAAgB,WAAW,SAA6B;IAExD,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,KAAK;;;;MAkBnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAuBlC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { ensureDaemon } from "../../daemon/daemon-spawn.mjs";
|
|
3
|
+
class DaemonStart extends Command {
|
|
4
|
+
async run() {
|
|
5
|
+
const { flags } = await this.parse(DaemonStart);
|
|
6
|
+
const infuraProjectId = flags['infura-project-id'];
|
|
7
|
+
const { password, srp } = flags;
|
|
8
|
+
const { state, socketPath } = await ensureDaemon({
|
|
9
|
+
dataDir: this.config.dataDir,
|
|
10
|
+
infuraProjectId,
|
|
11
|
+
password,
|
|
12
|
+
srp,
|
|
13
|
+
packageRoot: this.config.root,
|
|
14
|
+
});
|
|
15
|
+
if (state === 'already-running') {
|
|
16
|
+
this.log(`Daemon already running. Socket: ${socketPath}. ` +
|
|
17
|
+
`The provided flags were not applied; run \`mm daemon stop\` and start again to change them.`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.log(`Daemon running. Socket: ${socketPath}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
DaemonStart.description = 'Start the wallet daemon';
|
|
24
|
+
DaemonStart.examples = [
|
|
25
|
+
'<%= config.bin %> daemon start --infura-project-id <key> --password <pw> --srp <phrase>',
|
|
26
|
+
'INFURA_PROJECT_ID=<key> MM_WALLET_PASSWORD=<pw> MM_WALLET_SRP=<phrase> <%= config.bin %> daemon start',
|
|
27
|
+
];
|
|
28
|
+
DaemonStart.flags = {
|
|
29
|
+
'infura-project-id': Flags.string({
|
|
30
|
+
description: 'Infura project ID for network access',
|
|
31
|
+
env: 'INFURA_PROJECT_ID',
|
|
32
|
+
required: true,
|
|
33
|
+
}),
|
|
34
|
+
password: Flags.string({
|
|
35
|
+
description: 'Wallet password (testing only — use MM_WALLET_PASSWORD env var in production)',
|
|
36
|
+
env: 'MM_WALLET_PASSWORD',
|
|
37
|
+
required: true,
|
|
38
|
+
}),
|
|
39
|
+
srp: Flags.string({
|
|
40
|
+
description: 'Secret recovery phrase (testing only — use MM_WALLET_SRP env var in production)',
|
|
41
|
+
env: 'MM_WALLET_SRP',
|
|
42
|
+
required: true,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
export default DaemonStart;
|
|
46
|
+
//# sourceMappingURL=start.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.mjs","sourceRoot":"","sources":["../../../src/commands/daemon/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB;AAE7C,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAEzD,MAAqB,WAAY,SAAQ,OAAO;IA4BvC,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAChD,MAAM,eAAe,GAAG,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACnD,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;QAEhC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,YAAY,CAAC;YAC/C,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,eAAe;YACf,QAAQ;YACR,GAAG;YACH,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;SAC9B,CAAC,CAAC;QAEH,IAAI,KAAK,KAAK,iBAAiB,EAAE,CAAC;YAChC,IAAI,CAAC,GAAG,CACN,mCAAmC,UAAU,IAAI;gBAC/C,6FAA6F,CAChG,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;IACpD,CAAC;;AAjDe,uBAAW,GAAG,yBAAyB,CAAC;AAExC,oBAAQ,GAAG;IACzB,yFAAyF;IACzF,uGAAuG;CACxG,CAAC;AAEc,iBAAK,GAAG;IACtB,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC;QAChC,WAAW,EAAE,sCAAsC;QACnD,GAAG,EAAE,mBAAmB;QACxB,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC;QACrB,WAAW,EACT,+EAA+E;QACjF,GAAG,EAAE,oBAAoB;QACzB,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC;QAChB,WAAW,EACT,iFAAiF;QACnF,GAAG,EAAE,eAAe;QACpB,QAAQ,EAAE,IAAI;KACf,CAAC;CACH,CAAC;eA1BiB,WAAW","sourcesContent":["import { Command, Flags } from '@oclif/core';\n\nimport { ensureDaemon } from '../../daemon/daemon-spawn';\n\nexport default class DaemonStart extends Command {\n static override description = 'Start the wallet daemon';\n\n static override examples = [\n '<%= config.bin %> daemon start --infura-project-id <key> --password <pw> --srp <phrase>',\n 'INFURA_PROJECT_ID=<key> MM_WALLET_PASSWORD=<pw> MM_WALLET_SRP=<phrase> <%= config.bin %> daemon start',\n ];\n\n static override flags = {\n 'infura-project-id': Flags.string({\n description: 'Infura project ID for network access',\n env: 'INFURA_PROJECT_ID',\n required: true,\n }),\n password: Flags.string({\n description:\n 'Wallet password (testing only — use MM_WALLET_PASSWORD env var in production)',\n env: 'MM_WALLET_PASSWORD',\n required: true,\n }),\n srp: Flags.string({\n description:\n 'Secret recovery phrase (testing only — use MM_WALLET_SRP env var in production)',\n env: 'MM_WALLET_SRP',\n required: true,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(DaemonStart);\n const infuraProjectId = flags['infura-project-id'];\n const { password, srp } = flags;\n\n const { state, socketPath } = await ensureDaemon({\n dataDir: this.config.dataDir,\n infuraProjectId,\n password,\n srp,\n packageRoot: this.config.root,\n });\n\n if (state === 'already-running') {\n this.log(\n `Daemon already running. Socket: ${socketPath}. ` +\n `The provided flags were not applied; run \\`mm daemon stop\\` and start again to change them.`,\n );\n return;\n }\n\n this.log(`Daemon running. Socket: ${socketPath}`);\n }\n}\n"]}
|