@aaronbassett/midnight-local-devnet 0.5.0 → 0.6.0
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/README.md +29 -0
- package/dist/cli/commands/accounts.js +40 -23
- package/dist/cli/commands/accounts.js.map +1 -1
- package/dist/cli/commands/network.js +112 -42
- package/dist/cli/commands/network.js.map +1 -1
- package/dist/cli/commands/wallet.js +72 -29
- package/dist/cli/commands/wallet.js.map +1 -1
- package/dist/cli/output.d.ts +5 -0
- package/dist/cli/output.js +22 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/core/health.js +4 -1
- package/dist/core/health.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,18 @@ The MCP server communicates over stdio and exposes tools and resources that an A
|
|
|
46
46
|
|
|
47
47
|
All commands can be run via `npx @aaronbassett/midnight-local-devnet <command>`.
|
|
48
48
|
|
|
49
|
+
### Global Options
|
|
50
|
+
|
|
51
|
+
| Option | Description |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `--json` | Output results as machine-parseable JSON on stdout |
|
|
54
|
+
| `--version` | Show version number |
|
|
55
|
+
| `--help` | Show help |
|
|
56
|
+
|
|
57
|
+
When `--json` is active, only valid JSON is written to stdout. All progress messages and logs are redirected to stderr so the output can be piped directly to tools like `jq`.
|
|
58
|
+
|
|
59
|
+
### Commands
|
|
60
|
+
|
|
49
61
|
| Command | Description | Options |
|
|
50
62
|
|---|---|---|
|
|
51
63
|
| `start` | Start the local Midnight devnet | `--pull` Pull latest Docker images |
|
|
@@ -63,6 +75,23 @@ All commands can be run via `npx @aaronbassett/midnight-local-devnet <command>`.
|
|
|
63
75
|
|
|
64
76
|
Running with no arguments displays help.
|
|
65
77
|
|
|
78
|
+
### JSON Output
|
|
79
|
+
|
|
80
|
+
Use the `--json` flag for scripting and automation:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Get network status as JSON
|
|
84
|
+
npx @aaronbassett/midnight-local-devnet status --json
|
|
85
|
+
|
|
86
|
+
# Pipe to jq for filtering
|
|
87
|
+
npx @aaronbassett/midnight-local-devnet health --json | jq '.allHealthy'
|
|
88
|
+
|
|
89
|
+
# Generate accounts and capture output
|
|
90
|
+
npx @aaronbassett/midnight-local-devnet generate-accounts --count 3 --json > accounts.json
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Errors in `--json` mode produce `{"error": "message"}` on stdout with a non-zero exit code.
|
|
94
|
+
|
|
66
95
|
## Dashboard
|
|
67
96
|
|
|
68
97
|
The `dashboard` command starts a local server and opens a browser-based dashboard that displays the state of all local devnet services in real time.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { generateAccounts, generateAndFundAccounts, writeAccountsFile } from '../../core/accounts.js';
|
|
2
|
+
import { output, outputError } from '../output.js';
|
|
2
3
|
export function registerAccountCommands(program, manager) {
|
|
3
4
|
program
|
|
4
5
|
.command('generate-accounts')
|
|
@@ -8,31 +9,47 @@ export function registerAccountCommands(program, manager) {
|
|
|
8
9
|
.option('--output <path>', 'Write to file in accounts.json format')
|
|
9
10
|
.option('--fund', 'Fund accounts from master wallet')
|
|
10
11
|
.option('--register-dust', 'Register DUST for funded accounts')
|
|
11
|
-
.action(async (opts)
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
.action(async function (opts) {
|
|
13
|
+
const globals = this.optsWithGlobals();
|
|
14
|
+
try {
|
|
15
|
+
const format = opts.format;
|
|
16
|
+
const count = parseInt(opts.count, 10);
|
|
17
|
+
let accounts;
|
|
18
|
+
if (opts.fund) {
|
|
19
|
+
const wallet = await manager.ensureWallet();
|
|
20
|
+
accounts = await generateAndFundAccounts(wallet, manager.config, {
|
|
21
|
+
format,
|
|
22
|
+
count,
|
|
23
|
+
fund: true,
|
|
24
|
+
registerDust: opts.registerDust ?? false,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
accounts = await generateAccounts({ format, count });
|
|
29
|
+
}
|
|
30
|
+
if (opts.output) {
|
|
31
|
+
await writeAccountsFile(opts.output, accounts);
|
|
32
|
+
if (!globals.json)
|
|
33
|
+
console.log(`Accounts written to ${opts.output}`);
|
|
34
|
+
}
|
|
35
|
+
if (globals.json) {
|
|
36
|
+
output(accounts.map((a) => ({
|
|
37
|
+
name: a.name,
|
|
38
|
+
address: a.address || null,
|
|
39
|
+
...(a.mnemonic ? { mnemonic: a.mnemonic } : {}),
|
|
40
|
+
})), globals);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.table(accounts.map((a) => ({
|
|
44
|
+
Name: a.name,
|
|
45
|
+
Address: a.address || '(generated on fund)',
|
|
46
|
+
...(a.mnemonic ? { Mnemonic: a.mnemonic.split(' ').slice(0, 3).join(' ') + '...' } : {}),
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
23
49
|
}
|
|
24
|
-
|
|
25
|
-
|
|
50
|
+
catch (err) {
|
|
51
|
+
outputError(err, globals);
|
|
26
52
|
}
|
|
27
|
-
if (opts.output) {
|
|
28
|
-
await writeAccountsFile(opts.output, accounts);
|
|
29
|
-
console.log(`Accounts written to ${opts.output}`);
|
|
30
|
-
}
|
|
31
|
-
console.table(accounts.map((a) => ({
|
|
32
|
-
Name: a.name,
|
|
33
|
-
Address: a.address || '(generated on fund)',
|
|
34
|
-
...(a.mnemonic ? { Mnemonic: a.mnemonic.split(' ').slice(0, 3).join(' ') + '...' } : {}),
|
|
35
|
-
})));
|
|
36
53
|
});
|
|
37
54
|
}
|
|
38
55
|
//# sourceMappingURL=accounts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/cli/commands/accounts.ts"],"names":[],"mappings":"AA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AC,CAAC,CAAC,CAAC;YACP,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,60 +1,108 @@
|
|
|
1
1
|
import { checkAllHealth } from '../../core/health.js';
|
|
2
|
+
import { output, outputError } from '../output.js';
|
|
3
|
+
import { parseLogLines } from '../dashboard/lib/log-parser.js';
|
|
2
4
|
export function registerNetworkCommands(program, manager) {
|
|
3
5
|
program
|
|
4
6
|
.command('start')
|
|
5
7
|
.description('Start the local Midnight development network')
|
|
6
8
|
.option('--pull', 'Pull latest Docker images before starting')
|
|
7
|
-
.action(async (opts)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
.action(async function (opts) {
|
|
10
|
+
const globals = this.optsWithGlobals();
|
|
11
|
+
try {
|
|
12
|
+
if (!globals.json)
|
|
13
|
+
console.log('Starting Midnight local devnet...');
|
|
14
|
+
const result = await manager.start({ pull: opts.pull ?? false });
|
|
15
|
+
const status = result === 'already-running' ? 'already-running' : 'started';
|
|
16
|
+
if (!globals.json) {
|
|
17
|
+
console.log(result === 'already-running' ? 'Network is already running.' : 'Network is ready.');
|
|
18
|
+
}
|
|
19
|
+
const services = await manager.getServices();
|
|
20
|
+
if (globals.json) {
|
|
21
|
+
output({ status, services: services.map((s) => ({ name: s.name, port: s.port, url: s.url, status: s.status })) }, globals);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
console.table(services.map((s) => ({ Service: s.name, Port: s.port, URL: s.url, Status: s.status })));
|
|
25
|
+
}
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
catch (err) {
|
|
28
|
+
outputError(err, globals);
|
|
15
29
|
}
|
|
16
|
-
const services = await manager.getServices();
|
|
17
|
-
console.table(services.map((s) => ({ Service: s.name, Port: s.port, URL: s.url, Status: s.status })));
|
|
18
30
|
});
|
|
19
31
|
program
|
|
20
32
|
.command('stop')
|
|
21
33
|
.description('Stop the local Midnight development network')
|
|
22
34
|
.option('--remove-volumes', 'Remove volumes and containers')
|
|
23
|
-
.action(async (opts)
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
.action(async function (opts) {
|
|
36
|
+
const globals = this.optsWithGlobals();
|
|
37
|
+
try {
|
|
38
|
+
await manager.stop({ removeVolumes: opts.removeVolumes ?? false });
|
|
39
|
+
if (globals.json) {
|
|
40
|
+
output({ status: 'stopped' }, globals);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.log('Network stopped.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
outputError(err, globals);
|
|
48
|
+
}
|
|
26
49
|
});
|
|
27
50
|
program
|
|
28
51
|
.command('restart')
|
|
29
52
|
.description('Restart the network')
|
|
30
53
|
.option('--pull', 'Pull latest Docker images')
|
|
31
54
|
.option('--remove-volumes', 'Remove volumes for clean restart')
|
|
32
|
-
.action(async (opts)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
.action(async function (opts) {
|
|
56
|
+
const globals = this.optsWithGlobals();
|
|
57
|
+
try {
|
|
58
|
+
await manager.restart({
|
|
59
|
+
pull: opts.pull ?? false,
|
|
60
|
+
removeVolumes: opts.removeVolumes ?? false,
|
|
61
|
+
});
|
|
62
|
+
if (globals.json) {
|
|
63
|
+
output({ status: 'restarted' }, globals);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.log('Network restarted and ready.');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
outputError(err, globals);
|
|
71
|
+
}
|
|
38
72
|
});
|
|
39
73
|
program
|
|
40
74
|
.command('status')
|
|
41
75
|
.description('Show network status')
|
|
42
|
-
.action(async ()
|
|
76
|
+
.action(async function () {
|
|
77
|
+
const globals = this.optsWithGlobals();
|
|
43
78
|
try {
|
|
44
79
|
const services = await manager.getServices();
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
80
|
+
if (globals.json) {
|
|
81
|
+
output({
|
|
82
|
+
running: services.length > 0,
|
|
83
|
+
services: services.map((s) => ({ name: s.name, port: s.port, url: s.url, status: s.status })),
|
|
84
|
+
}, globals);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (services.length === 0) {
|
|
88
|
+
console.log('Network is not running.');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
console.table(services.map((s) => ({
|
|
92
|
+
Service: s.name,
|
|
93
|
+
Status: s.status,
|
|
94
|
+
Port: s.port,
|
|
95
|
+
URL: s.url,
|
|
96
|
+
})));
|
|
48
97
|
}
|
|
49
|
-
console.table(services.map((s) => ({
|
|
50
|
-
Service: s.name,
|
|
51
|
-
Status: s.status,
|
|
52
|
-
Port: s.port,
|
|
53
|
-
URL: s.url,
|
|
54
|
-
})));
|
|
55
98
|
}
|
|
56
99
|
catch {
|
|
57
|
-
|
|
100
|
+
if (globals.json) {
|
|
101
|
+
output({ running: false, services: [] }, globals);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
console.log('Network is not running.');
|
|
105
|
+
}
|
|
58
106
|
}
|
|
59
107
|
});
|
|
60
108
|
program
|
|
@@ -62,23 +110,45 @@ export function registerNetworkCommands(program, manager) {
|
|
|
62
110
|
.description('Show network service logs')
|
|
63
111
|
.option('--service <name>', 'Specific service (node, indexer, proof-server)')
|
|
64
112
|
.option('--lines <n>', 'Number of lines', '50')
|
|
65
|
-
.action(async (opts)
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
113
|
+
.action(async function (opts) {
|
|
114
|
+
const globals = this.optsWithGlobals();
|
|
115
|
+
try {
|
|
116
|
+
const logs = await manager.getLogs({
|
|
117
|
+
service: opts.service,
|
|
118
|
+
lines: parseInt(opts.lines, 10),
|
|
119
|
+
});
|
|
120
|
+
if (globals.json) {
|
|
121
|
+
output(parseLogLines(logs), globals);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
console.log(logs);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
outputError(err, globals);
|
|
129
|
+
}
|
|
71
130
|
});
|
|
72
131
|
program
|
|
73
132
|
.command('health')
|
|
74
133
|
.description('Check health of all services')
|
|
75
|
-
.action(async ()
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
134
|
+
.action(async function () {
|
|
135
|
+
const globals = this.optsWithGlobals();
|
|
136
|
+
try {
|
|
137
|
+
const health = await checkAllHealth(manager.config);
|
|
138
|
+
if (globals.json) {
|
|
139
|
+
output(health, globals);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
console.table({
|
|
143
|
+
Node: { Healthy: health.node.healthy, 'Response (ms)': health.node.responseTime },
|
|
144
|
+
Indexer: { Healthy: health.indexer.healthy, 'Response (ms)': health.indexer.responseTime },
|
|
145
|
+
'Proof Server': { Healthy: health.proofServer.healthy, 'Response (ms)': health.proofServer.responseTime },
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
outputError(err, globals);
|
|
151
|
+
}
|
|
82
152
|
});
|
|
83
153
|
}
|
|
84
154
|
//# sourceMappingURL=network.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/cli/commands/network.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/cli/commands/network.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EA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,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,49 +1,92 @@
|
|
|
1
1
|
import { getWalletBalances } from '../../core/wallet.js';
|
|
2
2
|
import { fundAccount, fundAccountsFromFile } from '../../core/funding.js';
|
|
3
|
+
import { output, outputError } from '../output.js';
|
|
3
4
|
export function registerWalletCommands(program, manager) {
|
|
4
5
|
program
|
|
5
6
|
.command('balances')
|
|
6
7
|
.description('Show master wallet balances')
|
|
7
|
-
.action(async ()
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
.action(async function () {
|
|
9
|
+
const globals = this.optsWithGlobals();
|
|
10
|
+
try {
|
|
11
|
+
const wallet = await manager.ensureWallet();
|
|
12
|
+
const b = await getWalletBalances(wallet);
|
|
13
|
+
if (globals.json) {
|
|
14
|
+
output({
|
|
15
|
+
unshielded: b.unshielded.toString(),
|
|
16
|
+
shielded: b.shielded.toString(),
|
|
17
|
+
dust: b.dust.toString(),
|
|
18
|
+
total: b.total.toString(),
|
|
19
|
+
}, globals);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.table({
|
|
23
|
+
Unshielded: b.unshielded.toString(),
|
|
24
|
+
Shielded: b.shielded.toString(),
|
|
25
|
+
DUST: b.dust.toString(),
|
|
26
|
+
Total: b.total.toString(),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
outputError(err, globals);
|
|
32
|
+
}
|
|
16
33
|
});
|
|
17
34
|
program
|
|
18
35
|
.command('fund <address>')
|
|
19
36
|
.description('Fund an address with NIGHT tokens')
|
|
20
37
|
.option('--amount <n>', 'Amount in NIGHT (default: 50000)')
|
|
21
|
-
.action(async (address, opts)
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
.action(async function (address, opts) {
|
|
39
|
+
const globals = this.optsWithGlobals();
|
|
40
|
+
try {
|
|
41
|
+
const wallet = await manager.ensureWallet();
|
|
42
|
+
let amount;
|
|
43
|
+
if (opts.amount) {
|
|
44
|
+
if (!/^[1-9]\d*$/.test(opts.amount)) {
|
|
45
|
+
outputError('--amount must be a positive whole number of NIGHT tokens.', globals);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
amount = BigInt(opts.amount) * 10n ** 6n;
|
|
49
|
+
}
|
|
50
|
+
const result = await fundAccount(wallet, address, amount);
|
|
51
|
+
if (globals.json) {
|
|
52
|
+
output({ address: result.address, amount: result.amount.toString(), txHash: result.txHash }, globals);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
console.log(`Funded ${result.address} with ${result.amount} NIGHT (tx: ${result.txHash})`);
|
|
29
56
|
}
|
|
30
|
-
amount = BigInt(opts.amount) * 10n ** 6n;
|
|
31
57
|
}
|
|
32
|
-
|
|
33
|
-
|
|
58
|
+
catch (err) {
|
|
59
|
+
outputError(err, globals);
|
|
60
|
+
}
|
|
34
61
|
});
|
|
35
62
|
program
|
|
36
63
|
.command('fund-file <path>')
|
|
37
64
|
.description('Fund accounts from an accounts.json file')
|
|
38
|
-
.action(async (filePath)
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
.action(async function (filePath) {
|
|
66
|
+
const globals = this.optsWithGlobals();
|
|
67
|
+
try {
|
|
68
|
+
const wallet = await manager.ensureWallet();
|
|
69
|
+
const results = await fundAccountsFromFile(wallet, filePath, manager.config);
|
|
70
|
+
if (globals.json) {
|
|
71
|
+
output(results.map((r) => ({
|
|
72
|
+
name: r.name,
|
|
73
|
+
address: r.address,
|
|
74
|
+
amount: r.amount.toString(),
|
|
75
|
+
hasDust: r.hasDust,
|
|
76
|
+
})), globals);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.table(results.map((r) => ({
|
|
80
|
+
Name: r.name,
|
|
81
|
+
Address: r.address,
|
|
82
|
+
Amount: r.amount.toString(),
|
|
83
|
+
DUST: r.hasDust ? 'Yes' : 'No',
|
|
84
|
+
})));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
outputError(err, globals);
|
|
89
|
+
}
|
|
47
90
|
});
|
|
48
91
|
}
|
|
49
92
|
//# sourceMappingURL=wallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/cli/commands/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/cli/commands/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAC;AAEvE,MAAM,UAAU,sBAAsB,CAAC,OAAgB,EAAE,OAAuB;IAC9E,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,KAAK;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,EAAmB,CAAC;QACxD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC;YAC5C,MAAM,CAAC,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC1C,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,MAAM,CAAC;oBACL,UAAU,EAAE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,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;oBAC3B,OAAO,EAAE,CAAC,CAAC,OAAO;iBACnB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAChB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAChC,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;oBAClB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;oBAC3B,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;iBAC/B,CAAC,CAAC,CAAC,CAAC;YACP,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function bigintReplacer(_key, value) {
|
|
2
|
+
return typeof value === 'bigint' ? value.toString() : value;
|
|
3
|
+
}
|
|
4
|
+
export function output(data, opts) {
|
|
5
|
+
if (opts.json) {
|
|
6
|
+
process.stdout.write(JSON.stringify(data, bigintReplacer, 2) + '\n');
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
console.log(data);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function outputError(error, opts) {
|
|
13
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
14
|
+
process.exitCode = 1;
|
|
15
|
+
if (opts.json) {
|
|
16
|
+
process.stdout.write(JSON.stringify({ error: message }, null, 2) + '\n');
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
console.error('Error:', message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAIA,SAAS,cAAc,CAAC,IAAY,EAAE,KAAc;IAClD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAa,EAAE,IAAmB;IACvD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACvE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc,EAAE,IAAmB;IAC7D,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACrB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3E,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,8 @@ import { setLogger as setWalletLogger } from './core/wallet.js';
|
|
|
11
11
|
import { setLogger as setFundingLogger } from './core/funding.js';
|
|
12
12
|
import { setLogger as setAccountsLogger } from './core/accounts.js';
|
|
13
13
|
const manager = new NetworkManager();
|
|
14
|
-
const
|
|
14
|
+
const jsonMode = process.argv.includes('--json');
|
|
15
|
+
const logger = createLogger('info', jsonMode ? process.stderr : process.stdout);
|
|
15
16
|
setWalletLogger(logger);
|
|
16
17
|
setFundingLogger(logger);
|
|
17
18
|
setAccountsLogger(logger);
|
|
@@ -29,7 +30,8 @@ const program = new Command();
|
|
|
29
30
|
program
|
|
30
31
|
.name('midnight-local-devnet')
|
|
31
32
|
.description('Manage a local Midnight development network')
|
|
32
|
-
.version('0.
|
|
33
|
+
.version('0.6.0')
|
|
34
|
+
.option('--json', 'Output results as JSON');
|
|
33
35
|
registerNetworkCommands(program, manager);
|
|
34
36
|
registerWalletCommands(program, manager);
|
|
35
37
|
registerAccountCommands(program, manager);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,OAAO,GAA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;AACxD,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC;AAErC,8BAA8B;AAC9B,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;IAC1B,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;IACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AACF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAEhC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,uBAAuB,CAAC;KAC7B,WAAW,CAAC,6CAA6C,CAAC;KAC1D,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;AAE9C,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1C,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACzC,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1C,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC7C,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAE3C,wCAAwC;AACxC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;IAClB,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/core/health.js
CHANGED
|
@@ -3,6 +3,9 @@ async function checkEndpoint(url) {
|
|
|
3
3
|
const start = Date.now();
|
|
4
4
|
try {
|
|
5
5
|
const response = await fetch(url, { signal: AbortSignal.timeout(5000) });
|
|
6
|
+
// Consume the body so the underlying TCP connection is released back to the pool.
|
|
7
|
+
// Without this, undici keeps the socket open and connections leak on every poll cycle.
|
|
8
|
+
await response.body?.cancel();
|
|
6
9
|
return {
|
|
7
10
|
healthy: response.ok,
|
|
8
11
|
responseTime: Date.now() - start,
|
|
@@ -22,7 +25,7 @@ export async function checkAllHealth(config) {
|
|
|
22
25
|
const [node, indexer, proofServer] = await Promise.all([
|
|
23
26
|
checkEndpoint(`${cfg.node}/health`),
|
|
24
27
|
checkEndpoint(`${indexerOrigin}/ready`),
|
|
25
|
-
checkEndpoint(`${cfg.proofServer}/
|
|
28
|
+
checkEndpoint(`${cfg.proofServer}/version`),
|
|
26
29
|
]);
|
|
27
30
|
return {
|
|
28
31
|
node,
|
package/dist/core/health.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/core/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAgB5C,KAAK,UAAU,aAAa,CAAC,GAAW;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzE,OAAO;YACL,OAAO,EAAE,QAAQ,CAAC,EAAE;YACpB,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;SACjC,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,OAAO,EAAE,KAAK;YACd,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;YAChC,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACxD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAsB;IACzD,MAAM,GAAG,GAAG,MAAM,IAAI,aA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