aether-hub 1.0.3 → 1.0.6
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/sdk.js +537 -381
- package/commands/wallet.js +1139 -0
- package/index.js +52 -1
- package/package.json +3 -2
package/commands/sdk.js
CHANGED
|
@@ -1,381 +1,537 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* aether-cli sdk
|
|
3
|
-
*
|
|
4
|
-
* Provides download links and install instructions for the Aether SDK,
|
|
5
|
-
* Aether JS client, and FLUX/ATH token libraries.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* aether-cli sdk # Show all SDK options
|
|
9
|
-
* aether-cli sdk js # Aether JS client
|
|
10
|
-
* aether-cli sdk rust # Aether Rust SDK
|
|
11
|
-
* aether-cli sdk tokens # FLUX/ATH token libraries
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
${colors.cyan}
|
|
36
|
-
${colors.cyan}║
|
|
37
|
-
${colors.cyan}║ ${colors.bright}
|
|
38
|
-
${colors.cyan}║
|
|
39
|
-
${colors.cyan}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log(
|
|
49
|
-
console.log(`${colors.bright}
|
|
50
|
-
console.log(`${colors.bright}${
|
|
51
|
-
console.log();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.log(` ${colors.
|
|
60
|
-
console.log();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
console.log(`
|
|
69
|
-
console.log();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
console.log(` ${colors.yellow}npm${colors.reset} aether-cli sdk
|
|
82
|
-
console.log(` ${colors.yellow}npm${colors.reset} aether-cli sdk
|
|
83
|
-
console.log(` ${colors.yellow}npm${colors.reset} aether-cli sdk
|
|
84
|
-
console.log();
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
console.log(`
|
|
92
|
-
printCode('
|
|
93
|
-
console.log(`
|
|
94
|
-
|
|
95
|
-
console.log();
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
printLink('
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
console.log(`
|
|
112
|
-
|
|
113
|
-
console.log();
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
console.log(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
console.log(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
console.log(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
console.log('
|
|
146
|
-
|
|
147
|
-
console.log(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
console.log(` ${colors.dim}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
console.log(` ${colors.
|
|
186
|
-
console.log(` ${colors.
|
|
187
|
-
console.log(` ${colors.
|
|
188
|
-
console.log();
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
console.log();
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
console.log(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
console.log(` ${colors.dim}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
console.log(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
console.log(` ${colors.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
console.log();
|
|
251
|
-
console.log(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
printSection('
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
console.log(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
console.log(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
console.log();
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
console.log(`
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
printLink('
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
1
|
+
/**
|
|
2
|
+
* aether-cli sdk
|
|
3
|
+
*
|
|
4
|
+
* Provides download links and install instructions for the Aether SDK,
|
|
5
|
+
* Aether JS client, and FLUX/ATH token libraries.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* aether-cli sdk # Show all SDK options
|
|
9
|
+
* aether-cli sdk js # Aether JS client
|
|
10
|
+
* aether-cli sdk rust # Aether Rust SDK
|
|
11
|
+
* aether-cli sdk tokens # FLUX/ATH token libraries
|
|
12
|
+
* aether-cli sdk types # TypeScript/Rust type definitions for TX payloads
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const os = require('os');
|
|
16
|
+
|
|
17
|
+
// ANSI colors
|
|
18
|
+
const colors = {
|
|
19
|
+
reset: '\x1b[0m',
|
|
20
|
+
bright: '\x1b[1m',
|
|
21
|
+
green: '\x1b[32m',
|
|
22
|
+
yellow: '\x1b[33m',
|
|
23
|
+
cyan: '\x1b[36m',
|
|
24
|
+
red: '\x1b[31m',
|
|
25
|
+
dim: '\x1b[2m',
|
|
26
|
+
magenta: '\x1b[35m',
|
|
27
|
+
blue: '\x1b[34m',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Print the SDK banner
|
|
32
|
+
*/
|
|
33
|
+
function printBanner() {
|
|
34
|
+
console.log(`
|
|
35
|
+
${colors.cyan}╔═══════════════════════════════════════════════════════════════╗
|
|
36
|
+
${colors.cyan}║ ║
|
|
37
|
+
${colors.cyan}║ ${colors.bright}AETHER SDK${colors.reset}${colors.cyan} ║
|
|
38
|
+
${colors.cyan}║ ${colors.bright}Developer Tools & Libraries${colors.reset}${colors.cyan} ║
|
|
39
|
+
${colors.cyan}║ ║
|
|
40
|
+
${colors.cyan}╚═══════════════════════════════════════════════════════════════╝${colors.reset}
|
|
41
|
+
`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Print a section header
|
|
46
|
+
*/
|
|
47
|
+
function printSection(title, icon = '📦') {
|
|
48
|
+
console.log();
|
|
49
|
+
console.log(`${colors.bright}${colors.cyan}${'═'.repeat(60)}${colors.reset}`);
|
|
50
|
+
console.log(`${colors.bright} ${icon} ${title}${colors.reset}`);
|
|
51
|
+
console.log(`${colors.bright}${colors.cyan}${'═'.repeat(60)}${colors.reset}`);
|
|
52
|
+
console.log();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Print a code block
|
|
57
|
+
*/
|
|
58
|
+
function printCode(code, lang = 'bash') {
|
|
59
|
+
console.log(` ${colors.dim}[ ${lang} ]${colors.reset}`);
|
|
60
|
+
console.log(` ${colors.bright}${code}${colors.reset}`);
|
|
61
|
+
console.log();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Print a link
|
|
66
|
+
*/
|
|
67
|
+
function printLink(label, url) {
|
|
68
|
+
console.log(` ${colors.cyan}🔗 ${label}:${colors.reset}`);
|
|
69
|
+
console.log(` ${colors.blue}${url}${colors.reset}`);
|
|
70
|
+
console.log();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Show all SDK options
|
|
75
|
+
*/
|
|
76
|
+
function showAllSdks() {
|
|
77
|
+
printBanner();
|
|
78
|
+
|
|
79
|
+
console.log(` ${colors.bright}Available SDKs and Libraries:${colors.reset}\n`);
|
|
80
|
+
|
|
81
|
+
console.log(` ${colors.yellow}npm${colors.reset} aether-cli sdk js - JavaScript/TypeScript client`);
|
|
82
|
+
console.log(` ${colors.yellow}npm${colors.reset} aether-cli sdk rust - Rust SDK for native development`);
|
|
83
|
+
console.log(` ${colors.yellow}npm${colors.reset} aether-cli sdk tokens - FLUX/ATH token libraries`);
|
|
84
|
+
console.log(` ${colors.yellow}npm${colors.reset} aether-cli sdk docs - Documentation portal`);
|
|
85
|
+
console.log(` ${colors.yellow}npm${colors.reset} aether-cli sdk types - TypeScript/Rust type definitions`);
|
|
86
|
+
console.log();
|
|
87
|
+
|
|
88
|
+
// Quick start
|
|
89
|
+
printSection('⚡ Quick Start', '🚀');
|
|
90
|
+
console.log(' Get started with Aether development in 3 steps:\n');
|
|
91
|
+
console.log(` 1. ${colors.bright}Install the JS client:${colors.reset}`);
|
|
92
|
+
printCode('npm install @aether-network/client');
|
|
93
|
+
console.log(` 2. ${colors.bright}Initialize your connection:${colors.reset}`);
|
|
94
|
+
printCode('const aether = require(\'@aether-network/client\');\nconst client = new aether.Client({ rpcUrl: \'http://localhost:8899\' });');
|
|
95
|
+
console.log(` 3. ${colors.bright}Start building!${colors.reset}`);
|
|
96
|
+
console.log(` ${colors.dim}See docs for full API reference${colors.reset}`);
|
|
97
|
+
console.log();
|
|
98
|
+
|
|
99
|
+
printLink('Documentation', 'https://docs.aether.network');
|
|
100
|
+
printLink('GitHub Organization', 'https://github.com/aether-network');
|
|
101
|
+
printLink('Discord Community', 'https://discord.gg/aether');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Show JavaScript SDK info
|
|
106
|
+
*/
|
|
107
|
+
function showJsSdk() {
|
|
108
|
+
printSection('Aether JavaScript Client', '📜');
|
|
109
|
+
|
|
110
|
+
console.log(` ${colors.bright}The official Aether JavaScript/TypeScript client library.${colors.reset}`);
|
|
111
|
+
console.log(` Provides a simple API for interacting with the Aether blockchain.${colors.reset}\n`);
|
|
112
|
+
|
|
113
|
+
console.log(` ${colors.green}✓ Stable Release${colors.reset}`);
|
|
114
|
+
console.log(` ${colors.dim}Version: 1.2.0${colors.reset}`);
|
|
115
|
+
console.log();
|
|
116
|
+
|
|
117
|
+
printSection('Transaction Types');
|
|
118
|
+
console.log(` ${colors.cyan}Transfer${colors.reset} — ${colors.dim}Send AETH to another address${colors.reset}`);
|
|
119
|
+
console.log(` { recipient: string, amount: u64, nonce: u64 }`);
|
|
120
|
+
console.log();
|
|
121
|
+
console.log(` ${colors.cyan}Stake${colors.reset} — ${colors.dim}Delegate tokens to a validator${colors.reset}`);
|
|
122
|
+
console.log(` { validator: string, amount: u64 }`);
|
|
123
|
+
console.log();
|
|
124
|
+
console.log(` ${colors.cyan}Unstake${colors.reset} — ${colors.dim}Request withdrawal of staked tokens${colors.reset}`);
|
|
125
|
+
console.log(` { stake_account: string, amount: u64 }`);
|
|
126
|
+
console.log();
|
|
127
|
+
console.log(` ${colors.cyan}ClaimRewards${colors.reset} — ${colors.dim}Claim accumulated staking rewards${colors.reset}`);
|
|
128
|
+
console.log(` { stake_account: string }`);
|
|
129
|
+
console.log();
|
|
130
|
+
console.log(` ${colors.cyan}CreateNFT${colors.reset} — ${colors.dim}Create a new NFT on-chain${colors.reset}`);
|
|
131
|
+
console.log(` { metadata_url: string, royalties: u16 }`);
|
|
132
|
+
console.log();
|
|
133
|
+
console.log(` ${colors.cyan}MintNFT${colors.reset} — ${colors.dim}Mint additional supply of an existing NFT${colors.reset}`);
|
|
134
|
+
console.log(` { nft_id: string, amount: u64 }`);
|
|
135
|
+
console.log();
|
|
136
|
+
console.log(` ${colors.cyan}TransferNFT${colors.reset} — ${colors.dim}Transfer an NFT to another address${colors.reset}`);
|
|
137
|
+
console.log(` { nft_id: string, recipient: string }`);
|
|
138
|
+
console.log();
|
|
139
|
+
console.log(` ${colors.cyan}UpdateMetadata${colors.reset} — ${colors.dim}Update NFT metadata URL${colors.reset}`);
|
|
140
|
+
console.log(` { nft_id: string, metadata_url: string }`);
|
|
141
|
+
console.log();
|
|
142
|
+
|
|
143
|
+
printSection('Installation');
|
|
144
|
+
printCode('npm install @aether-network/client');
|
|
145
|
+
console.log(' or');
|
|
146
|
+
printCode('yarn add @aether-network/client');
|
|
147
|
+
console.log(' or');
|
|
148
|
+
printCode('pnpm add @aether-network/client');
|
|
149
|
+
|
|
150
|
+
printSection('Usage Example');
|
|
151
|
+
const example = `const aether = require('@aether-network/client');
|
|
152
|
+
|
|
153
|
+
// Initialize client
|
|
154
|
+
const client = new aether.Client({
|
|
155
|
+
rpcUrl: 'http://localhost:8899',
|
|
156
|
+
wsUrl: 'ws://localhost:8900',
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Get slot info
|
|
160
|
+
const slot = await client.getSlot();
|
|
161
|
+
console.log('Current slot:', slot);
|
|
162
|
+
|
|
163
|
+
// Get account info (includes balance)
|
|
164
|
+
const account = await client.getAccountInfo(pubkey);
|
|
165
|
+
console.log('Balance:', account.lamports, 'lamports');
|
|
166
|
+
|
|
167
|
+
// Send Transfer transaction
|
|
168
|
+
const tx = await client.sendTransaction({
|
|
169
|
+
type: 'Transfer',
|
|
170
|
+
payload: {
|
|
171
|
+
recipient: 'ATH...',
|
|
172
|
+
amount: 1000000000, // 1 AETH in lamports
|
|
173
|
+
nonce: 0,
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
console.log('Transaction signature:', tx.signature);`;
|
|
177
|
+
|
|
178
|
+
console.log(` ${colors.dim}[ javascript ]${colors.reset}`);
|
|
179
|
+
example.split('\n').forEach(line => {
|
|
180
|
+
console.log(` ${colors.bright}${line}${colors.reset}`);
|
|
181
|
+
});
|
|
182
|
+
console.log();
|
|
183
|
+
|
|
184
|
+
printSection('RPC API Reference');
|
|
185
|
+
console.log(` ${colors.cyan}GET /v1/account/<addr>${colors.reset} — ${colors.dim}Fetch account info + lamports balance${colors.reset}`);
|
|
186
|
+
console.log(` ${colors.cyan}GET /v1/slot${colors.reset} — ${colors.dim}Get current slot number${colors.reset}`);
|
|
187
|
+
console.log(` ${colors.cyan}GET /v1/validators${colors.reset} — ${colors.dim}List active validators${colors.reset}`);
|
|
188
|
+
console.log(` ${colors.cyan}POST /v1/tx${colors.reset} — ${colors.dim}Submit signed transaction${colors.reset}`);
|
|
189
|
+
console.log(` ${colors.cyan}GET /v1/tx/<signature>${colors.reset} — ${colors.dim}Get transaction receipt${colors.reset}`);
|
|
190
|
+
console.log();
|
|
191
|
+
|
|
192
|
+
printLink('NPM Package', 'https://www.npmjs.com/package/@aether-network/client');
|
|
193
|
+
printLink('TypeScript Docs', 'https://docs.aether.network/sdk/js');
|
|
194
|
+
printLink('GitHub Repo', 'https://github.com/aether-network/aether-js');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Show Rust SDK info
|
|
199
|
+
*/
|
|
200
|
+
function showRustSdk() {
|
|
201
|
+
printSection('Aether Rust SDK', '🦀');
|
|
202
|
+
|
|
203
|
+
console.log(` ${colors.bright}Native Rust SDK for building Aether programs and clients.${colors.reset}`);
|
|
204
|
+
console.log(` Use this for validator plugins, custom programs, and high-performance tools.${colors.reset}\n`);
|
|
205
|
+
|
|
206
|
+
console.log(` ${colors.green}✓ Stable Release${colors.reset}`);
|
|
207
|
+
console.log(` ${colors.dim}Version: 1.2.0${colors.reset}`);
|
|
208
|
+
console.log();
|
|
209
|
+
|
|
210
|
+
printSection('Installation');
|
|
211
|
+
printCode('cargo add aether-sdk');
|
|
212
|
+
console.log(' or add to your Cargo.toml:');
|
|
213
|
+
console.log();
|
|
214
|
+
console.log(` ${colors.dim}${colors.bgRed}toml${colors.reset}`);
|
|
215
|
+
console.log(` ${colors.bright}[dependencies]${colors.reset}`);
|
|
216
|
+
console.log(` ${colors.bright}aether-sdk = "1.2"${colors.reset}`);
|
|
217
|
+
console.log();
|
|
218
|
+
|
|
219
|
+
printSection('Usage Example');
|
|
220
|
+
const rustExample = `use aether_sdk::{client::Client, pubkey::Pubkey};
|
|
221
|
+
|
|
222
|
+
#[tokio::main]
|
|
223
|
+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
224
|
+
// Initialize client
|
|
225
|
+
let client = Client::new("http://localhost:8899");
|
|
226
|
+
|
|
227
|
+
// Get slot
|
|
228
|
+
let slot = client.get_slot().await?;
|
|
229
|
+
println!("Current slot: {}", slot);
|
|
230
|
+
|
|
231
|
+
// Get balance
|
|
232
|
+
let pubkey = Pubkey::from_str("...")?;
|
|
233
|
+
let balance = client.get_balance(&pubkey).await?;
|
|
234
|
+
println!("Balance: {} lamports", balance);
|
|
235
|
+
|
|
236
|
+
Ok(())
|
|
237
|
+
}`;
|
|
238
|
+
|
|
239
|
+
console.log(` ${colors.dim}${colors.bgRed}rust${colors.reset}`);
|
|
240
|
+
rustExample.split('\n').forEach(line => {
|
|
241
|
+
console.log(` ${colors.bright}${line}${colors.reset}`);
|
|
242
|
+
});
|
|
243
|
+
console.log();
|
|
244
|
+
|
|
245
|
+
printSection('Features');
|
|
246
|
+
console.log(` ${colors.cyan}• Full RPC client${colors.reset}`);
|
|
247
|
+
console.log(` ${colors.cyan}• Program development framework${colors.reset}`);
|
|
248
|
+
console.log(` ${colors.cyan}• Account serialization/deserialization${colors.reset}`);
|
|
249
|
+
console.log(` ${colors.cyan}• Transaction building and signing${colors.reset}`);
|
|
250
|
+
console.log(` ${colors.cyan}• Async runtime support (tokio)${colors.reset}`);
|
|
251
|
+
console.log();
|
|
252
|
+
|
|
253
|
+
printLink('Crates.io', 'https://crates.io/crates/aether-sdk');
|
|
254
|
+
printLink('API Docs', 'https://docs.rs/aether-sdk');
|
|
255
|
+
printLink('GitHub Repo', 'https://github.com/aether-network/aether-rust');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Show token libraries info
|
|
260
|
+
*/
|
|
261
|
+
function showTokensSdk() {
|
|
262
|
+
printSection('FLUX / ATH Token Libraries', '🪙');
|
|
263
|
+
|
|
264
|
+
console.log(` ${colors.bright}Token libraries for FLUX (utility) and ATH (governance) tokens.${colors.reset}`);
|
|
265
|
+
console.log(` Use these to integrate Aether tokens into your applications.${colors.reset}\n`);
|
|
266
|
+
|
|
267
|
+
console.log(` ${colors.yellow}⚠ Beta Release${colors.reset}`);
|
|
268
|
+
console.log(` ${colors.dim}Version: 0.9.0 (testnet only)${colors.reset}`);
|
|
269
|
+
console.log();
|
|
270
|
+
|
|
271
|
+
printSection('Installation');
|
|
272
|
+
console.log(` ${colors.bright}JavaScript:${colors.reset}`);
|
|
273
|
+
printCode('npm install @aether-network/tokens');
|
|
274
|
+
console.log();
|
|
275
|
+
console.log(` ${colors.bright}Rust:${colors.reset}`);
|
|
276
|
+
printCode('cargo add aether-tokens');
|
|
277
|
+
|
|
278
|
+
printSection('Supported Tokens');
|
|
279
|
+
console.log();
|
|
280
|
+
console.log(` ${colors.magenta}FLUX${colors.reset} - Utility Token`);
|
|
281
|
+
console.log(` • Purpose: Transaction fees, staking rewards`);
|
|
282
|
+
console.log(` • Decimals: 9`);
|
|
283
|
+
console.log(` • Mint: ${colors.dim}flux7x... (testnet)${colors.reset}`);
|
|
284
|
+
console.log();
|
|
285
|
+
console.log(` ${colors.blue}ATH${colors.reset} - Governance Token`);
|
|
286
|
+
console.log(` • Purpose: Voting, protocol upgrades`);
|
|
287
|
+
console.log(` • Decimals: 6`);
|
|
288
|
+
console.log(` • Mint: ${colors.dim}athgov... (testnet)${colors.reset}`);
|
|
289
|
+
console.log();
|
|
290
|
+
|
|
291
|
+
printSection('Usage Example (JavaScript)');
|
|
292
|
+
const tokenExample = `const { TokenClient, TOKENS } = require('@aether-network/tokens');
|
|
293
|
+
|
|
294
|
+
const client = new TokenClient(rpcUrl);
|
|
295
|
+
|
|
296
|
+
// Get FLUX balance
|
|
297
|
+
const fluxBalance = await client.getTokenBalance(pubkey, TOKENS.FLUX);
|
|
298
|
+
console.log('FLUX:', fluxBalance);
|
|
299
|
+
|
|
300
|
+
// Transfer FLUX
|
|
301
|
+
const tx = await client.transfer({
|
|
302
|
+
mint: TOKENS.FLUX,
|
|
303
|
+
from: senderPubkey,
|
|
304
|
+
to: recipientPubkey,
|
|
305
|
+
amount: 1000,
|
|
306
|
+
});`;
|
|
307
|
+
|
|
308
|
+
console.log(` ${colors.dim}${colors.bgRed}javascript${colors.reset}`);
|
|
309
|
+
tokenExample.split('\n').forEach(line => {
|
|
310
|
+
console.log(` ${colors.bright}${line}${colors.reset}`);
|
|
311
|
+
});
|
|
312
|
+
console.log();
|
|
313
|
+
|
|
314
|
+
printLink('Token Documentation', 'https://docs.aether.network/tokens');
|
|
315
|
+
printLink('Token Registry', 'https://github.com/aether-network/token-registry');
|
|
316
|
+
printLink('Testnet Faucet', 'https://faucet.aether.network');
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Show TypeScript/Rust type definitions for Aether transactions
|
|
321
|
+
*/
|
|
322
|
+
function showTypes() {
|
|
323
|
+
printSection('Aether Transaction Type Definitions', '🏷️');
|
|
324
|
+
|
|
325
|
+
console.log(` ${colors.bright}Exported from ${colors.cyan}@aether-network/client${colors.reset} and ${colors.cyan}aether-sdk${colors.reset}\n`);
|
|
326
|
+
|
|
327
|
+
printSection('TransactionPayload (Rust enum — serde JSON tag)');
|
|
328
|
+
|
|
329
|
+
const tsTypes = `// TypeScript / JavaScript
|
|
330
|
+
// Import from @aether-network/client
|
|
331
|
+
|
|
332
|
+
// TransactionPayload — discriminated union via 'type' field
|
|
333
|
+
type TransferPayload = { type: 'Transfer'; data: { recipient: string; amount: u64; nonce: u64 } };
|
|
334
|
+
type StakePayload = { type: 'Stake'; data: { validator: string; amount: u64 } };
|
|
335
|
+
type UnstakePayload = { type: 'Unstake'; data: { stake_account: string; amount: u64 } };
|
|
336
|
+
type ClaimRewardsPayload = { type: 'ClaimRewards'; data: { stake_account: string } };
|
|
337
|
+
type CreateNFTPayload = { type: 'CreateNFT'; data: { metadata_url: string; royalties: u16 } };
|
|
338
|
+
type MintNFTPayload = { type: 'MintNFT'; data: { nft_id: string; amount: u64 } };
|
|
339
|
+
type TransferNFTPayload = { type: 'TransferNFT'; data: { nft_id: string; recipient: string } };
|
|
340
|
+
type UpdateMetadataPayload = { type: 'UpdateMetadata'; data: { nft_id: string; metadata_url: string } };
|
|
341
|
+
|
|
342
|
+
type TransactionPayload =
|
|
343
|
+
| TransferPayload | StakePayload | UnstakePayload | ClaimRewardsPayload
|
|
344
|
+
| CreateNFTPayload | MintNFTPayload | TransferNFTPayload | UpdateMetadataPayload;
|
|
345
|
+
|
|
346
|
+
// Full AetherTransaction
|
|
347
|
+
interface AetherTransaction {
|
|
348
|
+
signature: string; // base58 of [u8; 64]
|
|
349
|
+
signer: string; // base58 of [u8; 32]
|
|
350
|
+
tx_type: string; // e.g. "Transfer", "Stake"
|
|
351
|
+
payload: TransactionPayload;
|
|
352
|
+
fee: u64;
|
|
353
|
+
slot: u64;
|
|
354
|
+
timestamp: u64;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Account response from GET /v1/account/<addr>
|
|
358
|
+
interface Account {
|
|
359
|
+
lamports: u64;
|
|
360
|
+
owner: string; // base58 of [u8; 32]
|
|
361
|
+
data: Uint8Array;
|
|
362
|
+
rent_epoch: u64;
|
|
363
|
+
}`;
|
|
364
|
+
|
|
365
|
+
console.log(` ${colors.dim}[ typescript ]${colors.reset}`);
|
|
366
|
+
tsTypes.split('\n').forEach(line => {
|
|
367
|
+
console.log(` ${line}`);
|
|
368
|
+
});
|
|
369
|
+
console.log();
|
|
370
|
+
|
|
371
|
+
printSection('Rust struct definitions (from crates/aether-core/src/types.rs)');
|
|
372
|
+
|
|
373
|
+
const rustTypes = `// Rust — use aether_sdk::types;
|
|
374
|
+
|
|
375
|
+
use serde::{Deserialize, Serialize};
|
|
376
|
+
|
|
377
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
378
|
+
pub enum TransactionPayload {
|
|
379
|
+
#[serde(tag = "type", content = "data")]
|
|
380
|
+
Transfer { recipient: String, amount: u64, nonce: u64 },
|
|
381
|
+
#[serde(tag = "type", content = "data")]
|
|
382
|
+
Stake { validator: String, amount: u64 },
|
|
383
|
+
#[serde(tag = "type", content = "data")]
|
|
384
|
+
Unstake { stake_account: String, amount: u64 },
|
|
385
|
+
#[serde(tag = "type", content = "data")]
|
|
386
|
+
ClaimRewards { stake_account: String },
|
|
387
|
+
#[serde(tag = "type", content = "data")]
|
|
388
|
+
CreateNFT { metadata_url: String, royalties: u16 },
|
|
389
|
+
#[serde(tag = "type", content = "data")]
|
|
390
|
+
MintNFT { nft_id: String, amount: u64 },
|
|
391
|
+
#[serde(tag = "type", content = "data")]
|
|
392
|
+
TransferNFT { nft_id: String, recipient: String },
|
|
393
|
+
#[serde(tag = "type", content = "data")]
|
|
394
|
+
UpdateMetadata { nft_id: String, metadata_url: String },
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
398
|
+
pub struct AetherTransaction {
|
|
399
|
+
#[serde(with = "serde_bytes_64")]
|
|
400
|
+
pub signature: [u8; 64],
|
|
401
|
+
#[serde(with = "serde_bytes_32")]
|
|
402
|
+
pub signer: [u8; 32],
|
|
403
|
+
pub tx_type: TransactionType,
|
|
404
|
+
pub payload: TransactionPayload,
|
|
405
|
+
pub fee: u64,
|
|
406
|
+
pub slot: u64,
|
|
407
|
+
pub timestamp: u64,
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
pub type Address = [u8; 32];
|
|
411
|
+
|
|
412
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
413
|
+
pub struct Account {
|
|
414
|
+
pub lamports: u64,
|
|
415
|
+
pub owner: [u8; 32],
|
|
416
|
+
pub data: Vec<u8>,
|
|
417
|
+
pub rent_epoch: u64,
|
|
418
|
+
}`;
|
|
419
|
+
|
|
420
|
+
console.log(` ${colors.dim}[ rust ]${colors.reset}`);
|
|
421
|
+
rustTypes.split('\n').forEach(line => {
|
|
422
|
+
console.log(` ${line}`);
|
|
423
|
+
});
|
|
424
|
+
console.log();
|
|
425
|
+
|
|
426
|
+
printSection('TransactionType enum');
|
|
427
|
+
console.log(` ${colors.cyan}Transfer${colors.reset} — Send AETH`);
|
|
428
|
+
console.log(` ${colors.cyan}Stake${colors.reset} — Delegate to validator`);
|
|
429
|
+
console.log(` ${colors.cyan}Unstake${colors.reset} — Request withdrawal`);
|
|
430
|
+
console.log(` ${colors.cyan}ClaimRewards${colors.reset} — Claim staking rewards`);
|
|
431
|
+
console.log(` ${colors.cyan}CreateNFT${colors.reset} — Create on-chain NFT`);
|
|
432
|
+
console.log(` ${colors.cyan}MintNFT${colors.reset} — Mint additional NFT supply`);
|
|
433
|
+
console.log(` ${colors.cyan}TransferNFT${colors.reset} — Transfer NFT to another address`);
|
|
434
|
+
console.log(` ${colors.cyan}UpdateMetadata${colors.reset} — Update NFT metadata URL`);
|
|
435
|
+
console.log();
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Show documentation portal info
|
|
440
|
+
*/
|
|
441
|
+
function showDocs() {
|
|
442
|
+
printSection('Aether Documentation', '📚');
|
|
443
|
+
|
|
444
|
+
console.log(` ${colors.bright}Comprehensive documentation for Aether developers.${colors.reset}\n`);
|
|
445
|
+
|
|
446
|
+
console.log(` ${colors.cyan}📖 Documentation Portal:${colors.reset}`);
|
|
447
|
+
console.log(` ${colors.blue}https://docs.aether.network${colors.reset}`);
|
|
448
|
+
console.log();
|
|
449
|
+
|
|
450
|
+
console.log(` ${colors.cyan}Sections:${colors.reset}`);
|
|
451
|
+
console.log(` • Getting Started - Quick start guides`);
|
|
452
|
+
console.log(` • Core Concepts - Accounts, programs, transactions`);
|
|
453
|
+
console.log(` • SDK Reference - Full API docs for JS and Rust`);
|
|
454
|
+
console.log(` • Tutorials - Step-by-step projects`);
|
|
455
|
+
console.log(` • Validator Guide - Running and maintaining validators`);
|
|
456
|
+
console.log(` • Economics - Staking, rewards, fees`);
|
|
457
|
+
console.log();
|
|
458
|
+
|
|
459
|
+
printLink('Main Docs', 'https://docs.aether.network');
|
|
460
|
+
printLink('API Reference', 'https://docs.aether.network/api');
|
|
461
|
+
printLink('Tutorials', 'https://docs.aether.network/tutorials');
|
|
462
|
+
printLink('Validator Docs', 'https://docs.aether.network/validators');
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Parse command line args
|
|
467
|
+
*/
|
|
468
|
+
function parseArgs() {
|
|
469
|
+
const args = process.argv.slice(3); // Skip 'aether-cli sdk'
|
|
470
|
+
|
|
471
|
+
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
|
472
|
+
return 'all';
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const subcmd = args[0].toLowerCase();
|
|
476
|
+
|
|
477
|
+
switch (subcmd) {
|
|
478
|
+
case 'js':
|
|
479
|
+
case 'javascript':
|
|
480
|
+
case 'node':
|
|
481
|
+
return 'js';
|
|
482
|
+
case 'rust':
|
|
483
|
+
case 'rs':
|
|
484
|
+
return 'rust';
|
|
485
|
+
case 'tokens':
|
|
486
|
+
case 'token':
|
|
487
|
+
case 'flux':
|
|
488
|
+
case 'ath':
|
|
489
|
+
return 'tokens';
|
|
490
|
+
case 'docs':
|
|
491
|
+
case 'doc':
|
|
492
|
+
case 'documentation':
|
|
493
|
+
return 'docs';
|
|
494
|
+
case 'types':
|
|
495
|
+
case 'type':
|
|
496
|
+
case 'typedef':
|
|
497
|
+
case 'typedefs':
|
|
498
|
+
return 'types';
|
|
499
|
+
default:
|
|
500
|
+
return 'all';
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Main SDK command
|
|
506
|
+
*/
|
|
507
|
+
function sdkCommand() {
|
|
508
|
+
const subcmd = parseArgs();
|
|
509
|
+
|
|
510
|
+
switch (subcmd) {
|
|
511
|
+
case 'js':
|
|
512
|
+
showJsSdk();
|
|
513
|
+
break;
|
|
514
|
+
case 'rust':
|
|
515
|
+
showRustSdk();
|
|
516
|
+
break;
|
|
517
|
+
case 'tokens':
|
|
518
|
+
showTokensSdk();
|
|
519
|
+
break;
|
|
520
|
+
case 'docs':
|
|
521
|
+
showDocs();
|
|
522
|
+
break;
|
|
523
|
+
case 'types':
|
|
524
|
+
showTypes();
|
|
525
|
+
break;
|
|
526
|
+
default:
|
|
527
|
+
showAllSdks();
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Export for use as module
|
|
532
|
+
module.exports = { sdkCommand };
|
|
533
|
+
|
|
534
|
+
// Run if called directly
|
|
535
|
+
if (require.main === module) {
|
|
536
|
+
sdkCommand();
|
|
537
|
+
}
|