aether-hub 1.2.7 → 1.2.8
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 +280 -280
- package/commands/apy.js +480 -480
- package/commands/balance.js +276 -276
- package/commands/claim.js +292 -292
- package/commands/delegations.js +45 -95
- package/commands/emergency.js +14 -4
- package/commands/epoch.js +275 -275
- package/commands/fees.js +276 -276
- package/commands/info.js +495 -495
- package/commands/monitor.js +431 -431
- package/commands/multisig.js +726 -726
- package/commands/network.js +429 -429
- package/commands/ping.js +266 -266
- package/commands/sdk-test.js +477 -477
- package/commands/sdk.js +537 -537
- package/commands/slot.js +155 -0
- package/commands/snapshot.js +509 -509
- package/commands/stake-positions.js +31 -46
- package/commands/stats.js +418 -418
- package/commands/status.js +326 -326
- package/commands/supply.js +3 -1
- package/commands/tps.js +238 -238
- package/commands/tx-history.js +346 -462
- package/commands/wallet.js +3 -0
- package/index.js +11 -2
- package/package.json +1 -1
package/commands/slot.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* aether-cli slot
|
|
4
|
+
*
|
|
5
|
+
* Get current slot number from the Aether blockchain.
|
|
6
|
+
* Uses @jellylegsai/aether-sdk for REAL HTTP RPC calls.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* aether slot Show current slot
|
|
10
|
+
* aether slot --json JSON output for scripting
|
|
11
|
+
* aether slot --rpc <url> Custom RPC endpoint
|
|
12
|
+
*
|
|
13
|
+
* RPC Endpoint: GET /v1/slot
|
|
14
|
+
* SDK Function: sdk.getSlot()
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const path = require('path');
|
|
18
|
+
|
|
19
|
+
// ANSI colours
|
|
20
|
+
const C = {
|
|
21
|
+
reset: '\x1b[0m',
|
|
22
|
+
bright: '\x1b[1m',
|
|
23
|
+
dim: '\x1b[2m',
|
|
24
|
+
red: '\x1b[31m',
|
|
25
|
+
green: '\x1b[32m',
|
|
26
|
+
yellow: '\x1b[33m',
|
|
27
|
+
cyan: '\x1b[36m',
|
|
28
|
+
magenta: '\x1b[35m',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const CLI_VERSION = '1.0.0';
|
|
32
|
+
|
|
33
|
+
// Import SDK — makes REAL HTTP RPC calls to the blockchain
|
|
34
|
+
const sdkPath = path.join(__dirname, '..', 'sdk', 'index.js');
|
|
35
|
+
const aether = require(sdkPath);
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Helpers
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
function getDefaultRpc() {
|
|
42
|
+
return process.env.AETHER_RPC || aether.DEFAULT_RPC_URL || 'http://127.0.0.1:8899';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function createClient(rpc) {
|
|
46
|
+
return new aether.AetherClient({ rpcUrl: rpc });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Argument parsing
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
function parseArgs() {
|
|
54
|
+
const args = process.argv.slice(2);
|
|
55
|
+
return {
|
|
56
|
+
rpc: getDefaultRpc(),
|
|
57
|
+
asJson: args.includes('--json') || args.includes('-j'),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Slot query - REAL RPC call via SDK
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
async function fetchSlot(rpc) {
|
|
66
|
+
const client = createClient(rpc);
|
|
67
|
+
|
|
68
|
+
// Real RPC call: GET /v1/slot
|
|
69
|
+
// SDK function: client.getSlot()
|
|
70
|
+
const slot = await client.getSlot();
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
slot,
|
|
74
|
+
rpc,
|
|
75
|
+
timestamp: new Date().toISOString(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Output formatters
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
function printSlot(data) {
|
|
84
|
+
const { slot, rpc } = data;
|
|
85
|
+
|
|
86
|
+
console.log(`\n${C.bright}${C.cyan}── Aether Current Slot ──────────────────────────────────${C.reset}\n`);
|
|
87
|
+
console.log(` ${C.bright}Slot:${C.reset} ${C.green}${slot.toLocaleString()}${C.reset}`);
|
|
88
|
+
console.log(` ${C.dim}RPC:${C.reset} ${rpc}`);
|
|
89
|
+
console.log(` ${C.dim}Time:${C.reset} ${data.timestamp}${C.reset}\n`);
|
|
90
|
+
|
|
91
|
+
// Context info
|
|
92
|
+
console.log(` ${C.dim}RPC Endpoint: GET /v1/slot${C.reset}`);
|
|
93
|
+
console.log(` ${C.dim}SDK Function: sdk.getSlot()${C.reset}\n`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function printJson(data) {
|
|
97
|
+
console.log(JSON.stringify({
|
|
98
|
+
slot: data.slot,
|
|
99
|
+
rpc: data.rpc,
|
|
100
|
+
timestamp: data.timestamp,
|
|
101
|
+
cli_version: CLI_VERSION,
|
|
102
|
+
sdk: '@jellylegsai/aether-sdk',
|
|
103
|
+
rpc_endpoint: 'GET /v1/slot',
|
|
104
|
+
}, null, 2));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
// Main command
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
async function slotCommand() {
|
|
112
|
+
const options = parseArgs();
|
|
113
|
+
const { rpc, asJson } = options;
|
|
114
|
+
|
|
115
|
+
if (!asJson) {
|
|
116
|
+
console.log(`${C.dim}Fetching current slot from ${C.cyan}${rpc}${C.dim}...${C.reset}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
// Real blockchain RPC call via SDK
|
|
121
|
+
const data = await fetchSlot(rpc);
|
|
122
|
+
|
|
123
|
+
if (asJson) {
|
|
124
|
+
printJson(data);
|
|
125
|
+
} else {
|
|
126
|
+
printSlot(data);
|
|
127
|
+
}
|
|
128
|
+
} catch (err) {
|
|
129
|
+
if (asJson) {
|
|
130
|
+
console.log(JSON.stringify({
|
|
131
|
+
error: err.message,
|
|
132
|
+
rpc,
|
|
133
|
+
timestamp: new Date().toISOString(),
|
|
134
|
+
}));
|
|
135
|
+
} else {
|
|
136
|
+
console.log(`\n${C.red}✗ Failed to fetch slot: ${err.message}${C.reset}`);
|
|
137
|
+
console.log(` ${C.dim}RPC: ${rpc}${C.reset}`);
|
|
138
|
+
console.log(` ${C.dim}Make sure the Aether node is running at ${rpc}${C.reset}\n`);
|
|
139
|
+
}
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// Exports
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
module.exports = { slotCommand };
|
|
149
|
+
|
|
150
|
+
if (require.main === module) {
|
|
151
|
+
slotCommand().catch(err => {
|
|
152
|
+
console.error(`${C.red}Slot command failed:${C.reset} ${err.message}`);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
});
|
|
155
|
+
}
|