@jellylegsai/aether-cli 1.9.2 → 2.0.1
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/IMPLEMENTATION_REPORT.md +319 -0
- package/commands/blockheight.js +230 -0
- package/commands/call.js +981 -0
- package/commands/claim.js +98 -72
- package/commands/deploy.js +959 -0
- package/commands/index.js +2 -0
- package/commands/init.js +33 -49
- package/commands/network-diagnostics.js +706 -0
- package/commands/network.js +412 -429
- package/commands/rewards.js +311 -266
- package/commands/sdk.js +791 -656
- package/commands/slot.js +3 -11
- package/commands/stake.js +581 -516
- package/commands/supply.js +483 -391
- package/commands/token-accounts.js +275 -0
- package/commands/transfer.js +3 -11
- package/commands/unstake.js +3 -11
- package/commands/validator-start.js +681 -323
- package/commands/validator.js +959 -0
- package/commands/validators.js +623 -626
- package/commands/version.js +240 -0
- package/commands/wallet.js +17 -24
- package/cycle-report-issue-116.txt +165 -0
- package/index.js +501 -602
- package/lib/ui.js +623 -0
- package/package.json +10 -3
- package/sdk/index.d.ts +546 -0
- package/sdk/index.js +130 -0
- package/sdk/package.json +2 -1
package/sdk/index.d.ts
ADDED
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jellylegsai/aether-sdk
|
|
3
|
+
*
|
|
4
|
+
* Official Aether Blockchain SDK TypeScript Definitions
|
|
5
|
+
* Real HTTP RPC calls to Aether nodes with full type safety
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Error Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
export class AetherSDKError extends Error {
|
|
13
|
+
name: 'AetherSDKError';
|
|
14
|
+
code: string;
|
|
15
|
+
details: Record<string, unknown>;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class NetworkTimeoutError extends AetherSDKError {
|
|
20
|
+
name: 'NetworkTimeoutError';
|
|
21
|
+
code: 'NETWORK_TIMEOUT';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class RPCError extends AetherSDKError {
|
|
25
|
+
name: 'RPCError';
|
|
26
|
+
code: 'RPC_ERROR';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class RateLimitError extends AetherSDKError {
|
|
30
|
+
name: 'RateLimitError';
|
|
31
|
+
code: 'RATE_LIMIT';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class CircuitBreakerOpenError extends AetherSDKError {
|
|
35
|
+
name: 'CircuitBreakerOpenError';
|
|
36
|
+
code: 'CIRCUIT_BREAKER_OPEN';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Configuration Types
|
|
41
|
+
// ============================================================================
|
|
42
|
+
|
|
43
|
+
export interface AetherClientOptions {
|
|
44
|
+
/** RPC endpoint URL (default: http://127.0.0.1:8899) */
|
|
45
|
+
rpcUrl?: string;
|
|
46
|
+
/** Request timeout in milliseconds (default: 10000) */
|
|
47
|
+
timeoutMs?: number;
|
|
48
|
+
/** Number of retry attempts (default: 3) */
|
|
49
|
+
retryAttempts?: number;
|
|
50
|
+
/** Initial retry delay in milliseconds (default: 1000) */
|
|
51
|
+
retryDelayMs?: number;
|
|
52
|
+
/** Backoff multiplier for retries (default: 2) */
|
|
53
|
+
backoffMultiplier?: number;
|
|
54
|
+
/** Maximum retry delay in milliseconds (default: 30000) */
|
|
55
|
+
maxRetryDelayMs?: number;
|
|
56
|
+
/** Rate limit requests per second (default: 10) */
|
|
57
|
+
rateLimitRps?: number;
|
|
58
|
+
/** Rate limit burst capacity (default: 20) */
|
|
59
|
+
rateLimitBurst?: number;
|
|
60
|
+
/** Circuit breaker failure threshold (default: 5) */
|
|
61
|
+
circuitBreakerThreshold?: number;
|
|
62
|
+
/** Circuit breaker reset timeout in milliseconds (default: 60000) */
|
|
63
|
+
circuitBreakerResetMs?: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface CircuitBreakerState {
|
|
67
|
+
state: 'CLOSED' | 'OPEN' | 'HALF_OPEN';
|
|
68
|
+
failureCount: number;
|
|
69
|
+
nextAttempt: number | null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface RateLimiterState {
|
|
73
|
+
rps: number;
|
|
74
|
+
burst: number;
|
|
75
|
+
tokens: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ClientStats {
|
|
79
|
+
totalRequests: number;
|
|
80
|
+
successfulRequests: number;
|
|
81
|
+
failedRequests: number;
|
|
82
|
+
retriedRequests: number;
|
|
83
|
+
rateLimitedRequests: number;
|
|
84
|
+
circuitBreakerBlocked: number;
|
|
85
|
+
circuitBreaker: CircuitBreakerState;
|
|
86
|
+
rateLimiter: RateLimiterState;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// Blockchain Types
|
|
91
|
+
// ============================================================================
|
|
92
|
+
|
|
93
|
+
export interface AccountInfo {
|
|
94
|
+
lamports: number;
|
|
95
|
+
owner: string;
|
|
96
|
+
data: unknown;
|
|
97
|
+
executable: boolean;
|
|
98
|
+
rent_epoch: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface EpochInfo {
|
|
102
|
+
epoch: number;
|
|
103
|
+
slotIndex: number;
|
|
104
|
+
slotsInEpoch: number;
|
|
105
|
+
absoluteSlot: number;
|
|
106
|
+
block_height?: number;
|
|
107
|
+
epoch_schedule?: {
|
|
108
|
+
first_normal_epoch: number;
|
|
109
|
+
first_normal_slot: number;
|
|
110
|
+
leader_schedule_slot_offset: number;
|
|
111
|
+
slots_per_epoch: number;
|
|
112
|
+
warmup: boolean;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface SupplyInfo {
|
|
117
|
+
total: number;
|
|
118
|
+
circulating: number;
|
|
119
|
+
nonCirculating: number;
|
|
120
|
+
total_staked?: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface FeeInfo {
|
|
124
|
+
lamportsPerSignature: number;
|
|
125
|
+
feeCalculator?: {
|
|
126
|
+
lamportsPerSignature: number;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface BlockhashInfo {
|
|
131
|
+
blockhash: string;
|
|
132
|
+
lastValidBlockHeight: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface ValidatorInfo {
|
|
136
|
+
address?: string;
|
|
137
|
+
vote_account?: string;
|
|
138
|
+
identity?: string;
|
|
139
|
+
node_pubkey?: string;
|
|
140
|
+
pubkey?: string;
|
|
141
|
+
stake_lamports?: number;
|
|
142
|
+
activated_stake?: number;
|
|
143
|
+
stake?: number;
|
|
144
|
+
lamports?: number;
|
|
145
|
+
commission?: number;
|
|
146
|
+
commission_bps?: number;
|
|
147
|
+
apy?: number;
|
|
148
|
+
return_rate?: number;
|
|
149
|
+
name?: string;
|
|
150
|
+
moniker?: string;
|
|
151
|
+
tier?: 'full' | 'lite' | 'observer';
|
|
152
|
+
active?: boolean;
|
|
153
|
+
delinquent?: boolean;
|
|
154
|
+
version?: string;
|
|
155
|
+
agent?: string;
|
|
156
|
+
app_version?: string;
|
|
157
|
+
ip?: string;
|
|
158
|
+
remote?: string;
|
|
159
|
+
last_vote?: number;
|
|
160
|
+
lastVote?: number;
|
|
161
|
+
epoch?: number;
|
|
162
|
+
uptime?: number;
|
|
163
|
+
score?: number;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface TransactionInfo {
|
|
167
|
+
signature: string;
|
|
168
|
+
slot: number;
|
|
169
|
+
timestamp: number;
|
|
170
|
+
tx_type?: string;
|
|
171
|
+
signer?: string;
|
|
172
|
+
fee?: number;
|
|
173
|
+
payload?: {
|
|
174
|
+
type?: string;
|
|
175
|
+
data?: {
|
|
176
|
+
recipient?: string;
|
|
177
|
+
amount?: string | number | bigint;
|
|
178
|
+
validator?: string;
|
|
179
|
+
stake_account?: string;
|
|
180
|
+
nonce?: number;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
confirmations?: number;
|
|
184
|
+
status?: 'confirmed' | 'finalized' | 'failed' | 'pending';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface TransactionReceipt {
|
|
188
|
+
signature: string;
|
|
189
|
+
txid?: string;
|
|
190
|
+
slot: number;
|
|
191
|
+
confirmed: boolean;
|
|
192
|
+
block_height?: number;
|
|
193
|
+
error?: string;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface StakePosition {
|
|
197
|
+
pubkey?: string;
|
|
198
|
+
publicKey?: string;
|
|
199
|
+
account?: string;
|
|
200
|
+
address?: string;
|
|
201
|
+
validator?: string;
|
|
202
|
+
delegate?: string;
|
|
203
|
+
voter?: string;
|
|
204
|
+
lamports?: number;
|
|
205
|
+
stake_lamports?: number;
|
|
206
|
+
activation_epoch?: number;
|
|
207
|
+
deactivation_epoch?: number;
|
|
208
|
+
status?: string;
|
|
209
|
+
state?: string;
|
|
210
|
+
stake_type?: string;
|
|
211
|
+
type?: string;
|
|
212
|
+
pending_rewards?: number;
|
|
213
|
+
rewards?: number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface RewardsInfo {
|
|
217
|
+
total: number;
|
|
218
|
+
pending: number;
|
|
219
|
+
pending_rewards?: number;
|
|
220
|
+
amount?: number;
|
|
221
|
+
validator?: string;
|
|
222
|
+
rewards_per_epoch?: string;
|
|
223
|
+
total_network_stake?: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface PeerInfo {
|
|
227
|
+
address?: string;
|
|
228
|
+
pubkey?: string;
|
|
229
|
+
id?: string;
|
|
230
|
+
tier?: string;
|
|
231
|
+
node_type?: string;
|
|
232
|
+
score?: number;
|
|
233
|
+
uptime?: number;
|
|
234
|
+
uptime_seconds?: number;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface SlotProductionStats {
|
|
238
|
+
slotsProduced?: number;
|
|
239
|
+
byIdentity?: Record<string, number[]>;
|
|
240
|
+
samplePeriodSecs?: number;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface TokenAccount {
|
|
244
|
+
mint: string;
|
|
245
|
+
amount: number;
|
|
246
|
+
decimals: number;
|
|
247
|
+
owner?: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface StakeAccount {
|
|
251
|
+
pubkey?: string;
|
|
252
|
+
publicKey?: string;
|
|
253
|
+
account?: string;
|
|
254
|
+
lamports?: number;
|
|
255
|
+
stake_lamports?: number;
|
|
256
|
+
validator?: string;
|
|
257
|
+
voter?: string;
|
|
258
|
+
status?: string;
|
|
259
|
+
state?: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ============================================================================
|
|
263
|
+
// NFT Types
|
|
264
|
+
// ============================================================================
|
|
265
|
+
|
|
266
|
+
export interface NFTInfo {
|
|
267
|
+
id: string;
|
|
268
|
+
creator?: string;
|
|
269
|
+
mint_authority?: string;
|
|
270
|
+
metadata_url?: string;
|
|
271
|
+
metadata?: string;
|
|
272
|
+
royalties?: number;
|
|
273
|
+
royalty_bps?: number;
|
|
274
|
+
supply?: number;
|
|
275
|
+
current_supply?: number;
|
|
276
|
+
max_supply?: number;
|
|
277
|
+
created_at?: number;
|
|
278
|
+
update_authority?: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface NFTHolding {
|
|
282
|
+
nft_id?: string;
|
|
283
|
+
id?: string;
|
|
284
|
+
mint?: string;
|
|
285
|
+
amount?: number;
|
|
286
|
+
balance?: number;
|
|
287
|
+
acquired_at?: number;
|
|
288
|
+
metadata_url?: string;
|
|
289
|
+
metadata?: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// ============================================================================
|
|
293
|
+
// Transaction Builder Types
|
|
294
|
+
// ============================================================================
|
|
295
|
+
|
|
296
|
+
export interface TransferParams {
|
|
297
|
+
from: string;
|
|
298
|
+
to: string;
|
|
299
|
+
amount: number;
|
|
300
|
+
nonce: number;
|
|
301
|
+
signFn: (tx: TransactionData, blockhash: string) => Promise<string> | string;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export interface StakeParams {
|
|
305
|
+
staker: string;
|
|
306
|
+
validator: string;
|
|
307
|
+
amount: number;
|
|
308
|
+
signFn: (tx: TransactionData, blockhash: string) => Promise<string> | string;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface UnstakeParams {
|
|
312
|
+
stakeAccount: string;
|
|
313
|
+
amount: number;
|
|
314
|
+
signFn: (tx: TransactionData, blockhash: string) => Promise<string> | string;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface ClaimRewardsParams {
|
|
318
|
+
stakeAccount: string;
|
|
319
|
+
signFn: (tx: TransactionData, blockhash: string) => Promise<string> | string;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export interface NFTCreateParams {
|
|
323
|
+
creator: string;
|
|
324
|
+
metadataUrl: string;
|
|
325
|
+
royalties: number;
|
|
326
|
+
signFn: (tx: TransactionData, blockhash: string) => Promise<string> | string;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface NFTTransferParams {
|
|
330
|
+
from: string;
|
|
331
|
+
nftId: string;
|
|
332
|
+
to: string;
|
|
333
|
+
signFn: (tx: TransactionData, blockhash: string) => Promise<string> | string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface NFTUpdateMetadataParams {
|
|
337
|
+
creator: string;
|
|
338
|
+
nftId: string;
|
|
339
|
+
metadataUrl: string;
|
|
340
|
+
signFn: (tx: TransactionData, blockhash: string) => Promise<string> | string;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface TransactionData {
|
|
344
|
+
signature: string;
|
|
345
|
+
signer: string;
|
|
346
|
+
tx_type: string;
|
|
347
|
+
payload: {
|
|
348
|
+
type?: string;
|
|
349
|
+
data?: Record<string, unknown>;
|
|
350
|
+
};
|
|
351
|
+
fee: number;
|
|
352
|
+
slot: number;
|
|
353
|
+
timestamp: number;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ============================================================================
|
|
357
|
+
// Ping Types
|
|
358
|
+
// ============================================================================
|
|
359
|
+
|
|
360
|
+
export interface PingResult {
|
|
361
|
+
ok: boolean;
|
|
362
|
+
latency: number;
|
|
363
|
+
rpc: string;
|
|
364
|
+
error?: string;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// ============================================================================
|
|
368
|
+
// AetherClient Class
|
|
369
|
+
// ============================================================================
|
|
370
|
+
|
|
371
|
+
export class AetherClient {
|
|
372
|
+
readonly rpcUrl: string;
|
|
373
|
+
readonly timeoutMs: number;
|
|
374
|
+
readonly retryAttempts: number;
|
|
375
|
+
readonly retryDelayMs: number;
|
|
376
|
+
readonly backoffMultiplier: number;
|
|
377
|
+
readonly maxRetryDelayMs: number;
|
|
378
|
+
|
|
379
|
+
constructor(options?: AetherClientOptions);
|
|
380
|
+
|
|
381
|
+
// Core RPC Methods
|
|
382
|
+
getSlot(): Promise<number>;
|
|
383
|
+
getBlockHeight(): Promise<number>;
|
|
384
|
+
getAccountInfo(address: string): Promise<AccountInfo>;
|
|
385
|
+
getAccount(address: string): Promise<AccountInfo>;
|
|
386
|
+
getBalance(address: string): Promise<number>;
|
|
387
|
+
getEpochInfo(): Promise<EpochInfo>;
|
|
388
|
+
getTransaction(signature: string): Promise<TransactionInfo>;
|
|
389
|
+
sendTransaction(tx: TransactionData): Promise<TransactionReceipt>;
|
|
390
|
+
getRecentBlockhash(): Promise<BlockhashInfo>;
|
|
391
|
+
getClusterPeers(): Promise<PeerInfo[]>;
|
|
392
|
+
getValidators(): Promise<ValidatorInfo[]>;
|
|
393
|
+
getSupply(): Promise<SupplyInfo>;
|
|
394
|
+
getHealth(): Promise<string>;
|
|
395
|
+
getVersion(): Promise<{ aetherCore?: string; featureSet?: string }>;
|
|
396
|
+
getTPS(): Promise<number | null>;
|
|
397
|
+
getFees(): Promise<FeeInfo>;
|
|
398
|
+
getSlotProduction(): Promise<SlotProductionStats>;
|
|
399
|
+
|
|
400
|
+
// Stake Operations
|
|
401
|
+
getStakePositions(address: string): Promise<StakePosition[]>;
|
|
402
|
+
getRewards(address: string): Promise<RewardsInfo>;
|
|
403
|
+
getStakeAccounts(address: string): Promise<StakeAccount[]>;
|
|
404
|
+
|
|
405
|
+
// Transaction Queries
|
|
406
|
+
getRecentTransactions(address: string, limit?: number): Promise<TransactionInfo[]>;
|
|
407
|
+
getTransactionHistory(address: string, limit?: number): Promise<{
|
|
408
|
+
signatures: string[];
|
|
409
|
+
transactions: TransactionInfo[];
|
|
410
|
+
address: string;
|
|
411
|
+
}>;
|
|
412
|
+
|
|
413
|
+
// Token Operations
|
|
414
|
+
getTokenAccounts(address: string): Promise<TokenAccount[]>;
|
|
415
|
+
|
|
416
|
+
// NFT Operations
|
|
417
|
+
createNFT(params: NFTCreateParams): Promise<TransactionReceipt>;
|
|
418
|
+
transferNFT(params: NFTTransferParams): Promise<TransactionReceipt>;
|
|
419
|
+
updateMetadata(params: NFTUpdateMetadataParams): Promise<TransactionReceipt>;
|
|
420
|
+
getNFT(nftId: string): Promise<NFTInfo>;
|
|
421
|
+
getNFTHoldings(address: string): Promise<NFTHolding[]>;
|
|
422
|
+
getNFTsByCreator(address: string): Promise<NFTInfo[]>;
|
|
423
|
+
|
|
424
|
+
// Transaction Helpers
|
|
425
|
+
transfer(params: TransferParams): Promise<TransactionReceipt>;
|
|
426
|
+
stake(params: StakeParams): Promise<TransactionReceipt>;
|
|
427
|
+
unstake(params: UnstakeParams): Promise<TransactionReceipt>;
|
|
428
|
+
claimRewards(params: ClaimRewardsParams): Promise<TransactionReceipt>;
|
|
429
|
+
|
|
430
|
+
// Utilities
|
|
431
|
+
getStats(): ClientStats;
|
|
432
|
+
resetCircuitBreaker(): void;
|
|
433
|
+
destroy(): void;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// ============================================================================
|
|
437
|
+
// Token Bucket Rate Limiter
|
|
438
|
+
// ============================================================================
|
|
439
|
+
|
|
440
|
+
export class TokenBucketRateLimiter {
|
|
441
|
+
readonly rps: number;
|
|
442
|
+
readonly burst: number;
|
|
443
|
+
tokens: number;
|
|
444
|
+
lastRefill: number;
|
|
445
|
+
|
|
446
|
+
constructor(rps?: number, burst?: number);
|
|
447
|
+
refill(): void;
|
|
448
|
+
processQueue(): void;
|
|
449
|
+
acquire(tokens?: number): Promise<void>;
|
|
450
|
+
destroy(): void;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// ============================================================================
|
|
454
|
+
// Circuit Breaker
|
|
455
|
+
// ============================================================================
|
|
456
|
+
|
|
457
|
+
export class CircuitBreaker {
|
|
458
|
+
readonly threshold: number;
|
|
459
|
+
readonly resetTimeoutMs: number;
|
|
460
|
+
failureCount: number;
|
|
461
|
+
state: 'CLOSED' | 'OPEN' | 'HALF_OPEN';
|
|
462
|
+
nextAttempt: number;
|
|
463
|
+
|
|
464
|
+
constructor(threshold?: number, resetTimeoutMs?: number);
|
|
465
|
+
canExecute(): boolean;
|
|
466
|
+
recordSuccess(): void;
|
|
467
|
+
recordFailure(): void;
|
|
468
|
+
getState(): CircuitBreakerState;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// ============================================================================
|
|
472
|
+
// Low-level RPC
|
|
473
|
+
// ============================================================================
|
|
474
|
+
|
|
475
|
+
export function rpcGet(
|
|
476
|
+
rpcUrl: string,
|
|
477
|
+
path: string,
|
|
478
|
+
timeout?: number,
|
|
479
|
+
retries?: number
|
|
480
|
+
): Promise<unknown>;
|
|
481
|
+
|
|
482
|
+
export function rpcPost(
|
|
483
|
+
rpcUrl: string,
|
|
484
|
+
path: string,
|
|
485
|
+
body: Record<string, unknown>,
|
|
486
|
+
timeout?: number,
|
|
487
|
+
retries?: number
|
|
488
|
+
): Promise<unknown>;
|
|
489
|
+
|
|
490
|
+
// ============================================================================
|
|
491
|
+
// Convenience Functions
|
|
492
|
+
// ============================================================================
|
|
493
|
+
|
|
494
|
+
export function createClient(options?: AetherClientOptions): AetherClient;
|
|
495
|
+
|
|
496
|
+
// One-off queries (create client, call method, destroy)
|
|
497
|
+
export function getSlot(): Promise<number>;
|
|
498
|
+
export function getBlockHeight(): Promise<number>;
|
|
499
|
+
export function getEpoch(): Promise<EpochInfo>;
|
|
500
|
+
export function getAccount(address: string): Promise<AccountInfo>;
|
|
501
|
+
export function getBalance(address: string): Promise<number>;
|
|
502
|
+
export function getTransaction(signature: string): Promise<TransactionInfo>;
|
|
503
|
+
export function getRecentTransactions(address: string, limit?: number): Promise<TransactionInfo[]>;
|
|
504
|
+
export function getTransactionHistory(address: string, limit?: number): Promise<{
|
|
505
|
+
signatures: string[];
|
|
506
|
+
transactions: TransactionInfo[];
|
|
507
|
+
address: string;
|
|
508
|
+
}>;
|
|
509
|
+
export function getTokenAccounts(address: string): Promise<TokenAccount[]>;
|
|
510
|
+
export function getStakeAccounts(address: string): Promise<StakeAccount[]>;
|
|
511
|
+
export function getValidators(): Promise<ValidatorInfo[]>;
|
|
512
|
+
export function getTPS(): Promise<number | null>;
|
|
513
|
+
export function getSupply(): Promise<SupplyInfo>;
|
|
514
|
+
export function getSlotProduction(): Promise<SlotProductionStats>;
|
|
515
|
+
export function getFees(): Promise<FeeInfo>;
|
|
516
|
+
export function getStakePositions(address: string): Promise<StakePosition[]>;
|
|
517
|
+
export function getRewards(address: string): Promise<RewardsInfo>;
|
|
518
|
+
export function getValidatorAPY(validatorAddr: string): Promise<{ apy?: number; error?: string }>;
|
|
519
|
+
export function getPeers(): Promise<PeerInfo[]>;
|
|
520
|
+
export function getHealth(): Promise<string>;
|
|
521
|
+
|
|
522
|
+
// NFT queries
|
|
523
|
+
export function getNFT(nftId: string): Promise<NFTInfo>;
|
|
524
|
+
export function getNFTHoldings(address: string): Promise<NFTHolding[]>;
|
|
525
|
+
export function getNFTsByCreator(address: string): Promise<NFTInfo[]>;
|
|
526
|
+
|
|
527
|
+
// Transaction submission
|
|
528
|
+
export function sendTransaction(tx: TransactionData): Promise<TransactionReceipt>;
|
|
529
|
+
|
|
530
|
+
// Utilities
|
|
531
|
+
export function ping(rpcUrl?: string): Promise<PingResult>;
|
|
532
|
+
|
|
533
|
+
// ============================================================================
|
|
534
|
+
// Constants
|
|
535
|
+
// ============================================================================
|
|
536
|
+
|
|
537
|
+
export const DEFAULT_RPC_URL: string;
|
|
538
|
+
export const DEFAULT_TIMEOUT_MS: number;
|
|
539
|
+
export const DEFAULT_RETRY_ATTEMPTS: number;
|
|
540
|
+
export const DEFAULT_RETRY_DELAY_MS: number;
|
|
541
|
+
export const DEFAULT_BACKOFF_MULTIPLIER: number;
|
|
542
|
+
export const DEFAULT_MAX_RETRY_DELAY_MS: number;
|
|
543
|
+
export const DEFAULT_RATE_LIMIT_RPS: number;
|
|
544
|
+
export const DEFAULT_RATE_LIMIT_BURST: number;
|
|
545
|
+
export const DEFAULT_CIRCUIT_BREAKER_THRESHOLD: number;
|
|
546
|
+
export const DEFAULT_CIRCUIT_BREAKER_RESET_MS: number;
|
package/sdk/index.js
CHANGED
|
@@ -1278,6 +1278,102 @@ class AetherClient {
|
|
|
1278
1278
|
);
|
|
1279
1279
|
}
|
|
1280
1280
|
|
|
1281
|
+
// ============================================================
|
|
1282
|
+
// Contract Call Methods - Real blockchain calls for smart contracts
|
|
1283
|
+
// ============================================================
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Call a smart contract function (read-only query)
|
|
1287
|
+
* RPC: POST /v1/call
|
|
1288
|
+
*
|
|
1289
|
+
* @param {string} programId - Program/contract ID (base58)
|
|
1290
|
+
* @param {string} functionName - Function to call
|
|
1291
|
+
* @param {Array} args - Function arguments
|
|
1292
|
+
* @returns {Promise<Object>} Function result
|
|
1293
|
+
*/
|
|
1294
|
+
async call(programId, functionName, args = []) {
|
|
1295
|
+
if (!programId) throw new AetherSDKError('Program ID is required', 'VALIDATION_ERROR');
|
|
1296
|
+
if (!functionName) throw new AetherSDKError('Function name is required', 'VALIDATION_ERROR');
|
|
1297
|
+
|
|
1298
|
+
return this._executeWithRetry(
|
|
1299
|
+
async () => {
|
|
1300
|
+
const result = await this._httpPost('/v1/call', {
|
|
1301
|
+
program_id: programId,
|
|
1302
|
+
function: functionName,
|
|
1303
|
+
args: args,
|
|
1304
|
+
});
|
|
1305
|
+
return result;
|
|
1306
|
+
},
|
|
1307
|
+
'call'
|
|
1308
|
+
);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Simulate a contract call (dry run)
|
|
1313
|
+
* RPC: POST /v1/call/simulate
|
|
1314
|
+
*
|
|
1315
|
+
* @param {string} programId - Program/contract ID (base58)
|
|
1316
|
+
* @param {string} functionName - Function to simulate
|
|
1317
|
+
* @param {Array} args - Function arguments
|
|
1318
|
+
* @param {string} signer - Address of the caller (for auth simulation)
|
|
1319
|
+
* @returns {Promise<Object>} Simulation result with gas estimate
|
|
1320
|
+
*/
|
|
1321
|
+
async simulateCall(programId, functionName, args = [], signer = null) {
|
|
1322
|
+
if (!programId) throw new AetherSDKError('Program ID is required', 'VALIDATION_ERROR');
|
|
1323
|
+
if (!functionName) throw new AetherSDKError('Function name is required', 'VALIDATION_ERROR');
|
|
1324
|
+
|
|
1325
|
+
return this._executeWithRetry(
|
|
1326
|
+
async () => {
|
|
1327
|
+
const result = await this._httpPost('/v1/call/simulate', {
|
|
1328
|
+
program_id: programId,
|
|
1329
|
+
function: functionName,
|
|
1330
|
+
args: args,
|
|
1331
|
+
signer: signer,
|
|
1332
|
+
});
|
|
1333
|
+
return result;
|
|
1334
|
+
},
|
|
1335
|
+
'simulateCall'
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* Get contract interface/IDL
|
|
1341
|
+
* RPC: GET /v1/program/<program_id>/interface
|
|
1342
|
+
*
|
|
1343
|
+
* @param {string} programId - Program/contract ID (base58)
|
|
1344
|
+
* @returns {Promise<Object>} Contract interface with available functions
|
|
1345
|
+
*/
|
|
1346
|
+
async getContractInterface(programId) {
|
|
1347
|
+
if (!programId) throw new AetherSDKError('Program ID is required', 'VALIDATION_ERROR');
|
|
1348
|
+
|
|
1349
|
+
return this._executeWithRetry(
|
|
1350
|
+
async () => {
|
|
1351
|
+
const result = await this._httpGet(`/v1/program/${programId}/interface`);
|
|
1352
|
+
return result.interface ?? result.idl ?? result ?? null;
|
|
1353
|
+
},
|
|
1354
|
+
'getContractInterface'
|
|
1355
|
+
);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* Get program account info
|
|
1360
|
+
* RPC: GET /v1/program/<program_id>
|
|
1361
|
+
*
|
|
1362
|
+
* @param {string} programId - Program/contract ID (base58)
|
|
1363
|
+
* @returns {Promise<Object>} Program account info
|
|
1364
|
+
*/
|
|
1365
|
+
async getProgram(programId) {
|
|
1366
|
+
if (!programId) throw new AetherSDKError('Program ID is required', 'VALIDATION_ERROR');
|
|
1367
|
+
|
|
1368
|
+
return this._executeWithRetry(
|
|
1369
|
+
async () => {
|
|
1370
|
+
const result = await this._httpGet(`/v1/program/${programId}`);
|
|
1371
|
+
return result;
|
|
1372
|
+
},
|
|
1373
|
+
'getProgram'
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1281
1377
|
// ============================================================
|
|
1282
1378
|
// Utilities
|
|
1283
1379
|
// ============================================================
|
|
@@ -1724,6 +1820,40 @@ module.exports = {
|
|
|
1724
1820
|
getNFTHoldings,
|
|
1725
1821
|
getNFTsByCreator,
|
|
1726
1822
|
|
|
1823
|
+
// Contract calls
|
|
1824
|
+
call: async (programId, functionName, args) => {
|
|
1825
|
+
const client = new AetherClient();
|
|
1826
|
+
try {
|
|
1827
|
+
return await client.call(programId, functionName, args);
|
|
1828
|
+
} finally {
|
|
1829
|
+
client.destroy();
|
|
1830
|
+
}
|
|
1831
|
+
},
|
|
1832
|
+
simulateCall: async (programId, functionName, args, signer) => {
|
|
1833
|
+
const client = new AetherClient();
|
|
1834
|
+
try {
|
|
1835
|
+
return await client.simulateCall(programId, functionName, args, signer);
|
|
1836
|
+
} finally {
|
|
1837
|
+
client.destroy();
|
|
1838
|
+
}
|
|
1839
|
+
},
|
|
1840
|
+
getContractInterface: async (programId) => {
|
|
1841
|
+
const client = new AetherClient();
|
|
1842
|
+
try {
|
|
1843
|
+
return await client.getContractInterface(programId);
|
|
1844
|
+
} finally {
|
|
1845
|
+
client.destroy();
|
|
1846
|
+
}
|
|
1847
|
+
},
|
|
1848
|
+
getProgram: async (programId) => {
|
|
1849
|
+
const client = new AetherClient();
|
|
1850
|
+
try {
|
|
1851
|
+
return await client.getProgram(programId);
|
|
1852
|
+
} finally {
|
|
1853
|
+
client.destroy();
|
|
1854
|
+
}
|
|
1855
|
+
},
|
|
1856
|
+
|
|
1727
1857
|
// Transactions
|
|
1728
1858
|
sendTransaction,
|
|
1729
1859
|
|
package/sdk/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jellylegsai/aether-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Official Aether Blockchain SDK - Real HTTP RPC calls to Aether chain",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"index.js",
|
|
9
|
+
"index.d.ts",
|
|
9
10
|
"rpc.js",
|
|
10
11
|
"test.js",
|
|
11
12
|
"README.md"
|