@tonconnect/sdk 3.3.1 → 3.4.0-beta.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/README.md +54 -0
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +1090 -201
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +1085 -202
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +336 -50
- package/package.json +3 -3
package/lib/types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare interface Account {
|
|
|
6
6
|
/**
|
|
7
7
|
* User's selected chain.
|
|
8
8
|
*/
|
|
9
|
-
chain:
|
|
9
|
+
chain: ChainId;
|
|
10
10
|
/**
|
|
11
11
|
* Base64 (not url safe) encoded wallet contract stateInit.
|
|
12
12
|
* Can be used to get user's public key from the stateInit if the wallet contract doesn't support corresponding get method.
|
|
@@ -70,6 +70,8 @@ export declare enum CHAIN {
|
|
|
70
70
|
TESTNET = "-3"
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
export declare type ChainId = CHAIN | string;
|
|
74
|
+
|
|
73
75
|
export declare function checkRequiredWalletFeatures(features: Feature[], walletsRequiredFeatures?: RequiredFeatures): boolean;
|
|
74
76
|
|
|
75
77
|
export declare enum CONNECT_EVENT_ERROR_CODES {
|
|
@@ -115,6 +117,10 @@ export declare type ConnectionCompletedEvent = {
|
|
|
115
117
|
* Connection success flag.
|
|
116
118
|
*/
|
|
117
119
|
is_success: true;
|
|
120
|
+
/**
|
|
121
|
+
* Unique identifier used for tracking a specific user flow.
|
|
122
|
+
*/
|
|
123
|
+
trace_id?: string | null;
|
|
118
124
|
} & ConnectionInfo;
|
|
119
125
|
|
|
120
126
|
/**
|
|
@@ -140,7 +146,14 @@ export declare type ConnectionErrorEvent = {
|
|
|
140
146
|
/**
|
|
141
147
|
* Custom data for the connection.
|
|
142
148
|
*/
|
|
143
|
-
custom_data:
|
|
149
|
+
custom_data: {
|
|
150
|
+
client_id: string | null;
|
|
151
|
+
wallet_id: string | null;
|
|
152
|
+
} & Version;
|
|
153
|
+
/**
|
|
154
|
+
* Unique identifier used for tracking a specific user flow.
|
|
155
|
+
*/
|
|
156
|
+
trace_id?: string | null;
|
|
144
157
|
};
|
|
145
158
|
|
|
146
159
|
/**
|
|
@@ -156,6 +169,10 @@ export declare type ConnectionInfo = {
|
|
|
156
169
|
* Connected wallet address.
|
|
157
170
|
*/
|
|
158
171
|
wallet_address: string | null;
|
|
172
|
+
/**
|
|
173
|
+
* Connected wallet state init.
|
|
174
|
+
*/
|
|
175
|
+
wallet_state_init: string | null;
|
|
159
176
|
/**
|
|
160
177
|
* Wallet type: 'tonkeeper', 'tonhub', etc.
|
|
161
178
|
*/
|
|
@@ -180,6 +197,8 @@ export declare type ConnectionInfo = {
|
|
|
180
197
|
* Wallet provider.
|
|
181
198
|
*/
|
|
182
199
|
provider: 'http' | 'injected' | null;
|
|
200
|
+
client_id: string | null;
|
|
201
|
+
wallet_id: string | null;
|
|
183
202
|
} & Version;
|
|
184
203
|
};
|
|
185
204
|
|
|
@@ -195,6 +214,10 @@ export declare type ConnectionRestoringCompletedEvent = {
|
|
|
195
214
|
* Connection success flag.
|
|
196
215
|
*/
|
|
197
216
|
is_success: true;
|
|
217
|
+
/**
|
|
218
|
+
* Unique identifier used for tracking a specific user flow.
|
|
219
|
+
*/
|
|
220
|
+
trace_id?: string | null;
|
|
198
221
|
} & ConnectionInfo;
|
|
199
222
|
|
|
200
223
|
/**
|
|
@@ -217,6 +240,10 @@ export declare type ConnectionRestoringErrorEvent = {
|
|
|
217
240
|
* Custom data for the connection.
|
|
218
241
|
*/
|
|
219
242
|
custom_data: Version;
|
|
243
|
+
/**
|
|
244
|
+
* Unique identifier used for tracking a specific user flow.
|
|
245
|
+
*/
|
|
246
|
+
trace_id?: string | null;
|
|
220
247
|
};
|
|
221
248
|
|
|
222
249
|
/**
|
|
@@ -236,6 +263,10 @@ export declare type ConnectionRestoringStartedEvent = {
|
|
|
236
263
|
* Custom data for the connection.
|
|
237
264
|
*/
|
|
238
265
|
custom_data: Version;
|
|
266
|
+
/**
|
|
267
|
+
* Unique identifier used for tracking a specific user flow.
|
|
268
|
+
*/
|
|
269
|
+
trace_id?: string | null;
|
|
239
270
|
};
|
|
240
271
|
|
|
241
272
|
/**
|
|
@@ -250,6 +281,10 @@ export declare type ConnectionStartedEvent = {
|
|
|
250
281
|
* Custom data for the connection.
|
|
251
282
|
*/
|
|
252
283
|
custom_data: Version;
|
|
284
|
+
/**
|
|
285
|
+
* Unique identifier used for tracking a specific user flow.
|
|
286
|
+
*/
|
|
287
|
+
trace_id?: string | null;
|
|
253
288
|
};
|
|
254
289
|
|
|
255
290
|
export declare type ConnectItem = TonAddressItem | TonProofItem;
|
|
@@ -268,55 +303,55 @@ export declare type ConnectItemReplyError<T> = {
|
|
|
268
303
|
* Create a connection completed event.
|
|
269
304
|
* @param version
|
|
270
305
|
* @param wallet
|
|
306
|
+
* @param sessionInfo
|
|
307
|
+
* @param traceId
|
|
271
308
|
*/
|
|
272
|
-
export declare function createConnectionCompletedEvent(version: Version, wallet: Wallet | null): ConnectionCompletedEvent;
|
|
309
|
+
export declare function createConnectionCompletedEvent(version: Version, wallet: Wallet | null, sessionInfo?: SessionInfo | null, traceId?: string | null): ConnectionCompletedEvent;
|
|
273
310
|
|
|
274
311
|
/**
|
|
275
312
|
* Create a connection error event.
|
|
276
313
|
* @param version
|
|
277
314
|
* @param error_message
|
|
278
315
|
* @param errorCode
|
|
316
|
+
* @param sessionInfo
|
|
317
|
+
* @param traceId
|
|
279
318
|
*/
|
|
280
|
-
export declare function createConnectionErrorEvent(version: Version, error_message: string, errorCode: CONNECT_EVENT_ERROR_CODES | void): ConnectionErrorEvent;
|
|
319
|
+
export declare function createConnectionErrorEvent(version: Version, error_message: string, errorCode: CONNECT_EVENT_ERROR_CODES | void, sessionInfo?: SessionInfo | null, traceId?: string | null): ConnectionErrorEvent;
|
|
281
320
|
|
|
282
321
|
/**
|
|
283
322
|
* Create a connection restoring completed event.
|
|
284
323
|
* @param version
|
|
285
324
|
* @param wallet
|
|
325
|
+
* @param sessionInfo
|
|
326
|
+
* @param traceId
|
|
286
327
|
*/
|
|
287
|
-
export declare function createConnectionRestoringCompletedEvent(version: Version, wallet: Wallet | null): ConnectionRestoringCompletedEvent;
|
|
328
|
+
export declare function createConnectionRestoringCompletedEvent(version: Version, wallet: Wallet | null, sessionInfo?: SessionInfo | null, traceId?: string | null): ConnectionRestoringCompletedEvent;
|
|
288
329
|
|
|
289
330
|
/**
|
|
290
331
|
* Create a connection restoring error event.
|
|
291
332
|
* @param version
|
|
292
333
|
* @param errorMessage
|
|
334
|
+
* @param traceId
|
|
293
335
|
*/
|
|
294
|
-
export declare function createConnectionRestoringErrorEvent(version: Version, errorMessage: string): ConnectionRestoringErrorEvent;
|
|
336
|
+
export declare function createConnectionRestoringErrorEvent(version: Version, errorMessage: string, traceId?: string | null): ConnectionRestoringErrorEvent;
|
|
295
337
|
|
|
296
338
|
/**
|
|
297
339
|
* Create a connection restoring started event.
|
|
298
340
|
*/
|
|
299
|
-
export declare function createConnectionRestoringStartedEvent(version: Version): ConnectionRestoringStartedEvent;
|
|
341
|
+
export declare function createConnectionRestoringStartedEvent(version: Version, traceId?: string | null): ConnectionRestoringStartedEvent;
|
|
300
342
|
|
|
301
343
|
/**
|
|
302
344
|
* Create a connection init event.
|
|
303
345
|
*/
|
|
304
|
-
export declare function createConnectionStartedEvent(version: Version): ConnectionStartedEvent;
|
|
346
|
+
export declare function createConnectionStartedEvent(version: Version, traceId?: string | null): ConnectionStartedEvent;
|
|
305
347
|
|
|
306
|
-
export declare function createDataSentForSignatureEvent(version: Version, wallet: Wallet | null, data: SignDataPayload): DataSentForSignatureEvent;
|
|
348
|
+
export declare function createDataSentForSignatureEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, sessionInfo?: SessionInfo | null, traceId?: string | null): DataSentForSignatureEvent;
|
|
307
349
|
|
|
308
|
-
export declare function createDataSignedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, signedData: SignDataResponse): DataSignedEvent;
|
|
350
|
+
export declare function createDataSignedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, signedData: SignDataResponse, sessionInfo?: SessionInfo | null, traceId?: string | null): DataSignedEvent;
|
|
309
351
|
|
|
310
|
-
export declare function createDataSigningFailedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, errorMessage: string, errorCode: SIGN_DATA_ERROR_CODES | void): DataSigningFailedEvent;
|
|
352
|
+
export declare function createDataSigningFailedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, errorMessage: string, errorCode: SIGN_DATA_ERROR_CODES | void, sessionInfo?: SessionInfo | null, traceId?: string | null): DataSigningFailedEvent;
|
|
311
353
|
|
|
312
|
-
|
|
313
|
-
* Create a disconnect event.
|
|
314
|
-
* @param version
|
|
315
|
-
* @param wallet
|
|
316
|
-
* @param scope
|
|
317
|
-
* @returns
|
|
318
|
-
*/
|
|
319
|
-
export declare function createDisconnectionEvent(version: Version, wallet: Wallet | null, scope: 'dapp' | 'wallet'): DisconnectionEvent;
|
|
354
|
+
export declare function createDisconnectionEvent(version: Version, wallet: Wallet | null, scope: 'dapp' | 'wallet', sessionInfo?: SessionInfo | null, traceId?: string | null): DisconnectionEvent;
|
|
320
355
|
|
|
321
356
|
/**
|
|
322
357
|
* Create a request version event.
|
|
@@ -329,13 +364,17 @@ export declare function createRequestVersionEvent(): RequestVersionEvent;
|
|
|
329
364
|
*/
|
|
330
365
|
export declare function createResponseVersionEvent(version: string): ResponseVersionEvent;
|
|
331
366
|
|
|
367
|
+
export declare function createSelectedWalletEvent(version: Version, visibleWallets: string[], lastSelectedWallet: WalletInfoInjectable | WalletInfoRemote | null, walletsMenu: 'explicit_wallet' | 'main_screen' | 'other_wallets', redirectLink: string, redirectLinkType?: 'tg_link' | 'external_link', clientId?: string | null, traceId?: string | null): SelectedWalletEvent;
|
|
368
|
+
|
|
332
369
|
/**
|
|
333
370
|
* Create a transaction init event.
|
|
334
371
|
* @param version
|
|
335
372
|
* @param wallet
|
|
336
373
|
* @param transaction
|
|
374
|
+
* @param sessionInfo
|
|
375
|
+
* @param traceId
|
|
337
376
|
*/
|
|
338
|
-
export declare function createTransactionSentForSignatureEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest): TransactionSentForSignatureEvent;
|
|
377
|
+
export declare function createTransactionSentForSignatureEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, sessionInfo?: SessionInfo | null, traceId?: string | null): TransactionSentForSignatureEvent;
|
|
339
378
|
|
|
340
379
|
/**
|
|
341
380
|
* Create a transaction signed event.
|
|
@@ -343,8 +382,10 @@ export declare function createTransactionSentForSignatureEvent(version: Version,
|
|
|
343
382
|
* @param wallet
|
|
344
383
|
* @param transaction
|
|
345
384
|
* @param signedTransaction
|
|
385
|
+
* @param sessionInfo
|
|
386
|
+
* @param traceId
|
|
346
387
|
*/
|
|
347
|
-
export declare function createTransactionSignedEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, signedTransaction: SendTransactionResponse): TransactionSignedEvent;
|
|
388
|
+
export declare function createTransactionSignedEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, signedTransaction: SendTransactionResponse, sessionInfo?: SessionInfo | null, traceId?: string | null): TransactionSignedEvent;
|
|
348
389
|
|
|
349
390
|
/**
|
|
350
391
|
* Create a transaction error event.
|
|
@@ -353,8 +394,10 @@ export declare function createTransactionSignedEvent(version: Version, wallet: W
|
|
|
353
394
|
* @param transaction
|
|
354
395
|
* @param errorMessage
|
|
355
396
|
* @param errorCode
|
|
397
|
+
* @param sessionInfo
|
|
398
|
+
* @param traceId
|
|
356
399
|
*/
|
|
357
|
-
export declare function createTransactionSigningFailedEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, errorMessage: string, errorCode: SEND_TRANSACTION_ERROR_CODES | void): TransactionSigningFailedEvent;
|
|
400
|
+
export declare function createTransactionSigningFailedEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, errorMessage: string, errorCode: SEND_TRANSACTION_ERROR_CODES | void, sessionInfo?: SessionInfo | null, traceId?: string | null): TransactionSigningFailedEvent;
|
|
358
401
|
|
|
359
402
|
/**
|
|
360
403
|
* Create a version info.
|
|
@@ -362,6 +405,8 @@ export declare function createTransactionSigningFailedEvent(version: Version, wa
|
|
|
362
405
|
*/
|
|
363
406
|
export declare function createVersionInfo(version: Version): Version;
|
|
364
407
|
|
|
408
|
+
export declare function createWalletModalOpenedEvent(version: Version, visibleWallets: string[], clientId?: string | null, traceId?: string | null): WalletModalOpenedEvent;
|
|
409
|
+
|
|
365
410
|
export declare interface DappMetadata {
|
|
366
411
|
/**
|
|
367
412
|
* Dapp name. Might be simple, will not be used as identifier.
|
|
@@ -384,6 +429,10 @@ export declare interface DappMetadata {
|
|
|
384
429
|
export declare type DataSentForSignatureEvent = {
|
|
385
430
|
type: 'sign-data-request-initiated';
|
|
386
431
|
data: SignDataPayload;
|
|
432
|
+
/**
|
|
433
|
+
* Unique identifier used for tracking a specific user flow.
|
|
434
|
+
*/
|
|
435
|
+
trace_id?: string | null;
|
|
387
436
|
} & ConnectionInfo;
|
|
388
437
|
|
|
389
438
|
export declare type DataSignedEvent = {
|
|
@@ -391,6 +440,10 @@ export declare type DataSignedEvent = {
|
|
|
391
440
|
is_success: true;
|
|
392
441
|
data: SignDataPayload;
|
|
393
442
|
signed_data: SignDataResponse;
|
|
443
|
+
/**
|
|
444
|
+
* Unique identifier used for tracking a specific user flow.
|
|
445
|
+
*/
|
|
446
|
+
trace_id?: string | null;
|
|
394
447
|
} & ConnectionInfo;
|
|
395
448
|
|
|
396
449
|
export declare type DataSigningEvent = DataSentForSignatureEvent | DataSignedEvent | DataSigningFailedEvent;
|
|
@@ -401,8 +454,14 @@ export declare type DataSigningFailedEvent = {
|
|
|
401
454
|
error_message: string;
|
|
402
455
|
error_code: SIGN_DATA_ERROR_CODES | null;
|
|
403
456
|
data: SignDataPayload;
|
|
457
|
+
/**
|
|
458
|
+
* Unique identifier used for tracking a specific user flow.
|
|
459
|
+
*/
|
|
460
|
+
trace_id?: string | null;
|
|
404
461
|
} & ConnectionInfo;
|
|
405
462
|
|
|
463
|
+
export declare function decodeTelegramUrlParameters(parameters: string): string;
|
|
464
|
+
|
|
406
465
|
export declare interface DeviceInfo {
|
|
407
466
|
platform: 'iphone' | 'ipad' | 'android' | 'windows' | 'mac' | 'linux' | 'browser';
|
|
408
467
|
appName: string;
|
|
@@ -423,6 +482,10 @@ export declare type DisconnectionEvent = {
|
|
|
423
482
|
* Disconnect scope: 'dapp' or 'wallet'.
|
|
424
483
|
*/
|
|
425
484
|
scope: 'dapp' | 'wallet';
|
|
485
|
+
/**
|
|
486
|
+
* Unique identifier used for tracking a specific user flow.
|
|
487
|
+
*/
|
|
488
|
+
trace_id?: string | null;
|
|
426
489
|
} & ConnectionInfo;
|
|
427
490
|
|
|
428
491
|
export declare function enableQaMode(): void;
|
|
@@ -467,6 +530,36 @@ export declare class FetchWalletsError extends TonConnectError {
|
|
|
467
530
|
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
468
531
|
}
|
|
469
532
|
|
|
533
|
+
/**
|
|
534
|
+
* Represents the client environment in which the application is running.
|
|
535
|
+
*/
|
|
536
|
+
export declare interface IEnvironment {
|
|
537
|
+
/**
|
|
538
|
+
* Retrieves the user's current locale setting.
|
|
539
|
+
*/
|
|
540
|
+
getLocale(): string;
|
|
541
|
+
/**
|
|
542
|
+
* Retrieves the name or identifier of the user's browser.
|
|
543
|
+
*/
|
|
544
|
+
getBrowser(): string;
|
|
545
|
+
/**
|
|
546
|
+
* Retrieves the name of the user's operating system or platform.
|
|
547
|
+
*/
|
|
548
|
+
getPlatform(): string;
|
|
549
|
+
/**
|
|
550
|
+
* Retrieves the Telegram user associated with the current environment, if available.
|
|
551
|
+
*/
|
|
552
|
+
getTelegramUser(): TelegramUser | undefined;
|
|
553
|
+
/**
|
|
554
|
+
* Retrieves the type of client environment.
|
|
555
|
+
* Indicates whether the client is running as a web application,
|
|
556
|
+
* Telegram Mini App, or another custom environment.
|
|
557
|
+
*/
|
|
558
|
+
getClientEnvironment(): 'web' | 'miniapp' | (string & {});
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export declare function isConnectUrl(link: string | undefined): link is string;
|
|
562
|
+
|
|
470
563
|
export declare function isQaModeEnabled(): boolean;
|
|
471
564
|
|
|
472
565
|
export declare function isTelegramUrl(link: string | undefined): link is string;
|
|
@@ -551,16 +644,20 @@ export declare interface ITonConnect {
|
|
|
551
644
|
* Generates universal link for an external wallet and subscribes to the wallet's bridge, or sends connect request to the injected wallet.
|
|
552
645
|
* @param wallet wallet's bridge url and universal link for an external wallet or jsBridge key for the injected wallet, or list of bridges urls for creating an universal connection request for the corresponding wallets.
|
|
553
646
|
* @param request (optional) additional request to pass to the wallet while connect (currently only ton_proof is available).
|
|
647
|
+
* @param options (optional) options
|
|
554
648
|
* @returns universal link if external wallet was passed or void for the injected wallet.
|
|
555
649
|
*/
|
|
556
|
-
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest
|
|
650
|
+
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest, options?: OptionalTraceable<{
|
|
651
|
+
openingDeadlineMS?: number;
|
|
652
|
+
signal?: AbortSignal;
|
|
653
|
+
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
557
654
|
/**
|
|
558
655
|
* Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.
|
|
559
656
|
*/
|
|
560
|
-
restoreConnection(options?: {
|
|
657
|
+
restoreConnection(options?: OptionalTraceable<{
|
|
561
658
|
openingDeadlineMS?: number;
|
|
562
659
|
signal?: AbortSignal;
|
|
563
|
-
}): Promise<void>;
|
|
660
|
+
}>): Promise<void>;
|
|
564
661
|
/**
|
|
565
662
|
* Pause bridge HTTP connection. Might be helpful, if you want to pause connections while browser tab is unfocused,
|
|
566
663
|
* or if you use SDK with NodeJS and want to save server resources.
|
|
@@ -570,12 +667,18 @@ export declare interface ITonConnect {
|
|
|
570
667
|
* Unpause bridge HTTP connection if it is paused.
|
|
571
668
|
*/
|
|
572
669
|
unPauseConnection(): Promise<void>;
|
|
670
|
+
/**
|
|
671
|
+
* Set desired network for the connection. Can only be set before connecting.
|
|
672
|
+
* If wallet connects with a different chain, the SDK will throw an error and abort connection.
|
|
673
|
+
* @param network desired network id (e.g., '-239', '-3', or custom). Pass undefined to allow any network.
|
|
674
|
+
*/
|
|
675
|
+
setConnectionNetwork(network?: ChainId): void;
|
|
573
676
|
/**
|
|
574
677
|
* Disconnect form thw connected wallet and drop current session.
|
|
575
678
|
*/
|
|
576
|
-
disconnect(options?: {
|
|
679
|
+
disconnect(options?: OptionalTraceable<{
|
|
577
680
|
signal?: AbortSignal;
|
|
578
|
-
}): Promise<void>;
|
|
681
|
+
}>): Promise<void>;
|
|
579
682
|
/**
|
|
580
683
|
* Asks connected wallet to sign and send the transaction.
|
|
581
684
|
* @param transaction transaction to send.
|
|
@@ -583,16 +686,16 @@ export declare interface ITonConnect {
|
|
|
583
686
|
* @returns signed transaction boc that allows you to find the transaction in the blockchain.
|
|
584
687
|
* If user rejects transaction, method will throw the corresponding error.
|
|
585
688
|
*/
|
|
586
|
-
sendTransaction(transaction: SendTransactionRequest, options?: {
|
|
689
|
+
sendTransaction(transaction: SendTransactionRequest, options?: OptionalTraceable<{
|
|
587
690
|
onRequestSent?: () => void;
|
|
588
691
|
signal?: AbortSignal;
|
|
589
|
-
}): Promise<SendTransactionResponse
|
|
692
|
+
}>): Promise<OptionalTraceable<SendTransactionResponse>>;
|
|
590
693
|
/** @deprecated use sendTransaction(transaction, options) instead */
|
|
591
|
-
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<SendTransactionResponse
|
|
592
|
-
signData(data: SignDataPayload, options?: {
|
|
694
|
+
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<OptionalTraceable<SendTransactionResponse>>;
|
|
695
|
+
signData(data: SignDataPayload, options?: OptionalTraceable<{
|
|
593
696
|
onRequestSent?: () => void;
|
|
594
697
|
signal?: AbortSignal;
|
|
595
|
-
}): Promise<SignDataResponse
|
|
698
|
+
}>): Promise<OptionalTraceable<SignDataResponse>>;
|
|
596
699
|
/**
|
|
597
700
|
* Gets the current session ID if available.
|
|
598
701
|
* @returns session ID string or null if not available.
|
|
@@ -613,6 +716,10 @@ export declare class LocalstorageNotFoundError extends TonConnectError {
|
|
|
613
716
|
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
614
717
|
}
|
|
615
718
|
|
|
719
|
+
export declare type OptionalTraceable<T extends {} = {}> = {
|
|
720
|
+
traceId?: string;
|
|
721
|
+
} & T;
|
|
722
|
+
|
|
616
723
|
/**
|
|
617
724
|
* Thrown when passed hex is in incorrect format.
|
|
618
725
|
*/
|
|
@@ -688,7 +795,46 @@ export declare type ResponseVersionEvent = {
|
|
|
688
795
|
/**
|
|
689
796
|
* User action events.
|
|
690
797
|
*/
|
|
691
|
-
export declare type SdkActionEvent = VersionEvent | ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent | DataSigningEvent;
|
|
798
|
+
export declare type SdkActionEvent = VersionEvent | ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent | DataSigningEvent | WalletModalOpenedEvent | SelectedWalletEvent;
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Represents the event triggered when the wallet is selected.
|
|
802
|
+
*/
|
|
803
|
+
export declare type SelectedWalletEvent = {
|
|
804
|
+
/**
|
|
805
|
+
* Event type.
|
|
806
|
+
*/
|
|
807
|
+
type: 'selected-wallet';
|
|
808
|
+
/**
|
|
809
|
+
* The unique client identifier associated with the session or user.
|
|
810
|
+
*/
|
|
811
|
+
client_id: string | null;
|
|
812
|
+
/**
|
|
813
|
+
* A list of wallet identifiers that are currently visible in the modal.
|
|
814
|
+
*/
|
|
815
|
+
visible_wallets: string[];
|
|
816
|
+
wallets_menu: 'explicit_wallet' | 'main_screen' | 'other_wallets';
|
|
817
|
+
/**
|
|
818
|
+
* Redirect method: tg_link, external_link
|
|
819
|
+
*/
|
|
820
|
+
wallet_redirect_method?: 'tg_link' | 'external_link';
|
|
821
|
+
/**
|
|
822
|
+
* URL used to open the wallet
|
|
823
|
+
*/
|
|
824
|
+
wallet_redirect_link?: string;
|
|
825
|
+
/**
|
|
826
|
+
* Wallet type: 'tonkeeper', 'tonhub', etc.
|
|
827
|
+
*/
|
|
828
|
+
wallet_type: string | null;
|
|
829
|
+
/**
|
|
830
|
+
* Custom metadata containing versioning or contextual data for the modal.
|
|
831
|
+
*/
|
|
832
|
+
custom_data: Version;
|
|
833
|
+
/**
|
|
834
|
+
* Unique identifier used for tracking a specific user flow.
|
|
835
|
+
*/
|
|
836
|
+
trace_id: string | null;
|
|
837
|
+
};
|
|
692
838
|
|
|
693
839
|
export declare enum SEND_TRANSACTION_ERROR_CODES {
|
|
694
840
|
UNKNOWN_ERROR = 0,
|
|
@@ -714,7 +860,7 @@ export declare interface SendTransactionRequest {
|
|
|
714
860
|
/**
|
|
715
861
|
* The network (mainnet or testnet) where DApp intends to send the transaction. If not set, the transaction is sent to the network currently set in the wallet, but this is not safe and DApp should always strive to set the network. If the network parameter is set, but the wallet has a different network set, the wallet should show an alert and DO NOT ALLOW TO SEND this transaction.
|
|
716
862
|
*/
|
|
717
|
-
network?:
|
|
863
|
+
network?: ChainId;
|
|
718
864
|
/**
|
|
719
865
|
* The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default.
|
|
720
866
|
*/
|
|
@@ -768,6 +914,11 @@ export declare class SessionCrypto {
|
|
|
768
914
|
stringifyKeypair(): KeyPair;
|
|
769
915
|
}
|
|
770
916
|
|
|
917
|
+
export declare type SessionInfo = {
|
|
918
|
+
clientId: string | null;
|
|
919
|
+
walletId: string | null;
|
|
920
|
+
};
|
|
921
|
+
|
|
771
922
|
export declare enum SIGN_DATA_ERROR_CODES {
|
|
772
923
|
UNKNOWN_ERROR = 0,
|
|
773
924
|
BAD_REQUEST_ERROR = 1,
|
|
@@ -782,7 +933,7 @@ export declare type SignDataFeature = {
|
|
|
782
933
|
};
|
|
783
934
|
|
|
784
935
|
export declare type SignDataPayload = {
|
|
785
|
-
network?:
|
|
936
|
+
network?: ChainId;
|
|
786
937
|
from?: string;
|
|
787
938
|
} & (SignDataPayloadText | SignDataPayloadBinary | SignDataPayloadCell);
|
|
788
939
|
|
|
@@ -812,19 +963,34 @@ export declare type SignDataResponse = {
|
|
|
812
963
|
|
|
813
964
|
export declare type SignDataType = 'text' | 'binary' | 'cell';
|
|
814
965
|
|
|
966
|
+
/**
|
|
967
|
+
* Basic Telegram user information.
|
|
968
|
+
*/
|
|
969
|
+
export declare type TelegramUser = {
|
|
970
|
+
/** Unique Telegram user ID. */
|
|
971
|
+
id: number;
|
|
972
|
+
/** Whether the user has Telegram Premium. */
|
|
973
|
+
isPremium: boolean;
|
|
974
|
+
};
|
|
975
|
+
|
|
815
976
|
export declare interface TonAddressItem {
|
|
816
977
|
name: 'ton_addr';
|
|
978
|
+
/**
|
|
979
|
+
* Desired network global_id. If provided, wallet should connect on this network.
|
|
980
|
+
*/
|
|
981
|
+
network?: ChainId;
|
|
817
982
|
}
|
|
818
983
|
|
|
819
984
|
export declare interface TonAddressItemReply {
|
|
820
985
|
name: 'ton_addr';
|
|
821
986
|
address: string;
|
|
822
|
-
network:
|
|
987
|
+
network: ChainId;
|
|
823
988
|
walletStateInit: string;
|
|
824
989
|
publicKey: string;
|
|
825
990
|
}
|
|
826
991
|
|
|
827
992
|
declare class TonConnect implements ITonConnect {
|
|
993
|
+
private desiredChainId;
|
|
828
994
|
private static readonly walletsList;
|
|
829
995
|
/**
|
|
830
996
|
* Check if specified wallet is injected and available to use with the app.
|
|
@@ -846,6 +1012,8 @@ declare class TonConnect implements ITonConnect {
|
|
|
846
1012
|
*/
|
|
847
1013
|
private readonly tracker;
|
|
848
1014
|
private readonly walletsList;
|
|
1015
|
+
private readonly analytics?;
|
|
1016
|
+
private readonly environment;
|
|
849
1017
|
private readonly dappSettings;
|
|
850
1018
|
private readonly bridgeConnectionStorage;
|
|
851
1019
|
private _wallet;
|
|
@@ -886,23 +1054,23 @@ declare class TonConnect implements ITonConnect {
|
|
|
886
1054
|
* @param options (optional) openingDeadlineMS for the connection opening deadline and signal for the connection abort.
|
|
887
1055
|
* @returns universal link if external wallet was passed or void for the injected wallet.
|
|
888
1056
|
*/
|
|
889
|
-
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, options?: {
|
|
1057
|
+
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, options?: OptionalTraceable<{
|
|
890
1058
|
request?: ConnectAdditionalRequest;
|
|
891
1059
|
openingDeadlineMS?: number;
|
|
892
1060
|
signal?: AbortSignal;
|
|
893
|
-
}): T extends WalletConnectionSourceJS ? void : string;
|
|
1061
|
+
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
894
1062
|
/** @deprecated use connect(wallet, options) instead */
|
|
895
|
-
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest, options?: {
|
|
1063
|
+
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest, options?: OptionalTraceable<{
|
|
896
1064
|
openingDeadlineMS?: number;
|
|
897
1065
|
signal?: AbortSignal;
|
|
898
|
-
}): T extends WalletConnectionSourceJS ? void : string;
|
|
1066
|
+
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
899
1067
|
/**
|
|
900
1068
|
* Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.
|
|
901
1069
|
*/
|
|
902
|
-
restoreConnection(options?: {
|
|
1070
|
+
restoreConnection(options?: OptionalTraceable<{
|
|
903
1071
|
openingDeadlineMS?: number;
|
|
904
1072
|
signal?: AbortSignal;
|
|
905
|
-
}): Promise<void>;
|
|
1073
|
+
}>): Promise<void>;
|
|
906
1074
|
/**
|
|
907
1075
|
* Asks connected wallet to sign and send the transaction.
|
|
908
1076
|
* @param transaction transaction to send.
|
|
@@ -910,27 +1078,34 @@ declare class TonConnect implements ITonConnect {
|
|
|
910
1078
|
* @returns signed transaction boc that allows you to find the transaction in the blockchain.
|
|
911
1079
|
* If user rejects transaction, method will throw the corresponding error.
|
|
912
1080
|
*/
|
|
913
|
-
sendTransaction(transaction: SendTransactionRequest, options?: {
|
|
1081
|
+
sendTransaction(transaction: SendTransactionRequest, options?: OptionalTraceable<{
|
|
914
1082
|
onRequestSent?: () => void;
|
|
915
1083
|
signal?: AbortSignal;
|
|
916
|
-
}): Promise<SendTransactionResponse
|
|
1084
|
+
}>): Promise<Traceable<SendTransactionResponse>>;
|
|
917
1085
|
/** @deprecated use sendTransaction(transaction, options) instead */
|
|
918
|
-
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<SendTransactionResponse
|
|
919
|
-
signData(data: SignDataPayload, options?: {
|
|
1086
|
+
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<Traceable<SendTransactionResponse>>;
|
|
1087
|
+
signData(data: SignDataPayload, options?: OptionalTraceable<{
|
|
920
1088
|
onRequestSent?: () => void;
|
|
921
1089
|
signal?: AbortSignal;
|
|
922
|
-
}): Promise<SignDataResponse
|
|
1090
|
+
}>): Promise<Traceable<SignDataResponse>>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Set desired network for the connection. Can only be set before connecting.
|
|
1093
|
+
* If wallet connects with a different chain, the SDK will throw an error and abort connection.
|
|
1094
|
+
* @param network desired network id (e.g., '-239', '-3', or custom). Pass undefined to allow any network.
|
|
1095
|
+
*/
|
|
1096
|
+
setConnectionNetwork(network?: ChainId): void;
|
|
923
1097
|
/**
|
|
924
1098
|
* Disconnect form thw connected wallet and drop current session.
|
|
925
1099
|
*/
|
|
926
|
-
disconnect(options?: {
|
|
1100
|
+
disconnect(options?: OptionalTraceable<{
|
|
927
1101
|
signal?: AbortSignal;
|
|
928
|
-
}): Promise<void>;
|
|
1102
|
+
}>): Promise<void>;
|
|
929
1103
|
/**
|
|
930
1104
|
* Gets the current session ID if available.
|
|
931
1105
|
* @returns session ID string or null if not available.
|
|
932
1106
|
*/
|
|
933
1107
|
getSessionId(): Promise<string | null>;
|
|
1108
|
+
private getSessionInfo;
|
|
934
1109
|
/**
|
|
935
1110
|
* Pause bridge HTTP connection. Might be helpful, if you want to pause connections while browser tab is unfocused,
|
|
936
1111
|
* or if you use SDK with NodeJS and want to save server resources.
|
|
@@ -999,6 +1174,10 @@ export declare interface TonConnectOptions {
|
|
|
999
1174
|
* Allows to disable auto pause/unpause SSE connection on 'document.visibilitychange' event. It is not recommended to change default behaviour.
|
|
1000
1175
|
*/
|
|
1001
1176
|
disableAutoPauseConnection?: boolean;
|
|
1177
|
+
/**
|
|
1178
|
+
* Represents the client environment in which the application is running.
|
|
1179
|
+
*/
|
|
1180
|
+
environment?: IEnvironment;
|
|
1002
1181
|
}
|
|
1003
1182
|
|
|
1004
1183
|
export declare interface TonProofItem {
|
|
@@ -1030,6 +1209,39 @@ export declare interface TonProofItemReplySuccess {
|
|
|
1030
1209
|
*/
|
|
1031
1210
|
export declare function toUserFriendlyAddress(hexAddress: string, testOnly?: boolean): string;
|
|
1032
1211
|
|
|
1212
|
+
export declare type Traceable<T extends {} = {}> = {
|
|
1213
|
+
traceId: string;
|
|
1214
|
+
} & T;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* Transaction information.
|
|
1218
|
+
*/
|
|
1219
|
+
export declare type TransactionFullInfo = Omit<TransactionInfo, 'messages'> & {
|
|
1220
|
+
messages: TransactionFullMessage[];
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* Transaction message.
|
|
1225
|
+
*/
|
|
1226
|
+
export declare type TransactionFullMessage = {
|
|
1227
|
+
/**
|
|
1228
|
+
* Recipient address.
|
|
1229
|
+
*/
|
|
1230
|
+
address: string | null;
|
|
1231
|
+
/**
|
|
1232
|
+
* Transfer amount.
|
|
1233
|
+
*/
|
|
1234
|
+
amount: string | null;
|
|
1235
|
+
/**
|
|
1236
|
+
* Message payload
|
|
1237
|
+
*/
|
|
1238
|
+
payload: string | null;
|
|
1239
|
+
/**
|
|
1240
|
+
* Message state init
|
|
1241
|
+
*/
|
|
1242
|
+
state_init: string | null;
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1033
1245
|
/**
|
|
1034
1246
|
* Transaction information.
|
|
1035
1247
|
*/
|
|
@@ -1070,6 +1282,10 @@ export declare type TransactionSentForSignatureEvent = {
|
|
|
1070
1282
|
* Event type.
|
|
1071
1283
|
*/
|
|
1072
1284
|
type: 'transaction-sent-for-signature';
|
|
1285
|
+
/**
|
|
1286
|
+
* Unique identifier used for tracking a specific user flow.
|
|
1287
|
+
*/
|
|
1288
|
+
trace_id?: string | null;
|
|
1073
1289
|
} & ConnectionInfo & TransactionInfo;
|
|
1074
1290
|
|
|
1075
1291
|
/**
|
|
@@ -1088,6 +1304,10 @@ export declare type TransactionSignedEvent = {
|
|
|
1088
1304
|
* Signed transaction.
|
|
1089
1305
|
*/
|
|
1090
1306
|
signed_transaction: string;
|
|
1307
|
+
/**
|
|
1308
|
+
* Unique identifier used for tracking a specific user flow.
|
|
1309
|
+
*/
|
|
1310
|
+
trace_id?: string | null;
|
|
1091
1311
|
} & ConnectionInfo & TransactionInfo;
|
|
1092
1312
|
|
|
1093
1313
|
/**
|
|
@@ -1115,7 +1335,11 @@ export declare type TransactionSigningFailedEvent = {
|
|
|
1115
1335
|
* Error code.
|
|
1116
1336
|
*/
|
|
1117
1337
|
error_code: SEND_TRANSACTION_ERROR_CODES | null;
|
|
1118
|
-
|
|
1338
|
+
/**
|
|
1339
|
+
* Unique identifier used for tracking a specific user flow.
|
|
1340
|
+
*/
|
|
1341
|
+
trace_id?: string | null;
|
|
1342
|
+
} & ConnectionInfo & TransactionFullInfo;
|
|
1119
1343
|
|
|
1120
1344
|
/**
|
|
1121
1345
|
* Thrown when app tries to send rpc request to the injected wallet while not connected.
|
|
@@ -1140,6 +1364,23 @@ export declare class UserRejectsError extends TonConnectError {
|
|
|
1140
1364
|
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
1141
1365
|
}
|
|
1142
1366
|
|
|
1367
|
+
/**
|
|
1368
|
+
* The MIT License (MIT)
|
|
1369
|
+
*
|
|
1370
|
+
* Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
|
1371
|
+
*
|
|
1372
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1373
|
+
*
|
|
1374
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1375
|
+
*
|
|
1376
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1377
|
+
*/
|
|
1378
|
+
export declare type UUIDTypes<TBuf extends Uint8Array = Uint8Array> = string | TBuf;
|
|
1379
|
+
|
|
1380
|
+
export declare function UUIDv7(options?: Version7Options, buf?: undefined, offset?: number): string;
|
|
1381
|
+
|
|
1382
|
+
export declare function UUIDv7<TBuf extends Uint8Array = Uint8Array>(options: Version7Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
1383
|
+
|
|
1143
1384
|
/**
|
|
1144
1385
|
* Version of the TON Connect SDK and TON Connect UI.
|
|
1145
1386
|
*/
|
|
@@ -1154,6 +1395,13 @@ export declare type Version = {
|
|
|
1154
1395
|
ton_connect_ui_lib: string | null;
|
|
1155
1396
|
};
|
|
1156
1397
|
|
|
1398
|
+
export declare type Version7Options = {
|
|
1399
|
+
random?: Uint8Array;
|
|
1400
|
+
msecs?: number;
|
|
1401
|
+
seq?: number;
|
|
1402
|
+
rng?: () => Uint8Array;
|
|
1403
|
+
};
|
|
1404
|
+
|
|
1157
1405
|
/**
|
|
1158
1406
|
* Version events.
|
|
1159
1407
|
*/
|
|
@@ -1321,6 +1569,32 @@ export declare class WalletMissingRequiredFeaturesError extends TonConnectError<
|
|
|
1321
1569
|
});
|
|
1322
1570
|
}
|
|
1323
1571
|
|
|
1572
|
+
/**
|
|
1573
|
+
* Represents the event triggered when the wallet modal is opened.
|
|
1574
|
+
*/
|
|
1575
|
+
export declare type WalletModalOpenedEvent = {
|
|
1576
|
+
/**
|
|
1577
|
+
* Event type.
|
|
1578
|
+
*/
|
|
1579
|
+
type: 'wallet-modal-opened';
|
|
1580
|
+
/**
|
|
1581
|
+
* The unique client identifier associated with the session or user.
|
|
1582
|
+
*/
|
|
1583
|
+
client_id: string | null;
|
|
1584
|
+
/**
|
|
1585
|
+
* A list of wallet identifiers that are currently visible in the modal.
|
|
1586
|
+
*/
|
|
1587
|
+
visible_wallets: string[];
|
|
1588
|
+
/**
|
|
1589
|
+
* Custom metadata containing versioning or contextual data for the modal.
|
|
1590
|
+
*/
|
|
1591
|
+
custom_data: Version;
|
|
1592
|
+
/**
|
|
1593
|
+
* Unique identifier used for tracking a specific user flow.
|
|
1594
|
+
*/
|
|
1595
|
+
trace_id: string | null;
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1324
1598
|
/**
|
|
1325
1599
|
* Thrown when send transaction or other protocol methods called while wallet is not connected.
|
|
1326
1600
|
*/
|
|
@@ -1377,6 +1651,18 @@ export declare class WalletsListManager {
|
|
|
1377
1651
|
private isCorrectWalletConfigDTO;
|
|
1378
1652
|
}
|
|
1379
1653
|
|
|
1654
|
+
export declare class WalletWrongNetworkError extends TonConnectError<{
|
|
1655
|
+
expectedChainId: string;
|
|
1656
|
+
actualChainId: string;
|
|
1657
|
+
}> {
|
|
1658
|
+
constructor(message: string, options: {
|
|
1659
|
+
cause: {
|
|
1660
|
+
expectedChainId: string;
|
|
1661
|
+
actualChainId: string;
|
|
1662
|
+
};
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1380
1666
|
/**
|
|
1381
1667
|
* Parameters without version field.
|
|
1382
1668
|
*/
|