aether-hub 1.2.5 → 1.2.7
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/commands/account.js +10 -34
- package/commands/balance.js +276 -0
- package/commands/blockhash.js +181 -0
- package/commands/broadcast.js +323 -323
- package/commands/claim.js +292 -0
- package/commands/emergency.js +657 -657
- package/commands/epoch.js +12 -94
- package/commands/fees.js +276 -0
- package/commands/info.js +38 -79
- package/commands/network.js +34 -108
- package/commands/ping.js +11 -65
- package/commands/price.js +253 -253
- package/commands/rewards.js +187 -4
- package/commands/sdk-test.js +477 -0
- package/commands/stake-info.js +139 -0
- package/commands/status.js +113 -157
- package/commands/supply.js +34 -82
- package/commands/tps.js +238 -0
- package/commands/transfer.js +495 -0
- package/commands/tx-history.js +462 -0
- package/commands/validator-info.js +10 -4
- package/commands/validator-start.js +1 -1
- package/commands/validator-status.js +32 -73
- package/commands/validators.js +36 -75
- package/commands/wallet.js +5 -29
- package/index.js +64 -17
- package/package.json +1 -3
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* aether-cli tx-history
|
|
4
|
+
*
|
|
5
|
+
* Fetch and display transaction history for an Aether wallet address.
|
|
6
|
+
* Shows recent transactions with type, amount, timestamp, fee, and status.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* aether tx history --address <addr> [--limit <n>] [--json] [--rpc <url>]
|
|
10
|
+
* aether history --address <addr> [--limit <n>] [--json]
|
|
11
|
+
*
|
|
12
|
+
* Examples:
|
|
13
|
+
* aether tx history --address ATHxxx
|
|
14
|
+
* aether tx history --address ATHxxx --limit 50 --json
|
|
15
|
+
* aether history --address ATHxxx --rpc https://rpc.aether.io
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const path = require('path');
|
|
19
|
+
|
|
20
|
+
// Import SDK for real blockchain RPC calls
|
|
21
|
+
const sdkPath = path.join(__dirname, '..', 'sdk', 'index.js');
|
|
22
|
+
const aether = require(sdkPath);
|
|
23
|
+
|
|
24
|
+
// ANSI colours
|
|
25
|
+
const C = {
|
|
26
|
+
reset: '\x1b[0m',
|
|
27
|
+
bright: '\x1b[1m',
|
|
28
|
+
dim: '\x1b[2m',
|
|
29
|
+
red: '\x1b[31m',
|
|
30
|
+
green: '\x1b[32m',
|
|
31
|
+
yellow: '\x1b[33m',
|
|
32
|
+
cyan: '\x1b[36m',
|
|
33
|
+
magenta: '\x1b[35m',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const CLI_VERSION = '1.0.0';
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// SDK helpers - Real blockchain RPC calls via Aether SDK
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
function getDefaultRpc() {
|
|
43
|
+
return process.env.AETHER_RPC || aether.DEFAULT_RPC_URL || 'http://127.0.0.1:8899';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function createClient(rpcUrl) {
|
|
47
|
+
return new aether.AetherClient({ rpcUrl });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// Argument parsing
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
function parseArgs() {
|
|
55
|
+
const args = process.argv.slice(2);
|
|
56
|
+
const result = { address: null, limit: 20, json: false, rpc: null };
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < args.length; i++) {
|
|
59
|
+
const arg = args[i];
|
|
60
|
+
if ((arg === '--address' || arg === '-a') && args[i + 1] && !args[i + 1].startsWith('-')) {
|
|
61
|
+
result.address = args[i + 1];
|
|
62
|
+
i++;
|
|
63
|
+
} else if ((arg === '--limit' || arg === '-l') && args[i + 1] && !args[i + 1].startsWith('-')) {
|
|
64
|
+
result.limit = parseInt(args[i + 1], 10);
|
|
65
|
+
i++;
|
|
66
|
+
} else if (arg === '--json' || arg === '--json-output') {
|
|
67
|
+
result.json = true;
|
|
68
|
+
} else if (arg === '--rpc' && args[i + 1] && !args[i + 1].startsWith('-')) {
|
|
69
|
+
result.rpc = args[i + 1];
|
|
70
|
+
i++;
|
|
71
|
+
} else if (arg === '--help' || arg === '-h') {
|
|
72
|
+
result.help = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Formatting helpers
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
function formatAether(lamports) {
|
|
84
|
+
if (lamports == null) return '—';
|
|
85
|
+
const aeth = lamports / 1e9;
|
|
86
|
+
if (aeth === 0) return '0 AETH';
|
|
87
|
+
return aeth.toFixed(4).replace(/\.?0+$/, '') + ' AETH';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function formatTimestamp(slot, blockTime) {
|
|
91
|
+
if (!blockTime) return '—';
|
|
92
|
+
try {
|
|
93
|
+
const d = new Date(blockTime * 1000);
|
|
94
|
+
return d.toISOString().replace('T', ' ').slice(0, 19);
|
|
95
|
+
} catch {
|
|
96
|
+
return String(blockTime);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function shortAddress(addr) {
|
|
101
|
+
if (!addr) return '—';
|
|
102
|
+
if (addr.length <= 16) return addr;
|
|
103
|
+
return addr.slice(0, 8) + '…' + addr.slice(-6);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function formatTxType(type) {
|
|
107
|
+
const t = (type || 'unknown').toLowerCase();
|
|
108
|
+
if (t.includes('transfer') || t.includes('send') || t.includes('payment')) return { label: 'TRANSFER', color: C.cyan };
|
|
109
|
+
if (t.includes('stake') || t.includes('delegate')) return { label: 'STAKE', color: C.green };
|
|
110
|
+
if (t.includes('unstake') || t.includes('deactivate')) return { label: 'UNSTAKE', color: C.yellow };
|
|
111
|
+
if (t.includes('reward') || t.includes('mint')) return { label: 'REWARD', color: C.magenta };
|
|
112
|
+
if (t.includes('vote')) return { label: 'VOTE', color: C.bright };
|
|
113
|
+
if (t.includes('create') || t.includes('initialize')) return { label: 'CREATE', color: C.bright };
|
|
114
|
+
if (t.includes('burn')) return { label: 'BURN', color: C.red };
|
|
115
|
+
return { label: type ? type.toUpperCase().slice(0, 10) : 'TX', color: C.dim };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function formatStatus(status) {
|
|
119
|
+
if (!status) return { label: '—', color: C.dim };
|
|
120
|
+
const s = status.toLowerCase();
|
|
121
|
+
if (s === 'success' || s === 'finalized' || s === 'confirmed') {
|
|
122
|
+
return { label: '✓ OK', color: C.green };
|
|
123
|
+
}
|
|
124
|
+
if (s === 'pending' || s === 'processing') {
|
|
125
|
+
return { label: '⏳', color: C.yellow };
|
|
126
|
+
}
|
|
127
|
+
if (s === 'failed') {
|
|
128
|
+
return { label: '✗ FAIL', color: C.red };
|
|
129
|
+
}
|
|
130
|
+
return { label: status.slice(0, 8), color: C.dim };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
// Core RPC calls
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Fetch confirmed transaction signatures for an address using getSignaturesForAddress.
|
|
139
|
+
*/
|
|
140
|
+
async function fetchTxSignatures(rpcUrl, address, limit) {
|
|
141
|
+
const body = {
|
|
142
|
+
jsonrpc: '2.0',
|
|
143
|
+
id: 1,
|
|
144
|
+
method: 'getSignaturesForAddress',
|
|
145
|
+
params: [
|
|
146
|
+
address,
|
|
147
|
+
{ limit },
|
|
148
|
+
],
|
|
149
|
+
};
|
|
150
|
+
return httpPost(rpcUrl, '/', body);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Fetch a specific confirmed transaction by signature.
|
|
155
|
+
*/
|
|
156
|
+
async function fetchTx(rpcUrl, signature) {
|
|
157
|
+
const body = {
|
|
158
|
+
jsonrpc: '2.0',
|
|
159
|
+
id: 1,
|
|
160
|
+
method: 'getTransaction',
|
|
161
|
+
params: [
|
|
162
|
+
signature,
|
|
163
|
+
{ encoding: 'jsonParsed', maxSupportedTransactionVersion: 0 },
|
|
164
|
+
],
|
|
165
|
+
};
|
|
166
|
+
return httpPost(rpcUrl, '/', body);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Parse a transaction result into a normalized display object.
|
|
171
|
+
*/
|
|
172
|
+
function parseTransaction(txResult, sigInfo) {
|
|
173
|
+
const blockTime = sigInfo.blockTime || txResult.blockTime;
|
|
174
|
+
const slot = sigInfo.slot;
|
|
175
|
+
const status = sigInfo.err ? 'failed' : (sigInfo.confirmationStatus || 'confirmed');
|
|
176
|
+
|
|
177
|
+
let txType = 'unknown';
|
|
178
|
+
let amount = 0;
|
|
179
|
+
let fee = txResult.meta?.fee || 0;
|
|
180
|
+
let fromAddr = null;
|
|
181
|
+
let toAddr = null;
|
|
182
|
+
let memo = null;
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
const msg = txResult.transaction?.message;
|
|
186
|
+
if (msg) {
|
|
187
|
+
// Parse instructions for transfer/stake types
|
|
188
|
+
const instructions = msg.instructions || [];
|
|
189
|
+
for (const ix of instructions) {
|
|
190
|
+
const programId = ix.programId || (ix.parsed && ix.parsed.info && ix.parsed.type);
|
|
191
|
+
// Native transfer
|
|
192
|
+
if (ix.parsed && ix.parsed.type === 'transfer') {
|
|
193
|
+
txType = 'transfer';
|
|
194
|
+
const info = ix.parsed.info;
|
|
195
|
+
fromAddr = info.source || info.from;
|
|
196
|
+
toAddr = info.destination || info.to;
|
|
197
|
+
amount = info.lamports || info.amount || 0;
|
|
198
|
+
} else if (ix.parsed && ix.parsed.type === 'stake') {
|
|
199
|
+
txType = 'stake';
|
|
200
|
+
const info = ix.parsed.info;
|
|
201
|
+
fromAddr = info.from || info.funder;
|
|
202
|
+
toAddr = info.validator;
|
|
203
|
+
amount = info.lamports || info.amount || 0;
|
|
204
|
+
} else if (ix.parsed && ix.parsed.type === 'withdrawStake') {
|
|
205
|
+
txType = 'unstake';
|
|
206
|
+
const info = ix.parsed.info;
|
|
207
|
+
toAddr = info.destination || info.withdrawer;
|
|
208
|
+
amount = info.lamports || info.amount || 0;
|
|
209
|
+
} else if (ix.parsed && ix.parsed.type === 'vote') {
|
|
210
|
+
txType = 'vote';
|
|
211
|
+
} else if (ix.parsed && ix.parsed.type === 'initialize') {
|
|
212
|
+
txType = 'initialize';
|
|
213
|
+
} else if (ix.parsed && ix.parsed.type === 'createAccount') {
|
|
214
|
+
txType = 'create';
|
|
215
|
+
} else if (ix.parsed && ix.parsed.type === 'approve') {
|
|
216
|
+
txType = 'stake';
|
|
217
|
+
const info = ix.parsed.info || {};
|
|
218
|
+
fromAddr = info.from || info.owner;
|
|
219
|
+
toAddr = info.stake;
|
|
220
|
+
amount = info.amount || info.lamports || 0;
|
|
221
|
+
} else if (ix.parsed && ix.parsed.type === 'delegate') {
|
|
222
|
+
txType = 'stake';
|
|
223
|
+
const info = ix.parsed.info || {};
|
|
224
|
+
fromAddr = info.stake || info.from;
|
|
225
|
+
toAddr = info.validator;
|
|
226
|
+
amount = info.lamports || 0;
|
|
227
|
+
} else if (ix.parsed && ix.parsed.type === 'withdraw') {
|
|
228
|
+
txType = 'unstake';
|
|
229
|
+
const info = ix.parsed.info || {};
|
|
230
|
+
toAddr = info.destination;
|
|
231
|
+
amount = info.lamports || 0;
|
|
232
|
+
}
|
|
233
|
+
// Check memo
|
|
234
|
+
if (ix.memo) memo = ix.memo;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Fallback: try legacy instructions if no parsed instructions
|
|
238
|
+
if (!instructions.length || instructions.every(ix => !ix.parsed)) {
|
|
239
|
+
for (const ix of instructions) {
|
|
240
|
+
if (ix.data === 'AAAA' || ix.data === '2ugJ4ELK3wW9qNXH' || !ix.data) {
|
|
241
|
+
txType = 'transfer';
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Compute fee
|
|
247
|
+
if (txResult.meta) {
|
|
248
|
+
fee = txResult.meta.fee || 0;
|
|
249
|
+
if (txResult.meta.postBalances && txResult.meta.preBalances) {
|
|
250
|
+
// Try to detect native transfer from balance changes
|
|
251
|
+
for (let i = 0; i < txResult.meta.postBalances.length; i++) {
|
|
252
|
+
const diff = txResult.meta.postBalances[i] - txResult.meta.preBalances[i];
|
|
253
|
+
if (diff < 0) {
|
|
254
|
+
amount = Math.abs(diff);
|
|
255
|
+
if (!fromAddr) fromAddr = msg.accountKeys?.[i];
|
|
256
|
+
} else if (diff > 0 && amount === 0) {
|
|
257
|
+
if (!toAddr) toAddr = msg.accountKeys?.[i];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} catch (e) {
|
|
264
|
+
// Parsing failed — use defaults
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
signature: sigInfo.signature || sigInfo.signatures?.[0],
|
|
269
|
+
slot,
|
|
270
|
+
blockTime,
|
|
271
|
+
status,
|
|
272
|
+
type: txType,
|
|
273
|
+
amount,
|
|
274
|
+
fee,
|
|
275
|
+
from: fromAddr,
|
|
276
|
+
to: toAddr,
|
|
277
|
+
memo,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// ---------------------------------------------------------------------------
|
|
282
|
+
// Display
|
|
283
|
+
// ---------------------------------------------------------------------------
|
|
284
|
+
|
|
285
|
+
function displayTxTable(txs) {
|
|
286
|
+
// Header
|
|
287
|
+
console.log(
|
|
288
|
+
`\n${C.bright}${C.cyan} ╔══════════════════════════════════════════════════════════════════════════════════════════╗${C.reset}\n` +
|
|
289
|
+
` ║${C.bright} ${C.cyan}Transaction History${C.reset}${C.bright} ║${C.reset}\n` +
|
|
290
|
+
` ${C.cyan}╚══════════════════════════════════════════════════════════════════════════════════════════${C.reset}`
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
if (txs.length === 0) {
|
|
294
|
+
console.log(`\n ${C.yellow}No transactions found for this address.${C.reset}\n`);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
console.log(
|
|
299
|
+
` ${C.dim}┌────┬──────────────────────┬──────────┬───────────────┬────────────┬────────┬───────────┐${C.reset}\n` +
|
|
300
|
+
` ${C.dim}│ # │ ${C.reset}Timestamp ${C.dim}│ ${C.reset}Type ${C.dim}│ ${C.reset}Amount ${C.dim}│ ${C.reset}From ${C.dim}│ ${C.reset}To ${C.dim}│ ${C.reset}Status ${C.dim}│${C.reset}`
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
for (let i = 0; i < txs.length; i++) {
|
|
304
|
+
const tx = txs[i];
|
|
305
|
+
const num = String(i + 1).padStart(3);
|
|
306
|
+
const time = formatTimestamp(tx.blockTime).slice(0, 19).padEnd(19);
|
|
307
|
+
const typeInfo = formatTxType(tx.type);
|
|
308
|
+
const type = typeInfo.label.padEnd(10);
|
|
309
|
+
const amt = tx.amount > 0 ? formatAether(tx.amount).padEnd(13) : '—'.padEnd(13);
|
|
310
|
+
const from = shortAddress(tx.from || '').padEnd(11);
|
|
311
|
+
const to = shortAddress(tx.to || '').padEnd(11);
|
|
312
|
+
const statusInfo = formatStatus(tx.status);
|
|
313
|
+
const status = statusInfo.label;
|
|
314
|
+
|
|
315
|
+
const bgAlt = (i % 2 === 0) ? '' : C.dim;
|
|
316
|
+
const reset = C.reset + bgAlt;
|
|
317
|
+
|
|
318
|
+
console.log(
|
|
319
|
+
` ${bgAlt}${C.dim}├────┼──────────────────────┼──────────┼───────────────┼────────────┼────────┼───────────┤${reset}`
|
|
320
|
+
);
|
|
321
|
+
console.log(
|
|
322
|
+
` ${bgAlt}${C.dim}│${reset} ${num} ${bgAlt}${C.dim}│ ${reset}${time} ${bgAlt}${C.dim}│ ${reset}${typeInfo.color}${type}${reset} ${bgAlt}${C.dim}│ ${reset}${amt} ${bgAlt}${C.dim}│ ${reset}${from} ${bgAlt}${C.dim}│ ${reset}${to} ${bgAlt}${C.dim}│ ${reset}${statusInfo.color}${status}${reset}${bgAlt} │${reset}`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
console.log(
|
|
327
|
+
` ${C.dim}└────┴──────────────────────┴──────────┴───────────────┴────────────┴────────┴───────────┘${C.reset}`
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
// Summary
|
|
331
|
+
const totalVolume = txs.reduce((sum, tx) => sum + tx.amount, 0);
|
|
332
|
+
const successCount = txs.filter(tx => tx.status !== 'failed').length;
|
|
333
|
+
console.log(`\n ${C.dim} ${txs.length} transactions · Total volume: ${C.reset}${C.bright}${formatAether(totalVolume)}${C.reset} ${C.dim}· Success: ${C.reset}${C.green}${successCount}/${txs.length}${C.reset} ${C.dim}· Failed: ${C.reset}${C.red}${(txs.length - successCount)}${C.reset}\n`);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function displayJson(txs, meta) {
|
|
337
|
+
console.log(JSON.stringify({
|
|
338
|
+
address: meta.address,
|
|
339
|
+
rpc: meta.rpc,
|
|
340
|
+
limit: meta.limit,
|
|
341
|
+
transaction_count: txs.length,
|
|
342
|
+
total_volume_lamports: txs.reduce((sum, tx) => sum + tx.amount, 0),
|
|
343
|
+
transactions: txs.map(tx => ({
|
|
344
|
+
signature: tx.signature,
|
|
345
|
+
slot: tx.slot,
|
|
346
|
+
timestamp: tx.blockTime ? new Date(tx.blockTime * 1000).toISOString() : null,
|
|
347
|
+
type: tx.type,
|
|
348
|
+
amount_lamports: tx.amount,
|
|
349
|
+
amount_aeth: (tx.amount / 1e9).toFixed(9),
|
|
350
|
+
fee_lamports: tx.fee,
|
|
351
|
+
from: tx.from,
|
|
352
|
+
to: tx.to,
|
|
353
|
+
memo: tx.memo,
|
|
354
|
+
status: tx.status,
|
|
355
|
+
})),
|
|
356
|
+
}, null, 2));
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// ---------------------------------------------------------------------------
|
|
360
|
+
// Main
|
|
361
|
+
// ---------------------------------------------------------------------------
|
|
362
|
+
|
|
363
|
+
async function main() {
|
|
364
|
+
const opts = parseArgs();
|
|
365
|
+
|
|
366
|
+
if (opts.help) {
|
|
367
|
+
console.log(`
|
|
368
|
+
${C.bright}${C.cyan}tx-history${C.reset} — Fetch and display transaction history for an Aether address
|
|
369
|
+
|
|
370
|
+
${C.bright}USAGE${C.reset}
|
|
371
|
+
aether tx history --address <addr> [--limit <n>] [--json] [--rpc <url>]
|
|
372
|
+
aether history --address <addr> [--limit <n>] [--json]
|
|
373
|
+
|
|
374
|
+
${C.bright}OPTIONS${C.reset}
|
|
375
|
+
--address <addr> Aether wallet address (ATH...)
|
|
376
|
+
--limit <n> Max transactions to fetch (default: 20, max: 100)
|
|
377
|
+
--json Output raw JSON for scripting
|
|
378
|
+
--rpc <url> RPC endpoint (default: AETHER_RPC or http://127.0.0.1:8899)
|
|
379
|
+
--help Show this help
|
|
380
|
+
|
|
381
|
+
${C.bright}EXAMPLES${C.reset}
|
|
382
|
+
aether tx history --address ATH3abc... --limit 50
|
|
383
|
+
aether tx history --address ATH3abc... --json
|
|
384
|
+
aether history --address ATH3abc... --rpc https://mainnet.aether.io
|
|
385
|
+
`);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (!opts.address) {
|
|
390
|
+
console.log(` ${C.red}✗ Missing --address${C.reset}\n`);
|
|
391
|
+
console.log(` Usage: aether tx history --address <addr> [--limit <n>] [--json]\n`);
|
|
392
|
+
process.exit(1);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const rpcUrl = opts.rpc || getDefaultRpc();
|
|
396
|
+
const limit = Math.min(Math.max(1, opts.limit || 20), 100);
|
|
397
|
+
|
|
398
|
+
if (!opts.json) {
|
|
399
|
+
console.log(`\n${C.bright}${C.cyan} Tx History${C.reset} · ${C.dim}address:${C.reset} ${opts.address} ${C.dim}· ${C.dim}limit:${C.reset} ${limit} ${C.dim}· ${C.dim}rpc:${C.reset} ${rpcUrl}\n`);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
try {
|
|
403
|
+
// Step 1: Get transaction signatures
|
|
404
|
+
const sigsResult = await fetchTxSignatures(rpcUrl, opts.address, limit);
|
|
405
|
+
|
|
406
|
+
if (sigsResult.error) {
|
|
407
|
+
throw new Error(sigsResult.error.message || JSON.stringify(sigsResult.error));
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const signatures = Array.isArray(sigsResult.result) ? sigsResult.result : [];
|
|
411
|
+
|
|
412
|
+
if (signatures.length === 0) {
|
|
413
|
+
if (!opts.json) {
|
|
414
|
+
displayTxTable([]);
|
|
415
|
+
} else {
|
|
416
|
+
displayJson([], { address: opts.address, rpc: rpcUrl, limit });
|
|
417
|
+
}
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Step 2: Fetch each transaction in parallel (up to 10 at a time)
|
|
422
|
+
const txResults = [];
|
|
423
|
+
const BATCH = 10;
|
|
424
|
+
|
|
425
|
+
for (let i = 0; i < signatures.length; i += BATCH) {
|
|
426
|
+
const batch = signatures.slice(i, i + BATCH);
|
|
427
|
+
const batchPromises = batch.map(sig => fetchTx(rpcUrl, sig.signature).catch(err => ({ error: err.message })));
|
|
428
|
+
const batchResults = await Promise.all(batchPromises);
|
|
429
|
+
txResults.push(...batchResults);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Step 3: Parse and normalize
|
|
433
|
+
const txs = txResults
|
|
434
|
+
.map((res, idx) => {
|
|
435
|
+
if (res.error) return null;
|
|
436
|
+
try {
|
|
437
|
+
return parseTransaction(res.result || {}, signatures[idx] || {});
|
|
438
|
+
} catch {
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
.filter(Boolean);
|
|
443
|
+
|
|
444
|
+
if (opts.json) {
|
|
445
|
+
displayJson(txs, { address: opts.address, rpc: rpcUrl, limit });
|
|
446
|
+
} else {
|
|
447
|
+
displayTxTable(txs);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
} catch (err) {
|
|
451
|
+
console.log(`\n ${C.red}✗ Failed to fetch transaction history:${C.reset} ${err.message}\n`);
|
|
452
|
+
if (err.stack && !opts.json) {
|
|
453
|
+
console.log(` ${C.dim}${err.stack.split('\n').slice(0, 3).join('\n ')}${C.reset}\n`);
|
|
454
|
+
}
|
|
455
|
+
process.exit(1);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// Run if called directly
|
|
460
|
+
if (require.main === module) {
|
|
461
|
+
main();
|
|
462
|
+
}
|
|
@@ -634,7 +634,13 @@ async function main() {
|
|
|
634
634
|
console.log();
|
|
635
635
|
}
|
|
636
636
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
637
|
+
// Export for module use
|
|
638
|
+
module.exports = { validatorInfo: main };
|
|
639
|
+
|
|
640
|
+
// Only run if called directly (not when required as module)
|
|
641
|
+
if (require.main === module) {
|
|
642
|
+
main().catch(err => {
|
|
643
|
+
console.error(`\n${C.red}✗ Validator info failed:${C.reset} ${err.message}\n`);
|
|
644
|
+
process.exit(1);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
@@ -254,7 +254,7 @@ function startValidatorProcess({ type, path: binaryPath, inPath }, options) {
|
|
|
254
254
|
if (options.testnet) {
|
|
255
255
|
validatorArgs.push('--testnet');
|
|
256
256
|
}
|
|
257
|
-
validatorArgs.push('--tier', options.tier);
|
|
257
|
+
validatorArgs.push('--tier', options.tier.toLowerCase());
|
|
258
258
|
validatorArgs.push('--rpc-addr', options.rpcAddr);
|
|
259
259
|
validatorArgs.push('--p2p-addr', options.p2pAddr);
|
|
260
260
|
if (options.identity) {
|
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Queries the validator's RPC endpoint and displays status information.
|
|
5
5
|
* Shows slot height, peer count, block production, and epoch info.
|
|
6
|
+
*
|
|
7
|
+
* Uses @jellylegsai/aether-sdk for real blockchain RPC calls.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
|
-
const
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
// Import SDK for real blockchain RPC calls
|
|
13
|
+
const sdkPath = path.join(__dirname, '..', 'sdk', 'index.js');
|
|
14
|
+
const aether = require(sdkPath);
|
|
9
15
|
|
|
10
16
|
// ANSI colors
|
|
11
17
|
const colors = {
|
|
@@ -19,54 +25,10 @@ const colors = {
|
|
|
19
25
|
};
|
|
20
26
|
|
|
21
27
|
/**
|
|
22
|
-
*
|
|
28
|
+
* Create SDK client
|
|
23
29
|
*/
|
|
24
|
-
function
|
|
25
|
-
return new
|
|
26
|
-
const urlObj = new URL(url);
|
|
27
|
-
|
|
28
|
-
const postData = JSON.stringify({
|
|
29
|
-
jsonrpc: '2.0',
|
|
30
|
-
id: 1,
|
|
31
|
-
method,
|
|
32
|
-
params,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const options = {
|
|
36
|
-
hostname: urlObj.hostname,
|
|
37
|
-
port: urlObj.port || 8899,
|
|
38
|
-
path: '/',
|
|
39
|
-
method: 'POST',
|
|
40
|
-
headers: {
|
|
41
|
-
'Content-Type': 'application/json',
|
|
42
|
-
'Content-Length': Buffer.byteLength(postData),
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const req = http.request(options, (res) => {
|
|
47
|
-
let data = '';
|
|
48
|
-
res.on('data', (chunk) => data += chunk);
|
|
49
|
-
res.on('end', () => {
|
|
50
|
-
try {
|
|
51
|
-
const json = JSON.parse(data);
|
|
52
|
-
if (json.error) {
|
|
53
|
-
reject(new Error(json.error.message || JSON.stringify(json.error)));
|
|
54
|
-
} else {
|
|
55
|
-
resolve(json.result);
|
|
56
|
-
}
|
|
57
|
-
} catch (e) {
|
|
58
|
-
reject(new Error(`Invalid JSON response: ${data}`));
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
req.on('error', (e) => {
|
|
64
|
-
reject(new Error(`Connection failed: ${e.message}`));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
req.write(postData);
|
|
68
|
-
req.end();
|
|
69
|
-
});
|
|
30
|
+
function createClient(rpcUrl) {
|
|
31
|
+
return new aether.AetherClient({ rpcUrl });
|
|
70
32
|
}
|
|
71
33
|
|
|
72
34
|
/**
|
|
@@ -181,24 +143,25 @@ async function validatorStatus() {
|
|
|
181
143
|
let epochInfo = {};
|
|
182
144
|
let blockProduction = {};
|
|
183
145
|
|
|
146
|
+
const client = createClient(options.rpcUrl);
|
|
147
|
+
|
|
184
148
|
try {
|
|
185
|
-
// Make parallel RPC calls
|
|
186
|
-
const [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
options.details ? rpcCall(options.rpcUrl, 'getBlockProduction').catch(e => ({})) : Promise.resolve({}),
|
|
149
|
+
// Make parallel RPC calls using SDK
|
|
150
|
+
const [slotResult, blockHeightResult, epochInfoResult, peersResult] = await Promise.all([
|
|
151
|
+
client.getSlot().catch(e => ({ error: e.message })),
|
|
152
|
+
client.getBlockHeight().catch(e => ({ error: e.message })),
|
|
153
|
+
client.getEpochInfo().catch(e => ({})),
|
|
154
|
+
client.getClusterPeers().catch(e => ([])),
|
|
192
155
|
]);
|
|
193
156
|
|
|
194
|
-
if (typeof
|
|
157
|
+
if (typeof slotResult === 'object' && slotResult.error) {
|
|
195
158
|
if (options.json) {
|
|
196
|
-
console.log(JSON.stringify({ error:
|
|
159
|
+
console.log(JSON.stringify({ error: slotResult.error }, null, 2));
|
|
197
160
|
process.exit(1);
|
|
198
161
|
}
|
|
199
162
|
console.log();
|
|
200
163
|
console.log(` ${colors.red}❌ Cannot connect to validator${colors.reset}`);
|
|
201
|
-
console.log(` ${colors.yellow}${
|
|
164
|
+
console.log(` ${colors.yellow}${slotResult.error}${colors.reset}`);
|
|
202
165
|
console.log();
|
|
203
166
|
console.log(` ${colors.bright}Start the validator first:${colors.reset}`);
|
|
204
167
|
console.log(` ${colors.cyan}aether-cli validator start${colors.reset}`);
|
|
@@ -206,26 +169,22 @@ async function validatorStatus() {
|
|
|
206
169
|
process.exit(1);
|
|
207
170
|
}
|
|
208
171
|
|
|
209
|
-
status.slot = typeof
|
|
210
|
-
status.blockHeight = typeof
|
|
211
|
-
status.transactionCount =
|
|
172
|
+
status.slot = typeof slotResult === 'number' ? slotResult : (slotResult.slot || 0);
|
|
173
|
+
status.blockHeight = typeof blockHeightResult === 'number' ? blockHeightResult : status.slot;
|
|
174
|
+
status.transactionCount = 0; // Transaction count not available via SDK
|
|
175
|
+
status.peerCount = Array.isArray(peersResult) ? peersResult.length : 0;
|
|
212
176
|
|
|
213
177
|
if (epochInfoResult && typeof epochInfoResult === 'object') {
|
|
214
178
|
epochInfo = epochInfoResult;
|
|
215
179
|
status.epoch = epochInfo.epoch || 0;
|
|
216
|
-
epochInfo.slotIndex = epochInfo.slotIndex || 0;
|
|
217
|
-
epochInfo.slotsInEpoch = epochInfo.slotsInEpoch || 432000;
|
|
180
|
+
epochInfo.slotIndex = epochInfo.slotIndex || epochInfo.slot_index || 0;
|
|
181
|
+
epochInfo.slotsInEpoch = epochInfo.slotsInEpoch || epochInfo.slots_in_epoch || 432000;
|
|
218
182
|
}
|
|
219
183
|
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// Get peer count
|
|
225
|
-
try {
|
|
226
|
-
status.peerCount = await rpcCall(options.rpcUrl, 'getPeerCount') || 0;
|
|
227
|
-
} catch (e) {
|
|
228
|
-
status.peerCount = 0;
|
|
184
|
+
if (options.details) {
|
|
185
|
+
try {
|
|
186
|
+
blockProduction = await client.getSlotProduction();
|
|
187
|
+
} catch { /* Block production not available */ }
|
|
229
188
|
}
|
|
230
189
|
|
|
231
190
|
if (options.json) {
|
|
@@ -260,7 +219,7 @@ async function validatorStatus() {
|
|
|
260
219
|
}
|
|
261
220
|
|
|
262
221
|
// Export for use as module
|
|
263
|
-
module.exports = { validatorStatus
|
|
222
|
+
module.exports = { validatorStatus };
|
|
264
223
|
|
|
265
224
|
// Run if called directly
|
|
266
225
|
if (require.main === module) {
|