@tonconnect/sdk 3.3.1 → 3.4.0-beta.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.
- package/README.md +20 -0
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +1039 -196
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +1035 -197
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +301 -46
- package/package.json +3 -3
package/lib/types/index.d.ts
CHANGED
|
@@ -115,6 +115,10 @@ export declare type ConnectionCompletedEvent = {
|
|
|
115
115
|
* Connection success flag.
|
|
116
116
|
*/
|
|
117
117
|
is_success: true;
|
|
118
|
+
/**
|
|
119
|
+
* Unique identifier used for tracking a specific user flow.
|
|
120
|
+
*/
|
|
121
|
+
trace_id?: string | null;
|
|
118
122
|
} & ConnectionInfo;
|
|
119
123
|
|
|
120
124
|
/**
|
|
@@ -140,7 +144,14 @@ export declare type ConnectionErrorEvent = {
|
|
|
140
144
|
/**
|
|
141
145
|
* Custom data for the connection.
|
|
142
146
|
*/
|
|
143
|
-
custom_data:
|
|
147
|
+
custom_data: {
|
|
148
|
+
client_id: string | null;
|
|
149
|
+
wallet_id: string | null;
|
|
150
|
+
} & Version;
|
|
151
|
+
/**
|
|
152
|
+
* Unique identifier used for tracking a specific user flow.
|
|
153
|
+
*/
|
|
154
|
+
trace_id?: string | null;
|
|
144
155
|
};
|
|
145
156
|
|
|
146
157
|
/**
|
|
@@ -156,6 +167,10 @@ export declare type ConnectionInfo = {
|
|
|
156
167
|
* Connected wallet address.
|
|
157
168
|
*/
|
|
158
169
|
wallet_address: string | null;
|
|
170
|
+
/**
|
|
171
|
+
* Connected wallet state init.
|
|
172
|
+
*/
|
|
173
|
+
wallet_state_init: string | null;
|
|
159
174
|
/**
|
|
160
175
|
* Wallet type: 'tonkeeper', 'tonhub', etc.
|
|
161
176
|
*/
|
|
@@ -180,6 +195,8 @@ export declare type ConnectionInfo = {
|
|
|
180
195
|
* Wallet provider.
|
|
181
196
|
*/
|
|
182
197
|
provider: 'http' | 'injected' | null;
|
|
198
|
+
client_id: string | null;
|
|
199
|
+
wallet_id: string | null;
|
|
183
200
|
} & Version;
|
|
184
201
|
};
|
|
185
202
|
|
|
@@ -195,6 +212,10 @@ export declare type ConnectionRestoringCompletedEvent = {
|
|
|
195
212
|
* Connection success flag.
|
|
196
213
|
*/
|
|
197
214
|
is_success: true;
|
|
215
|
+
/**
|
|
216
|
+
* Unique identifier used for tracking a specific user flow.
|
|
217
|
+
*/
|
|
218
|
+
trace_id?: string | null;
|
|
198
219
|
} & ConnectionInfo;
|
|
199
220
|
|
|
200
221
|
/**
|
|
@@ -217,6 +238,10 @@ export declare type ConnectionRestoringErrorEvent = {
|
|
|
217
238
|
* Custom data for the connection.
|
|
218
239
|
*/
|
|
219
240
|
custom_data: Version;
|
|
241
|
+
/**
|
|
242
|
+
* Unique identifier used for tracking a specific user flow.
|
|
243
|
+
*/
|
|
244
|
+
trace_id?: string | null;
|
|
220
245
|
};
|
|
221
246
|
|
|
222
247
|
/**
|
|
@@ -236,6 +261,10 @@ export declare type ConnectionRestoringStartedEvent = {
|
|
|
236
261
|
* Custom data for the connection.
|
|
237
262
|
*/
|
|
238
263
|
custom_data: Version;
|
|
264
|
+
/**
|
|
265
|
+
* Unique identifier used for tracking a specific user flow.
|
|
266
|
+
*/
|
|
267
|
+
trace_id?: string | null;
|
|
239
268
|
};
|
|
240
269
|
|
|
241
270
|
/**
|
|
@@ -250,6 +279,10 @@ export declare type ConnectionStartedEvent = {
|
|
|
250
279
|
* Custom data for the connection.
|
|
251
280
|
*/
|
|
252
281
|
custom_data: Version;
|
|
282
|
+
/**
|
|
283
|
+
* Unique identifier used for tracking a specific user flow.
|
|
284
|
+
*/
|
|
285
|
+
trace_id?: string | null;
|
|
253
286
|
};
|
|
254
287
|
|
|
255
288
|
export declare type ConnectItem = TonAddressItem | TonProofItem;
|
|
@@ -268,55 +301,55 @@ export declare type ConnectItemReplyError<T> = {
|
|
|
268
301
|
* Create a connection completed event.
|
|
269
302
|
* @param version
|
|
270
303
|
* @param wallet
|
|
304
|
+
* @param sessionInfo
|
|
305
|
+
* @param traceId
|
|
271
306
|
*/
|
|
272
|
-
export declare function createConnectionCompletedEvent(version: Version, wallet: Wallet | null): ConnectionCompletedEvent;
|
|
307
|
+
export declare function createConnectionCompletedEvent(version: Version, wallet: Wallet | null, sessionInfo?: SessionInfo | null, traceId?: string | null): ConnectionCompletedEvent;
|
|
273
308
|
|
|
274
309
|
/**
|
|
275
310
|
* Create a connection error event.
|
|
276
311
|
* @param version
|
|
277
312
|
* @param error_message
|
|
278
313
|
* @param errorCode
|
|
314
|
+
* @param sessionInfo
|
|
315
|
+
* @param traceId
|
|
279
316
|
*/
|
|
280
|
-
export declare function createConnectionErrorEvent(version: Version, error_message: string, errorCode: CONNECT_EVENT_ERROR_CODES | void): ConnectionErrorEvent;
|
|
317
|
+
export declare function createConnectionErrorEvent(version: Version, error_message: string, errorCode: CONNECT_EVENT_ERROR_CODES | void, sessionInfo?: SessionInfo | null, traceId?: string | null): ConnectionErrorEvent;
|
|
281
318
|
|
|
282
319
|
/**
|
|
283
320
|
* Create a connection restoring completed event.
|
|
284
321
|
* @param version
|
|
285
322
|
* @param wallet
|
|
323
|
+
* @param sessionInfo
|
|
324
|
+
* @param traceId
|
|
286
325
|
*/
|
|
287
|
-
export declare function createConnectionRestoringCompletedEvent(version: Version, wallet: Wallet | null): ConnectionRestoringCompletedEvent;
|
|
326
|
+
export declare function createConnectionRestoringCompletedEvent(version: Version, wallet: Wallet | null, sessionInfo?: SessionInfo | null, traceId?: string | null): ConnectionRestoringCompletedEvent;
|
|
288
327
|
|
|
289
328
|
/**
|
|
290
329
|
* Create a connection restoring error event.
|
|
291
330
|
* @param version
|
|
292
331
|
* @param errorMessage
|
|
332
|
+
* @param traceId
|
|
293
333
|
*/
|
|
294
|
-
export declare function createConnectionRestoringErrorEvent(version: Version, errorMessage: string): ConnectionRestoringErrorEvent;
|
|
334
|
+
export declare function createConnectionRestoringErrorEvent(version: Version, errorMessage: string, traceId?: string | null): ConnectionRestoringErrorEvent;
|
|
295
335
|
|
|
296
336
|
/**
|
|
297
337
|
* Create a connection restoring started event.
|
|
298
338
|
*/
|
|
299
|
-
export declare function createConnectionRestoringStartedEvent(version: Version): ConnectionRestoringStartedEvent;
|
|
339
|
+
export declare function createConnectionRestoringStartedEvent(version: Version, traceId?: string | null): ConnectionRestoringStartedEvent;
|
|
300
340
|
|
|
301
341
|
/**
|
|
302
342
|
* Create a connection init event.
|
|
303
343
|
*/
|
|
304
|
-
export declare function createConnectionStartedEvent(version: Version): ConnectionStartedEvent;
|
|
344
|
+
export declare function createConnectionStartedEvent(version: Version, traceId?: string | null): ConnectionStartedEvent;
|
|
305
345
|
|
|
306
|
-
export declare function createDataSentForSignatureEvent(version: Version, wallet: Wallet | null, data: SignDataPayload): DataSentForSignatureEvent;
|
|
346
|
+
export declare function createDataSentForSignatureEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, sessionInfo?: SessionInfo | null, traceId?: string | null): DataSentForSignatureEvent;
|
|
307
347
|
|
|
308
|
-
export declare function createDataSignedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, signedData: SignDataResponse): DataSignedEvent;
|
|
348
|
+
export declare function createDataSignedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, signedData: SignDataResponse, sessionInfo?: SessionInfo | null, traceId?: string | null): DataSignedEvent;
|
|
309
349
|
|
|
310
|
-
export declare function createDataSigningFailedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, errorMessage: string, errorCode: SIGN_DATA_ERROR_CODES | void): DataSigningFailedEvent;
|
|
350
|
+
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
351
|
|
|
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;
|
|
352
|
+
export declare function createDisconnectionEvent(version: Version, wallet: Wallet | null, scope: 'dapp' | 'wallet', sessionInfo?: SessionInfo | null, traceId?: string | null): DisconnectionEvent;
|
|
320
353
|
|
|
321
354
|
/**
|
|
322
355
|
* Create a request version event.
|
|
@@ -329,13 +362,17 @@ export declare function createRequestVersionEvent(): RequestVersionEvent;
|
|
|
329
362
|
*/
|
|
330
363
|
export declare function createResponseVersionEvent(version: string): ResponseVersionEvent;
|
|
331
364
|
|
|
365
|
+
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;
|
|
366
|
+
|
|
332
367
|
/**
|
|
333
368
|
* Create a transaction init event.
|
|
334
369
|
* @param version
|
|
335
370
|
* @param wallet
|
|
336
371
|
* @param transaction
|
|
372
|
+
* @param sessionInfo
|
|
373
|
+
* @param traceId
|
|
337
374
|
*/
|
|
338
|
-
export declare function createTransactionSentForSignatureEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest): TransactionSentForSignatureEvent;
|
|
375
|
+
export declare function createTransactionSentForSignatureEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, sessionInfo?: SessionInfo | null, traceId?: string | null): TransactionSentForSignatureEvent;
|
|
339
376
|
|
|
340
377
|
/**
|
|
341
378
|
* Create a transaction signed event.
|
|
@@ -343,8 +380,10 @@ export declare function createTransactionSentForSignatureEvent(version: Version,
|
|
|
343
380
|
* @param wallet
|
|
344
381
|
* @param transaction
|
|
345
382
|
* @param signedTransaction
|
|
383
|
+
* @param sessionInfo
|
|
384
|
+
* @param traceId
|
|
346
385
|
*/
|
|
347
|
-
export declare function createTransactionSignedEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, signedTransaction: SendTransactionResponse): TransactionSignedEvent;
|
|
386
|
+
export declare function createTransactionSignedEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, signedTransaction: SendTransactionResponse, sessionInfo?: SessionInfo | null, traceId?: string | null): TransactionSignedEvent;
|
|
348
387
|
|
|
349
388
|
/**
|
|
350
389
|
* Create a transaction error event.
|
|
@@ -353,8 +392,10 @@ export declare function createTransactionSignedEvent(version: Version, wallet: W
|
|
|
353
392
|
* @param transaction
|
|
354
393
|
* @param errorMessage
|
|
355
394
|
* @param errorCode
|
|
395
|
+
* @param sessionInfo
|
|
396
|
+
* @param traceId
|
|
356
397
|
*/
|
|
357
|
-
export declare function createTransactionSigningFailedEvent(version: Version, wallet: Wallet | null, transaction: SendTransactionRequest, errorMessage: string, errorCode: SEND_TRANSACTION_ERROR_CODES | void): TransactionSigningFailedEvent;
|
|
398
|
+
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
399
|
|
|
359
400
|
/**
|
|
360
401
|
* Create a version info.
|
|
@@ -362,6 +403,8 @@ export declare function createTransactionSigningFailedEvent(version: Version, wa
|
|
|
362
403
|
*/
|
|
363
404
|
export declare function createVersionInfo(version: Version): Version;
|
|
364
405
|
|
|
406
|
+
export declare function createWalletModalOpenedEvent(version: Version, visibleWallets: string[], clientId?: string | null, traceId?: string | null): WalletModalOpenedEvent;
|
|
407
|
+
|
|
365
408
|
export declare interface DappMetadata {
|
|
366
409
|
/**
|
|
367
410
|
* Dapp name. Might be simple, will not be used as identifier.
|
|
@@ -384,6 +427,10 @@ export declare interface DappMetadata {
|
|
|
384
427
|
export declare type DataSentForSignatureEvent = {
|
|
385
428
|
type: 'sign-data-request-initiated';
|
|
386
429
|
data: SignDataPayload;
|
|
430
|
+
/**
|
|
431
|
+
* Unique identifier used for tracking a specific user flow.
|
|
432
|
+
*/
|
|
433
|
+
trace_id?: string | null;
|
|
387
434
|
} & ConnectionInfo;
|
|
388
435
|
|
|
389
436
|
export declare type DataSignedEvent = {
|
|
@@ -391,6 +438,10 @@ export declare type DataSignedEvent = {
|
|
|
391
438
|
is_success: true;
|
|
392
439
|
data: SignDataPayload;
|
|
393
440
|
signed_data: SignDataResponse;
|
|
441
|
+
/**
|
|
442
|
+
* Unique identifier used for tracking a specific user flow.
|
|
443
|
+
*/
|
|
444
|
+
trace_id?: string | null;
|
|
394
445
|
} & ConnectionInfo;
|
|
395
446
|
|
|
396
447
|
export declare type DataSigningEvent = DataSentForSignatureEvent | DataSignedEvent | DataSigningFailedEvent;
|
|
@@ -401,8 +452,14 @@ export declare type DataSigningFailedEvent = {
|
|
|
401
452
|
error_message: string;
|
|
402
453
|
error_code: SIGN_DATA_ERROR_CODES | null;
|
|
403
454
|
data: SignDataPayload;
|
|
455
|
+
/**
|
|
456
|
+
* Unique identifier used for tracking a specific user flow.
|
|
457
|
+
*/
|
|
458
|
+
trace_id?: string | null;
|
|
404
459
|
} & ConnectionInfo;
|
|
405
460
|
|
|
461
|
+
export declare function decodeTelegramUrlParameters(parameters: string): string;
|
|
462
|
+
|
|
406
463
|
export declare interface DeviceInfo {
|
|
407
464
|
platform: 'iphone' | 'ipad' | 'android' | 'windows' | 'mac' | 'linux' | 'browser';
|
|
408
465
|
appName: string;
|
|
@@ -423,6 +480,10 @@ export declare type DisconnectionEvent = {
|
|
|
423
480
|
* Disconnect scope: 'dapp' or 'wallet'.
|
|
424
481
|
*/
|
|
425
482
|
scope: 'dapp' | 'wallet';
|
|
483
|
+
/**
|
|
484
|
+
* Unique identifier used for tracking a specific user flow.
|
|
485
|
+
*/
|
|
486
|
+
trace_id?: string | null;
|
|
426
487
|
} & ConnectionInfo;
|
|
427
488
|
|
|
428
489
|
export declare function enableQaMode(): void;
|
|
@@ -467,6 +528,36 @@ export declare class FetchWalletsError extends TonConnectError {
|
|
|
467
528
|
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
468
529
|
}
|
|
469
530
|
|
|
531
|
+
/**
|
|
532
|
+
* Represents the client environment in which the application is running.
|
|
533
|
+
*/
|
|
534
|
+
export declare interface IEnvironment {
|
|
535
|
+
/**
|
|
536
|
+
* Retrieves the user's current locale setting.
|
|
537
|
+
*/
|
|
538
|
+
getLocale(): string;
|
|
539
|
+
/**
|
|
540
|
+
* Retrieves the name or identifier of the user's browser.
|
|
541
|
+
*/
|
|
542
|
+
getBrowser(): string;
|
|
543
|
+
/**
|
|
544
|
+
* Retrieves the name of the user's operating system or platform.
|
|
545
|
+
*/
|
|
546
|
+
getPlatform(): string;
|
|
547
|
+
/**
|
|
548
|
+
* Retrieves the Telegram user associated with the current environment, if available.
|
|
549
|
+
*/
|
|
550
|
+
getTelegramUser(): TelegramUser | undefined;
|
|
551
|
+
/**
|
|
552
|
+
* Retrieves the type of client environment.
|
|
553
|
+
* Indicates whether the client is running as a web application,
|
|
554
|
+
* Telegram Mini App, or another custom environment.
|
|
555
|
+
*/
|
|
556
|
+
getClientEnvironment(): 'web' | 'miniapp' | (string & {});
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export declare function isConnectUrl(link: string | undefined): link is string;
|
|
560
|
+
|
|
470
561
|
export declare function isQaModeEnabled(): boolean;
|
|
471
562
|
|
|
472
563
|
export declare function isTelegramUrl(link: string | undefined): link is string;
|
|
@@ -551,16 +642,20 @@ export declare interface ITonConnect {
|
|
|
551
642
|
* Generates universal link for an external wallet and subscribes to the wallet's bridge, or sends connect request to the injected wallet.
|
|
552
643
|
* @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
644
|
* @param request (optional) additional request to pass to the wallet while connect (currently only ton_proof is available).
|
|
645
|
+
* @param options (optional) options
|
|
554
646
|
* @returns universal link if external wallet was passed or void for the injected wallet.
|
|
555
647
|
*/
|
|
556
|
-
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest
|
|
648
|
+
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest, options?: OptionalTraceable<{
|
|
649
|
+
openingDeadlineMS?: number;
|
|
650
|
+
signal?: AbortSignal;
|
|
651
|
+
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
557
652
|
/**
|
|
558
653
|
* Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.
|
|
559
654
|
*/
|
|
560
|
-
restoreConnection(options?: {
|
|
655
|
+
restoreConnection(options?: OptionalTraceable<{
|
|
561
656
|
openingDeadlineMS?: number;
|
|
562
657
|
signal?: AbortSignal;
|
|
563
|
-
}): Promise<void>;
|
|
658
|
+
}>): Promise<void>;
|
|
564
659
|
/**
|
|
565
660
|
* Pause bridge HTTP connection. Might be helpful, if you want to pause connections while browser tab is unfocused,
|
|
566
661
|
* or if you use SDK with NodeJS and want to save server resources.
|
|
@@ -573,9 +668,9 @@ export declare interface ITonConnect {
|
|
|
573
668
|
/**
|
|
574
669
|
* Disconnect form thw connected wallet and drop current session.
|
|
575
670
|
*/
|
|
576
|
-
disconnect(options?: {
|
|
671
|
+
disconnect(options?: OptionalTraceable<{
|
|
577
672
|
signal?: AbortSignal;
|
|
578
|
-
}): Promise<void>;
|
|
673
|
+
}>): Promise<void>;
|
|
579
674
|
/**
|
|
580
675
|
* Asks connected wallet to sign and send the transaction.
|
|
581
676
|
* @param transaction transaction to send.
|
|
@@ -583,16 +678,16 @@ export declare interface ITonConnect {
|
|
|
583
678
|
* @returns signed transaction boc that allows you to find the transaction in the blockchain.
|
|
584
679
|
* If user rejects transaction, method will throw the corresponding error.
|
|
585
680
|
*/
|
|
586
|
-
sendTransaction(transaction: SendTransactionRequest, options?: {
|
|
681
|
+
sendTransaction(transaction: SendTransactionRequest, options?: OptionalTraceable<{
|
|
587
682
|
onRequestSent?: () => void;
|
|
588
683
|
signal?: AbortSignal;
|
|
589
|
-
}): Promise<SendTransactionResponse
|
|
684
|
+
}>): Promise<OptionalTraceable<SendTransactionResponse>>;
|
|
590
685
|
/** @deprecated use sendTransaction(transaction, options) instead */
|
|
591
|
-
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<SendTransactionResponse
|
|
592
|
-
signData(data: SignDataPayload, options?: {
|
|
686
|
+
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<OptionalTraceable<SendTransactionResponse>>;
|
|
687
|
+
signData(data: SignDataPayload, options?: OptionalTraceable<{
|
|
593
688
|
onRequestSent?: () => void;
|
|
594
689
|
signal?: AbortSignal;
|
|
595
|
-
}): Promise<SignDataResponse
|
|
690
|
+
}>): Promise<OptionalTraceable<SignDataResponse>>;
|
|
596
691
|
/**
|
|
597
692
|
* Gets the current session ID if available.
|
|
598
693
|
* @returns session ID string or null if not available.
|
|
@@ -613,6 +708,10 @@ export declare class LocalstorageNotFoundError extends TonConnectError {
|
|
|
613
708
|
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
614
709
|
}
|
|
615
710
|
|
|
711
|
+
export declare type OptionalTraceable<T extends {} = {}> = {
|
|
712
|
+
traceId?: string;
|
|
713
|
+
} & T;
|
|
714
|
+
|
|
616
715
|
/**
|
|
617
716
|
* Thrown when passed hex is in incorrect format.
|
|
618
717
|
*/
|
|
@@ -688,7 +787,46 @@ export declare type ResponseVersionEvent = {
|
|
|
688
787
|
/**
|
|
689
788
|
* User action events.
|
|
690
789
|
*/
|
|
691
|
-
export declare type SdkActionEvent = VersionEvent | ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent | DataSigningEvent;
|
|
790
|
+
export declare type SdkActionEvent = VersionEvent | ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent | DataSigningEvent | WalletModalOpenedEvent | SelectedWalletEvent;
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Represents the event triggered when the wallet is selected.
|
|
794
|
+
*/
|
|
795
|
+
export declare type SelectedWalletEvent = {
|
|
796
|
+
/**
|
|
797
|
+
* Event type.
|
|
798
|
+
*/
|
|
799
|
+
type: 'selected-wallet';
|
|
800
|
+
/**
|
|
801
|
+
* The unique client identifier associated with the session or user.
|
|
802
|
+
*/
|
|
803
|
+
client_id: string | null;
|
|
804
|
+
/**
|
|
805
|
+
* A list of wallet identifiers that are currently visible in the modal.
|
|
806
|
+
*/
|
|
807
|
+
visible_wallets: string[];
|
|
808
|
+
wallets_menu: 'explicit_wallet' | 'main_screen' | 'other_wallets';
|
|
809
|
+
/**
|
|
810
|
+
* Redirect method: tg_link, external_link
|
|
811
|
+
*/
|
|
812
|
+
wallet_redirect_method?: 'tg_link' | 'external_link';
|
|
813
|
+
/**
|
|
814
|
+
* URL used to open the wallet
|
|
815
|
+
*/
|
|
816
|
+
wallet_redirect_link?: string;
|
|
817
|
+
/**
|
|
818
|
+
* Wallet type: 'tonkeeper', 'tonhub', etc.
|
|
819
|
+
*/
|
|
820
|
+
wallet_type: string | null;
|
|
821
|
+
/**
|
|
822
|
+
* Custom metadata containing versioning or contextual data for the modal.
|
|
823
|
+
*/
|
|
824
|
+
custom_data: Version;
|
|
825
|
+
/**
|
|
826
|
+
* Unique identifier used for tracking a specific user flow.
|
|
827
|
+
*/
|
|
828
|
+
trace_id: string | null;
|
|
829
|
+
};
|
|
692
830
|
|
|
693
831
|
export declare enum SEND_TRANSACTION_ERROR_CODES {
|
|
694
832
|
UNKNOWN_ERROR = 0,
|
|
@@ -768,6 +906,11 @@ export declare class SessionCrypto {
|
|
|
768
906
|
stringifyKeypair(): KeyPair;
|
|
769
907
|
}
|
|
770
908
|
|
|
909
|
+
export declare type SessionInfo = {
|
|
910
|
+
clientId: string | null;
|
|
911
|
+
walletId: string | null;
|
|
912
|
+
};
|
|
913
|
+
|
|
771
914
|
export declare enum SIGN_DATA_ERROR_CODES {
|
|
772
915
|
UNKNOWN_ERROR = 0,
|
|
773
916
|
BAD_REQUEST_ERROR = 1,
|
|
@@ -812,6 +955,16 @@ export declare type SignDataResponse = {
|
|
|
812
955
|
|
|
813
956
|
export declare type SignDataType = 'text' | 'binary' | 'cell';
|
|
814
957
|
|
|
958
|
+
/**
|
|
959
|
+
* Basic Telegram user information.
|
|
960
|
+
*/
|
|
961
|
+
export declare type TelegramUser = {
|
|
962
|
+
/** Unique Telegram user ID. */
|
|
963
|
+
id: number;
|
|
964
|
+
/** Whether the user has Telegram Premium. */
|
|
965
|
+
isPremium: boolean;
|
|
966
|
+
};
|
|
967
|
+
|
|
815
968
|
export declare interface TonAddressItem {
|
|
816
969
|
name: 'ton_addr';
|
|
817
970
|
}
|
|
@@ -846,6 +999,8 @@ declare class TonConnect implements ITonConnect {
|
|
|
846
999
|
*/
|
|
847
1000
|
private readonly tracker;
|
|
848
1001
|
private readonly walletsList;
|
|
1002
|
+
private readonly analytics?;
|
|
1003
|
+
private readonly environment;
|
|
849
1004
|
private readonly dappSettings;
|
|
850
1005
|
private readonly bridgeConnectionStorage;
|
|
851
1006
|
private _wallet;
|
|
@@ -886,23 +1041,23 @@ declare class TonConnect implements ITonConnect {
|
|
|
886
1041
|
* @param options (optional) openingDeadlineMS for the connection opening deadline and signal for the connection abort.
|
|
887
1042
|
* @returns universal link if external wallet was passed or void for the injected wallet.
|
|
888
1043
|
*/
|
|
889
|
-
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, options?: {
|
|
1044
|
+
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, options?: OptionalTraceable<{
|
|
890
1045
|
request?: ConnectAdditionalRequest;
|
|
891
1046
|
openingDeadlineMS?: number;
|
|
892
1047
|
signal?: AbortSignal;
|
|
893
|
-
}): T extends WalletConnectionSourceJS ? void : string;
|
|
1048
|
+
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
894
1049
|
/** @deprecated use connect(wallet, options) instead */
|
|
895
|
-
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest, options?: {
|
|
1050
|
+
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest, options?: OptionalTraceable<{
|
|
896
1051
|
openingDeadlineMS?: number;
|
|
897
1052
|
signal?: AbortSignal;
|
|
898
|
-
}): T extends WalletConnectionSourceJS ? void : string;
|
|
1053
|
+
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
899
1054
|
/**
|
|
900
1055
|
* Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.
|
|
901
1056
|
*/
|
|
902
|
-
restoreConnection(options?: {
|
|
1057
|
+
restoreConnection(options?: OptionalTraceable<{
|
|
903
1058
|
openingDeadlineMS?: number;
|
|
904
1059
|
signal?: AbortSignal;
|
|
905
|
-
}): Promise<void>;
|
|
1060
|
+
}>): Promise<void>;
|
|
906
1061
|
/**
|
|
907
1062
|
* Asks connected wallet to sign and send the transaction.
|
|
908
1063
|
* @param transaction transaction to send.
|
|
@@ -910,27 +1065,28 @@ declare class TonConnect implements ITonConnect {
|
|
|
910
1065
|
* @returns signed transaction boc that allows you to find the transaction in the blockchain.
|
|
911
1066
|
* If user rejects transaction, method will throw the corresponding error.
|
|
912
1067
|
*/
|
|
913
|
-
sendTransaction(transaction: SendTransactionRequest, options?: {
|
|
1068
|
+
sendTransaction(transaction: SendTransactionRequest, options?: OptionalTraceable<{
|
|
914
1069
|
onRequestSent?: () => void;
|
|
915
1070
|
signal?: AbortSignal;
|
|
916
|
-
}): Promise<SendTransactionResponse
|
|
1071
|
+
}>): Promise<Traceable<SendTransactionResponse>>;
|
|
917
1072
|
/** @deprecated use sendTransaction(transaction, options) instead */
|
|
918
|
-
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<SendTransactionResponse
|
|
919
|
-
signData(data: SignDataPayload, options?: {
|
|
1073
|
+
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<Traceable<SendTransactionResponse>>;
|
|
1074
|
+
signData(data: SignDataPayload, options?: OptionalTraceable<{
|
|
920
1075
|
onRequestSent?: () => void;
|
|
921
1076
|
signal?: AbortSignal;
|
|
922
|
-
}): Promise<SignDataResponse
|
|
1077
|
+
}>): Promise<Traceable<SignDataResponse>>;
|
|
923
1078
|
/**
|
|
924
1079
|
* Disconnect form thw connected wallet and drop current session.
|
|
925
1080
|
*/
|
|
926
|
-
disconnect(options?: {
|
|
1081
|
+
disconnect(options?: OptionalTraceable<{
|
|
927
1082
|
signal?: AbortSignal;
|
|
928
|
-
}): Promise<void>;
|
|
1083
|
+
}>): Promise<void>;
|
|
929
1084
|
/**
|
|
930
1085
|
* Gets the current session ID if available.
|
|
931
1086
|
* @returns session ID string or null if not available.
|
|
932
1087
|
*/
|
|
933
1088
|
getSessionId(): Promise<string | null>;
|
|
1089
|
+
private getSessionInfo;
|
|
934
1090
|
/**
|
|
935
1091
|
* Pause bridge HTTP connection. Might be helpful, if you want to pause connections while browser tab is unfocused,
|
|
936
1092
|
* or if you use SDK with NodeJS and want to save server resources.
|
|
@@ -999,6 +1155,10 @@ export declare interface TonConnectOptions {
|
|
|
999
1155
|
* Allows to disable auto pause/unpause SSE connection on 'document.visibilitychange' event. It is not recommended to change default behaviour.
|
|
1000
1156
|
*/
|
|
1001
1157
|
disableAutoPauseConnection?: boolean;
|
|
1158
|
+
/**
|
|
1159
|
+
* Represents the client environment in which the application is running.
|
|
1160
|
+
*/
|
|
1161
|
+
environment?: IEnvironment;
|
|
1002
1162
|
}
|
|
1003
1163
|
|
|
1004
1164
|
export declare interface TonProofItem {
|
|
@@ -1030,6 +1190,39 @@ export declare interface TonProofItemReplySuccess {
|
|
|
1030
1190
|
*/
|
|
1031
1191
|
export declare function toUserFriendlyAddress(hexAddress: string, testOnly?: boolean): string;
|
|
1032
1192
|
|
|
1193
|
+
export declare type Traceable<T extends {} = {}> = {
|
|
1194
|
+
traceId: string;
|
|
1195
|
+
} & T;
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Transaction information.
|
|
1199
|
+
*/
|
|
1200
|
+
export declare type TransactionFullInfo = Omit<TransactionInfo, 'messages'> & {
|
|
1201
|
+
messages: TransactionFullMessage[];
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Transaction message.
|
|
1206
|
+
*/
|
|
1207
|
+
export declare type TransactionFullMessage = {
|
|
1208
|
+
/**
|
|
1209
|
+
* Recipient address.
|
|
1210
|
+
*/
|
|
1211
|
+
address: string | null;
|
|
1212
|
+
/**
|
|
1213
|
+
* Transfer amount.
|
|
1214
|
+
*/
|
|
1215
|
+
amount: string | null;
|
|
1216
|
+
/**
|
|
1217
|
+
* Message payload
|
|
1218
|
+
*/
|
|
1219
|
+
payload: string | null;
|
|
1220
|
+
/**
|
|
1221
|
+
* Message state init
|
|
1222
|
+
*/
|
|
1223
|
+
state_init: string | null;
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1033
1226
|
/**
|
|
1034
1227
|
* Transaction information.
|
|
1035
1228
|
*/
|
|
@@ -1070,6 +1263,10 @@ export declare type TransactionSentForSignatureEvent = {
|
|
|
1070
1263
|
* Event type.
|
|
1071
1264
|
*/
|
|
1072
1265
|
type: 'transaction-sent-for-signature';
|
|
1266
|
+
/**
|
|
1267
|
+
* Unique identifier used for tracking a specific user flow.
|
|
1268
|
+
*/
|
|
1269
|
+
trace_id?: string | null;
|
|
1073
1270
|
} & ConnectionInfo & TransactionInfo;
|
|
1074
1271
|
|
|
1075
1272
|
/**
|
|
@@ -1088,6 +1285,10 @@ export declare type TransactionSignedEvent = {
|
|
|
1088
1285
|
* Signed transaction.
|
|
1089
1286
|
*/
|
|
1090
1287
|
signed_transaction: string;
|
|
1288
|
+
/**
|
|
1289
|
+
* Unique identifier used for tracking a specific user flow.
|
|
1290
|
+
*/
|
|
1291
|
+
trace_id?: string | null;
|
|
1091
1292
|
} & ConnectionInfo & TransactionInfo;
|
|
1092
1293
|
|
|
1093
1294
|
/**
|
|
@@ -1115,7 +1316,11 @@ export declare type TransactionSigningFailedEvent = {
|
|
|
1115
1316
|
* Error code.
|
|
1116
1317
|
*/
|
|
1117
1318
|
error_code: SEND_TRANSACTION_ERROR_CODES | null;
|
|
1118
|
-
|
|
1319
|
+
/**
|
|
1320
|
+
* Unique identifier used for tracking a specific user flow.
|
|
1321
|
+
*/
|
|
1322
|
+
trace_id?: string | null;
|
|
1323
|
+
} & ConnectionInfo & TransactionFullInfo;
|
|
1119
1324
|
|
|
1120
1325
|
/**
|
|
1121
1326
|
* Thrown when app tries to send rpc request to the injected wallet while not connected.
|
|
@@ -1140,6 +1345,23 @@ export declare class UserRejectsError extends TonConnectError {
|
|
|
1140
1345
|
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
1141
1346
|
}
|
|
1142
1347
|
|
|
1348
|
+
/**
|
|
1349
|
+
* The MIT License (MIT)
|
|
1350
|
+
*
|
|
1351
|
+
* Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
|
1352
|
+
*
|
|
1353
|
+
* 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:
|
|
1354
|
+
*
|
|
1355
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1356
|
+
*
|
|
1357
|
+
* 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.
|
|
1358
|
+
*/
|
|
1359
|
+
export declare type UUIDTypes<TBuf extends Uint8Array = Uint8Array> = string | TBuf;
|
|
1360
|
+
|
|
1361
|
+
export declare function UUIDv7(options?: Version7Options, buf?: undefined, offset?: number): string;
|
|
1362
|
+
|
|
1363
|
+
export declare function UUIDv7<TBuf extends Uint8Array = Uint8Array>(options: Version7Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
1364
|
+
|
|
1143
1365
|
/**
|
|
1144
1366
|
* Version of the TON Connect SDK and TON Connect UI.
|
|
1145
1367
|
*/
|
|
@@ -1154,6 +1376,13 @@ export declare type Version = {
|
|
|
1154
1376
|
ton_connect_ui_lib: string | null;
|
|
1155
1377
|
};
|
|
1156
1378
|
|
|
1379
|
+
export declare type Version7Options = {
|
|
1380
|
+
random?: Uint8Array;
|
|
1381
|
+
msecs?: number;
|
|
1382
|
+
seq?: number;
|
|
1383
|
+
rng?: () => Uint8Array;
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1157
1386
|
/**
|
|
1158
1387
|
* Version events.
|
|
1159
1388
|
*/
|
|
@@ -1321,6 +1550,32 @@ export declare class WalletMissingRequiredFeaturesError extends TonConnectError<
|
|
|
1321
1550
|
});
|
|
1322
1551
|
}
|
|
1323
1552
|
|
|
1553
|
+
/**
|
|
1554
|
+
* Represents the event triggered when the wallet modal is opened.
|
|
1555
|
+
*/
|
|
1556
|
+
export declare type WalletModalOpenedEvent = {
|
|
1557
|
+
/**
|
|
1558
|
+
* Event type.
|
|
1559
|
+
*/
|
|
1560
|
+
type: 'wallet-modal-opened';
|
|
1561
|
+
/**
|
|
1562
|
+
* The unique client identifier associated with the session or user.
|
|
1563
|
+
*/
|
|
1564
|
+
client_id: string | null;
|
|
1565
|
+
/**
|
|
1566
|
+
* A list of wallet identifiers that are currently visible in the modal.
|
|
1567
|
+
*/
|
|
1568
|
+
visible_wallets: string[];
|
|
1569
|
+
/**
|
|
1570
|
+
* Custom metadata containing versioning or contextual data for the modal.
|
|
1571
|
+
*/
|
|
1572
|
+
custom_data: Version;
|
|
1573
|
+
/**
|
|
1574
|
+
* Unique identifier used for tracking a specific user flow.
|
|
1575
|
+
*/
|
|
1576
|
+
trace_id: string | null;
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1324
1579
|
/**
|
|
1325
1580
|
* Thrown when send transaction or other protocol methods called while wallet is not connected.
|
|
1326
1581
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonconnect/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ton-connect/sdk.git"
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@tonconnect/isomorphic-eventsource": "0.0.2",
|
|
24
|
-
"@tonconnect/
|
|
25
|
-
"@tonconnect/
|
|
24
|
+
"@tonconnect/isomorphic-fetch": "0.0.3",
|
|
25
|
+
"@tonconnect/protocol": "2.3.0"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"lib",
|