@tonconnect/ui 2.0.3-beta.0 → 2.0.3-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 +48 -0
- package/dist/tonconnect-ui.min.js +209 -209
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.cjs +67 -138
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +20 -232
- package/lib/index.mjs +58 -129
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { WalletInfoBase, WalletInfoInjectable, WalletInfoRemote, ITonConnect, Wallet, WalletInfo, Account, ConnectAdditionalRequest, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk';
|
|
1
|
+
import { WalletInfoBase, WalletInfoInjectable, WalletInfoRemote, ConnectionEvent, ConnectionRestoringEvent, DisconnectionEvent, TransactionSigningEvent, ITonConnect, EventDispatcher, SdkActionEvent, Wallet, WalletInfo, Account, ConnectAdditionalRequest, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk';
|
|
2
2
|
export * from '@tonconnect/sdk';
|
|
3
3
|
import { Property } from 'csstype';
|
|
4
|
-
import { ConnectItem } from '@tonconnect/protocol';
|
|
5
4
|
|
|
6
5
|
declare type Locales = 'en' | 'ru';
|
|
7
6
|
|
|
@@ -169,6 +168,11 @@ interface TonConnectUiOptions {
|
|
|
169
168
|
enableAndroidBackHandler?: boolean;
|
|
170
169
|
}
|
|
171
170
|
|
|
171
|
+
/**
|
|
172
|
+
* User action events.
|
|
173
|
+
*/
|
|
174
|
+
declare type UserActionEvent = ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent;
|
|
175
|
+
|
|
172
176
|
declare type TonConnectUiCreateOptions = TonConnectUiOptionsWithConnector | TonConnectUiOptionsWithManifest;
|
|
173
177
|
interface TonConnectUiOptionsWithManifest extends TonConnectUiCreateOptionsBase {
|
|
174
178
|
/**
|
|
@@ -194,6 +198,11 @@ interface TonConnectUiCreateOptionsBase extends TonConnectUiOptions {
|
|
|
194
198
|
* @default `div#tc-widget-root`.
|
|
195
199
|
*/
|
|
196
200
|
widgetRootId?: string;
|
|
201
|
+
/**
|
|
202
|
+
* Event dispatcher to track user actions. By default, it uses `window.dispatchEvent` for browser environment.
|
|
203
|
+
* @default BrowserEventDispatcher.
|
|
204
|
+
*/
|
|
205
|
+
eventDispatcher?: EventDispatcher<UserActionEvent | SdkActionEvent>;
|
|
197
206
|
}
|
|
198
207
|
|
|
199
208
|
declare type WalletOpenMethod = 'qrcode' | 'universal-link' | 'custom-deeplink';
|
|
@@ -219,8 +228,9 @@ interface WalletsModal {
|
|
|
219
228
|
open: () => void;
|
|
220
229
|
/**
|
|
221
230
|
* Close the modal.
|
|
231
|
+
* @default 'action-cancelled'
|
|
222
232
|
*/
|
|
223
|
-
close: () => void;
|
|
233
|
+
close: (reason?: WalletsModalCloseReason) => void;
|
|
224
234
|
/**
|
|
225
235
|
* Subscribe to the modal window status changes.
|
|
226
236
|
*/
|
|
@@ -308,6 +318,10 @@ declare class TonConnectUI {
|
|
|
308
318
|
static getWallets(): Promise<WalletInfo[]>;
|
|
309
319
|
private readonly walletInfoStorage;
|
|
310
320
|
private readonly preferredWalletStorage;
|
|
321
|
+
/**
|
|
322
|
+
* Emits user action event to the EventDispatcher. By default, it uses `window.dispatchEvent` for browser environment.
|
|
323
|
+
* @private
|
|
324
|
+
*/
|
|
311
325
|
private readonly tracker;
|
|
312
326
|
private walletInfo;
|
|
313
327
|
private systemThemeChangeUnsubscribe;
|
|
@@ -379,7 +393,7 @@ declare class TonConnectUI {
|
|
|
379
393
|
/**
|
|
380
394
|
* Closes the modal window.
|
|
381
395
|
*/
|
|
382
|
-
closeModal(): void;
|
|
396
|
+
closeModal(reason?: WalletsModalCloseReason): void;
|
|
383
397
|
/**
|
|
384
398
|
* Subscribe to the modal window state changes, returns a function which has to be called to unsubscribe.
|
|
385
399
|
*/
|
|
@@ -397,7 +411,7 @@ declare class TonConnectUI {
|
|
|
397
411
|
* Close the single wallet modal window.
|
|
398
412
|
* @experimental
|
|
399
413
|
*/
|
|
400
|
-
closeSingleWalletModal(): void;
|
|
414
|
+
closeSingleWalletModal(closeReason?: WalletsModalCloseReason): void;
|
|
401
415
|
/**
|
|
402
416
|
* Subscribe to the single wallet modal window state changes, returns a function which has to be called to unsubscribe.
|
|
403
417
|
* @experimental
|
|
@@ -476,236 +490,10 @@ declare class TonConnectUI {
|
|
|
476
490
|
private getModalsAndNotificationsConfiguration;
|
|
477
491
|
}
|
|
478
492
|
|
|
479
|
-
/**
|
|
480
|
-
* Requested authentication type: 'ton_addr' or 'ton_proof'.
|
|
481
|
-
*/
|
|
482
|
-
declare type AuthType = ConnectItem['name'];
|
|
483
|
-
/**
|
|
484
|
-
* Information about a connected wallet.
|
|
485
|
-
*/
|
|
486
|
-
declare type ConnectionInfo = {
|
|
487
|
-
/**
|
|
488
|
-
* Connected wallet address.
|
|
489
|
-
*/
|
|
490
|
-
address: string | null;
|
|
491
|
-
/**
|
|
492
|
-
* Connected chain ID.
|
|
493
|
-
*/
|
|
494
|
-
chainId: string | null;
|
|
495
|
-
/**
|
|
496
|
-
* Wallet provider.
|
|
497
|
-
*/
|
|
498
|
-
provider: 'http' | 'injected' | null;
|
|
499
|
-
/**
|
|
500
|
-
* Wallet type: 'tonkeeper', 'tonhub', etc.
|
|
501
|
-
*/
|
|
502
|
-
walletType: string | null;
|
|
503
|
-
/**
|
|
504
|
-
* Wallet version.
|
|
505
|
-
*/
|
|
506
|
-
walletVersion: string | null;
|
|
507
|
-
/**
|
|
508
|
-
* Requested authentication types.
|
|
509
|
-
*/
|
|
510
|
-
authType: AuthType | null;
|
|
511
|
-
};
|
|
512
|
-
/**
|
|
513
|
-
* Initial connection event when a user initiates a connection.
|
|
514
|
-
*/
|
|
515
|
-
declare type ConnectionStartedEvent = {
|
|
516
|
-
/**
|
|
517
|
-
* Event type.
|
|
518
|
-
*/
|
|
519
|
-
type: 'connection-started';
|
|
520
|
-
};
|
|
521
|
-
/**
|
|
522
|
-
* Successful connection event when a user successfully connected a wallet.
|
|
523
|
-
*/
|
|
524
|
-
declare type ConnectionCompletedEvent = {
|
|
525
|
-
/**
|
|
526
|
-
* Event type.
|
|
527
|
-
*/
|
|
528
|
-
type: 'connection-completed';
|
|
529
|
-
/**
|
|
530
|
-
* Wallet information.
|
|
531
|
-
*/
|
|
532
|
-
connectionInfo: ConnectionInfo;
|
|
533
|
-
};
|
|
534
|
-
/**
|
|
535
|
-
* Connection error event when a user cancels a connection or there is an error during the connection process.
|
|
536
|
-
*/
|
|
537
|
-
declare type ConnectionErrorEvent = {
|
|
538
|
-
/**
|
|
539
|
-
* Event type.
|
|
540
|
-
*/
|
|
541
|
-
type: 'connection-error';
|
|
542
|
-
/**
|
|
543
|
-
* Reason for the error.
|
|
544
|
-
*/
|
|
545
|
-
reason: string;
|
|
546
|
-
};
|
|
547
|
-
/**
|
|
548
|
-
* Connection events.
|
|
549
|
-
*/
|
|
550
|
-
declare type ConnectionEvent = ConnectionStartedEvent | ConnectionCompletedEvent | ConnectionErrorEvent;
|
|
551
|
-
/**
|
|
552
|
-
* Connection restoring started event when initiates a connection restoring process.
|
|
553
|
-
*/
|
|
554
|
-
declare type ConnectionRestoringStartedEvent = {
|
|
555
|
-
/**
|
|
556
|
-
* Event type.
|
|
557
|
-
*/
|
|
558
|
-
type: 'connection-restoring-started';
|
|
559
|
-
};
|
|
560
|
-
/**
|
|
561
|
-
* Connection restoring completed event when successfully restored a connection.
|
|
562
|
-
*/
|
|
563
|
-
declare type ConnectionRestoringCompletedEvent = {
|
|
564
|
-
/**
|
|
565
|
-
* Event type.
|
|
566
|
-
*/
|
|
567
|
-
type: 'connection-restoring-completed';
|
|
568
|
-
/**
|
|
569
|
-
* Wallet information.
|
|
570
|
-
*/
|
|
571
|
-
connectionInfo: ConnectionInfo;
|
|
572
|
-
};
|
|
573
|
-
/**
|
|
574
|
-
* Connection restoring error event when there is an error during the connection restoring process.
|
|
575
|
-
*/
|
|
576
|
-
declare type ConnectionRestoringErrorEvent = {
|
|
577
|
-
/**
|
|
578
|
-
* Event type.
|
|
579
|
-
*/
|
|
580
|
-
type: 'connection-restoring-error';
|
|
581
|
-
/**
|
|
582
|
-
* Reason for the error.
|
|
583
|
-
*/
|
|
584
|
-
reason: string;
|
|
585
|
-
};
|
|
586
|
-
/**
|
|
587
|
-
* Connection restoring events.
|
|
588
|
-
*/
|
|
589
|
-
declare type ConnectionRestoringEvent = ConnectionRestoringStartedEvent | ConnectionRestoringCompletedEvent | ConnectionRestoringErrorEvent;
|
|
590
|
-
/**
|
|
591
|
-
* Transaction message.
|
|
592
|
-
*/
|
|
593
|
-
declare type TransactionMessage = {
|
|
594
|
-
/**
|
|
595
|
-
* Recipient address.
|
|
596
|
-
*/
|
|
597
|
-
address: string | null;
|
|
598
|
-
/**
|
|
599
|
-
* Transfer amount.
|
|
600
|
-
*/
|
|
601
|
-
amount: string | null;
|
|
602
|
-
};
|
|
603
|
-
/**
|
|
604
|
-
* Transaction information.
|
|
605
|
-
*/
|
|
606
|
-
declare type TransactionInfo = {
|
|
607
|
-
/**
|
|
608
|
-
* Transaction validity time in unix timestamp.
|
|
609
|
-
*/
|
|
610
|
-
validUntil: number | null;
|
|
611
|
-
/**
|
|
612
|
-
* Sender address.
|
|
613
|
-
*/
|
|
614
|
-
from: string | null;
|
|
615
|
-
/**
|
|
616
|
-
* Transaction messages.
|
|
617
|
-
*/
|
|
618
|
-
messages: TransactionMessage[];
|
|
619
|
-
};
|
|
620
|
-
/**
|
|
621
|
-
* Initial transaction event when a user initiates a transaction.
|
|
622
|
-
*/
|
|
623
|
-
declare type TransactionSentForSignatureEvent = {
|
|
624
|
-
/**
|
|
625
|
-
* Event type.
|
|
626
|
-
*/
|
|
627
|
-
type: 'transaction-sent-for-signature';
|
|
628
|
-
/**
|
|
629
|
-
* Wallet information.
|
|
630
|
-
*/
|
|
631
|
-
connectionInfo: ConnectionInfo;
|
|
632
|
-
/**
|
|
633
|
-
* Transaction information.
|
|
634
|
-
*/
|
|
635
|
-
transactionInfo: TransactionInfo;
|
|
636
|
-
};
|
|
637
|
-
/**
|
|
638
|
-
* Transaction signed event when a user successfully signed a transaction.
|
|
639
|
-
*/
|
|
640
|
-
declare type TransactionSignedEvent = {
|
|
641
|
-
/**
|
|
642
|
-
* Event type.
|
|
643
|
-
*/
|
|
644
|
-
type: 'transaction-signed';
|
|
645
|
-
/**
|
|
646
|
-
* Wallet information.
|
|
647
|
-
*/
|
|
648
|
-
connectionInfo: ConnectionInfo;
|
|
649
|
-
/**
|
|
650
|
-
* Transaction information.
|
|
651
|
-
*/
|
|
652
|
-
transactionInfo: TransactionInfo;
|
|
653
|
-
/**
|
|
654
|
-
* Signed transaction.
|
|
655
|
-
*/
|
|
656
|
-
signedTransaction: string;
|
|
657
|
-
};
|
|
658
|
-
/**
|
|
659
|
-
* Transaction error event when a user cancels a transaction or there is an error during the transaction process.
|
|
660
|
-
*/
|
|
661
|
-
declare type TransactionSigningFailedEvent = {
|
|
662
|
-
/**
|
|
663
|
-
* Event type.
|
|
664
|
-
*/
|
|
665
|
-
type: 'transaction-signing-failed';
|
|
666
|
-
/**
|
|
667
|
-
* Wallet information.
|
|
668
|
-
*/
|
|
669
|
-
connectionInfo: ConnectionInfo;
|
|
670
|
-
/**
|
|
671
|
-
* Transaction information.
|
|
672
|
-
*/
|
|
673
|
-
transactionInfo: TransactionInfo;
|
|
674
|
-
/**
|
|
675
|
-
* Reason for the error.
|
|
676
|
-
*/
|
|
677
|
-
reason: string;
|
|
678
|
-
};
|
|
679
|
-
/**
|
|
680
|
-
* Transaction events.
|
|
681
|
-
*/
|
|
682
|
-
declare type TransactionSigningEvent = TransactionSentForSignatureEvent | TransactionSignedEvent | TransactionSigningFailedEvent;
|
|
683
|
-
/**
|
|
684
|
-
* Disconnect event when a user initiates a disconnection.
|
|
685
|
-
*/
|
|
686
|
-
declare type DisconnectionEvent = {
|
|
687
|
-
/**
|
|
688
|
-
* Event type.
|
|
689
|
-
*/
|
|
690
|
-
type: 'disconnection';
|
|
691
|
-
/**
|
|
692
|
-
* Wallet information.
|
|
693
|
-
*/
|
|
694
|
-
connectionInfo: ConnectionInfo;
|
|
695
|
-
/**
|
|
696
|
-
* Disconnect scope: 'dapp' or 'wallet'.
|
|
697
|
-
*/
|
|
698
|
-
scope: 'dapp' | 'wallet';
|
|
699
|
-
};
|
|
700
|
-
/**
|
|
701
|
-
* User action events.
|
|
702
|
-
*/
|
|
703
|
-
declare type UserActionEvent = ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent;
|
|
704
|
-
|
|
705
493
|
declare type Color = Property.Color;
|
|
706
494
|
|
|
707
495
|
declare class TonConnectUIError extends TonConnectError {
|
|
708
496
|
constructor(...args: ConstructorParameters<typeof Error>);
|
|
709
497
|
}
|
|
710
498
|
|
|
711
|
-
export { ActionConfiguration, BorderRadius, Color, ColorsSet, ConnectedWallet,
|
|
499
|
+
export { ActionConfiguration, BorderRadius, Color, ColorsSet, ConnectedWallet, Loadable, LoadableLoading, LoadableReady, Locales, PartialColorsSet, ReturnStrategy, THEME, Theme, TonConnectUI, TonConnectUIError, TonConnectUiCreateOptions, TonConnectUiCreateOptionsBase, TonConnectUiOptions, TonConnectUiOptionsWithConnector, TonConnectUiOptionsWithManifest, UIPreferences, UIWallet, UserActionEvent, WalletInfoRemoteWithOpenMethod, WalletInfoWithOpenMethod, WalletModalClosed, WalletModalOpened, WalletOpenMethod, WalletsListConfiguration, WalletsModal, WalletsModalCloseReason, WalletsModalState };
|
package/lib/index.mjs
CHANGED
|
@@ -42,7 +42,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
45
|
-
import { TonConnectError, isWalletInfoCurrentlyInjected, toUserFriendlyAddress, CHAIN, TonConnect, isTelegramUrl, encodeTelegramUrlParameters, isWalletInfoRemote, isWalletInfoCurrentlyEmbedded } from "@tonconnect/sdk";
|
|
45
|
+
import { TonConnectError, isWalletInfoCurrentlyInjected, toUserFriendlyAddress, CHAIN, TonConnect, isTelegramUrl, encodeTelegramUrlParameters, isWalletInfoRemote, isWalletInfoCurrentlyEmbedded, BrowserEventDispatcher, createConnectionStartedEvent, createConnectionCompletedEvent, createConnectionErrorEvent, createConnectionRestoringStartedEvent, createConnectionRestoringCompletedEvent, createConnectionRestoringErrorEvent, createDisconnectionEvent, createTransactionSentForSignatureEvent, createTransactionSignedEvent, createTransactionSigningFailedEvent } from "@tonconnect/sdk";
|
|
46
46
|
export * from "@tonconnect/sdk";
|
|
47
47
|
import UAParser from "ua-parser-js";
|
|
48
48
|
import deepmerge from "deepmerge";
|
|
@@ -10031,18 +10031,26 @@ const WalletsModal = () => {
|
|
|
10031
10031
|
return (_a2 = appState.connectRequestParameters) == null ? void 0 : _a2.value;
|
|
10032
10032
|
});
|
|
10033
10033
|
const onClose = (closeReason) => {
|
|
10034
|
-
|
|
10035
|
-
status: "closed",
|
|
10036
|
-
closeReason
|
|
10037
|
-
});
|
|
10038
|
-
setSelectedWalletInfo(null);
|
|
10039
|
-
setInfoTab(false);
|
|
10034
|
+
tonConnectUI.closeModal(closeReason);
|
|
10040
10035
|
};
|
|
10041
10036
|
const unsubscribe = connector.onStatusChange((wallet) => {
|
|
10042
10037
|
if (wallet) {
|
|
10043
10038
|
onClose("wallet-selected");
|
|
10044
10039
|
}
|
|
10045
10040
|
});
|
|
10041
|
+
const onSelectAllWallets = () => {
|
|
10042
|
+
setSelectedTab("all-wallets");
|
|
10043
|
+
};
|
|
10044
|
+
const onSelectUniversal = () => {
|
|
10045
|
+
setSelectedTab("universal");
|
|
10046
|
+
};
|
|
10047
|
+
const clearSelectedWalletInfo = () => {
|
|
10048
|
+
setSelectedWalletInfo(null);
|
|
10049
|
+
};
|
|
10050
|
+
onCleanup(() => {
|
|
10051
|
+
setSelectedWalletInfo(null);
|
|
10052
|
+
setInfoTab(false);
|
|
10053
|
+
});
|
|
10046
10054
|
onCleanup(unsubscribe);
|
|
10047
10055
|
return createComponent(StyledModal, {
|
|
10048
10056
|
get opened() {
|
|
@@ -10107,7 +10115,7 @@ const WalletsModal = () => {
|
|
|
10107
10115
|
get additionalRequest() {
|
|
10108
10116
|
return additionalRequest();
|
|
10109
10117
|
},
|
|
10110
|
-
onBackClick:
|
|
10118
|
+
onBackClick: clearSelectedWalletInfo
|
|
10111
10119
|
});
|
|
10112
10120
|
}
|
|
10113
10121
|
}), createComponent(Match, {
|
|
@@ -10126,7 +10134,7 @@ const WalletsModal = () => {
|
|
|
10126
10134
|
get additionalRequest() {
|
|
10127
10135
|
return additionalRequest();
|
|
10128
10136
|
},
|
|
10129
|
-
onSelectAllWallets
|
|
10137
|
+
onSelectAllWallets
|
|
10130
10138
|
});
|
|
10131
10139
|
}
|
|
10132
10140
|
}), createComponent(Match, {
|
|
@@ -10138,7 +10146,7 @@ const WalletsModal = () => {
|
|
|
10138
10146
|
get walletsList() {
|
|
10139
10147
|
return walletsList();
|
|
10140
10148
|
},
|
|
10141
|
-
onBack:
|
|
10149
|
+
onBack: onSelectUniversal,
|
|
10142
10150
|
onSelect: setSelectedWalletInfo
|
|
10143
10151
|
});
|
|
10144
10152
|
}
|
|
@@ -10393,6 +10401,7 @@ const SingleWalletModal = () => {
|
|
|
10393
10401
|
}
|
|
10394
10402
|
});
|
|
10395
10403
|
const connector = useContext(ConnectorContext);
|
|
10404
|
+
const tonConnectUI = useContext(TonConnectUiContext);
|
|
10396
10405
|
const [infoTab, setInfoTab] = createSignal(false);
|
|
10397
10406
|
const additionalRequestLoading = () => {
|
|
10398
10407
|
var _a2;
|
|
@@ -10406,11 +10415,7 @@ const SingleWalletModal = () => {
|
|
|
10406
10415
|
return (_a2 = appState.connectRequestParameters) == null ? void 0 : _a2.value;
|
|
10407
10416
|
});
|
|
10408
10417
|
const onClose = (closeReason) => {
|
|
10409
|
-
|
|
10410
|
-
status: "closed",
|
|
10411
|
-
closeReason
|
|
10412
|
-
});
|
|
10413
|
-
setInfoTab(false);
|
|
10418
|
+
tonConnectUI.closeSingleWalletModal(closeReason);
|
|
10414
10419
|
};
|
|
10415
10420
|
const unsubscribe = connector.onStatusChange((wallet) => {
|
|
10416
10421
|
if (wallet) {
|
|
@@ -10418,6 +10423,9 @@ const SingleWalletModal = () => {
|
|
|
10418
10423
|
}
|
|
10419
10424
|
});
|
|
10420
10425
|
onCleanup(unsubscribe);
|
|
10426
|
+
onCleanup(() => {
|
|
10427
|
+
setInfoTab(false);
|
|
10428
|
+
});
|
|
10421
10429
|
return createComponent(StyledModal, {
|
|
10422
10430
|
get opened() {
|
|
10423
10431
|
return getSingleWalletModalIsOpened();
|
|
@@ -10567,8 +10575,10 @@ class WalletsModalManager {
|
|
|
10567
10575
|
__publicField(this, "connector");
|
|
10568
10576
|
__publicField(this, "setConnectRequestParametersCallback");
|
|
10569
10577
|
__publicField(this, "consumers", []);
|
|
10578
|
+
__publicField(this, "tracker");
|
|
10570
10579
|
__publicField(this, "state", walletsModalState());
|
|
10571
10580
|
this.connector = options.connector;
|
|
10581
|
+
this.tracker = options.tracker;
|
|
10572
10582
|
this.setConnectRequestParametersCallback = options.setConnectRequestParametersCallback;
|
|
10573
10583
|
createEffect(() => {
|
|
10574
10584
|
const state = walletsModalState();
|
|
@@ -10578,6 +10588,7 @@ class WalletsModalManager {
|
|
|
10578
10588
|
}
|
|
10579
10589
|
open() {
|
|
10580
10590
|
return __async(this, null, function* () {
|
|
10591
|
+
this.tracker.trackConnectionStarted();
|
|
10581
10592
|
const walletsList = yield this.connector.getWallets();
|
|
10582
10593
|
const embeddedWallet = walletsList.find(isWalletInfoCurrentlyEmbedded);
|
|
10583
10594
|
if (embeddedWallet) {
|
|
@@ -10587,8 +10598,11 @@ class WalletsModalManager {
|
|
|
10587
10598
|
}
|
|
10588
10599
|
});
|
|
10589
10600
|
}
|
|
10590
|
-
close() {
|
|
10591
|
-
|
|
10601
|
+
close(reason = "action-cancelled") {
|
|
10602
|
+
if (reason === "action-cancelled") {
|
|
10603
|
+
this.tracker.trackConnectionError("Connection was cancelled");
|
|
10604
|
+
}
|
|
10605
|
+
widgetController.closeWalletsModal(reason);
|
|
10592
10606
|
}
|
|
10593
10607
|
onStateChange(onChange) {
|
|
10594
10608
|
this.consumers.push(onChange);
|
|
@@ -10648,8 +10662,10 @@ class SingleWalletModalManager {
|
|
|
10648
10662
|
__publicField(this, "connector");
|
|
10649
10663
|
__publicField(this, "setConnectRequestParametersCallback");
|
|
10650
10664
|
__publicField(this, "consumers", []);
|
|
10665
|
+
__publicField(this, "tracker");
|
|
10651
10666
|
__publicField(this, "state", singleWalletModalState());
|
|
10652
10667
|
this.connector = options.connector;
|
|
10668
|
+
this.tracker = options.tracker;
|
|
10653
10669
|
this.setConnectRequestParametersCallback = options.setConnectRequestParametersCallback;
|
|
10654
10670
|
createEffect(() => {
|
|
10655
10671
|
const state = singleWalletModalState();
|
|
@@ -10659,6 +10675,7 @@ class SingleWalletModalManager {
|
|
|
10659
10675
|
}
|
|
10660
10676
|
open(wallet) {
|
|
10661
10677
|
return __async(this, null, function* () {
|
|
10678
|
+
this.tracker.trackConnectionStarted();
|
|
10662
10679
|
const fetchedWalletsList = yield this.connector.getWallets();
|
|
10663
10680
|
const walletsList = applyWalletsListConfiguration(
|
|
10664
10681
|
fetchedWalletsList,
|
|
@@ -10675,10 +10692,15 @@ class SingleWalletModalManager {
|
|
|
10675
10692
|
if (isExternalWalletExist) {
|
|
10676
10693
|
return this.openSingleWalletModal(externalWallet);
|
|
10677
10694
|
}
|
|
10678
|
-
|
|
10695
|
+
const error = `Trying to open modal window with unknown wallet "${wallet}".`;
|
|
10696
|
+
this.tracker.trackConnectionError(error);
|
|
10697
|
+
throw new TonConnectUIError(error);
|
|
10679
10698
|
});
|
|
10680
10699
|
}
|
|
10681
|
-
close() {
|
|
10700
|
+
close(reason = "action-cancelled") {
|
|
10701
|
+
if (reason === "action-cancelled") {
|
|
10702
|
+
this.tracker.trackConnectionError("Connection was cancelled");
|
|
10703
|
+
}
|
|
10682
10704
|
widgetController.closeSingleWalletModal("action-cancelled");
|
|
10683
10705
|
}
|
|
10684
10706
|
onStateChange(onChange) {
|
|
@@ -10717,112 +10739,17 @@ class SingleWalletModalManager {
|
|
|
10717
10739
|
});
|
|
10718
10740
|
}
|
|
10719
10741
|
}
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
let authType = null;
|
|
10723
|
-
if ((_a2 = wallet == null ? void 0 : wallet.connectItems) == null ? void 0 : _a2.tonProof) {
|
|
10724
|
-
authType = "proof" in wallet.connectItems.tonProof ? "ton_proof" : null;
|
|
10725
|
-
} else if (wallet == null ? void 0 : wallet.connectItems) {
|
|
10726
|
-
authType = "ton_addr";
|
|
10727
|
-
}
|
|
10728
|
-
return {
|
|
10729
|
-
address: (_c2 = (_b2 = wallet == null ? void 0 : wallet.account) == null ? void 0 : _b2.address) != null ? _c2 : null,
|
|
10730
|
-
chainId: (_e2 = (_d2 = wallet == null ? void 0 : wallet.account) == null ? void 0 : _d2.chain) != null ? _e2 : null,
|
|
10731
|
-
provider: (_f2 = wallet == null ? void 0 : wallet.provider) != null ? _f2 : null,
|
|
10732
|
-
walletType: (_g2 = wallet == null ? void 0 : wallet.device.appName) != null ? _g2 : null,
|
|
10733
|
-
walletVersion: (_h2 = wallet == null ? void 0 : wallet.device.appVersion) != null ? _h2 : null,
|
|
10734
|
-
authType
|
|
10735
|
-
};
|
|
10736
|
-
}
|
|
10737
|
-
function createConnectionStartedEvent() {
|
|
10738
|
-
return {
|
|
10739
|
-
type: "connection-started"
|
|
10740
|
-
};
|
|
10741
|
-
}
|
|
10742
|
-
function createConnectionCompletedEvent(wallet) {
|
|
10743
|
-
return {
|
|
10744
|
-
type: "connection-completed",
|
|
10745
|
-
connectionInfo: createConnnectionInfo(wallet)
|
|
10746
|
-
};
|
|
10747
|
-
}
|
|
10748
|
-
function createConnectionErrorEvent(reason) {
|
|
10749
|
-
return {
|
|
10750
|
-
type: "connection-error",
|
|
10751
|
-
reason
|
|
10752
|
-
};
|
|
10753
|
-
}
|
|
10754
|
-
function createConnectionRestoringStartedEvent() {
|
|
10755
|
-
return {
|
|
10756
|
-
type: "connection-restoring-started"
|
|
10757
|
-
};
|
|
10758
|
-
}
|
|
10759
|
-
function createConnectionRestoringCompletedEvent(wallet) {
|
|
10760
|
-
return {
|
|
10761
|
-
type: "connection-restoring-completed",
|
|
10762
|
-
connectionInfo: createConnnectionInfo(wallet)
|
|
10763
|
-
};
|
|
10764
|
-
}
|
|
10765
|
-
function createConnectionRestoringErrorEvent(reason) {
|
|
10766
|
-
return {
|
|
10767
|
-
type: "connection-restoring-error",
|
|
10768
|
-
reason
|
|
10769
|
-
};
|
|
10770
|
-
}
|
|
10771
|
-
function createTransactionInfo(transaction) {
|
|
10772
|
-
var _a2, _b2;
|
|
10773
|
-
return {
|
|
10774
|
-
validUntil: (_a2 = transaction.validUntil) != null ? _a2 : null,
|
|
10775
|
-
from: (_b2 = transaction.from) != null ? _b2 : null,
|
|
10776
|
-
messages: transaction.messages.map((message) => {
|
|
10777
|
-
var _a3, _b3;
|
|
10778
|
-
return {
|
|
10779
|
-
address: (_a3 = message.address) != null ? _a3 : null,
|
|
10780
|
-
amount: (_b3 = message.amount) != null ? _b3 : null
|
|
10781
|
-
};
|
|
10782
|
-
})
|
|
10783
|
-
};
|
|
10784
|
-
}
|
|
10785
|
-
function createTransactionSentForSignatureEvent(wallet, transaction) {
|
|
10786
|
-
return {
|
|
10787
|
-
type: "transaction-sent-for-signature",
|
|
10788
|
-
connectionInfo: createConnnectionInfo(wallet),
|
|
10789
|
-
transactionInfo: createTransactionInfo(transaction)
|
|
10790
|
-
};
|
|
10791
|
-
}
|
|
10792
|
-
function createTransactionSignedEvent(wallet, transaction, signedTransaction) {
|
|
10793
|
-
return {
|
|
10794
|
-
type: "transaction-signed",
|
|
10795
|
-
connectionInfo: createConnnectionInfo(wallet),
|
|
10796
|
-
transactionInfo: createTransactionInfo(transaction),
|
|
10797
|
-
signedTransaction: signedTransaction.boc
|
|
10798
|
-
};
|
|
10799
|
-
}
|
|
10800
|
-
function createTransactionSigningFailedEvent(wallet, transaction, reason) {
|
|
10801
|
-
return {
|
|
10802
|
-
type: "transaction-signing-failed",
|
|
10803
|
-
connectionInfo: createConnnectionInfo(wallet),
|
|
10804
|
-
transactionInfo: createTransactionInfo(transaction),
|
|
10805
|
-
reason
|
|
10806
|
-
};
|
|
10807
|
-
}
|
|
10808
|
-
function createDisconnectionEvent(wallet, scope) {
|
|
10809
|
-
return {
|
|
10810
|
-
type: "disconnection",
|
|
10811
|
-
connectionInfo: createConnnectionInfo(wallet),
|
|
10812
|
-
scope
|
|
10813
|
-
};
|
|
10814
|
-
}
|
|
10815
|
-
class TonConnectTracker {
|
|
10816
|
-
constructor() {
|
|
10742
|
+
class TonConnectUITracker {
|
|
10743
|
+
constructor(eventDispatcher) {
|
|
10817
10744
|
__publicField(this, "eventPrefix", "ton-connect-ui-");
|
|
10818
|
-
__publicField(this, "
|
|
10745
|
+
__publicField(this, "eventDispatcher");
|
|
10746
|
+
this.eventDispatcher = eventDispatcher != null ? eventDispatcher : new BrowserEventDispatcher();
|
|
10819
10747
|
}
|
|
10820
10748
|
dispatchUserActionEvent(eventDetails) {
|
|
10821
10749
|
var _a2;
|
|
10822
10750
|
try {
|
|
10823
10751
|
const eventName = `${this.eventPrefix}${eventDetails.type}`;
|
|
10824
|
-
|
|
10825
|
-
(_a2 = this.window) == null ? void 0 : _a2.dispatchEvent(event);
|
|
10752
|
+
(_a2 = this.eventDispatcher) == null ? void 0 : _a2.dispatchEvent(eventName, eventDetails).catch();
|
|
10826
10753
|
} catch (e2) {
|
|
10827
10754
|
}
|
|
10828
10755
|
}
|
|
@@ -10901,7 +10828,7 @@ class TonConnectUI {
|
|
|
10901
10828
|
constructor(options) {
|
|
10902
10829
|
__publicField(this, "walletInfoStorage", new WalletInfoStorage());
|
|
10903
10830
|
__publicField(this, "preferredWalletStorage", new PreferredWalletStorage());
|
|
10904
|
-
__publicField(this, "tracker"
|
|
10831
|
+
__publicField(this, "tracker");
|
|
10905
10832
|
__publicField(this, "walletInfo", null);
|
|
10906
10833
|
__publicField(this, "systemThemeChangeUnsubscribe", null);
|
|
10907
10834
|
__publicField(this, "actionsConfiguration");
|
|
@@ -10915,20 +10842,26 @@ class TonConnectUI {
|
|
|
10915
10842
|
if (options && "connector" in options && options.connector) {
|
|
10916
10843
|
this.connector = options.connector;
|
|
10917
10844
|
} else if (options && "manifestUrl" in options && options.manifestUrl) {
|
|
10918
|
-
this.connector = new TonConnect({
|
|
10845
|
+
this.connector = new TonConnect({
|
|
10846
|
+
manifestUrl: options.manifestUrl,
|
|
10847
|
+
eventDispatcher: options == null ? void 0 : options.eventDispatcher
|
|
10848
|
+
});
|
|
10919
10849
|
} else {
|
|
10920
10850
|
throw new TonConnectUIError(
|
|
10921
10851
|
"You have to specify a `manifestUrl` or a `connector` in the options."
|
|
10922
10852
|
);
|
|
10923
10853
|
}
|
|
10854
|
+
this.tracker = new TonConnectUITracker(options == null ? void 0 : options.eventDispatcher);
|
|
10924
10855
|
this.modal = new WalletsModalManager({
|
|
10925
10856
|
connector: this.connector,
|
|
10857
|
+
tracker: this.tracker,
|
|
10926
10858
|
setConnectRequestParametersCallback: (callback) => {
|
|
10927
10859
|
this.connectRequestParametersCallback = callback;
|
|
10928
10860
|
}
|
|
10929
10861
|
});
|
|
10930
10862
|
this.singleWalletModal = new SingleWalletModalManager({
|
|
10931
10863
|
connector: this.connector,
|
|
10864
|
+
tracker: this.tracker,
|
|
10932
10865
|
setConnectRequestParametersCallback: (callback) => {
|
|
10933
10866
|
this.connectRequestParametersCallback = callback;
|
|
10934
10867
|
}
|
|
@@ -11043,13 +10976,11 @@ class TonConnectUI {
|
|
|
11043
10976
|
}
|
|
11044
10977
|
openModal() {
|
|
11045
10978
|
return __async(this, null, function* () {
|
|
11046
|
-
this.tracker.trackConnectionStarted();
|
|
11047
10979
|
return this.modal.open();
|
|
11048
10980
|
});
|
|
11049
10981
|
}
|
|
11050
|
-
closeModal() {
|
|
11051
|
-
this.
|
|
11052
|
-
this.modal.close();
|
|
10982
|
+
closeModal(reason) {
|
|
10983
|
+
this.modal.close(reason);
|
|
11053
10984
|
}
|
|
11054
10985
|
onModalStateChange(onChange) {
|
|
11055
10986
|
return this.modal.onStateChange(onChange);
|
|
@@ -11059,13 +10990,11 @@ class TonConnectUI {
|
|
|
11059
10990
|
}
|
|
11060
10991
|
openSingleWalletModal(wallet) {
|
|
11061
10992
|
return __async(this, null, function* () {
|
|
11062
|
-
this.tracker.trackConnectionStarted();
|
|
11063
10993
|
return this.singleWalletModal.open(wallet);
|
|
11064
10994
|
});
|
|
11065
10995
|
}
|
|
11066
|
-
closeSingleWalletModal() {
|
|
11067
|
-
this.
|
|
11068
|
-
this.singleWalletModal.close();
|
|
10996
|
+
closeSingleWalletModal(closeReason) {
|
|
10997
|
+
this.singleWalletModal.close(closeReason);
|
|
11069
10998
|
}
|
|
11070
10999
|
onSingleWalletModalStateChange(onChange) {
|
|
11071
11000
|
return this.singleWalletModal.onStateChange(onChange);
|