@jellylegsai/aether-cli 1.8.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/LICENSE +21 -0
- package/README.md +110 -0
- package/aether-cli-1.0.0.tgz +0 -0
- package/aether-cli-1.8.0.tgz +0 -0
- package/aether-hub-1.0.5.tgz +0 -0
- package/aether-hub-1.1.8.tgz +0 -0
- package/aether-hub-1.2.1.tgz +0 -0
- package/commands/account.js +280 -0
- package/commands/apy.js +499 -0
- package/commands/balance.js +241 -0
- package/commands/blockhash.js +181 -0
- package/commands/broadcast.js +387 -0
- package/commands/claim.js +490 -0
- package/commands/config.js +851 -0
- package/commands/delegations.js +582 -0
- package/commands/doctor.js +769 -0
- package/commands/emergency.js +667 -0
- package/commands/epoch.js +275 -0
- package/commands/fees.js +276 -0
- package/commands/index.js +78 -0
- package/commands/info.js +495 -0
- package/commands/init.js +816 -0
- package/commands/install.js +666 -0
- package/commands/kyc.js +272 -0
- package/commands/logs.js +315 -0
- package/commands/monitor.js +431 -0
- package/commands/multisig.js +701 -0
- package/commands/network.js +429 -0
- package/commands/nft.js +857 -0
- package/commands/ping.js +266 -0
- package/commands/price.js +253 -0
- package/commands/rewards.js +931 -0
- package/commands/sdk-test.js +477 -0
- package/commands/sdk.js +656 -0
- package/commands/slot.js +155 -0
- package/commands/snapshot.js +470 -0
- package/commands/stake-info.js +139 -0
- package/commands/stake-positions.js +205 -0
- package/commands/stake.js +516 -0
- package/commands/stats.js +396 -0
- package/commands/status.js +327 -0
- package/commands/supply.js +391 -0
- package/commands/tps.js +238 -0
- package/commands/transfer.js +495 -0
- package/commands/tx-history.js +346 -0
- package/commands/unstake.js +597 -0
- package/commands/validator-info.js +657 -0
- package/commands/validator-register.js +593 -0
- package/commands/validator-start.js +323 -0
- package/commands/validator-status.js +227 -0
- package/commands/validators.js +626 -0
- package/commands/wallet.js +1570 -0
- package/index.js +593 -0
- package/lib/errors.js +398 -0
- package/package.json +76 -0
- package/sdk/README.md +210 -0
- package/sdk/index.js +1639 -0
- package/sdk/package.json +34 -0
- package/sdk/rpc.js +254 -0
- package/sdk/test.js +85 -0
- package/test/doctor.test.js +76 -0
- package/validator-identity.json +4 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* aether-cli network - Aether Network Status
|
|
4
|
+
*
|
|
5
|
+
* Queries the Aether network for broad health metrics:
|
|
6
|
+
* - Network-wide slot, block height, slot production
|
|
7
|
+
* - Connected peers and their info
|
|
8
|
+
* - Consensus status and epoch info
|
|
9
|
+
* - TPS estimates from the network
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* aether-cli network # Interactive summary view
|
|
13
|
+
* aether-cli network --json # JSON output for scripting
|
|
14
|
+
* aether-cli network --rpc <url> # Query a specific RPC endpoint
|
|
15
|
+
* aether-cli network --peers # Detailed peer list
|
|
16
|
+
* aether-cli network --epoch # Current epoch and consensus info
|
|
17
|
+
*
|
|
18
|
+
* Uses @jellylegsai/aether-sdk for real blockchain RPC calls to http://127.0.0.1:8899
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// ANSI colours
|
|
22
|
+
const C = {
|
|
23
|
+
reset: '\x1b[0m',
|
|
24
|
+
bright: '\x1b[1m',
|
|
25
|
+
dim: '\x1b[2m',
|
|
26
|
+
red: '\x1b[31m',
|
|
27
|
+
green: '\x1b[32m',
|
|
28
|
+
yellow: '\x1b[33m',
|
|
29
|
+
blue: '\x1b[34m',
|
|
30
|
+
cyan: '\x1b[36m',
|
|
31
|
+
magenta: '\x1b[35m',
|
|
32
|
+
white: '\x1b[37m',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Import SDK for real blockchain RPC calls
|
|
36
|
+
const path = require('path');
|
|
37
|
+
const sdkPath = path.join(__dirname, '..', 'sdk', 'index.js');
|
|
38
|
+
const aether = require(sdkPath);
|
|
39
|
+
|
|
40
|
+
const DEFAULT_RPC = process.env.AETHER_RPC || aether.DEFAULT_RPC_URL || 'http://127.0.0.1:8899';
|
|
41
|
+
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Argument parsing
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
function parseArgs() {
|
|
47
|
+
const args = process.argv.slice(2);
|
|
48
|
+
const options = {
|
|
49
|
+
rpc: DEFAULT_RPC,
|
|
50
|
+
showPeers: false,
|
|
51
|
+
showEpoch: false,
|
|
52
|
+
asJson: false,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
for (let i = 0; i < args.length; i++) {
|
|
56
|
+
if (args[i] === '--rpc' || args[i] === '-r') {
|
|
57
|
+
options.rpc = args[++i];
|
|
58
|
+
} else if (args[i] === '--peers' || args[i] === '-p') {
|
|
59
|
+
options.showPeers = true;
|
|
60
|
+
} else if (args[i] === '--epoch' || args[i] === '-e') {
|
|
61
|
+
options.showEpoch = true;
|
|
62
|
+
} else if (args[i] === '--json' || args[i] === '-j') {
|
|
63
|
+
options.asJson = true;
|
|
64
|
+
} else if (args[i] === '--help' || args[i] === '-h') {
|
|
65
|
+
showHelp();
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return options;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function showHelp() {
|
|
74
|
+
console.log(`
|
|
75
|
+
${C.bright}${C.cyan}aether-cli network${C.reset} - Aether Network Status
|
|
76
|
+
|
|
77
|
+
${C.bright}Usage:${C.reset}
|
|
78
|
+
aether-cli network [options]
|
|
79
|
+
|
|
80
|
+
${C.bright}Options:${C.reset}
|
|
81
|
+
-r, --rpc <url> RPC endpoint (default: ${DEFAULT_RPC} or $AETHER_RPC)
|
|
82
|
+
-p, --peers Show detailed peer list
|
|
83
|
+
-e, --epoch Show epoch and consensus information
|
|
84
|
+
-j, --json Output raw JSON (good for scripting)
|
|
85
|
+
-h, --help Show this help message
|
|
86
|
+
|
|
87
|
+
${C.bright}Examples:${C.reset}
|
|
88
|
+
aether-cli network # Summary view
|
|
89
|
+
aether-cli network --json # JSON output
|
|
90
|
+
aether-cli network --rpc http://api.testnet.aether.network
|
|
91
|
+
aether-cli network --peers # Detailed peer list
|
|
92
|
+
aether-cli network --epoch # Epoch/consensus info
|
|
93
|
+
`.trim());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Network data fetchers using SDK (real blockchain RPC calls)
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
/** Create SDK client for custom RPC */
|
|
101
|
+
function createClient(rpc) {
|
|
102
|
+
return new aether.AetherClient({ rpcUrl: rpc });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** GET /v1/slot — current network slot (via SDK) */
|
|
106
|
+
async function getSlot(rpc) {
|
|
107
|
+
try {
|
|
108
|
+
const client = createClient(rpc);
|
|
109
|
+
return await client.getSlot();
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** GET /v1/blockheight — current network block height (via SDK) */
|
|
116
|
+
async function getBlockHeight(rpc) {
|
|
117
|
+
try {
|
|
118
|
+
const client = createClient(rpc);
|
|
119
|
+
return await client.getBlockHeight();
|
|
120
|
+
} catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** GET /v1/validators — list of validators / peers (via SDK) */
|
|
126
|
+
async function getValidators(rpc) {
|
|
127
|
+
try {
|
|
128
|
+
const client = createClient(rpc);
|
|
129
|
+
return await client.getValidators();
|
|
130
|
+
} catch {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** GET /v1/epoch — current epoch and consensus info (via SDK) */
|
|
136
|
+
async function getEpoch(rpc) {
|
|
137
|
+
try {
|
|
138
|
+
const client = createClient(rpc);
|
|
139
|
+
return await client.getEpochInfo();
|
|
140
|
+
} catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** POST /v1/slot_production — slot production stats (via SDK) */
|
|
146
|
+
async function getSlotProduction(rpc) {
|
|
147
|
+
try {
|
|
148
|
+
const client = createClient(rpc);
|
|
149
|
+
return await client.getSlotProduction();
|
|
150
|
+
} catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** GET /v1/tps — TPS estimate from network (via SDK) */
|
|
156
|
+
async function getTPS(rpc) {
|
|
157
|
+
try {
|
|
158
|
+
const client = createClient(rpc);
|
|
159
|
+
return await client.getTPS();
|
|
160
|
+
} catch {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** GET /v1/supply — token supply info (via SDK) */
|
|
166
|
+
async function getSupply(rpc) {
|
|
167
|
+
try {
|
|
168
|
+
const client = createClient(rpc);
|
|
169
|
+
return await client.getSupply();
|
|
170
|
+
} catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
// Output formatters
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
function formatNumber(n) {
|
|
180
|
+
if (n === null || n === undefined) return 'N/A';
|
|
181
|
+
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function peerHealthIcon(score) {
|
|
185
|
+
if (score === undefined || score === null) return `${C.dim}●${C.reset}`;
|
|
186
|
+
if (score >= 80) return `${C.green}●${C.reset}`;
|
|
187
|
+
if (score >= 50) return `${C.yellow}●${C.reset}`;
|
|
188
|
+
return `${C.red}●${C.reset}`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function uptimeString(seconds) {
|
|
192
|
+
if (!seconds) return `${C.dim}unknown${C.reset}`;
|
|
193
|
+
const d = Math.floor(seconds / 86400);
|
|
194
|
+
const h = Math.floor((seconds % 86400) / 3600);
|
|
195
|
+
const m = Math.floor((seconds % 3600) / 60);
|
|
196
|
+
const parts = [];
|
|
197
|
+
if (d > 0) parts.push(`${d}d`);
|
|
198
|
+
if (h > 0) parts.push(`${h}h`);
|
|
199
|
+
if (m > 0) parts.push(`${m}m`);
|
|
200
|
+
return parts.length > 0 ? parts.join(' ') : `${seconds}s`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
// Main renderers
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
function renderSummary(data, rpc) {
|
|
208
|
+
const { slot, blockHeight, peerCount, tps, supply, epochData } = data;
|
|
209
|
+
const now = new Date().toLocaleTimeString();
|
|
210
|
+
|
|
211
|
+
console.log(`
|
|
212
|
+
${C.bright}${C.cyan}╔═══════════════════════════════════════════════════════════════════╗${C.reset}
|
|
213
|
+
${C.bright}${C.cyan}║${C.reset} ${C.bright}AETHER NETWORK STATUS${C.reset}${C.cyan} ║${C.reset}
|
|
214
|
+
${C.bright}${C.cyan}╚═══════════════════════════════════════════════════════════════════╝${C.reset}
|
|
215
|
+
`);
|
|
216
|
+
console.log(` ${C.dim}RPC:${C.reset} ${rpc}`);
|
|
217
|
+
console.log(` ${C.dim}Updated:${C.reset} ${now}`);
|
|
218
|
+
console.log();
|
|
219
|
+
|
|
220
|
+
// Network health
|
|
221
|
+
const isHealthy = slot !== null && blockHeight !== null;
|
|
222
|
+
const healthIcon = isHealthy ? `${C.green}● HEALTHY${C.reset}` : `${C.red}● UNHEALTHY${C.reset}`;
|
|
223
|
+
console.log(` Network ${healthIcon}`);
|
|
224
|
+
console.log();
|
|
225
|
+
|
|
226
|
+
// Key metrics
|
|
227
|
+
console.log(` ${C.bright}┌─────────────────────────────────────────────────────────────────┐${C.reset}`);
|
|
228
|
+
console.log(` ${C.bright}│${C.reset} ${C.cyan}Current Slot${C.reset} ${C.bright}│${C.reset} ${C.green}${formatNumber(slot).padEnd(20)}${C.reset}${C.bright}│${C.reset}`);
|
|
229
|
+
console.log(` ${C.bright}│${C.reset} ${C.cyan}Block Height${C.reset} ${C.bright}│${C.reset} ${C.blue}${formatNumber(blockHeight).padEnd(20)}${C.reset}${C.bright}│${C.reset}`);
|
|
230
|
+
console.log(` ${C.bright}│${C.reset} ${C.cyan}Active Peers${C.reset} ${C.bright}│${C.reset} ${C.magenta}${formatNumber(peerCount).padEnd(20)}${C.reset}${C.bright}│${C.reset}`);
|
|
231
|
+
console.log(` ${C.bright}│${C.reset} ${C.cyan}Network TPS${C.reset} ${C.bright}│${C.reset} ${tps !== null ? (tps > 0 ? `${C.green}` : `${C.yellow}`) + tps.toFixed(2).padEnd(20) : `${C.dim}N/A`.padEnd(20)}${C.reset}${C.bright}│${C.reset}`);
|
|
232
|
+
console.log(` ${C.bright}└─────────────────────────────────────────────────────────────────┘${C.reset}`);
|
|
233
|
+
console.log();
|
|
234
|
+
|
|
235
|
+
// Epoch info if available
|
|
236
|
+
if (epochData && (epochData.epoch !== undefined || epochData.absolute_slot !== undefined)) {
|
|
237
|
+
console.log(` ${C.bright}── Epoch / Consensus ──────────────────────────────────────────${C.reset}`);
|
|
238
|
+
const ep = epochData.epoch !== undefined ? epochData.epoch : '?';
|
|
239
|
+
const slotIndex = epochData.slot_index !== undefined ? epochData.slot_index : '?';
|
|
240
|
+
const slotsInEpoch = epochData.slots_in_epoch !== undefined ? epochData.slots_in_epoch : '?';
|
|
241
|
+
const progress = slotsInEpoch !== '?' && slotsInEpoch > 0
|
|
242
|
+
? ((slotIndex / slotsInEpoch) * 100).toFixed(1) + '%'
|
|
243
|
+
: '?';
|
|
244
|
+
|
|
245
|
+
console.log(` ${C.dim}Epoch:${C.reset} ${C.bright}${ep}${C.reset} ${C.dim}Slot in epoch:${C.reset} ${slotIndex}/${slotsInEpoch} ${C.dim}(${progress})${C.reset}`);
|
|
246
|
+
if (epochData.absolute_slot !== undefined) {
|
|
247
|
+
console.log(` ${C.dim}Absolute slot:${C.reset} ${formatNumber(epochData.absolute_slot)}`);
|
|
248
|
+
}
|
|
249
|
+
if (epochData.block_height !== undefined) {
|
|
250
|
+
console.log(` ${C.dim}Block height:${C.reset} ${formatNumber(epochData.block_height)}`);
|
|
251
|
+
}
|
|
252
|
+
console.log();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Supply if available
|
|
256
|
+
if (supply && !supply.error) {
|
|
257
|
+
console.log(` ${C.bright}── Token Supply ───────────────────────────────────────────────${C.reset}`);
|
|
258
|
+
if (supply.total !== undefined) {
|
|
259
|
+
const totalAETH = (supply.total / 1e9).toFixed(2);
|
|
260
|
+
console.log(` ${C.dim}Total supply:${C.reset} ${C.green}${formatNumber(supply.total)} lamports${C.reset} ${C.dim}(${totalAETH} AETH)${C.reset}`);
|
|
261
|
+
}
|
|
262
|
+
if (supply.circulating !== undefined) {
|
|
263
|
+
const circAETH = (supply.circulating / 1e9).toFixed(2);
|
|
264
|
+
console.log(` ${C.dim}Circulating:${C.reset} ${formatNumber(supply.circulating)} lamports ${C.dim}(${circAETH} AETH)${C.reset}`);
|
|
265
|
+
}
|
|
266
|
+
console.log();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
console.log(` ${C.dim}Tip: --peers for peer list | --epoch for consensus | --json for raw data${C.reset}`);
|
|
270
|
+
console.log();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function renderPeers(peers, rpc) {
|
|
274
|
+
console.log();
|
|
275
|
+
console.log(`${C.bright}${C.cyan}── Peer List ─────────────────────────────────────────────────${C.reset}`);
|
|
276
|
+
console.log(` ${C.dim}RPC: ${rpc}${C.reset}`);
|
|
277
|
+
console.log();
|
|
278
|
+
|
|
279
|
+
if (!peers || peers.length === 0) {
|
|
280
|
+
console.log(` ${C.yellow}⚠ No peer information available from this RPC.${C.reset}`);
|
|
281
|
+
console.log(` ${C.dim} Peers may not be exposed by your validator's RPC configuration.${C.reset}`);
|
|
282
|
+
console.log();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
console.log(` ${C.bright}┌────────────────────────────────────────────────────────────────────────┐${C.reset}`);
|
|
287
|
+
console.log(` ${C.bright}│${C.reset} ${C.cyan}#${C.reset} ${C.cyan}Validator Address${C.reset} ${C.cyan}Tier${C.reset} ${C.cyan}Score${C.reset} ${C.cyan}Uptime${C.reset} ${C.bright}│${C.reset}`);
|
|
288
|
+
console.log(` ${C.bright}├${C.reset}${'-'.repeat(78)}${C.bright}│${C.reset}`);
|
|
289
|
+
|
|
290
|
+
peers.slice(0, 50).forEach((peer, i) => {
|
|
291
|
+
const num = (i + 1).toString().padStart(2);
|
|
292
|
+
const addr = (peer.address || peer.pubkey || peer.id || 'unknown').slice(0, 32).padEnd(34);
|
|
293
|
+
const tier = (peer.tier || peer.node_type || '?').toUpperCase().padEnd(6).slice(0, 6);
|
|
294
|
+
const score = peer.score !== undefined ? peer.score : (peer.uptime !== undefined ? Math.round(peer.uptime * 100) : null);
|
|
295
|
+
const scoreStr = score !== null ? `${score}%` : '?';
|
|
296
|
+
const uptime = uptimeString(peer.uptime_seconds || peer.uptime);
|
|
297
|
+
const scoreColor = score === null ? C.dim : score >= 80 ? C.green : score >= 50 ? C.yellow : C.red;
|
|
298
|
+
|
|
299
|
+
console.log(
|
|
300
|
+
` ${C.bright}│${C.reset} ${C.dim}${num}${C.reset} ${addr} ${tier.padEnd(6)} ${scoreColor}${(scoreStr + '%').padEnd(7)}${C.reset} ${C.dim}${uptime}${C.reset} ${C.bright}│${C.reset}`
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
if (peers.length > 50) {
|
|
305
|
+
console.log(` ${C.bright}│${C.reset} ${C.dim}... and ${peers.length - 50} more peers (use --json for full list)${C.reset}`.padEnd(80) + `${C.bright}│${C.reset}`);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
console.log(` ${C.bright}└────────────────────────────────────────────────────────────────────────┘${C.reset}`);
|
|
309
|
+
console.log();
|
|
310
|
+
console.log(` ${C.dim}Total peers: ${peers.length}${C.reset}`);
|
|
311
|
+
console.log();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function renderEpoch(epochData, rpc) {
|
|
315
|
+
console.log();
|
|
316
|
+
console.log(`${C.bright}${C.cyan}── Epoch / Consensus ────────────────────────────────────────${C.reset}`);
|
|
317
|
+
console.log(` ${C.dim}RPC: ${rpc}${C.reset}`);
|
|
318
|
+
console.log();
|
|
319
|
+
|
|
320
|
+
if (!epochData) {
|
|
321
|
+
console.log(` ${C.yellow}⚠ Epoch information not available.${C.reset}`);
|
|
322
|
+
console.log(` ${C.dim} Is your validator fully synced?${C.reset}`);
|
|
323
|
+
console.log();
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const t = (label, val) => console.log(` ${C.dim}${label}:${C.reset} ${val !== undefined && val !== null ? C.bright + val : C.dim + 'N/A'}${C.reset}`);
|
|
328
|
+
|
|
329
|
+
console.log(` ${C.bright}┌─────────────────────────────────────────────────────┐${C.reset}`);
|
|
330
|
+
console.log(` ${C.bright}│${C.reset} ${C.cyan}Epoch${C.reset}${' '.repeat(45)}${C.bright}│${C.reset}`);
|
|
331
|
+
const ep = epochData.epoch !== undefined ? epochData.epoch : '?';
|
|
332
|
+
console.log(` ${C.bright}│${C.reset} ${C.green}${(ep + '').padEnd(53)}${C.reset}${C.bright}│${C.reset}`);
|
|
333
|
+
console.log(` ${C.bright}├${C.reset}${'─'.repeat(58)}${C.bright}│${C.reset}`);
|
|
334
|
+
|
|
335
|
+
if (epochData.slots_in_epoch !== undefined) {
|
|
336
|
+
console.log(` ${C.bright}│${C.reset} ${C.dim}Slots in epoch${C.reset}`.padEnd(53) + `${C.bright}│${C.reset}`);
|
|
337
|
+
console.log(` ${C.bright}│${C.reset} ${C.bright}${formatNumber(epochData.slots_in_epoch).padEnd(53)}${C.reset}${C.bright}│${C.reset}`);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (epochData.slot_index !== undefined) {
|
|
341
|
+
console.log(` ${C.bright}│${C.reset} ${C.dim}Current slot in epoch${C.reset}`.padEnd(53) + `${C.bright}│${C.reset}`);
|
|
342
|
+
const progress = epochData.slots_in_epoch > 0
|
|
343
|
+
? `${epochData.slot_index} / ${epochData.slots_in_epoch} (${((epochData.slot_index / epochData.slots_in_epoch) * 100).toFixed(1)}%)`
|
|
344
|
+
: `${epochData.slot_index}`;
|
|
345
|
+
console.log(` ${C.bright}│${C.reset} ${C.bright}${progress.padEnd(53)}${C.reset}${C.bright}│${C.reset}`);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (epochData.absolute_slot !== undefined) {
|
|
349
|
+
console.log(` ${C.bright}│${C.reset} ${C.dim}Absolute slot${C.reset}`.padEnd(53) + `${C.bright}│${C.reset}`);
|
|
350
|
+
console.log(` ${C.bright}│${C.reset} ${C.bright}${formatNumber(epochData.absolute_slot).padEnd(53)}${C.reset}${C.bright}│${C.reset}`);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (epochData.block_height !== undefined) {
|
|
354
|
+
console.log(` ${C.bright}│${C.reset} ${C.dim}Block height${C.reset}`.padEnd(53) + `${C.bright}│${C.reset}`);
|
|
355
|
+
console.log(` ${C.bright}│${C.reset} ${C.bright}${formatNumber(epochData.block_height).padEnd(53)}${C.reset}${C.bright}│${C.reset}`);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (epochData.epoch_schedule) {
|
|
359
|
+
const es = epochData.epoch_schedule;
|
|
360
|
+
if (es.first_normal_epoch !== undefined) {
|
|
361
|
+
console.log(` ${C.bright}│${C.reset} ${C.dim}First normal epoch${C.reset}`.padEnd(53) + `${C.bright}│${C.reset}`);
|
|
362
|
+
console.log(` ${C.bright}│${C.reset} ${C.bright}${es.first_normal_epoch.padEnd(53)}${C.reset}${C.bright}│${C.reset}`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
console.log(` ${C.bright}└─────────────────────────────────────────────────────┘${C.reset}`);
|
|
367
|
+
console.log();
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// ---------------------------------------------------------------------------
|
|
371
|
+
// Main
|
|
372
|
+
// ---------------------------------------------------------------------------
|
|
373
|
+
|
|
374
|
+
async function main() {
|
|
375
|
+
const opts = parseArgs();
|
|
376
|
+
const rpc = opts.rpc;
|
|
377
|
+
|
|
378
|
+
if (!opts.asJson) {
|
|
379
|
+
console.log(`\n${C.cyan}Querying Aether network...${C.reset} ${C.dim}(${rpc})${C.reset}\n`);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Fetch all data in parallel
|
|
383
|
+
const [slot, blockHeight, validators, epochData, tps, supply] = await Promise.all([
|
|
384
|
+
getSlot(rpc),
|
|
385
|
+
getBlockHeight(rpc),
|
|
386
|
+
getValidators(rpc),
|
|
387
|
+
getEpoch(rpc),
|
|
388
|
+
getTPS(rpc),
|
|
389
|
+
getSupply(rpc),
|
|
390
|
+
]);
|
|
391
|
+
|
|
392
|
+
const peerCount = Array.isArray(validators) ? validators.length : 0;
|
|
393
|
+
|
|
394
|
+
const data = {
|
|
395
|
+
slot,
|
|
396
|
+
blockHeight,
|
|
397
|
+
peerCount,
|
|
398
|
+
tps,
|
|
399
|
+
supply,
|
|
400
|
+
epochData,
|
|
401
|
+
validators,
|
|
402
|
+
rpc,
|
|
403
|
+
fetchedAt: new Date().toISOString(),
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
if (opts.asJson) {
|
|
407
|
+
console.log(JSON.stringify(data, null, 2));
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (opts.showPeers) {
|
|
412
|
+
renderPeers(validators, rpc);
|
|
413
|
+
} else if (opts.showEpoch) {
|
|
414
|
+
renderEpoch(epochData, rpc);
|
|
415
|
+
} else {
|
|
416
|
+
renderSummary(data, rpc);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
module.exports = { main, networkCommand: main };
|
|
421
|
+
|
|
422
|
+
if (require.main === module) {
|
|
423
|
+
main().catch((err) => {
|
|
424
|
+
console.error(`\n${C.red}✗ Network command failed:${C.reset} ${err.message}`);
|
|
425
|
+
console.error(` ${C.dim}Check that your validator is running and RPC is accessible.${C.reset}`);
|
|
426
|
+
console.error(` ${C.dim}Set custom RPC: AETHER_RPC=http://your-rpc-url${C.reset}\n`);
|
|
427
|
+
process.exit(1);
|
|
428
|
+
});
|
|
429
|
+
}
|