@trustware/sdk-staging 1.1.9-staging.1 → 1.1.9-staging.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/constants.cjs +1 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/{core-p_5BLdbE.d.ts → core-CwT8Wd1x.d.ts} +1 -1
- package/dist/{core-D_jx805U.d.cts → core-Dy_rZl5y.d.cts} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/{detect--pmNlAHv.d.cts → detect-DVpECOTa.d.cts} +2 -2
- package/dist/{detect-qAX6I4JI.d.ts → detect-d2PUaxE_.d.ts} +2 -2
- package/dist/index.cjs +592 -268
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.mjs +546 -222
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-aMi4_Ss6.d.cts → manager-B5aklGtm.d.cts} +1 -1
- package/dist/{manager-DFQkemW0.d.ts → manager-xFiq0SHr.d.ts} +1 -1
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +31 -3
- package/dist/smart-account.d.ts +31 -3
- package/dist/smart-account.mjs +1 -1
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +103 -47
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +3 -3
- package/dist/wallet.d.ts +3 -3
- package/dist/wallet.mjs +103 -47
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +592 -268
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +546 -222
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -408,7 +408,7 @@ var init_constants = __esm({
|
|
|
408
408
|
"src/constants.ts"() {
|
|
409
409
|
"use strict";
|
|
410
410
|
SDK_NAME = "@trustware/sdk";
|
|
411
|
-
SDK_VERSION = "1.1.9-staging.
|
|
411
|
+
SDK_VERSION = "1.1.9-staging.3";
|
|
412
412
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
413
413
|
GTM_ID = "GTM-TZDGNCXB";
|
|
414
414
|
API_PREFIX = "/api";
|
|
@@ -1012,12 +1012,25 @@ var init_connect = __esm({
|
|
|
1012
1012
|
function formatDeepLink(id, currentUrl) {
|
|
1013
1013
|
const enc = encodeURIComponent(currentUrl);
|
|
1014
1014
|
switch (id) {
|
|
1015
|
+
// EVM
|
|
1015
1016
|
case "metamask":
|
|
1016
1017
|
return `metamask://dapp/${currentUrl}`;
|
|
1017
1018
|
case "coinbase":
|
|
1018
1019
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
1019
1020
|
case "rainbow":
|
|
1020
1021
|
return `rainbow://connect?uri=${enc}`;
|
|
1022
|
+
case "trust":
|
|
1023
|
+
return `https://link.trustwallet.com/open_url?coin_id=60&url=${enc}`;
|
|
1024
|
+
case "okx":
|
|
1025
|
+
return `okx://wallet/dapp/url?dappUrl=${enc}`;
|
|
1026
|
+
// Solana
|
|
1027
|
+
case "phantom-solana":
|
|
1028
|
+
return `phantom://browse/${enc}`;
|
|
1029
|
+
case "solflare":
|
|
1030
|
+
return `solflare://ul/v1/browse/${enc}`;
|
|
1031
|
+
case "backpack":
|
|
1032
|
+
return `https://backpack.app/ul/v1/browse/${enc}?ref=${enc}`;
|
|
1033
|
+
// No confirmed deep link scheme
|
|
1021
1034
|
default:
|
|
1022
1035
|
return void 0;
|
|
1023
1036
|
}
|
|
@@ -1045,6 +1058,8 @@ var init_metadata = __esm({
|
|
|
1045
1058
|
emoji: "\u{1F98A}",
|
|
1046
1059
|
homepage: "https://metamask.io/",
|
|
1047
1060
|
chromeWebStore: "https://chromewebstore.google.com/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",
|
|
1061
|
+
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
1062
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
1048
1063
|
detectFlags: ["isMetaMask"],
|
|
1049
1064
|
deepLink: (url) => formatDeepLink("metamask", url) ?? ""
|
|
1050
1065
|
},
|
|
@@ -1056,6 +1071,8 @@ var init_metadata = __esm({
|
|
|
1056
1071
|
logo: `${ASSETS_BASE_URL}/assets/wallets/coinbase.svg`,
|
|
1057
1072
|
emoji: "\u{1F7E6}",
|
|
1058
1073
|
homepage: "https://www.coinbase.com/wallet",
|
|
1074
|
+
ios: "https://apps.apple.com/app/coinbase-wallet/id1278383455",
|
|
1075
|
+
android: "https://play.google.com/store/apps/details?id=org.toshi",
|
|
1059
1076
|
detectFlags: ["isCoinbaseWallet"],
|
|
1060
1077
|
deepLink: (url) => formatDeepLink("coinbase", url) ?? ""
|
|
1061
1078
|
},
|
|
@@ -1067,6 +1084,7 @@ var init_metadata = __esm({
|
|
|
1067
1084
|
logo: `${ASSETS_BASE_URL}/assets/wallets/walletconnect.svg`,
|
|
1068
1085
|
emoji: "\u{1FA9D}",
|
|
1069
1086
|
homepage: "https://walletconnect.com/"
|
|
1087
|
+
// No deep link — opens its own modal
|
|
1070
1088
|
},
|
|
1071
1089
|
{
|
|
1072
1090
|
id: "rainbow",
|
|
@@ -1076,8 +1094,38 @@ var init_metadata = __esm({
|
|
|
1076
1094
|
logo: `${ASSETS_BASE_URL}/assets/wallets/rainbow.svg`,
|
|
1077
1095
|
emoji: "\u{1F308}",
|
|
1078
1096
|
homepage: "https://rainbow.me/",
|
|
1079
|
-
|
|
1080
|
-
|
|
1097
|
+
ios: "https://apps.apple.com/app/rainbow-ethereum-wallet/id1457119021",
|
|
1098
|
+
android: "https://play.google.com/store/apps/details?id=me.rainbow",
|
|
1099
|
+
detectFlags: ["isRainbow"],
|
|
1100
|
+
deepLink: (url) => formatDeepLink("rainbow", url) ?? ""
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
id: "trust",
|
|
1104
|
+
name: "Trust Wallet",
|
|
1105
|
+
category: "app",
|
|
1106
|
+
ecosystem: "multi",
|
|
1107
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
|
|
1108
|
+
emoji: "\u{1F6E1}\uFE0F",
|
|
1109
|
+
homepage: "https://trustwallet.com/",
|
|
1110
|
+
ios: "https://apps.apple.com/app/trust-crypto-bitcoin-wallet/id1288339409",
|
|
1111
|
+
android: "https://play.google.com/store/apps/details?id=com.wallet.crypto.trustapp",
|
|
1112
|
+
detectFlags: ["isTrustWallet"],
|
|
1113
|
+
deepLink: (url) => formatDeepLink("trust", url) ?? ""
|
|
1114
|
+
// ✅ Added
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
id: "okx",
|
|
1118
|
+
name: "OKX",
|
|
1119
|
+
category: "injected",
|
|
1120
|
+
ecosystem: "evm",
|
|
1121
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
|
|
1122
|
+
emoji: "\u2B1B",
|
|
1123
|
+
homepage: "https://www.okx.com/web3",
|
|
1124
|
+
ios: "https://apps.apple.com/app/okx-buy-bitcoin-eth-crypto/id1327268470",
|
|
1125
|
+
android: "https://play.google.com/store/apps/details?id=com.okinc.okex.gp",
|
|
1126
|
+
detectFlags: ["isOkxWallet"],
|
|
1127
|
+
deepLink: (url) => formatDeepLink("okx", url) ?? ""
|
|
1128
|
+
// ✅ Added
|
|
1081
1129
|
},
|
|
1082
1130
|
{
|
|
1083
1131
|
id: "phantom-evm",
|
|
@@ -1087,7 +1135,10 @@ var init_metadata = __esm({
|
|
|
1087
1135
|
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
1088
1136
|
emoji: "\u{1F47B}",
|
|
1089
1137
|
homepage: "https://phantom.app/",
|
|
1138
|
+
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1139
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1090
1140
|
detectFlags: ["isPhantom"]
|
|
1141
|
+
// No EVM dapp browser deep link — falls back to app store
|
|
1091
1142
|
},
|
|
1092
1143
|
{
|
|
1093
1144
|
id: "phantom-solana",
|
|
@@ -1097,18 +1148,9 @@ var init_metadata = __esm({
|
|
|
1097
1148
|
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
1098
1149
|
emoji: "\u{1F47B}",
|
|
1099
1150
|
homepage: "https://phantom.app/",
|
|
1100
|
-
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1101
1151
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
{
|
|
1105
|
-
id: "metamask-solana",
|
|
1106
|
-
name: "MetaMask (Solana)",
|
|
1107
|
-
category: "injected",
|
|
1108
|
-
ecosystem: "solana",
|
|
1109
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1110
|
-
emoji: "\u{1F98A}",
|
|
1111
|
-
homepage: "https://metamask.io/"
|
|
1152
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1153
|
+
deepLink: (url) => formatDeepLink("phantom-solana", url) ?? ""
|
|
1112
1154
|
},
|
|
1113
1155
|
{
|
|
1114
1156
|
id: "solflare",
|
|
@@ -1118,7 +1160,9 @@ var init_metadata = __esm({
|
|
|
1118
1160
|
logo: `${ASSETS_BASE_URL}/assets/wallets/solflare-logo.svg`,
|
|
1119
1161
|
emoji: "\u2600\uFE0F",
|
|
1120
1162
|
homepage: "https://solflare.com/",
|
|
1121
|
-
|
|
1163
|
+
ios: "https://apps.apple.com/app/solflare-solana-wallet/id1580902717",
|
|
1164
|
+
android: "https://play.google.com/store/apps/details?id=com.solflare.mobile",
|
|
1165
|
+
deepLink: (url) => formatDeepLink("solflare", url) ?? ""
|
|
1122
1166
|
},
|
|
1123
1167
|
{
|
|
1124
1168
|
id: "backpack",
|
|
@@ -1127,8 +1171,25 @@ var init_metadata = __esm({
|
|
|
1127
1171
|
ecosystem: "solana",
|
|
1128
1172
|
logo: `${ASSETS_BASE_URL}/assets/wallets/backpack-logo.svg`,
|
|
1129
1173
|
emoji: "\u{1F392}",
|
|
1130
|
-
homepage: "https://backpack.app/"
|
|
1174
|
+
homepage: "https://backpack.app/",
|
|
1175
|
+
ios: "https://apps.apple.com/app/backpack-crypto-wallet/id6445964121",
|
|
1176
|
+
android: "https://play.google.com/store/apps/details?id=app.backpack.mobile",
|
|
1177
|
+
deepLink: (url) => formatDeepLink("backpack", url) ?? ""
|
|
1178
|
+
// ✅ Added
|
|
1131
1179
|
},
|
|
1180
|
+
{
|
|
1181
|
+
id: "metamask-solana",
|
|
1182
|
+
name: "MetaMask (Solana)",
|
|
1183
|
+
category: "injected",
|
|
1184
|
+
ecosystem: "solana",
|
|
1185
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1186
|
+
emoji: "\u{1F98A}",
|
|
1187
|
+
homepage: "https://metamask.io/",
|
|
1188
|
+
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
1189
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
1190
|
+
// No Solana-specific deep link for MetaMask
|
|
1191
|
+
},
|
|
1192
|
+
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
1132
1193
|
{
|
|
1133
1194
|
id: "rabby",
|
|
1134
1195
|
name: "Rabby",
|
|
@@ -1139,6 +1200,7 @@ var init_metadata = __esm({
|
|
|
1139
1200
|
homepage: "https://rabby.io/",
|
|
1140
1201
|
chromeWebStore: "https://chromewebstore.google.com/detail/rabby/acmacodkjbdgmoleebolmdjonilkdbch",
|
|
1141
1202
|
detectFlags: ["isRabby"]
|
|
1203
|
+
// Extension only — no mobile app or deep link
|
|
1142
1204
|
},
|
|
1143
1205
|
{
|
|
1144
1206
|
id: "brave",
|
|
@@ -1149,25 +1211,7 @@ var init_metadata = __esm({
|
|
|
1149
1211
|
emoji: "\u{1F981}",
|
|
1150
1212
|
homepage: "https://brave.com/wallet/",
|
|
1151
1213
|
detectFlags: ["isBraveWallet"]
|
|
1152
|
-
|
|
1153
|
-
{
|
|
1154
|
-
id: "okx",
|
|
1155
|
-
name: "OKX",
|
|
1156
|
-
category: "injected",
|
|
1157
|
-
ecosystem: "evm",
|
|
1158
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
|
|
1159
|
-
emoji: "\u2B1B",
|
|
1160
|
-
homepage: "https://www.okx.com/web3",
|
|
1161
|
-
detectFlags: ["isOkxWallet"]
|
|
1162
|
-
},
|
|
1163
|
-
{
|
|
1164
|
-
id: "zerion",
|
|
1165
|
-
name: "Zerion",
|
|
1166
|
-
category: "app",
|
|
1167
|
-
ecosystem: "evm",
|
|
1168
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
|
|
1169
|
-
emoji: "\u{1F9FF}",
|
|
1170
|
-
homepage: "https://zerion.io/wallet/"
|
|
1214
|
+
// Built into Brave browser — no standalone deep link
|
|
1171
1215
|
},
|
|
1172
1216
|
{
|
|
1173
1217
|
id: "taho",
|
|
@@ -1178,16 +1222,7 @@ var init_metadata = __esm({
|
|
|
1178
1222
|
emoji: "\u{1F7EA}",
|
|
1179
1223
|
homepage: "https://taho.xyz/",
|
|
1180
1224
|
detectFlags: ["isTally", "isTallyWallet", "isTahoWallet"]
|
|
1181
|
-
|
|
1182
|
-
{
|
|
1183
|
-
id: "trust",
|
|
1184
|
-
name: "Trust Wallet",
|
|
1185
|
-
category: "app",
|
|
1186
|
-
ecosystem: "multi",
|
|
1187
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
|
|
1188
|
-
emoji: "\u{1F6E1}\uFE0F",
|
|
1189
|
-
homepage: "https://trustwallet.com/",
|
|
1190
|
-
detectFlags: ["isTrustWallet"]
|
|
1225
|
+
// Extension only — no mobile app
|
|
1191
1226
|
},
|
|
1192
1227
|
{
|
|
1193
1228
|
id: "bitget",
|
|
@@ -1197,7 +1232,22 @@ var init_metadata = __esm({
|
|
|
1197
1232
|
logo: `${ASSETS_BASE_URL}/assets/wallets/bitget.svg`,
|
|
1198
1233
|
emoji: "\u{1F7E9}",
|
|
1199
1234
|
homepage: "https://web3.bitget.com/",
|
|
1235
|
+
ios: "https://apps.apple.com/app/bitget-wallet-ex-bitkeep/id1395301115",
|
|
1236
|
+
android: "https://play.google.com/store/apps/details?id=com.bitkeep.wallet",
|
|
1200
1237
|
detectFlags: ["isBitGetWallet"]
|
|
1238
|
+
// No public deep link scheme documented
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
id: "zerion",
|
|
1242
|
+
name: "Zerion",
|
|
1243
|
+
category: "app",
|
|
1244
|
+
ecosystem: "evm",
|
|
1245
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
|
|
1246
|
+
emoji: "\u{1F9FF}",
|
|
1247
|
+
homepage: "https://zerion.io/wallet/",
|
|
1248
|
+
ios: "https://apps.apple.com/app/zerion-crypto-defi-wallet/id1456732565",
|
|
1249
|
+
android: "https://play.google.com/store/apps/details?id=io.zerion.android"
|
|
1250
|
+
// Uses WalletConnect URI — not a simple page URL deep link
|
|
1201
1251
|
},
|
|
1202
1252
|
{
|
|
1203
1253
|
id: "safe",
|
|
@@ -1206,7 +1256,10 @@ var init_metadata = __esm({
|
|
|
1206
1256
|
ecosystem: "evm",
|
|
1207
1257
|
logo: `${ASSETS_BASE_URL}/assets/wallets/safe.svg`,
|
|
1208
1258
|
emoji: "\u{1F7E9}",
|
|
1209
|
-
homepage: "https://safe.global/"
|
|
1259
|
+
homepage: "https://safe.global/",
|
|
1260
|
+
ios: "https://apps.apple.com/app/safe-gnosis-safe/id1515759131",
|
|
1261
|
+
android: "https://play.google.com/store/apps/details?id=io.gnosis.safe"
|
|
1262
|
+
// Uses WalletConnect — no dapp browser deep link
|
|
1210
1263
|
},
|
|
1211
1264
|
{
|
|
1212
1265
|
id: "kucoin",
|
|
@@ -1215,7 +1268,10 @@ var init_metadata = __esm({
|
|
|
1215
1268
|
ecosystem: "evm",
|
|
1216
1269
|
logo: `${ASSETS_BASE_URL}/assets/wallets/kucoin.svg`,
|
|
1217
1270
|
emoji: "\u{1F7E6}",
|
|
1218
|
-
homepage: "https://www.kucoin.com/"
|
|
1271
|
+
homepage: "https://www.kucoin.com/",
|
|
1272
|
+
ios: "https://apps.apple.com/app/kucoin-buy-bitcoin-crypto/id1378956601",
|
|
1273
|
+
android: "https://play.google.com/store/apps/details?id=com.kubi.kucoin"
|
|
1274
|
+
// No public deep link scheme documented
|
|
1219
1275
|
}
|
|
1220
1276
|
];
|
|
1221
1277
|
}
|
|
@@ -1394,6 +1450,14 @@ function useWalletDetection(timeoutMs = 400) {
|
|
|
1394
1450
|
);
|
|
1395
1451
|
return { detected, detectedIds };
|
|
1396
1452
|
}
|
|
1453
|
+
function useIsMobile() {
|
|
1454
|
+
const [isMobile, set] = useState(false);
|
|
1455
|
+
useEffect(() => {
|
|
1456
|
+
const ua = navigator.userAgent || "";
|
|
1457
|
+
set(/Android|iPhone|iPad|iPod/i.test(ua));
|
|
1458
|
+
}, []);
|
|
1459
|
+
return isMobile;
|
|
1460
|
+
}
|
|
1397
1461
|
var WALLET_BY_ID, DETECT_PRIORITY, GENERIC_FLAGS, RDNS_WALLET_MAP, NAME_WALLET_MAP;
|
|
1398
1462
|
var init_detect = __esm({
|
|
1399
1463
|
"src/wallets/detect.ts"() {
|
|
@@ -4031,6 +4095,7 @@ var init_wallets = __esm({
|
|
|
4031
4095
|
init_adapters();
|
|
4032
4096
|
init_solana();
|
|
4033
4097
|
init_detect();
|
|
4098
|
+
init_metadata();
|
|
4034
4099
|
}
|
|
4035
4100
|
});
|
|
4036
4101
|
|
|
@@ -16107,8 +16172,9 @@ var init_WalletNamespaceTabs = __esm({
|
|
|
16107
16172
|
});
|
|
16108
16173
|
|
|
16109
16174
|
// src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx
|
|
16110
|
-
import {
|
|
16111
|
-
|
|
16175
|
+
import { useEffect as useEffect23, useMemo as useMemo17, useRef as useRef10, useState as useState23 } from "react";
|
|
16176
|
+
import { Fragment as Fragment7, jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
16177
|
+
function DesktopWalletDropdownContent({
|
|
16112
16178
|
browserWallets,
|
|
16113
16179
|
handleWalletConnect,
|
|
16114
16180
|
handleWalletSelect
|
|
@@ -16172,6 +16238,262 @@ function CryptoWalletDropdownContent({
|
|
|
16172
16238
|
}
|
|
16173
16239
|
);
|
|
16174
16240
|
}
|
|
16241
|
+
function MobileWalletDropdownContent({
|
|
16242
|
+
handleWalletConnect
|
|
16243
|
+
}) {
|
|
16244
|
+
const { setCurrentStep } = useDepositNavigation();
|
|
16245
|
+
const { selectedNamespace } = useDepositWallet();
|
|
16246
|
+
const { walletMetaId, isConnected, status } = useWalletInfo();
|
|
16247
|
+
const [hoveredId, setHoveredId] = useState23(null);
|
|
16248
|
+
const storeFallbackTimeoutRef = useRef10(
|
|
16249
|
+
null
|
|
16250
|
+
);
|
|
16251
|
+
useEffect23(() => {
|
|
16252
|
+
return () => {
|
|
16253
|
+
if (storeFallbackTimeoutRef.current !== null) {
|
|
16254
|
+
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16255
|
+
}
|
|
16256
|
+
};
|
|
16257
|
+
}, []);
|
|
16258
|
+
const connectedWalletId = isConnected ? walletMetaId : null;
|
|
16259
|
+
const currentUrl = window.location.href;
|
|
16260
|
+
const mobileWallets = useMemo17(
|
|
16261
|
+
() => WALLETS.filter((w) => {
|
|
16262
|
+
if (w.id === "walletconnect") return true;
|
|
16263
|
+
const hasMobileLink = Boolean(w.deepLink || w.ios || w.android);
|
|
16264
|
+
if (!hasMobileLink) return false;
|
|
16265
|
+
return w.ecosystem.trim().toLowerCase() === "multi" || w.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase();
|
|
16266
|
+
}),
|
|
16267
|
+
[selectedNamespace]
|
|
16268
|
+
);
|
|
16269
|
+
const handleWalletSelect = (wallet) => {
|
|
16270
|
+
if (wallet.id === "walletconnect") {
|
|
16271
|
+
handleWalletConnect();
|
|
16272
|
+
return;
|
|
16273
|
+
}
|
|
16274
|
+
if (wallet.deepLink) {
|
|
16275
|
+
const deepLinkUrl = wallet.deepLink(currentUrl);
|
|
16276
|
+
if (deepLinkUrl) {
|
|
16277
|
+
window.location.assign(deepLinkUrl);
|
|
16278
|
+
if (storeFallbackTimeoutRef.current !== null) {
|
|
16279
|
+
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16280
|
+
}
|
|
16281
|
+
storeFallbackTimeoutRef.current = setTimeout(() => {
|
|
16282
|
+
storeFallbackTimeoutRef.current = null;
|
|
16283
|
+
const isIos2 = /iPhone|iPad/i.test(navigator.userAgent);
|
|
16284
|
+
const storeUrl2 = isIos2 ? wallet.ios : wallet.android;
|
|
16285
|
+
if (storeUrl2) window.location.assign(storeUrl2);
|
|
16286
|
+
}, 1500);
|
|
16287
|
+
return;
|
|
16288
|
+
}
|
|
16289
|
+
}
|
|
16290
|
+
const isIos = /iPhone|iPad/i.test(navigator.userAgent);
|
|
16291
|
+
const storeUrl = isIos ? wallet.ios : wallet.android;
|
|
16292
|
+
if (storeUrl) window.location.assign(storeUrl);
|
|
16293
|
+
};
|
|
16294
|
+
const handleContinue = () => {
|
|
16295
|
+
if (isConnected && status === "connected") {
|
|
16296
|
+
setCurrentStep("crypto-pay");
|
|
16297
|
+
} else {
|
|
16298
|
+
alert("Please connect your wallet first.");
|
|
16299
|
+
}
|
|
16300
|
+
};
|
|
16301
|
+
const showContinueButton = useMemo17(
|
|
16302
|
+
() => isConnected && status === "connected",
|
|
16303
|
+
[isConnected, status]
|
|
16304
|
+
);
|
|
16305
|
+
return /* @__PURE__ */ jsxs30(
|
|
16306
|
+
"div",
|
|
16307
|
+
{
|
|
16308
|
+
style: {
|
|
16309
|
+
...dropdownSurfaceStyle,
|
|
16310
|
+
maxHeight: "16rem",
|
|
16311
|
+
backgroundColor: colors.card,
|
|
16312
|
+
borderRadius: borderRadius.xl,
|
|
16313
|
+
boxShadow: shadows.large,
|
|
16314
|
+
border: `1px solid rgba(63, 63, 70, 0.5)`,
|
|
16315
|
+
zIndex: 100,
|
|
16316
|
+
overflow: "hidden",
|
|
16317
|
+
// changed from auto
|
|
16318
|
+
animation: "tw-fade-in 0.2s ease-out",
|
|
16319
|
+
display: "flex",
|
|
16320
|
+
flexDirection: "column"
|
|
16321
|
+
},
|
|
16322
|
+
children: [
|
|
16323
|
+
/* @__PURE__ */ jsx36(
|
|
16324
|
+
"div",
|
|
16325
|
+
{
|
|
16326
|
+
style: {
|
|
16327
|
+
width: "100%",
|
|
16328
|
+
padding: spacing[2]
|
|
16329
|
+
},
|
|
16330
|
+
children: /* @__PURE__ */ jsx36("div", { style: { display: "flex", gap: spacing[2] }, children: /* @__PURE__ */ jsx36(WalletNamespaceTabs, { showBitcoin: false }) })
|
|
16331
|
+
}
|
|
16332
|
+
),
|
|
16333
|
+
/* @__PURE__ */ jsx36(
|
|
16334
|
+
"div",
|
|
16335
|
+
{
|
|
16336
|
+
style: {
|
|
16337
|
+
padding: spacing[3],
|
|
16338
|
+
overflowY: "auto",
|
|
16339
|
+
flex: 1,
|
|
16340
|
+
scrollbarWidth: "thin",
|
|
16341
|
+
scrollbarColor: `${colors.muted} transparent`
|
|
16342
|
+
},
|
|
16343
|
+
children: mobileWallets.map((wallet) => {
|
|
16344
|
+
const isConnectedWallet = wallet.id === connectedWalletId;
|
|
16345
|
+
const isDisabled = isConnected && !isConnectedWallet;
|
|
16346
|
+
const isHovered = hoveredId === wallet.id;
|
|
16347
|
+
return /* @__PURE__ */ jsxs30(
|
|
16348
|
+
"button",
|
|
16349
|
+
{
|
|
16350
|
+
type: "button",
|
|
16351
|
+
onClick: () => !isDisabled && handleWalletSelect(wallet),
|
|
16352
|
+
onMouseEnter: () => !isDisabled && setHoveredId(wallet.id),
|
|
16353
|
+
onMouseLeave: () => setHoveredId(null),
|
|
16354
|
+
style: {
|
|
16355
|
+
width: "100%",
|
|
16356
|
+
display: "flex",
|
|
16357
|
+
alignItems: "center",
|
|
16358
|
+
justifyContent: "space-between",
|
|
16359
|
+
padding: spacing[2],
|
|
16360
|
+
borderRadius: borderRadius.lg,
|
|
16361
|
+
transition: "background-color 0.2s",
|
|
16362
|
+
border: "none",
|
|
16363
|
+
backgroundColor: isHovered ? "rgba(255,255,255,0.06)" : "transparent",
|
|
16364
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
16365
|
+
opacity: isDisabled ? 0.4 : 1,
|
|
16366
|
+
fontFamily: "inherit",
|
|
16367
|
+
fontSize: fontSize.sm,
|
|
16368
|
+
outline: "none"
|
|
16369
|
+
},
|
|
16370
|
+
children: [
|
|
16371
|
+
/* @__PURE__ */ jsxs30(
|
|
16372
|
+
"div",
|
|
16373
|
+
{
|
|
16374
|
+
style: {
|
|
16375
|
+
display: "flex",
|
|
16376
|
+
alignItems: "center",
|
|
16377
|
+
gap: spacing[2]
|
|
16378
|
+
},
|
|
16379
|
+
children: [
|
|
16380
|
+
/* @__PURE__ */ jsx36(
|
|
16381
|
+
"img",
|
|
16382
|
+
{
|
|
16383
|
+
src: wallet.logo ?? wallet.emoji,
|
|
16384
|
+
alt: wallet.name,
|
|
16385
|
+
style: {
|
|
16386
|
+
width: "2rem",
|
|
16387
|
+
height: "2rem",
|
|
16388
|
+
borderRadius: borderRadius.lg,
|
|
16389
|
+
objectFit: "cover"
|
|
16390
|
+
}
|
|
16391
|
+
}
|
|
16392
|
+
),
|
|
16393
|
+
/* @__PURE__ */ jsx36(
|
|
16394
|
+
"span",
|
|
16395
|
+
{
|
|
16396
|
+
style: {
|
|
16397
|
+
fontWeight: fontWeight.medium,
|
|
16398
|
+
fontSize: fontSize.sm,
|
|
16399
|
+
color: colors.foreground
|
|
16400
|
+
},
|
|
16401
|
+
children: wallet.name
|
|
16402
|
+
}
|
|
16403
|
+
)
|
|
16404
|
+
]
|
|
16405
|
+
}
|
|
16406
|
+
),
|
|
16407
|
+
isConnectedWallet && /* @__PURE__ */ jsxs30(
|
|
16408
|
+
"div",
|
|
16409
|
+
{
|
|
16410
|
+
style: {
|
|
16411
|
+
display: "flex",
|
|
16412
|
+
alignItems: "center",
|
|
16413
|
+
gap: spacing[1]
|
|
16414
|
+
},
|
|
16415
|
+
children: [
|
|
16416
|
+
/* @__PURE__ */ jsx36(
|
|
16417
|
+
"div",
|
|
16418
|
+
{
|
|
16419
|
+
style: {
|
|
16420
|
+
width: "0.5rem",
|
|
16421
|
+
height: "0.5rem",
|
|
16422
|
+
borderRadius: "50%",
|
|
16423
|
+
backgroundColor: "#22c55e"
|
|
16424
|
+
}
|
|
16425
|
+
}
|
|
16426
|
+
),
|
|
16427
|
+
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "Connected" })
|
|
16428
|
+
]
|
|
16429
|
+
}
|
|
16430
|
+
)
|
|
16431
|
+
]
|
|
16432
|
+
},
|
|
16433
|
+
wallet.id
|
|
16434
|
+
);
|
|
16435
|
+
})
|
|
16436
|
+
}
|
|
16437
|
+
),
|
|
16438
|
+
showContinueButton && /* @__PURE__ */ jsx36(
|
|
16439
|
+
"div",
|
|
16440
|
+
{
|
|
16441
|
+
style: {
|
|
16442
|
+
padding: spacing[3],
|
|
16443
|
+
borderTop: `1px solid rgba(63, 63, 70, 0.5)`,
|
|
16444
|
+
backgroundColor: colors.card
|
|
16445
|
+
},
|
|
16446
|
+
children: /* @__PURE__ */ jsx36(
|
|
16447
|
+
"button",
|
|
16448
|
+
{
|
|
16449
|
+
onClick: handleContinue,
|
|
16450
|
+
style: {
|
|
16451
|
+
width: "100%",
|
|
16452
|
+
padding: `${spacing[2]} ${spacing[3]}`,
|
|
16453
|
+
borderRadius: borderRadius.lg,
|
|
16454
|
+
border: "none",
|
|
16455
|
+
backgroundColor: colors.primary,
|
|
16456
|
+
color: "#fff",
|
|
16457
|
+
fontFamily: "inherit",
|
|
16458
|
+
fontSize: fontSize.sm,
|
|
16459
|
+
fontWeight: fontWeight.medium,
|
|
16460
|
+
cursor: "pointer",
|
|
16461
|
+
transition: "opacity 0.2s"
|
|
16462
|
+
},
|
|
16463
|
+
onMouseEnter: (e2) => e2.currentTarget.style.opacity = "0.85",
|
|
16464
|
+
onMouseLeave: (e2) => e2.currentTarget.style.opacity = "1",
|
|
16465
|
+
children: "Continue \u2192"
|
|
16466
|
+
}
|
|
16467
|
+
)
|
|
16468
|
+
}
|
|
16469
|
+
)
|
|
16470
|
+
]
|
|
16471
|
+
}
|
|
16472
|
+
);
|
|
16473
|
+
}
|
|
16474
|
+
function CryptoWalletDropdownContent({
|
|
16475
|
+
browserWallets,
|
|
16476
|
+
handleWalletConnect,
|
|
16477
|
+
handleWalletSelect
|
|
16478
|
+
}) {
|
|
16479
|
+
const isMobile = useIsMobile();
|
|
16480
|
+
return /* @__PURE__ */ jsxs30(Fragment7, { children: [
|
|
16481
|
+
!isMobile && /* @__PURE__ */ jsx36(
|
|
16482
|
+
DesktopWalletDropdownContent,
|
|
16483
|
+
{
|
|
16484
|
+
browserWallets,
|
|
16485
|
+
handleWalletConnect,
|
|
16486
|
+
handleWalletSelect
|
|
16487
|
+
}
|
|
16488
|
+
),
|
|
16489
|
+
isMobile && /* @__PURE__ */ jsx36(
|
|
16490
|
+
MobileWalletDropdownContent,
|
|
16491
|
+
{
|
|
16492
|
+
handleWalletConnect
|
|
16493
|
+
}
|
|
16494
|
+
)
|
|
16495
|
+
] });
|
|
16496
|
+
}
|
|
16175
16497
|
var init_CryptoWalletDropdownContent = __esm({
|
|
16176
16498
|
"src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx"() {
|
|
16177
16499
|
"use strict";
|
|
@@ -16182,6 +16504,7 @@ var init_CryptoWalletDropdownContent = __esm({
|
|
|
16182
16504
|
init_paymentOptionStyles();
|
|
16183
16505
|
init_WalletNamespaceTabs();
|
|
16184
16506
|
init_DepositContext();
|
|
16507
|
+
init_wallets();
|
|
16185
16508
|
}
|
|
16186
16509
|
});
|
|
16187
16510
|
|
|
@@ -16636,7 +16959,7 @@ var init_HomePaymentOptions = __esm({
|
|
|
16636
16959
|
});
|
|
16637
16960
|
|
|
16638
16961
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
16639
|
-
import { useCallback as useCallback18, useEffect as
|
|
16962
|
+
import { useCallback as useCallback18, useEffect as useEffect24, useMemo as useMemo18, useRef as useRef11, useState as useState24 } from "react";
|
|
16640
16963
|
function useHomeWalletActions({
|
|
16641
16964
|
connectWallet,
|
|
16642
16965
|
detectedWallets,
|
|
@@ -16645,12 +16968,12 @@ function useHomeWalletActions({
|
|
|
16645
16968
|
WalletConnect
|
|
16646
16969
|
// setCurrentStepInternal,
|
|
16647
16970
|
}) {
|
|
16648
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] =
|
|
16649
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] =
|
|
16650
|
-
const cryptoDropdownRef =
|
|
16651
|
-
const fiatDropdownRef =
|
|
16971
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = useState24(false);
|
|
16972
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = useState24(false);
|
|
16973
|
+
const cryptoDropdownRef = useRef11(null);
|
|
16974
|
+
const fiatDropdownRef = useRef11(null);
|
|
16652
16975
|
const { disconnect } = useWalletInfo();
|
|
16653
|
-
|
|
16976
|
+
useEffect24(() => {
|
|
16654
16977
|
const handleClickOutside = (event) => {
|
|
16655
16978
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
16656
16979
|
setIsCryptoDropdownOpen(false);
|
|
@@ -16676,6 +16999,7 @@ function useHomeWalletActions({
|
|
|
16676
16999
|
setWalletType("other");
|
|
16677
17000
|
const { error } = await connectWallet(wallet);
|
|
16678
17001
|
if (error) {
|
|
17002
|
+
console.error("Wallet connection error:", error);
|
|
16679
17003
|
resetNavigation();
|
|
16680
17004
|
return;
|
|
16681
17005
|
}
|
|
@@ -16697,7 +17021,7 @@ function useHomeWalletActions({
|
|
|
16697
17021
|
WalletConnect().catch(() => resetNavigation());
|
|
16698
17022
|
}, [setYourWalletTokens, disconnect]);
|
|
16699
17023
|
const { selectedNamespace } = useDepositWallet();
|
|
16700
|
-
const browserWallets =
|
|
17024
|
+
const browserWallets = useMemo18(() => {
|
|
16701
17025
|
if (!detectedWallets?.length) return [];
|
|
16702
17026
|
return detectedWallets.filter(
|
|
16703
17027
|
(wallet) => wallet?.meta?.id !== "walletconnect" && wallet?.meta?.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase()
|
|
@@ -17109,7 +17433,7 @@ var init_relayFeeUtils = __esm({
|
|
|
17109
17433
|
});
|
|
17110
17434
|
|
|
17111
17435
|
// src/widget/features/route-preview/hooks/useRoutePreviewModel.ts
|
|
17112
|
-
import { useMemo as
|
|
17436
|
+
import { useMemo as useMemo19 } from "react";
|
|
17113
17437
|
function useRoutePreviewModel({
|
|
17114
17438
|
amountUsd,
|
|
17115
17439
|
amountValidationError,
|
|
@@ -17122,7 +17446,7 @@ function useRoutePreviewModel({
|
|
|
17122
17446
|
walletAddress
|
|
17123
17447
|
}) {
|
|
17124
17448
|
const { chains } = useChains();
|
|
17125
|
-
const destinationConfig =
|
|
17449
|
+
const destinationConfig = useMemo19(
|
|
17126
17450
|
() => ({
|
|
17127
17451
|
dappName: config.messages?.title || "DApp",
|
|
17128
17452
|
toChain: config.routes.toChain,
|
|
@@ -17136,7 +17460,7 @@ function useRoutePreviewModel({
|
|
|
17136
17460
|
config.routes.toToken
|
|
17137
17461
|
]
|
|
17138
17462
|
);
|
|
17139
|
-
const routeConfig =
|
|
17463
|
+
const routeConfig = useMemo19(() => {
|
|
17140
17464
|
const toChainId = config.routes.toChain;
|
|
17141
17465
|
const toChainKey = normalizeChainKey2(toChainId);
|
|
17142
17466
|
const toChain = toChainKey ? chains.find(
|
|
@@ -17173,7 +17497,7 @@ function useRoutePreviewModel({
|
|
|
17173
17497
|
...routeConfig,
|
|
17174
17498
|
enabled: !!isReady
|
|
17175
17499
|
});
|
|
17176
|
-
const routePrerequisiteError =
|
|
17500
|
+
const routePrerequisiteError = useMemo19(() => {
|
|
17177
17501
|
if (!isReady) return;
|
|
17178
17502
|
if (!selectedChain) {
|
|
17179
17503
|
return "Select a source chain to fetch a route.";
|
|
@@ -30755,7 +31079,7 @@ var init_smart_account2 = __esm({
|
|
|
30755
31079
|
});
|
|
30756
31080
|
|
|
30757
31081
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
30758
|
-
import { useCallback as useCallback19, useEffect as
|
|
31082
|
+
import { useCallback as useCallback19, useEffect as useEffect25, useMemo as useMemo20, useRef as useRef12, useState as useState25 } from "react";
|
|
30759
31083
|
import { encodeFunctionData as encodeFunctionData8, erc20Abi } from "viem";
|
|
30760
31084
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
30761
31085
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
@@ -30777,7 +31101,7 @@ function useTransactionActionModel({
|
|
|
30777
31101
|
walletAddress,
|
|
30778
31102
|
walletStatus
|
|
30779
31103
|
}) {
|
|
30780
|
-
const feeDataCacheRef =
|
|
31104
|
+
const feeDataCacheRef = useRef12({});
|
|
30781
31105
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
30782
31106
|
const { trackEvent } = useGTM(GTM_ID);
|
|
30783
31107
|
const destinationConfig = (() => {
|
|
@@ -30790,7 +31114,7 @@ function useTransactionActionModel({
|
|
|
30790
31114
|
const chainType = selectedChain?.type ?? selectedChain?.chainType;
|
|
30791
31115
|
const chainTypeNormalized = (chainType ?? "").toLowerCase();
|
|
30792
31116
|
const isEvm = chainTypeNormalized === "evm";
|
|
30793
|
-
const backendChainId2 =
|
|
31117
|
+
const backendChainId2 = useMemo20(() => {
|
|
30794
31118
|
const chainRef = routeResult?.txReq?.chainId ?? selectedChain?.networkIdentifier ?? selectedChain?.chainId ?? selectedChain?.id;
|
|
30795
31119
|
if (chainRef == null) return null;
|
|
30796
31120
|
return String(chainRef);
|
|
@@ -30800,7 +31124,7 @@ function useTransactionActionModel({
|
|
|
30800
31124
|
selectedChain?.id,
|
|
30801
31125
|
selectedChain?.networkIdentifier
|
|
30802
31126
|
]);
|
|
30803
|
-
const selectedTokenOnBackendChain =
|
|
31127
|
+
const selectedTokenOnBackendChain = useMemo20(() => {
|
|
30804
31128
|
if (!backendChainId2) return false;
|
|
30805
31129
|
const target = normalizeChainKey2(backendChainId2);
|
|
30806
31130
|
return [
|
|
@@ -30817,22 +31141,22 @@ function useTransactionActionModel({
|
|
|
30817
31141
|
selectedChain?.id,
|
|
30818
31142
|
selectedChain?.networkIdentifier
|
|
30819
31143
|
]);
|
|
30820
|
-
const isNativeSelected =
|
|
31144
|
+
const isNativeSelected = useMemo20(() => {
|
|
30821
31145
|
const address = selectedToken?.address;
|
|
30822
31146
|
return isNativeTokenAddress(address, chainType) || isZeroAddrLike(address, chainType) || normalizeTokenAddressForCompare(selectedChain, address) === normalizeTokenAddressForCompare(
|
|
30823
31147
|
selectedChain,
|
|
30824
31148
|
getNativeTokenAddress2(chainType)
|
|
30825
31149
|
);
|
|
30826
31150
|
}, [chainType, selectedChain, selectedToken?.address]);
|
|
30827
|
-
const spender =
|
|
31151
|
+
const spender = useMemo20(() => {
|
|
30828
31152
|
const txReq = routeResult?.txReq;
|
|
30829
31153
|
const addr = txReq?.to ?? txReq?.target;
|
|
30830
31154
|
return addr ?? null;
|
|
30831
31155
|
}, [routeResult?.txReq]);
|
|
30832
|
-
const [allowanceWei, setAllowanceWei] =
|
|
30833
|
-
const [isReadingAllowance, setIsReadingAllowance] =
|
|
30834
|
-
const [isApproving, setIsApproving] =
|
|
30835
|
-
const [gasReservationWei, setGasReservationWei] =
|
|
31156
|
+
const [allowanceWei, setAllowanceWei] = useState25(0n);
|
|
31157
|
+
const [isReadingAllowance, setIsReadingAllowance] = useState25(false);
|
|
31158
|
+
const [isApproving, setIsApproving] = useState25(false);
|
|
31159
|
+
const [gasReservationWei, setGasReservationWei] = useState25(0n);
|
|
30836
31160
|
const readAllowance = useCallback19(async () => {
|
|
30837
31161
|
if (!isEvm || isNativeSelected || !!routeResult?.sponsorship || // sponsored routes: SA approves bridge inside the UO batch
|
|
30838
31162
|
!backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
@@ -30863,7 +31187,7 @@ function useTransactionActionModel({
|
|
|
30863
31187
|
spender,
|
|
30864
31188
|
walletAddress
|
|
30865
31189
|
]);
|
|
30866
|
-
|
|
31190
|
+
useEffect25(() => {
|
|
30867
31191
|
void readAllowance();
|
|
30868
31192
|
}, [readAllowance]);
|
|
30869
31193
|
const needsApproval = isEvm && !isNativeSelected && !routeResult?.sponsorship && // sponsored routes use Permit2 + SA internal batch — no EOA bridge approval
|
|
@@ -31067,13 +31391,13 @@ function useTransactionActionModel({
|
|
|
31067
31391
|
routeResult?.txReq,
|
|
31068
31392
|
walletAddress
|
|
31069
31393
|
]);
|
|
31070
|
-
|
|
31394
|
+
useEffect25(() => {
|
|
31071
31395
|
if (routeResult) {
|
|
31072
31396
|
void estimateGasReservationWei();
|
|
31073
31397
|
}
|
|
31074
31398
|
}, [estimateGasReservationWei, routeResult]);
|
|
31075
|
-
const [smartAccountFailed, setSmartAccountFailed] =
|
|
31076
|
-
|
|
31399
|
+
const [smartAccountFailed, setSmartAccountFailed] = useState25(false);
|
|
31400
|
+
useEffect25(() => {
|
|
31077
31401
|
setSmartAccountFailed(false);
|
|
31078
31402
|
}, [routeResult?.intentId]);
|
|
31079
31403
|
const handleConfirm = useCallback19(async () => {
|
|
@@ -31177,7 +31501,7 @@ function useTransactionActionModel({
|
|
|
31177
31501
|
]);
|
|
31178
31502
|
const isWalletConnected = walletStatus === "connected";
|
|
31179
31503
|
const canSwipe = parsedAmount > 0 && !!selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
|
|
31180
|
-
const swipeResetKey =
|
|
31504
|
+
const swipeResetKey = useMemo20(() => {
|
|
31181
31505
|
const tokenAddress = selectedToken ? normalizeAddress2(
|
|
31182
31506
|
selectedToken.address,
|
|
31183
31507
|
selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType
|
|
@@ -31407,12 +31731,12 @@ var init_DefaultCryptoPay = __esm({
|
|
|
31407
31731
|
});
|
|
31408
31732
|
|
|
31409
31733
|
// src/widget/pages/CryptoPay/RouteQuoteLoader.tsx
|
|
31410
|
-
import { useState as
|
|
31734
|
+
import { useState as useState26, useEffect as useEffect26 } from "react";
|
|
31411
31735
|
import { jsx as jsx49, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
31412
31736
|
function RouteQuoteLoader({ selectedToken }) {
|
|
31413
|
-
const [messageIndex, setMessageIndex] =
|
|
31414
|
-
const [visible, setVisible] =
|
|
31415
|
-
|
|
31737
|
+
const [messageIndex, setMessageIndex] = useState26(0);
|
|
31738
|
+
const [visible, setVisible] = useState26(true);
|
|
31739
|
+
useEffect26(() => {
|
|
31416
31740
|
let t = null;
|
|
31417
31741
|
const interval = setInterval(() => {
|
|
31418
31742
|
setVisible(false);
|
|
@@ -31588,8 +31912,8 @@ var init_RouteQuoteLoader = __esm({
|
|
|
31588
31912
|
});
|
|
31589
31913
|
|
|
31590
31914
|
// src/widget/pages/CryptoPay/index.tsx
|
|
31591
|
-
import { useEffect as
|
|
31592
|
-
import { Fragment as
|
|
31915
|
+
import { useEffect as useEffect27, useMemo as useMemo21 } from "react";
|
|
31916
|
+
import { Fragment as Fragment8, jsx as jsx50, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
31593
31917
|
function CryptoPay({ style: _style }) {
|
|
31594
31918
|
const {
|
|
31595
31919
|
amount,
|
|
@@ -31612,17 +31936,17 @@ function CryptoPay({ style: _style }) {
|
|
|
31612
31936
|
const { goBack, setCurrentStep, currentStep } = useDepositNavigation();
|
|
31613
31937
|
const config = useTrustwareConfig();
|
|
31614
31938
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
31615
|
-
const routeRefreshMs =
|
|
31939
|
+
const routeRefreshMs = useMemo21(() => {
|
|
31616
31940
|
const raw = config.routes?.options?.routeRefreshMs;
|
|
31617
31941
|
const n = Number(raw);
|
|
31618
31942
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
31619
31943
|
}, [config.routes?.options?.routeRefreshMs]);
|
|
31620
31944
|
const IsPos = (x) => x !== null && x !== void 0 && x.balance !== "0";
|
|
31621
|
-
const showDefaultCryptoPay =
|
|
31945
|
+
const showDefaultCryptoPay = useMemo21(() => {
|
|
31622
31946
|
const nonZer0Tks = (yourWalletTokens ?? []).filter(IsPos);
|
|
31623
31947
|
return !yourWalletTokensLoading && nonZer0Tks.length === 0 && yourWalletTokens.length > 0;
|
|
31624
31948
|
}, [yourWalletTokens, yourWalletTokensLoading]);
|
|
31625
|
-
const showSkeleton =
|
|
31949
|
+
const showSkeleton = useMemo21(() => {
|
|
31626
31950
|
return (yourWalletTokens ?? []).length === 0;
|
|
31627
31951
|
}, [yourWalletTokens]);
|
|
31628
31952
|
const isReady = selectedToken != null && selectedToken?.chainData !== void 0 && !showDefaultCryptoPay && !showSkeleton;
|
|
@@ -31698,7 +32022,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31698
32022
|
});
|
|
31699
32023
|
const { emitError } = useTrustware();
|
|
31700
32024
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
31701
|
-
|
|
32025
|
+
useEffect27(() => {
|
|
31702
32026
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
31703
32027
|
emitError?.(
|
|
31704
32028
|
new TrustwareError({
|
|
@@ -31727,7 +32051,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31727
32051
|
if (isFixedAmount) return;
|
|
31728
32052
|
setAmount(value.toString());
|
|
31729
32053
|
};
|
|
31730
|
-
const relayFeeUsd =
|
|
32054
|
+
const relayFeeUsd = useMemo21(
|
|
31731
32055
|
() => computeRelayFeeUsd(routeResult, isNativeSelected),
|
|
31732
32056
|
[isNativeSelected, routeResult]
|
|
31733
32057
|
);
|
|
@@ -31828,7 +32152,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31828
32152
|
]
|
|
31829
32153
|
}
|
|
31830
32154
|
),
|
|
31831
|
-
showSkeleton ? /* @__PURE__ */ jsx50(
|
|
32155
|
+
showSkeleton ? /* @__PURE__ */ jsx50(Fragment8, { children: /* @__PURE__ */ jsx50(
|
|
31832
32156
|
"div",
|
|
31833
32157
|
{
|
|
31834
32158
|
style: {
|
|
@@ -31839,8 +32163,8 @@ function CryptoPay({ style: _style }) {
|
|
|
31839
32163
|
},
|
|
31840
32164
|
children: /* @__PURE__ */ jsx50(LoadingSkeleton, {})
|
|
31841
32165
|
}
|
|
31842
|
-
) }) : /* @__PURE__ */ jsxs40(
|
|
31843
|
-
isReady && /* @__PURE__ */ jsx50(
|
|
32166
|
+
) }) : /* @__PURE__ */ jsxs40(Fragment8, { children: [
|
|
32167
|
+
isReady && /* @__PURE__ */ jsx50(Fragment8, { children: isLoadingRoute && !routeResult ? /* @__PURE__ */ jsx50(RouteQuoteLoader, { selectedToken: readySelectedToken }) : /* @__PURE__ */ jsxs40(Fragment8, { children: [
|
|
31844
32168
|
/* @__PURE__ */ jsx50(
|
|
31845
32169
|
CryptoPayAmountSection,
|
|
31846
32170
|
{
|
|
@@ -31919,7 +32243,7 @@ var init_CryptoPay = __esm({
|
|
|
31919
32243
|
});
|
|
31920
32244
|
|
|
31921
32245
|
// src/widget/pages/Processing.tsx
|
|
31922
|
-
import { useEffect as
|
|
32246
|
+
import { useEffect as useEffect28, useMemo as useMemo22, useRef as useRef13 } from "react";
|
|
31923
32247
|
import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
31924
32248
|
function getProgressFromStatus(status) {
|
|
31925
32249
|
switch (status) {
|
|
@@ -31958,27 +32282,27 @@ function Processing({ style }) {
|
|
|
31958
32282
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
31959
32283
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
31960
32284
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
31961
|
-
const hasStartedPolling =
|
|
31962
|
-
|
|
32285
|
+
const hasStartedPolling = useRef13(false);
|
|
32286
|
+
useEffect28(() => {
|
|
31963
32287
|
return () => {
|
|
31964
32288
|
hasStartedPolling.current = false;
|
|
31965
32289
|
};
|
|
31966
32290
|
}, []);
|
|
31967
|
-
|
|
32291
|
+
useEffect28(() => {
|
|
31968
32292
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
31969
32293
|
hasStartedPolling.current = true;
|
|
31970
32294
|
startPolling(intentId, transactionHash);
|
|
31971
32295
|
}
|
|
31972
32296
|
}, [intentId, transactionHash, isPolling, transactionStatus, startPolling]);
|
|
31973
|
-
const progress =
|
|
32297
|
+
const progress = useMemo22(
|
|
31974
32298
|
() => getProgressFromStatus(transactionStatus),
|
|
31975
32299
|
[transactionStatus]
|
|
31976
32300
|
);
|
|
31977
|
-
const stepText =
|
|
32301
|
+
const stepText = useMemo22(
|
|
31978
32302
|
() => getStepText(transactionStatus),
|
|
31979
32303
|
[transactionStatus]
|
|
31980
32304
|
);
|
|
31981
|
-
const explorerUrl =
|
|
32305
|
+
const explorerUrl = useMemo22(() => {
|
|
31982
32306
|
if (transaction?.fromChainTxUrl) {
|
|
31983
32307
|
return transaction.fromChainTxUrl;
|
|
31984
32308
|
}
|
|
@@ -32124,15 +32448,15 @@ var init_Processing = __esm({
|
|
|
32124
32448
|
});
|
|
32125
32449
|
|
|
32126
32450
|
// src/widget/pages/Success.tsx
|
|
32127
|
-
import { lazy, Suspense, useMemo as
|
|
32451
|
+
import { lazy, Suspense, useMemo as useMemo23 } from "react";
|
|
32128
32452
|
import { jsx as jsx52, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
32129
32453
|
function Success({ style }) {
|
|
32130
32454
|
const { selectedToken, selectedChain, amount } = useDepositForm();
|
|
32131
32455
|
const { resetState } = useDepositNavigation();
|
|
32132
32456
|
const { transactionHash } = useDepositTransaction();
|
|
32133
32457
|
const { transaction } = useTransactionPolling();
|
|
32134
|
-
const parsedAmount =
|
|
32135
|
-
const explorerUrl =
|
|
32458
|
+
const parsedAmount = useMemo23(() => parseFloat(amount) || 0, [amount]);
|
|
32459
|
+
const explorerUrl = useMemo23(() => {
|
|
32136
32460
|
if (transaction?.toChainTxUrl) {
|
|
32137
32461
|
return transaction.toChainTxUrl;
|
|
32138
32462
|
}
|
|
@@ -32353,7 +32677,7 @@ var init_mapError = __esm({
|
|
|
32353
32677
|
});
|
|
32354
32678
|
|
|
32355
32679
|
// src/widget/pages/Error.tsx
|
|
32356
|
-
import { useMemo as
|
|
32680
|
+
import { useMemo as useMemo24 } from "react";
|
|
32357
32681
|
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
32358
32682
|
function Error2({ style: _style }) {
|
|
32359
32683
|
const { selectedChain } = useDepositForm();
|
|
@@ -32364,8 +32688,8 @@ function Error2({ style: _style }) {
|
|
|
32364
32688
|
setErrorMessage,
|
|
32365
32689
|
transactionHash
|
|
32366
32690
|
} = useDepositTransaction();
|
|
32367
|
-
const mapped =
|
|
32368
|
-
const explorerUrl =
|
|
32691
|
+
const mapped = useMemo24(() => mapError(errorMessage), [errorMessage]);
|
|
32692
|
+
const explorerUrl = useMemo24(() => {
|
|
32369
32693
|
if (transactionHash && selectedChain?.blockExplorerUrls?.length) {
|
|
32370
32694
|
return `${selectedChain.blockExplorerUrls[0].replace(/\/+$/, "")}/tx/${transactionHash}`;
|
|
32371
32695
|
}
|
|
@@ -32425,18 +32749,18 @@ var init_widgetSteps = __esm({
|
|
|
32425
32749
|
});
|
|
32426
32750
|
|
|
32427
32751
|
// src/widget/app/WidgetRouter.tsx
|
|
32428
|
-
import { useMemo as
|
|
32752
|
+
import { useMemo as useMemo25 } from "react";
|
|
32429
32753
|
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
32430
32754
|
function WidgetRouter({
|
|
32431
32755
|
currentStep,
|
|
32432
32756
|
navigationDirection,
|
|
32433
32757
|
stepHistory
|
|
32434
32758
|
}) {
|
|
32435
|
-
const PageComponent =
|
|
32759
|
+
const PageComponent = useMemo25(
|
|
32436
32760
|
() => PAGE_COMPONENTS[currentStep],
|
|
32437
32761
|
[currentStep]
|
|
32438
32762
|
);
|
|
32439
|
-
const animationClass =
|
|
32763
|
+
const animationClass = useMemo25(() => {
|
|
32440
32764
|
return navigationDirection === "forward" ? "tw-animate-slide-in-right" : "tw-animate-slide-in-left";
|
|
32441
32765
|
}, [navigationDirection]);
|
|
32442
32766
|
return /* @__PURE__ */ jsx54(
|
|
@@ -32464,14 +32788,14 @@ var init_WidgetRouter = __esm({
|
|
|
32464
32788
|
});
|
|
32465
32789
|
|
|
32466
32790
|
// src/modes/swap/hooks/useSwapRoute.ts
|
|
32467
|
-
import { useCallback as useCallback20, useRef as
|
|
32791
|
+
import { useCallback as useCallback20, useRef as useRef14, useState as useState27 } from "react";
|
|
32468
32792
|
function useSwapRoute() {
|
|
32469
|
-
const [state, setState] =
|
|
32793
|
+
const [state, setState] = useState27({
|
|
32470
32794
|
data: null,
|
|
32471
32795
|
loading: false,
|
|
32472
32796
|
error: null
|
|
32473
32797
|
});
|
|
32474
|
-
const abortRef =
|
|
32798
|
+
const abortRef = useRef14(false);
|
|
32475
32799
|
const fetch2 = useCallback20(
|
|
32476
32800
|
async (params) => {
|
|
32477
32801
|
const { fromToken, fromChain, toToken, toChain, amount, walletAddress } = params;
|
|
@@ -32530,7 +32854,7 @@ var init_useSwapRoute = __esm({
|
|
|
32530
32854
|
});
|
|
32531
32855
|
|
|
32532
32856
|
// src/modes/swap/hooks/useSwapExecution.ts
|
|
32533
|
-
import { useCallback as useCallback21, useRef as
|
|
32857
|
+
import { useCallback as useCallback21, useRef as useRef15, useState as useState28 } from "react";
|
|
32534
32858
|
import { encodeFunctionData as encodeFunctionData9, erc20Abi as erc20Abi2 } from "viem";
|
|
32535
32859
|
function normalizeTx(raw) {
|
|
32536
32860
|
const r = raw;
|
|
@@ -32565,7 +32889,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
32565
32889
|
throw new Error("Timed out waiting for approval confirmation");
|
|
32566
32890
|
}
|
|
32567
32891
|
function useSwapExecution(fromChain) {
|
|
32568
|
-
const [state, setState] =
|
|
32892
|
+
const [state, setState] = useState28({
|
|
32569
32893
|
txStatus: "idle",
|
|
32570
32894
|
txHash: null,
|
|
32571
32895
|
intentId: null,
|
|
@@ -32574,11 +32898,11 @@ function useSwapExecution(fromChain) {
|
|
|
32574
32898
|
isSubmitting: false,
|
|
32575
32899
|
allowanceStatus: "unknown"
|
|
32576
32900
|
});
|
|
32577
|
-
const saFailedUntilRef =
|
|
32578
|
-
const pollingRef =
|
|
32579
|
-
const timeoutRef =
|
|
32580
|
-
const abortRef =
|
|
32581
|
-
const pollCountRef =
|
|
32901
|
+
const saFailedUntilRef = useRef15(0);
|
|
32902
|
+
const pollingRef = useRef15(null);
|
|
32903
|
+
const timeoutRef = useRef15(null);
|
|
32904
|
+
const abortRef = useRef15(false);
|
|
32905
|
+
const pollCountRef = useRef15(0);
|
|
32582
32906
|
const clearPolling = useCallback21(() => {
|
|
32583
32907
|
abortRef.current = true;
|
|
32584
32908
|
if (pollingRef.current) clearTimeout(pollingRef.current);
|
|
@@ -32941,13 +33265,13 @@ var init_forex = __esm({
|
|
|
32941
33265
|
});
|
|
32942
33266
|
|
|
32943
33267
|
// src/modes/swap/hooks/useForex.ts
|
|
32944
|
-
import { useEffect as
|
|
33268
|
+
import { useEffect as useEffect29, useRef as useRef16, useState as useState29 } from "react";
|
|
32945
33269
|
function useForex() {
|
|
32946
|
-
const [rates, setRates] =
|
|
32947
|
-
const [error, setError] =
|
|
32948
|
-
const [lastUpdated, setLastUpdated] =
|
|
32949
|
-
const timerRef =
|
|
32950
|
-
|
|
33270
|
+
const [rates, setRates] = useState29({ USD: 1 });
|
|
33271
|
+
const [error, setError] = useState29(null);
|
|
33272
|
+
const [lastUpdated, setLastUpdated] = useState29(null);
|
|
33273
|
+
const timerRef = useRef16(null);
|
|
33274
|
+
useEffect29(() => {
|
|
32951
33275
|
let cancelled = false;
|
|
32952
33276
|
const load = () => {
|
|
32953
33277
|
fetchForexRates("USD").then((r) => {
|
|
@@ -32984,7 +33308,7 @@ var init_useForex = __esm({
|
|
|
32984
33308
|
});
|
|
32985
33309
|
|
|
32986
33310
|
// src/modes/swap/components/SwapTokenSelect.tsx
|
|
32987
|
-
import { useState as
|
|
33311
|
+
import { useState as useState30, useMemo as useMemo26, useEffect as useEffect30 } from "react";
|
|
32988
33312
|
import { jsx as jsx55, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
32989
33313
|
function SwapTokenSelect({
|
|
32990
33314
|
side,
|
|
@@ -33000,10 +33324,10 @@ function SwapTokenSelect({
|
|
|
33000
33324
|
allowedTokens,
|
|
33001
33325
|
excludeToken
|
|
33002
33326
|
}) {
|
|
33003
|
-
const [localChain, setLocalChain] =
|
|
33004
|
-
const [pinnedTokens, setPinnedTokens] =
|
|
33005
|
-
const [pinnedLoading, setPinnedLoading] =
|
|
33006
|
-
|
|
33327
|
+
const [localChain, setLocalChain] = useState30(initialChain);
|
|
33328
|
+
const [pinnedTokens, setPinnedTokens] = useState30([]);
|
|
33329
|
+
const [pinnedLoading, setPinnedLoading] = useState30(false);
|
|
33330
|
+
useEffect30(() => {
|
|
33007
33331
|
if (!allowedTokens || allowedTokens.length === 0 || !localChain) {
|
|
33008
33332
|
setPinnedTokens([]);
|
|
33009
33333
|
return;
|
|
@@ -33084,26 +33408,26 @@ function SwapTokenSelect({
|
|
|
33084
33408
|
walletAddress,
|
|
33085
33409
|
yourWalletTokens
|
|
33086
33410
|
});
|
|
33087
|
-
const allowedSet =
|
|
33411
|
+
const allowedSet = useMemo26(() => {
|
|
33088
33412
|
if (!allowedTokens || allowedTokens.length === 0) return null;
|
|
33089
33413
|
return new Set(
|
|
33090
33414
|
allowedTokens.map((t) => `${t.chainId}:${t.address.toLowerCase()}`)
|
|
33091
33415
|
);
|
|
33092
33416
|
}, [allowedTokens]);
|
|
33093
|
-
const filteredWalletTokens =
|
|
33417
|
+
const filteredWalletTokens = useMemo26(() => {
|
|
33094
33418
|
if (!allowedSet) return rawWalletTokens;
|
|
33095
33419
|
return rawWalletTokens.filter(
|
|
33096
33420
|
(t) => allowedSet.has(`${Number(t.chainId)}:${t.address.toLowerCase()}`)
|
|
33097
33421
|
);
|
|
33098
33422
|
}, [rawWalletTokens, allowedSet]);
|
|
33099
33423
|
const excludeKey = excludeToken ? `${Number(excludeToken.chainId)}:${excludeToken.address.toLowerCase()}` : null;
|
|
33100
|
-
const visibleTokens =
|
|
33424
|
+
const visibleTokens = useMemo26(() => {
|
|
33101
33425
|
if (!excludeKey) return filteredTokens;
|
|
33102
33426
|
return filteredTokens.filter(
|
|
33103
33427
|
(t) => `${Number(t.chainId)}:${t.address.toLowerCase()}` !== excludeKey
|
|
33104
33428
|
);
|
|
33105
33429
|
}, [filteredTokens, excludeKey]);
|
|
33106
|
-
const visibleWalletTokens =
|
|
33430
|
+
const visibleWalletTokens = useMemo26(() => {
|
|
33107
33431
|
if (!excludeKey) return filteredWalletTokens;
|
|
33108
33432
|
return filteredWalletTokens.filter(
|
|
33109
33433
|
(t) => `${Number(t.chainId)}:${t.address.toLowerCase()}` !== excludeKey
|
|
@@ -33232,8 +33556,8 @@ var init_SwapTokenSelect = __esm({
|
|
|
33232
33556
|
});
|
|
33233
33557
|
|
|
33234
33558
|
// src/modes/swap/components/SwapWalletSelector.tsx
|
|
33235
|
-
import { useEffect as
|
|
33236
|
-
import { Fragment as
|
|
33559
|
+
import { useEffect as useEffect31, useMemo as useMemo27, useRef as useRef17, useState as useState31 } from "react";
|
|
33560
|
+
import { Fragment as Fragment9, jsx as jsx56, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
33237
33561
|
function SwapWalletSelector({
|
|
33238
33562
|
walletStatus,
|
|
33239
33563
|
walletAddress,
|
|
@@ -33249,16 +33573,16 @@ function SwapWalletSelector({
|
|
|
33249
33573
|
} = useWalletInfo();
|
|
33250
33574
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
33251
33575
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
33252
|
-
const [wcConnecting, setWcConnecting] =
|
|
33253
|
-
const [connectingId, setConnectingId] =
|
|
33254
|
-
const [timerExpired, setTimerExpired] =
|
|
33255
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
33256
|
-
const prevStatusRef =
|
|
33257
|
-
|
|
33576
|
+
const [wcConnecting, setWcConnecting] = useState31(false);
|
|
33577
|
+
const [connectingId, setConnectingId] = useState31(null);
|
|
33578
|
+
const [timerExpired, setTimerExpired] = useState31(false);
|
|
33579
|
+
const [selectedNamespace, setSelectedNamespace] = useState31("evm");
|
|
33580
|
+
const prevStatusRef = useRef17(walletStatus);
|
|
33581
|
+
useEffect31(() => {
|
|
33258
33582
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
33259
33583
|
return () => clearTimeout(t);
|
|
33260
33584
|
}, []);
|
|
33261
|
-
|
|
33585
|
+
useEffect31(() => {
|
|
33262
33586
|
const prev = prevStatusRef.current;
|
|
33263
33587
|
if (prev !== walletStatus) {
|
|
33264
33588
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -33267,7 +33591,7 @@ function SwapWalletSelector({
|
|
|
33267
33591
|
prevStatusRef.current = walletStatus;
|
|
33268
33592
|
}
|
|
33269
33593
|
}, [walletStatus]);
|
|
33270
|
-
const filteredWallets =
|
|
33594
|
+
const filteredWallets = useMemo27(
|
|
33271
33595
|
() => detected.filter(
|
|
33272
33596
|
(w) => (w.meta?.ecosystem ?? "").toLowerCase() === selectedNamespace
|
|
33273
33597
|
),
|
|
@@ -33691,7 +34015,7 @@ function SwapWalletSelector({
|
|
|
33691
34015
|
})
|
|
33692
34016
|
}
|
|
33693
34017
|
),
|
|
33694
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(
|
|
34018
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(Fragment9, { children: [
|
|
33695
34019
|
/* @__PURE__ */ jsx56(
|
|
33696
34020
|
"div",
|
|
33697
34021
|
{
|
|
@@ -33932,13 +34256,13 @@ import {
|
|
|
33932
34256
|
lazy as lazy2,
|
|
33933
34257
|
Suspense as Suspense2,
|
|
33934
34258
|
useCallback as useCallback22,
|
|
33935
|
-
useEffect as
|
|
33936
|
-
useMemo as
|
|
33937
|
-
useRef as
|
|
33938
|
-
useState as
|
|
34259
|
+
useEffect as useEffect32,
|
|
34260
|
+
useMemo as useMemo28,
|
|
34261
|
+
useRef as useRef18,
|
|
34262
|
+
useState as useState32
|
|
33939
34263
|
} from "react";
|
|
33940
34264
|
import ReactDOM from "react-dom";
|
|
33941
|
-
import { Fragment as
|
|
34265
|
+
import { Fragment as Fragment10, jsx as jsx57, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
33942
34266
|
function fmtAmount(n, max = 6) {
|
|
33943
34267
|
if (!isFinite(n) || n === 0) return "0";
|
|
33944
34268
|
return n.toLocaleString(void 0, { maximumFractionDigits: max });
|
|
@@ -34030,36 +34354,36 @@ function SwapMode({
|
|
|
34030
34354
|
theme: themeProp,
|
|
34031
34355
|
style
|
|
34032
34356
|
}) {
|
|
34033
|
-
const [stage, setStage] =
|
|
34034
|
-
const [fromToken, setFromToken] =
|
|
34357
|
+
const [stage, setStage] = useState32("home");
|
|
34358
|
+
const [fromToken, setFromToken] = useState32(
|
|
34035
34359
|
null
|
|
34036
34360
|
);
|
|
34037
|
-
const [fromChain, setFromChain] =
|
|
34038
|
-
const [toToken, setToToken] =
|
|
34039
|
-
const [toChain, setToChain] =
|
|
34040
|
-
const [amount, setAmount] =
|
|
34041
|
-
const [amountInputMode, setAmountInputMode] =
|
|
34361
|
+
const [fromChain, setFromChain] = useState32(null);
|
|
34362
|
+
const [toToken, setToToken] = useState32(null);
|
|
34363
|
+
const [toChain, setToChain] = useState32(null);
|
|
34364
|
+
const [amount, setAmount] = useState32("");
|
|
34365
|
+
const [amountInputMode, setAmountInputMode] = useState32(
|
|
34042
34366
|
"usd"
|
|
34043
34367
|
);
|
|
34044
|
-
const [hoverSell, setHoverSell] =
|
|
34045
|
-
const [showRateDetails, setShowRateDetails] =
|
|
34046
|
-
const [showReviewDetails, setShowReviewDetails] =
|
|
34047
|
-
const [showSettings, setShowSettings] =
|
|
34048
|
-
const [maxApproval, setMaxApproval] =
|
|
34049
|
-
const [slippage, setSlippage] =
|
|
34050
|
-
const [slippageInput, setSlippageInput] =
|
|
34051
|
-
const [selectedCurrency, setSelectedCurrency] =
|
|
34052
|
-
const [showCurrencyDropdown, setShowCurrencyDropdown] =
|
|
34053
|
-
const [completedAt, setCompletedAt] =
|
|
34054
|
-
const [copiedHash, setCopiedHash] =
|
|
34055
|
-
const [rateUpdated, setRateUpdated] =
|
|
34056
|
-
const prevToAmountRef =
|
|
34057
|
-
const [destAddress, setDestAddress] =
|
|
34058
|
-
const [quoteAge, setQuoteAge] =
|
|
34059
|
-
const quoteTimestampRef =
|
|
34060
|
-
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] =
|
|
34061
|
-
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] =
|
|
34062
|
-
const latestFetchParamsRef =
|
|
34368
|
+
const [hoverSell, setHoverSell] = useState32(false);
|
|
34369
|
+
const [showRateDetails, setShowRateDetails] = useState32(false);
|
|
34370
|
+
const [showReviewDetails, setShowReviewDetails] = useState32(false);
|
|
34371
|
+
const [showSettings, setShowSettings] = useState32(false);
|
|
34372
|
+
const [maxApproval, setMaxApproval] = useState32(false);
|
|
34373
|
+
const [slippage, setSlippage] = useState32(0.5);
|
|
34374
|
+
const [slippageInput, setSlippageInput] = useState32("");
|
|
34375
|
+
const [selectedCurrency, setSelectedCurrency] = useState32("USD");
|
|
34376
|
+
const [showCurrencyDropdown, setShowCurrencyDropdown] = useState32(false);
|
|
34377
|
+
const [completedAt, setCompletedAt] = useState32(null);
|
|
34378
|
+
const [copiedHash, setCopiedHash] = useState32(null);
|
|
34379
|
+
const [rateUpdated, setRateUpdated] = useState32(false);
|
|
34380
|
+
const prevToAmountRef = useRef18(null);
|
|
34381
|
+
const [destAddress, setDestAddress] = useState32("");
|
|
34382
|
+
const [quoteAge, setQuoteAge] = useState32(0);
|
|
34383
|
+
const quoteTimestampRef = useRef18(null);
|
|
34384
|
+
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = useState32(0);
|
|
34385
|
+
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = useState32(true);
|
|
34386
|
+
const latestFetchParamsRef = useRef18(null);
|
|
34063
34387
|
const { rates: forexRates } = useForex();
|
|
34064
34388
|
const currencyMeta = getCurrencyMeta(selectedCurrency);
|
|
34065
34389
|
const currencyRate = forexRates[selectedCurrency] ?? 1;
|
|
@@ -34075,8 +34399,8 @@ function SwapMode({
|
|
|
34075
34399
|
},
|
|
34076
34400
|
[currencyRate, selectedCurrency]
|
|
34077
34401
|
);
|
|
34078
|
-
const settingsRef =
|
|
34079
|
-
const currencyDropdownRef =
|
|
34402
|
+
const settingsRef = useRef18(null);
|
|
34403
|
+
const currencyDropdownRef = useRef18(null);
|
|
34080
34404
|
const { emitEvent } = useTrustware();
|
|
34081
34405
|
const { features, theme: configTheme } = useTrustwareConfig();
|
|
34082
34406
|
const effectiveThemeSetting = themeProp ?? configTheme ?? "system";
|
|
@@ -34092,26 +34416,26 @@ function SwapMode({
|
|
|
34092
34416
|
isLoading: chainsLoading,
|
|
34093
34417
|
error: chainsError
|
|
34094
34418
|
} = useChains();
|
|
34095
|
-
const allowedDestChainIds =
|
|
34419
|
+
const allowedDestChainIds = useMemo28(() => {
|
|
34096
34420
|
if (!allowedDestTokens || allowedDestTokens.length === 0) return null;
|
|
34097
34421
|
return new Set(allowedDestTokens.map((t) => t.chainId));
|
|
34098
34422
|
}, [allowedDestTokens]);
|
|
34099
|
-
const toPopularChains =
|
|
34423
|
+
const toPopularChains = useMemo28(
|
|
34100
34424
|
() => allowedDestChainIds ? popularChains.filter(
|
|
34101
34425
|
(c) => allowedDestChainIds.has(Number(c.chainId))
|
|
34102
34426
|
) : popularChains,
|
|
34103
34427
|
[popularChains, allowedDestChainIds]
|
|
34104
34428
|
);
|
|
34105
|
-
const toOtherChains =
|
|
34429
|
+
const toOtherChains = useMemo28(
|
|
34106
34430
|
() => allowedDestChainIds ? otherChains.filter((c) => allowedDestChainIds.has(Number(c.chainId))) : otherChains,
|
|
34107
34431
|
[otherChains, allowedDestChainIds]
|
|
34108
34432
|
);
|
|
34109
|
-
const allChains =
|
|
34433
|
+
const allChains = useMemo28(
|
|
34110
34434
|
() => [...popularChains, ...otherChains],
|
|
34111
34435
|
[popularChains, otherChains]
|
|
34112
34436
|
);
|
|
34113
|
-
const destInitialized =
|
|
34114
|
-
|
|
34437
|
+
const destInitialized = useRef18(false);
|
|
34438
|
+
useEffect32(() => {
|
|
34115
34439
|
if (!defaultDestRef || destInitialized.current || allChains.length === 0)
|
|
34116
34440
|
return;
|
|
34117
34441
|
const chain = allChains.find(
|
|
@@ -34159,18 +34483,18 @@ function SwapMode({
|
|
|
34159
34483
|
});
|
|
34160
34484
|
const route = useSwapRoute();
|
|
34161
34485
|
const execution = useSwapExecution(fromChain);
|
|
34162
|
-
const fromTokenPriceUSD =
|
|
34486
|
+
const fromTokenPriceUSD = useMemo28(() => {
|
|
34163
34487
|
const p = fromToken?.usdPrice;
|
|
34164
34488
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
34165
34489
|
}, [fromToken]);
|
|
34166
34490
|
const hasFromUsdPrice = fromTokenPriceUSD > 0;
|
|
34167
|
-
const toTokenPriceUSD =
|
|
34491
|
+
const toTokenPriceUSD = useMemo28(() => {
|
|
34168
34492
|
const p = toToken?.usdPrice;
|
|
34169
34493
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
34170
34494
|
}, [toToken]);
|
|
34171
34495
|
const hasToUsdPrice = toTokenPriceUSD > 0;
|
|
34172
34496
|
const rawSellNum = parseFloat(amount) || 0;
|
|
34173
|
-
const usdSellNum =
|
|
34497
|
+
const usdSellNum = useMemo28(() => {
|
|
34174
34498
|
if (amountInputMode === "usd") return rawSellNum / currencyRate;
|
|
34175
34499
|
return hasFromUsdPrice ? rawSellNum * fromTokenPriceUSD : 0;
|
|
34176
34500
|
}, [
|
|
@@ -34180,7 +34504,7 @@ function SwapMode({
|
|
|
34180
34504
|
hasFromUsdPrice,
|
|
34181
34505
|
fromTokenPriceUSD
|
|
34182
34506
|
]);
|
|
34183
|
-
const tokenSellNum =
|
|
34507
|
+
const tokenSellNum = useMemo28(() => {
|
|
34184
34508
|
if (amountInputMode === "usd") {
|
|
34185
34509
|
return hasFromUsdPrice && fromTokenPriceUSD > 0 ? usdSellNum / fromTokenPriceUSD : 0;
|
|
34186
34510
|
}
|
|
@@ -34192,7 +34516,7 @@ function SwapMode({
|
|
|
34192
34516
|
hasFromUsdPrice,
|
|
34193
34517
|
fromTokenPriceUSD
|
|
34194
34518
|
]);
|
|
34195
|
-
const tokenAmountStr =
|
|
34519
|
+
const tokenAmountStr = useMemo28(() => {
|
|
34196
34520
|
if (tokenSellNum <= 0) return "";
|
|
34197
34521
|
const decimals = fromToken?.decimals ?? 18;
|
|
34198
34522
|
return truncateDecimal(tokenSellNum, Math.min(decimals, 18));
|
|
@@ -34403,7 +34727,7 @@ function SwapMode({
|
|
|
34403
34727
|
fromToken?.decimals,
|
|
34404
34728
|
route
|
|
34405
34729
|
]);
|
|
34406
|
-
const fromBalance =
|
|
34730
|
+
const fromBalance = useMemo28(() => {
|
|
34407
34731
|
const walletToken = fromToken;
|
|
34408
34732
|
if (!walletToken || !("balance" in walletToken)) return null;
|
|
34409
34733
|
const raw = walletToken.balance;
|
|
@@ -34413,7 +34737,7 @@ function SwapMode({
|
|
|
34413
34737
|
return Number.isFinite(n) ? n : null;
|
|
34414
34738
|
}, [fromToken]);
|
|
34415
34739
|
const balanceUsd = fromBalance !== null && hasFromUsdPrice ? fromBalance * fromTokenPriceUSD : null;
|
|
34416
|
-
const estimatedToAmount =
|
|
34740
|
+
const estimatedToAmount = useMemo28(() => {
|
|
34417
34741
|
if (tokenSellNum <= 0 || !hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
34418
34742
|
return tokenSellNum * (fromTokenPriceUSD / toTokenPriceUSD);
|
|
34419
34743
|
}, [
|
|
@@ -34423,10 +34747,10 @@ function SwapMode({
|
|
|
34423
34747
|
hasFromUsdPrice,
|
|
34424
34748
|
hasToUsdPrice
|
|
34425
34749
|
]);
|
|
34426
|
-
const backendToUsdStr =
|
|
34750
|
+
const backendToUsdStr = useMemo28(() => {
|
|
34427
34751
|
return route.data?.finalExchangeRate?.toAmountMinUSD ?? route.data?.route?.estimate?.toAmountMinUsd ?? route.data?.route?.estimate?.toAmountUsd ?? null;
|
|
34428
34752
|
}, [route.data]);
|
|
34429
|
-
const toAmount =
|
|
34753
|
+
const toAmount = useMemo28(() => {
|
|
34430
34754
|
if (backendToUsdStr && toTokenPriceUSD > 0) {
|
|
34431
34755
|
const usd = parseFloat(backendToUsdStr);
|
|
34432
34756
|
if (Number.isFinite(usd) && usd > 0) return usd / toTokenPriceUSD;
|
|
@@ -34452,7 +34776,7 @@ function SwapMode({
|
|
|
34452
34776
|
estimatedToAmount
|
|
34453
34777
|
]);
|
|
34454
34778
|
const fromUsd = usdSellNum;
|
|
34455
|
-
const toUsd =
|
|
34779
|
+
const toUsd = useMemo28(() => {
|
|
34456
34780
|
if (backendToUsdStr) {
|
|
34457
34781
|
const n = parseFloat(backendToUsdStr);
|
|
34458
34782
|
if (Number.isFinite(n) && n > 0) return n;
|
|
@@ -34463,12 +34787,12 @@ function SwapMode({
|
|
|
34463
34787
|
const isEstimate = !route.data;
|
|
34464
34788
|
const USD_EPSILON = 1e-3;
|
|
34465
34789
|
const displayToUsd = toUsd > USD_EPSILON ? toUsd : estimatedToAmount !== null && hasToUsdPrice ? estimatedToAmount * toTokenPriceUSD : 0;
|
|
34466
|
-
const priceImpact =
|
|
34790
|
+
const priceImpact = useMemo28(() => {
|
|
34467
34791
|
if (!route.data || fromUsd < 0.01 || displayToUsd < 0.01) return null;
|
|
34468
34792
|
const impact = 1 - displayToUsd / fromUsd;
|
|
34469
34793
|
return impact > 1e-3 ? impact : null;
|
|
34470
34794
|
}, [route.data, fromUsd, displayToUsd]);
|
|
34471
|
-
const routePath =
|
|
34795
|
+
const routePath = useMemo28(() => {
|
|
34472
34796
|
if (!route.data) return null;
|
|
34473
34797
|
const provider = route.data.route?.provider;
|
|
34474
34798
|
const steps = route.data.route?.steps;
|
|
@@ -34495,19 +34819,19 @@ function SwapMode({
|
|
|
34495
34819
|
return null;
|
|
34496
34820
|
}, [route.data, fromToken?.symbol, toToken?.symbol]);
|
|
34497
34821
|
const isGasSponsored = !!route.data?.sponsorship;
|
|
34498
|
-
const networkCostUsd =
|
|
34822
|
+
const networkCostUsd = useMemo28(() => {
|
|
34499
34823
|
const fees = route.data?.route?.estimate?.fees;
|
|
34500
34824
|
if (!fees?.length) return null;
|
|
34501
34825
|
const gasTotal = fees.filter((f) => f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
34502
34826
|
return gasTotal > 0 ? gasTotal : null;
|
|
34503
34827
|
}, [route.data]);
|
|
34504
|
-
const protocolFeeUsd =
|
|
34828
|
+
const protocolFeeUsd = useMemo28(() => {
|
|
34505
34829
|
const fees = route.data?.route?.estimate?.fees;
|
|
34506
34830
|
if (!fees?.length) return null;
|
|
34507
34831
|
const total = fees.filter((f) => !f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
34508
34832
|
return total > 0 ? total : null;
|
|
34509
34833
|
}, [route.data]);
|
|
34510
|
-
const exchangeRate =
|
|
34834
|
+
const exchangeRate = useMemo28(() => {
|
|
34511
34835
|
if (!hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
34512
34836
|
return toTokenPriceUSD / fromTokenPriceUSD;
|
|
34513
34837
|
}, [fromTokenPriceUSD, toTokenPriceUSD, hasFromUsdPrice, hasToUsdPrice]);
|
|
@@ -34516,13 +34840,13 @@ function SwapMode({
|
|
|
34516
34840
|
const hasAmount = rawSellNum > 0 && (amountInputMode === "token" || hasFromUsdPrice);
|
|
34517
34841
|
const isConnected = walletStatus === "connected" && !!walletAddress;
|
|
34518
34842
|
const canGetQuote = hasTokens && hasAmount && !insufficient && isConnected && (!needsDestAddress || isValidDestAddress);
|
|
34519
|
-
|
|
34843
|
+
useEffect32(() => {
|
|
34520
34844
|
if (!fromToken) return;
|
|
34521
34845
|
if (!hasFromUsdPrice && amountInputMode === "usd") {
|
|
34522
34846
|
setAmountInputMode("token");
|
|
34523
34847
|
}
|
|
34524
34848
|
}, [fromToken, hasFromUsdPrice, amountInputMode]);
|
|
34525
|
-
|
|
34849
|
+
useEffect32(() => {
|
|
34526
34850
|
if (displayToAmount === null) {
|
|
34527
34851
|
prevToAmountRef.current = null;
|
|
34528
34852
|
return;
|
|
@@ -34536,14 +34860,14 @@ function SwapMode({
|
|
|
34536
34860
|
const t = setTimeout(() => setRateUpdated(false), 700);
|
|
34537
34861
|
return () => clearTimeout(t);
|
|
34538
34862
|
}, [displayToAmount]);
|
|
34539
|
-
|
|
34863
|
+
useEffect32(() => {
|
|
34540
34864
|
setDestAddress("");
|
|
34541
34865
|
}, [toChainType]);
|
|
34542
|
-
const fetchRef =
|
|
34543
|
-
|
|
34866
|
+
const fetchRef = useRef18(route.fetch);
|
|
34867
|
+
useEffect32(() => {
|
|
34544
34868
|
fetchRef.current = route.fetch;
|
|
34545
34869
|
});
|
|
34546
|
-
|
|
34870
|
+
useEffect32(() => {
|
|
34547
34871
|
if (!canGetQuote || stage !== "home") return;
|
|
34548
34872
|
if (!fromToken || !fromChain || !toToken || !toChain || !walletAddress)
|
|
34549
34873
|
return;
|
|
@@ -34572,7 +34896,7 @@ function SwapMode({
|
|
|
34572
34896
|
destAddress,
|
|
34573
34897
|
slippage
|
|
34574
34898
|
]);
|
|
34575
|
-
|
|
34899
|
+
useEffect32(() => {
|
|
34576
34900
|
if (!canGetQuote || !fromToken || !fromChain || !toToken || !toChain || !walletAddress) {
|
|
34577
34901
|
latestFetchParamsRef.current = null;
|
|
34578
34902
|
return;
|
|
@@ -34599,12 +34923,12 @@ function SwapMode({
|
|
|
34599
34923
|
destAddress,
|
|
34600
34924
|
slippage
|
|
34601
34925
|
]);
|
|
34602
|
-
|
|
34926
|
+
useEffect32(() => {
|
|
34603
34927
|
quoteTimestampRef.current = route.data ? Date.now() : null;
|
|
34604
34928
|
setQuoteAge(0);
|
|
34605
34929
|
}, [route.data]);
|
|
34606
|
-
const msgTimeoutRef =
|
|
34607
|
-
|
|
34930
|
+
const msgTimeoutRef = useRef18(null);
|
|
34931
|
+
useEffect32(() => {
|
|
34608
34932
|
if (!route.loading) {
|
|
34609
34933
|
setQuoteLoadingMsgIdx(0);
|
|
34610
34934
|
setQuoteLoadingMsgVisible(true);
|
|
@@ -34622,7 +34946,7 @@ function SwapMode({
|
|
|
34622
34946
|
if (msgTimeoutRef.current !== null) clearTimeout(msgTimeoutRef.current);
|
|
34623
34947
|
};
|
|
34624
34948
|
}, [route.loading]);
|
|
34625
|
-
|
|
34949
|
+
useEffect32(() => {
|
|
34626
34950
|
if (!route.data) return;
|
|
34627
34951
|
const id = setInterval(() => {
|
|
34628
34952
|
const ts = quoteTimestampRef.current;
|
|
@@ -34636,7 +34960,7 @@ function SwapMode({
|
|
|
34636
34960
|
}, 1e3);
|
|
34637
34961
|
return () => clearInterval(id);
|
|
34638
34962
|
}, [route.data]);
|
|
34639
|
-
|
|
34963
|
+
useEffect32(() => {
|
|
34640
34964
|
if (stage !== "review") return;
|
|
34641
34965
|
if (!route.data || !walletAddress) return;
|
|
34642
34966
|
const fromTokenAddress = fromToken?.address;
|
|
@@ -34647,7 +34971,7 @@ function SwapMode({
|
|
|
34647
34971
|
routeResult: route.data
|
|
34648
34972
|
});
|
|
34649
34973
|
}, [stage, route.data, walletAddress, fromToken]);
|
|
34650
|
-
|
|
34974
|
+
useEffect32(() => {
|
|
34651
34975
|
if (!showSettings) {
|
|
34652
34976
|
setShowCurrencyDropdown(false);
|
|
34653
34977
|
return;
|
|
@@ -34660,7 +34984,7 @@ function SwapMode({
|
|
|
34660
34984
|
document.addEventListener("mousedown", handler);
|
|
34661
34985
|
return () => document.removeEventListener("mousedown", handler);
|
|
34662
34986
|
}, [showSettings]);
|
|
34663
|
-
|
|
34987
|
+
useEffect32(() => {
|
|
34664
34988
|
if (!showCurrencyDropdown) return;
|
|
34665
34989
|
const handler = (e2) => {
|
|
34666
34990
|
if (currencyDropdownRef.current && !currencyDropdownRef.current.contains(e2.target)) {
|
|
@@ -35147,7 +35471,7 @@ function SwapMode({
|
|
|
35147
35471
|
padding: 0,
|
|
35148
35472
|
transition: "color 0.15s"
|
|
35149
35473
|
},
|
|
35150
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs45(
|
|
35474
|
+
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs45(Fragment10, { children: [
|
|
35151
35475
|
txHash.slice(0, 6),
|
|
35152
35476
|
"\u2026",
|
|
35153
35477
|
txHash.slice(-4),
|
|
@@ -37810,8 +38134,8 @@ function ReviewDetailRow({
|
|
|
37810
38134
|
value,
|
|
37811
38135
|
tooltip
|
|
37812
38136
|
}) {
|
|
37813
|
-
const iconRef =
|
|
37814
|
-
const [tipPos, setTipPos] =
|
|
38137
|
+
const iconRef = useRef18(null);
|
|
38138
|
+
const [tipPos, setTipPos] = useState32(null);
|
|
37815
38139
|
const handleMouseEnter = () => {
|
|
37816
38140
|
if (!tooltip || !iconRef.current) return;
|
|
37817
38141
|
const r = iconRef.current.getBoundingClientRect();
|
|
@@ -38146,14 +38470,14 @@ var init_swap = __esm({
|
|
|
38146
38470
|
|
|
38147
38471
|
// src/widget/TrustwareWidgetV2.tsx
|
|
38148
38472
|
import {
|
|
38149
|
-
useState as
|
|
38150
|
-
useEffect as
|
|
38151
|
-
useRef as
|
|
38473
|
+
useState as useState33,
|
|
38474
|
+
useEffect as useEffect33,
|
|
38475
|
+
useRef as useRef19,
|
|
38152
38476
|
useCallback as useCallback23,
|
|
38153
38477
|
useImperativeHandle,
|
|
38154
38478
|
forwardRef
|
|
38155
38479
|
} from "react";
|
|
38156
|
-
import { Fragment as
|
|
38480
|
+
import { Fragment as Fragment11, jsx as jsx58, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
38157
38481
|
function WidgetContent({
|
|
38158
38482
|
style,
|
|
38159
38483
|
onStateChange,
|
|
@@ -38164,7 +38488,7 @@ function WidgetContent({
|
|
|
38164
38488
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
38165
38489
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
38166
38490
|
useWalletExternalDisconnect(() => setCurrentStep("home"));
|
|
38167
|
-
|
|
38491
|
+
useEffect33(() => {
|
|
38168
38492
|
const state = {
|
|
38169
38493
|
currentStep,
|
|
38170
38494
|
amount,
|
|
@@ -38207,7 +38531,7 @@ function WidgetInner({
|
|
|
38207
38531
|
const { transactionStatus } = useDepositTransaction();
|
|
38208
38532
|
const { resolvedTheme } = useDepositUi();
|
|
38209
38533
|
const { status, revalidate, errors } = useTrustware();
|
|
38210
|
-
const [showConfirmDialog, setShowConfirmDialog] =
|
|
38534
|
+
const [showConfirmDialog, setShowConfirmDialog] = useState33(false);
|
|
38211
38535
|
const handleCloseRequest = useCallback23(() => {
|
|
38212
38536
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
38213
38537
|
setShowConfirmDialog(true);
|
|
@@ -38219,7 +38543,7 @@ function WidgetInner({
|
|
|
38219
38543
|
onClose?.();
|
|
38220
38544
|
}
|
|
38221
38545
|
}, [transactionStatus, onClose, resetState]);
|
|
38222
|
-
|
|
38546
|
+
useEffect33(() => {
|
|
38223
38547
|
closeRequestRef.current = handleCloseRequest;
|
|
38224
38548
|
}, [handleCloseRequest, closeRequestRef]);
|
|
38225
38549
|
const handleConfirmClose = useCallback23(() => {
|
|
@@ -38235,7 +38559,7 @@ function WidgetInner({
|
|
|
38235
38559
|
const handleRefresh = useCallback23(() => {
|
|
38236
38560
|
revalidate?.();
|
|
38237
38561
|
}, [revalidate]);
|
|
38238
|
-
return /* @__PURE__ */ jsxs46(
|
|
38562
|
+
return /* @__PURE__ */ jsxs46(Fragment11, { children: [
|
|
38239
38563
|
/* @__PURE__ */ jsxs46(WidgetContainer, { theme: effectiveTheme, style, children: [
|
|
38240
38564
|
/* @__PURE__ */ jsx58(
|
|
38241
38565
|
WidgetContent,
|
|
@@ -38303,8 +38627,8 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38303
38627
|
onOpen,
|
|
38304
38628
|
showThemeToggle = true
|
|
38305
38629
|
}, ref) {
|
|
38306
|
-
const [isOpen, setIsOpen] =
|
|
38307
|
-
const closeRequestRef =
|
|
38630
|
+
const [isOpen, setIsOpen] = useState33(defaultOpen);
|
|
38631
|
+
const closeRequestRef = useRef19(null);
|
|
38308
38632
|
const config = useTrustwareConfig();
|
|
38309
38633
|
const effectiveInitialStep = initialStep;
|
|
38310
38634
|
const open = useCallback23(() => {
|