-
-
Notifications
You must be signed in to change notification settings - Fork 280
Expand file tree
/
Copy pathstart.ts
More file actions
58 lines (50 loc) · 1.79 KB
/
start.ts
File metadata and controls
58 lines (50 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Command, Flags } from '@oclif/core';
import { ensureDaemon } from '../../daemon/daemon-spawn';
import { Password, Srp } from '../../daemon/secrets';
export default class DaemonStart extends Command {
static override description = 'Start the wallet daemon';
static override examples = [
'<%= config.bin %> daemon start --infura-project-id <key> --password <pw> --srp <phrase>',
'INFURA_PROJECT_ID=<key> MM_WALLET_PASSWORD=<pw> MM_WALLET_SRP=<phrase> <%= config.bin %> daemon start',
];
static override flags = {
'infura-project-id': Flags.string({
description: 'Infura project ID for network access',
env: 'INFURA_PROJECT_ID',
required: true,
}),
password: Flags.string({
description:
'Wallet password (testing only — use MM_WALLET_PASSWORD env var in production)',
env: 'MM_WALLET_PASSWORD',
required: true,
}),
srp: Flags.string({
description:
'Secret recovery phrase (testing only — use MM_WALLET_SRP env var in production)',
env: 'MM_WALLET_SRP',
required: true,
}),
};
public async run(): Promise<void> {
const { flags } = await this.parse(DaemonStart);
const infuraProjectId = flags['infura-project-id'];
const password = Password.from(flags.password);
const srp = Srp.from(flags.srp);
const { state, socketPath } = await ensureDaemon({
dataDir: this.config.dataDir,
infuraProjectId,
password,
srp,
packageRoot: this.config.root,
});
if (state === 'already-running') {
this.log(
`Daemon already running. Socket: ${socketPath}. ` +
`The provided flags were not applied; run \`mm daemon stop\` and start again to change them.`,
);
return;
}
this.log(`Daemon running. Socket: ${socketPath}`);
}
}