@jellylegsai/aether-cli 1.9.2 → 2.0.2

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/index.js CHANGED
@@ -1,602 +1,501 @@
1
- #!/usr/bin/env node
2
- /**
3
- * aether-cli - AeTHer Validator Command Line Interface
4
- *
5
- * Main entry point for the validator CLI tool.
6
- * Provides onboarding, system checks, validator management, and KYC integration.
7
- */
8
-
9
- const { doctorCommand } = require('./commands/doctor');
10
- const { validatorStart } = require('./commands/validator-start');
11
- const { validatorStatus } = require('./commands/validator-status');
12
- const { validatorInfo } = require('./commands/validator-info');
13
- const { init } = require('./commands/init');
14
- const { monitorLoop } = require('./commands/monitor');
15
- const { logsCommand } = require('./commands/logs');
16
- const { sdkCommand } = require('./commands/sdk');
17
- const { snapshotCommand } = require('./commands/snapshot');
18
- const { walletCommand } = require('./commands/wallet');
19
- const { networkCommand } = require('./commands/network');
20
- const { validatorsListCommand } = require('./commands/validators');
21
- const { delegationsCommand } = require('./commands/delegations');
22
- const { rewardsCommand } = require('./commands/rewards');
23
- const { validatorRegisterCommand } = require('./commands/validator-register');
24
- const { accountCommand } = require('./commands/account');
25
- const { emergencyCommand } = require('./commands/emergency');
26
- const { priceCommand } = require('./commands/price');
27
- const { epochCommand } = require('./commands/epoch');
28
- const { supplyCommand } = require('./commands/supply');
29
- const { statusCommand } = require('./commands/status');
30
- const { broadcastCommand } = require('./commands/broadcast');
31
- const { apyCommand } = require('./commands/apy');
32
- const { statsCommand } = require('./commands/stats');
33
- const { txHistoryCommand } = require('./commands/tx-history');
34
- const { feesCommand } = require('./commands/fees');
35
- const { tpsCommand } = require('./commands/tps');
36
- const { blockhashCommand } = require('./commands/blockhash');
37
- const { sdkTestCommand } = require('./commands/sdk-test');
38
- const { balanceCommand } = require('./commands/balance');
39
- const { transferCommand } = require('./commands/transfer');
40
- const { slotCommand } = require('./commands/slot');
41
- const { configCommand } = require('./commands/config');
42
- const { stakeCommand } = require('./commands/stake');
43
- const { nftCommand } = require('./commands/nft');
44
- const { installCommand } = require('./commands/install');
45
- const { pingCommand } = require('./commands/ping');
46
- const readline = require('readline');
47
-
48
- // CLI version
49
- const VERSION = '1.8.0';
50
-
51
- // Parse args early to support flags on commands
52
- function getCommandArgs() {
53
- return process.argv.slice(2);
54
- }
55
-
56
- // Tier colours
57
- const TIER_COLORS = {
58
- FULL: '\x1b[36m', // cyan
59
- LITE: '\x1b[33m', // yellow
60
- OBSERVER: '\x1b[32m', // green
61
- reset: '\x1b[0m',
62
- };
63
-
64
- /**
65
- * Display the interactive main menu
66
- */
67
- async function showMenu() {
68
- const rl = readline.createInterface({
69
- input: process.stdin,
70
- output: process.stdout,
71
- });
72
-
73
- const prompt = (q) => new Promise((res) => rl.question(q, res));
74
-
75
- console.log(
76
- TIER_COLORS.FULL + '\n ╔═══════════════════════════════════════════════╗\n' +
77
- ' ║ AETHER CHAIN Validator Setup Wizard ║\n' +
78
- ' ╚═══════════════════════════════════════════════╝' + TIER_COLORS.reset + '\n'
79
- );
80
-
81
- console.log(' Welcome to AeTHer Chain. What would you like to do?\n');
82
- console.log(' ' + TIER_COLORS.FULL + '1)' + TIER_COLORS.reset + ' 🩺 Doctor — Check if your system meets requirements');
83
- console.log(' ' + TIER_COLORS.FULL + '2)' + TIER_COLORS.reset + ' 🚀 Start — Begin validator onboarding (recommended)');
84
- console.log(' ' + TIER_COLORS.FULL + '3)' + TIER_COLORS.reset + ' 📊 Monitor — Watch live validator stats');
85
- console.log(' ' + TIER_COLORS.FULL + '4)' + TIER_COLORS.reset + ' 📋 Logs — Tail and colourise validator logs');
86
- console.log(' ' + TIER_COLORS.FULL + '5)' + TIER_COLORS.reset + ' 📦 SDK — Get SDK links and install tools');
87
- console.log(' ' + TIER_COLORS.FULL + '6)' + TIER_COLORS.reset + ' 🌐 Network — Aether network status (slot, peers, TPS)');
88
- console.log(' ' + TIER_COLORS.FULL + '7)' + TIER_COLORS.reset + ' ❓ Help — Show all commands\n');
89
- console.log(' ' + TIER_COLORS.reset + ' Type a number or command name. Press Ctrl+C to exit.\n');
90
-
91
- const VALID_CHOICES = ['1', '2', '3', '4', '5', '6', '7', 'doctor', 'init', 'monitor', 'logs', 'sdk', 'network', 'help'];
92
-
93
- while (true) {
94
- const answer = (await prompt(` > `)).trim().toLowerCase();
95
-
96
- if (answer === '' || answer === '1' || answer === 'doctor') {
97
- rl.close();
98
- const { doctorCommand } = require('./commands/doctor');
99
- doctorCommand({ autoFix: false, tier: 'full' });
100
- return;
101
- }
102
-
103
- if (answer === '2' || answer === 'init' || answer === 'start') {
104
- rl.close();
105
- const { init } = require('./commands/init');
106
- init();
107
- return;
108
- }
109
-
110
- if (answer === '3' || answer === 'monitor') {
111
- rl.close();
112
- const { main } = require('./commands/monitor');
113
- main();
114
- return;
115
- }
116
-
117
- if (answer === '4' || answer === 'logs') {
118
- rl.close();
119
- const { logsCommand } = require('./commands/logs');
120
- logsCommand();
121
- return;
122
- }
123
-
124
- if (answer === '5' || answer === 'sdk') {
125
- rl.close();
126
- const { sdkCommand } = require('./commands/sdk');
127
- const { snapshotCommand } = require('./commands/snapshot');
128
- sdkCommand();
129
- return;
130
- }
131
-
132
- if (answer === '6' || answer === 'network') {
133
- rl.close();
134
- const { networkCommand } = require('./commands/network');
135
- networkCommand();
136
- return;
137
- }
138
-
139
- if (answer === '7' || answer === 'help') {
140
- showHelp();
141
- console.log(" Press Ctrl+C to exit or select an option above.\n");
142
- continue;
143
- }
144
-
145
- console.log(`\n ⚠️ Unknown option: "${answer}". Type 1-6 or a command name.\n`);
146
- }
147
- }
148
-
149
- // Available commands
150
- const COMMANDS = {
151
- start: {
152
- description: 'Launch interactive menu (default if no args) — same as running aether-cli with no arguments',
153
- handler: () => showMenu(),
154
- },
155
- doctor: {
156
- description: 'Run system requirements checks (CPU/RAM/Disk/Network/Firewall)',
157
- handler: () => {
158
- const args = getCommandArgs();
159
- const autoFix = args.includes('--fix') || args.includes('-f');
160
-
161
- // Parse --tier flag
162
- let tier = 'full';
163
- const tierIndex = args.findIndex(arg => arg === '--tier');
164
- if (tierIndex !== -1 && args[tierIndex + 1]) {
165
- tier = args[tierIndex + 1].toLowerCase();
166
- }
167
-
168
- doctorCommand({ autoFix, tier });
169
- },
170
- },
171
- init: {
172
- description: 'Start onboarding wizard (generate identity, create stake account, connect to testnet)',
173
- handler: init,
174
- },
175
- 'kyc generate': {
176
- description: 'Generate pre-filled KYC link with pubkey, node ID, signature',
177
- handler: () => {
178
- const { kycGenerate } = require('./commands/kyc');
179
- kycGenerate();
180
- },
181
- },
182
- monitor: {
183
- description: 'Real-time validator dashboard (slot, block height, peers, TPS)',
184
- handler: () => {
185
- // monitor command runs its own loop
186
- const { main } = require('./commands/monitor');
187
- main();
188
- },
189
- },
190
- logs: {
191
- description: 'Tail validator logs with colour-coded output (ERROR=red, WARN=yellow, INFO=green)',
192
- handler: logsCommand,
193
- },
194
- sdk: {
195
- description: 'Aether SDK download links and install instructions (JS, Rust, FLUX/ATH tokens)',
196
- handler: sdkCommand,
197
- },
198
- wallet: {
199
- description: 'Wallet management — create, import, list, default, connect, balance, stake, transfer',
200
- handler: () => {
201
- const { walletCommand } = require('./commands/wallet');
202
- walletCommand();
203
- },
204
- },
205
- stake: {
206
- description: 'Stake AETH to a validator — aether stake --validator <addr> --amount <aeth> [--list-validators]',
207
- handler: () => {
208
- const { stakeCommand } = require('./commands/stake');
209
- stakeCommand();
210
- },
211
- },
212
- 'stake-positions': {
213
- description: 'Show current stake positions/delegations aether stake-positions --address <addr> [--json]',
214
- handler: () => {
215
- const { stakePositionsCommand } = require('./commands/stake-positions');
216
- stakePositionsCommand();
217
- },
218
- },
219
- 'stake-info': {
220
- description: 'Get staking info for an address via real chain RPC — aether stake-info <address>',
221
- handler: () => {
222
- const { stakeInfoCommand } = require('./commands/stake-info');
223
- stakeInfoCommand();
224
- },
225
- },
226
- unstake: {
227
- description: 'Unstake AETH — deactivate a stake account — aether unstake --account <stakeAcct> [--amount <aeth>]',
228
- handler: () => {
229
- const { unstakeCommand } = require('./commands/unstake');
230
- unstakeCommand();
231
- },
232
- },
233
- export: {
234
- description: 'Export wallet data — aether export --address <addr> [--mnemonic] [--json]',
235
- handler: () => {
236
- const { walletCommand } = require('./commands/wallet');
237
- const originalArgv = process.argv;
238
- process.argv = [...originalArgv.slice(0, 2), 'wallet', 'export', ...originalArgv.slice(3)];
239
- walletCommand();
240
- process.argv = originalArgv;
241
- },
242
- },
243
- transfer: {
244
- description: 'Transfer AETH to another address — aether transfer --to <addr> --amount <aeth>',
245
- handler: () => {
246
- transferCommand();
247
- },
248
- },
249
- 'tx-history': {
250
- description: 'Transaction history for an address — aether tx-history --address <addr> [--limit 20] [--json]',
251
- handler: () => {
252
- txHistoryCommand();
253
- },
254
- },
255
- tx: {
256
- description: 'Look up a transaction by signature — aether tx <signature> [--json] [--wait] [--logs]',
257
- handler: () => {
258
- const { txCommand } = require('./commands/tx');
259
- txCommand();
260
- },
261
- },
262
- blockhash: {
263
- description: 'Get the latest blockhash from the chain (required for signing TXs) — aether blockhash [--json] [--watch]',
264
- handler: () => {
265
- const { blockhashCommand } = require('./commands/blockhash');
266
- blockhashCommand();
267
- },
268
- },
269
- balance: {
270
- description: 'Query account balance aether balance [address] [--json] [--lamports] [--rpc <url>]',
271
- handler: () => {
272
- const { balanceCommand } = require('./commands/balance');
273
- balanceCommand();
274
- },
275
- },
276
- network: {
277
- description: 'Aether network status slot, block height, peers, TPS, epoch info',
278
- handler: () => {
279
- const { networkCommand } = require('./commands/network');
280
- networkCommand();
281
- },
282
- },
283
- history: {
284
- description: 'Transaction history for an address — alias for tx history',
285
- handler: () => {
286
- txHistoryCommand();
287
- },
288
- },
289
- validator: {
290
- description: 'Validator node management',
291
- handler: () => {
292
- // Handle validator subcommands
293
- const subcmd = process.argv[3];
294
-
295
- if (!subcmd) {
296
- console.log('Usage: aether-cli validator <command>');
297
- console.log('');
298
- console.log('Commands:');
299
- console.log(' start Start the validator node');
300
- console.log(' status Check validator status');
301
- console.log(' info Get validator info');
302
- console.log(' register Register validator with the network');
303
- console.log('');
304
- return;
305
- }
306
-
307
- switch (subcmd) {
308
- case 'start':
309
- validatorStart();
310
- break;
311
- case 'status':
312
- validatorStatus();
313
- break;
314
- case 'info':
315
- validatorInfo();
316
- break;
317
- case 'register':
318
- validatorRegisterCommand();
319
- break;
320
- default:
321
- console.error(`Unknown validator command: ${subcmd}`);
322
- console.error('Valid commands: start, status, info, register');
323
- process.exit(1);
324
- }
325
- },
326
- },
327
- delegations: {
328
- description: 'List/claim stake delegations aether delegations list --address <addr>',
329
- handler: () => {
330
- delegationsCommand();
331
- },
332
- },
333
- rewards: {
334
- description: 'View staking rewards — aether rewards list | summary | pending | claim | compound',
335
- handler: () => {
336
- rewardsCommand();
337
- },
338
- },
339
- snapshot: {
340
- description: 'Node sync status, snapshot slot info, and network slot comparison',
341
- handler: () => {
342
- const { snapshotCommand } = require('./commands/snapshot');
343
- snapshotCommand();
344
- },
345
- },
346
- info: {
347
- description: 'Validator info snapshot — identity, sync state, peers, stake positions',
348
- handler: () => {
349
- const { infoCommand } = require('./commands/info');
350
- infoCommand();
351
- },
352
- },
353
- account: {
354
- description: 'Query on-chain account data — aether account --address <addr> [--json] [--data] [--rpc <url>]',
355
- handler: () => {
356
- const { accountCommand } = require('./commands/account');
357
- accountCommand();
358
- },
359
- },
360
- epoch: {
361
- description: 'Aether epoch info — current epoch, slot, time remaining, APY estimate — aether epoch [--json] [--schedule]',
362
- handler: () => {
363
- const { epochCommand } = require('./commands/epoch');
364
- epochCommand();
365
- },
366
- },
367
- supply: {
368
- description: 'Aether token supply total, circulating, staked, burned — aether supply [--json] [--verbose]',
369
- handler: () => {
370
- const { supplyCommand } = require('./commands/supply');
371
- // Pass full argv so supply.js can parse its own --help etc.
372
- supplyCommand();
373
- },
374
- },
375
- status: {
376
- description: 'Full dashboard epoch, network, supply, validator info — aether status [--json] [--compact] [--validator]',
377
- handler: () => {
378
- const { statusCommand } = require('./commands/status');
379
- statusCommand();
380
- },
381
- },
382
- validators: {
383
- description: 'List active validators — aether validators list [--tier full|lite|observer] [--json]',
384
- handler: () => {
385
- validatorsListCommand();
386
- },
387
- },
388
- 'validator-info': {
389
- description: 'Get detailed info for a specific validator — aether validator-info <address> [--json]',
390
- handler: () => {
391
- const { validatorInfoCommand } = require('./commands/validator-info');
392
- validatorInfoCommand();
393
- },
394
- },
395
- stats: {
396
- description: 'Wallet stats dashboard — balance, stake positions, recent txs — aether stats --address <addr> [--compact] [--json]',
397
- handler: () => {
398
- statsCommand();
399
- },
400
- },
401
- price: {
402
- description: 'AETH/USD price aether price [--pair AETH/USD] [--json] [--source coingecko]',
403
- handler: () => {
404
- const { priceCommand } = require('./commands/price');
405
- priceCommand();
406
- },
407
- },
408
- broadcast: {
409
- description: 'Broadcast a signed transaction — aether broadcast --tx <sig> [--json] [--file <path>]',
410
- handler: () => {
411
- const { broadcastCommand } = require('./commands/broadcast');
412
- broadcastCommand();
413
- },
414
- },
415
- apy: {
416
- description: 'Validator APY estimator — aether apy [--validator <addr>] [--address <addr>] [--json] [--epochs <n>]',
417
- handler: () => {
418
- const { apyCommand } = require('./commands/apy');
419
- apyCommand();
420
- },
421
- },
422
- ping: {
423
- description: 'Ping RPC endpoint — measure latency, check node health — aether ping [--rpc <url>] [--count <n>] [--json]',
424
- handler: () => {
425
- const { pingCommand } = require('./commands/ping');
426
- pingCommand();
427
- },
428
- },
429
- emergency: {
430
- description: 'Emergency response & network alerts — status, monitor, check, alert, failover, history',
431
- handler: () => {
432
- const { emergencyCommand } = require('./commands/emergency');
433
- emergencyCommand();
434
- },
435
- },
436
- fees: {
437
- description: 'Network fee estimates — aether fees [--json] [--verbose] [--rpc <url>]',
438
- handler: () => {
439
- feesCommand();
440
- },
441
- },
442
- tps: {
443
- description: 'Transactions per second monitor — aether tps [--monitor] [--interval 2] [--json]',
444
- handler: () => {
445
- tpsCommand();
446
- },
447
- },
448
- slot: {
449
- description: 'Get current slot number — aether slot [--json] [--rpc <url>]',
450
- handler: () => {
451
- slotCommand();
452
- },
453
- },
454
- multisig: {
455
- description: 'Multi-signature wallet management — create, list, info, send, add-signer — aether multisig <subcommand>',
456
- handler: () => {
457
- const { multisigCommand } = require('./commands/multisig');
458
- multisigCommand();
459
- },
460
- },
461
- claim: {
462
- description: 'Claim accumulated staking rewards — aether claim --address <addr> [--json] [--dry-run]',
463
- handler: () => {
464
- const { claimCommand } = require('./commands/claim');
465
- claimCommand();
466
- },
467
- },
468
- register: {
469
- description: 'Register validator with network — aether register --wallet <addr> --amount <aeth> [--tier full]',
470
- handler: () => {
471
- validatorRegisterCommand();
472
- },
473
- },
474
- 'sdk-test': {
475
- description: 'Test SDK with real RPC calls — aether sdk-test [--rpc <url>] [--quick] [--json]',
476
- handler: () => {
477
- sdkTestCommand();
478
- },
479
- },
480
- config: {
481
- description: 'Configuration management — aether config set/get/list/validate/init',
482
- handler: () => {
483
- configCommand();
484
- },
485
- },
486
- nft: {
487
- description: 'NFT management — aether nft create|list|transfer|info|update — full SDK-wired suite',
488
- handler: () => {
489
- nftCommand();
490
- },
491
- },
492
- install: {
493
- description: 'Install or upgrade aether-cli — npm install, config init, PATH setup — aether install [--force] [--rpc <url>] [--skip-rpc-check]',
494
- handler: () => {
495
- installCommand();
496
- },
497
- },
498
- 'install-help': {
499
- description: 'Show install command help',
500
- hidden: true,
501
- handler: () => {
502
- process.argv = [process.argv[0], process.argv[1], 'install', '--help'];
503
- installCommand();
504
- },
505
- },
506
- help: {
507
- description: 'Show this help message',
508
- handler: showHelp,
509
- },
510
- version: {
511
- description: 'Show version number',
512
- handler: () => console.log(`aether-cli v${VERSION}`),
513
- },
514
- };
515
-
516
- /**
517
- * Display help message with ASCII art
518
- */
519
- function showHelp() {
520
- const header = `
521
- ███╗ ███╗██╗███████╗███████╗██╗ ██████╗ ███╗ ██╗
522
- ████╗ ████║██║██╔════╝██╔════╝██║██╔═══██╗████╗ ██║
523
- ██╔████╔██║██║███████╗███████╗██║██║ ██║██╔██╗ ██║
524
- ██║╚██╔╝██║██║╚════██║╚════██║██║██║ ██║██║╚██╗██║
525
- ██║ ╚═╝ ██║██║███████║███████║██║╚██████╔╝██║ ╚████║
526
- ╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝
527
-
528
- Validator CLI v${VERSION}
529
- `.trim();
530
-
531
- console.log(header);
532
- console.log('\nUsage: aether-cli <command> [options]\n');
533
- console.log('Commands:');
534
- Object.entries(COMMANDS).forEach(([cmd, info]) => {
535
- if (info.hidden) return;
536
- console.log(` ${cmd.padEnd(18)} ${info.description}`);
537
- });
538
- console.log('\nExamples:');
539
- console.log(' aether-cli doctor # Check system requirements');
540
- console.log(' aether-cli init # Start onboarding wizard');
541
- console.log(' aether-cli monitor # Real-time validator dashboard');
542
- console.log(' aether-cli validator start # Start validator node');
543
- console.log(' aether-cli validator status # Check validator status');
544
- console.log(' aether-cli wallet balance # Query AETH balance');
545
- console.log(' aether-cli network # Network status, peers, slot info');
546
- console.log(' aether-cli network --peers # Detailed peer list');
547
- console.log(' aether-cli tx history # Show transaction history');
548
- console.log(' aether-cli price # AETH/USD price check');
549
- console.log(' aether-cli nft create # Create NFT with metadata');
550
- console.log(' aether-cli nft list # List NFTs owned by wallet');
551
- console.log(' aether-cli --version # Show version');
552
- console.log('\nDocumentation: https://github.com/jelly-legs-ai/Jelly-legs-unsteady-workshop');
553
- console.log('Spec: docs/MINING_VALIDATOR_TOOLS.md\n');
554
- }
555
-
556
- /**
557
- * Parse command line arguments
558
- */
559
- function parseArgs() {
560
- const args = process.argv.slice(2);
561
-
562
- // Handle version flag
563
- if (args.includes('--version') || args.includes('-v') || args.includes('-V')) {
564
- return 'version';
565
- }
566
-
567
- // No args → interactive menu
568
- if (args.length === 0) {
569
- return 'start';
570
- }
571
-
572
- // Handle multi-word commands (e.g., "validator start", "kyc generate")
573
- if (args.length >= 2) {
574
- const multiCmd = `${args[0]} ${args[1]}`;
575
- if (COMMANDS[multiCmd]) {
576
- return multiCmd;
577
- }
578
- }
579
-
580
- // Handle single word commands
581
- return args[0] || 'help';
582
- }
583
-
584
- /**
585
- * Main CLI entry point
586
- */
587
- function main() {
588
- const command = parseArgs();
589
-
590
- if (COMMANDS[command]) {
591
- COMMANDS[command].handler();
592
- } else {
593
- console.error(`❌ Unknown command: ${command}`);
594
- console.error('Run "aether-cli help" for usage.\n');
595
- process.exit(1);
596
- }
597
- }
598
-
599
- // Run CLI only if executed directly
600
- if (require.main === module) {
601
- main();
602
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * aether-cli - Aether Blockchain Command Line Interface
4
+ *
5
+ * Main entry point for the validator CLI tool.
6
+ * Provides onboarding, system checks, validator management, and blockchain operations.
7
+ *
8
+ * @version 2.0.0
9
+ * @author Jelly-legs AI Team
10
+ */
11
+
12
+ const readline = require('readline');
13
+ const path = require('path');
14
+
15
+ // Import UI framework for consistent branding
16
+ const { BRANDING, C, indicators, success, error, warning, info, code, key, value, formatHelp, drawBox } = require('./lib/ui');
17
+
18
+ // CLI version
19
+ const VERSION = '2.0.2';
20
+
21
+ // Command imports
22
+ const { doctorCommand } = require('./commands/doctor');
23
+ const { validatorStartCommand } = require('./commands/validator-start');
24
+ const { validatorStatus } = require('./commands/validator-status');
25
+ const { validatorInfo } = require('./commands/validator-info');
26
+ const { validatorCommand } = require('./commands/validator');
27
+ const { init } = require('./commands/init');
28
+ const { monitorLoop } = require('./commands/monitor');
29
+ const { logsCommand } = require('./commands/logs');
30
+ const { sdkCommand } = require('./commands/sdk');
31
+ const { snapshotCommand } = require('./commands/snapshot');
32
+ const { walletCommand } = require('./commands/wallet');
33
+ const { networkCommand } = require('./commands/network');
34
+ const { networkDiagnosticsCommand } = require('./commands/network-diagnostics');
35
+ const { validatorsCommand } = require('./commands/validators');
36
+ const { delegationsCommand } = require('./commands/delegations');
37
+ const { rewardsCommand } = require('./commands/rewards');
38
+ const { validatorRegisterCommand } = require('./commands/validator-register');
39
+ const { accountCommand } = require('./commands/account');
40
+ const { emergencyCommand } = require('./commands/emergency');
41
+ const { priceCommand } = require('./commands/price');
42
+ const { epochCommand } = require('./commands/epoch');
43
+ const { supplyCommand } = require('./commands/supply');
44
+ const { statusCommand } = require('./commands/status');
45
+ const { broadcastCommand } = require('./commands/broadcast');
46
+ const { apyCommand } = require('./commands/apy');
47
+ const { statsCommand } = require('./commands/stats');
48
+ const { txHistoryCommand } = require('./commands/tx-history');
49
+ const { feesCommand } = require('./commands/fees');
50
+ const { tpsCommand } = require('./commands/tps');
51
+ const { blockhashCommand } = require('./commands/blockhash');
52
+ const { sdkTestCommand } = require('./commands/sdk-test');
53
+ const { balanceCommand } = require('./commands/balance');
54
+ const { transferCommand } = require('./commands/transfer');
55
+ const { slotCommand } = require('./commands/slot');
56
+ const { configCommand } = require('./commands/config');
57
+ const { stakeCommand } = require('./commands/stake');
58
+ const { nftCommand } = require('./commands/nft');
59
+ const { installCommand } = require('./commands/install');
60
+ const { pingCommand } = require('./commands/ping');
61
+ const { claimCommand } = require('./commands/claim');
62
+ const { unstakeCommand } = require('./commands/unstake');
63
+ const { txCommand } = require('./commands/tx');
64
+ const { multisigCommand } = require('./commands/multisig');
65
+ const { deployCommand } = require('./commands/deploy');
66
+ const { callCommand } = require('./commands/call');
67
+ const { blockheightCommand } = require('./commands/blockheight');
68
+ const { versionCommand } = require('./commands/version');
69
+ const { tokenAccountsCommand } = require('./commands/token-accounts');
70
+
71
+ // Parse args early to support flags on commands
72
+ function getCommandArgs() {
73
+ return process.argv.slice(2);
74
+ }
75
+
76
+ /**
77
+ * Display the interactive main menu
78
+ */
79
+ async function showMenu() {
80
+ const rl = readline.createInterface({
81
+ input: process.stdin,
82
+ output: process.stdout,
83
+ });
84
+
85
+ const prompt = (q) => new Promise((res) => rl.question(q, res));
86
+
87
+ console.log(BRANDING.header(VERSION));
88
+
89
+ console.log(` ${C.dim}Welcome to Aether CLI. What would you like to do?${C.reset}\n`);
90
+
91
+ const menuItems = [
92
+ { num: '1', icon: indicators.bullet, label: 'Doctor', desc: 'Check system requirements', cmd: 'doctor' },
93
+ { num: '2', icon: indicators.bullet, label: 'Start', desc: 'Begin validator onboarding', cmd: 'init' },
94
+ { num: '3', icon: indicators.bullet, label: 'Monitor', desc: 'Watch live validator stats', cmd: 'monitor' },
95
+ { num: '4', icon: indicators.bullet, label: 'Logs', desc: 'Tail validator logs', cmd: 'logs' },
96
+ { num: '5', icon: indicators.bullet, label: 'SDK', desc: 'SDK tools and info', cmd: 'sdk' },
97
+ { num: '6', icon: indicators.bullet, label: 'Network', desc: 'Network status', cmd: 'network' },
98
+ { num: '7', icon: indicators.bullet, label: 'Help', desc: 'Show all commands', cmd: 'help' },
99
+ ];
100
+
101
+ for (const item of menuItems) {
102
+ console.log(` ${C.cyan}${item.num})${C.reset} ${C.bright}${item.label}${C.reset} ${C.dim}${item.desc}${C.reset}`);
103
+ }
104
+
105
+ console.log(`\n ${C.dim}Type a number or command name. Press Ctrl+C to exit.${C.reset}\n`);
106
+
107
+ const VALID_CHOICES = ['1', '2', '3', '4', '5', '6', '7', 'doctor', 'init', 'monitor', 'logs', 'sdk', 'network', 'help'];
108
+
109
+ while (true) {
110
+ const answer = (await prompt(`${C.cyan}>${C.reset} `)).trim().toLowerCase();
111
+
112
+ if (answer === '' || answer === '1' || answer === 'doctor') {
113
+ rl.close();
114
+ doctorCommand({ autoFix: false, tier: 'full' });
115
+ return;
116
+ }
117
+
118
+ if (answer === '2' || answer === 'init' || answer === 'start') {
119
+ rl.close();
120
+ init();
121
+ return;
122
+ }
123
+
124
+ if (answer === '3' || answer === 'monitor') {
125
+ rl.close();
126
+ const { main } = require('./commands/monitor');
127
+ main();
128
+ return;
129
+ }
130
+
131
+ if (answer === '4' || answer === 'logs') {
132
+ rl.close();
133
+ logsCommand();
134
+ return;
135
+ }
136
+
137
+ if (answer === '5' || answer === 'sdk') {
138
+ rl.close();
139
+ sdkCommand();
140
+ return;
141
+ }
142
+
143
+ if (answer === '6' || answer === 'network') {
144
+ rl.close();
145
+ networkCommand();
146
+ return;
147
+ }
148
+
149
+ if (answer === '7' || answer === 'help') {
150
+ showHelp();
151
+ console.log(` ${C.dim}Press Ctrl+C to exit or select an option above.${C.reset}\n`);
152
+ continue;
153
+ }
154
+
155
+ console.log(`\n ${warning(`Unknown option: "${answer}". Type 1-7 or a command name.`)}\n`);
156
+ }
157
+ }
158
+
159
+ // Available commands
160
+ const COMMANDS = {
161
+ start: {
162
+ description: 'Launch interactive menu (default)',
163
+ handler: () => showMenu(),
164
+ },
165
+ doctor: {
166
+ description: 'Run system requirements checks (CPU/RAM/Disk/Network)',
167
+ handler: () => {
168
+ const args = getCommandArgs();
169
+ const autoFix = args.includes('--fix') || args.includes('-f');
170
+ let tier = 'full';
171
+ const tierIndex = args.findIndex(arg => arg === '--tier');
172
+ if (tierIndex !== -1 && args[tierIndex + 1]) {
173
+ tier = args[tierIndex + 1].toLowerCase();
174
+ }
175
+ doctorCommand({ autoFix, tier });
176
+ },
177
+ },
178
+ init: {
179
+ description: 'Start onboarding wizard (generate identity, wallet, connect)',
180
+ handler: init,
181
+ },
182
+ monitor: {
183
+ description: 'Real-time validator dashboard (slot, height, peers, TPS)',
184
+ handler: () => {
185
+ const { main } = require('./commands/monitor');
186
+ main();
187
+ },
188
+ },
189
+ logs: {
190
+ description: 'Tail validator logs with colour-coded output',
191
+ handler: logsCommand,
192
+ },
193
+ sdk: {
194
+ description: 'Aether SDK tools - direct blockchain RPC access',
195
+ handler: sdkCommand,
196
+ },
197
+ wallet: {
198
+ description: 'Wallet management - create, import, list, balance, transfer',
199
+ handler: walletCommand,
200
+ },
201
+ stake: {
202
+ description: 'Stake AETH to a validator - stake --validator <addr> --amount <aeth>',
203
+ handler: stakeCommand,
204
+ },
205
+ 'stake-positions': {
206
+ description: 'Show current stake positions/delegations',
207
+ handler: () => {
208
+ const { stakePositionsCommand } = require('./commands/stake-positions');
209
+ stakePositionsCommand();
210
+ },
211
+ },
212
+ 'stake-info': {
213
+ description: 'Get staking info for an address via chain RPC',
214
+ handler: () => {
215
+ const { stakeInfoCommand } = require('./commands/stake-info');
216
+ stakeInfoCommand();
217
+ },
218
+ },
219
+ unstake: {
220
+ description: 'Unstake AETH - deactivate a stake account',
221
+ handler: unstakeCommand,
222
+ },
223
+ claim: {
224
+ description: 'Claim accumulated staking rewards - claim --address <addr>',
225
+ handler: claimCommand,
226
+ },
227
+ transfer: {
228
+ description: 'Transfer AETH to another address - transfer --to <addr> --amount <aeth>',
229
+ handler: transferCommand,
230
+ },
231
+ 'tx-history': {
232
+ description: 'Transaction history for an address',
233
+ handler: txHistoryCommand,
234
+ },
235
+ tx: {
236
+ description: 'Look up a transaction by signature - tx <sig> [--json] [--wait]',
237
+ handler: txCommand,
238
+ },
239
+ blockhash: {
240
+ description: 'Get the latest blockhash for transaction signing',
241
+ handler: blockhashCommand,
242
+ },
243
+ balance: {
244
+ description: 'Query account balance - balance [address] [--json]',
245
+ handler: balanceCommand,
246
+ },
247
+ network: {
248
+ description: 'Aether network status - slot, height, peers, TPS',
249
+ handler: networkCommand,
250
+ },
251
+ validator: {
252
+ description: 'Validator node management - status, info, start, stop, register, logs',
253
+ handler: () => {
254
+ validatorCommand();
255
+ },
256
+ },
257
+ delegations: {
258
+ description: 'List/claim stake delegations',
259
+ handler: delegationsCommand,
260
+ },
261
+ rewards: {
262
+ description: 'View staking rewards - list | summary | pending | claim | compound',
263
+ handler: rewardsCommand,
264
+ },
265
+ snapshot: {
266
+ description: 'Node sync status, snapshot slot info',
267
+ handler: snapshotCommand,
268
+ },
269
+ info: {
270
+ description: 'Validator info snapshot - identity, sync, peers, stake',
271
+ handler: () => {
272
+ const { infoCommand } = require('./commands/info');
273
+ infoCommand();
274
+ },
275
+ },
276
+ account: {
277
+ description: 'Query on-chain account data - account --address <addr> [--json]',
278
+ handler: accountCommand,
279
+ },
280
+ epoch: {
281
+ description: 'Aether epoch info - current epoch, slot, time remaining, APY',
282
+ handler: epochCommand,
283
+ },
284
+ supply: {
285
+ description: 'Aether token supply - total, circulating, staked, burned',
286
+ handler: supplyCommand,
287
+ },
288
+ status: {
289
+ description: 'Full dashboard - epoch, network, supply, validator info',
290
+ handler: statusCommand,
291
+ },
292
+ validators: {
293
+ description: 'Validator network management - validators list|info|top [--tier] [--json]',
294
+ handler: validatorsCommand,
295
+ },
296
+ 'validator-info': {
297
+ description: 'Get detailed info for a specific validator',
298
+ handler: () => {
299
+ const { validatorInfoCommand } = require('./commands/validator-info');
300
+ validatorInfoCommand();
301
+ },
302
+ },
303
+ stats: {
304
+ description: 'Wallet stats dashboard - balance, stake, recent txs',
305
+ handler: statsCommand,
306
+ },
307
+ price: {
308
+ description: 'AETH/USD price - price [--pair AETH/USD] [--json]',
309
+ handler: priceCommand,
310
+ },
311
+ broadcast: {
312
+ description: 'Broadcast a signed transaction - broadcast --tx <sig> [--json]',
313
+ handler: broadcastCommand,
314
+ },
315
+ apy: {
316
+ description: 'Validator APY estimator',
317
+ handler: apyCommand,
318
+ },
319
+ ping: {
320
+ description: 'Ping RPC endpoint - measure latency, check node health',
321
+ handler: pingCommand,
322
+ },
323
+ 'network-diagnostics': {
324
+ description: 'Network diagnostics with RPC failover',
325
+ handler: networkDiagnosticsCommand,
326
+ },
327
+ emergency: {
328
+ description: 'Emergency response & network alerts',
329
+ handler: emergencyCommand,
330
+ },
331
+ fees: {
332
+ description: 'Network fee estimates - fees [--json] [--verbose] [--rpc <url>]',
333
+ handler: feesCommand,
334
+ },
335
+ tps: {
336
+ description: 'Transactions per second monitor - tps [--monitor] [--interval 2] [--json]',
337
+ handler: tpsCommand,
338
+ },
339
+ slot: {
340
+ description: 'Get current slot number - slot [--json] [--rpc <url>]',
341
+ handler: slotCommand,
342
+ },
343
+ blockheight: {
344
+ description: 'Get current block height - blockheight [--json] [--rpc <url>] [--compare]',
345
+ handler: blockheightCommand,
346
+ },
347
+ 'token-accounts': {
348
+ description: 'Get SPL token accounts for wallet - token-accounts [address] [--json]',
349
+ handler: tokenAccountsCommand,
350
+ },
351
+ version: {
352
+ description: 'Get node version info - version [--json] [--cli]',
353
+ handler: versionCommand,
354
+ },
355
+ multisig: {
356
+ description: 'Multi-signature wallet management',
357
+ handler: multisigCommand,
358
+ },
359
+ register: {
360
+ description: 'Register validator with network',
361
+ handler: validatorRegisterCommand,
362
+ },
363
+ 'sdk-test': {
364
+ description: 'Test SDK with real RPC calls - sdk-test [--rpc <url>] [--quick] [--json]',
365
+ handler: sdkTestCommand,
366
+ },
367
+ config: {
368
+ description: 'Configuration management - config set/get/list/validate/init',
369
+ handler: configCommand,
370
+ },
371
+ nft: {
372
+ description: 'NFT management - create|list|transfer|info|update',
373
+ handler: nftCommand,
374
+ },
375
+ deploy: {
376
+ description: 'Deploy smart contracts - deploy <file> [--name <name>] [--upgradeable]',
377
+ handler: deployCommand,
378
+ },
379
+ call: {
380
+ description: 'Call smart contract functions - call <program-id> <function> [args...] [--query|--wallet]',
381
+ handler: callCommand,
382
+ },
383
+ 'validator-setup': {
384
+ description: 'Setup validator prerequisites (alias for validator start)',
385
+ handler: () => {
386
+ const { validatorStartCommand } = require('./commands/validator-start');
387
+ validatorStartCommand();
388
+ },
389
+ },
390
+ install: {
391
+ description: 'Install or upgrade aether-cli',
392
+ handler: installCommand,
393
+ },
394
+ help: {
395
+ description: 'Show this help message',
396
+ handler: showHelp,
397
+ },
398
+ 'cli-version': {
399
+ description: 'Show CLI version number',
400
+ handler: () => {
401
+ console.log(BRANDING.header(VERSION));
402
+ console.log(` ${C.dim}SDK-powered blockchain CLI for Aether validators${C.reset}\n`);
403
+ },
404
+ },
405
+ };
406
+
407
+ /**
408
+ * Display help message with consistent branding
409
+ */
410
+ function showHelp() {
411
+ console.log(BRANDING.header(VERSION));
412
+
413
+ console.log(`\n ${C.bright}AETHER CLI${C.reset} — ${C.dim}Decentralized Infrastructure for the Future${C.reset}\n`);
414
+
415
+ // Group commands by category
416
+ const categories = {
417
+ 'Wallet & Accounts': ['wallet', 'balance', 'transfer', 'tx', 'tx-history', 'account', 'stats', 'token-accounts'],
418
+ 'Staking': ['stake', 'unstake', 'stake-positions', 'stake-info', 'delegations', 'rewards', 'claim'],
419
+ 'Validator': ['init', 'validator', 'validator-info', 'register', 'validators', 'monitor', 'logs'],
420
+ 'Network': ['network', 'network-diagnostics', 'ping', 'epoch', 'slot', 'blockheight', 'tps', 'fees', 'supply', 'version'],
421
+ 'SDK & Tools': ['sdk', 'sdk-test', 'snapshot', 'info', 'status', 'blockhash', 'broadcast', 'price', 'apy', 'deploy'],
422
+ 'Advanced': ['nft', 'multisig', 'emergency', 'config', 'doctor', 'install', 'call'],
423
+ };
424
+
425
+ for (const [category, cmds] of Object.entries(categories)) {
426
+ console.log(` ${C.cyan}◆ ${category}${C.reset}`);
427
+ for (const cmd of cmds) {
428
+ const cmdInfo = COMMANDS[cmd];
429
+ if (cmdInfo) {
430
+ console.log(` ${code(cmd.padEnd(18))} ${C.dim}${cmdInfo.description}${C.reset}`);
431
+ }
432
+ }
433
+ console.log();
434
+ }
435
+
436
+ console.log(` ${C.cyan}◆ Quick Start${C.reset}\n`);
437
+ console.log(` ${C.dim}$${C.reset} ${code('aether doctor')} ${C.dim}# Check system requirements${C.reset}`);
438
+ console.log(` ${C.dim}$${C.reset} ${code('aether init')} ${C.dim}# Start validator onboarding${C.reset}`);
439
+ console.log(` ${C.dim}$${C.reset} ${code('aether wallet create')} ${C.dim}# Create a new wallet${C.reset}`);
440
+ console.log(` ${C.dim}$${C.reset} ${code('aether network')} ${C.dim}# Check network status${C.reset}`);
441
+ console.log(` ${C.dim}$${C.reset} ${code('aether sdk getSlot')} ${C.dim}# Query current slot via SDK${C.reset}`);
442
+ console.log();
443
+
444
+ console.log(` ${C.dim}Documentation: ${C.cyan}https://github.com/jelly-legs-ai/Jelly-legs-unsteady-workshop${C.reset}\n`);
445
+ }
446
+
447
+ /**
448
+ * Parse command line arguments
449
+ */
450
+ function parseArgs() {
451
+ const args = process.argv.slice(2);
452
+
453
+ // Handle version flags
454
+ if (args.includes('--version') || args.includes('-v') || args.includes('-V')) {
455
+ return 'cli-version';
456
+ }
457
+
458
+ // No args → interactive menu
459
+ if (args.length === 0) {
460
+ return 'start';
461
+ }
462
+
463
+ // Handle multi-word commands (e.g., "validator start")
464
+ if (args.length >= 2) {
465
+ const multiCmd = `${args[0]} ${args[1]}`;
466
+ if (COMMANDS[multiCmd]) {
467
+ return multiCmd;
468
+ }
469
+ }
470
+
471
+ // Handle single word commands
472
+ return args[0] || 'help';
473
+ }
474
+
475
+ /**
476
+ * Main CLI entry point
477
+ */
478
+ function main() {
479
+ const command = parseArgs();
480
+
481
+ if (COMMANDS[command]) {
482
+ try {
483
+ COMMANDS[command].handler();
484
+ } catch (err) {
485
+ console.error(`\n ${error(`Command failed: ${err.message}`)}\n`);
486
+ process.exit(1);
487
+ }
488
+ } else {
489
+ console.error(`\n ${error(`Unknown command: ${command}`)}`);
490
+ console.log(` ${C.dim}Run "aether help" to see available commands.${C.reset}\n`);
491
+ process.exit(1);
492
+ }
493
+ }
494
+
495
+ // Run CLI only if executed directly
496
+ if (require.main === module) {
497
+ main();
498
+ }
499
+
500
+ // Export for module use
501
+ module.exports = { main, showHelp, COMMANDS, VERSION };