@tonconnect/ui 2.0.0-beta.6 → 2.0.0-beta.7
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 +190 -190
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.cjs +298 -52
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.mjs +298 -52
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -1754,12 +1754,167 @@ class TonConnectUIError extends sdk.TonConnectError {
|
|
|
1754
1754
|
Object.setPrototypeOf(this, TonConnectUIError.prototype);
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
1757
|
+
function logError(...args) {
|
|
1758
|
+
{
|
|
1759
|
+
try {
|
|
1760
|
+
console.error("[TON_CONNECT_UI]", ...args);
|
|
1761
|
+
} catch (e2) {
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
function logWarning(...args) {
|
|
1766
|
+
{
|
|
1767
|
+
try {
|
|
1768
|
+
console.warn("[TON_CONNECT_UI]", ...args);
|
|
1769
|
+
} catch (e2) {
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
let initParams = {};
|
|
1774
|
+
try {
|
|
1775
|
+
let locationHash = location.hash.toString();
|
|
1776
|
+
initParams = urlParseHashParams(locationHash);
|
|
1777
|
+
} catch (e2) {
|
|
1778
|
+
}
|
|
1779
|
+
let tmaPlatform = "unknown";
|
|
1780
|
+
if (initParams.tgWebAppPlatform) {
|
|
1781
|
+
tmaPlatform = initParams.tgWebAppPlatform;
|
|
1782
|
+
}
|
|
1783
|
+
let webAppVersion = "6.0";
|
|
1784
|
+
if (initParams.tgWebAppVersion) {
|
|
1785
|
+
webAppVersion = initParams.tgWebAppVersion;
|
|
1786
|
+
}
|
|
1787
|
+
function isTmaPlatform(...platforms) {
|
|
1788
|
+
return platforms.includes(tmaPlatform);
|
|
1789
|
+
}
|
|
1790
|
+
function isInTMA() {
|
|
1791
|
+
var _a2;
|
|
1792
|
+
return tmaPlatform !== "unknown" || !!((_a2 = getWindow$1()) == null ? void 0 : _a2.TelegramWebviewProxy);
|
|
1793
|
+
}
|
|
1794
|
+
function sendExpand() {
|
|
1795
|
+
postEvent("web_app_expand", {});
|
|
1796
|
+
}
|
|
1797
|
+
function sendOpenTelegramLink(link) {
|
|
1798
|
+
const url = new URL(link);
|
|
1799
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
1800
|
+
throw new TonConnectUIError(`Url protocol is not supported: ${url}`);
|
|
1801
|
+
}
|
|
1802
|
+
if (url.hostname !== "t.me") {
|
|
1803
|
+
throw new TonConnectUIError(`Url host is not supported: ${url}`);
|
|
1804
|
+
}
|
|
1805
|
+
const pathFull = url.pathname + url.search;
|
|
1806
|
+
if (isIframe() || versionAtLeast("6.1")) {
|
|
1807
|
+
postEvent("web_app_open_tg_link", { path_full: pathFull });
|
|
1808
|
+
} else {
|
|
1809
|
+
window.open("https://t.me" + pathFull, "_blank", "noreferrer noopener");
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
function isIframe() {
|
|
1813
|
+
try {
|
|
1814
|
+
return window.parent != null && window !== window.parent;
|
|
1815
|
+
} catch (e2) {
|
|
1816
|
+
return false;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
function postEvent(eventType, eventData) {
|
|
1820
|
+
try {
|
|
1821
|
+
if (window.TelegramWebviewProxy !== void 0) {
|
|
1822
|
+
window.TelegramWebviewProxy.postEvent(eventType, JSON.stringify(eventData));
|
|
1823
|
+
} else if (window.external && "notify" in window.external) {
|
|
1824
|
+
window.external.notify(JSON.stringify({ eventType, eventData }));
|
|
1825
|
+
} else if (isIframe()) {
|
|
1826
|
+
const trustedTarget = "*";
|
|
1827
|
+
const message = JSON.stringify({ eventType, eventData });
|
|
1828
|
+
window.parent.postMessage(message, trustedTarget);
|
|
1829
|
+
}
|
|
1830
|
+
throw new TonConnectUIError(`Can't post event to TMA`);
|
|
1831
|
+
} catch (e2) {
|
|
1832
|
+
logError(`Can't post event to parent window: ${e2}`);
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
function urlParseHashParams(locationHash) {
|
|
1836
|
+
locationHash = locationHash.replace(/^#/, "");
|
|
1837
|
+
let params = {};
|
|
1838
|
+
if (!locationHash.length) {
|
|
1839
|
+
return params;
|
|
1840
|
+
}
|
|
1841
|
+
if (locationHash.indexOf("=") < 0 && locationHash.indexOf("?") < 0) {
|
|
1842
|
+
params._path = urlSafeDecode(locationHash);
|
|
1843
|
+
return params;
|
|
1844
|
+
}
|
|
1845
|
+
let qIndex = locationHash.indexOf("?");
|
|
1846
|
+
if (qIndex >= 0) {
|
|
1847
|
+
let pathParam = locationHash.substr(0, qIndex);
|
|
1848
|
+
params._path = urlSafeDecode(pathParam);
|
|
1849
|
+
locationHash = locationHash.substr(qIndex + 1);
|
|
1850
|
+
}
|
|
1851
|
+
let query_params = urlParseQueryString(locationHash);
|
|
1852
|
+
for (let k in query_params) {
|
|
1853
|
+
params[k] = query_params[k];
|
|
1854
|
+
}
|
|
1855
|
+
return params;
|
|
1856
|
+
}
|
|
1857
|
+
function urlSafeDecode(urlencoded) {
|
|
1858
|
+
try {
|
|
1859
|
+
urlencoded = urlencoded.replace(/\+/g, "%20");
|
|
1860
|
+
return decodeURIComponent(urlencoded);
|
|
1861
|
+
} catch (e2) {
|
|
1862
|
+
return urlencoded;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
function urlParseQueryString(queryString) {
|
|
1866
|
+
let params = {};
|
|
1867
|
+
if (!queryString.length) {
|
|
1868
|
+
return params;
|
|
1869
|
+
}
|
|
1870
|
+
let queryStringParams = queryString.split("&");
|
|
1871
|
+
let i2, param, paramName, paramValue;
|
|
1872
|
+
for (i2 = 0; i2 < queryStringParams.length; i2++) {
|
|
1873
|
+
param = queryStringParams[i2].split("=");
|
|
1874
|
+
paramName = urlSafeDecode(param[0]);
|
|
1875
|
+
paramValue = param[1] == null ? null : urlSafeDecode(param[1]);
|
|
1876
|
+
params[paramName] = paramValue;
|
|
1877
|
+
}
|
|
1878
|
+
return params;
|
|
1879
|
+
}
|
|
1880
|
+
function versionCompare(v1, v2) {
|
|
1881
|
+
if (typeof v1 !== "string")
|
|
1882
|
+
v1 = "";
|
|
1883
|
+
if (typeof v2 !== "string")
|
|
1884
|
+
v2 = "";
|
|
1885
|
+
let v1List = v1.replace(/^\s+|\s+$/g, "").split(".");
|
|
1886
|
+
let v2List = v2.replace(/^\s+|\s+$/g, "").split(".");
|
|
1887
|
+
let a2, i2, p1, p2;
|
|
1888
|
+
a2 = Math.max(v1List.length, v2List.length);
|
|
1889
|
+
for (i2 = 0; i2 < a2; i2++) {
|
|
1890
|
+
p1 = parseInt(v1List[i2]) || 0;
|
|
1891
|
+
p2 = parseInt(v2List[i2]) || 0;
|
|
1892
|
+
if (p1 === p2)
|
|
1893
|
+
continue;
|
|
1894
|
+
if (p1 > p2)
|
|
1895
|
+
return 1;
|
|
1896
|
+
return -1;
|
|
1897
|
+
}
|
|
1898
|
+
return 0;
|
|
1899
|
+
}
|
|
1900
|
+
function versionAtLeast(ver) {
|
|
1901
|
+
return versionCompare(webAppVersion, ver) >= 0;
|
|
1902
|
+
}
|
|
1757
1903
|
function openLink(href, target = "_self") {
|
|
1758
|
-
|
|
1904
|
+
window.open(href, target, "noopener noreferrer");
|
|
1759
1905
|
}
|
|
1760
1906
|
function openLinkBlank(href) {
|
|
1761
1907
|
openLink(href, "_blank");
|
|
1762
1908
|
}
|
|
1909
|
+
function openIframeLink(href, fallback) {
|
|
1910
|
+
const iframe = document.createElement("iframe");
|
|
1911
|
+
iframe.style.display = "none";
|
|
1912
|
+
iframe.src = href;
|
|
1913
|
+
document.body.appendChild(iframe);
|
|
1914
|
+
const fallbackTimeout = setTimeout(() => fallback(), 1e3);
|
|
1915
|
+
window.addEventListener("blur", () => clearTimeout(fallbackTimeout), { once: true });
|
|
1916
|
+
setTimeout(() => document.body.removeChild(iframe), 1e3);
|
|
1917
|
+
}
|
|
1763
1918
|
function getSystemTheme() {
|
|
1764
1919
|
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
1765
1920
|
return THEME.LIGHT;
|
|
@@ -1781,7 +1936,7 @@ function addReturnStrategy(url, strategy) {
|
|
|
1781
1936
|
if (typeof strategy === "string") {
|
|
1782
1937
|
returnStrategy = strategy;
|
|
1783
1938
|
} else {
|
|
1784
|
-
returnStrategy =
|
|
1939
|
+
returnStrategy = isInTMA() ? strategy.twaReturnUrl || strategy.returnStrategy : "none";
|
|
1785
1940
|
}
|
|
1786
1941
|
const newUrl = addQueryParameter(url, "ret", returnStrategy);
|
|
1787
1942
|
if (!sdk.isTelegramUrl(url)) {
|
|
@@ -1811,9 +1966,17 @@ function defineStylesRoot() {
|
|
|
1811
1966
|
customElements.define(globalStylesTag, class TcRootElement extends HTMLElement {
|
|
1812
1967
|
});
|
|
1813
1968
|
}
|
|
1969
|
+
function createMacrotask(callback) {
|
|
1970
|
+
return __async(this, null, function* () {
|
|
1971
|
+
yield new Promise((resolve) => requestAnimationFrame(resolve));
|
|
1972
|
+
callback();
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1814
1975
|
function preloadImages(images) {
|
|
1815
1976
|
if (document.readyState !== "complete") {
|
|
1816
|
-
window.addEventListener("load", () => preloadImages(images), {
|
|
1977
|
+
window.addEventListener("load", () => createMacrotask(() => preloadImages(images)), {
|
|
1978
|
+
once: true
|
|
1979
|
+
});
|
|
1817
1980
|
} else {
|
|
1818
1981
|
images.forEach((img) => {
|
|
1819
1982
|
const node = new window.Image();
|
|
@@ -1888,14 +2051,67 @@ function getUserAgent() {
|
|
|
1888
2051
|
browser
|
|
1889
2052
|
};
|
|
1890
2053
|
}
|
|
2054
|
+
function isOS(...os) {
|
|
2055
|
+
return os.includes(getUserAgent().os);
|
|
2056
|
+
}
|
|
1891
2057
|
function redirectToTelegram(universalLink, options) {
|
|
2058
|
+
options = __spreadValues({}, options);
|
|
2059
|
+
const directLink = convertToDirectLink(universalLink);
|
|
2060
|
+
const directLinkUrl = new URL(directLink);
|
|
2061
|
+
if (!directLinkUrl.searchParams.has("startapp")) {
|
|
2062
|
+
directLinkUrl.searchParams.append("startapp", "tonconnect");
|
|
2063
|
+
}
|
|
2064
|
+
if (isInTMA()) {
|
|
2065
|
+
if (isTmaPlatform("ios", "android")) {
|
|
2066
|
+
options.returnStrategy = "none";
|
|
2067
|
+
options.twaReturnUrl = void 0;
|
|
2068
|
+
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2069
|
+
} else if (isTmaPlatform("macos", "tdesktop")) {
|
|
2070
|
+
if (!options.twaReturnUrl) {
|
|
2071
|
+
throw new TonConnectUIError("`twaReturnUrl` is required for this platform");
|
|
2072
|
+
}
|
|
2073
|
+
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2074
|
+
} else if (isTmaPlatform("weba")) {
|
|
2075
|
+
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2076
|
+
} else if (isTmaPlatform("web")) {
|
|
2077
|
+
options.returnStrategy = "none";
|
|
2078
|
+
options.twaReturnUrl = void 0;
|
|
2079
|
+
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2080
|
+
} else {
|
|
2081
|
+
openLinkBlank(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2082
|
+
}
|
|
2083
|
+
} else {
|
|
2084
|
+
if (isOS("ios", "android")) {
|
|
2085
|
+
options.returnStrategy = "back";
|
|
2086
|
+
openLinkBlank(addReturnStrategy(directLinkUrl.toString(), options.returnStrategy));
|
|
2087
|
+
} else if (isOS("macos", "windows", "linux")) {
|
|
2088
|
+
options.returnStrategy = "none";
|
|
2089
|
+
options.twaReturnUrl = void 0;
|
|
2090
|
+
if (options.forceRedirect) {
|
|
2091
|
+
openLinkBlank(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2092
|
+
} else {
|
|
2093
|
+
const link = addReturnStrategy(directLinkUrl.toString(), options);
|
|
2094
|
+
const deepLink = convertToDeepLink(link);
|
|
2095
|
+
openIframeLink(deepLink, () => openLinkBlank(link));
|
|
2096
|
+
}
|
|
2097
|
+
} else {
|
|
2098
|
+
openLinkBlank(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
function convertToDirectLink(universalLink) {
|
|
1892
2103
|
const url = new URL(universalLink);
|
|
1893
|
-
url.searchParams.
|
|
1894
|
-
|
|
2104
|
+
if (url.searchParams.has("attach")) {
|
|
2105
|
+
url.searchParams.delete("attach");
|
|
2106
|
+
url.pathname += "/start";
|
|
2107
|
+
}
|
|
2108
|
+
return url.toString();
|
|
1895
2109
|
}
|
|
1896
|
-
function
|
|
1897
|
-
|
|
1898
|
-
|
|
2110
|
+
function convertToDeepLink(directLink) {
|
|
2111
|
+
const parsed = new URL(directLink);
|
|
2112
|
+
const [, domain, appname] = parsed.pathname.split("/");
|
|
2113
|
+
const startapp = parsed.searchParams.get("startapp");
|
|
2114
|
+
return `tg://resolve?domain=${domain}&appname=${appname}&startapp=${startapp}`;
|
|
1899
2115
|
}
|
|
1900
2116
|
class WalletInfoStorage {
|
|
1901
2117
|
constructor() {
|
|
@@ -2014,8 +2230,8 @@ const walletModal$1 = {
|
|
|
2014
2230
|
wallets: "Wallets",
|
|
2015
2231
|
mobileUniversalModal: {
|
|
2016
2232
|
connectYourWallet: "Connect your wallet",
|
|
2017
|
-
openWalletOnTelegramOrSelect: "Open Wallet
|
|
2018
|
-
openWalletOnTelegram: "Open Wallet
|
|
2233
|
+
openWalletOnTelegramOrSelect: "Open Wallet in Telegram or select your wallet to connect",
|
|
2234
|
+
openWalletOnTelegram: "Open Wallet in Telegram",
|
|
2019
2235
|
openLink: "Open Link",
|
|
2020
2236
|
scan: "Scan with your mobile wallet"
|
|
2021
2237
|
},
|
|
@@ -2036,7 +2252,7 @@ const walletModal$1 = {
|
|
|
2036
2252
|
dontHaveExtension: "Seems you don't have installed {{ name }}\xA0browser\xA0extension",
|
|
2037
2253
|
getWallet: "Get {{ name }}",
|
|
2038
2254
|
continueOnDesktop: "Continue in\xA0{{ name }} on desktop\u2026",
|
|
2039
|
-
openWalletOnTelegram: "Open Wallet
|
|
2255
|
+
openWalletOnTelegram: "Open Wallet in Telegram on desktop",
|
|
2040
2256
|
connectionDeclined: "Connection declined"
|
|
2041
2257
|
},
|
|
2042
2258
|
infoModal: {
|
|
@@ -2625,6 +2841,9 @@ function isDevice(device) {
|
|
|
2625
2841
|
if (!window2) {
|
|
2626
2842
|
return device === "desktop";
|
|
2627
2843
|
}
|
|
2844
|
+
if (isTmaPlatform("weba")) {
|
|
2845
|
+
return true;
|
|
2846
|
+
}
|
|
2628
2847
|
const width = window2.innerWidth;
|
|
2629
2848
|
switch (device) {
|
|
2630
2849
|
case "desktop":
|
|
@@ -3078,7 +3297,7 @@ function androidBackHandler$1(_, config) {
|
|
|
3078
3297
|
});
|
|
3079
3298
|
onCleanup(() => {
|
|
3080
3299
|
window.removeEventListener("popstate", popstateHandler);
|
|
3081
|
-
|
|
3300
|
+
createMacrotask(() => {
|
|
3082
3301
|
var _a2;
|
|
3083
3302
|
if (((_a2 = window.history.state) == null ? void 0 : _a2[ROUTE_STATE_KEY]) === true) {
|
|
3084
3303
|
window.history.back();
|
|
@@ -3297,14 +3516,6 @@ const ModalFooterStyled = styled.div`
|
|
|
3297
3516
|
const QuestionButtonStyled = styled(IconButton)`
|
|
3298
3517
|
background-color: ${(props) => rgba(props.theme.colors.icon.secondary, 0.12)};
|
|
3299
3518
|
`;
|
|
3300
|
-
function logWarning(...args) {
|
|
3301
|
-
{
|
|
3302
|
-
try {
|
|
3303
|
-
console.warn("[TON_CONNECT_UI]", ...args);
|
|
3304
|
-
} catch (e2) {
|
|
3305
|
-
}
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
3519
|
class AnimationTimelineNoop {
|
|
3309
3520
|
constructor() {
|
|
3310
3521
|
__publicField(this, "currentTime", 0);
|
|
@@ -5355,11 +5566,16 @@ var qrcode$1 = { exports: {} };
|
|
|
5355
5566
|
})(qrcode$1);
|
|
5356
5567
|
const qrcode = qrcode$1.exports;
|
|
5357
5568
|
function copyToClipboard(text) {
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5569
|
+
return __async(this, null, function* () {
|
|
5570
|
+
try {
|
|
5571
|
+
if (!(navigator == null ? void 0 : navigator.clipboard)) {
|
|
5572
|
+
throw new TonConnectUIError("Clipboard API not available");
|
|
5573
|
+
}
|
|
5574
|
+
return yield navigator.clipboard.writeText(text);
|
|
5575
|
+
} catch (e2) {
|
|
5576
|
+
}
|
|
5577
|
+
fallbackCopyTextToClipboard(text);
|
|
5578
|
+
});
|
|
5363
5579
|
}
|
|
5364
5580
|
function fallbackCopyTextToClipboard(text) {
|
|
5365
5581
|
const textArea = document.createElement("textarea");
|
|
@@ -8101,6 +8317,7 @@ const DesktopConnectionModal = (props) => {
|
|
|
8101
8317
|
const [mode, setMode] = createSignal("mobile");
|
|
8102
8318
|
const [connectionErrored, setConnectionErrored] = createSignal(false);
|
|
8103
8319
|
const [universalLink, setUniversalLink] = createSignal();
|
|
8320
|
+
const [firstClick, setFirstClick] = createSignal(true);
|
|
8104
8321
|
const connector = useContext(ConnectorContext);
|
|
8105
8322
|
const unsubscribe = connector.onStatusChange(() => {
|
|
8106
8323
|
}, () => {
|
|
@@ -8142,13 +8359,16 @@ const DesktopConnectionModal = (props) => {
|
|
|
8142
8359
|
openLinkBlank(addReturnStrategy(universalLink(), appState.returnStrategy));
|
|
8143
8360
|
};
|
|
8144
8361
|
const onClickTelegram = () => {
|
|
8362
|
+
const forceRedirect = !firstClick();
|
|
8363
|
+
setFirstClick(false);
|
|
8145
8364
|
setLastSelectedWalletInfo(__spreadProps(__spreadValues({}, props.wallet), {
|
|
8146
8365
|
openMethod: "universal-link"
|
|
8147
8366
|
}));
|
|
8148
|
-
|
|
8367
|
+
redirectToTelegram(universalLink(), {
|
|
8149
8368
|
returnStrategy: appState.returnStrategy,
|
|
8150
|
-
twaReturnUrl: appState.twaReturnUrl
|
|
8151
|
-
|
|
8369
|
+
twaReturnUrl: appState.twaReturnUrl,
|
|
8370
|
+
forceRedirect
|
|
8371
|
+
});
|
|
8152
8372
|
};
|
|
8153
8373
|
const onClickExtension = () => {
|
|
8154
8374
|
setConnectionErrored(false);
|
|
@@ -8414,7 +8634,7 @@ const DesktopConnectionModal = (props) => {
|
|
|
8414
8634
|
get children() {
|
|
8415
8635
|
return createComponent(Translation, {
|
|
8416
8636
|
translationKey: "walletModal.desktopConnectionModal.openWalletOnTelegram",
|
|
8417
|
-
children: "Open Wallet
|
|
8637
|
+
children: "Open Wallet in Telegram on desktop"
|
|
8418
8638
|
});
|
|
8419
8639
|
}
|
|
8420
8640
|
});
|
|
@@ -9051,6 +9271,7 @@ const MobileUniversalQR = (props) => {
|
|
|
9051
9271
|
const _tmpl$$1 = /* @__PURE__ */ template$1(`<li></li>`), _tmpl$2 = /* @__PURE__ */ template$1(`<div data-tc-wallets-modal-universal-mobile="true"></div>`);
|
|
9052
9272
|
const MobileUniversalModal = (props) => {
|
|
9053
9273
|
const [showQR, setShowQR] = createSignal(false);
|
|
9274
|
+
const [firstClick, setFirstClick] = createSignal(true);
|
|
9054
9275
|
const connector = appState.connector;
|
|
9055
9276
|
const walletsList = () => props.walletsList.filter((w) => supportsMobile(w) && w.appName !== AT_WALLET_APP_NAME);
|
|
9056
9277
|
const shouldShowMoreButton = () => walletsList().length > 7;
|
|
@@ -9082,10 +9303,13 @@ const MobileUniversalModal = (props) => {
|
|
|
9082
9303
|
bridgeUrl: atWallet.bridgeUrl,
|
|
9083
9304
|
universalLink: atWallet.universalLink
|
|
9084
9305
|
}, props.additionalRequest);
|
|
9085
|
-
|
|
9306
|
+
const forceRedirect = !firstClick();
|
|
9307
|
+
setFirstClick(false);
|
|
9308
|
+
redirectToTelegram(walletLink, {
|
|
9086
9309
|
returnStrategy: appState.returnStrategy,
|
|
9087
|
-
twaReturnUrl: appState.twaReturnUrl
|
|
9088
|
-
|
|
9310
|
+
twaReturnUrl: appState.twaReturnUrl,
|
|
9311
|
+
forceRedirect
|
|
9312
|
+
});
|
|
9089
9313
|
};
|
|
9090
9314
|
const onOpenQR = () => {
|
|
9091
9315
|
setShowQR(true);
|
|
@@ -9131,7 +9355,7 @@ const MobileUniversalModal = (props) => {
|
|
|
9131
9355
|
children: "Connect your wallet"
|
|
9132
9356
|
}), createComponent(H2Styled$2, {
|
|
9133
9357
|
translationKey: "walletModal.mobileUniversalModal.openWalletOnTelegramOrSelect",
|
|
9134
|
-
children: "Open Wallet
|
|
9358
|
+
children: "Open Wallet in Telegram or select your wallet to connect"
|
|
9135
9359
|
}), createComponent(TelegramButtonStyled, {
|
|
9136
9360
|
get leftIcon() {
|
|
9137
9361
|
return createComponent(AtWalletIcon, {});
|
|
@@ -9148,7 +9372,7 @@ const MobileUniversalModal = (props) => {
|
|
|
9148
9372
|
get children() {
|
|
9149
9373
|
return createComponent(Translation, {
|
|
9150
9374
|
translationKey: "walletModal.mobileUniversalModal.openWalletOnTelegram",
|
|
9151
|
-
children: "Open Wallet
|
|
9375
|
+
children: "Open Wallet in Telegram"
|
|
9152
9376
|
});
|
|
9153
9377
|
}
|
|
9154
9378
|
}), createComponent(UlStyled, {
|
|
@@ -9585,17 +9809,21 @@ const ButtonStyled = styled(Button)`
|
|
|
9585
9809
|
const ActionModal = (props) => {
|
|
9586
9810
|
const dataAttrs = useDataAttributes(props);
|
|
9587
9811
|
const tonConnectUI = useContext(TonConnectUiContext);
|
|
9812
|
+
const [firstClick, setFirstClick] = createSignal(true);
|
|
9588
9813
|
let universalLink;
|
|
9589
|
-
if ((tonConnectUI == null ? void 0 : tonConnectUI.wallet) && "universalLink" in tonConnectUI.wallet && (tonConnectUI.wallet.openMethod === "universal-link" || sdk.isTelegramUrl(tonConnectUI.wallet.universalLink) &&
|
|
9814
|
+
if ((tonConnectUI == null ? void 0 : tonConnectUI.wallet) && "universalLink" in tonConnectUI.wallet && (tonConnectUI.wallet.openMethod === "universal-link" || sdk.isTelegramUrl(tonConnectUI.wallet.universalLink) && isInTMA())) {
|
|
9590
9815
|
universalLink = tonConnectUI.wallet.universalLink;
|
|
9591
9816
|
}
|
|
9592
9817
|
const onOpenWallet = () => {
|
|
9593
9818
|
const currentAction = action();
|
|
9594
9819
|
const returnStrategy = "returnStrategy" in currentAction ? currentAction.returnStrategy : appState.returnStrategy;
|
|
9595
9820
|
if (sdk.isTelegramUrl(universalLink)) {
|
|
9821
|
+
const forceRedirect = !firstClick();
|
|
9822
|
+
setFirstClick(false);
|
|
9596
9823
|
redirectToTelegram(universalLink, {
|
|
9597
9824
|
returnStrategy,
|
|
9598
|
-
twaReturnUrl: "twaReturnUrl" in currentAction ? currentAction.twaReturnUrl : appState.twaReturnUrl
|
|
9825
|
+
twaReturnUrl: "twaReturnUrl" in currentAction ? currentAction.twaReturnUrl : appState.twaReturnUrl,
|
|
9826
|
+
forceRedirect
|
|
9599
9827
|
});
|
|
9600
9828
|
} else {
|
|
9601
9829
|
openLinkBlank(addReturnStrategy(universalLink, returnStrategy));
|
|
@@ -9860,6 +10088,9 @@ class WalletsModalManager {
|
|
|
9860
10088
|
}
|
|
9861
10089
|
connectExternalWallet() {
|
|
9862
10090
|
return __async(this, null, function* () {
|
|
10091
|
+
if (isInTMA()) {
|
|
10092
|
+
sendExpand();
|
|
10093
|
+
}
|
|
9863
10094
|
widgetController.openWalletsModal();
|
|
9864
10095
|
return new Promise((resolve) => {
|
|
9865
10096
|
const unsubscribe = this.onStateChange((state) => {
|
|
@@ -10058,21 +10289,30 @@ class TonConnectUI {
|
|
|
10058
10289
|
if (!this.connected) {
|
|
10059
10290
|
throw new TonConnectUIError("Connect wallet to send a transaction.");
|
|
10060
10291
|
}
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
const shouldSkipRedirectToWallet = skipRedirectToWallet === "ios" && userOSIsIos || skipRedirectToWallet === "always";
|
|
10064
|
-
if (this.walletInfo && "universalLink" in this.walletInfo && this.walletInfo.openMethod === "universal-link" && !shouldSkipRedirectToWallet) {
|
|
10065
|
-
if (sdk.isTelegramUrl(this.walletInfo.universalLink)) {
|
|
10066
|
-
redirectToTelegram(this.walletInfo.universalLink, { returnStrategy, twaReturnUrl });
|
|
10067
|
-
} else {
|
|
10068
|
-
openLinkBlank(addReturnStrategy(this.walletInfo.universalLink, returnStrategy));
|
|
10069
|
-
}
|
|
10292
|
+
if (isInTMA()) {
|
|
10293
|
+
sendExpand();
|
|
10070
10294
|
}
|
|
10295
|
+
const { notifications: notifications2, modals, returnStrategy, twaReturnUrl, skipRedirectToWallet } = this.getModalsAndNotificationsConfiguration(options);
|
|
10071
10296
|
widgetController.setAction({
|
|
10072
10297
|
name: "confirm-transaction",
|
|
10073
10298
|
showNotification: notifications2.includes("before"),
|
|
10074
10299
|
openModal: modals.includes("before")
|
|
10075
10300
|
});
|
|
10301
|
+
const onRequestSent = () => {
|
|
10302
|
+
const userOSIsIos = getUserAgent().os === "ios";
|
|
10303
|
+
const shouldSkipRedirectToWallet = skipRedirectToWallet === "ios" && userOSIsIos || skipRedirectToWallet === "always";
|
|
10304
|
+
if (this.walletInfo && "universalLink" in this.walletInfo && this.walletInfo.openMethod === "universal-link" && !shouldSkipRedirectToWallet) {
|
|
10305
|
+
if (sdk.isTelegramUrl(this.walletInfo.universalLink)) {
|
|
10306
|
+
redirectToTelegram(this.walletInfo.universalLink, {
|
|
10307
|
+
returnStrategy,
|
|
10308
|
+
twaReturnUrl: twaReturnUrl || appState.twaReturnUrl,
|
|
10309
|
+
forceRedirect: false
|
|
10310
|
+
});
|
|
10311
|
+
} else {
|
|
10312
|
+
openLinkBlank(addReturnStrategy(this.walletInfo.universalLink, returnStrategy));
|
|
10313
|
+
}
|
|
10314
|
+
}
|
|
10315
|
+
};
|
|
10076
10316
|
const abortController = new AbortController();
|
|
10077
10317
|
const unsubscribe = this.onTransactionModalStateChange((action2) => {
|
|
10078
10318
|
if (action2 == null ? void 0 : action2.openModal) {
|
|
@@ -10084,10 +10324,13 @@ class TonConnectUI {
|
|
|
10084
10324
|
}
|
|
10085
10325
|
});
|
|
10086
10326
|
try {
|
|
10087
|
-
const result = yield this.waitForSendTransaction(
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10327
|
+
const result = yield this.waitForSendTransaction(
|
|
10328
|
+
{
|
|
10329
|
+
transaction: tx,
|
|
10330
|
+
abortSignal: abortController.signal
|
|
10331
|
+
},
|
|
10332
|
+
onRequestSent
|
|
10333
|
+
);
|
|
10091
10334
|
widgetController.setAction({
|
|
10092
10335
|
name: "transaction-sent",
|
|
10093
10336
|
showNotification: notifications2.includes("success"),
|
|
@@ -10187,7 +10430,7 @@ class TonConnectUI {
|
|
|
10187
10430
|
});
|
|
10188
10431
|
});
|
|
10189
10432
|
}
|
|
10190
|
-
waitForSendTransaction(options) {
|
|
10433
|
+
waitForSendTransaction(options, onRequestSent) {
|
|
10191
10434
|
return __async(this, null, function* () {
|
|
10192
10435
|
return new Promise((resolve, reject) => {
|
|
10193
10436
|
const { transaction, abortSignal } = options;
|
|
@@ -10200,7 +10443,7 @@ class TonConnectUI {
|
|
|
10200
10443
|
const onErrorsHandler = (reason) => {
|
|
10201
10444
|
reject(reason);
|
|
10202
10445
|
};
|
|
10203
|
-
this.connector.sendTransaction(transaction).then((result) => onTransactionHandler(result)).catch((reason) => onErrorsHandler(reason));
|
|
10446
|
+
this.connector.sendTransaction(transaction, onRequestSent).then((result) => onTransactionHandler(result)).catch((reason) => onErrorsHandler(reason));
|
|
10204
10447
|
abortSignal.addEventListener("abort", () => {
|
|
10205
10448
|
reject(new TonConnectUIError("Transaction was not sent"));
|
|
10206
10449
|
});
|
|
@@ -10320,7 +10563,10 @@ class TonConnectUI {
|
|
|
10320
10563
|
}
|
|
10321
10564
|
const returnStrategy = (options == null ? void 0 : options.returnStrategy) || ((_d = this.actionsConfiguration) == null ? void 0 : _d.returnStrategy) || "back";
|
|
10322
10565
|
const twaReturnUrl = (options == null ? void 0 : options.twaReturnUrl) || ((_e = this.actionsConfiguration) == null ? void 0 : _e.twaReturnUrl);
|
|
10323
|
-
|
|
10566
|
+
let skipRedirectToWallet = (options == null ? void 0 : options.skipRedirectToWallet) || ((_f = this.actionsConfiguration) == null ? void 0 : _f.skipRedirectToWallet) || "ios";
|
|
10567
|
+
if (isInTMA()) {
|
|
10568
|
+
skipRedirectToWallet = "never";
|
|
10569
|
+
}
|
|
10324
10570
|
return {
|
|
10325
10571
|
notifications: notifications2,
|
|
10326
10572
|
modals,
|