@tonconnect/ui 2.0.3-beta.2 → 2.0.3-beta.4
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/dist/tonconnect-ui.min.js +209 -209
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.cjs +120 -33
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.mjs +121 -34
- package/lib/index.mjs.map +1 -1
- package/package.json +16 -15
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletInfoBase, WalletInfoInjectable, WalletInfoRemote, ConnectionEvent, ConnectionRestoringEvent, DisconnectionEvent, TransactionSigningEvent, ITonConnect, EventDispatcher, SdkActionEvent, Wallet, WalletInfo, Account, ConnectAdditionalRequest, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk';
|
|
1
|
+
import { WalletInfoBase, WalletInfoInjectable, WalletInfoRemote, VersionEvent, 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
4
|
|
|
@@ -171,7 +171,7 @@ interface TonConnectUiOptions {
|
|
|
171
171
|
/**
|
|
172
172
|
* User action events.
|
|
173
173
|
*/
|
|
174
|
-
declare type UserActionEvent = ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent;
|
|
174
|
+
declare type UserActionEvent = VersionEvent | ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent;
|
|
175
175
|
|
|
176
176
|
declare type TonConnectUiCreateOptions = TonConnectUiOptionsWithConnector | TonConnectUiOptionsWithManifest;
|
|
177
177
|
interface TonConnectUiOptionsWithManifest extends TonConnectUiCreateOptionsBase {
|
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, BrowserEventDispatcher, createConnectionStartedEvent, createConnectionCompletedEvent, createConnectionErrorEvent, createConnectionRestoringStartedEvent, createConnectionRestoringCompletedEvent, createConnectionRestoringErrorEvent, createDisconnectionEvent, createTransactionSentForSignatureEvent, createTransactionSignedEvent, createTransactionSigningFailedEvent } from "@tonconnect/sdk";
|
|
45
|
+
import { TonConnectError, isWalletInfoCurrentlyInjected, toUserFriendlyAddress, CHAIN, TonConnect, isTelegramUrl, encodeTelegramUrlParameters, isWalletInfoRemote, isWalletInfoCurrentlyEmbedded, createVersionInfo, BrowserEventDispatcher, createResponseVersionEvent, createRequestVersionEvent, 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";
|
|
@@ -1829,6 +1829,12 @@ function createMacrotask(callback) {
|
|
|
1829
1829
|
callback();
|
|
1830
1830
|
});
|
|
1831
1831
|
}
|
|
1832
|
+
function createMacrotaskAsync(callback) {
|
|
1833
|
+
return __async(this, null, function* () {
|
|
1834
|
+
yield new Promise((resolve) => requestAnimationFrame(resolve));
|
|
1835
|
+
return callback();
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1832
1838
|
function preloadImages(images) {
|
|
1833
1839
|
if (document.readyState !== "complete") {
|
|
1834
1840
|
window.addEventListener("load", () => createMacrotask(() => preloadImages(images)), {
|
|
@@ -7159,7 +7165,7 @@ const computePosition$1 = (reference, floating, config) => __async(void 0, null,
|
|
|
7159
7165
|
} = config;
|
|
7160
7166
|
const validMiddleware = middleware.filter(Boolean);
|
|
7161
7167
|
const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(floating);
|
|
7162
|
-
if (
|
|
7168
|
+
if (process.env.NODE_ENV !== "production") {
|
|
7163
7169
|
if (platform2 == null) {
|
|
7164
7170
|
console.error(["Floating UI: `platform` property was not passed to config. If you", "want to use Floating UI on the web, install @floating-ui/dom", "instead of the /core package. Otherwise, you can create your own", "`platform`: https://floating-ui.com/docs/platform"].join(" "));
|
|
7165
7171
|
}
|
|
@@ -7216,7 +7222,7 @@ const computePosition$1 = (reference, floating, config) => __async(void 0, null,
|
|
|
7216
7222
|
middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
|
|
7217
7223
|
[name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
|
|
7218
7224
|
});
|
|
7219
|
-
if (
|
|
7225
|
+
if (process.env.NODE_ENV !== "production") {
|
|
7220
7226
|
if (resetCount > 50) {
|
|
7221
7227
|
console.warn(["Floating UI: The middleware lifecycle appears to be running in an", "infinite loop. This is usually caused by a `reset` continually", "being returned without a break condition."].join(" "));
|
|
7222
7228
|
}
|
|
@@ -8643,10 +8649,14 @@ const DesktopConnectionModal = (props) => {
|
|
|
8643
8649
|
});
|
|
8644
8650
|
onCleanup(unsubscribe);
|
|
8645
8651
|
const generateUniversalLink = () => {
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8652
|
+
try {
|
|
8653
|
+
const universalLink2 = connector.connect({
|
|
8654
|
+
universalLink: props.wallet.universalLink,
|
|
8655
|
+
bridgeUrl: props.wallet.bridgeUrl
|
|
8656
|
+
}, props.additionalRequest);
|
|
8657
|
+
setUniversalLink(universalLink2);
|
|
8658
|
+
} catch (e2) {
|
|
8659
|
+
}
|
|
8650
8660
|
};
|
|
8651
8661
|
createEffect(() => {
|
|
8652
8662
|
if (untrack(mode) !== "extension" && (supportsMobile(props.wallet) || supportsDesktop(props.wallet))) {
|
|
@@ -9626,6 +9636,17 @@ const MobileUniversalQR = (props) => {
|
|
|
9626
9636
|
}
|
|
9627
9637
|
})];
|
|
9628
9638
|
};
|
|
9639
|
+
function getUniqueBridges(walletsList) {
|
|
9640
|
+
const uniqueBridges = new Set(
|
|
9641
|
+
walletsList.filter(isWalletInfoRemote).map((item) => item.bridgeUrl)
|
|
9642
|
+
);
|
|
9643
|
+
return Array.from(uniqueBridges).map((bridgeUrl) => ({ bridgeUrl }));
|
|
9644
|
+
}
|
|
9645
|
+
function bridgesIsEqual(left, right) {
|
|
9646
|
+
const leftSet = new Set(left == null ? void 0 : left.map((i2) => i2.bridgeUrl));
|
|
9647
|
+
const rightSet = new Set(right == null ? void 0 : right.map((i2) => i2.bridgeUrl));
|
|
9648
|
+
return leftSet.size === rightSet.size && [...leftSet].every((value) => rightSet.has(value));
|
|
9649
|
+
}
|
|
9629
9650
|
const _tmpl$$1 = /* @__PURE__ */ template$1(`<li></li>`), _tmpl$2 = /* @__PURE__ */ template$1(`<div data-tc-wallets-modal-universal-mobile="true"></div>`);
|
|
9630
9651
|
const MobileUniversalModal = (props) => {
|
|
9631
9652
|
const [showQR, setShowQR] = createSignal(false);
|
|
@@ -9633,10 +9654,10 @@ const MobileUniversalModal = (props) => {
|
|
|
9633
9654
|
const connector = appState.connector;
|
|
9634
9655
|
const walletsList = () => props.walletsList.filter((w) => supportsMobile(w) && w.appName !== AT_WALLET_APP_NAME);
|
|
9635
9656
|
const shouldShowMoreButton = () => walletsList().length > 7;
|
|
9636
|
-
const walletsBridges = () =>
|
|
9637
|
-
|
|
9638
|
-
})
|
|
9639
|
-
const getUniversalLink = () => connector.connect(walletsBridges(), props.additionalRequest);
|
|
9657
|
+
const walletsBridges = createMemo(() => getUniqueBridges(props.walletsList), null, {
|
|
9658
|
+
equals: bridgesIsEqual
|
|
9659
|
+
});
|
|
9660
|
+
const getUniversalLink = createMemo(() => connector.connect(walletsBridges(), props.additionalRequest));
|
|
9640
9661
|
setLastSelectedWalletInfo({
|
|
9641
9662
|
openMethod: "universal-link"
|
|
9642
9663
|
});
|
|
@@ -9924,9 +9945,9 @@ const _tmpl$ = /* @__PURE__ */ template$1(`<li></li>`);
|
|
|
9924
9945
|
const DesktopUniversalModal = (props) => {
|
|
9925
9946
|
const [popupOpened, setPopupOpened] = createSignal(false);
|
|
9926
9947
|
const connector = appState.connector;
|
|
9927
|
-
const walletsBridges = () =>
|
|
9928
|
-
|
|
9929
|
-
})
|
|
9948
|
+
const walletsBridges = createMemo(() => getUniqueBridges(props.walletsList), null, {
|
|
9949
|
+
equals: bridgesIsEqual
|
|
9950
|
+
});
|
|
9930
9951
|
setLastSelectedWalletInfo({
|
|
9931
9952
|
openMethod: "qrcode"
|
|
9932
9953
|
});
|
|
@@ -9989,6 +10010,10 @@ const WalletsModal = () => {
|
|
|
9989
10010
|
createEffect(() => {
|
|
9990
10011
|
if (getWalletsModalIsOpened()) {
|
|
9991
10012
|
updateIsMobile();
|
|
10013
|
+
} else {
|
|
10014
|
+
setSelectedWalletInfo(null);
|
|
10015
|
+
setSelectedTab("universal");
|
|
10016
|
+
setInfoTab(false);
|
|
9992
10017
|
}
|
|
9993
10018
|
});
|
|
9994
10019
|
const connector = useContext(ConnectorContext);
|
|
@@ -10740,90 +10765,141 @@ class SingleWalletModalManager {
|
|
|
10740
10765
|
}
|
|
10741
10766
|
}
|
|
10742
10767
|
class TonConnectUITracker {
|
|
10743
|
-
constructor(
|
|
10768
|
+
constructor(options) {
|
|
10744
10769
|
__publicField(this, "eventPrefix", "ton-connect-ui-");
|
|
10770
|
+
__publicField(this, "tonConnectUiVersion");
|
|
10771
|
+
__publicField(this, "tonConnectSdkVersion", null);
|
|
10745
10772
|
__publicField(this, "eventDispatcher");
|
|
10746
|
-
|
|
10773
|
+
var _a2;
|
|
10774
|
+
this.eventDispatcher = (_a2 = options == null ? void 0 : options.eventDispatcher) != null ? _a2 : new BrowserEventDispatcher();
|
|
10775
|
+
this.tonConnectUiVersion = options.tonConnectUiVersion;
|
|
10776
|
+
this.init().catch();
|
|
10777
|
+
}
|
|
10778
|
+
get version() {
|
|
10779
|
+
return createVersionInfo({
|
|
10780
|
+
ton_connect_sdk_lib: this.tonConnectSdkVersion,
|
|
10781
|
+
ton_connect_ui_lib: this.tonConnectUiVersion
|
|
10782
|
+
});
|
|
10783
|
+
}
|
|
10784
|
+
init() {
|
|
10785
|
+
return __async(this, null, function* () {
|
|
10786
|
+
try {
|
|
10787
|
+
yield this.setRequestVersionHandler();
|
|
10788
|
+
this.tonConnectSdkVersion = yield this.requestTonConnectSdkVersion();
|
|
10789
|
+
} catch (e2) {
|
|
10790
|
+
}
|
|
10791
|
+
});
|
|
10792
|
+
}
|
|
10793
|
+
setRequestVersionHandler() {
|
|
10794
|
+
return __async(this, null, function* () {
|
|
10795
|
+
yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version", () => __async(this, null, function* () {
|
|
10796
|
+
yield this.eventDispatcher.dispatchEvent(
|
|
10797
|
+
"ton-connect-ui-response-version",
|
|
10798
|
+
createResponseVersionEvent(this.tonConnectUiVersion)
|
|
10799
|
+
);
|
|
10800
|
+
}));
|
|
10801
|
+
});
|
|
10802
|
+
}
|
|
10803
|
+
requestTonConnectSdkVersion() {
|
|
10804
|
+
return __async(this, null, function* () {
|
|
10805
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
10806
|
+
try {
|
|
10807
|
+
yield this.eventDispatcher.addEventListener(
|
|
10808
|
+
"ton-connect-response-version",
|
|
10809
|
+
(event) => {
|
|
10810
|
+
resolve(event.detail.version);
|
|
10811
|
+
},
|
|
10812
|
+
{ once: true }
|
|
10813
|
+
);
|
|
10814
|
+
yield this.eventDispatcher.dispatchEvent(
|
|
10815
|
+
"ton-connect-request-version",
|
|
10816
|
+
createRequestVersionEvent()
|
|
10817
|
+
);
|
|
10818
|
+
} catch (e2) {
|
|
10819
|
+
reject(e2);
|
|
10820
|
+
}
|
|
10821
|
+
}));
|
|
10822
|
+
});
|
|
10747
10823
|
}
|
|
10748
10824
|
dispatchUserActionEvent(eventDetails) {
|
|
10749
10825
|
var _a2;
|
|
10750
10826
|
try {
|
|
10751
|
-
|
|
10752
|
-
(_a2 = this.eventDispatcher) == null ? void 0 : _a2.dispatchEvent(eventName, eventDetails).catch();
|
|
10827
|
+
(_a2 = this.eventDispatcher) == null ? void 0 : _a2.dispatchEvent(`${this.eventPrefix}${eventDetails.type}`, eventDetails).catch();
|
|
10753
10828
|
} catch (e2) {
|
|
10754
10829
|
}
|
|
10755
10830
|
}
|
|
10756
10831
|
trackConnectionStarted(...args) {
|
|
10757
10832
|
try {
|
|
10758
|
-
const event = createConnectionStartedEvent(...args);
|
|
10833
|
+
const event = createConnectionStartedEvent(this.version, ...args);
|
|
10759
10834
|
this.dispatchUserActionEvent(event);
|
|
10760
10835
|
} catch (e2) {
|
|
10761
10836
|
}
|
|
10762
10837
|
}
|
|
10763
10838
|
trackConnectionCompleted(...args) {
|
|
10764
10839
|
try {
|
|
10765
|
-
const event = createConnectionCompletedEvent(...args);
|
|
10840
|
+
const event = createConnectionCompletedEvent(this.version, ...args);
|
|
10766
10841
|
this.dispatchUserActionEvent(event);
|
|
10767
10842
|
} catch (e2) {
|
|
10768
10843
|
}
|
|
10769
10844
|
}
|
|
10770
10845
|
trackConnectionError(...args) {
|
|
10771
10846
|
try {
|
|
10772
|
-
const event = createConnectionErrorEvent(...args);
|
|
10847
|
+
const event = createConnectionErrorEvent(this.version, ...args);
|
|
10773
10848
|
this.dispatchUserActionEvent(event);
|
|
10774
10849
|
} catch (e2) {
|
|
10775
10850
|
}
|
|
10776
10851
|
}
|
|
10777
10852
|
trackConnectionRestoringStarted(...args) {
|
|
10778
10853
|
try {
|
|
10779
|
-
const event = createConnectionRestoringStartedEvent(...args);
|
|
10854
|
+
const event = createConnectionRestoringStartedEvent(this.version, ...args);
|
|
10780
10855
|
this.dispatchUserActionEvent(event);
|
|
10781
10856
|
} catch (e2) {
|
|
10782
10857
|
}
|
|
10783
10858
|
}
|
|
10784
10859
|
trackConnectionRestoringCompleted(...args) {
|
|
10785
10860
|
try {
|
|
10786
|
-
const event = createConnectionRestoringCompletedEvent(...args);
|
|
10861
|
+
const event = createConnectionRestoringCompletedEvent(this.version, ...args);
|
|
10787
10862
|
this.dispatchUserActionEvent(event);
|
|
10788
10863
|
} catch (e2) {
|
|
10789
10864
|
}
|
|
10790
10865
|
}
|
|
10791
10866
|
trackConnectionRestoringError(...args) {
|
|
10792
10867
|
try {
|
|
10793
|
-
const event = createConnectionRestoringErrorEvent(...args);
|
|
10868
|
+
const event = createConnectionRestoringErrorEvent(this.version, ...args);
|
|
10794
10869
|
this.dispatchUserActionEvent(event);
|
|
10795
10870
|
} catch (e2) {
|
|
10796
10871
|
}
|
|
10797
10872
|
}
|
|
10798
10873
|
trackDisconnection(...args) {
|
|
10799
10874
|
try {
|
|
10800
|
-
const event = createDisconnectionEvent(...args);
|
|
10875
|
+
const event = createDisconnectionEvent(this.version, ...args);
|
|
10801
10876
|
this.dispatchUserActionEvent(event);
|
|
10802
10877
|
} catch (e2) {
|
|
10803
10878
|
}
|
|
10804
10879
|
}
|
|
10805
10880
|
trackTransactionSentForSignature(...args) {
|
|
10806
10881
|
try {
|
|
10807
|
-
const event = createTransactionSentForSignatureEvent(...args);
|
|
10882
|
+
const event = createTransactionSentForSignatureEvent(this.version, ...args);
|
|
10808
10883
|
this.dispatchUserActionEvent(event);
|
|
10809
10884
|
} catch (e2) {
|
|
10810
10885
|
}
|
|
10811
10886
|
}
|
|
10812
10887
|
trackTransactionSigned(...args) {
|
|
10813
10888
|
try {
|
|
10814
|
-
const event = createTransactionSignedEvent(...args);
|
|
10889
|
+
const event = createTransactionSignedEvent(this.version, ...args);
|
|
10815
10890
|
this.dispatchUserActionEvent(event);
|
|
10816
10891
|
} catch (e2) {
|
|
10817
10892
|
}
|
|
10818
10893
|
}
|
|
10819
10894
|
trackTransactionSigningFailed(...args) {
|
|
10820
10895
|
try {
|
|
10821
|
-
const event = createTransactionSigningFailedEvent(...args);
|
|
10896
|
+
const event = createTransactionSigningFailedEvent(this.version, ...args);
|
|
10822
10897
|
this.dispatchUserActionEvent(event);
|
|
10823
10898
|
} catch (e2) {
|
|
10824
10899
|
}
|
|
10825
10900
|
}
|
|
10826
10901
|
}
|
|
10902
|
+
const tonConnectUiVersion = "2.0.3-beta.4";
|
|
10827
10903
|
class TonConnectUI {
|
|
10828
10904
|
constructor(options) {
|
|
10829
10905
|
__publicField(this, "walletInfoStorage", new WalletInfoStorage());
|
|
@@ -10851,7 +10927,10 @@ class TonConnectUI {
|
|
|
10851
10927
|
"You have to specify a `manifestUrl` or a `connector` in the options."
|
|
10852
10928
|
);
|
|
10853
10929
|
}
|
|
10854
|
-
this.tracker = new TonConnectUITracker(
|
|
10930
|
+
this.tracker = new TonConnectUITracker({
|
|
10931
|
+
eventDispatcher: options == null ? void 0 : options.eventDispatcher,
|
|
10932
|
+
tonConnectUiVersion
|
|
10933
|
+
});
|
|
10855
10934
|
this.modal = new WalletsModalManager({
|
|
10856
10935
|
connector: this.connector,
|
|
10857
10936
|
tracker: this.tracker,
|
|
@@ -10874,8 +10953,8 @@ class TonConnectUI {
|
|
|
10874
10953
|
const rootId = this.normalizeWidgetRoot(options == null ? void 0 : options.widgetRootId);
|
|
10875
10954
|
this.subscribeToWalletChange();
|
|
10876
10955
|
if ((options == null ? void 0 : options.restoreConnection) !== false) {
|
|
10877
|
-
this.
|
|
10878
|
-
|
|
10956
|
+
this.connectionRestored = createMacrotaskAsync(() => __async(this, null, function* () {
|
|
10957
|
+
this.tracker.trackConnectionRestoringStarted();
|
|
10879
10958
|
yield this.connector.restoreConnection();
|
|
10880
10959
|
if (!this.connector.connected) {
|
|
10881
10960
|
this.tracker.trackConnectionRestoringError("Connection was not restored");
|
|
@@ -10883,7 +10962,7 @@ class TonConnectUI {
|
|
|
10883
10962
|
} else {
|
|
10884
10963
|
this.tracker.trackConnectionRestoringCompleted(this.wallet);
|
|
10885
10964
|
}
|
|
10886
|
-
|
|
10965
|
+
return this.connector.connected;
|
|
10887
10966
|
}));
|
|
10888
10967
|
}
|
|
10889
10968
|
this.uiOptions = mergeOptions(options, { uiPreferences: { theme: "SYSTEM" } });
|
|
@@ -11200,7 +11279,11 @@ class TonConnectUI {
|
|
|
11200
11279
|
return new Promise((resolve, reject) => {
|
|
11201
11280
|
const { transaction, signal } = options;
|
|
11202
11281
|
if (signal.aborted) {
|
|
11203
|
-
this.tracker.trackTransactionSigningFailed(
|
|
11282
|
+
this.tracker.trackTransactionSigningFailed(
|
|
11283
|
+
this.wallet,
|
|
11284
|
+
transaction,
|
|
11285
|
+
"Transaction was cancelled"
|
|
11286
|
+
);
|
|
11204
11287
|
return reject(new TonConnectUIError("Transaction was not sent"));
|
|
11205
11288
|
}
|
|
11206
11289
|
const onTransactionHandler = (transaction2) => __async(this, null, function* () {
|
|
@@ -11210,7 +11293,11 @@ class TonConnectUI {
|
|
|
11210
11293
|
reject(reason);
|
|
11211
11294
|
};
|
|
11212
11295
|
const onCanceledHandler = () => {
|
|
11213
|
-
this.tracker.trackTransactionSigningFailed(
|
|
11296
|
+
this.tracker.trackTransactionSigningFailed(
|
|
11297
|
+
this.wallet,
|
|
11298
|
+
transaction,
|
|
11299
|
+
"Transaction was cancelled"
|
|
11300
|
+
);
|
|
11214
11301
|
reject(new TonConnectUIError("Transaction was not sent"));
|
|
11215
11302
|
};
|
|
11216
11303
|
signal.addEventListener("abort", onCanceledHandler, { once: true });
|