wsbridge-sdk 0.1.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,1764 @@
1
+ /**
2
+ * Transport state machine.
3
+ * Transitions: DISCONNECTED → CONNECTING → CONNECTED → RECONNECTING → CONNECTED
4
+ * → DESTROYED (terminal)
5
+ */
6
+ declare enum TransportState {
7
+ DISCONNECTED = "DISCONNECTED",
8
+ CONNECTING = "CONNECTING",
9
+ CONNECTED = "CONNECTED",
10
+ RECONNECTING = "RECONNECTING",
11
+ DESTROYED = "DESTROYED"
12
+ }
13
+ interface TransportEvents {
14
+ open: () => void;
15
+ close: (code: number, reason: string) => void;
16
+ error: (error: Error) => void;
17
+ message: (data: string) => void;
18
+ stateChange: (newState: TransportState, oldState: TransportState) => void;
19
+ reconnectFailed: () => void;
20
+ }
21
+ type TransportEventName = keyof TransportEvents;
22
+ /**
23
+ * Base class for all transports. Provides a typed event emitter and lifecycle contract.
24
+ */
25
+ declare abstract class AbstractTransport {
26
+ protected listeners: Map<keyof TransportEvents, Set<(() => void) | ((code: number, reason: string) => void) | ((error: Error) => void) | ((data: string) => void) | ((newState: TransportState, oldState: TransportState) => void) | (() => void)>>;
27
+ abstract connect(): Promise<void>;
28
+ abstract disconnect(): void;
29
+ abstract send(data: string): void;
30
+ abstract get state(): TransportState;
31
+ /** Whether the transport is currently connected. */
32
+ get isConnected(): boolean;
33
+ /** Register an event listener. */
34
+ on<E extends TransportEventName>(event: E, listener: TransportEvents[E]): this;
35
+ /** Remove an event listener. */
36
+ off<E extends TransportEventName>(event: E, listener: TransportEvents[E]): this;
37
+ /** Register a one-shot event listener that auto-removes after the first call. */
38
+ once<E extends TransportEventName>(event: E, listener: TransportEvents[E]): this;
39
+ /** Permanently tear down the transport. After this call, connect() will throw. */
40
+ abstract destroy(): void;
41
+ protected emit<E extends TransportEventName>(event: E, ...args: Parameters<TransportEvents[E]>): void;
42
+ }
43
+
44
+ interface WsTransportOptions {
45
+ url?: string;
46
+ autoReconnect?: boolean;
47
+ reconnectDelay?: number;
48
+ reconnectMaxDelay?: number;
49
+ reconnectMaxRetries?: number;
50
+ /** Keepalive ping interval in ms. 0 disables. Default: 30 000. Only works in Node.js. */
51
+ keepaliveInterval?: number;
52
+ }
53
+ /**
54
+ * WebSocket-based transport with auto-reconnect, keepalive, and state tracking.
55
+ */
56
+ declare class WsTransport extends AbstractTransport {
57
+ private ws;
58
+ private readonly url;
59
+ private readonly autoReconnect;
60
+ private readonly reconnectDelay;
61
+ private readonly reconnectMaxDelay;
62
+ private readonly reconnectMaxRetries;
63
+ private readonly keepaliveInterval;
64
+ private reconnectAttempt;
65
+ private reconnectTimer;
66
+ private keepaliveTimer;
67
+ private intentionalClose;
68
+ private _state;
69
+ constructor(options?: WsTransportOptions);
70
+ /** Current transport state. */
71
+ get state(): TransportState;
72
+ /** Open a WebSocket connection. Throws if already connecting or destroyed. */
73
+ connect(): Promise<void>;
74
+ /** Close the connection without triggering auto-reconnect. */
75
+ disconnect(): void;
76
+ /** Permanently destroy the transport. No further connect() calls are allowed. */
77
+ destroy(): void;
78
+ /** Send data over the WebSocket. Throws if not connected. */
79
+ send(data: string): void;
80
+ private setState;
81
+ private setupListeners;
82
+ private scheduleReconnect;
83
+ private clearReconnectTimer;
84
+ private startKeepalive;
85
+ private stopKeepalive;
86
+ private getWebSocketImpl;
87
+ }
88
+
89
+ declare global {
90
+ interface Window {
91
+ ton?: {
92
+ adnl?: {
93
+ send: (data: string) => void;
94
+ onMessage: (callback: (data: string) => void) => () => void;
95
+ };
96
+ };
97
+ }
98
+ }
99
+ /**
100
+ * IPC transport for Electron/browser preload environments that expose `window.ton.adnl`.
101
+ */
102
+ declare class IpcTransport extends AbstractTransport {
103
+ private unsubscribe;
104
+ private _state;
105
+ /** Current transport state. */
106
+ get state(): TransportState;
107
+ /** Connect to the IPC bridge via `window.ton.adnl`. */
108
+ connect(): Promise<void>;
109
+ /** Disconnect from the IPC bridge. */
110
+ disconnect(): void;
111
+ /** Permanently destroy the transport. */
112
+ destroy(): void;
113
+ /** Send data over the IPC bridge. */
114
+ send(data: string): void;
115
+ private setState;
116
+ }
117
+
118
+ /** Auto-detect the best transport: prefer IPC in Electron preload, otherwise WebSocket. */
119
+ declare function createTransport(options?: WsTransportOptions): AbstractTransport;
120
+
121
+ type PushHandler = (event: string, data: unknown) => void;
122
+ /** Logger interface accepted by RpcEngine. */
123
+ interface Logger {
124
+ debug: (...args: unknown[]) => void;
125
+ warn: (...args: unknown[]) => void;
126
+ error: (...args: unknown[]) => void;
127
+ }
128
+ interface RpcEngineOptions {
129
+ requestTimeout?: number;
130
+ logger?: Logger;
131
+ }
132
+ /** Options for individual RPC calls. */
133
+ interface CallOptions {
134
+ signal?: AbortSignal;
135
+ }
136
+ /**
137
+ * JSON-RPC 2.0 engine over an AbstractTransport.
138
+ * Handles request/response correlation, timeouts, push events, and abort signals.
139
+ */
140
+ declare class RpcEngine {
141
+ private transport;
142
+ private pending;
143
+ private pushHandler;
144
+ private readonly requestTimeout;
145
+ private readonly logger;
146
+ constructor(transport: AbstractTransport, options?: RpcEngineOptions);
147
+ /** Register a handler for push events (subscriptions, ADNL). */
148
+ setPushHandler(handler: PushHandler): void;
149
+ /**
150
+ * Send a JSON-RPC 2.0 request and return the result.
151
+ * @param method - The RPC method name.
152
+ * @param params - Optional parameters.
153
+ * @param options - Optional call options (abort signal).
154
+ */
155
+ call<T>(method: string, params?: unknown, options?: CallOptions): Promise<T>;
156
+ private handleMessage;
157
+ private rejectAll;
158
+ /** Destroy the engine, rejecting all pending calls. */
159
+ destroy(): void;
160
+ }
161
+
162
+ /** JSON-RPC 2.0 request sent over the WebSocket. */
163
+ interface WSRequest {
164
+ jsonrpc: '2.0';
165
+ id: string;
166
+ method: string;
167
+ params?: unknown;
168
+ }
169
+ /** JSON-RPC 2.0 response received from the bridge. */
170
+ interface WSResponse {
171
+ jsonrpc: string;
172
+ id: string;
173
+ result?: unknown;
174
+ error?: {
175
+ code: number;
176
+ message: string;
177
+ } | null;
178
+ }
179
+ /** Server-pushed event for subscriptions and ADNL/overlay notifications. */
180
+ interface WSEvent<T = unknown> {
181
+ event: string;
182
+ data: T;
183
+ }
184
+ /**
185
+ * TEP-64 content for NFTs. Serialized by Go `serializeContent`.
186
+ * Fields beyond `type`+`uri` are present only when the on-chain data includes them.
187
+ */
188
+ type NftTepContent = {
189
+ type: 'offchain';
190
+ uri: string;
191
+ } | {
192
+ type: 'semichain';
193
+ uri: string;
194
+ name?: string;
195
+ description?: string;
196
+ image?: string;
197
+ image_data?: string;
198
+ } | {
199
+ type: 'onchain';
200
+ name?: string;
201
+ description?: string;
202
+ image?: string;
203
+ image_data?: string;
204
+ } | {
205
+ type: 'unknown';
206
+ };
207
+ /**
208
+ * TEP-64 content for jettons. Serialized by Go `serializeJettonContent`.
209
+ * Includes `symbol` and `decimals` fields specific to fungible tokens.
210
+ */
211
+ type JettonTepContent = {
212
+ type: 'offchain';
213
+ uri: string;
214
+ } | {
215
+ type: 'semichain';
216
+ uri: string;
217
+ name?: string;
218
+ symbol?: string;
219
+ decimals?: string;
220
+ description?: string;
221
+ image?: string;
222
+ } | {
223
+ type: 'onchain';
224
+ name?: string;
225
+ symbol?: string;
226
+ decimals?: string;
227
+ description?: string;
228
+ image?: string;
229
+ image_data?: string;
230
+ } | {
231
+ type: 'unknown';
232
+ };
233
+ /** Params for `dht.findAddresses`. */
234
+ interface DhtFindAddressesParams {
235
+ /** Base64-encoded ADNL ID to look up. */
236
+ key: string;
237
+ }
238
+ /** A single address returned by the DHT. */
239
+ interface DhtAddress {
240
+ ip: string;
241
+ port: number;
242
+ }
243
+ /** Result of `dht.findAddresses`. */
244
+ interface DhtFindAddressesResult {
245
+ addresses: DhtAddress[];
246
+ /** Base64-encoded ed25519 public key. */
247
+ pubkey: string;
248
+ }
249
+ /** Params for `dht.findOverlayNodes`. */
250
+ interface DhtFindOverlayNodesParams {
251
+ /** Base64-encoded overlay key. */
252
+ overlay_key: string;
253
+ }
254
+ /** A single overlay node returned by the DHT. */
255
+ interface OverlayNodeInfo {
256
+ /** Base64-encoded ed25519 public key. */
257
+ id: string;
258
+ /** Base64-encoded overlay ID. */
259
+ overlay: string;
260
+ version: number;
261
+ }
262
+ /** Result of `dht.findOverlayNodes`. */
263
+ interface DhtFindOverlayNodesResult {
264
+ nodes: OverlayNodeInfo[];
265
+ count: number;
266
+ }
267
+ /** Params for `dht.findTunnelNodes`. */
268
+ /** A single relay node returned by the DHT. */
269
+ interface DhtRelayInfo {
270
+ /** Base64-encoded ADNL ID. */
271
+ adnl_id: string;
272
+ version: number;
273
+ }
274
+ /** Result of `dht.findTunnelNodes`. */
275
+ interface DhtFindTunnelNodesResult {
276
+ relays: DhtRelayInfo[];
277
+ count: number;
278
+ }
279
+ /** Params for `dht.findValue`. */
280
+ interface DhtFindValueParams {
281
+ /** Base64-encoded key ID. */
282
+ key_id: string;
283
+ name: string;
284
+ index: number;
285
+ }
286
+ /** Result of `dht.findValue`. */
287
+ interface DhtFindValueResult {
288
+ /** Base64-encoded value bytes. */
289
+ data: string;
290
+ ttl: number;
291
+ }
292
+ /** Result of `lite.getMasterchainInfo` (no params). */
293
+ interface LiteGetMasterchainInfoResult {
294
+ seqno: number;
295
+ workchain: number;
296
+ /** Hex-encoded shard ID. */
297
+ shard: string;
298
+ /** Hex-encoded root hash. */
299
+ root_hash: string;
300
+ /** Hex-encoded file hash. */
301
+ file_hash: string;
302
+ }
303
+ /** Params for `lite.getAccountState`. */
304
+ interface LiteGetAccountStateParams {
305
+ address: string;
306
+ }
307
+ /** Result of `lite.getAccountState`. */
308
+ interface LiteGetAccountStateResult {
309
+ /** One of "active", "frozen", "uninit". */
310
+ status: string;
311
+ /** Balance in nanotons. */
312
+ balance: string;
313
+ last_tx_lt: string;
314
+ /** Hex-encoded last transaction hash. */
315
+ last_tx_hash: string;
316
+ has_code: boolean;
317
+ has_data: boolean;
318
+ /** Base64 BOC of account code (present only when has_code is true). */
319
+ code?: string;
320
+ /** Base64 BOC of account data (present only when has_data is true). */
321
+ data?: string;
322
+ }
323
+ /** Params for `lite.runMethod`. */
324
+ interface LiteRunMethodParams {
325
+ address: string;
326
+ method: string;
327
+ params: unknown[];
328
+ }
329
+ /** Result of `lite.runMethod`. */
330
+ interface LiteRunMethodResult {
331
+ exit_code: number;
332
+ /** TVM stack items serialized as strings (big ints) or base64 (cells). */
333
+ stack: unknown[];
334
+ }
335
+ /** Params for `lite.sendMessage` and `lite.sendMessageWait`. */
336
+ interface LiteSendMessageParams {
337
+ /** Base64-encoded external message BOC. */
338
+ boc: string;
339
+ }
340
+ /** Result of `lite.sendMessage` and `lite.sendMessageWait`. */
341
+ interface LiteSendMessageResult {
342
+ /** Hex-encoded message cell hash. */
343
+ hash: string;
344
+ status: number;
345
+ }
346
+ /** Params for `lite.getTransactions`. */
347
+ interface LiteGetTransactionsParams {
348
+ address: string;
349
+ limit?: number;
350
+ /** Optional LT for pagination (decimal string). */
351
+ last_lt?: string;
352
+ /** Optional hex-encoded hash for pagination. */
353
+ last_hash?: string;
354
+ }
355
+ /** A message inside a transaction (matches Go `serializeMessage`). */
356
+ interface LiteTransactionMessage {
357
+ /** Sender address (empty string if external). */
358
+ source: string;
359
+ /** Destination address (empty string if external-out). */
360
+ destination: string;
361
+ /** Amount in nanotons ("0" for external messages). */
362
+ value: string;
363
+ /** Base64-encoded body BOC (empty string if no payload). */
364
+ body: string;
365
+ }
366
+ /** A single transaction (matches Go `serializeTransaction`). */
367
+ interface LiteTransaction {
368
+ /** Hex-encoded transaction hash. */
369
+ hash: string;
370
+ /** Logical time (decimal string). */
371
+ lt: string;
372
+ /** Unix timestamp. */
373
+ now: number;
374
+ /** Total fees in nanotons. */
375
+ total_fees: string;
376
+ /** Previous transaction LT (decimal string). */
377
+ prev_tx_lt: string;
378
+ /** Hex-encoded previous transaction hash. */
379
+ prev_tx_hash: string;
380
+ in_msg?: LiteTransactionMessage;
381
+ out_msgs: LiteTransactionMessage[];
382
+ }
383
+ /** Result of `lite.getTransactions`. */
384
+ interface LiteGetTransactionsResult {
385
+ transactions: LiteTransaction[];
386
+ }
387
+ /** Params for `lite.getTransaction`. */
388
+ interface LiteGetTransactionParams {
389
+ address: string;
390
+ /** Logical time (decimal string). */
391
+ lt: string;
392
+ }
393
+ /** Params for `lite.findTxByInMsgHash`. */
394
+ interface LiteFindTxByInMsgHashParams {
395
+ address: string;
396
+ /** Hex-encoded inbound message hash. */
397
+ msg_hash: string;
398
+ }
399
+ /** Params for `lite.findTxByOutMsgHash`. */
400
+ interface LiteFindTxByOutMsgHashParams {
401
+ address: string;
402
+ /** Hex-encoded outbound message hash. */
403
+ msg_hash: string;
404
+ }
405
+ /** Result of `lite.getTime` (no params). */
406
+ interface LiteGetTimeResult {
407
+ time: number;
408
+ }
409
+ /** Params for `lite.lookupBlock`. */
410
+ interface LiteLookupBlockParams {
411
+ workchain: number;
412
+ /** Hex-encoded shard ID. */
413
+ shard: string;
414
+ seqno: number;
415
+ }
416
+ /** Result of `lite.lookupBlock`. */
417
+ interface LiteLookupBlockResult {
418
+ workchain: number;
419
+ shard: string;
420
+ seqno: number;
421
+ root_hash: string;
422
+ file_hash: string;
423
+ }
424
+ /** Params for `lite.getBlockTransactions`. */
425
+ interface LiteGetBlockTransactionsParams {
426
+ workchain: number;
427
+ shard: string;
428
+ seqno: number;
429
+ count?: number;
430
+ }
431
+ /** A short transaction reference from a block. */
432
+ interface LiteBlockTransaction {
433
+ /** Hex-encoded account address. */
434
+ account: string;
435
+ lt: string;
436
+ /** Hex-encoded transaction hash. */
437
+ hash: string;
438
+ }
439
+ /** Result of `lite.getBlockTransactions`. */
440
+ interface LiteGetBlockTransactionsResult {
441
+ transactions: LiteBlockTransaction[];
442
+ incomplete: boolean;
443
+ }
444
+ /** Result of `lite.getShards` (no params). */
445
+ interface LiteShardInfo {
446
+ workchain: number;
447
+ shard: string;
448
+ seqno: number;
449
+ }
450
+ /** Result of `lite.getShards`. */
451
+ interface LiteGetShardsResult {
452
+ shards: LiteShardInfo[];
453
+ }
454
+ /** Params for `lite.getBlockchainConfig`. */
455
+ interface LiteGetBlockchainConfigParams {
456
+ params?: number[];
457
+ }
458
+ /** Result of `lite.getBlockchainConfig`. */
459
+ interface LiteGetBlockchainConfigResult {
460
+ /** Key is param ID (decimal string), value is base64 BOC or null. */
461
+ params: Record<string, string | null>;
462
+ }
463
+ /** Params for `lite.getBlockData`. */
464
+ interface LiteGetBlockDataParams {
465
+ workchain: number;
466
+ shard: string;
467
+ seqno: number;
468
+ }
469
+ /** Result of `lite.getBlockData`. */
470
+ interface LiteGetBlockDataResult {
471
+ /** Base64-encoded block BOC. */
472
+ boc: string;
473
+ }
474
+ /** Params for `lite.getBlockHeader`. */
475
+ interface LiteGetBlockHeaderParams {
476
+ workchain: number;
477
+ shard: string;
478
+ seqno: number;
479
+ }
480
+ /** Result of `lite.getBlockHeader`. */
481
+ interface LiteGetBlockHeaderResult {
482
+ workchain: number;
483
+ shard: string;
484
+ seqno: number;
485
+ root_hash: string;
486
+ file_hash: string;
487
+ /** Base64-encoded header proof BOC. */
488
+ header_boc: string;
489
+ }
490
+ /** Params for `lite.getLibraries`. */
491
+ interface LiteGetLibrariesParams {
492
+ /** Hex-encoded library cell hashes. */
493
+ hashes: string[];
494
+ }
495
+ /** A single library entry. */
496
+ interface LiteLibraryEntry {
497
+ /** Hex-encoded hash. */
498
+ hash: string;
499
+ /** Base64-encoded BOC. */
500
+ boc: string;
501
+ }
502
+ /** Result of `lite.getLibraries`. */
503
+ interface LiteGetLibrariesResult {
504
+ /** Array of library entries (null for missing hashes). */
505
+ libraries: (LiteLibraryEntry | null)[];
506
+ }
507
+ /** Params for `lite.sendAndWatch`. */
508
+ interface LiteSendAndWatchParams {
509
+ /** Base64-encoded external message BOC. */
510
+ boc: string;
511
+ }
512
+ /** Confirmation result of `lite.sendAndWatch`. */
513
+ interface LiteSendAndWatchResult {
514
+ watching: boolean;
515
+ subscription_id: string;
516
+ /** Hex-encoded message cell hash. */
517
+ msg_hash: string;
518
+ }
519
+ /** Params for `subscribe.transactions`. */
520
+ interface SubscribeTransactionsParams {
521
+ address: string;
522
+ last_lt?: string;
523
+ /** Optional list of opcodes to filter incoming transactions. */
524
+ operations?: number[];
525
+ }
526
+ /** Confirmation of `subscribe.transactions`. */
527
+ interface SubscribeTransactionsConfirmation {
528
+ subscribed: boolean;
529
+ address: string;
530
+ subscription_id: string;
531
+ }
532
+ /** Confirmation of `subscribe.blocks` (no params). */
533
+ interface SubscribeBlocksConfirmation {
534
+ subscribed: boolean;
535
+ start_seqno: number;
536
+ subscription_id: string;
537
+ }
538
+ /** Push data for the "block" event. */
539
+ interface SubscribeBlockEvent {
540
+ seqno: number;
541
+ workchain: number;
542
+ shard: string;
543
+ root_hash: string;
544
+ file_hash: string;
545
+ shards: LiteShardInfo[];
546
+ }
547
+ /** Params for `subscribe.accountState`. */
548
+ interface SubscribeAccountStateParams {
549
+ address: string;
550
+ }
551
+ /** Confirmation of `subscribe.accountState`. */
552
+ interface SubscribeAccountStateConfirmation {
553
+ subscribed: boolean;
554
+ address: string;
555
+ balance: string;
556
+ last_tx_lt: string;
557
+ subscription_id: string;
558
+ }
559
+ /** Push data for the "account_state" event. */
560
+ interface SubscribeAccountStateEvent {
561
+ address: string;
562
+ balance: string;
563
+ status: string;
564
+ last_tx_lt: string;
565
+ last_tx_hash: string;
566
+ block_seqno: number;
567
+ }
568
+ /** Confirmation of `subscribe.newTransactions` (no params). */
569
+ interface SubscribeNewTransactionsConfirmation {
570
+ subscribed: boolean;
571
+ start_seqno: number;
572
+ subscription_id: string;
573
+ }
574
+ /** Push data for the "new_transaction" event. */
575
+ interface SubscribeNewTransactionEvent {
576
+ /** Hex-encoded account address. */
577
+ account: string;
578
+ lt: string;
579
+ hash: string;
580
+ block_workchain: number;
581
+ block_shard: string;
582
+ block_seqno: number;
583
+ }
584
+ /** Params for `subscribe.configChanges`. */
585
+ interface SubscribeConfigChangesParams {
586
+ /** List of blockchain config param IDs to watch. */
587
+ params: number[];
588
+ }
589
+ /** Confirmation of `subscribe.configChanges`. */
590
+ interface SubscribeConfigChangesConfirmation {
591
+ subscribed: boolean;
592
+ start_seqno: number;
593
+ subscription_id: string;
594
+ }
595
+ /** Push data for the "config_changed" event. */
596
+ interface SubscribeConfigChangedEvent {
597
+ param_id: number;
598
+ block_seqno: number;
599
+ /** Base64-encoded BOC of the old value. */
600
+ old_value: string;
601
+ /** Base64-encoded BOC of the new value. */
602
+ new_value: string;
603
+ }
604
+ /** A single account entry for `subscribe.multiAccount`. */
605
+ interface MultiAccountEntry {
606
+ address: string;
607
+ last_lt?: string;
608
+ operations?: number[];
609
+ }
610
+ /** Params for `subscribe.multiAccount`. */
611
+ interface SubscribeMultiAccountParams {
612
+ accounts: MultiAccountEntry[];
613
+ }
614
+ /** Confirmation of `subscribe.multiAccount`. */
615
+ interface SubscribeMultiAccountConfirmation {
616
+ subscribed: boolean;
617
+ account_count: number;
618
+ subscription_id: string;
619
+ }
620
+ /** Params for `subscribe.trace`. */
621
+ interface SubscribeTraceParams {
622
+ address: string;
623
+ last_lt?: string;
624
+ /** Max depth of internal message chains (1-10, default 3). */
625
+ max_depth?: number;
626
+ /** Per-message timeout in seconds (1-120, default 10). */
627
+ msg_timeout_sec?: number;
628
+ }
629
+ /** Confirmation of `subscribe.trace`. */
630
+ interface SubscribeTraceConfirmation {
631
+ subscribed: boolean;
632
+ address: string;
633
+ subscription_id: string;
634
+ }
635
+ /** Push data for the "trace_started" event. */
636
+ interface TraceStartedEvent {
637
+ trace_id: string;
638
+ root_tx: LiteTransaction;
639
+ subscription_id: string;
640
+ }
641
+ /** Push data for the "trace_tx" event. */
642
+ interface TraceTxEvent {
643
+ trace_id: string;
644
+ transaction: LiteTransaction & {
645
+ address: string;
646
+ };
647
+ depth: number;
648
+ address: string;
649
+ }
650
+ /** Push data for the "trace_complete" event. */
651
+ interface TraceCompleteEvent {
652
+ trace_id: string;
653
+ total_txs: number;
654
+ max_depth_reached: number;
655
+ timed_out_count: number;
656
+ }
657
+ /** Push data for the "trace_timeout" event. */
658
+ interface TraceTimeoutEvent {
659
+ trace_id: string;
660
+ address: string;
661
+ body_hash: string;
662
+ depth: number;
663
+ }
664
+ /** Params for `subscribe.unsubscribe`. */
665
+ interface SubscribeUnsubscribeParams {
666
+ subscription_id: string;
667
+ }
668
+ /** Result of `subscribe.unsubscribe`. */
669
+ interface SubscribeUnsubscribeResult {
670
+ unsubscribed: boolean;
671
+ subscription_id: string;
672
+ }
673
+ /** Push data for the "tx_confirmed" event (from `lite.sendAndWatch`). */
674
+ interface TxConfirmedEvent {
675
+ msg_hash: string;
676
+ transaction: LiteTransaction;
677
+ block: {
678
+ seqno: number;
679
+ workchain: number;
680
+ shard: string;
681
+ };
682
+ }
683
+ /** Push data for the "tx_timeout" event (from `lite.sendAndWatch`). */
684
+ interface TxTimeoutEvent {
685
+ msg_hash: string;
686
+ reason: string;
687
+ }
688
+ /** Params for `jetton.getData`. */
689
+ interface JettonGetDataParams {
690
+ address: string;
691
+ }
692
+ /** Result of `jetton.getData`. */
693
+ interface JettonGetDataResult {
694
+ total_supply: string;
695
+ mintable: boolean;
696
+ admin: string | null;
697
+ /** TEP-64 content from `serializeJettonContent`. */
698
+ content: JettonTepContent;
699
+ }
700
+ /** Params for `jetton.getWalletAddress`. */
701
+ interface JettonGetWalletAddressParams {
702
+ jetton_master: string;
703
+ owner: string;
704
+ }
705
+ /** Result of `jetton.getWalletAddress`. */
706
+ interface JettonGetWalletAddressResult {
707
+ wallet_address: string;
708
+ }
709
+ /** Params for `jetton.getBalance`. */
710
+ interface JettonGetBalanceParams {
711
+ jetton_wallet: string;
712
+ }
713
+ /** Result of `jetton.getBalance`. */
714
+ interface JettonGetBalanceResult {
715
+ balance: string;
716
+ owner: string | null;
717
+ jetton_master: string | null;
718
+ }
719
+ /** Params for `nft.getData`. */
720
+ interface NftGetDataParams {
721
+ address: string;
722
+ }
723
+ /** Result of `nft.getData`. */
724
+ interface NftGetDataResult {
725
+ initialized: boolean;
726
+ index: string;
727
+ collection: string | null;
728
+ owner: string | null;
729
+ /** TEP-64 content from `serializeContent`. */
730
+ content: NftTepContent;
731
+ }
732
+ /** Params for `nft.getCollectionData`. */
733
+ interface NftGetCollectionDataParams {
734
+ address: string;
735
+ }
736
+ /** Result of `nft.getCollectionData`. */
737
+ interface NftGetCollectionDataResult {
738
+ next_item_index: string;
739
+ owner: string | null;
740
+ /** TEP-64 content from `serializeContent`. */
741
+ content: NftTepContent;
742
+ }
743
+ /** Params for `nft.getAddressByIndex`. */
744
+ interface NftGetAddressByIndexParams {
745
+ collection: string;
746
+ /** Decimal integer string. */
747
+ index: string;
748
+ }
749
+ /** Result of `nft.getAddressByIndex`. */
750
+ interface NftGetAddressByIndexResult {
751
+ address: string;
752
+ }
753
+ /** Params for `nft.getRoyaltyParams`. */
754
+ interface NftGetRoyaltyParamsParams {
755
+ collection: string;
756
+ }
757
+ /** Result of `nft.getRoyaltyParams`. */
758
+ interface NftGetRoyaltyParamsResult {
759
+ factor: number;
760
+ base: number;
761
+ address: string | null;
762
+ }
763
+ /** Params for `nft.getContent`. */
764
+ interface NftGetContentParams {
765
+ collection: string;
766
+ /** Decimal integer string. */
767
+ index: string;
768
+ /** Base64-encoded individual content BOC. */
769
+ individual_content: string;
770
+ }
771
+ /** Result of `nft.getContent`. */
772
+ interface NftGetContentResult {
773
+ content: NftTepContent;
774
+ }
775
+ /** Params for `wallet.getSeqno`. */
776
+ interface WalletGetSeqnoParams {
777
+ address: string;
778
+ }
779
+ /** Result of `wallet.getSeqno`. */
780
+ interface WalletGetSeqnoResult {
781
+ seqno: number;
782
+ }
783
+ /** Params for `wallet.getPublicKey`. */
784
+ interface WalletGetPublicKeyParams {
785
+ address: string;
786
+ }
787
+ /** Result of `wallet.getPublicKey`. */
788
+ interface WalletGetPublicKeyResult {
789
+ /** Base64-encoded ed25519 public key. */
790
+ public_key: string;
791
+ }
792
+ /** Params for `sbt.getAuthorityAddress`. */
793
+ interface SbtGetAuthorityAddressParams {
794
+ address: string;
795
+ }
796
+ /** Result of `sbt.getAuthorityAddress`. */
797
+ interface SbtGetAuthorityAddressResult {
798
+ authority: string | null;
799
+ }
800
+ /** Params for `sbt.getRevokedTime`. */
801
+ interface SbtGetRevokedTimeParams {
802
+ address: string;
803
+ }
804
+ /** Result of `sbt.getRevokedTime`. */
805
+ interface SbtGetRevokedTimeResult {
806
+ /** Unix timestamp; 0 means not revoked. */
807
+ revoked_time: number;
808
+ }
809
+ /** Params for `payment.getChannelState`. */
810
+ interface PaymentGetChannelStateParams {
811
+ address: string;
812
+ }
813
+ /** Semi-channel state within a quarantine record. */
814
+ interface PaymentSemiChannelState {
815
+ seqno: number;
816
+ /** Nanotons sent. */
817
+ sent: string;
818
+ }
819
+ /** Quarantine info for a payment channel (null when no quarantine is active). */
820
+ interface PaymentQuarantine {
821
+ quarantine_starts: number;
822
+ state_committed_by_a: boolean;
823
+ state_challenged: boolean;
824
+ state_a: PaymentSemiChannelState;
825
+ state_b: PaymentSemiChannelState;
826
+ }
827
+ /** Closing configuration of a payment channel. */
828
+ interface PaymentClosingConfig {
829
+ quarantine_duration: number;
830
+ conditional_close_duration: number;
831
+ /** Misbehavior fine in nanotons. */
832
+ misbehavior_fine: string;
833
+ }
834
+ /** Result of `payment.getChannelState`. */
835
+ interface PaymentGetChannelStateResult {
836
+ status: number;
837
+ initialized: boolean;
838
+ /** Balance of party A in nanotons. */
839
+ balance_a: string;
840
+ /** Balance of party B in nanotons. */
841
+ balance_b: string;
842
+ /** Base64-encoded ed25519 public key of party A. */
843
+ key_a: string;
844
+ /** Base64-encoded ed25519 public key of party B. */
845
+ key_b: string;
846
+ /** Hex-encoded channel ID. */
847
+ channel_id: string;
848
+ committed_seqno_a: number;
849
+ committed_seqno_b: number;
850
+ quarantine: PaymentQuarantine | null;
851
+ dest_a: string | null;
852
+ dest_b: string | null;
853
+ /** Excess fee in nanotons. */
854
+ excess_fee: string;
855
+ closing_config: PaymentClosingConfig;
856
+ }
857
+ /** Params for `dns.resolve`. */
858
+ interface DnsResolveParams {
859
+ domain: string;
860
+ }
861
+ /** Result of `dns.resolve`. */
862
+ interface DnsResolveResult {
863
+ wallet: string | null;
864
+ /** Hex-encoded ADNL address of the site record. */
865
+ site_adnl: string | null;
866
+ has_storage: boolean;
867
+ owner: string | null;
868
+ nft_address: string | null;
869
+ collection: string | null;
870
+ editor: string | null;
871
+ initialized: boolean;
872
+ /** Unix timestamp or null if unknown. */
873
+ expiring_at: number | null;
874
+ /** Map of sha256(name) hex keys to text values (category 0x1eda). */
875
+ text_records?: Record<string, string>;
876
+ }
877
+ /** Params for `adnl.connect`. */
878
+ interface AdnlConnectParams {
879
+ address: string;
880
+ /** Base64-encoded ed25519 public key. */
881
+ key: string;
882
+ }
883
+ /** Result of `adnl.connect` and `adnl.connectByADNL`. */
884
+ interface AdnlConnectResult {
885
+ connected: boolean;
886
+ /** Base64-encoded peer ID. */
887
+ peer_id: string;
888
+ remote_addr: string;
889
+ }
890
+ /** Params for `adnl.connectByADNL`. */
891
+ interface AdnlConnectByAdnlParams {
892
+ /** Base64-encoded ADNL ID. */
893
+ adnl_id: string;
894
+ }
895
+ /** Params for `adnl.sendMessage`. */
896
+ interface AdnlSendMessageParams {
897
+ /** Base64-encoded peer ID. */
898
+ peer_id: string;
899
+ /** Base64-encoded message data. */
900
+ data: string;
901
+ }
902
+ /** Result of `adnl.sendMessage`. */
903
+ interface AdnlSendMessageResult {
904
+ sent: boolean;
905
+ }
906
+ /** Params for `adnl.ping`. */
907
+ interface AdnlPingParams {
908
+ /** Base64-encoded peer ID. */
909
+ peer_id: string;
910
+ }
911
+ /** Result of `adnl.ping`. */
912
+ interface AdnlPingResult {
913
+ latency_ms: number;
914
+ }
915
+ /** Params for `adnl.disconnect`. */
916
+ interface AdnlDisconnectParams {
917
+ /** Base64-encoded peer ID. */
918
+ peer_id: string;
919
+ }
920
+ /** Result of `adnl.disconnect`. */
921
+ interface AdnlDisconnectResult {
922
+ disconnected: boolean;
923
+ }
924
+ /** Result of `adnl.peers` (no params). */
925
+ interface AdnlPeerInfo {
926
+ /** Base64-encoded peer ID. */
927
+ id: string;
928
+ addr: string;
929
+ }
930
+ /** Result of `adnl.peers`. */
931
+ interface AdnlPeersResult {
932
+ peers: AdnlPeerInfo[];
933
+ }
934
+ /** Params for `adnl.query`. */
935
+ interface AdnlQueryParams {
936
+ /** Base64-encoded peer ID. */
937
+ peer_id: string;
938
+ /** Base64-encoded TL-serialized request. */
939
+ data: string;
940
+ /** Optional timeout in seconds (1-60, default 15). */
941
+ timeout?: number;
942
+ }
943
+ /** Result of `adnl.query`. */
944
+ interface AdnlQueryResult {
945
+ /** Base64-encoded TL-serialized response. */
946
+ data: string;
947
+ }
948
+ /** Params for `adnl.setQueryHandler`. */
949
+ interface AdnlSetQueryHandlerParams {
950
+ /** Base64-encoded peer ID. */
951
+ peer_id: string;
952
+ }
953
+ /** Result of `adnl.setQueryHandler`. */
954
+ interface AdnlSetQueryHandlerResult {
955
+ enabled: boolean;
956
+ }
957
+ /** Params for `adnl.answer`. */
958
+ interface AdnlAnswerParams {
959
+ /** Hex-encoded query ID. */
960
+ query_id: string;
961
+ /** Base64-encoded TL-serialized response. */
962
+ data: string;
963
+ }
964
+ /** Result of `adnl.answer`. */
965
+ interface AdnlAnswerResult {
966
+ answered: boolean;
967
+ }
968
+ /** Push data for the "adnl.message" event. */
969
+ interface AdnlMessageEvent {
970
+ /** Base64-encoded peer ID. */
971
+ from: string;
972
+ /** Base64-encoded message data. */
973
+ message: string;
974
+ }
975
+ /** Push data for the "adnl.disconnected" event. */
976
+ interface AdnlDisconnectedEvent {
977
+ /** Base64-encoded peer ID. */
978
+ peer: string;
979
+ }
980
+ /** Push data for the "adnl.incomingConnection" event. */
981
+ interface AdnlIncomingConnectionEvent {
982
+ /** Base64-encoded peer ID. */
983
+ peer_id: string;
984
+ remote_addr: string;
985
+ }
986
+ /** Push data for the "adnl.queryReceived" event. */
987
+ interface AdnlQueryReceivedEvent {
988
+ /** Base64-encoded peer ID. */
989
+ peer_id: string;
990
+ /** Hex-encoded query ID. */
991
+ query_id: string;
992
+ /** Base64-encoded query data. */
993
+ data: string;
994
+ }
995
+ /** Params for `overlay.join`. */
996
+ interface OverlayJoinParams {
997
+ /** Base64-encoded overlay ID. */
998
+ overlay_id: string;
999
+ /** Base64-encoded ADNL peer ID. */
1000
+ peer_id: string;
1001
+ }
1002
+ /** Result of `overlay.join`. */
1003
+ interface OverlayJoinResult {
1004
+ joined: boolean;
1005
+ overlay_id: string;
1006
+ }
1007
+ /** Params for `overlay.leave`. */
1008
+ interface OverlayLeaveParams {
1009
+ overlay_id: string;
1010
+ }
1011
+ /** Result of `overlay.leave`. */
1012
+ interface OverlayLeaveResult {
1013
+ left: boolean;
1014
+ }
1015
+ /** Params for `overlay.getPeers`. */
1016
+ interface OverlayGetPeersParams {
1017
+ overlay_id: string;
1018
+ }
1019
+ /** A single peer inside an overlay. */
1020
+ interface OverlayPeerInfo {
1021
+ /** Base64-encoded ed25519 public key. */
1022
+ id: string;
1023
+ /** Base64-encoded overlay ID. */
1024
+ overlay: string;
1025
+ }
1026
+ /** Result of `overlay.getPeers`. */
1027
+ interface OverlayGetPeersResult {
1028
+ peers: OverlayPeerInfo[];
1029
+ }
1030
+ /** Params for `overlay.sendMessage`. */
1031
+ interface OverlaySendMessageParams {
1032
+ overlay_id: string;
1033
+ /** Base64-encoded message data. */
1034
+ data: string;
1035
+ }
1036
+ /** Result of `overlay.sendMessage`. */
1037
+ interface OverlaySendMessageResult {
1038
+ sent: boolean;
1039
+ }
1040
+ /** Params for `overlay.query`. */
1041
+ interface OverlayQueryParams {
1042
+ overlay_id: string;
1043
+ /** Base64-encoded TL-serialized request. */
1044
+ data: string;
1045
+ /** Optional timeout in seconds (1-60, default 15). */
1046
+ timeout?: number;
1047
+ }
1048
+ /** Result of `overlay.query`. */
1049
+ interface OverlayQueryResult {
1050
+ /** Base64-encoded TL-serialized response. */
1051
+ data: string;
1052
+ }
1053
+ /** Params for `overlay.setQueryHandler`. */
1054
+ interface OverlaySetQueryHandlerParams {
1055
+ overlay_id: string;
1056
+ /** Base64-encoded ADNL peer ID that owns this overlay. */
1057
+ peer_id: string;
1058
+ }
1059
+ /** Result of `overlay.setQueryHandler`. */
1060
+ interface OverlaySetQueryHandlerResult {
1061
+ enabled: boolean;
1062
+ }
1063
+ /** Params for `overlay.answer`. */
1064
+ interface OverlayAnswerParams {
1065
+ /** Hex-encoded query ID. */
1066
+ query_id: string;
1067
+ /** Base64-encoded TL-serialized response. */
1068
+ data: string;
1069
+ }
1070
+ /** Result of `overlay.answer`. */
1071
+ interface OverlayAnswerResult {
1072
+ answered: boolean;
1073
+ }
1074
+ /** Push data for the "overlay.broadcast" event. */
1075
+ interface OverlayBroadcastEvent {
1076
+ overlay_id: string;
1077
+ /** Base64-encoded broadcast data. */
1078
+ message: string;
1079
+ trusted: boolean;
1080
+ }
1081
+ /** Push data for the "overlay.message" event. */
1082
+ interface OverlayMessageEvent {
1083
+ overlay_id: string;
1084
+ /** Base64-encoded message data. */
1085
+ message: string;
1086
+ }
1087
+ /** Push data for the "overlay.queryReceived" event. */
1088
+ interface OverlayQueryReceivedEvent {
1089
+ overlay_id: string;
1090
+ /** Hex-encoded query ID. */
1091
+ query_id: string;
1092
+ /** Base64-encoded query data. */
1093
+ data: string;
1094
+ }
1095
+ /** Result of `network.info` (no params). */
1096
+ interface NetworkInfoResult {
1097
+ dht_connected: boolean;
1098
+ ws_clients: number;
1099
+ }
1100
+ interface MethodMap {
1101
+ 'dht.findAddresses': {
1102
+ params: DhtFindAddressesParams;
1103
+ result: DhtFindAddressesResult;
1104
+ };
1105
+ 'dht.findOverlayNodes': {
1106
+ params: DhtFindOverlayNodesParams;
1107
+ result: DhtFindOverlayNodesResult;
1108
+ };
1109
+ 'dht.findTunnelNodes': {
1110
+ params: undefined;
1111
+ result: DhtFindTunnelNodesResult;
1112
+ };
1113
+ 'dht.findValue': {
1114
+ params: DhtFindValueParams;
1115
+ result: DhtFindValueResult;
1116
+ };
1117
+ 'lite.getMasterchainInfo': {
1118
+ params: undefined;
1119
+ result: LiteGetMasterchainInfoResult;
1120
+ };
1121
+ 'lite.getAccountState': {
1122
+ params: LiteGetAccountStateParams;
1123
+ result: LiteGetAccountStateResult;
1124
+ };
1125
+ 'lite.runMethod': {
1126
+ params: LiteRunMethodParams;
1127
+ result: LiteRunMethodResult;
1128
+ };
1129
+ 'lite.sendMessage': {
1130
+ params: LiteSendMessageParams;
1131
+ result: LiteSendMessageResult;
1132
+ };
1133
+ 'lite.sendMessageWait': {
1134
+ params: LiteSendMessageParams;
1135
+ result: LiteSendMessageResult;
1136
+ };
1137
+ 'lite.getTransactions': {
1138
+ params: LiteGetTransactionsParams;
1139
+ result: LiteGetTransactionsResult;
1140
+ };
1141
+ 'lite.getTransaction': {
1142
+ params: LiteGetTransactionParams;
1143
+ result: LiteTransaction;
1144
+ };
1145
+ 'lite.findTxByInMsgHash': {
1146
+ params: LiteFindTxByInMsgHashParams;
1147
+ result: LiteTransaction;
1148
+ };
1149
+ 'lite.findTxByOutMsgHash': {
1150
+ params: LiteFindTxByOutMsgHashParams;
1151
+ result: LiteTransaction;
1152
+ };
1153
+ 'lite.getTime': {
1154
+ params: undefined;
1155
+ result: LiteGetTimeResult;
1156
+ };
1157
+ 'lite.lookupBlock': {
1158
+ params: LiteLookupBlockParams;
1159
+ result: LiteLookupBlockResult;
1160
+ };
1161
+ 'lite.getBlockTransactions': {
1162
+ params: LiteGetBlockTransactionsParams;
1163
+ result: LiteGetBlockTransactionsResult;
1164
+ };
1165
+ 'lite.getShards': {
1166
+ params: undefined;
1167
+ result: LiteGetShardsResult;
1168
+ };
1169
+ 'lite.getBlockchainConfig': {
1170
+ params: LiteGetBlockchainConfigParams;
1171
+ result: LiteGetBlockchainConfigResult;
1172
+ };
1173
+ 'lite.sendAndWatch': {
1174
+ params: LiteSendAndWatchParams;
1175
+ result: LiteSendAndWatchResult;
1176
+ };
1177
+ 'lite.getBlockData': {
1178
+ params: LiteGetBlockDataParams;
1179
+ result: LiteGetBlockDataResult;
1180
+ };
1181
+ 'lite.getBlockHeader': {
1182
+ params: LiteGetBlockHeaderParams;
1183
+ result: LiteGetBlockHeaderResult;
1184
+ };
1185
+ 'lite.getLibraries': {
1186
+ params: LiteGetLibrariesParams;
1187
+ result: LiteGetLibrariesResult;
1188
+ };
1189
+ 'subscribe.transactions': {
1190
+ params: SubscribeTransactionsParams;
1191
+ result: SubscribeTransactionsConfirmation;
1192
+ };
1193
+ 'subscribe.blocks': {
1194
+ params: undefined;
1195
+ result: SubscribeBlocksConfirmation;
1196
+ };
1197
+ 'subscribe.accountState': {
1198
+ params: SubscribeAccountStateParams;
1199
+ result: SubscribeAccountStateConfirmation;
1200
+ };
1201
+ 'subscribe.newTransactions': {
1202
+ params: undefined;
1203
+ result: SubscribeNewTransactionsConfirmation;
1204
+ };
1205
+ 'subscribe.configChanges': {
1206
+ params: SubscribeConfigChangesParams;
1207
+ result: SubscribeConfigChangesConfirmation;
1208
+ };
1209
+ 'subscribe.multiAccount': {
1210
+ params: SubscribeMultiAccountParams;
1211
+ result: SubscribeMultiAccountConfirmation;
1212
+ };
1213
+ 'subscribe.trace': {
1214
+ params: SubscribeTraceParams;
1215
+ result: SubscribeTraceConfirmation;
1216
+ };
1217
+ 'subscribe.unsubscribe': {
1218
+ params: SubscribeUnsubscribeParams;
1219
+ result: SubscribeUnsubscribeResult;
1220
+ };
1221
+ 'jetton.getData': {
1222
+ params: JettonGetDataParams;
1223
+ result: JettonGetDataResult;
1224
+ };
1225
+ 'jetton.getWalletAddress': {
1226
+ params: JettonGetWalletAddressParams;
1227
+ result: JettonGetWalletAddressResult;
1228
+ };
1229
+ 'jetton.getBalance': {
1230
+ params: JettonGetBalanceParams;
1231
+ result: JettonGetBalanceResult;
1232
+ };
1233
+ 'nft.getData': {
1234
+ params: NftGetDataParams;
1235
+ result: NftGetDataResult;
1236
+ };
1237
+ 'nft.getCollectionData': {
1238
+ params: NftGetCollectionDataParams;
1239
+ result: NftGetCollectionDataResult;
1240
+ };
1241
+ 'nft.getAddressByIndex': {
1242
+ params: NftGetAddressByIndexParams;
1243
+ result: NftGetAddressByIndexResult;
1244
+ };
1245
+ 'nft.getRoyaltyParams': {
1246
+ params: NftGetRoyaltyParamsParams;
1247
+ result: NftGetRoyaltyParamsResult;
1248
+ };
1249
+ 'nft.getContent': {
1250
+ params: NftGetContentParams;
1251
+ result: NftGetContentResult;
1252
+ };
1253
+ 'wallet.getSeqno': {
1254
+ params: WalletGetSeqnoParams;
1255
+ result: WalletGetSeqnoResult;
1256
+ };
1257
+ 'wallet.getPublicKey': {
1258
+ params: WalletGetPublicKeyParams;
1259
+ result: WalletGetPublicKeyResult;
1260
+ };
1261
+ 'sbt.getAuthorityAddress': {
1262
+ params: SbtGetAuthorityAddressParams;
1263
+ result: SbtGetAuthorityAddressResult;
1264
+ };
1265
+ 'sbt.getRevokedTime': {
1266
+ params: SbtGetRevokedTimeParams;
1267
+ result: SbtGetRevokedTimeResult;
1268
+ };
1269
+ 'payment.getChannelState': {
1270
+ params: PaymentGetChannelStateParams;
1271
+ result: PaymentGetChannelStateResult;
1272
+ };
1273
+ 'dns.resolve': {
1274
+ params: DnsResolveParams;
1275
+ result: DnsResolveResult;
1276
+ };
1277
+ 'adnl.connect': {
1278
+ params: AdnlConnectParams;
1279
+ result: AdnlConnectResult;
1280
+ };
1281
+ 'adnl.connectByADNL': {
1282
+ params: AdnlConnectByAdnlParams;
1283
+ result: AdnlConnectResult;
1284
+ };
1285
+ 'adnl.sendMessage': {
1286
+ params: AdnlSendMessageParams;
1287
+ result: AdnlSendMessageResult;
1288
+ };
1289
+ 'adnl.ping': {
1290
+ params: AdnlPingParams;
1291
+ result: AdnlPingResult;
1292
+ };
1293
+ 'adnl.disconnect': {
1294
+ params: AdnlDisconnectParams;
1295
+ result: AdnlDisconnectResult;
1296
+ };
1297
+ 'adnl.peers': {
1298
+ params: undefined;
1299
+ result: AdnlPeersResult;
1300
+ };
1301
+ 'adnl.query': {
1302
+ params: AdnlQueryParams;
1303
+ result: AdnlQueryResult;
1304
+ };
1305
+ 'adnl.setQueryHandler': {
1306
+ params: AdnlSetQueryHandlerParams;
1307
+ result: AdnlSetQueryHandlerResult;
1308
+ };
1309
+ 'adnl.answer': {
1310
+ params: AdnlAnswerParams;
1311
+ result: AdnlAnswerResult;
1312
+ };
1313
+ 'overlay.join': {
1314
+ params: OverlayJoinParams;
1315
+ result: OverlayJoinResult;
1316
+ };
1317
+ 'overlay.leave': {
1318
+ params: OverlayLeaveParams;
1319
+ result: OverlayLeaveResult;
1320
+ };
1321
+ 'overlay.getPeers': {
1322
+ params: OverlayGetPeersParams;
1323
+ result: OverlayGetPeersResult;
1324
+ };
1325
+ 'overlay.sendMessage': {
1326
+ params: OverlaySendMessageParams;
1327
+ result: OverlaySendMessageResult;
1328
+ };
1329
+ 'overlay.query': {
1330
+ params: OverlayQueryParams;
1331
+ result: OverlayQueryResult;
1332
+ };
1333
+ 'overlay.setQueryHandler': {
1334
+ params: OverlaySetQueryHandlerParams;
1335
+ result: OverlaySetQueryHandlerResult;
1336
+ };
1337
+ 'overlay.answer': {
1338
+ params: OverlayAnswerParams;
1339
+ result: OverlayAnswerResult;
1340
+ };
1341
+ 'network.info': {
1342
+ params: undefined;
1343
+ result: NetworkInfoResult;
1344
+ };
1345
+ }
1346
+ interface SubscriptionEventMap {
1347
+ 'transaction': LiteTransaction;
1348
+ 'block': SubscribeBlockEvent;
1349
+ 'account_state': SubscribeAccountStateEvent;
1350
+ 'new_transaction': SubscribeNewTransactionEvent;
1351
+ 'config_changed': SubscribeConfigChangedEvent;
1352
+ 'trace_started': TraceStartedEvent;
1353
+ 'trace_tx': TraceTxEvent;
1354
+ 'trace_complete': TraceCompleteEvent;
1355
+ 'trace_timeout': TraceTimeoutEvent;
1356
+ 'tx_confirmed': TxConfirmedEvent;
1357
+ 'tx_timeout': TxTimeoutEvent;
1358
+ 'adnl.message': AdnlMessageEvent;
1359
+ 'adnl.disconnected': AdnlDisconnectedEvent;
1360
+ 'adnl.incomingConnection': AdnlIncomingConnectionEvent;
1361
+ 'adnl.queryReceived': AdnlQueryReceivedEvent;
1362
+ 'overlay.broadcast': OverlayBroadcastEvent;
1363
+ 'overlay.message': OverlayMessageEvent;
1364
+ 'overlay.queryReceived': OverlayQueryReceivedEvent;
1365
+ }
1366
+
1367
+ /**
1368
+ * Base class for all namespace implementations.
1369
+ * Provides a type-safe `call` helper wired to the MethodMap.
1370
+ */
1371
+ declare abstract class BaseNamespace {
1372
+ protected rpc: RpcEngine;
1373
+ constructor(rpc: RpcEngine);
1374
+ /** Send a typed JSON-RPC call through the engine. */
1375
+ protected call<M extends keyof MethodMap>(method: M, params?: MethodMap[M]['params'], options?: CallOptions): Promise<MethodMap[M]['result']>;
1376
+ }
1377
+
1378
+ /** DHT namespace — distributed hash table lookups. */
1379
+ declare class DhtNamespace extends BaseNamespace {
1380
+ /** Look up ADNL addresses for a given key. */
1381
+ findAddresses(params: DhtFindAddressesParams, options?: CallOptions): Promise<DhtFindAddressesResult>;
1382
+ /** Find overlay nodes for a given overlay key. */
1383
+ findOverlayNodes(params: DhtFindOverlayNodesParams, options?: CallOptions): Promise<DhtFindOverlayNodesResult>;
1384
+ /** Discover tunnel relay nodes from the DHT. */
1385
+ findTunnelNodes(options?: CallOptions): Promise<DhtFindTunnelNodesResult>;
1386
+ /** Look up an arbitrary value in the DHT. */
1387
+ findValue(params: DhtFindValueParams, options?: CallOptions): Promise<DhtFindValueResult>;
1388
+ }
1389
+
1390
+ interface SubscriptionOptions {
1391
+ /** Maximum buffered events for the async iterator. Oldest are dropped when exceeded. Default: 1000. */
1392
+ highWaterMark?: number;
1393
+ }
1394
+ /**
1395
+ * A typed subscription to push events from the bridge.
1396
+ * Supports both listener-based and async-iterator consumption.
1397
+ */
1398
+ declare class Subscription<T> {
1399
+ readonly event: string;
1400
+ private onUnsubscribe;
1401
+ private listeners;
1402
+ private errorListeners;
1403
+ private _active;
1404
+ private _iteratorResolve;
1405
+ private readonly highWaterMark;
1406
+ constructor(event: string, onUnsubscribe: () => void, options?: SubscriptionOptions);
1407
+ /** Whether the subscription is still active. */
1408
+ get active(): boolean;
1409
+ /** Register a data or error listener. */
1410
+ on(event: 'data', listener: (data: T) => void): this;
1411
+ on(event: 'error', listener: (error: Error) => void): this;
1412
+ /** Remove a data or error listener. */
1413
+ off(event: 'data', listener: (data: T) => void): this;
1414
+ off(event: 'error', listener: (error: Error) => void): this;
1415
+ /** @internal Called by SubscriptionManager to deliver push events. */
1416
+ _deliver(data: T): void;
1417
+ /** @internal Called by SubscriptionManager on error. */
1418
+ _error(error: Error): void;
1419
+ /** Unsubscribe, releasing all listeners and unblocking any active async iterator. */
1420
+ unsubscribe(): Promise<void>;
1421
+ /** Consume events as an async iterable. Respects backpressure via highWaterMark. */
1422
+ [Symbol.asyncIterator](): AsyncIterableIterator<T>;
1423
+ }
1424
+
1425
+ /** Listener type for raw ADNL events. */
1426
+ type AdnlListener = (data: unknown) => void;
1427
+ /**
1428
+ * Manages subscriptions and ADNL event listeners.
1429
+ * Routes push events from the RPC engine to the correct subscription or listener.
1430
+ */
1431
+ declare class SubscriptionManager {
1432
+ private subscriptions;
1433
+ private adnlListeners;
1434
+ private subscriptionIds;
1435
+ /** Register a subscription for a push event type. */
1436
+ register<T>(eventType: string, onUnsubscribe: () => void, options?: SubscriptionOptions): Subscription<T>;
1437
+ /** Store the bridge-assigned subscription ID for a subscription. */
1438
+ setSubscriptionId(subscriptionId: string, subscription: Subscription<unknown>): void;
1439
+ /** Get a subscription by its bridge-assigned ID. */
1440
+ getBySubscriptionId(subscriptionId: string): Subscription<unknown> | undefined;
1441
+ /** Route a push event to all matching subscriptions. */
1442
+ handleEvent(event: string, data: unknown): void;
1443
+ /** Register an ADNL event listener. */
1444
+ onAdnl(event: string, listener: AdnlListener): void;
1445
+ /** Remove an ADNL event listener. */
1446
+ offAdnl(event: string, listener: AdnlListener): void;
1447
+ /**
1448
+ * Returns all active subscriptions as event-type entries for resubscription after reconnect.
1449
+ * The caller (typically the client) should iterate this list and re-send subscribe RPCs
1450
+ * to the bridge, then update subscription IDs via setSubscriptionId().
1451
+ */
1452
+ getResubscribeEntries(): Array<{
1453
+ eventType: string;
1454
+ subscription: Subscription<unknown>;
1455
+ }>;
1456
+ /**
1457
+ * Resubscribe all active subscriptions after a reconnect.
1458
+ * Accepts a callback that performs the actual RPC subscribe call for each entry
1459
+ * and returns the new subscription_id from the bridge.
1460
+ * Old subscription IDs are cleared and replaced with new ones.
1461
+ */
1462
+ resubscribe(doSubscribe: (eventType: string) => Promise<string>): Promise<void>;
1463
+ /** Number of active subscriptions (for debugging). */
1464
+ get activeCount(): number;
1465
+ /** Clear all subscriptions and ADNL listeners (e.g. on disconnect). */
1466
+ clear(): void;
1467
+ }
1468
+
1469
+ /** Union of events delivered to a sendAndWatch subscription. */
1470
+ type SendAndWatchEvent = TxConfirmedEvent | TxTimeoutEvent;
1471
+ /** Liteserver namespace — blockchain queries and transaction submission. */
1472
+ declare class LiteNamespace extends BaseNamespace {
1473
+ private manager;
1474
+ constructor(rpc: RpcEngine, manager: SubscriptionManager);
1475
+ /** Get the latest masterchain block info. */
1476
+ getMasterchainInfo(options?: CallOptions): Promise<LiteGetMasterchainInfoResult>;
1477
+ /** Get the state of an account. */
1478
+ getAccountState(params: LiteGetAccountStateParams, options?: CallOptions): Promise<LiteGetAccountStateResult>;
1479
+ /** Run a get-method on a smart contract. */
1480
+ runMethod(params: LiteRunMethodParams, options?: CallOptions): Promise<LiteRunMethodResult>;
1481
+ /** Send an external message (fire and forget). */
1482
+ sendMessage(params: LiteSendMessageParams, options?: CallOptions): Promise<LiteSendMessageResult>;
1483
+ /** Send an external message and wait for processing confirmation. */
1484
+ sendMessageWait(params: LiteSendMessageParams, options?: CallOptions): Promise<LiteSendMessageResult>;
1485
+ /** Get account transactions with optional pagination. */
1486
+ getTransactions(params: LiteGetTransactionsParams, options?: CallOptions): Promise<LiteGetTransactionsResult>;
1487
+ /** Get a single transaction by address and LT. */
1488
+ getTransaction(params: LiteGetTransactionParams, options?: CallOptions): Promise<LiteTransaction>;
1489
+ /** Find a transaction by its inbound message hash. */
1490
+ findTxByInMsgHash(params: LiteFindTxByInMsgHashParams, options?: CallOptions): Promise<LiteTransaction>;
1491
+ /** Find a transaction by its outbound message hash. */
1492
+ findTxByOutMsgHash(params: LiteFindTxByOutMsgHashParams, options?: CallOptions): Promise<LiteTransaction>;
1493
+ /** Get the current liteserver time. */
1494
+ getTime(options?: CallOptions): Promise<LiteGetTimeResult>;
1495
+ /** Look up a block by workchain, shard, and seqno. */
1496
+ lookupBlock(params: LiteLookupBlockParams, options?: CallOptions): Promise<LiteLookupBlockResult>;
1497
+ /** Get short transaction references from a block. */
1498
+ getBlockTransactions(params: LiteGetBlockTransactionsParams, options?: CallOptions): Promise<LiteGetBlockTransactionsResult>;
1499
+ /** Get current shard descriptors. */
1500
+ getShards(options?: CallOptions): Promise<LiteGetShardsResult>;
1501
+ /** Get blockchain configuration parameters. */
1502
+ getBlockchainConfig(params?: LiteGetBlockchainConfigParams, options?: CallOptions): Promise<LiteGetBlockchainConfigResult>;
1503
+ /**
1504
+ * Send a message and subscribe to tx_confirmed / tx_timeout events.
1505
+ * Returns a Subscription that delivers {@link SendAndWatchEvent} push events.
1506
+ */
1507
+ sendAndWatch(params: LiteSendAndWatchParams, options?: CallOptions): Promise<{
1508
+ confirmation: LiteSendAndWatchResult;
1509
+ subscription: Subscription<SendAndWatchEvent>;
1510
+ }>;
1511
+ /** Get the raw block BOC. */
1512
+ getBlockData(params: LiteGetBlockDataParams, options?: CallOptions): Promise<LiteGetBlockDataResult>;
1513
+ /** Get the block header proof BOC. */
1514
+ getBlockHeader(params: LiteGetBlockHeaderParams, options?: CallOptions): Promise<LiteGetBlockHeaderResult>;
1515
+ /** Get library cells by their hashes. */
1516
+ getLibraries(params: LiteGetLibrariesParams, options?: CallOptions): Promise<LiteGetLibrariesResult>;
1517
+ }
1518
+
1519
+ /** Union of all trace push events. */
1520
+ type TraceEvent = TraceStartedEvent | TraceTxEvent | TraceCompleteEvent | TraceTimeoutEvent;
1521
+ /** Subscribe namespace — real-time event subscriptions. */
1522
+ declare class SubscribeNamespace extends BaseNamespace {
1523
+ private manager;
1524
+ constructor(rpc: RpcEngine, manager: SubscriptionManager);
1525
+ /** Subscribe to transactions for a specific account. */
1526
+ transactions(params: SubscribeTransactionsParams, options?: CallOptions): Promise<Subscription<LiteTransaction>>;
1527
+ /** Subscribe to new masterchain blocks. */
1528
+ blocks(options?: CallOptions): Promise<Subscription<SubscribeBlockEvent>>;
1529
+ /** Subscribe to account state changes. */
1530
+ accountState(params: SubscribeAccountStateParams, options?: CallOptions): Promise<Subscription<SubscribeAccountStateEvent>>;
1531
+ /** Subscribe to all new transactions across the blockchain. */
1532
+ newTransactions(options?: CallOptions): Promise<Subscription<SubscribeNewTransactionEvent>>;
1533
+ /** Subscribe to blockchain config parameter changes. */
1534
+ configChanges(params: SubscribeConfigChangesParams, options?: CallOptions): Promise<Subscription<SubscribeConfigChangedEvent>>;
1535
+ /** Subscribe to transactions across multiple accounts. */
1536
+ multiAccount(params: SubscribeMultiAccountParams, options?: CallOptions): Promise<Subscription<LiteTransaction>>;
1537
+ /**
1538
+ * Subscribe to transaction traces (internal message chains).
1539
+ * Returns a subscription that delivers trace_started, trace_tx, trace_complete, and trace_timeout events.
1540
+ */
1541
+ trace(params: SubscribeTraceParams, options?: CallOptions): Promise<Subscription<TraceEvent>>;
1542
+ }
1543
+
1544
+ /** Jetton namespace — fungible token queries (TEP-74). */
1545
+ declare class JettonNamespace extends BaseNamespace {
1546
+ /** Get jetton master data (supply, admin, content). */
1547
+ getData(params: JettonGetDataParams, options?: CallOptions): Promise<JettonGetDataResult>;
1548
+ /** Compute the jetton wallet address for an owner. */
1549
+ getWalletAddress(params: JettonGetWalletAddressParams, options?: CallOptions): Promise<JettonGetWalletAddressResult>;
1550
+ /** Get balance of a jetton wallet. */
1551
+ getBalance(params: JettonGetBalanceParams, options?: CallOptions): Promise<JettonGetBalanceResult>;
1552
+ }
1553
+
1554
+ /** NFT namespace — non-fungible token queries (TEP-62). */
1555
+ declare class NftNamespace extends BaseNamespace {
1556
+ /** Get individual NFT item data. */
1557
+ getData(params: NftGetDataParams, options?: CallOptions): Promise<NftGetDataResult>;
1558
+ /** Get NFT collection data. */
1559
+ getCollectionData(params: NftGetCollectionDataParams, options?: CallOptions): Promise<NftGetCollectionDataResult>;
1560
+ /** Get the NFT item address by collection index. */
1561
+ getAddressByIndex(params: NftGetAddressByIndexParams, options?: CallOptions): Promise<NftGetAddressByIndexResult>;
1562
+ /** Get royalty parameters for a collection. */
1563
+ getRoyaltyParams(params: NftGetRoyaltyParamsParams, options?: CallOptions): Promise<NftGetRoyaltyParamsResult>;
1564
+ /** Resolve the full content URI for an NFT by combining collection and individual content. */
1565
+ getContent(params: NftGetContentParams, options?: CallOptions): Promise<NftGetContentResult>;
1566
+ }
1567
+
1568
+ /** DNS namespace — TON DNS domain resolution. */
1569
+ declare class DnsNamespace extends BaseNamespace {
1570
+ /** Resolve a .ton domain to wallet, site ADNL, text records, etc. */
1571
+ resolve(params: DnsResolveParams, options?: CallOptions): Promise<DnsResolveResult>;
1572
+ }
1573
+
1574
+ /** Map of friendly event names to their wire event names and data types. */
1575
+ type AdnlEventMap = {
1576
+ 'message': AdnlMessageEvent;
1577
+ 'disconnected': AdnlDisconnectedEvent;
1578
+ 'incomingConnection': AdnlIncomingConnectionEvent;
1579
+ 'queryReceived': AdnlQueryReceivedEvent;
1580
+ };
1581
+ /** ADNL namespace — low-level peer-to-peer messaging. */
1582
+ declare class AdnlNamespace extends BaseNamespace {
1583
+ private manager;
1584
+ constructor(rpc: RpcEngine, manager: SubscriptionManager);
1585
+ /** Connect to a peer by IP address and public key. */
1586
+ connect(params: AdnlConnectParams, options?: CallOptions): Promise<AdnlConnectResult>;
1587
+ /** Connect to a peer by ADNL ID (resolved via DHT). */
1588
+ connectByADNL(params: AdnlConnectByAdnlParams, options?: CallOptions): Promise<AdnlConnectResult>;
1589
+ /** Send an unreliable message to a connected peer. */
1590
+ sendMessage(params: AdnlSendMessageParams, options?: CallOptions): Promise<AdnlSendMessageResult>;
1591
+ /** Ping a connected peer. */
1592
+ ping(params: AdnlPingParams, options?: CallOptions): Promise<AdnlPingResult>;
1593
+ /** Disconnect from a peer. */
1594
+ disconnect(params: AdnlDisconnectParams, options?: CallOptions): Promise<AdnlDisconnectResult>;
1595
+ /** List all connected ADNL peers. */
1596
+ peers(options?: CallOptions): Promise<AdnlPeersResult>;
1597
+ /** Send a TL query to a peer and wait for the response. */
1598
+ query(params: AdnlQueryParams, options?: CallOptions): Promise<AdnlQueryResult>;
1599
+ /** Enable the query handler for a peer (receive queryReceived events). */
1600
+ setQueryHandler(params: AdnlSetQueryHandlerParams, options?: CallOptions): Promise<AdnlSetQueryHandlerResult>;
1601
+ /** Answer a received query. */
1602
+ answer(params: AdnlAnswerParams, options?: CallOptions): Promise<AdnlAnswerResult>;
1603
+ /** Register a listener for ADNL push events. */
1604
+ on<K extends keyof AdnlEventMap>(event: K, listener: (data: AdnlEventMap[K]) => void): this;
1605
+ /** Remove a listener for ADNL push events. */
1606
+ off<K extends keyof AdnlEventMap>(event: K, listener: (data: AdnlEventMap[K]) => void): this;
1607
+ }
1608
+
1609
+ /** Network namespace — bridge and DHT status. */
1610
+ declare class NetworkNamespace extends BaseNamespace {
1611
+ /** Get bridge network information (DHT status, connected WS clients). */
1612
+ info(options?: CallOptions): Promise<NetworkInfoResult>;
1613
+ }
1614
+
1615
+ /** Map of friendly event names to their wire event names and data types. */
1616
+ type OverlayEventMap = {
1617
+ 'broadcast': OverlayBroadcastEvent;
1618
+ 'message': OverlayMessageEvent;
1619
+ 'queryReceived': OverlayQueryReceivedEvent;
1620
+ };
1621
+ /** Overlay namespace — P2P pubsub overlay networks. */
1622
+ declare class OverlayNamespace extends BaseNamespace {
1623
+ private manager;
1624
+ constructor(rpc: RpcEngine, manager: SubscriptionManager);
1625
+ /** Join an overlay network. */
1626
+ join(params: OverlayJoinParams, options?: CallOptions): Promise<OverlayJoinResult>;
1627
+ /** Leave an overlay network. */
1628
+ leave(params: OverlayLeaveParams, options?: CallOptions): Promise<OverlayLeaveResult>;
1629
+ /** Get peers in an overlay network. */
1630
+ getPeers(params: OverlayGetPeersParams, options?: CallOptions): Promise<OverlayGetPeersResult>;
1631
+ /** Send a broadcast message to all overlay peers. */
1632
+ sendMessage(params: OverlaySendMessageParams, options?: CallOptions): Promise<OverlaySendMessageResult>;
1633
+ /** Send a TL query through the overlay and wait for the response. */
1634
+ query(params: OverlayQueryParams, options?: CallOptions): Promise<OverlayQueryResult>;
1635
+ /** Enable the query handler for an overlay (receive queryReceived events). */
1636
+ setQueryHandler(params: OverlaySetQueryHandlerParams, options?: CallOptions): Promise<OverlaySetQueryHandlerResult>;
1637
+ /** Answer a received overlay query. */
1638
+ answer(params: OverlayAnswerParams, options?: CallOptions): Promise<OverlayAnswerResult>;
1639
+ /** Register a listener for overlay push events. */
1640
+ on<K extends keyof OverlayEventMap>(event: K, listener: (data: OverlayEventMap[K]) => void): this;
1641
+ /** Remove a listener for overlay push events. */
1642
+ off<K extends keyof OverlayEventMap>(event: K, listener: (data: OverlayEventMap[K]) => void): this;
1643
+ }
1644
+
1645
+ /** Wallet namespace — standard wallet contract queries. */
1646
+ declare class WalletNamespace extends BaseNamespace {
1647
+ /** Get the current seqno of a wallet contract. */
1648
+ getSeqno(params: WalletGetSeqnoParams, options?: CallOptions): Promise<WalletGetSeqnoResult>;
1649
+ /** Get the public key stored in a wallet contract. */
1650
+ getPublicKey(params: WalletGetPublicKeyParams, options?: CallOptions): Promise<WalletGetPublicKeyResult>;
1651
+ }
1652
+
1653
+ /** SBT namespace — soulbound token queries (TEP-85). */
1654
+ declare class SbtNamespace extends BaseNamespace {
1655
+ /** Get the authority address of a soulbound token. */
1656
+ getAuthorityAddress(params: SbtGetAuthorityAddressParams, options?: CallOptions): Promise<SbtGetAuthorityAddressResult>;
1657
+ /** Get the revocation timestamp of a soulbound token (0 = not revoked). */
1658
+ getRevokedTime(params: SbtGetRevokedTimeParams, options?: CallOptions): Promise<SbtGetRevokedTimeResult>;
1659
+ }
1660
+
1661
+ /** Payment namespace — payment channel queries. */
1662
+ declare class PaymentNamespace extends BaseNamespace {
1663
+ /** Get the state of a payment channel contract. */
1664
+ getChannelState(params: PaymentGetChannelStateParams, options?: CallOptions): Promise<PaymentGetChannelStateResult>;
1665
+ }
1666
+
1667
+ /** Options for creating a {@link Web3SocketsClient}. */
1668
+ interface ClientOptions extends WsTransportOptions {
1669
+ /** Pre-built transport instance (overrides URL-based auto-detection). */
1670
+ transport?: AbstractTransport;
1671
+ /** RPC request timeout in milliseconds (default: 30 000). */
1672
+ requestTimeout?: number;
1673
+ /** Optional logger for debug/warn/error output. */
1674
+ logger?: Logger;
1675
+ }
1676
+ /** Typed client event map. */
1677
+ interface ClientEventMap {
1678
+ connected: () => void;
1679
+ disconnected: (code: number, reason: string) => void;
1680
+ error: (err: Error) => void;
1681
+ stateChange: (newState: TransportState, oldState: TransportState) => void;
1682
+ }
1683
+ type ClientEventName = keyof ClientEventMap;
1684
+ /**
1685
+ * High-level client for the TON WebSocket JSON-RPC bridge.
1686
+ * Provides typed namespace accessors for all 58+ bridge methods.
1687
+ */
1688
+ declare class Web3SocketsClient {
1689
+ private transport;
1690
+ private rpc;
1691
+ private subscriptionManager;
1692
+ private clientListeners;
1693
+ /** DHT namespace — distributed hash table lookups. */
1694
+ readonly dht: DhtNamespace;
1695
+ /** Liteserver namespace — blockchain queries and transaction submission. */
1696
+ readonly lite: LiteNamespace;
1697
+ /** Subscribe namespace — real-time event subscriptions. */
1698
+ readonly subscribe: SubscribeNamespace;
1699
+ /** Jetton namespace — fungible token queries. */
1700
+ readonly jetton: JettonNamespace;
1701
+ /** NFT namespace — non-fungible token queries. */
1702
+ readonly nft: NftNamespace;
1703
+ /** DNS namespace — TON DNS domain resolution. */
1704
+ readonly dns: DnsNamespace;
1705
+ /** ADNL namespace — low-level peer-to-peer messaging. */
1706
+ readonly adnl: AdnlNamespace;
1707
+ /** Network namespace — bridge status. */
1708
+ readonly network: NetworkNamespace;
1709
+ /** Overlay namespace — P2P pubsub overlay networks. */
1710
+ readonly overlay: OverlayNamespace;
1711
+ /** Wallet namespace — standard wallet contract queries. */
1712
+ readonly wallet: WalletNamespace;
1713
+ /** SBT namespace — soulbound token queries. */
1714
+ readonly sbt: SbtNamespace;
1715
+ /** Payment namespace — payment channel queries. */
1716
+ readonly payment: PaymentNamespace;
1717
+ constructor(options?: ClientOptions);
1718
+ /** Open the transport connection. */
1719
+ connect(): Promise<void>;
1720
+ /** Gracefully close the transport connection. */
1721
+ disconnect(): void;
1722
+ /** Whether the transport is currently connected. */
1723
+ get isConnected(): boolean;
1724
+ /** Current transport state. */
1725
+ get state(): TransportState;
1726
+ /** Permanently tear down the client, releasing all resources. */
1727
+ destroy(): void;
1728
+ /** Register a client event listener. */
1729
+ on<E extends ClientEventName>(event: E, listener: ClientEventMap[E]): this;
1730
+ /** Remove a client event listener. */
1731
+ off<E extends ClientEventName>(event: E, listener: ClientEventMap[E]): this;
1732
+ private emitClient;
1733
+ }
1734
+
1735
+ /** Base error class for all SDK errors. */
1736
+ declare class Web3SocketsError extends Error {
1737
+ code: string;
1738
+ constructor(message: string, code: string);
1739
+ }
1740
+ /** Thrown when the WebSocket connection cannot be established. */
1741
+ declare class ConnectionError extends Web3SocketsError {
1742
+ url: string;
1743
+ constructor(message: string, url: string);
1744
+ }
1745
+ /** Thrown when the WebSocket connection is closed unexpectedly. */
1746
+ declare class ConnectionClosedError extends Web3SocketsError {
1747
+ closeCode: number;
1748
+ constructor(closeCode: number, reason: string);
1749
+ }
1750
+ /** Thrown when the bridge returns a JSON-RPC error response. */
1751
+ declare class RpcError extends Web3SocketsError {
1752
+ rpcCode?: number | undefined;
1753
+ constructor(message: string, rpcCode?: number | undefined);
1754
+ }
1755
+ /** Thrown when a JSON-RPC request exceeds its deadline. */
1756
+ declare class TimeoutError extends Web3SocketsError {
1757
+ constructor(method: string, timeoutMs: number);
1758
+ }
1759
+ /** Thrown when request parameters fail client-side validation. */
1760
+ declare class ValidationError extends Web3SocketsError {
1761
+ constructor(message: string);
1762
+ }
1763
+
1764
+ export { AbstractTransport, type AdnlAnswerParams, type AdnlAnswerResult, type AdnlConnectByAdnlParams, type AdnlConnectParams, type AdnlConnectResult, type AdnlDisconnectParams, type AdnlDisconnectResult, type AdnlDisconnectedEvent, type AdnlIncomingConnectionEvent, type AdnlMessageEvent, AdnlNamespace, type AdnlPeerInfo, type AdnlPeersResult, type AdnlPingParams, type AdnlPingResult, type AdnlQueryParams, type AdnlQueryReceivedEvent, type AdnlQueryResult, type AdnlSendMessageParams, type AdnlSendMessageResult, type AdnlSetQueryHandlerParams, type AdnlSetQueryHandlerResult, type CallOptions, type ClientOptions, ConnectionClosedError, ConnectionError, type DhtAddress, type DhtFindAddressesParams, type DhtFindAddressesResult, type DhtFindOverlayNodesParams, type DhtFindOverlayNodesResult, type DhtFindTunnelNodesResult, type DhtFindValueParams, type DhtFindValueResult, DhtNamespace, type DhtRelayInfo, DnsNamespace, type DnsResolveParams, type DnsResolveResult, IpcTransport, type JettonGetBalanceParams, type JettonGetBalanceResult, type JettonGetDataParams, type JettonGetDataResult, type JettonGetWalletAddressParams, type JettonGetWalletAddressResult, JettonNamespace, type JettonTepContent, type LiteBlockTransaction, type LiteFindTxByInMsgHashParams, type LiteFindTxByOutMsgHashParams, type LiteGetAccountStateParams, type LiteGetAccountStateResult, type LiteGetBlockDataParams, type LiteGetBlockDataResult, type LiteGetBlockHeaderParams, type LiteGetBlockHeaderResult, type LiteGetBlockTransactionsParams, type LiteGetBlockTransactionsResult, type LiteGetBlockchainConfigParams, type LiteGetBlockchainConfigResult, type LiteGetLibrariesParams, type LiteGetLibrariesResult, type LiteGetMasterchainInfoResult, type LiteGetShardsResult, type LiteGetTimeResult, type LiteGetTransactionParams, type LiteGetTransactionsParams, type LiteGetTransactionsResult, type LiteLibraryEntry, type LiteLookupBlockParams, type LiteLookupBlockResult, LiteNamespace, type LiteRunMethodParams, type LiteRunMethodResult, type LiteSendAndWatchParams, type LiteSendAndWatchResult, type LiteSendMessageParams, type LiteSendMessageResult, type LiteShardInfo, type LiteTransaction, type LiteTransactionMessage, type Logger, type MethodMap, type MultiAccountEntry, type NetworkInfoResult, NetworkNamespace, type NftGetAddressByIndexParams, type NftGetAddressByIndexResult, type NftGetCollectionDataParams, type NftGetCollectionDataResult, type NftGetContentParams, type NftGetContentResult, type NftGetDataParams, type NftGetDataResult, type NftGetRoyaltyParamsParams, type NftGetRoyaltyParamsResult, NftNamespace, type NftTepContent, type OverlayAnswerParams, type OverlayAnswerResult, type OverlayBroadcastEvent, type OverlayGetPeersParams, type OverlayGetPeersResult, type OverlayJoinParams, type OverlayJoinResult, type OverlayLeaveParams, type OverlayLeaveResult, type OverlayMessageEvent, OverlayNamespace, type OverlayNodeInfo, type OverlayPeerInfo, type OverlayQueryParams, type OverlayQueryReceivedEvent, type OverlayQueryResult, type OverlaySendMessageParams, type OverlaySendMessageResult, type OverlaySetQueryHandlerParams, type OverlaySetQueryHandlerResult, type PaymentClosingConfig, type PaymentGetChannelStateParams, type PaymentGetChannelStateResult, PaymentNamespace, type PaymentQuarantine, type PaymentSemiChannelState, type RpcEngineOptions, RpcError, type SbtGetAuthorityAddressParams, type SbtGetAuthorityAddressResult, type SbtGetRevokedTimeParams, type SbtGetRevokedTimeResult, SbtNamespace, type SendAndWatchEvent, type SubscribeAccountStateConfirmation, type SubscribeAccountStateEvent, type SubscribeAccountStateParams, type SubscribeBlockEvent, type SubscribeBlocksConfirmation, type SubscribeConfigChangedEvent, type SubscribeConfigChangesConfirmation, type SubscribeConfigChangesParams, type SubscribeMultiAccountConfirmation, type SubscribeMultiAccountParams, SubscribeNamespace, type SubscribeNewTransactionEvent, type SubscribeNewTransactionsConfirmation, type SubscribeTraceConfirmation, type SubscribeTraceParams, type SubscribeTransactionsConfirmation, type SubscribeTransactionsParams, type SubscribeUnsubscribeParams, type SubscribeUnsubscribeResult, Subscription, type SubscriptionEventMap, type SubscriptionOptions, TimeoutError, type TraceCompleteEvent, type TraceEvent, type TraceStartedEvent, type TraceTimeoutEvent, type TraceTxEvent, type TransportEventName, type TransportEvents, TransportState, type TxConfirmedEvent, type TxTimeoutEvent, ValidationError, type WSEvent, type WSRequest, type WSResponse, type WalletGetPublicKeyParams, type WalletGetPublicKeyResult, type WalletGetSeqnoParams, type WalletGetSeqnoResult, WalletNamespace, Web3SocketsClient, Web3SocketsError, WsTransport, type WsTransportOptions, createTransport };