@lobstercove/lichen-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,482 @@
1
+ import { PublicKey } from './publickey.js';
2
+ import { Keypair } from './keypair.js';
3
+ import { Transaction } from './transaction.js';
4
+ /**
5
+ * Balance information
6
+ */
7
+ export interface Balance {
8
+ spores: number;
9
+ licn: number;
10
+ spendable?: number;
11
+ spendable_licn?: string;
12
+ staked?: number;
13
+ staked_licn?: string;
14
+ locked?: number;
15
+ locked_licn?: string;
16
+ moss_staked?: number;
17
+ moss_staked_licn?: string;
18
+ moss_value?: number;
19
+ moss_value_licn?: string;
20
+ }
21
+ /**
22
+ * Account information
23
+ */
24
+ export interface Account {
25
+ spores: number;
26
+ owner: string;
27
+ executable: boolean;
28
+ data: string;
29
+ }
30
+ /**
31
+ * Block information
32
+ */
33
+ export interface Block {
34
+ slot: number;
35
+ hash: string;
36
+ parentHash: string;
37
+ transactions: number;
38
+ timestamp: number;
39
+ }
40
+ /**
41
+ * Validator information
42
+ */
43
+ export interface Validator {
44
+ pubkey: string;
45
+ stake: number;
46
+ reputation: number;
47
+ blocksProposed: number;
48
+ votesCast: number;
49
+ correctVotes: number;
50
+ lastActiveSlot: number;
51
+ }
52
+ /**
53
+ * Network information
54
+ */
55
+ export interface NetworkInfo {
56
+ chainId: string;
57
+ networkId: string;
58
+ version: string;
59
+ currentSlot: number;
60
+ validatorCount: number;
61
+ peerCount: number;
62
+ }
63
+ /**
64
+ * Chain status
65
+ */
66
+ export interface ChainStatus {
67
+ currentSlot: number;
68
+ validatorCount: number;
69
+ totalStake: number;
70
+ tps: number;
71
+ totalTransactions: number;
72
+ totalBlocks: number;
73
+ averageBlockTime: number;
74
+ isHealthy: boolean;
75
+ }
76
+ /**
77
+ * Performance metrics
78
+ */
79
+ export interface Metrics {
80
+ tps: number;
81
+ totalTransactions: number;
82
+ totalBlocks: number;
83
+ averageBlockTime: number;
84
+ }
85
+ /**
86
+ * A single step in a Merkle inclusion proof
87
+ */
88
+ export interface ProofStep {
89
+ hash: string;
90
+ direction: 'left' | 'right';
91
+ }
92
+ /**
93
+ * Merkle inclusion proof for a transaction
94
+ */
95
+ export interface TransactionProof {
96
+ slot: number;
97
+ tx_index: number;
98
+ tx_hash: string;
99
+ root: string;
100
+ proof: ProofStep[];
101
+ }
102
+ /**
103
+ * Read-only contract call result.
104
+ */
105
+ export interface ReadonlyContractResult {
106
+ success: boolean;
107
+ returnData?: string | null;
108
+ returnCode?: number | null;
109
+ logs?: string[];
110
+ error?: string | null;
111
+ computeUsed?: number;
112
+ }
113
+ /**
114
+ * RPC/WebSocket connection to Lichen
115
+ */
116
+ export declare class Connection {
117
+ private rpcUrl;
118
+ private wsUrl?;
119
+ private ws?;
120
+ private subscriptions;
121
+ private nextId;
122
+ private timeoutMs;
123
+ constructor(rpcUrl: string, wsUrl?: string, options?: {
124
+ timeoutMs?: number;
125
+ });
126
+ /**
127
+ * Make an RPC call
128
+ */
129
+ private rpc;
130
+ /**
131
+ * Get account balance
132
+ */
133
+ getBalance(pubkey: PublicKey): Promise<Balance>;
134
+ /**
135
+ * Get account information
136
+ */
137
+ getAccount(pubkey: PublicKey): Promise<Account>;
138
+ /**
139
+ * Get block by slot number
140
+ */
141
+ getBlock(slot: number): Promise<Block>;
142
+ /**
143
+ * Get latest block
144
+ */
145
+ getLatestBlock(): Promise<Block>;
146
+ /**
147
+ * Get current slot
148
+ */
149
+ getSlot(): Promise<number>;
150
+ /**
151
+ * Get recent blockhash for transactions
152
+ */
153
+ getRecentBlockhash(): Promise<string>;
154
+ /**
155
+ * Get transaction by signature.
156
+ * For contract calls, response includes: return_code (u32), return_data (base64), contract_logs (string[]).
157
+ */
158
+ getTransaction(signature: string): Promise<any>;
159
+ /**
160
+ * Get a Merkle inclusion proof for a transaction by its signature.
161
+ */
162
+ getTransactionProof(signature: string): Promise<TransactionProof>;
163
+ /**
164
+ * Verify a Merkle inclusion proof for a transaction against a root.
165
+ * Uses SHA-256 with domain-separated leaf (0x00) and internal (0x01) nodes.
166
+ *
167
+ * This is a pure static function — no RPC call needed.
168
+ */
169
+ static verifyTransactionProof(root: string, txHash: string, proof: ProofStep[]): boolean;
170
+ /**
171
+ * Send transaction
172
+ */
173
+ sendTransaction(transaction: Transaction): Promise<string>;
174
+ /**
175
+ * Get total burned LICN
176
+ */
177
+ getTotalBurned(): Promise<Balance>;
178
+ /**
179
+ * Get all validators
180
+ */
181
+ getValidators(): Promise<Validator[]>;
182
+ /**
183
+ * Get performance metrics
184
+ */
185
+ getMetrics(): Promise<Metrics>;
186
+ /**
187
+ * Health check
188
+ */
189
+ health(): Promise<{
190
+ status: string;
191
+ }>;
192
+ /**
193
+ * Get connected peers
194
+ */
195
+ getPeers(): Promise<any[]>;
196
+ /**
197
+ * Get network information
198
+ */
199
+ getNetworkInfo(): Promise<NetworkInfo>;
200
+ /**
201
+ * Get detailed validator information
202
+ */
203
+ getValidatorInfo(pubkey: PublicKey): Promise<Validator>;
204
+ /**
205
+ * Get validator performance metrics
206
+ */
207
+ getValidatorPerformance(pubkey: PublicKey): Promise<any>;
208
+ /**
209
+ * Get comprehensive chain status
210
+ */
211
+ getChainStatus(): Promise<ChainStatus>;
212
+ /**
213
+ * Create stake transaction
214
+ */
215
+ stake(from: Keypair, validator: PublicKey, amount: number | bigint): Promise<string>;
216
+ /**
217
+ * Create unstake transaction
218
+ */
219
+ unstake(from: Keypair, validator: PublicKey, amount: number | bigint): Promise<string>;
220
+ /**
221
+ * Get staking status
222
+ */
223
+ getStakingStatus(pubkey: PublicKey): Promise<any>;
224
+ /**
225
+ * Get staking rewards
226
+ */
227
+ getStakingRewards(pubkey: PublicKey): Promise<any>;
228
+ /**
229
+ * Transfer native LICN (spores) from one account to another.
230
+ *
231
+ * @param from - Sender keypair (signer)
232
+ * @param to - Recipient public key
233
+ * @param amount - Amount in spores (1 LICN = 1,000,000,000 spores)
234
+ * @returns Transaction signature
235
+ */
236
+ transfer(from: Keypair, to: PublicKey, amount: number | bigint): Promise<string>;
237
+ /**
238
+ * Deploy a WASM smart contract.
239
+ *
240
+ * @param deployer - Deployer keypair (signer, pays deploy fee)
241
+ * @param code - WASM bytecode (must start with \\0asm magic, max 512 KB)
242
+ * @param initData - Optional initialization data passed to contract init
243
+ * @returns Transaction signature
244
+ */
245
+ deployContract(deployer: Keypair, code: Uint8Array, initData?: Uint8Array): Promise<string>;
246
+ /**
247
+ * Call a function on a deployed WASM smart contract.
248
+ *
249
+ * @param caller - Caller keypair (signer)
250
+ * @param contract - Contract account public key
251
+ * @param functionName - Name of the contract function to invoke
252
+ * @param args - Serialized function arguments (default: empty)
253
+ * @param value - Native LICN to send with the call in spores (default: 0)
254
+ * @returns Transaction signature
255
+ */
256
+ callContract(caller: Keypair, contract: PublicKey, functionName: string, args?: Uint8Array, value?: number | bigint): Promise<string>;
257
+ /**
258
+ * Upgrade a deployed WASM smart contract (owner only).
259
+ *
260
+ * @param owner - Contract owner keypair (signer)
261
+ * @param contract - Contract account public key
262
+ * @param code - New WASM bytecode
263
+ * @returns Transaction signature
264
+ */
265
+ upgradeContract(owner: Keypair, contract: PublicKey, code: Uint8Array): Promise<string>;
266
+ /**
267
+ * Get enhanced account information
268
+ */
269
+ getAccountInfo(pubkey: PublicKey): Promise<any>;
270
+ /**
271
+ * Get transaction history
272
+ */
273
+ getTransactionHistory(pubkey: PublicKey, limit?: number): Promise<any>;
274
+ /**
275
+ * Get program accounts
276
+ */
277
+ getProgramAccounts(programId: PublicKey): Promise<any[]>;
278
+ /**
279
+ * Simulate transaction (dry run)
280
+ */
281
+ simulateTransaction(transaction: Transaction): Promise<any>;
282
+ /**
283
+ * Execute a read-only contract call without submitting a transaction.
284
+ */
285
+ callReadonlyContract(contractId: PublicKey, functionName: string, args?: Uint8Array, from?: PublicKey): Promise<ReadonlyContractResult>;
286
+ /**
287
+ * Get contract information
288
+ */
289
+ getContractInfo(contractId: PublicKey): Promise<any>;
290
+ /**
291
+ * Get contract logs
292
+ */
293
+ getContractLogs(contractId: PublicKey): Promise<any>;
294
+ /**
295
+ * Get contract ABI/IDL (machine-readable function and event interface)
296
+ */
297
+ getContractAbi(contractId: PublicKey): Promise<any>;
298
+ /**
299
+ * Set/update contract ABI (owner only)
300
+ */
301
+ setContractAbi(contractId: PublicKey, abi: any): Promise<any>;
302
+ /**
303
+ * Get all deployed contracts
304
+ */
305
+ getAllContracts(): Promise<any>;
306
+ /**
307
+ * Get a symbol-registry entry.
308
+ */
309
+ getSymbolRegistry(symbol: string): Promise<any>;
310
+ /**
311
+ * Get the complete LichenID profile for an address.
312
+ */
313
+ getLichenIdProfile(pubkey: PublicKey): Promise<any>;
314
+ /**
315
+ * Get the LichenID reputation summary for an address.
316
+ */
317
+ getLichenIdReputation(pubkey: PublicKey): Promise<any>;
318
+ /**
319
+ * Get LichenID skills for an address.
320
+ */
321
+ getLichenIdSkills(pubkey: PublicKey): Promise<any>;
322
+ /**
323
+ * Get LichenID vouches for an address.
324
+ */
325
+ getLichenIdVouches(pubkey: PublicKey): Promise<any>;
326
+ /**
327
+ * Resolve a .lichen name to its owner.
328
+ */
329
+ resolveLichenName(name: string): Promise<any>;
330
+ /**
331
+ * Get premium-name auction state for a .lichen label.
332
+ */
333
+ getNameAuction(name: string): Promise<any>;
334
+ /**
335
+ * Get the LichenID agent directory.
336
+ */
337
+ getLichenIdAgentDirectory(options?: {
338
+ type?: number;
339
+ available?: boolean;
340
+ min_reputation?: number;
341
+ limit?: number;
342
+ offset?: number;
343
+ }): Promise<any>;
344
+ /**
345
+ * Get aggregated LichenID statistics.
346
+ */
347
+ getLichenIdStats(): Promise<any>;
348
+ /**
349
+ * Get aggregated SporePay streaming statistics.
350
+ */
351
+ getSporePayStats(): Promise<any>;
352
+ /**
353
+ * Get aggregated LichenSwap AMM statistics.
354
+ */
355
+ getLichenSwapStats(): Promise<any>;
356
+ /**
357
+ * Get aggregated ThallLend lending statistics.
358
+ */
359
+ getThallLendStats(): Promise<any>;
360
+ /**
361
+ * Get aggregated SporeVault yield-vault statistics.
362
+ */
363
+ getSporeVaultStats(): Promise<any>;
364
+ /**
365
+ * Get aggregated BountyBoard marketplace statistics.
366
+ */
367
+ getBountyBoardStats(): Promise<any>;
368
+ getProgram(programId: PublicKey): Promise<any>;
369
+ getProgramStats(programId: PublicKey): Promise<any>;
370
+ getPrograms(): Promise<any>;
371
+ getProgramCalls(programId: PublicKey): Promise<any>;
372
+ getProgramStorage(programId: PublicKey): Promise<any>;
373
+ getCollection(collectionId: PublicKey): Promise<any>;
374
+ getNFT(collectionId: PublicKey, tokenId: number): Promise<any>;
375
+ getNFTsByOwner(owner: PublicKey): Promise<any>;
376
+ getNFTsByCollection(collectionId: PublicKey): Promise<any>;
377
+ getNFTActivity(collectionId: PublicKey, tokenId: number): Promise<any>;
378
+ /**
379
+ * Connect WebSocket
380
+ */
381
+ private connectWs;
382
+ /**
383
+ * Subscribe to method
384
+ */
385
+ private subscribe;
386
+ /**
387
+ * Unsubscribe from subscription
388
+ */
389
+ private unsubscribe;
390
+ /**
391
+ * Subscribe to slot updates
392
+ */
393
+ onSlot(callback: (slot: number) => void): Promise<number>;
394
+ /**
395
+ * Unsubscribe from slots
396
+ */
397
+ offSlot(subscriptionId: number): Promise<boolean>;
398
+ /**
399
+ * Subscribe to block updates
400
+ */
401
+ onBlock(callback: (block: Block) => void): Promise<number>;
402
+ /**
403
+ * Unsubscribe from blocks
404
+ */
405
+ offBlock(subscriptionId: number): Promise<boolean>;
406
+ /**
407
+ * Subscribe to transaction updates
408
+ */
409
+ onTransaction(callback: (transaction: any) => void): Promise<number>;
410
+ /**
411
+ * Unsubscribe from transactions
412
+ */
413
+ offTransaction(subscriptionId: number): Promise<boolean>;
414
+ /**
415
+ * Subscribe to account changes
416
+ */
417
+ onAccountChange(pubkey: PublicKey, callback: (account: any) => void): Promise<number>;
418
+ /**
419
+ * Unsubscribe from account changes
420
+ */
421
+ offAccountChange(subscriptionId: number): Promise<boolean>;
422
+ /**
423
+ * Subscribe to contract logs
424
+ */
425
+ onLogs(callback: (log: any) => void, contractId?: PublicKey): Promise<number>;
426
+ /**
427
+ * Unsubscribe from logs
428
+ */
429
+ offLogs(subscriptionId: number): Promise<boolean>;
430
+ /**
431
+ * Subscribe to program updates
432
+ */
433
+ onProgramUpdates(callback: (event: any) => void): Promise<number>;
434
+ /**
435
+ * Unsubscribe from program updates
436
+ */
437
+ offProgramUpdates(subscriptionId: number): Promise<boolean>;
438
+ /**
439
+ * Subscribe to program calls
440
+ */
441
+ onProgramCalls(callback: (event: any) => void, programId?: PublicKey): Promise<number>;
442
+ /**
443
+ * Unsubscribe from program calls
444
+ */
445
+ offProgramCalls(subscriptionId: number): Promise<boolean>;
446
+ /**
447
+ * Subscribe to NFT mints
448
+ */
449
+ onNftMints(callback: (event: any) => void, collectionId?: PublicKey): Promise<number>;
450
+ /**
451
+ * Unsubscribe from NFT mints
452
+ */
453
+ offNftMints(subscriptionId: number): Promise<boolean>;
454
+ /**
455
+ * Subscribe to NFT transfers
456
+ */
457
+ onNftTransfers(callback: (event: any) => void, collectionId?: PublicKey): Promise<number>;
458
+ /**
459
+ * Unsubscribe from NFT transfers
460
+ */
461
+ offNftTransfers(subscriptionId: number): Promise<boolean>;
462
+ /**
463
+ * Subscribe to marketplace listings
464
+ */
465
+ onMarketListings(callback: (event: any) => void): Promise<number>;
466
+ /**
467
+ * Unsubscribe from marketplace listings
468
+ */
469
+ offMarketListings(subscriptionId: number): Promise<boolean>;
470
+ /**
471
+ * Subscribe to marketplace sales
472
+ */
473
+ onMarketSales(callback: (event: any) => void): Promise<number>;
474
+ /**
475
+ * Unsubscribe from marketplace sales
476
+ */
477
+ offMarketSales(subscriptionId: number): Promise<boolean>;
478
+ /**
479
+ * Close connection
480
+ */
481
+ close(): void;
482
+ }