@tonconnect/ui 2.0.3-beta.1 → 2.0.3-beta.3
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 +130 -40
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.mjs +131 -41
- package/lib/index.mjs.map +1 -1
- package/package.json +16 -15
package/lib/index.cjs
CHANGED
|
@@ -1834,6 +1834,12 @@ function createMacrotask(callback) {
|
|
|
1834
1834
|
callback();
|
|
1835
1835
|
});
|
|
1836
1836
|
}
|
|
1837
|
+
function createMacrotaskAsync(callback) {
|
|
1838
|
+
return __async(this, null, function* () {
|
|
1839
|
+
yield new Promise((resolve) => requestAnimationFrame(resolve));
|
|
1840
|
+
return callback();
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1837
1843
|
function preloadImages(images) {
|
|
1838
1844
|
if (document.readyState !== "complete") {
|
|
1839
1845
|
window.addEventListener("load", () => createMacrotask(() => preloadImages(images)), {
|
|
@@ -7164,7 +7170,7 @@ const computePosition$1 = (reference, floating, config) => __async(exports, null
|
|
|
7164
7170
|
} = config;
|
|
7165
7171
|
const validMiddleware = middleware.filter(Boolean);
|
|
7166
7172
|
const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(floating);
|
|
7167
|
-
if (
|
|
7173
|
+
if (process.env.NODE_ENV !== "production") {
|
|
7168
7174
|
if (platform2 == null) {
|
|
7169
7175
|
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(" "));
|
|
7170
7176
|
}
|
|
@@ -7221,7 +7227,7 @@ const computePosition$1 = (reference, floating, config) => __async(exports, null
|
|
|
7221
7227
|
middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
|
|
7222
7228
|
[name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
|
|
7223
7229
|
});
|
|
7224
|
-
if (
|
|
7230
|
+
if (process.env.NODE_ENV !== "production") {
|
|
7225
7231
|
if (resetCount > 50) {
|
|
7226
7232
|
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(" "));
|
|
7227
7233
|
}
|
|
@@ -8648,10 +8654,14 @@ const DesktopConnectionModal = (props) => {
|
|
|
8648
8654
|
});
|
|
8649
8655
|
onCleanup(unsubscribe);
|
|
8650
8656
|
const generateUniversalLink = () => {
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8657
|
+
try {
|
|
8658
|
+
const universalLink2 = connector.connect({
|
|
8659
|
+
universalLink: props.wallet.universalLink,
|
|
8660
|
+
bridgeUrl: props.wallet.bridgeUrl
|
|
8661
|
+
}, props.additionalRequest);
|
|
8662
|
+
setUniversalLink(universalLink2);
|
|
8663
|
+
} catch (e2) {
|
|
8664
|
+
}
|
|
8655
8665
|
};
|
|
8656
8666
|
createEffect(() => {
|
|
8657
8667
|
if (untrack(mode) !== "extension" && (supportsMobile(props.wallet) || supportsDesktop(props.wallet))) {
|
|
@@ -9631,6 +9641,17 @@ const MobileUniversalQR = (props) => {
|
|
|
9631
9641
|
}
|
|
9632
9642
|
})];
|
|
9633
9643
|
};
|
|
9644
|
+
function getUniqueBridges(walletsList) {
|
|
9645
|
+
const uniqueBridges = new Set(
|
|
9646
|
+
walletsList.filter(sdk.isWalletInfoRemote).map((item) => item.bridgeUrl)
|
|
9647
|
+
);
|
|
9648
|
+
return Array.from(uniqueBridges).map((bridgeUrl) => ({ bridgeUrl }));
|
|
9649
|
+
}
|
|
9650
|
+
function bridgesIsEqual(left, right) {
|
|
9651
|
+
const leftSet = new Set(left == null ? void 0 : left.map((i2) => i2.bridgeUrl));
|
|
9652
|
+
const rightSet = new Set(right == null ? void 0 : right.map((i2) => i2.bridgeUrl));
|
|
9653
|
+
return leftSet.size === rightSet.size && [...leftSet].every((value) => rightSet.has(value));
|
|
9654
|
+
}
|
|
9634
9655
|
const _tmpl$$1 = /* @__PURE__ */ template$1(`<li></li>`), _tmpl$2 = /* @__PURE__ */ template$1(`<div data-tc-wallets-modal-universal-mobile="true"></div>`);
|
|
9635
9656
|
const MobileUniversalModal = (props) => {
|
|
9636
9657
|
const [showQR, setShowQR] = createSignal(false);
|
|
@@ -9638,10 +9659,10 @@ const MobileUniversalModal = (props) => {
|
|
|
9638
9659
|
const connector = appState.connector;
|
|
9639
9660
|
const walletsList = () => props.walletsList.filter((w) => supportsMobile(w) && w.appName !== AT_WALLET_APP_NAME);
|
|
9640
9661
|
const shouldShowMoreButton = () => walletsList().length > 7;
|
|
9641
|
-
const walletsBridges = () =>
|
|
9642
|
-
|
|
9643
|
-
})
|
|
9644
|
-
const getUniversalLink = () => connector.connect(walletsBridges(), props.additionalRequest);
|
|
9662
|
+
const walletsBridges = createMemo(() => getUniqueBridges(props.walletsList), null, {
|
|
9663
|
+
equals: bridgesIsEqual
|
|
9664
|
+
});
|
|
9665
|
+
const getUniversalLink = createMemo(() => connector.connect(walletsBridges(), props.additionalRequest));
|
|
9645
9666
|
setLastSelectedWalletInfo({
|
|
9646
9667
|
openMethod: "universal-link"
|
|
9647
9668
|
});
|
|
@@ -9929,9 +9950,9 @@ const _tmpl$ = /* @__PURE__ */ template$1(`<li></li>`);
|
|
|
9929
9950
|
const DesktopUniversalModal = (props) => {
|
|
9930
9951
|
const [popupOpened, setPopupOpened] = createSignal(false);
|
|
9931
9952
|
const connector = appState.connector;
|
|
9932
|
-
const walletsBridges = () =>
|
|
9933
|
-
|
|
9934
|
-
})
|
|
9953
|
+
const walletsBridges = createMemo(() => getUniqueBridges(props.walletsList), null, {
|
|
9954
|
+
equals: bridgesIsEqual
|
|
9955
|
+
});
|
|
9935
9956
|
setLastSelectedWalletInfo({
|
|
9936
9957
|
openMethod: "qrcode"
|
|
9937
9958
|
});
|
|
@@ -9993,6 +10014,9 @@ const WalletsModal = () => {
|
|
|
9993
10014
|
createEffect(() => locale(appState.language));
|
|
9994
10015
|
createEffect(() => {
|
|
9995
10016
|
if (getWalletsModalIsOpened()) {
|
|
10017
|
+
setSelectedWalletInfo(null);
|
|
10018
|
+
setSelectedTab("universal");
|
|
10019
|
+
setInfoTab(false);
|
|
9996
10020
|
updateIsMobile();
|
|
9997
10021
|
}
|
|
9998
10022
|
});
|
|
@@ -10745,90 +10769,141 @@ class SingleWalletModalManager {
|
|
|
10745
10769
|
}
|
|
10746
10770
|
}
|
|
10747
10771
|
class TonConnectUITracker {
|
|
10748
|
-
constructor(
|
|
10772
|
+
constructor(options) {
|
|
10749
10773
|
__publicField(this, "eventPrefix", "ton-connect-ui-");
|
|
10774
|
+
__publicField(this, "tonConnectUiVersion");
|
|
10775
|
+
__publicField(this, "tonConnectSdkVersion", null);
|
|
10750
10776
|
__publicField(this, "eventDispatcher");
|
|
10751
|
-
|
|
10777
|
+
var _a2;
|
|
10778
|
+
this.eventDispatcher = (_a2 = options == null ? void 0 : options.eventDispatcher) != null ? _a2 : new sdk.BrowserEventDispatcher();
|
|
10779
|
+
this.tonConnectUiVersion = options.tonConnectUiVersion;
|
|
10780
|
+
this.init().catch();
|
|
10781
|
+
}
|
|
10782
|
+
get version() {
|
|
10783
|
+
return sdk.createVersionInfo({
|
|
10784
|
+
ton_connect_sdk_lib: this.tonConnectSdkVersion,
|
|
10785
|
+
ton_connect_ui_lib: this.tonConnectUiVersion
|
|
10786
|
+
});
|
|
10787
|
+
}
|
|
10788
|
+
init() {
|
|
10789
|
+
return __async(this, null, function* () {
|
|
10790
|
+
try {
|
|
10791
|
+
yield this.setRequestVersionHandler();
|
|
10792
|
+
this.tonConnectSdkVersion = yield this.requestTonConnectSdkVersion();
|
|
10793
|
+
} catch (e2) {
|
|
10794
|
+
}
|
|
10795
|
+
});
|
|
10796
|
+
}
|
|
10797
|
+
setRequestVersionHandler() {
|
|
10798
|
+
return __async(this, null, function* () {
|
|
10799
|
+
yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version", () => __async(this, null, function* () {
|
|
10800
|
+
yield this.eventDispatcher.dispatchEvent(
|
|
10801
|
+
"ton-connect-ui-response-version",
|
|
10802
|
+
sdk.createResponseVersionEvent(this.tonConnectUiVersion)
|
|
10803
|
+
);
|
|
10804
|
+
}));
|
|
10805
|
+
});
|
|
10806
|
+
}
|
|
10807
|
+
requestTonConnectSdkVersion() {
|
|
10808
|
+
return __async(this, null, function* () {
|
|
10809
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
10810
|
+
try {
|
|
10811
|
+
yield this.eventDispatcher.addEventListener(
|
|
10812
|
+
"ton-connect-response-version",
|
|
10813
|
+
(event) => {
|
|
10814
|
+
resolve(event.detail.version);
|
|
10815
|
+
},
|
|
10816
|
+
{ once: true }
|
|
10817
|
+
);
|
|
10818
|
+
yield this.eventDispatcher.dispatchEvent(
|
|
10819
|
+
"ton-connect-request-version",
|
|
10820
|
+
sdk.createRequestVersionEvent()
|
|
10821
|
+
);
|
|
10822
|
+
} catch (e2) {
|
|
10823
|
+
reject(e2);
|
|
10824
|
+
}
|
|
10825
|
+
}));
|
|
10826
|
+
});
|
|
10752
10827
|
}
|
|
10753
10828
|
dispatchUserActionEvent(eventDetails) {
|
|
10754
10829
|
var _a2;
|
|
10755
10830
|
try {
|
|
10756
|
-
|
|
10757
|
-
(_a2 = this.eventDispatcher) == null ? void 0 : _a2.dispatchEvent(eventName, eventDetails).catch();
|
|
10831
|
+
(_a2 = this.eventDispatcher) == null ? void 0 : _a2.dispatchEvent(`${this.eventPrefix}${eventDetails.type}`, eventDetails).catch();
|
|
10758
10832
|
} catch (e2) {
|
|
10759
10833
|
}
|
|
10760
10834
|
}
|
|
10761
10835
|
trackConnectionStarted(...args) {
|
|
10762
10836
|
try {
|
|
10763
|
-
const event = sdk.createConnectionStartedEvent(...args);
|
|
10837
|
+
const event = sdk.createConnectionStartedEvent(this.version, ...args);
|
|
10764
10838
|
this.dispatchUserActionEvent(event);
|
|
10765
10839
|
} catch (e2) {
|
|
10766
10840
|
}
|
|
10767
10841
|
}
|
|
10768
10842
|
trackConnectionCompleted(...args) {
|
|
10769
10843
|
try {
|
|
10770
|
-
const event = sdk.createConnectionCompletedEvent(...args);
|
|
10844
|
+
const event = sdk.createConnectionCompletedEvent(this.version, ...args);
|
|
10771
10845
|
this.dispatchUserActionEvent(event);
|
|
10772
10846
|
} catch (e2) {
|
|
10773
10847
|
}
|
|
10774
10848
|
}
|
|
10775
10849
|
trackConnectionError(...args) {
|
|
10776
10850
|
try {
|
|
10777
|
-
const event = sdk.createConnectionErrorEvent(...args);
|
|
10851
|
+
const event = sdk.createConnectionErrorEvent(this.version, ...args);
|
|
10778
10852
|
this.dispatchUserActionEvent(event);
|
|
10779
10853
|
} catch (e2) {
|
|
10780
10854
|
}
|
|
10781
10855
|
}
|
|
10782
10856
|
trackConnectionRestoringStarted(...args) {
|
|
10783
10857
|
try {
|
|
10784
|
-
const event = sdk.createConnectionRestoringStartedEvent(...args);
|
|
10858
|
+
const event = sdk.createConnectionRestoringStartedEvent(this.version, ...args);
|
|
10785
10859
|
this.dispatchUserActionEvent(event);
|
|
10786
10860
|
} catch (e2) {
|
|
10787
10861
|
}
|
|
10788
10862
|
}
|
|
10789
10863
|
trackConnectionRestoringCompleted(...args) {
|
|
10790
10864
|
try {
|
|
10791
|
-
const event = sdk.createConnectionRestoringCompletedEvent(...args);
|
|
10865
|
+
const event = sdk.createConnectionRestoringCompletedEvent(this.version, ...args);
|
|
10792
10866
|
this.dispatchUserActionEvent(event);
|
|
10793
10867
|
} catch (e2) {
|
|
10794
10868
|
}
|
|
10795
10869
|
}
|
|
10796
10870
|
trackConnectionRestoringError(...args) {
|
|
10797
10871
|
try {
|
|
10798
|
-
const event = sdk.createConnectionRestoringErrorEvent(...args);
|
|
10872
|
+
const event = sdk.createConnectionRestoringErrorEvent(this.version, ...args);
|
|
10799
10873
|
this.dispatchUserActionEvent(event);
|
|
10800
10874
|
} catch (e2) {
|
|
10801
10875
|
}
|
|
10802
10876
|
}
|
|
10803
10877
|
trackDisconnection(...args) {
|
|
10804
10878
|
try {
|
|
10805
|
-
const event = sdk.createDisconnectionEvent(...args);
|
|
10879
|
+
const event = sdk.createDisconnectionEvent(this.version, ...args);
|
|
10806
10880
|
this.dispatchUserActionEvent(event);
|
|
10807
10881
|
} catch (e2) {
|
|
10808
10882
|
}
|
|
10809
10883
|
}
|
|
10810
10884
|
trackTransactionSentForSignature(...args) {
|
|
10811
10885
|
try {
|
|
10812
|
-
const event = sdk.createTransactionSentForSignatureEvent(...args);
|
|
10886
|
+
const event = sdk.createTransactionSentForSignatureEvent(this.version, ...args);
|
|
10813
10887
|
this.dispatchUserActionEvent(event);
|
|
10814
10888
|
} catch (e2) {
|
|
10815
10889
|
}
|
|
10816
10890
|
}
|
|
10817
10891
|
trackTransactionSigned(...args) {
|
|
10818
10892
|
try {
|
|
10819
|
-
const event = sdk.createTransactionSignedEvent(...args);
|
|
10893
|
+
const event = sdk.createTransactionSignedEvent(this.version, ...args);
|
|
10820
10894
|
this.dispatchUserActionEvent(event);
|
|
10821
10895
|
} catch (e2) {
|
|
10822
10896
|
}
|
|
10823
10897
|
}
|
|
10824
10898
|
trackTransactionSigningFailed(...args) {
|
|
10825
10899
|
try {
|
|
10826
|
-
const event = sdk.createTransactionSigningFailedEvent(...args);
|
|
10900
|
+
const event = sdk.createTransactionSigningFailedEvent(this.version, ...args);
|
|
10827
10901
|
this.dispatchUserActionEvent(event);
|
|
10828
10902
|
} catch (e2) {
|
|
10829
10903
|
}
|
|
10830
10904
|
}
|
|
10831
10905
|
}
|
|
10906
|
+
const tonConnectUiVersion = "2.0.3-beta.3";
|
|
10832
10907
|
class TonConnectUI {
|
|
10833
10908
|
constructor(options) {
|
|
10834
10909
|
__publicField(this, "walletInfoStorage", new WalletInfoStorage());
|
|
@@ -10856,7 +10931,10 @@ class TonConnectUI {
|
|
|
10856
10931
|
"You have to specify a `manifestUrl` or a `connector` in the options."
|
|
10857
10932
|
);
|
|
10858
10933
|
}
|
|
10859
|
-
this.tracker = new TonConnectUITracker(
|
|
10934
|
+
this.tracker = new TonConnectUITracker({
|
|
10935
|
+
eventDispatcher: options == null ? void 0 : options.eventDispatcher,
|
|
10936
|
+
tonConnectUiVersion
|
|
10937
|
+
});
|
|
10860
10938
|
this.modal = new WalletsModalManager({
|
|
10861
10939
|
connector: this.connector,
|
|
10862
10940
|
tracker: this.tracker,
|
|
@@ -10879,8 +10957,8 @@ class TonConnectUI {
|
|
|
10879
10957
|
const rootId = this.normalizeWidgetRoot(options == null ? void 0 : options.widgetRootId);
|
|
10880
10958
|
this.subscribeToWalletChange();
|
|
10881
10959
|
if ((options == null ? void 0 : options.restoreConnection) !== false) {
|
|
10882
|
-
this.
|
|
10883
|
-
|
|
10960
|
+
this.connectionRestored = createMacrotaskAsync(() => __async(this, null, function* () {
|
|
10961
|
+
this.tracker.trackConnectionRestoringStarted();
|
|
10884
10962
|
yield this.connector.restoreConnection();
|
|
10885
10963
|
if (!this.connector.connected) {
|
|
10886
10964
|
this.tracker.trackConnectionRestoringError("Connection was not restored");
|
|
@@ -10888,7 +10966,7 @@ class TonConnectUI {
|
|
|
10888
10966
|
} else {
|
|
10889
10967
|
this.tracker.trackConnectionRestoringCompleted(this.wallet);
|
|
10890
10968
|
}
|
|
10891
|
-
|
|
10969
|
+
return this.connector.connected;
|
|
10892
10970
|
}));
|
|
10893
10971
|
}
|
|
10894
10972
|
this.uiOptions = mergeOptions(options, { uiPreferences: { theme: "SYSTEM" } });
|
|
@@ -11099,7 +11177,6 @@ class TonConnectUI {
|
|
|
11099
11177
|
});
|
|
11100
11178
|
return result;
|
|
11101
11179
|
} catch (e2) {
|
|
11102
|
-
this.tracker.trackTransactionSigningFailed(this.wallet, tx, e2.message);
|
|
11103
11180
|
widgetController.setAction({
|
|
11104
11181
|
name: "transaction-canceled",
|
|
11105
11182
|
showNotification: notifications2.includes("error"),
|
|
@@ -11206,6 +11283,11 @@ class TonConnectUI {
|
|
|
11206
11283
|
return new Promise((resolve, reject) => {
|
|
11207
11284
|
const { transaction, signal } = options;
|
|
11208
11285
|
if (signal.aborted) {
|
|
11286
|
+
this.tracker.trackTransactionSigningFailed(
|
|
11287
|
+
this.wallet,
|
|
11288
|
+
transaction,
|
|
11289
|
+
"Transaction was cancelled"
|
|
11290
|
+
);
|
|
11209
11291
|
return reject(new TonConnectUIError("Transaction was not sent"));
|
|
11210
11292
|
}
|
|
11211
11293
|
const onTransactionHandler = (transaction2) => __async(this, null, function* () {
|
|
@@ -11214,14 +11296,22 @@ class TonConnectUI {
|
|
|
11214
11296
|
const onErrorsHandler = (reason) => {
|
|
11215
11297
|
reject(reason);
|
|
11216
11298
|
};
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11299
|
+
const onCanceledHandler = () => {
|
|
11300
|
+
this.tracker.trackTransactionSigningFailed(
|
|
11301
|
+
this.wallet,
|
|
11302
|
+
transaction,
|
|
11303
|
+
"Transaction was cancelled"
|
|
11304
|
+
);
|
|
11305
|
+
reject(new TonConnectUIError("Transaction was not sent"));
|
|
11306
|
+
};
|
|
11307
|
+
signal.addEventListener("abort", onCanceledHandler, { once: true });
|
|
11308
|
+
this.connector.sendTransaction(transaction, { onRequestSent, signal }).then((result) => {
|
|
11309
|
+
signal.removeEventListener("abort", onCanceledHandler);
|
|
11310
|
+
return onTransactionHandler(result);
|
|
11311
|
+
}).catch((reason) => {
|
|
11312
|
+
signal.removeEventListener("abort", onCanceledHandler);
|
|
11313
|
+
return onErrorsHandler(reason);
|
|
11314
|
+
});
|
|
11225
11315
|
});
|
|
11226
11316
|
});
|
|
11227
11317
|
}
|