@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.cjs
CHANGED
|
@@ -430,7 +430,7 @@ var init_constants = __esm({
|
|
|
430
430
|
"src/constants.ts"() {
|
|
431
431
|
"use strict";
|
|
432
432
|
SDK_NAME = "@trustware/sdk";
|
|
433
|
-
SDK_VERSION = "1.1.9-staging.
|
|
433
|
+
SDK_VERSION = "1.1.9-staging.3";
|
|
434
434
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
435
435
|
GTM_ID = "GTM-TZDGNCXB";
|
|
436
436
|
API_PREFIX = "/api";
|
|
@@ -1034,12 +1034,25 @@ var init_connect = __esm({
|
|
|
1034
1034
|
function formatDeepLink(id, currentUrl) {
|
|
1035
1035
|
const enc = encodeURIComponent(currentUrl);
|
|
1036
1036
|
switch (id) {
|
|
1037
|
+
// EVM
|
|
1037
1038
|
case "metamask":
|
|
1038
1039
|
return `metamask://dapp/${currentUrl}`;
|
|
1039
1040
|
case "coinbase":
|
|
1040
1041
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
1041
1042
|
case "rainbow":
|
|
1042
1043
|
return `rainbow://connect?uri=${enc}`;
|
|
1044
|
+
case "trust":
|
|
1045
|
+
return `https://link.trustwallet.com/open_url?coin_id=60&url=${enc}`;
|
|
1046
|
+
case "okx":
|
|
1047
|
+
return `okx://wallet/dapp/url?dappUrl=${enc}`;
|
|
1048
|
+
// Solana
|
|
1049
|
+
case "phantom-solana":
|
|
1050
|
+
return `phantom://browse/${enc}`;
|
|
1051
|
+
case "solflare":
|
|
1052
|
+
return `solflare://ul/v1/browse/${enc}`;
|
|
1053
|
+
case "backpack":
|
|
1054
|
+
return `https://backpack.app/ul/v1/browse/${enc}?ref=${enc}`;
|
|
1055
|
+
// No confirmed deep link scheme
|
|
1043
1056
|
default:
|
|
1044
1057
|
return void 0;
|
|
1045
1058
|
}
|
|
@@ -1067,6 +1080,8 @@ var init_metadata = __esm({
|
|
|
1067
1080
|
emoji: "\u{1F98A}",
|
|
1068
1081
|
homepage: "https://metamask.io/",
|
|
1069
1082
|
chromeWebStore: "https://chromewebstore.google.com/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",
|
|
1083
|
+
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
1084
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
1070
1085
|
detectFlags: ["isMetaMask"],
|
|
1071
1086
|
deepLink: (url) => formatDeepLink("metamask", url) ?? ""
|
|
1072
1087
|
},
|
|
@@ -1078,6 +1093,8 @@ var init_metadata = __esm({
|
|
|
1078
1093
|
logo: `${ASSETS_BASE_URL}/assets/wallets/coinbase.svg`,
|
|
1079
1094
|
emoji: "\u{1F7E6}",
|
|
1080
1095
|
homepage: "https://www.coinbase.com/wallet",
|
|
1096
|
+
ios: "https://apps.apple.com/app/coinbase-wallet/id1278383455",
|
|
1097
|
+
android: "https://play.google.com/store/apps/details?id=org.toshi",
|
|
1081
1098
|
detectFlags: ["isCoinbaseWallet"],
|
|
1082
1099
|
deepLink: (url) => formatDeepLink("coinbase", url) ?? ""
|
|
1083
1100
|
},
|
|
@@ -1089,6 +1106,7 @@ var init_metadata = __esm({
|
|
|
1089
1106
|
logo: `${ASSETS_BASE_URL}/assets/wallets/walletconnect.svg`,
|
|
1090
1107
|
emoji: "\u{1FA9D}",
|
|
1091
1108
|
homepage: "https://walletconnect.com/"
|
|
1109
|
+
// No deep link — opens its own modal
|
|
1092
1110
|
},
|
|
1093
1111
|
{
|
|
1094
1112
|
id: "rainbow",
|
|
@@ -1098,8 +1116,38 @@ var init_metadata = __esm({
|
|
|
1098
1116
|
logo: `${ASSETS_BASE_URL}/assets/wallets/rainbow.svg`,
|
|
1099
1117
|
emoji: "\u{1F308}",
|
|
1100
1118
|
homepage: "https://rainbow.me/",
|
|
1101
|
-
|
|
1102
|
-
|
|
1119
|
+
ios: "https://apps.apple.com/app/rainbow-ethereum-wallet/id1457119021",
|
|
1120
|
+
android: "https://play.google.com/store/apps/details?id=me.rainbow",
|
|
1121
|
+
detectFlags: ["isRainbow"],
|
|
1122
|
+
deepLink: (url) => formatDeepLink("rainbow", url) ?? ""
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
id: "trust",
|
|
1126
|
+
name: "Trust Wallet",
|
|
1127
|
+
category: "app",
|
|
1128
|
+
ecosystem: "multi",
|
|
1129
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
|
|
1130
|
+
emoji: "\u{1F6E1}\uFE0F",
|
|
1131
|
+
homepage: "https://trustwallet.com/",
|
|
1132
|
+
ios: "https://apps.apple.com/app/trust-crypto-bitcoin-wallet/id1288339409",
|
|
1133
|
+
android: "https://play.google.com/store/apps/details?id=com.wallet.crypto.trustapp",
|
|
1134
|
+
detectFlags: ["isTrustWallet"],
|
|
1135
|
+
deepLink: (url) => formatDeepLink("trust", url) ?? ""
|
|
1136
|
+
// ✅ Added
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
id: "okx",
|
|
1140
|
+
name: "OKX",
|
|
1141
|
+
category: "injected",
|
|
1142
|
+
ecosystem: "evm",
|
|
1143
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
|
|
1144
|
+
emoji: "\u2B1B",
|
|
1145
|
+
homepage: "https://www.okx.com/web3",
|
|
1146
|
+
ios: "https://apps.apple.com/app/okx-buy-bitcoin-eth-crypto/id1327268470",
|
|
1147
|
+
android: "https://play.google.com/store/apps/details?id=com.okinc.okex.gp",
|
|
1148
|
+
detectFlags: ["isOkxWallet"],
|
|
1149
|
+
deepLink: (url) => formatDeepLink("okx", url) ?? ""
|
|
1150
|
+
// ✅ Added
|
|
1103
1151
|
},
|
|
1104
1152
|
{
|
|
1105
1153
|
id: "phantom-evm",
|
|
@@ -1109,7 +1157,10 @@ var init_metadata = __esm({
|
|
|
1109
1157
|
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
1110
1158
|
emoji: "\u{1F47B}",
|
|
1111
1159
|
homepage: "https://phantom.app/",
|
|
1160
|
+
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1161
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1112
1162
|
detectFlags: ["isPhantom"]
|
|
1163
|
+
// No EVM dapp browser deep link — falls back to app store
|
|
1113
1164
|
},
|
|
1114
1165
|
{
|
|
1115
1166
|
id: "phantom-solana",
|
|
@@ -1119,18 +1170,9 @@ var init_metadata = __esm({
|
|
|
1119
1170
|
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
1120
1171
|
emoji: "\u{1F47B}",
|
|
1121
1172
|
homepage: "https://phantom.app/",
|
|
1122
|
-
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1123
1173
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
{
|
|
1127
|
-
id: "metamask-solana",
|
|
1128
|
-
name: "MetaMask (Solana)",
|
|
1129
|
-
category: "injected",
|
|
1130
|
-
ecosystem: "solana",
|
|
1131
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1132
|
-
emoji: "\u{1F98A}",
|
|
1133
|
-
homepage: "https://metamask.io/"
|
|
1174
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1175
|
+
deepLink: (url) => formatDeepLink("phantom-solana", url) ?? ""
|
|
1134
1176
|
},
|
|
1135
1177
|
{
|
|
1136
1178
|
id: "solflare",
|
|
@@ -1140,7 +1182,9 @@ var init_metadata = __esm({
|
|
|
1140
1182
|
logo: `${ASSETS_BASE_URL}/assets/wallets/solflare-logo.svg`,
|
|
1141
1183
|
emoji: "\u2600\uFE0F",
|
|
1142
1184
|
homepage: "https://solflare.com/",
|
|
1143
|
-
|
|
1185
|
+
ios: "https://apps.apple.com/app/solflare-solana-wallet/id1580902717",
|
|
1186
|
+
android: "https://play.google.com/store/apps/details?id=com.solflare.mobile",
|
|
1187
|
+
deepLink: (url) => formatDeepLink("solflare", url) ?? ""
|
|
1144
1188
|
},
|
|
1145
1189
|
{
|
|
1146
1190
|
id: "backpack",
|
|
@@ -1149,8 +1193,25 @@ var init_metadata = __esm({
|
|
|
1149
1193
|
ecosystem: "solana",
|
|
1150
1194
|
logo: `${ASSETS_BASE_URL}/assets/wallets/backpack-logo.svg`,
|
|
1151
1195
|
emoji: "\u{1F392}",
|
|
1152
|
-
homepage: "https://backpack.app/"
|
|
1196
|
+
homepage: "https://backpack.app/",
|
|
1197
|
+
ios: "https://apps.apple.com/app/backpack-crypto-wallet/id6445964121",
|
|
1198
|
+
android: "https://play.google.com/store/apps/details?id=app.backpack.mobile",
|
|
1199
|
+
deepLink: (url) => formatDeepLink("backpack", url) ?? ""
|
|
1200
|
+
// ✅ Added
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
id: "metamask-solana",
|
|
1204
|
+
name: "MetaMask (Solana)",
|
|
1205
|
+
category: "injected",
|
|
1206
|
+
ecosystem: "solana",
|
|
1207
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1208
|
+
emoji: "\u{1F98A}",
|
|
1209
|
+
homepage: "https://metamask.io/",
|
|
1210
|
+
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
1211
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
1212
|
+
// No Solana-specific deep link for MetaMask
|
|
1153
1213
|
},
|
|
1214
|
+
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
1154
1215
|
{
|
|
1155
1216
|
id: "rabby",
|
|
1156
1217
|
name: "Rabby",
|
|
@@ -1161,6 +1222,7 @@ var init_metadata = __esm({
|
|
|
1161
1222
|
homepage: "https://rabby.io/",
|
|
1162
1223
|
chromeWebStore: "https://chromewebstore.google.com/detail/rabby/acmacodkjbdgmoleebolmdjonilkdbch",
|
|
1163
1224
|
detectFlags: ["isRabby"]
|
|
1225
|
+
// Extension only — no mobile app or deep link
|
|
1164
1226
|
},
|
|
1165
1227
|
{
|
|
1166
1228
|
id: "brave",
|
|
@@ -1171,25 +1233,7 @@ var init_metadata = __esm({
|
|
|
1171
1233
|
emoji: "\u{1F981}",
|
|
1172
1234
|
homepage: "https://brave.com/wallet/",
|
|
1173
1235
|
detectFlags: ["isBraveWallet"]
|
|
1174
|
-
|
|
1175
|
-
{
|
|
1176
|
-
id: "okx",
|
|
1177
|
-
name: "OKX",
|
|
1178
|
-
category: "injected",
|
|
1179
|
-
ecosystem: "evm",
|
|
1180
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
|
|
1181
|
-
emoji: "\u2B1B",
|
|
1182
|
-
homepage: "https://www.okx.com/web3",
|
|
1183
|
-
detectFlags: ["isOkxWallet"]
|
|
1184
|
-
},
|
|
1185
|
-
{
|
|
1186
|
-
id: "zerion",
|
|
1187
|
-
name: "Zerion",
|
|
1188
|
-
category: "app",
|
|
1189
|
-
ecosystem: "evm",
|
|
1190
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
|
|
1191
|
-
emoji: "\u{1F9FF}",
|
|
1192
|
-
homepage: "https://zerion.io/wallet/"
|
|
1236
|
+
// Built into Brave browser — no standalone deep link
|
|
1193
1237
|
},
|
|
1194
1238
|
{
|
|
1195
1239
|
id: "taho",
|
|
@@ -1200,16 +1244,7 @@ var init_metadata = __esm({
|
|
|
1200
1244
|
emoji: "\u{1F7EA}",
|
|
1201
1245
|
homepage: "https://taho.xyz/",
|
|
1202
1246
|
detectFlags: ["isTally", "isTallyWallet", "isTahoWallet"]
|
|
1203
|
-
|
|
1204
|
-
{
|
|
1205
|
-
id: "trust",
|
|
1206
|
-
name: "Trust Wallet",
|
|
1207
|
-
category: "app",
|
|
1208
|
-
ecosystem: "multi",
|
|
1209
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
|
|
1210
|
-
emoji: "\u{1F6E1}\uFE0F",
|
|
1211
|
-
homepage: "https://trustwallet.com/",
|
|
1212
|
-
detectFlags: ["isTrustWallet"]
|
|
1247
|
+
// Extension only — no mobile app
|
|
1213
1248
|
},
|
|
1214
1249
|
{
|
|
1215
1250
|
id: "bitget",
|
|
@@ -1219,7 +1254,22 @@ var init_metadata = __esm({
|
|
|
1219
1254
|
logo: `${ASSETS_BASE_URL}/assets/wallets/bitget.svg`,
|
|
1220
1255
|
emoji: "\u{1F7E9}",
|
|
1221
1256
|
homepage: "https://web3.bitget.com/",
|
|
1257
|
+
ios: "https://apps.apple.com/app/bitget-wallet-ex-bitkeep/id1395301115",
|
|
1258
|
+
android: "https://play.google.com/store/apps/details?id=com.bitkeep.wallet",
|
|
1222
1259
|
detectFlags: ["isBitGetWallet"]
|
|
1260
|
+
// No public deep link scheme documented
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
id: "zerion",
|
|
1264
|
+
name: "Zerion",
|
|
1265
|
+
category: "app",
|
|
1266
|
+
ecosystem: "evm",
|
|
1267
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
|
|
1268
|
+
emoji: "\u{1F9FF}",
|
|
1269
|
+
homepage: "https://zerion.io/wallet/",
|
|
1270
|
+
ios: "https://apps.apple.com/app/zerion-crypto-defi-wallet/id1456732565",
|
|
1271
|
+
android: "https://play.google.com/store/apps/details?id=io.zerion.android"
|
|
1272
|
+
// Uses WalletConnect URI — not a simple page URL deep link
|
|
1223
1273
|
},
|
|
1224
1274
|
{
|
|
1225
1275
|
id: "safe",
|
|
@@ -1228,7 +1278,10 @@ var init_metadata = __esm({
|
|
|
1228
1278
|
ecosystem: "evm",
|
|
1229
1279
|
logo: `${ASSETS_BASE_URL}/assets/wallets/safe.svg`,
|
|
1230
1280
|
emoji: "\u{1F7E9}",
|
|
1231
|
-
homepage: "https://safe.global/"
|
|
1281
|
+
homepage: "https://safe.global/",
|
|
1282
|
+
ios: "https://apps.apple.com/app/safe-gnosis-safe/id1515759131",
|
|
1283
|
+
android: "https://play.google.com/store/apps/details?id=io.gnosis.safe"
|
|
1284
|
+
// Uses WalletConnect — no dapp browser deep link
|
|
1232
1285
|
},
|
|
1233
1286
|
{
|
|
1234
1287
|
id: "kucoin",
|
|
@@ -1237,7 +1290,10 @@ var init_metadata = __esm({
|
|
|
1237
1290
|
ecosystem: "evm",
|
|
1238
1291
|
logo: `${ASSETS_BASE_URL}/assets/wallets/kucoin.svg`,
|
|
1239
1292
|
emoji: "\u{1F7E6}",
|
|
1240
|
-
homepage: "https://www.kucoin.com/"
|
|
1293
|
+
homepage: "https://www.kucoin.com/",
|
|
1294
|
+
ios: "https://apps.apple.com/app/kucoin-buy-bitcoin-crypto/id1378956601",
|
|
1295
|
+
android: "https://play.google.com/store/apps/details?id=com.kubi.kucoin"
|
|
1296
|
+
// No public deep link scheme documented
|
|
1241
1297
|
}
|
|
1242
1298
|
];
|
|
1243
1299
|
}
|
|
@@ -1415,6 +1471,14 @@ function useWalletDetection(timeoutMs = 400) {
|
|
|
1415
1471
|
);
|
|
1416
1472
|
return { detected, detectedIds };
|
|
1417
1473
|
}
|
|
1474
|
+
function useIsMobile() {
|
|
1475
|
+
const [isMobile, set] = (0, import_react.useState)(false);
|
|
1476
|
+
(0, import_react.useEffect)(() => {
|
|
1477
|
+
const ua = navigator.userAgent || "";
|
|
1478
|
+
set(/Android|iPhone|iPad|iPod/i.test(ua));
|
|
1479
|
+
}, []);
|
|
1480
|
+
return isMobile;
|
|
1481
|
+
}
|
|
1418
1482
|
var import_react, WALLET_BY_ID, DETECT_PRIORITY, GENERIC_FLAGS, RDNS_WALLET_MAP, NAME_WALLET_MAP;
|
|
1419
1483
|
var init_detect = __esm({
|
|
1420
1484
|
"src/wallets/detect.ts"() {
|
|
@@ -4053,6 +4117,7 @@ var init_wallets = __esm({
|
|
|
4053
4117
|
init_adapters();
|
|
4054
4118
|
init_solana();
|
|
4055
4119
|
init_detect();
|
|
4120
|
+
init_metadata();
|
|
4056
4121
|
}
|
|
4057
4122
|
});
|
|
4058
4123
|
|
|
@@ -16153,7 +16218,7 @@ var init_WalletNamespaceTabs = __esm({
|
|
|
16153
16218
|
});
|
|
16154
16219
|
|
|
16155
16220
|
// src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx
|
|
16156
|
-
function
|
|
16221
|
+
function DesktopWalletDropdownContent({
|
|
16157
16222
|
browserWallets,
|
|
16158
16223
|
handleWalletConnect,
|
|
16159
16224
|
handleWalletSelect
|
|
@@ -16217,7 +16282,263 @@ function CryptoWalletDropdownContent({
|
|
|
16217
16282
|
}
|
|
16218
16283
|
);
|
|
16219
16284
|
}
|
|
16220
|
-
|
|
16285
|
+
function MobileWalletDropdownContent({
|
|
16286
|
+
handleWalletConnect
|
|
16287
|
+
}) {
|
|
16288
|
+
const { setCurrentStep } = useDepositNavigation();
|
|
16289
|
+
const { selectedNamespace } = useDepositWallet();
|
|
16290
|
+
const { walletMetaId, isConnected, status } = useWalletInfo();
|
|
16291
|
+
const [hoveredId, setHoveredId] = (0, import_react34.useState)(null);
|
|
16292
|
+
const storeFallbackTimeoutRef = (0, import_react34.useRef)(
|
|
16293
|
+
null
|
|
16294
|
+
);
|
|
16295
|
+
(0, import_react34.useEffect)(() => {
|
|
16296
|
+
return () => {
|
|
16297
|
+
if (storeFallbackTimeoutRef.current !== null) {
|
|
16298
|
+
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16299
|
+
}
|
|
16300
|
+
};
|
|
16301
|
+
}, []);
|
|
16302
|
+
const connectedWalletId = isConnected ? walletMetaId : null;
|
|
16303
|
+
const currentUrl = window.location.href;
|
|
16304
|
+
const mobileWallets = (0, import_react34.useMemo)(
|
|
16305
|
+
() => WALLETS.filter((w) => {
|
|
16306
|
+
if (w.id === "walletconnect") return true;
|
|
16307
|
+
const hasMobileLink = Boolean(w.deepLink || w.ios || w.android);
|
|
16308
|
+
if (!hasMobileLink) return false;
|
|
16309
|
+
return w.ecosystem.trim().toLowerCase() === "multi" || w.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase();
|
|
16310
|
+
}),
|
|
16311
|
+
[selectedNamespace]
|
|
16312
|
+
);
|
|
16313
|
+
const handleWalletSelect = (wallet) => {
|
|
16314
|
+
if (wallet.id === "walletconnect") {
|
|
16315
|
+
handleWalletConnect();
|
|
16316
|
+
return;
|
|
16317
|
+
}
|
|
16318
|
+
if (wallet.deepLink) {
|
|
16319
|
+
const deepLinkUrl = wallet.deepLink(currentUrl);
|
|
16320
|
+
if (deepLinkUrl) {
|
|
16321
|
+
window.location.assign(deepLinkUrl);
|
|
16322
|
+
if (storeFallbackTimeoutRef.current !== null) {
|
|
16323
|
+
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16324
|
+
}
|
|
16325
|
+
storeFallbackTimeoutRef.current = setTimeout(() => {
|
|
16326
|
+
storeFallbackTimeoutRef.current = null;
|
|
16327
|
+
const isIos2 = /iPhone|iPad/i.test(navigator.userAgent);
|
|
16328
|
+
const storeUrl2 = isIos2 ? wallet.ios : wallet.android;
|
|
16329
|
+
if (storeUrl2) window.location.assign(storeUrl2);
|
|
16330
|
+
}, 1500);
|
|
16331
|
+
return;
|
|
16332
|
+
}
|
|
16333
|
+
}
|
|
16334
|
+
const isIos = /iPhone|iPad/i.test(navigator.userAgent);
|
|
16335
|
+
const storeUrl = isIos ? wallet.ios : wallet.android;
|
|
16336
|
+
if (storeUrl) window.location.assign(storeUrl);
|
|
16337
|
+
};
|
|
16338
|
+
const handleContinue = () => {
|
|
16339
|
+
if (isConnected && status === "connected") {
|
|
16340
|
+
setCurrentStep("crypto-pay");
|
|
16341
|
+
} else {
|
|
16342
|
+
alert("Please connect your wallet first.");
|
|
16343
|
+
}
|
|
16344
|
+
};
|
|
16345
|
+
const showContinueButton = (0, import_react34.useMemo)(
|
|
16346
|
+
() => isConnected && status === "connected",
|
|
16347
|
+
[isConnected, status]
|
|
16348
|
+
);
|
|
16349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16350
|
+
"div",
|
|
16351
|
+
{
|
|
16352
|
+
style: {
|
|
16353
|
+
...dropdownSurfaceStyle,
|
|
16354
|
+
maxHeight: "16rem",
|
|
16355
|
+
backgroundColor: colors.card,
|
|
16356
|
+
borderRadius: borderRadius.xl,
|
|
16357
|
+
boxShadow: shadows.large,
|
|
16358
|
+
border: `1px solid rgba(63, 63, 70, 0.5)`,
|
|
16359
|
+
zIndex: 100,
|
|
16360
|
+
overflow: "hidden",
|
|
16361
|
+
// changed from auto
|
|
16362
|
+
animation: "tw-fade-in 0.2s ease-out",
|
|
16363
|
+
display: "flex",
|
|
16364
|
+
flexDirection: "column"
|
|
16365
|
+
},
|
|
16366
|
+
children: [
|
|
16367
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16368
|
+
"div",
|
|
16369
|
+
{
|
|
16370
|
+
style: {
|
|
16371
|
+
width: "100%",
|
|
16372
|
+
padding: spacing[2]
|
|
16373
|
+
},
|
|
16374
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { style: { display: "flex", gap: spacing[2] }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(WalletNamespaceTabs, { showBitcoin: false }) })
|
|
16375
|
+
}
|
|
16376
|
+
),
|
|
16377
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16378
|
+
"div",
|
|
16379
|
+
{
|
|
16380
|
+
style: {
|
|
16381
|
+
padding: spacing[3],
|
|
16382
|
+
overflowY: "auto",
|
|
16383
|
+
flex: 1,
|
|
16384
|
+
scrollbarWidth: "thin",
|
|
16385
|
+
scrollbarColor: `${colors.muted} transparent`
|
|
16386
|
+
},
|
|
16387
|
+
children: mobileWallets.map((wallet) => {
|
|
16388
|
+
const isConnectedWallet = wallet.id === connectedWalletId;
|
|
16389
|
+
const isDisabled = isConnected && !isConnectedWallet;
|
|
16390
|
+
const isHovered = hoveredId === wallet.id;
|
|
16391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16392
|
+
"button",
|
|
16393
|
+
{
|
|
16394
|
+
type: "button",
|
|
16395
|
+
onClick: () => !isDisabled && handleWalletSelect(wallet),
|
|
16396
|
+
onMouseEnter: () => !isDisabled && setHoveredId(wallet.id),
|
|
16397
|
+
onMouseLeave: () => setHoveredId(null),
|
|
16398
|
+
style: {
|
|
16399
|
+
width: "100%",
|
|
16400
|
+
display: "flex",
|
|
16401
|
+
alignItems: "center",
|
|
16402
|
+
justifyContent: "space-between",
|
|
16403
|
+
padding: spacing[2],
|
|
16404
|
+
borderRadius: borderRadius.lg,
|
|
16405
|
+
transition: "background-color 0.2s",
|
|
16406
|
+
border: "none",
|
|
16407
|
+
backgroundColor: isHovered ? "rgba(255,255,255,0.06)" : "transparent",
|
|
16408
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
16409
|
+
opacity: isDisabled ? 0.4 : 1,
|
|
16410
|
+
fontFamily: "inherit",
|
|
16411
|
+
fontSize: fontSize.sm,
|
|
16412
|
+
outline: "none"
|
|
16413
|
+
},
|
|
16414
|
+
children: [
|
|
16415
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16416
|
+
"div",
|
|
16417
|
+
{
|
|
16418
|
+
style: {
|
|
16419
|
+
display: "flex",
|
|
16420
|
+
alignItems: "center",
|
|
16421
|
+
gap: spacing[2]
|
|
16422
|
+
},
|
|
16423
|
+
children: [
|
|
16424
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16425
|
+
"img",
|
|
16426
|
+
{
|
|
16427
|
+
src: wallet.logo ?? wallet.emoji,
|
|
16428
|
+
alt: wallet.name,
|
|
16429
|
+
style: {
|
|
16430
|
+
width: "2rem",
|
|
16431
|
+
height: "2rem",
|
|
16432
|
+
borderRadius: borderRadius.lg,
|
|
16433
|
+
objectFit: "cover"
|
|
16434
|
+
}
|
|
16435
|
+
}
|
|
16436
|
+
),
|
|
16437
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16438
|
+
"span",
|
|
16439
|
+
{
|
|
16440
|
+
style: {
|
|
16441
|
+
fontWeight: fontWeight.medium,
|
|
16442
|
+
fontSize: fontSize.sm,
|
|
16443
|
+
color: colors.foreground
|
|
16444
|
+
},
|
|
16445
|
+
children: wallet.name
|
|
16446
|
+
}
|
|
16447
|
+
)
|
|
16448
|
+
]
|
|
16449
|
+
}
|
|
16450
|
+
),
|
|
16451
|
+
isConnectedWallet && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16452
|
+
"div",
|
|
16453
|
+
{
|
|
16454
|
+
style: {
|
|
16455
|
+
display: "flex",
|
|
16456
|
+
alignItems: "center",
|
|
16457
|
+
gap: spacing[1]
|
|
16458
|
+
},
|
|
16459
|
+
children: [
|
|
16460
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16461
|
+
"div",
|
|
16462
|
+
{
|
|
16463
|
+
style: {
|
|
16464
|
+
width: "0.5rem",
|
|
16465
|
+
height: "0.5rem",
|
|
16466
|
+
borderRadius: "50%",
|
|
16467
|
+
backgroundColor: "#22c55e"
|
|
16468
|
+
}
|
|
16469
|
+
}
|
|
16470
|
+
),
|
|
16471
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "Connected" })
|
|
16472
|
+
]
|
|
16473
|
+
}
|
|
16474
|
+
)
|
|
16475
|
+
]
|
|
16476
|
+
},
|
|
16477
|
+
wallet.id
|
|
16478
|
+
);
|
|
16479
|
+
})
|
|
16480
|
+
}
|
|
16481
|
+
),
|
|
16482
|
+
showContinueButton && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16483
|
+
"div",
|
|
16484
|
+
{
|
|
16485
|
+
style: {
|
|
16486
|
+
padding: spacing[3],
|
|
16487
|
+
borderTop: `1px solid rgba(63, 63, 70, 0.5)`,
|
|
16488
|
+
backgroundColor: colors.card
|
|
16489
|
+
},
|
|
16490
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16491
|
+
"button",
|
|
16492
|
+
{
|
|
16493
|
+
onClick: handleContinue,
|
|
16494
|
+
style: {
|
|
16495
|
+
width: "100%",
|
|
16496
|
+
padding: `${spacing[2]} ${spacing[3]}`,
|
|
16497
|
+
borderRadius: borderRadius.lg,
|
|
16498
|
+
border: "none",
|
|
16499
|
+
backgroundColor: colors.primary,
|
|
16500
|
+
color: "#fff",
|
|
16501
|
+
fontFamily: "inherit",
|
|
16502
|
+
fontSize: fontSize.sm,
|
|
16503
|
+
fontWeight: fontWeight.medium,
|
|
16504
|
+
cursor: "pointer",
|
|
16505
|
+
transition: "opacity 0.2s"
|
|
16506
|
+
},
|
|
16507
|
+
onMouseEnter: (e2) => e2.currentTarget.style.opacity = "0.85",
|
|
16508
|
+
onMouseLeave: (e2) => e2.currentTarget.style.opacity = "1",
|
|
16509
|
+
children: "Continue \u2192"
|
|
16510
|
+
}
|
|
16511
|
+
)
|
|
16512
|
+
}
|
|
16513
|
+
)
|
|
16514
|
+
]
|
|
16515
|
+
}
|
|
16516
|
+
);
|
|
16517
|
+
}
|
|
16518
|
+
function CryptoWalletDropdownContent({
|
|
16519
|
+
browserWallets,
|
|
16520
|
+
handleWalletConnect,
|
|
16521
|
+
handleWalletSelect
|
|
16522
|
+
}) {
|
|
16523
|
+
const isMobile = useIsMobile();
|
|
16524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
16525
|
+
!isMobile && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16526
|
+
DesktopWalletDropdownContent,
|
|
16527
|
+
{
|
|
16528
|
+
browserWallets,
|
|
16529
|
+
handleWalletConnect,
|
|
16530
|
+
handleWalletSelect
|
|
16531
|
+
}
|
|
16532
|
+
),
|
|
16533
|
+
isMobile && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16534
|
+
MobileWalletDropdownContent,
|
|
16535
|
+
{
|
|
16536
|
+
handleWalletConnect
|
|
16537
|
+
}
|
|
16538
|
+
)
|
|
16539
|
+
] });
|
|
16540
|
+
}
|
|
16541
|
+
var import_react34, import_jsx_runtime36;
|
|
16221
16542
|
var init_CryptoWalletDropdownContent = __esm({
|
|
16222
16543
|
"src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx"() {
|
|
16223
16544
|
"use strict";
|
|
@@ -16228,6 +16549,8 @@ var init_CryptoWalletDropdownContent = __esm({
|
|
|
16228
16549
|
init_paymentOptionStyles();
|
|
16229
16550
|
init_WalletNamespaceTabs();
|
|
16230
16551
|
init_DepositContext();
|
|
16552
|
+
init_wallets();
|
|
16553
|
+
import_react34 = require("react");
|
|
16231
16554
|
import_jsx_runtime36 = require("react/jsx-runtime");
|
|
16232
16555
|
}
|
|
16233
16556
|
});
|
|
@@ -16697,12 +17020,12 @@ function useHomeWalletActions({
|
|
|
16697
17020
|
WalletConnect
|
|
16698
17021
|
// setCurrentStepInternal,
|
|
16699
17022
|
}) {
|
|
16700
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0,
|
|
16701
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0,
|
|
16702
|
-
const cryptoDropdownRef = (0,
|
|
16703
|
-
const fiatDropdownRef = (0,
|
|
17023
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0, import_react35.useState)(false);
|
|
17024
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0, import_react35.useState)(false);
|
|
17025
|
+
const cryptoDropdownRef = (0, import_react35.useRef)(null);
|
|
17026
|
+
const fiatDropdownRef = (0, import_react35.useRef)(null);
|
|
16704
17027
|
const { disconnect } = useWalletInfo();
|
|
16705
|
-
(0,
|
|
17028
|
+
(0, import_react35.useEffect)(() => {
|
|
16706
17029
|
const handleClickOutside = (event) => {
|
|
16707
17030
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
16708
17031
|
setIsCryptoDropdownOpen(false);
|
|
@@ -16717,7 +17040,7 @@ function useHomeWalletActions({
|
|
|
16717
17040
|
const { resetNavigation } = useDepositNavigationState("home");
|
|
16718
17041
|
const { setYourWalletTokens } = useDepositWallet();
|
|
16719
17042
|
const { isConnected, walletMetaId, connectedVia } = useWalletInfo();
|
|
16720
|
-
const handleWalletSelect = (0,
|
|
17043
|
+
const handleWalletSelect = (0, import_react35.useCallback)(
|
|
16721
17044
|
async (wallet) => {
|
|
16722
17045
|
setIsCryptoDropdownOpen(false);
|
|
16723
17046
|
try {
|
|
@@ -16728,6 +17051,7 @@ function useHomeWalletActions({
|
|
|
16728
17051
|
setWalletType("other");
|
|
16729
17052
|
const { error } = await connectWallet(wallet);
|
|
16730
17053
|
if (error) {
|
|
17054
|
+
console.error("Wallet connection error:", error);
|
|
16731
17055
|
resetNavigation();
|
|
16732
17056
|
return;
|
|
16733
17057
|
}
|
|
@@ -16741,7 +17065,7 @@ function useHomeWalletActions({
|
|
|
16741
17065
|
const handleFiatSelect = () => {
|
|
16742
17066
|
setIsFiatDropdownOpen(false);
|
|
16743
17067
|
};
|
|
16744
|
-
const handleWalletConnect = (0,
|
|
17068
|
+
const handleWalletConnect = (0, import_react35.useCallback)(async () => {
|
|
16745
17069
|
if (connectedVia !== "walletconnect" && isConnected) {
|
|
16746
17070
|
disconnect();
|
|
16747
17071
|
setYourWalletTokens([]);
|
|
@@ -16749,7 +17073,7 @@ function useHomeWalletActions({
|
|
|
16749
17073
|
WalletConnect().catch(() => resetNavigation());
|
|
16750
17074
|
}, [setYourWalletTokens, disconnect]);
|
|
16751
17075
|
const { selectedNamespace } = useDepositWallet();
|
|
16752
|
-
const browserWallets = (0,
|
|
17076
|
+
const browserWallets = (0, import_react35.useMemo)(() => {
|
|
16753
17077
|
if (!detectedWallets?.length) return [];
|
|
16754
17078
|
return detectedWallets.filter(
|
|
16755
17079
|
(wallet) => wallet?.meta?.id !== "walletconnect" && wallet?.meta?.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase()
|
|
@@ -16768,11 +17092,11 @@ function useHomeWalletActions({
|
|
|
16768
17092
|
setIsFiatDropdownOpen
|
|
16769
17093
|
};
|
|
16770
17094
|
}
|
|
16771
|
-
var
|
|
17095
|
+
var import_react35;
|
|
16772
17096
|
var init_useHomeWalletActions = __esm({
|
|
16773
17097
|
"src/widget/features/wallet/hooks/useHomeWalletActions.ts"() {
|
|
16774
17098
|
"use strict";
|
|
16775
|
-
|
|
17099
|
+
import_react35 = require("react");
|
|
16776
17100
|
init_useDepositNavigationState();
|
|
16777
17101
|
init_DepositContext();
|
|
16778
17102
|
init_wallets();
|
|
@@ -17177,7 +17501,7 @@ function useRoutePreviewModel({
|
|
|
17177
17501
|
walletAddress
|
|
17178
17502
|
}) {
|
|
17179
17503
|
const { chains } = useChains();
|
|
17180
|
-
const destinationConfig = (0,
|
|
17504
|
+
const destinationConfig = (0, import_react36.useMemo)(
|
|
17181
17505
|
() => ({
|
|
17182
17506
|
dappName: config.messages?.title || "DApp",
|
|
17183
17507
|
toChain: config.routes.toChain,
|
|
@@ -17191,7 +17515,7 @@ function useRoutePreviewModel({
|
|
|
17191
17515
|
config.routes.toToken
|
|
17192
17516
|
]
|
|
17193
17517
|
);
|
|
17194
|
-
const routeConfig = (0,
|
|
17518
|
+
const routeConfig = (0, import_react36.useMemo)(() => {
|
|
17195
17519
|
const toChainId = config.routes.toChain;
|
|
17196
17520
|
const toChainKey = normalizeChainKey2(toChainId);
|
|
17197
17521
|
const toChain = toChainKey ? chains.find(
|
|
@@ -17228,7 +17552,7 @@ function useRoutePreviewModel({
|
|
|
17228
17552
|
...routeConfig,
|
|
17229
17553
|
enabled: !!isReady
|
|
17230
17554
|
});
|
|
17231
|
-
const routePrerequisiteError = (0,
|
|
17555
|
+
const routePrerequisiteError = (0, import_react36.useMemo)(() => {
|
|
17232
17556
|
if (!isReady) return;
|
|
17233
17557
|
if (!selectedChain) {
|
|
17234
17558
|
return "Select a source chain to fetch a route.";
|
|
@@ -17269,11 +17593,11 @@ function useRoutePreviewModel({
|
|
|
17269
17593
|
...routeBuilderState
|
|
17270
17594
|
};
|
|
17271
17595
|
}
|
|
17272
|
-
var
|
|
17596
|
+
var import_react36;
|
|
17273
17597
|
var init_useRoutePreviewModel = __esm({
|
|
17274
17598
|
"src/widget/features/route-preview/hooks/useRoutePreviewModel.ts"() {
|
|
17275
17599
|
"use strict";
|
|
17276
|
-
|
|
17600
|
+
import_react36 = require("react");
|
|
17277
17601
|
init_hooks2();
|
|
17278
17602
|
init_chainHelpers();
|
|
17279
17603
|
}
|
|
@@ -30834,7 +31158,7 @@ function useTransactionActionModel({
|
|
|
30834
31158
|
walletAddress,
|
|
30835
31159
|
walletStatus
|
|
30836
31160
|
}) {
|
|
30837
|
-
const feeDataCacheRef = (0,
|
|
31161
|
+
const feeDataCacheRef = (0, import_react37.useRef)({});
|
|
30838
31162
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
30839
31163
|
const { trackEvent } = useGTM(GTM_ID);
|
|
30840
31164
|
const destinationConfig = (() => {
|
|
@@ -30847,7 +31171,7 @@ function useTransactionActionModel({
|
|
|
30847
31171
|
const chainType = selectedChain?.type ?? selectedChain?.chainType;
|
|
30848
31172
|
const chainTypeNormalized = (chainType ?? "").toLowerCase();
|
|
30849
31173
|
const isEvm = chainTypeNormalized === "evm";
|
|
30850
|
-
const backendChainId2 = (0,
|
|
31174
|
+
const backendChainId2 = (0, import_react37.useMemo)(() => {
|
|
30851
31175
|
const chainRef = routeResult?.txReq?.chainId ?? selectedChain?.networkIdentifier ?? selectedChain?.chainId ?? selectedChain?.id;
|
|
30852
31176
|
if (chainRef == null) return null;
|
|
30853
31177
|
return String(chainRef);
|
|
@@ -30857,7 +31181,7 @@ function useTransactionActionModel({
|
|
|
30857
31181
|
selectedChain?.id,
|
|
30858
31182
|
selectedChain?.networkIdentifier
|
|
30859
31183
|
]);
|
|
30860
|
-
const selectedTokenOnBackendChain = (0,
|
|
31184
|
+
const selectedTokenOnBackendChain = (0, import_react37.useMemo)(() => {
|
|
30861
31185
|
if (!backendChainId2) return false;
|
|
30862
31186
|
const target = normalizeChainKey2(backendChainId2);
|
|
30863
31187
|
return [
|
|
@@ -30874,23 +31198,23 @@ function useTransactionActionModel({
|
|
|
30874
31198
|
selectedChain?.id,
|
|
30875
31199
|
selectedChain?.networkIdentifier
|
|
30876
31200
|
]);
|
|
30877
|
-
const isNativeSelected = (0,
|
|
31201
|
+
const isNativeSelected = (0, import_react37.useMemo)(() => {
|
|
30878
31202
|
const address = selectedToken?.address;
|
|
30879
31203
|
return isNativeTokenAddress(address, chainType) || isZeroAddrLike(address, chainType) || normalizeTokenAddressForCompare(selectedChain, address) === normalizeTokenAddressForCompare(
|
|
30880
31204
|
selectedChain,
|
|
30881
31205
|
getNativeTokenAddress2(chainType)
|
|
30882
31206
|
);
|
|
30883
31207
|
}, [chainType, selectedChain, selectedToken?.address]);
|
|
30884
|
-
const spender = (0,
|
|
31208
|
+
const spender = (0, import_react37.useMemo)(() => {
|
|
30885
31209
|
const txReq = routeResult?.txReq;
|
|
30886
31210
|
const addr = txReq?.to ?? txReq?.target;
|
|
30887
31211
|
return addr ?? null;
|
|
30888
31212
|
}, [routeResult?.txReq]);
|
|
30889
|
-
const [allowanceWei, setAllowanceWei] = (0,
|
|
30890
|
-
const [isReadingAllowance, setIsReadingAllowance] = (0,
|
|
30891
|
-
const [isApproving, setIsApproving] = (0,
|
|
30892
|
-
const [gasReservationWei, setGasReservationWei] = (0,
|
|
30893
|
-
const readAllowance = (0,
|
|
31213
|
+
const [allowanceWei, setAllowanceWei] = (0, import_react37.useState)(0n);
|
|
31214
|
+
const [isReadingAllowance, setIsReadingAllowance] = (0, import_react37.useState)(false);
|
|
31215
|
+
const [isApproving, setIsApproving] = (0, import_react37.useState)(false);
|
|
31216
|
+
const [gasReservationWei, setGasReservationWei] = (0, import_react37.useState)(0n);
|
|
31217
|
+
const readAllowance = (0, import_react37.useCallback)(async () => {
|
|
30894
31218
|
if (!isEvm || isNativeSelected || !!routeResult?.sponsorship || // sponsored routes: SA approves bridge inside the UO batch
|
|
30895
31219
|
!backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
30896
31220
|
setAllowanceWei(0n);
|
|
@@ -30920,12 +31244,12 @@ function useTransactionActionModel({
|
|
|
30920
31244
|
spender,
|
|
30921
31245
|
walletAddress
|
|
30922
31246
|
]);
|
|
30923
|
-
(0,
|
|
31247
|
+
(0, import_react37.useEffect)(() => {
|
|
30924
31248
|
void readAllowance();
|
|
30925
31249
|
}, [readAllowance]);
|
|
30926
31250
|
const needsApproval = isEvm && !isNativeSelected && !routeResult?.sponsorship && // sponsored routes use Permit2 + SA internal batch — no EOA bridge approval
|
|
30927
31251
|
!!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
|
|
30928
|
-
const waitForApprovalConfirmation2 = (0,
|
|
31252
|
+
const waitForApprovalConfirmation2 = (0, import_react37.useCallback)(
|
|
30929
31253
|
async (chainId, txHash) => {
|
|
30930
31254
|
const timeoutMs = 12e4;
|
|
30931
31255
|
const intervalMs = 2e3;
|
|
@@ -30944,7 +31268,7 @@ function useTransactionActionModel({
|
|
|
30944
31268
|
},
|
|
30945
31269
|
[]
|
|
30946
31270
|
);
|
|
30947
|
-
const handleApproveExact = (0,
|
|
31271
|
+
const handleApproveExact = (0, import_react37.useCallback)(async () => {
|
|
30948
31272
|
if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
|
|
30949
31273
|
return;
|
|
30950
31274
|
}
|
|
@@ -31037,7 +31361,7 @@ function useTransactionActionModel({
|
|
|
31037
31361
|
waitForApprovalConfirmation2,
|
|
31038
31362
|
walletAddress
|
|
31039
31363
|
]);
|
|
31040
|
-
const getCachedFeeData = (0,
|
|
31364
|
+
const getCachedFeeData = (0, import_react37.useCallback)(async () => {
|
|
31041
31365
|
if (!backendChainId2) return {};
|
|
31042
31366
|
const now = Date.now();
|
|
31043
31367
|
const cache = feeDataCacheRef.current;
|
|
@@ -31060,7 +31384,7 @@ function useTransactionActionModel({
|
|
|
31060
31384
|
}
|
|
31061
31385
|
return cache.inflight;
|
|
31062
31386
|
}, [backendChainId2]);
|
|
31063
|
-
const estimateGasReservationWei = (0,
|
|
31387
|
+
const estimateGasReservationWei = (0, import_react37.useCallback)(async () => {
|
|
31064
31388
|
if (!isNativeSelected) {
|
|
31065
31389
|
setGasReservationWei(0n);
|
|
31066
31390
|
return 0n;
|
|
@@ -31124,16 +31448,16 @@ function useTransactionActionModel({
|
|
|
31124
31448
|
routeResult?.txReq,
|
|
31125
31449
|
walletAddress
|
|
31126
31450
|
]);
|
|
31127
|
-
(0,
|
|
31451
|
+
(0, import_react37.useEffect)(() => {
|
|
31128
31452
|
if (routeResult) {
|
|
31129
31453
|
void estimateGasReservationWei();
|
|
31130
31454
|
}
|
|
31131
31455
|
}, [estimateGasReservationWei, routeResult]);
|
|
31132
|
-
const [smartAccountFailed, setSmartAccountFailed] = (0,
|
|
31133
|
-
(0,
|
|
31456
|
+
const [smartAccountFailed, setSmartAccountFailed] = (0, import_react37.useState)(false);
|
|
31457
|
+
(0, import_react37.useEffect)(() => {
|
|
31134
31458
|
setSmartAccountFailed(false);
|
|
31135
31459
|
}, [routeResult?.intentId]);
|
|
31136
|
-
const handleConfirm = (0,
|
|
31460
|
+
const handleConfirm = (0, import_react37.useCallback)(async () => {
|
|
31137
31461
|
if (!routeResult) {
|
|
31138
31462
|
return;
|
|
31139
31463
|
}
|
|
@@ -31203,7 +31527,7 @@ function useTransactionActionModel({
|
|
|
31203
31527
|
trackEvent,
|
|
31204
31528
|
walletAddress
|
|
31205
31529
|
]);
|
|
31206
|
-
const handleSwipeConfirm = (0,
|
|
31530
|
+
const handleSwipeConfirm = (0, import_react37.useCallback)(async () => {
|
|
31207
31531
|
if (needsApproval) {
|
|
31208
31532
|
await handleApproveExact();
|
|
31209
31533
|
if (!backendChainId2 || !selectedTokenOnBackendChain || !selectedToken?.address || !walletAddress || !spender) {
|
|
@@ -31234,7 +31558,7 @@ function useTransactionActionModel({
|
|
|
31234
31558
|
]);
|
|
31235
31559
|
const isWalletConnected = walletStatus === "connected";
|
|
31236
31560
|
const canSwipe = parsedAmount > 0 && !!selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
|
|
31237
|
-
const swipeResetKey = (0,
|
|
31561
|
+
const swipeResetKey = (0, import_react37.useMemo)(() => {
|
|
31238
31562
|
const tokenAddress = selectedToken ? normalizeAddress2(
|
|
31239
31563
|
selectedToken.address,
|
|
31240
31564
|
selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType
|
|
@@ -31260,11 +31584,11 @@ function useTransactionActionModel({
|
|
|
31260
31584
|
swipeResetKey
|
|
31261
31585
|
};
|
|
31262
31586
|
}
|
|
31263
|
-
var
|
|
31587
|
+
var import_react37, import_viem42;
|
|
31264
31588
|
var init_useTransactionActionModel = __esm({
|
|
31265
31589
|
"src/widget/features/transaction/hooks/useTransactionActionModel.ts"() {
|
|
31266
31590
|
"use strict";
|
|
31267
|
-
|
|
31591
|
+
import_react37 = require("react");
|
|
31268
31592
|
import_viem42 = require("viem");
|
|
31269
31593
|
init_core2();
|
|
31270
31594
|
init_sdkRpc();
|
|
@@ -31468,9 +31792,9 @@ var init_DefaultCryptoPay = __esm({
|
|
|
31468
31792
|
|
|
31469
31793
|
// src/widget/pages/CryptoPay/RouteQuoteLoader.tsx
|
|
31470
31794
|
function RouteQuoteLoader({ selectedToken }) {
|
|
31471
|
-
const [messageIndex, setMessageIndex] = (0,
|
|
31472
|
-
const [visible, setVisible] = (0,
|
|
31473
|
-
(0,
|
|
31795
|
+
const [messageIndex, setMessageIndex] = (0, import_react38.useState)(0);
|
|
31796
|
+
const [visible, setVisible] = (0, import_react38.useState)(true);
|
|
31797
|
+
(0, import_react38.useEffect)(() => {
|
|
31474
31798
|
let t = null;
|
|
31475
31799
|
const interval = setInterval(() => {
|
|
31476
31800
|
setVisible(false);
|
|
@@ -31626,11 +31950,11 @@ function RouteQuoteLoader({ selectedToken }) {
|
|
|
31626
31950
|
}
|
|
31627
31951
|
);
|
|
31628
31952
|
}
|
|
31629
|
-
var
|
|
31953
|
+
var import_react38, import_jsx_runtime49, QUOTE_MESSAGES;
|
|
31630
31954
|
var init_RouteQuoteLoader = __esm({
|
|
31631
31955
|
"src/widget/pages/CryptoPay/RouteQuoteLoader.tsx"() {
|
|
31632
31956
|
"use strict";
|
|
31633
|
-
|
|
31957
|
+
import_react38 = require("react");
|
|
31634
31958
|
init_styles();
|
|
31635
31959
|
import_jsx_runtime49 = require("react/jsx-runtime");
|
|
31636
31960
|
QUOTE_MESSAGES = [
|
|
@@ -31670,17 +31994,17 @@ function CryptoPay({ style: _style }) {
|
|
|
31670
31994
|
const { goBack, setCurrentStep, currentStep } = useDepositNavigation();
|
|
31671
31995
|
const config = useTrustwareConfig();
|
|
31672
31996
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
31673
|
-
const routeRefreshMs = (0,
|
|
31997
|
+
const routeRefreshMs = (0, import_react39.useMemo)(() => {
|
|
31674
31998
|
const raw = config.routes?.options?.routeRefreshMs;
|
|
31675
31999
|
const n = Number(raw);
|
|
31676
32000
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
31677
32001
|
}, [config.routes?.options?.routeRefreshMs]);
|
|
31678
32002
|
const IsPos = (x) => x !== null && x !== void 0 && x.balance !== "0";
|
|
31679
|
-
const showDefaultCryptoPay = (0,
|
|
32003
|
+
const showDefaultCryptoPay = (0, import_react39.useMemo)(() => {
|
|
31680
32004
|
const nonZer0Tks = (yourWalletTokens ?? []).filter(IsPos);
|
|
31681
32005
|
return !yourWalletTokensLoading && nonZer0Tks.length === 0 && yourWalletTokens.length > 0;
|
|
31682
32006
|
}, [yourWalletTokens, yourWalletTokensLoading]);
|
|
31683
|
-
const showSkeleton = (0,
|
|
32007
|
+
const showSkeleton = (0, import_react39.useMemo)(() => {
|
|
31684
32008
|
return (yourWalletTokens ?? []).length === 0;
|
|
31685
32009
|
}, [yourWalletTokens]);
|
|
31686
32010
|
const isReady = selectedToken != null && selectedToken?.chainData !== void 0 && !showDefaultCryptoPay && !showSkeleton;
|
|
@@ -31756,7 +32080,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31756
32080
|
});
|
|
31757
32081
|
const { emitError } = useTrustware();
|
|
31758
32082
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
31759
|
-
(0,
|
|
32083
|
+
(0, import_react39.useEffect)(() => {
|
|
31760
32084
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
31761
32085
|
emitError?.(
|
|
31762
32086
|
new TrustwareError({
|
|
@@ -31785,7 +32109,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31785
32109
|
if (isFixedAmount) return;
|
|
31786
32110
|
setAmount(value.toString());
|
|
31787
32111
|
};
|
|
31788
|
-
const relayFeeUsd = (0,
|
|
32112
|
+
const relayFeeUsd = (0, import_react39.useMemo)(
|
|
31789
32113
|
() => computeRelayFeeUsd(routeResult, isNativeSelected),
|
|
31790
32114
|
[isNativeSelected, routeResult]
|
|
31791
32115
|
);
|
|
@@ -31955,11 +32279,11 @@ function CryptoPay({ style: _style }) {
|
|
|
31955
32279
|
}
|
|
31956
32280
|
);
|
|
31957
32281
|
}
|
|
31958
|
-
var
|
|
32282
|
+
var import_react39, import_jsx_runtime50, SHOW_FEE_SUMMARY;
|
|
31959
32283
|
var init_CryptoPay = __esm({
|
|
31960
32284
|
"src/widget/pages/CryptoPay/index.tsx"() {
|
|
31961
32285
|
"use strict";
|
|
31962
|
-
|
|
32286
|
+
import_react39 = require("react");
|
|
31963
32287
|
init_relayFeeUtils();
|
|
31964
32288
|
init_TrustwareError();
|
|
31965
32289
|
init_useTrustwareConfig();
|
|
@@ -32016,27 +32340,27 @@ function Processing({ style }) {
|
|
|
32016
32340
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
32017
32341
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
32018
32342
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
32019
|
-
const hasStartedPolling = (0,
|
|
32020
|
-
(0,
|
|
32343
|
+
const hasStartedPolling = (0, import_react40.useRef)(false);
|
|
32344
|
+
(0, import_react40.useEffect)(() => {
|
|
32021
32345
|
return () => {
|
|
32022
32346
|
hasStartedPolling.current = false;
|
|
32023
32347
|
};
|
|
32024
32348
|
}, []);
|
|
32025
|
-
(0,
|
|
32349
|
+
(0, import_react40.useEffect)(() => {
|
|
32026
32350
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
32027
32351
|
hasStartedPolling.current = true;
|
|
32028
32352
|
startPolling(intentId, transactionHash);
|
|
32029
32353
|
}
|
|
32030
32354
|
}, [intentId, transactionHash, isPolling, transactionStatus, startPolling]);
|
|
32031
|
-
const progress = (0,
|
|
32355
|
+
const progress = (0, import_react40.useMemo)(
|
|
32032
32356
|
() => getProgressFromStatus(transactionStatus),
|
|
32033
32357
|
[transactionStatus]
|
|
32034
32358
|
);
|
|
32035
|
-
const stepText = (0,
|
|
32359
|
+
const stepText = (0, import_react40.useMemo)(
|
|
32036
32360
|
() => getStepText(transactionStatus),
|
|
32037
32361
|
[transactionStatus]
|
|
32038
32362
|
);
|
|
32039
|
-
const explorerUrl = (0,
|
|
32363
|
+
const explorerUrl = (0, import_react40.useMemo)(() => {
|
|
32040
32364
|
if (transaction?.fromChainTxUrl) {
|
|
32041
32365
|
return transaction.fromChainTxUrl;
|
|
32042
32366
|
}
|
|
@@ -32171,11 +32495,11 @@ function Processing({ style }) {
|
|
|
32171
32495
|
}
|
|
32172
32496
|
);
|
|
32173
32497
|
}
|
|
32174
|
-
var
|
|
32498
|
+
var import_react40, import_jsx_runtime51;
|
|
32175
32499
|
var init_Processing = __esm({
|
|
32176
32500
|
"src/widget/pages/Processing.tsx"() {
|
|
32177
32501
|
"use strict";
|
|
32178
|
-
|
|
32502
|
+
import_react40 = require("react");
|
|
32179
32503
|
init_styles();
|
|
32180
32504
|
init_DepositContext();
|
|
32181
32505
|
init_components();
|
|
@@ -32190,8 +32514,8 @@ function Success({ style }) {
|
|
|
32190
32514
|
const { resetState } = useDepositNavigation();
|
|
32191
32515
|
const { transactionHash } = useDepositTransaction();
|
|
32192
32516
|
const { transaction } = useTransactionPolling();
|
|
32193
|
-
const parsedAmount = (0,
|
|
32194
|
-
const explorerUrl = (0,
|
|
32517
|
+
const parsedAmount = (0, import_react41.useMemo)(() => parseFloat(amount) || 0, [amount]);
|
|
32518
|
+
const explorerUrl = (0, import_react41.useMemo)(() => {
|
|
32195
32519
|
if (transaction?.toChainTxUrl) {
|
|
32196
32520
|
return transaction.toChainTxUrl;
|
|
32197
32521
|
}
|
|
@@ -32219,7 +32543,7 @@ function Success({ style }) {
|
|
|
32219
32543
|
...style
|
|
32220
32544
|
},
|
|
32221
32545
|
children: [
|
|
32222
|
-
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
32546
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react41.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ConfettiEffect2, { isActive: true, pieceCount: 60, clearDelay: 4e3 }) }),
|
|
32223
32547
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(WidgetPageHeader, { title: "Deposit Complete" }),
|
|
32224
32548
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
32225
32549
|
"div",
|
|
@@ -32252,16 +32576,16 @@ function Success({ style }) {
|
|
|
32252
32576
|
}
|
|
32253
32577
|
);
|
|
32254
32578
|
}
|
|
32255
|
-
var
|
|
32579
|
+
var import_react41, import_jsx_runtime52, ConfettiEffect2;
|
|
32256
32580
|
var init_Success = __esm({
|
|
32257
32581
|
"src/widget/pages/Success.tsx"() {
|
|
32258
32582
|
"use strict";
|
|
32259
|
-
|
|
32583
|
+
import_react41 = require("react");
|
|
32260
32584
|
init_DepositContext();
|
|
32261
32585
|
init_components();
|
|
32262
32586
|
init_transaction2();
|
|
32263
32587
|
import_jsx_runtime52 = require("react/jsx-runtime");
|
|
32264
|
-
ConfettiEffect2 = (0,
|
|
32588
|
+
ConfettiEffect2 = (0, import_react41.lazy)(() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports)));
|
|
32265
32589
|
}
|
|
32266
32590
|
});
|
|
32267
32591
|
|
|
@@ -32423,8 +32747,8 @@ function Error2({ style: _style }) {
|
|
|
32423
32747
|
setErrorMessage,
|
|
32424
32748
|
transactionHash
|
|
32425
32749
|
} = useDepositTransaction();
|
|
32426
|
-
const mapped = (0,
|
|
32427
|
-
const explorerUrl = (0,
|
|
32750
|
+
const mapped = (0, import_react42.useMemo)(() => mapError(errorMessage), [errorMessage]);
|
|
32751
|
+
const explorerUrl = (0, import_react42.useMemo)(() => {
|
|
32428
32752
|
if (transactionHash && selectedChain?.blockExplorerUrls?.length) {
|
|
32429
32753
|
return `${selectedChain.blockExplorerUrls[0].replace(/\/+$/, "")}/tx/${transactionHash}`;
|
|
32430
32754
|
}
|
|
@@ -32447,11 +32771,11 @@ function Error2({ style: _style }) {
|
|
|
32447
32771
|
}
|
|
32448
32772
|
);
|
|
32449
32773
|
}
|
|
32450
|
-
var
|
|
32774
|
+
var import_react42, import_jsx_runtime53;
|
|
32451
32775
|
var init_Error = __esm({
|
|
32452
32776
|
"src/widget/pages/Error.tsx"() {
|
|
32453
32777
|
"use strict";
|
|
32454
|
-
|
|
32778
|
+
import_react42 = require("react");
|
|
32455
32779
|
init_DepositContext();
|
|
32456
32780
|
init_components();
|
|
32457
32781
|
init_mapError();
|
|
@@ -32492,11 +32816,11 @@ function WidgetRouter({
|
|
|
32492
32816
|
navigationDirection,
|
|
32493
32817
|
stepHistory
|
|
32494
32818
|
}) {
|
|
32495
|
-
const PageComponent = (0,
|
|
32819
|
+
const PageComponent = (0, import_react43.useMemo)(
|
|
32496
32820
|
() => PAGE_COMPONENTS[currentStep],
|
|
32497
32821
|
[currentStep]
|
|
32498
32822
|
);
|
|
32499
|
-
const animationClass = (0,
|
|
32823
|
+
const animationClass = (0, import_react43.useMemo)(() => {
|
|
32500
32824
|
return navigationDirection === "forward" ? "tw-animate-slide-in-right" : "tw-animate-slide-in-left";
|
|
32501
32825
|
}, [navigationDirection]);
|
|
32502
32826
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
@@ -32509,11 +32833,11 @@ function WidgetRouter({
|
|
|
32509
32833
|
`${currentStep}-${stepHistory.length}`
|
|
32510
32834
|
);
|
|
32511
32835
|
}
|
|
32512
|
-
var
|
|
32836
|
+
var import_react43, import_jsx_runtime54, pageContainerBaseStyle;
|
|
32513
32837
|
var init_WidgetRouter = __esm({
|
|
32514
32838
|
"src/widget/app/WidgetRouter.tsx"() {
|
|
32515
32839
|
"use strict";
|
|
32516
|
-
|
|
32840
|
+
import_react43 = require("react");
|
|
32517
32841
|
init_utils2();
|
|
32518
32842
|
init_widgetSteps();
|
|
32519
32843
|
import_jsx_runtime54 = require("react/jsx-runtime");
|
|
@@ -32527,13 +32851,13 @@ var init_WidgetRouter = __esm({
|
|
|
32527
32851
|
|
|
32528
32852
|
// src/modes/swap/hooks/useSwapRoute.ts
|
|
32529
32853
|
function useSwapRoute() {
|
|
32530
|
-
const [state, setState] = (0,
|
|
32854
|
+
const [state, setState] = (0, import_react44.useState)({
|
|
32531
32855
|
data: null,
|
|
32532
32856
|
loading: false,
|
|
32533
32857
|
error: null
|
|
32534
32858
|
});
|
|
32535
|
-
const abortRef = (0,
|
|
32536
|
-
const fetch2 = (0,
|
|
32859
|
+
const abortRef = (0, import_react44.useRef)(false);
|
|
32860
|
+
const fetch2 = (0, import_react44.useCallback)(
|
|
32537
32861
|
async (params) => {
|
|
32538
32862
|
const { fromToken, fromChain, toToken, toChain, amount, walletAddress } = params;
|
|
32539
32863
|
const decimals = fromToken.decimals ?? 18;
|
|
@@ -32574,18 +32898,18 @@ function useSwapRoute() {
|
|
|
32574
32898
|
},
|
|
32575
32899
|
[]
|
|
32576
32900
|
);
|
|
32577
|
-
const clear = (0,
|
|
32901
|
+
const clear = (0, import_react44.useCallback)(() => {
|
|
32578
32902
|
abortRef.current = true;
|
|
32579
32903
|
setState({ data: null, loading: false, error: null });
|
|
32580
32904
|
}, []);
|
|
32581
32905
|
return { ...state, fetch: fetch2, clear };
|
|
32582
32906
|
}
|
|
32583
|
-
var
|
|
32907
|
+
var import_react44;
|
|
32584
32908
|
var init_useSwapRoute = __esm({
|
|
32585
32909
|
"src/modes/swap/hooks/useSwapRoute.ts"() {
|
|
32586
32910
|
"use strict";
|
|
32587
32911
|
"use client";
|
|
32588
|
-
|
|
32912
|
+
import_react44 = require("react");
|
|
32589
32913
|
init_routes();
|
|
32590
32914
|
init_chainHelpers();
|
|
32591
32915
|
init_store();
|
|
@@ -32626,7 +32950,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
32626
32950
|
throw new Error("Timed out waiting for approval confirmation");
|
|
32627
32951
|
}
|
|
32628
32952
|
function useSwapExecution(fromChain) {
|
|
32629
|
-
const [state, setState] = (0,
|
|
32953
|
+
const [state, setState] = (0, import_react45.useState)({
|
|
32630
32954
|
txStatus: "idle",
|
|
32631
32955
|
txHash: null,
|
|
32632
32956
|
intentId: null,
|
|
@@ -32635,19 +32959,19 @@ function useSwapExecution(fromChain) {
|
|
|
32635
32959
|
isSubmitting: false,
|
|
32636
32960
|
allowanceStatus: "unknown"
|
|
32637
32961
|
});
|
|
32638
|
-
const saFailedUntilRef = (0,
|
|
32639
|
-
const pollingRef = (0,
|
|
32640
|
-
const timeoutRef = (0,
|
|
32641
|
-
const abortRef = (0,
|
|
32642
|
-
const pollCountRef = (0,
|
|
32643
|
-
const clearPolling = (0,
|
|
32962
|
+
const saFailedUntilRef = (0, import_react45.useRef)(0);
|
|
32963
|
+
const pollingRef = (0, import_react45.useRef)(null);
|
|
32964
|
+
const timeoutRef = (0, import_react45.useRef)(null);
|
|
32965
|
+
const abortRef = (0, import_react45.useRef)(false);
|
|
32966
|
+
const pollCountRef = (0, import_react45.useRef)(0);
|
|
32967
|
+
const clearPolling = (0, import_react45.useCallback)(() => {
|
|
32644
32968
|
abortRef.current = true;
|
|
32645
32969
|
if (pollingRef.current) clearTimeout(pollingRef.current);
|
|
32646
32970
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
32647
32971
|
pollingRef.current = null;
|
|
32648
32972
|
timeoutRef.current = null;
|
|
32649
32973
|
}, []);
|
|
32650
|
-
const startPolling = (0,
|
|
32974
|
+
const startPolling = (0, import_react45.useCallback)(
|
|
32651
32975
|
(intentIdVal, onSuccess, onError) => {
|
|
32652
32976
|
clearPolling();
|
|
32653
32977
|
abortRef.current = false;
|
|
@@ -32692,7 +33016,7 @@ function useSwapExecution(fromChain) {
|
|
|
32692
33016
|
},
|
|
32693
33017
|
[clearPolling]
|
|
32694
33018
|
);
|
|
32695
|
-
const checkAllowance = (0,
|
|
33019
|
+
const checkAllowance = (0, import_react45.useCallback)(
|
|
32696
33020
|
async (params) => {
|
|
32697
33021
|
const { fromTokenAddress, walletAddress, routeResult } = params;
|
|
32698
33022
|
if (routeResult.sponsorship) {
|
|
@@ -32732,7 +33056,7 @@ function useSwapExecution(fromChain) {
|
|
|
32732
33056
|
},
|
|
32733
33057
|
[fromChain]
|
|
32734
33058
|
);
|
|
32735
|
-
const execute = (0,
|
|
33059
|
+
const execute = (0, import_react45.useCallback)(
|
|
32736
33060
|
async (routeResult, fromTokenAddress, fromTokenDecimals, walletAddress, maxApproval, onSuccess, onError) => {
|
|
32737
33061
|
if (!routeResult?.txReq) {
|
|
32738
33062
|
const msg = "Invalid route data. Please try again.";
|
|
@@ -32928,10 +33252,10 @@ function useSwapExecution(fromChain) {
|
|
|
32928
33252
|
},
|
|
32929
33253
|
[fromChain, startPolling]
|
|
32930
33254
|
);
|
|
32931
|
-
const resetSmartAccountFailure = (0,
|
|
33255
|
+
const resetSmartAccountFailure = (0, import_react45.useCallback)(() => {
|
|
32932
33256
|
saFailedUntilRef.current = 0;
|
|
32933
33257
|
}, []);
|
|
32934
|
-
const reset = (0,
|
|
33258
|
+
const reset = (0, import_react45.useCallback)(() => {
|
|
32935
33259
|
clearPolling();
|
|
32936
33260
|
saFailedUntilRef.current = 0;
|
|
32937
33261
|
setState({
|
|
@@ -32962,12 +33286,12 @@ function mapTxError(err) {
|
|
|
32962
33286
|
return "Transaction would fail. Try a different amount.";
|
|
32963
33287
|
return msg.length > 150 ? msg.slice(0, 147) + "..." : msg || "Transaction failed.";
|
|
32964
33288
|
}
|
|
32965
|
-
var
|
|
33289
|
+
var import_react45, import_viem43, FAST_POLL_MS, SLOW_POLL_MS, TIMEOUT_MS, SA_COOLDOWN_MS;
|
|
32966
33290
|
var init_useSwapExecution = __esm({
|
|
32967
33291
|
"src/modes/swap/hooks/useSwapExecution.ts"() {
|
|
32968
33292
|
"use strict";
|
|
32969
33293
|
"use client";
|
|
32970
|
-
|
|
33294
|
+
import_react45 = require("react");
|
|
32971
33295
|
import_viem43 = require("viem");
|
|
32972
33296
|
init_core2();
|
|
32973
33297
|
init_routes();
|
|
@@ -33005,11 +33329,11 @@ var init_forex = __esm({
|
|
|
33005
33329
|
|
|
33006
33330
|
// src/modes/swap/hooks/useForex.ts
|
|
33007
33331
|
function useForex() {
|
|
33008
|
-
const [rates, setRates] = (0,
|
|
33009
|
-
const [error, setError] = (0,
|
|
33010
|
-
const [lastUpdated, setLastUpdated] = (0,
|
|
33011
|
-
const timerRef = (0,
|
|
33012
|
-
(0,
|
|
33332
|
+
const [rates, setRates] = (0, import_react46.useState)({ USD: 1 });
|
|
33333
|
+
const [error, setError] = (0, import_react46.useState)(null);
|
|
33334
|
+
const [lastUpdated, setLastUpdated] = (0, import_react46.useState)(null);
|
|
33335
|
+
const timerRef = (0, import_react46.useRef)(null);
|
|
33336
|
+
(0, import_react46.useEffect)(() => {
|
|
33013
33337
|
let cancelled = false;
|
|
33014
33338
|
const load = () => {
|
|
33015
33339
|
fetchForexRates("USD").then((r) => {
|
|
@@ -33036,11 +33360,11 @@ function useForex() {
|
|
|
33036
33360
|
}, []);
|
|
33037
33361
|
return { rates, error, lastUpdated };
|
|
33038
33362
|
}
|
|
33039
|
-
var
|
|
33363
|
+
var import_react46, REFRESH_MS;
|
|
33040
33364
|
var init_useForex = __esm({
|
|
33041
33365
|
"src/modes/swap/hooks/useForex.ts"() {
|
|
33042
33366
|
"use strict";
|
|
33043
|
-
|
|
33367
|
+
import_react46 = require("react");
|
|
33044
33368
|
init_forex();
|
|
33045
33369
|
REFRESH_MS = 5 * 60 * 1e3;
|
|
33046
33370
|
}
|
|
@@ -33061,10 +33385,10 @@ function SwapTokenSelect({
|
|
|
33061
33385
|
allowedTokens,
|
|
33062
33386
|
excludeToken
|
|
33063
33387
|
}) {
|
|
33064
|
-
const [localChain, setLocalChain] = (0,
|
|
33065
|
-
const [pinnedTokens, setPinnedTokens] = (0,
|
|
33066
|
-
const [pinnedLoading, setPinnedLoading] = (0,
|
|
33067
|
-
(0,
|
|
33388
|
+
const [localChain, setLocalChain] = (0, import_react47.useState)(initialChain);
|
|
33389
|
+
const [pinnedTokens, setPinnedTokens] = (0, import_react47.useState)([]);
|
|
33390
|
+
const [pinnedLoading, setPinnedLoading] = (0, import_react47.useState)(false);
|
|
33391
|
+
(0, import_react47.useEffect)(() => {
|
|
33068
33392
|
if (!allowedTokens || allowedTokens.length === 0 || !localChain) {
|
|
33069
33393
|
setPinnedTokens([]);
|
|
33070
33394
|
return;
|
|
@@ -33145,26 +33469,26 @@ function SwapTokenSelect({
|
|
|
33145
33469
|
walletAddress,
|
|
33146
33470
|
yourWalletTokens
|
|
33147
33471
|
});
|
|
33148
|
-
const allowedSet = (0,
|
|
33472
|
+
const allowedSet = (0, import_react47.useMemo)(() => {
|
|
33149
33473
|
if (!allowedTokens || allowedTokens.length === 0) return null;
|
|
33150
33474
|
return new Set(
|
|
33151
33475
|
allowedTokens.map((t) => `${t.chainId}:${t.address.toLowerCase()}`)
|
|
33152
33476
|
);
|
|
33153
33477
|
}, [allowedTokens]);
|
|
33154
|
-
const filteredWalletTokens = (0,
|
|
33478
|
+
const filteredWalletTokens = (0, import_react47.useMemo)(() => {
|
|
33155
33479
|
if (!allowedSet) return rawWalletTokens;
|
|
33156
33480
|
return rawWalletTokens.filter(
|
|
33157
33481
|
(t) => allowedSet.has(`${Number(t.chainId)}:${t.address.toLowerCase()}`)
|
|
33158
33482
|
);
|
|
33159
33483
|
}, [rawWalletTokens, allowedSet]);
|
|
33160
33484
|
const excludeKey = excludeToken ? `${Number(excludeToken.chainId)}:${excludeToken.address.toLowerCase()}` : null;
|
|
33161
|
-
const visibleTokens = (0,
|
|
33485
|
+
const visibleTokens = (0, import_react47.useMemo)(() => {
|
|
33162
33486
|
if (!excludeKey) return filteredTokens;
|
|
33163
33487
|
return filteredTokens.filter(
|
|
33164
33488
|
(t) => `${Number(t.chainId)}:${t.address.toLowerCase()}` !== excludeKey
|
|
33165
33489
|
);
|
|
33166
33490
|
}, [filteredTokens, excludeKey]);
|
|
33167
|
-
const visibleWalletTokens = (0,
|
|
33491
|
+
const visibleWalletTokens = (0, import_react47.useMemo)(() => {
|
|
33168
33492
|
if (!excludeKey) return filteredWalletTokens;
|
|
33169
33493
|
return filteredWalletTokens.filter(
|
|
33170
33494
|
(t) => `${Number(t.chainId)}:${t.address.toLowerCase()}` !== excludeKey
|
|
@@ -33281,11 +33605,11 @@ function SwapTokenSelect({
|
|
|
33281
33605
|
}
|
|
33282
33606
|
);
|
|
33283
33607
|
}
|
|
33284
|
-
var
|
|
33608
|
+
var import_react47, import_jsx_runtime55;
|
|
33285
33609
|
var init_SwapTokenSelect = __esm({
|
|
33286
33610
|
"src/modes/swap/components/SwapTokenSelect.tsx"() {
|
|
33287
33611
|
"use strict";
|
|
33288
|
-
|
|
33612
|
+
import_react47 = require("react");
|
|
33289
33613
|
init_styles();
|
|
33290
33614
|
init_registryClient();
|
|
33291
33615
|
init_hooks2();
|
|
@@ -33311,16 +33635,16 @@ function SwapWalletSelector({
|
|
|
33311
33635
|
} = useWalletInfo();
|
|
33312
33636
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
33313
33637
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
33314
|
-
const [wcConnecting, setWcConnecting] = (0,
|
|
33315
|
-
const [connectingId, setConnectingId] = (0,
|
|
33316
|
-
const [timerExpired, setTimerExpired] = (0,
|
|
33317
|
-
const [selectedNamespace, setSelectedNamespace] = (0,
|
|
33318
|
-
const prevStatusRef = (0,
|
|
33319
|
-
(0,
|
|
33638
|
+
const [wcConnecting, setWcConnecting] = (0, import_react48.useState)(false);
|
|
33639
|
+
const [connectingId, setConnectingId] = (0, import_react48.useState)(null);
|
|
33640
|
+
const [timerExpired, setTimerExpired] = (0, import_react48.useState)(false);
|
|
33641
|
+
const [selectedNamespace, setSelectedNamespace] = (0, import_react48.useState)("evm");
|
|
33642
|
+
const prevStatusRef = (0, import_react48.useRef)(walletStatus);
|
|
33643
|
+
(0, import_react48.useEffect)(() => {
|
|
33320
33644
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
33321
33645
|
return () => clearTimeout(t);
|
|
33322
33646
|
}, []);
|
|
33323
|
-
(0,
|
|
33647
|
+
(0, import_react48.useEffect)(() => {
|
|
33324
33648
|
const prev = prevStatusRef.current;
|
|
33325
33649
|
if (prev !== walletStatus) {
|
|
33326
33650
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -33329,7 +33653,7 @@ function SwapWalletSelector({
|
|
|
33329
33653
|
prevStatusRef.current = walletStatus;
|
|
33330
33654
|
}
|
|
33331
33655
|
}, [walletStatus]);
|
|
33332
|
-
const filteredWallets = (0,
|
|
33656
|
+
const filteredWallets = (0, import_react48.useMemo)(
|
|
33333
33657
|
() => detected.filter(
|
|
33334
33658
|
(w) => (w.meta?.ecosystem ?? "").toLowerCase() === selectedNamespace
|
|
33335
33659
|
),
|
|
@@ -33905,11 +34229,11 @@ function SwapWalletSelector({
|
|
|
33905
34229
|
] })
|
|
33906
34230
|
] });
|
|
33907
34231
|
}
|
|
33908
|
-
var
|
|
34232
|
+
var import_react48, import_jsx_runtime56;
|
|
33909
34233
|
var init_SwapWalletSelector = __esm({
|
|
33910
34234
|
"src/modes/swap/components/SwapWalletSelector.tsx"() {
|
|
33911
34235
|
"use strict";
|
|
33912
|
-
|
|
34236
|
+
import_react48 = require("react");
|
|
33913
34237
|
init_styles();
|
|
33914
34238
|
init_utils2();
|
|
33915
34239
|
init_wallets();
|
|
@@ -34084,41 +34408,41 @@ function SwapMode({
|
|
|
34084
34408
|
theme: themeProp,
|
|
34085
34409
|
style
|
|
34086
34410
|
}) {
|
|
34087
|
-
const [stage, setStage] = (0,
|
|
34088
|
-
const [fromToken, setFromToken] = (0,
|
|
34411
|
+
const [stage, setStage] = (0, import_react49.useState)("home");
|
|
34412
|
+
const [fromToken, setFromToken] = (0, import_react49.useState)(
|
|
34089
34413
|
null
|
|
34090
34414
|
);
|
|
34091
|
-
const [fromChain, setFromChain] = (0,
|
|
34092
|
-
const [toToken, setToToken] = (0,
|
|
34093
|
-
const [toChain, setToChain] = (0,
|
|
34094
|
-
const [amount, setAmount] = (0,
|
|
34095
|
-
const [amountInputMode, setAmountInputMode] = (0,
|
|
34415
|
+
const [fromChain, setFromChain] = (0, import_react49.useState)(null);
|
|
34416
|
+
const [toToken, setToToken] = (0, import_react49.useState)(null);
|
|
34417
|
+
const [toChain, setToChain] = (0, import_react49.useState)(null);
|
|
34418
|
+
const [amount, setAmount] = (0, import_react49.useState)("");
|
|
34419
|
+
const [amountInputMode, setAmountInputMode] = (0, import_react49.useState)(
|
|
34096
34420
|
"usd"
|
|
34097
34421
|
);
|
|
34098
|
-
const [hoverSell, setHoverSell] = (0,
|
|
34099
|
-
const [showRateDetails, setShowRateDetails] = (0,
|
|
34100
|
-
const [showReviewDetails, setShowReviewDetails] = (0,
|
|
34101
|
-
const [showSettings, setShowSettings] = (0,
|
|
34102
|
-
const [maxApproval, setMaxApproval] = (0,
|
|
34103
|
-
const [slippage, setSlippage] = (0,
|
|
34104
|
-
const [slippageInput, setSlippageInput] = (0,
|
|
34105
|
-
const [selectedCurrency, setSelectedCurrency] = (0,
|
|
34106
|
-
const [showCurrencyDropdown, setShowCurrencyDropdown] = (0,
|
|
34107
|
-
const [completedAt, setCompletedAt] = (0,
|
|
34108
|
-
const [copiedHash, setCopiedHash] = (0,
|
|
34109
|
-
const [rateUpdated, setRateUpdated] = (0,
|
|
34110
|
-
const prevToAmountRef = (0,
|
|
34111
|
-
const [destAddress, setDestAddress] = (0,
|
|
34112
|
-
const [quoteAge, setQuoteAge] = (0,
|
|
34113
|
-
const quoteTimestampRef = (0,
|
|
34114
|
-
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = (0,
|
|
34115
|
-
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = (0,
|
|
34116
|
-
const latestFetchParamsRef = (0,
|
|
34422
|
+
const [hoverSell, setHoverSell] = (0, import_react49.useState)(false);
|
|
34423
|
+
const [showRateDetails, setShowRateDetails] = (0, import_react49.useState)(false);
|
|
34424
|
+
const [showReviewDetails, setShowReviewDetails] = (0, import_react49.useState)(false);
|
|
34425
|
+
const [showSettings, setShowSettings] = (0, import_react49.useState)(false);
|
|
34426
|
+
const [maxApproval, setMaxApproval] = (0, import_react49.useState)(false);
|
|
34427
|
+
const [slippage, setSlippage] = (0, import_react49.useState)(0.5);
|
|
34428
|
+
const [slippageInput, setSlippageInput] = (0, import_react49.useState)("");
|
|
34429
|
+
const [selectedCurrency, setSelectedCurrency] = (0, import_react49.useState)("USD");
|
|
34430
|
+
const [showCurrencyDropdown, setShowCurrencyDropdown] = (0, import_react49.useState)(false);
|
|
34431
|
+
const [completedAt, setCompletedAt] = (0, import_react49.useState)(null);
|
|
34432
|
+
const [copiedHash, setCopiedHash] = (0, import_react49.useState)(null);
|
|
34433
|
+
const [rateUpdated, setRateUpdated] = (0, import_react49.useState)(false);
|
|
34434
|
+
const prevToAmountRef = (0, import_react49.useRef)(null);
|
|
34435
|
+
const [destAddress, setDestAddress] = (0, import_react49.useState)("");
|
|
34436
|
+
const [quoteAge, setQuoteAge] = (0, import_react49.useState)(0);
|
|
34437
|
+
const quoteTimestampRef = (0, import_react49.useRef)(null);
|
|
34438
|
+
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = (0, import_react49.useState)(0);
|
|
34439
|
+
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = (0, import_react49.useState)(true);
|
|
34440
|
+
const latestFetchParamsRef = (0, import_react49.useRef)(null);
|
|
34117
34441
|
const { rates: forexRates } = useForex();
|
|
34118
34442
|
const currencyMeta = getCurrencyMeta(selectedCurrency);
|
|
34119
34443
|
const currencyRate = forexRates[selectedCurrency] ?? 1;
|
|
34120
34444
|
const currencySymbol = currencyMeta.symbol;
|
|
34121
|
-
const fmtLocal = (0,
|
|
34445
|
+
const fmtLocal = (0, import_react49.useCallback)(
|
|
34122
34446
|
(usdAmount) => {
|
|
34123
34447
|
const sym = getCurrencyMeta(selectedCurrency).symbol;
|
|
34124
34448
|
if (usdAmount === null || !isFinite(usdAmount) || usdAmount <= 0)
|
|
@@ -34129,8 +34453,8 @@ function SwapMode({
|
|
|
34129
34453
|
},
|
|
34130
34454
|
[currencyRate, selectedCurrency]
|
|
34131
34455
|
);
|
|
34132
|
-
const settingsRef = (0,
|
|
34133
|
-
const currencyDropdownRef = (0,
|
|
34456
|
+
const settingsRef = (0, import_react49.useRef)(null);
|
|
34457
|
+
const currencyDropdownRef = (0, import_react49.useRef)(null);
|
|
34134
34458
|
const { emitEvent } = useTrustware();
|
|
34135
34459
|
const { features, theme: configTheme } = useTrustwareConfig();
|
|
34136
34460
|
const effectiveThemeSetting = themeProp ?? configTheme ?? "system";
|
|
@@ -34146,26 +34470,26 @@ function SwapMode({
|
|
|
34146
34470
|
isLoading: chainsLoading,
|
|
34147
34471
|
error: chainsError
|
|
34148
34472
|
} = useChains();
|
|
34149
|
-
const allowedDestChainIds = (0,
|
|
34473
|
+
const allowedDestChainIds = (0, import_react49.useMemo)(() => {
|
|
34150
34474
|
if (!allowedDestTokens || allowedDestTokens.length === 0) return null;
|
|
34151
34475
|
return new Set(allowedDestTokens.map((t) => t.chainId));
|
|
34152
34476
|
}, [allowedDestTokens]);
|
|
34153
|
-
const toPopularChains = (0,
|
|
34477
|
+
const toPopularChains = (0, import_react49.useMemo)(
|
|
34154
34478
|
() => allowedDestChainIds ? popularChains.filter(
|
|
34155
34479
|
(c) => allowedDestChainIds.has(Number(c.chainId))
|
|
34156
34480
|
) : popularChains,
|
|
34157
34481
|
[popularChains, allowedDestChainIds]
|
|
34158
34482
|
);
|
|
34159
|
-
const toOtherChains = (0,
|
|
34483
|
+
const toOtherChains = (0, import_react49.useMemo)(
|
|
34160
34484
|
() => allowedDestChainIds ? otherChains.filter((c) => allowedDestChainIds.has(Number(c.chainId))) : otherChains,
|
|
34161
34485
|
[otherChains, allowedDestChainIds]
|
|
34162
34486
|
);
|
|
34163
|
-
const allChains = (0,
|
|
34487
|
+
const allChains = (0, import_react49.useMemo)(
|
|
34164
34488
|
() => [...popularChains, ...otherChains],
|
|
34165
34489
|
[popularChains, otherChains]
|
|
34166
34490
|
);
|
|
34167
|
-
const destInitialized = (0,
|
|
34168
|
-
(0,
|
|
34491
|
+
const destInitialized = (0, import_react49.useRef)(false);
|
|
34492
|
+
(0, import_react49.useEffect)(() => {
|
|
34169
34493
|
if (!defaultDestRef || destInitialized.current || allChains.length === 0)
|
|
34170
34494
|
return;
|
|
34171
34495
|
const chain = allChains.find(
|
|
@@ -34196,11 +34520,11 @@ function SwapMode({
|
|
|
34196
34520
|
});
|
|
34197
34521
|
}, [defaultDestRef, allChains]);
|
|
34198
34522
|
const { walletAddress, walletStatus, connectWallet, disconnectWallet } = useWalletSessionState();
|
|
34199
|
-
const setFromTokenStable = (0,
|
|
34523
|
+
const setFromTokenStable = (0, import_react49.useCallback)(
|
|
34200
34524
|
(t) => setFromToken(t),
|
|
34201
34525
|
[]
|
|
34202
34526
|
);
|
|
34203
|
-
const setFromChainStable = (0,
|
|
34527
|
+
const setFromChainStable = (0, import_react49.useCallback)(
|
|
34204
34528
|
(c) => setFromChain(c),
|
|
34205
34529
|
[]
|
|
34206
34530
|
);
|
|
@@ -34213,18 +34537,18 @@ function SwapMode({
|
|
|
34213
34537
|
});
|
|
34214
34538
|
const route = useSwapRoute();
|
|
34215
34539
|
const execution = useSwapExecution(fromChain);
|
|
34216
|
-
const fromTokenPriceUSD = (0,
|
|
34540
|
+
const fromTokenPriceUSD = (0, import_react49.useMemo)(() => {
|
|
34217
34541
|
const p = fromToken?.usdPrice;
|
|
34218
34542
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
34219
34543
|
}, [fromToken]);
|
|
34220
34544
|
const hasFromUsdPrice = fromTokenPriceUSD > 0;
|
|
34221
|
-
const toTokenPriceUSD = (0,
|
|
34545
|
+
const toTokenPriceUSD = (0, import_react49.useMemo)(() => {
|
|
34222
34546
|
const p = toToken?.usdPrice;
|
|
34223
34547
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
34224
34548
|
}, [toToken]);
|
|
34225
34549
|
const hasToUsdPrice = toTokenPriceUSD > 0;
|
|
34226
34550
|
const rawSellNum = parseFloat(amount) || 0;
|
|
34227
|
-
const usdSellNum = (0,
|
|
34551
|
+
const usdSellNum = (0, import_react49.useMemo)(() => {
|
|
34228
34552
|
if (amountInputMode === "usd") return rawSellNum / currencyRate;
|
|
34229
34553
|
return hasFromUsdPrice ? rawSellNum * fromTokenPriceUSD : 0;
|
|
34230
34554
|
}, [
|
|
@@ -34234,7 +34558,7 @@ function SwapMode({
|
|
|
34234
34558
|
hasFromUsdPrice,
|
|
34235
34559
|
fromTokenPriceUSD
|
|
34236
34560
|
]);
|
|
34237
|
-
const tokenSellNum = (0,
|
|
34561
|
+
const tokenSellNum = (0, import_react49.useMemo)(() => {
|
|
34238
34562
|
if (amountInputMode === "usd") {
|
|
34239
34563
|
return hasFromUsdPrice && fromTokenPriceUSD > 0 ? usdSellNum / fromTokenPriceUSD : 0;
|
|
34240
34564
|
}
|
|
@@ -34246,12 +34570,12 @@ function SwapMode({
|
|
|
34246
34570
|
hasFromUsdPrice,
|
|
34247
34571
|
fromTokenPriceUSD
|
|
34248
34572
|
]);
|
|
34249
|
-
const tokenAmountStr = (0,
|
|
34573
|
+
const tokenAmountStr = (0, import_react49.useMemo)(() => {
|
|
34250
34574
|
if (tokenSellNum <= 0) return "";
|
|
34251
34575
|
const decimals = fromToken?.decimals ?? 18;
|
|
34252
34576
|
return truncateDecimal(tokenSellNum, Math.min(decimals, 18));
|
|
34253
34577
|
}, [tokenSellNum, fromToken?.decimals]);
|
|
34254
|
-
const handleCurrencyChange = (0,
|
|
34578
|
+
const handleCurrencyChange = (0, import_react49.useCallback)(
|
|
34255
34579
|
(newCode) => {
|
|
34256
34580
|
if (amountInputMode === "usd" && amount) {
|
|
34257
34581
|
const oldRate = currencyRate;
|
|
@@ -34266,7 +34590,7 @@ function SwapMode({
|
|
|
34266
34590
|
},
|
|
34267
34591
|
[amountInputMode, amount, currencyRate, forexRates, route]
|
|
34268
34592
|
);
|
|
34269
|
-
const handleSelectFromToken = (0,
|
|
34593
|
+
const handleSelectFromToken = (0, import_react49.useCallback)(
|
|
34270
34594
|
(token, chain) => {
|
|
34271
34595
|
setFromToken(token);
|
|
34272
34596
|
setFromChain(chain);
|
|
@@ -34287,7 +34611,7 @@ function SwapMode({
|
|
|
34287
34611
|
},
|
|
34288
34612
|
[route, emitEvent, toToken, toChain, amount]
|
|
34289
34613
|
);
|
|
34290
|
-
const handleSelectToToken = (0,
|
|
34614
|
+
const handleSelectToToken = (0, import_react49.useCallback)(
|
|
34291
34615
|
(token, chain) => {
|
|
34292
34616
|
setToToken(token);
|
|
34293
34617
|
setToChain(chain);
|
|
@@ -34304,7 +34628,7 @@ function SwapMode({
|
|
|
34304
34628
|
},
|
|
34305
34629
|
[route, emitEvent, fromToken, fromChain, amount]
|
|
34306
34630
|
);
|
|
34307
|
-
const handleFlip = (0,
|
|
34631
|
+
const handleFlip = (0, import_react49.useCallback)(() => {
|
|
34308
34632
|
if (lockDestToken) return;
|
|
34309
34633
|
const newFrom = toToken ?? fromToken;
|
|
34310
34634
|
const newFromChain = toChain ?? fromChain;
|
|
@@ -34326,7 +34650,7 @@ function SwapMode({
|
|
|
34326
34650
|
const toChainType = normalizeChainType2(toChain);
|
|
34327
34651
|
const needsDestAddress = !!fromChainType && !!toChainType && fromChainType !== toChainType;
|
|
34328
34652
|
const isValidDestAddress = !needsDestAddress || validateDestAddress(destAddress, toChainType ?? "");
|
|
34329
|
-
const handleReview = (0,
|
|
34653
|
+
const handleReview = (0, import_react49.useCallback)(async () => {
|
|
34330
34654
|
if (!fromToken || !fromChain || !toToken || !toChain || !tokenAmountStr || !walletAddress) {
|
|
34331
34655
|
if (!walletAddress) setStage("connect-wallet");
|
|
34332
34656
|
return;
|
|
@@ -34361,13 +34685,13 @@ function SwapMode({
|
|
|
34361
34685
|
route,
|
|
34362
34686
|
slippage
|
|
34363
34687
|
]);
|
|
34364
|
-
const handleConnectAndReview = (0,
|
|
34688
|
+
const handleConnectAndReview = (0, import_react49.useCallback)(() => {
|
|
34365
34689
|
setStage("connect-wallet");
|
|
34366
34690
|
}, []);
|
|
34367
|
-
const handleWalletConnected = (0,
|
|
34691
|
+
const handleWalletConnected = (0, import_react49.useCallback)(() => {
|
|
34368
34692
|
setStage("home");
|
|
34369
34693
|
}, []);
|
|
34370
|
-
const handleExecute = (0,
|
|
34694
|
+
const handleExecute = (0, import_react49.useCallback)(async () => {
|
|
34371
34695
|
if (!route.data) return;
|
|
34372
34696
|
setStage("processing");
|
|
34373
34697
|
const fromTokenAddress = fromToken?.address ?? fromToken?.address;
|
|
@@ -34390,7 +34714,7 @@ function SwapMode({
|
|
|
34390
34714
|
() => setStage("error")
|
|
34391
34715
|
);
|
|
34392
34716
|
}, [route, execution, fromToken, walletAddress, maxApproval]);
|
|
34393
|
-
const handleReset = (0,
|
|
34717
|
+
const handleReset = (0, import_react49.useCallback)(() => {
|
|
34394
34718
|
execution.reset();
|
|
34395
34719
|
route.clear();
|
|
34396
34720
|
setAmount("");
|
|
@@ -34400,7 +34724,7 @@ function SwapMode({
|
|
|
34400
34724
|
setStage("home");
|
|
34401
34725
|
reloadWalletTokens();
|
|
34402
34726
|
}, [execution, route, reloadWalletTokens]);
|
|
34403
|
-
const handleSwapBack = (0,
|
|
34727
|
+
const handleSwapBack = (0, import_react49.useCallback)(() => {
|
|
34404
34728
|
const prevFrom = fromToken;
|
|
34405
34729
|
const prevFromChain = fromChain;
|
|
34406
34730
|
setFromToken(toToken);
|
|
@@ -34424,14 +34748,14 @@ function SwapMode({
|
|
|
34424
34748
|
route,
|
|
34425
34749
|
reloadWalletTokens
|
|
34426
34750
|
]);
|
|
34427
|
-
const handleCopyHash = (0,
|
|
34751
|
+
const handleCopyHash = (0, import_react49.useCallback)((hash) => {
|
|
34428
34752
|
if (!navigator?.clipboard?.writeText) return;
|
|
34429
34753
|
void navigator.clipboard.writeText(hash).then(() => {
|
|
34430
34754
|
setCopiedHash(hash);
|
|
34431
34755
|
setTimeout(() => setCopiedHash((v) => v === hash ? null : v), 1500);
|
|
34432
34756
|
});
|
|
34433
34757
|
}, []);
|
|
34434
|
-
const handleToggleDenom = (0,
|
|
34758
|
+
const handleToggleDenom = (0, import_react49.useCallback)(() => {
|
|
34435
34759
|
if (!hasFromUsdPrice) return;
|
|
34436
34760
|
const parsed = parseFloat(amount) || 0;
|
|
34437
34761
|
if (amountInputMode === "usd") {
|
|
@@ -34457,7 +34781,7 @@ function SwapMode({
|
|
|
34457
34781
|
fromToken?.decimals,
|
|
34458
34782
|
route
|
|
34459
34783
|
]);
|
|
34460
|
-
const fromBalance = (0,
|
|
34784
|
+
const fromBalance = (0, import_react49.useMemo)(() => {
|
|
34461
34785
|
const walletToken = fromToken;
|
|
34462
34786
|
if (!walletToken || !("balance" in walletToken)) return null;
|
|
34463
34787
|
const raw = walletToken.balance;
|
|
@@ -34467,7 +34791,7 @@ function SwapMode({
|
|
|
34467
34791
|
return Number.isFinite(n) ? n : null;
|
|
34468
34792
|
}, [fromToken]);
|
|
34469
34793
|
const balanceUsd = fromBalance !== null && hasFromUsdPrice ? fromBalance * fromTokenPriceUSD : null;
|
|
34470
|
-
const estimatedToAmount = (0,
|
|
34794
|
+
const estimatedToAmount = (0, import_react49.useMemo)(() => {
|
|
34471
34795
|
if (tokenSellNum <= 0 || !hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
34472
34796
|
return tokenSellNum * (fromTokenPriceUSD / toTokenPriceUSD);
|
|
34473
34797
|
}, [
|
|
@@ -34477,10 +34801,10 @@ function SwapMode({
|
|
|
34477
34801
|
hasFromUsdPrice,
|
|
34478
34802
|
hasToUsdPrice
|
|
34479
34803
|
]);
|
|
34480
|
-
const backendToUsdStr = (0,
|
|
34804
|
+
const backendToUsdStr = (0, import_react49.useMemo)(() => {
|
|
34481
34805
|
return route.data?.finalExchangeRate?.toAmountMinUSD ?? route.data?.route?.estimate?.toAmountMinUsd ?? route.data?.route?.estimate?.toAmountUsd ?? null;
|
|
34482
34806
|
}, [route.data]);
|
|
34483
|
-
const toAmount = (0,
|
|
34807
|
+
const toAmount = (0, import_react49.useMemo)(() => {
|
|
34484
34808
|
if (backendToUsdStr && toTokenPriceUSD > 0) {
|
|
34485
34809
|
const usd = parseFloat(backendToUsdStr);
|
|
34486
34810
|
if (Number.isFinite(usd) && usd > 0) return usd / toTokenPriceUSD;
|
|
@@ -34506,7 +34830,7 @@ function SwapMode({
|
|
|
34506
34830
|
estimatedToAmount
|
|
34507
34831
|
]);
|
|
34508
34832
|
const fromUsd = usdSellNum;
|
|
34509
|
-
const toUsd = (0,
|
|
34833
|
+
const toUsd = (0, import_react49.useMemo)(() => {
|
|
34510
34834
|
if (backendToUsdStr) {
|
|
34511
34835
|
const n = parseFloat(backendToUsdStr);
|
|
34512
34836
|
if (Number.isFinite(n) && n > 0) return n;
|
|
@@ -34517,12 +34841,12 @@ function SwapMode({
|
|
|
34517
34841
|
const isEstimate = !route.data;
|
|
34518
34842
|
const USD_EPSILON = 1e-3;
|
|
34519
34843
|
const displayToUsd = toUsd > USD_EPSILON ? toUsd : estimatedToAmount !== null && hasToUsdPrice ? estimatedToAmount * toTokenPriceUSD : 0;
|
|
34520
|
-
const priceImpact = (0,
|
|
34844
|
+
const priceImpact = (0, import_react49.useMemo)(() => {
|
|
34521
34845
|
if (!route.data || fromUsd < 0.01 || displayToUsd < 0.01) return null;
|
|
34522
34846
|
const impact = 1 - displayToUsd / fromUsd;
|
|
34523
34847
|
return impact > 1e-3 ? impact : null;
|
|
34524
34848
|
}, [route.data, fromUsd, displayToUsd]);
|
|
34525
|
-
const routePath = (0,
|
|
34849
|
+
const routePath = (0, import_react49.useMemo)(() => {
|
|
34526
34850
|
if (!route.data) return null;
|
|
34527
34851
|
const provider = route.data.route?.provider;
|
|
34528
34852
|
const steps = route.data.route?.steps;
|
|
@@ -34549,19 +34873,19 @@ function SwapMode({
|
|
|
34549
34873
|
return null;
|
|
34550
34874
|
}, [route.data, fromToken?.symbol, toToken?.symbol]);
|
|
34551
34875
|
const isGasSponsored = !!route.data?.sponsorship;
|
|
34552
|
-
const networkCostUsd = (0,
|
|
34876
|
+
const networkCostUsd = (0, import_react49.useMemo)(() => {
|
|
34553
34877
|
const fees = route.data?.route?.estimate?.fees;
|
|
34554
34878
|
if (!fees?.length) return null;
|
|
34555
34879
|
const gasTotal = fees.filter((f) => f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
34556
34880
|
return gasTotal > 0 ? gasTotal : null;
|
|
34557
34881
|
}, [route.data]);
|
|
34558
|
-
const protocolFeeUsd = (0,
|
|
34882
|
+
const protocolFeeUsd = (0, import_react49.useMemo)(() => {
|
|
34559
34883
|
const fees = route.data?.route?.estimate?.fees;
|
|
34560
34884
|
if (!fees?.length) return null;
|
|
34561
34885
|
const total = fees.filter((f) => !f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
34562
34886
|
return total > 0 ? total : null;
|
|
34563
34887
|
}, [route.data]);
|
|
34564
|
-
const exchangeRate = (0,
|
|
34888
|
+
const exchangeRate = (0, import_react49.useMemo)(() => {
|
|
34565
34889
|
if (!hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
34566
34890
|
return toTokenPriceUSD / fromTokenPriceUSD;
|
|
34567
34891
|
}, [fromTokenPriceUSD, toTokenPriceUSD, hasFromUsdPrice, hasToUsdPrice]);
|
|
@@ -34570,13 +34894,13 @@ function SwapMode({
|
|
|
34570
34894
|
const hasAmount = rawSellNum > 0 && (amountInputMode === "token" || hasFromUsdPrice);
|
|
34571
34895
|
const isConnected = walletStatus === "connected" && !!walletAddress;
|
|
34572
34896
|
const canGetQuote = hasTokens && hasAmount && !insufficient && isConnected && (!needsDestAddress || isValidDestAddress);
|
|
34573
|
-
(0,
|
|
34897
|
+
(0, import_react49.useEffect)(() => {
|
|
34574
34898
|
if (!fromToken) return;
|
|
34575
34899
|
if (!hasFromUsdPrice && amountInputMode === "usd") {
|
|
34576
34900
|
setAmountInputMode("token");
|
|
34577
34901
|
}
|
|
34578
34902
|
}, [fromToken, hasFromUsdPrice, amountInputMode]);
|
|
34579
|
-
(0,
|
|
34903
|
+
(0, import_react49.useEffect)(() => {
|
|
34580
34904
|
if (displayToAmount === null) {
|
|
34581
34905
|
prevToAmountRef.current = null;
|
|
34582
34906
|
return;
|
|
@@ -34590,14 +34914,14 @@ function SwapMode({
|
|
|
34590
34914
|
const t = setTimeout(() => setRateUpdated(false), 700);
|
|
34591
34915
|
return () => clearTimeout(t);
|
|
34592
34916
|
}, [displayToAmount]);
|
|
34593
|
-
(0,
|
|
34917
|
+
(0, import_react49.useEffect)(() => {
|
|
34594
34918
|
setDestAddress("");
|
|
34595
34919
|
}, [toChainType]);
|
|
34596
|
-
const fetchRef = (0,
|
|
34597
|
-
(0,
|
|
34920
|
+
const fetchRef = (0, import_react49.useRef)(route.fetch);
|
|
34921
|
+
(0, import_react49.useEffect)(() => {
|
|
34598
34922
|
fetchRef.current = route.fetch;
|
|
34599
34923
|
});
|
|
34600
|
-
(0,
|
|
34924
|
+
(0, import_react49.useEffect)(() => {
|
|
34601
34925
|
if (!canGetQuote || stage !== "home") return;
|
|
34602
34926
|
if (!fromToken || !fromChain || !toToken || !toChain || !walletAddress)
|
|
34603
34927
|
return;
|
|
@@ -34626,7 +34950,7 @@ function SwapMode({
|
|
|
34626
34950
|
destAddress,
|
|
34627
34951
|
slippage
|
|
34628
34952
|
]);
|
|
34629
|
-
(0,
|
|
34953
|
+
(0, import_react49.useEffect)(() => {
|
|
34630
34954
|
if (!canGetQuote || !fromToken || !fromChain || !toToken || !toChain || !walletAddress) {
|
|
34631
34955
|
latestFetchParamsRef.current = null;
|
|
34632
34956
|
return;
|
|
@@ -34653,12 +34977,12 @@ function SwapMode({
|
|
|
34653
34977
|
destAddress,
|
|
34654
34978
|
slippage
|
|
34655
34979
|
]);
|
|
34656
|
-
(0,
|
|
34980
|
+
(0, import_react49.useEffect)(() => {
|
|
34657
34981
|
quoteTimestampRef.current = route.data ? Date.now() : null;
|
|
34658
34982
|
setQuoteAge(0);
|
|
34659
34983
|
}, [route.data]);
|
|
34660
|
-
const msgTimeoutRef = (0,
|
|
34661
|
-
(0,
|
|
34984
|
+
const msgTimeoutRef = (0, import_react49.useRef)(null);
|
|
34985
|
+
(0, import_react49.useEffect)(() => {
|
|
34662
34986
|
if (!route.loading) {
|
|
34663
34987
|
setQuoteLoadingMsgIdx(0);
|
|
34664
34988
|
setQuoteLoadingMsgVisible(true);
|
|
@@ -34676,7 +35000,7 @@ function SwapMode({
|
|
|
34676
35000
|
if (msgTimeoutRef.current !== null) clearTimeout(msgTimeoutRef.current);
|
|
34677
35001
|
};
|
|
34678
35002
|
}, [route.loading]);
|
|
34679
|
-
(0,
|
|
35003
|
+
(0, import_react49.useEffect)(() => {
|
|
34680
35004
|
if (!route.data) return;
|
|
34681
35005
|
const id = setInterval(() => {
|
|
34682
35006
|
const ts = quoteTimestampRef.current;
|
|
@@ -34690,7 +35014,7 @@ function SwapMode({
|
|
|
34690
35014
|
}, 1e3);
|
|
34691
35015
|
return () => clearInterval(id);
|
|
34692
35016
|
}, [route.data]);
|
|
34693
|
-
(0,
|
|
35017
|
+
(0, import_react49.useEffect)(() => {
|
|
34694
35018
|
if (stage !== "review") return;
|
|
34695
35019
|
if (!route.data || !walletAddress) return;
|
|
34696
35020
|
const fromTokenAddress = fromToken?.address;
|
|
@@ -34701,7 +35025,7 @@ function SwapMode({
|
|
|
34701
35025
|
routeResult: route.data
|
|
34702
35026
|
});
|
|
34703
35027
|
}, [stage, route.data, walletAddress, fromToken]);
|
|
34704
|
-
(0,
|
|
35028
|
+
(0, import_react49.useEffect)(() => {
|
|
34705
35029
|
if (!showSettings) {
|
|
34706
35030
|
setShowCurrencyDropdown(false);
|
|
34707
35031
|
return;
|
|
@@ -34714,7 +35038,7 @@ function SwapMode({
|
|
|
34714
35038
|
document.addEventListener("mousedown", handler);
|
|
34715
35039
|
return () => document.removeEventListener("mousedown", handler);
|
|
34716
35040
|
}, [showSettings]);
|
|
34717
|
-
(0,
|
|
35041
|
+
(0, import_react49.useEffect)(() => {
|
|
34718
35042
|
if (!showCurrencyDropdown) return;
|
|
34719
35043
|
const handler = (e2) => {
|
|
34720
35044
|
if (currencyDropdownRef.current && !currencyDropdownRef.current.contains(e2.target)) {
|
|
@@ -35256,7 +35580,7 @@ function SwapMode({
|
|
|
35256
35580
|
timeStyle: "short"
|
|
35257
35581
|
}) ?? null;
|
|
35258
35582
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(WidgetContainer, { theme: resolvedTheme, style, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { style: { position: "relative", overflow: "hidden" }, children: [
|
|
35259
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
35583
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_react49.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ConfettiEffect3, { isActive: true, pieceCount: 60, clearDelay: 4e3 }) }),
|
|
35260
35584
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { style: { padding: `${spacing[6]} ${spacing[6]} 0` }, children: [
|
|
35261
35585
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
35262
35586
|
"div",
|
|
@@ -37864,8 +38188,8 @@ function ReviewDetailRow({
|
|
|
37864
38188
|
value,
|
|
37865
38189
|
tooltip
|
|
37866
38190
|
}) {
|
|
37867
|
-
const iconRef = (0,
|
|
37868
|
-
const [tipPos, setTipPos] = (0,
|
|
38191
|
+
const iconRef = (0, import_react49.useRef)(null);
|
|
38192
|
+
const [tipPos, setTipPos] = (0, import_react49.useState)(null);
|
|
37869
38193
|
const handleMouseEnter = () => {
|
|
37870
38194
|
if (!tooltip || !iconRef.current) return;
|
|
37871
38195
|
const r = iconRef.current.getBoundingClientRect();
|
|
@@ -38144,11 +38468,11 @@ function ProcessingStepLine({ done }) {
|
|
|
38144
38468
|
}
|
|
38145
38469
|
);
|
|
38146
38470
|
}
|
|
38147
|
-
var
|
|
38471
|
+
var import_react49, import_react_dom, import_jsx_runtime57, ConfettiEffect3, QUOTE_TTL, QUOTE_LOADING_MESSAGES, PERCENT_OPTIONS;
|
|
38148
38472
|
var init_SwapMode = __esm({
|
|
38149
38473
|
"src/modes/swap/SwapMode.tsx"() {
|
|
38150
38474
|
"use strict";
|
|
38151
|
-
|
|
38475
|
+
import_react49 = require("react");
|
|
38152
38476
|
import_react_dom = __toESM(require("react-dom"), 1);
|
|
38153
38477
|
init_styles();
|
|
38154
38478
|
init_utils2();
|
|
@@ -38171,7 +38495,7 @@ var init_SwapMode = __esm({
|
|
|
38171
38495
|
init_SwapWalletSelector();
|
|
38172
38496
|
init_currency();
|
|
38173
38497
|
import_jsx_runtime57 = require("react/jsx-runtime");
|
|
38174
|
-
ConfettiEffect3 = (0,
|
|
38498
|
+
ConfettiEffect3 = (0, import_react49.lazy)(
|
|
38175
38499
|
() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports))
|
|
38176
38500
|
);
|
|
38177
38501
|
QUOTE_TTL = 60;
|
|
@@ -38212,7 +38536,7 @@ function WidgetContent({
|
|
|
38212
38536
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
38213
38537
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
38214
38538
|
useWalletExternalDisconnect(() => setCurrentStep("home"));
|
|
38215
|
-
(0,
|
|
38539
|
+
(0, import_react50.useEffect)(() => {
|
|
38216
38540
|
const state = {
|
|
38217
38541
|
currentStep,
|
|
38218
38542
|
amount,
|
|
@@ -38255,8 +38579,8 @@ function WidgetInner({
|
|
|
38255
38579
|
const { transactionStatus } = useDepositTransaction();
|
|
38256
38580
|
const { resolvedTheme } = useDepositUi();
|
|
38257
38581
|
const { status, revalidate, errors } = useTrustware();
|
|
38258
|
-
const [showConfirmDialog, setShowConfirmDialog] = (0,
|
|
38259
|
-
const handleCloseRequest = (0,
|
|
38582
|
+
const [showConfirmDialog, setShowConfirmDialog] = (0, import_react50.useState)(false);
|
|
38583
|
+
const handleCloseRequest = (0, import_react50.useCallback)(() => {
|
|
38260
38584
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
38261
38585
|
setShowConfirmDialog(true);
|
|
38262
38586
|
} else {
|
|
@@ -38267,20 +38591,20 @@ function WidgetInner({
|
|
|
38267
38591
|
onClose?.();
|
|
38268
38592
|
}
|
|
38269
38593
|
}, [transactionStatus, onClose, resetState]);
|
|
38270
|
-
(0,
|
|
38594
|
+
(0, import_react50.useEffect)(() => {
|
|
38271
38595
|
closeRequestRef.current = handleCloseRequest;
|
|
38272
38596
|
}, [handleCloseRequest, closeRequestRef]);
|
|
38273
|
-
const handleConfirmClose = (0,
|
|
38597
|
+
const handleConfirmClose = (0, import_react50.useCallback)(() => {
|
|
38274
38598
|
setShowConfirmDialog(false);
|
|
38275
38599
|
onClose?.();
|
|
38276
38600
|
}, [onClose]);
|
|
38277
|
-
const handleCancelClose = (0,
|
|
38601
|
+
const handleCancelClose = (0, import_react50.useCallback)(() => {
|
|
38278
38602
|
setShowConfirmDialog(false);
|
|
38279
38603
|
}, []);
|
|
38280
38604
|
const effectiveTheme = resolvedTheme;
|
|
38281
38605
|
const isRefreshing = status === "initializing";
|
|
38282
38606
|
const initBlocked = status === "error";
|
|
38283
|
-
const handleRefresh = (0,
|
|
38607
|
+
const handleRefresh = (0, import_react50.useCallback)(() => {
|
|
38284
38608
|
revalidate?.();
|
|
38285
38609
|
}, [revalidate]);
|
|
38286
38610
|
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
|
|
@@ -38314,11 +38638,11 @@ function WidgetInner({
|
|
|
38314
38638
|
)
|
|
38315
38639
|
] });
|
|
38316
38640
|
}
|
|
38317
|
-
var
|
|
38641
|
+
var import_react50, import_jsx_runtime58, widgetContentContainerStyle, themeToggleContainerStyle, TrustwareWidgetV2;
|
|
38318
38642
|
var init_TrustwareWidgetV2 = __esm({
|
|
38319
38643
|
"src/widget/TrustwareWidgetV2.tsx"() {
|
|
38320
38644
|
"use strict";
|
|
38321
|
-
|
|
38645
|
+
import_react50 = require("react");
|
|
38322
38646
|
init_utils2();
|
|
38323
38647
|
init_styles();
|
|
38324
38648
|
init_DepositContext();
|
|
@@ -38344,7 +38668,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38344
38668
|
right: spacing[3],
|
|
38345
38669
|
zIndex: 12
|
|
38346
38670
|
};
|
|
38347
|
-
TrustwareWidgetV2 = (0,
|
|
38671
|
+
TrustwareWidgetV2 = (0, import_react50.forwardRef)(function TrustwareWidgetV22({
|
|
38348
38672
|
theme,
|
|
38349
38673
|
style,
|
|
38350
38674
|
initialStep = "home",
|
|
@@ -38353,15 +38677,15 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38353
38677
|
onOpen,
|
|
38354
38678
|
showThemeToggle = true
|
|
38355
38679
|
}, ref) {
|
|
38356
|
-
const [isOpen, setIsOpen] = (0,
|
|
38357
|
-
const closeRequestRef = (0,
|
|
38680
|
+
const [isOpen, setIsOpen] = (0, import_react50.useState)(defaultOpen);
|
|
38681
|
+
const closeRequestRef = (0, import_react50.useRef)(null);
|
|
38358
38682
|
const config = useTrustwareConfig();
|
|
38359
38683
|
const effectiveInitialStep = initialStep;
|
|
38360
|
-
const open = (0,
|
|
38684
|
+
const open = (0, import_react50.useCallback)(() => {
|
|
38361
38685
|
setIsOpen(true);
|
|
38362
38686
|
onOpen?.();
|
|
38363
38687
|
}, [onOpen]);
|
|
38364
|
-
const close = (0,
|
|
38688
|
+
const close = (0, import_react50.useCallback)(() => {
|
|
38365
38689
|
if (closeRequestRef.current) {
|
|
38366
38690
|
closeRequestRef.current();
|
|
38367
38691
|
} else {
|
|
@@ -38369,11 +38693,11 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38369
38693
|
onClose?.();
|
|
38370
38694
|
}
|
|
38371
38695
|
}, [onClose]);
|
|
38372
|
-
const handleClose = (0,
|
|
38696
|
+
const handleClose = (0, import_react50.useCallback)(() => {
|
|
38373
38697
|
setIsOpen(false);
|
|
38374
38698
|
onClose?.();
|
|
38375
38699
|
}, [onClose]);
|
|
38376
|
-
(0,
|
|
38700
|
+
(0, import_react50.useImperativeHandle)(
|
|
38377
38701
|
ref,
|
|
38378
38702
|
() => ({
|
|
38379
38703
|
open,
|