@trustware/sdk-staging 1.1.8-staging.8 → 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/README.md +0 -2
- package/dist/{blockchain-BONedEsU.d.cts → blockchain-BxAFzp0s.d.cts} +5 -1
- package/dist/{blockchain-BONedEsU.d.ts → blockchain-BxAFzp0s.d.ts} +5 -1
- 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-BQ0mFnLc.d.ts → core-CwT8Wd1x.d.ts} +32 -4
- package/dist/{core-BjQwlpoI.d.cts → core-Dy_rZl5y.d.cts} +32 -4
- package/dist/core.cjs +69 -32
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +4 -4
- package/dist/core.d.ts +4 -4
- package/dist/core.mjs +69 -32
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-DlbgTrkm.d.cts → detect-DVpECOTa.d.cts} +2 -2
- package/dist/{detect-MWKHLhn9.d.ts → detect-d2PUaxE_.d.ts} +2 -2
- package/dist/index.cjs +699 -333
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -10
- package/dist/index.d.ts +9 -10
- package/dist/index.mjs +653 -287
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-aOd3vkF9.d.ts → manager-B5aklGtm.d.cts} +2 -4
- package/dist/{manager-DKVW7zeh.d.cts → manager-xFiq0SHr.d.ts} +2 -4
- package/dist/smart-account.cjs +1 -2
- 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 -2
- package/dist/smart-account.mjs.map +1 -1
- package/dist/{types-MtdjJgwT.d.ts → types-BJY9r-mz.d.ts} +1 -1
- package/dist/{types-B3nKHW6H.d.cts → types-DX3HtFcn.d.cts} +1 -1
- package/dist/wallet.cjs +124 -53
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +4 -4
- package/dist/wallet.d.ts +4 -4
- package/dist/wallet.mjs +124 -53
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +672 -306
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.d.cts +2 -2
- package/dist/widget.d.ts +2 -2
- package/dist/widget.mjs +626 -260
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -129,7 +129,6 @@ function resolveConfig(input) {
|
|
|
129
129
|
defaultSlippage: normalizeSlippage(
|
|
130
130
|
input.routes.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
131
131
|
),
|
|
132
|
-
routeType: input.routes.routeType ?? "swap",
|
|
133
132
|
options: {
|
|
134
133
|
...input.routes.options
|
|
135
134
|
}
|
|
@@ -431,7 +430,7 @@ var init_constants = __esm({
|
|
|
431
430
|
"src/constants.ts"() {
|
|
432
431
|
"use strict";
|
|
433
432
|
SDK_NAME = "@trustware/sdk";
|
|
434
|
-
SDK_VERSION = "1.1.
|
|
433
|
+
SDK_VERSION = "1.1.9-staging.3";
|
|
435
434
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
436
435
|
GTM_ID = "GTM-TZDGNCXB";
|
|
437
436
|
API_PREFIX = "/api";
|
|
@@ -451,16 +450,6 @@ var init_config2 = __esm({
|
|
|
451
450
|
});
|
|
452
451
|
|
|
453
452
|
// src/core/http.ts
|
|
454
|
-
var http_exports = {};
|
|
455
|
-
__export(http_exports, {
|
|
456
|
-
RateLimitError: () => RateLimitError,
|
|
457
|
-
apiBase: () => apiBase,
|
|
458
|
-
assertOK: () => assertOK,
|
|
459
|
-
jsonHeaders: () => jsonHeaders,
|
|
460
|
-
parseRateLimitHeaders: () => parseRateLimitHeaders,
|
|
461
|
-
rateLimitedFetch: () => rateLimitedFetch,
|
|
462
|
-
validateSdkAccess: () => validateSdkAccess
|
|
463
|
-
});
|
|
464
453
|
function apiBase() {
|
|
465
454
|
return `${API_ROOT}${API_PREFIX}`;
|
|
466
455
|
}
|
|
@@ -912,11 +901,27 @@ function toSolanaWalletInterface(provider) {
|
|
|
912
901
|
serializedTransactionBase64
|
|
913
902
|
);
|
|
914
903
|
if (provider.signAndSendTransaction) {
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
904
|
+
const MAX_INTERNAL_ERROR_ATTEMPTS = 3;
|
|
905
|
+
const INTERNAL_ERROR_RETRY_DELAY_MS = 500;
|
|
906
|
+
for (let attempt = 1; attempt <= MAX_INTERNAL_ERROR_ATTEMPTS; attempt++) {
|
|
907
|
+
try {
|
|
908
|
+
const result = await provider.signAndSendTransaction(transaction, {
|
|
909
|
+
skipPreflight: true
|
|
910
|
+
});
|
|
911
|
+
if (typeof result === "string") return result;
|
|
912
|
+
if (result?.signature) return result.signature;
|
|
913
|
+
break;
|
|
914
|
+
} catch (err) {
|
|
915
|
+
const code = err?.code;
|
|
916
|
+
if (code === -32603 && attempt < MAX_INTERNAL_ERROR_ATTEMPTS) {
|
|
917
|
+
await new Promise(
|
|
918
|
+
(resolve) => setTimeout(resolve, INTERNAL_ERROR_RETRY_DELAY_MS * attempt)
|
|
919
|
+
);
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
throw err;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
920
925
|
}
|
|
921
926
|
if (!provider.signTransaction) {
|
|
922
927
|
throw new Error("Connected Solana wallet cannot sign transactions");
|
|
@@ -1029,12 +1034,25 @@ var init_connect = __esm({
|
|
|
1029
1034
|
function formatDeepLink(id, currentUrl) {
|
|
1030
1035
|
const enc = encodeURIComponent(currentUrl);
|
|
1031
1036
|
switch (id) {
|
|
1037
|
+
// EVM
|
|
1032
1038
|
case "metamask":
|
|
1033
1039
|
return `metamask://dapp/${currentUrl}`;
|
|
1034
1040
|
case "coinbase":
|
|
1035
1041
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
1036
1042
|
case "rainbow":
|
|
1037
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
|
|
1038
1056
|
default:
|
|
1039
1057
|
return void 0;
|
|
1040
1058
|
}
|
|
@@ -1062,6 +1080,8 @@ var init_metadata = __esm({
|
|
|
1062
1080
|
emoji: "\u{1F98A}",
|
|
1063
1081
|
homepage: "https://metamask.io/",
|
|
1064
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",
|
|
1065
1085
|
detectFlags: ["isMetaMask"],
|
|
1066
1086
|
deepLink: (url) => formatDeepLink("metamask", url) ?? ""
|
|
1067
1087
|
},
|
|
@@ -1073,6 +1093,8 @@ var init_metadata = __esm({
|
|
|
1073
1093
|
logo: `${ASSETS_BASE_URL}/assets/wallets/coinbase.svg`,
|
|
1074
1094
|
emoji: "\u{1F7E6}",
|
|
1075
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",
|
|
1076
1098
|
detectFlags: ["isCoinbaseWallet"],
|
|
1077
1099
|
deepLink: (url) => formatDeepLink("coinbase", url) ?? ""
|
|
1078
1100
|
},
|
|
@@ -1084,6 +1106,7 @@ var init_metadata = __esm({
|
|
|
1084
1106
|
logo: `${ASSETS_BASE_URL}/assets/wallets/walletconnect.svg`,
|
|
1085
1107
|
emoji: "\u{1FA9D}",
|
|
1086
1108
|
homepage: "https://walletconnect.com/"
|
|
1109
|
+
// No deep link — opens its own modal
|
|
1087
1110
|
},
|
|
1088
1111
|
{
|
|
1089
1112
|
id: "rainbow",
|
|
@@ -1093,8 +1116,38 @@ var init_metadata = __esm({
|
|
|
1093
1116
|
logo: `${ASSETS_BASE_URL}/assets/wallets/rainbow.svg`,
|
|
1094
1117
|
emoji: "\u{1F308}",
|
|
1095
1118
|
homepage: "https://rainbow.me/",
|
|
1096
|
-
|
|
1097
|
-
|
|
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
|
|
1098
1151
|
},
|
|
1099
1152
|
{
|
|
1100
1153
|
id: "phantom-evm",
|
|
@@ -1104,7 +1157,10 @@ var init_metadata = __esm({
|
|
|
1104
1157
|
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
1105
1158
|
emoji: "\u{1F47B}",
|
|
1106
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",
|
|
1107
1162
|
detectFlags: ["isPhantom"]
|
|
1163
|
+
// No EVM dapp browser deep link — falls back to app store
|
|
1108
1164
|
},
|
|
1109
1165
|
{
|
|
1110
1166
|
id: "phantom-solana",
|
|
@@ -1114,18 +1170,9 @@ var init_metadata = __esm({
|
|
|
1114
1170
|
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
1115
1171
|
emoji: "\u{1F47B}",
|
|
1116
1172
|
homepage: "https://phantom.app/",
|
|
1117
|
-
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1118
1173
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
{
|
|
1122
|
-
id: "metamask-solana",
|
|
1123
|
-
name: "MetaMask (Solana)",
|
|
1124
|
-
category: "injected",
|
|
1125
|
-
ecosystem: "solana",
|
|
1126
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1127
|
-
emoji: "\u{1F98A}",
|
|
1128
|
-
homepage: "https://metamask.io/"
|
|
1174
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1175
|
+
deepLink: (url) => formatDeepLink("phantom-solana", url) ?? ""
|
|
1129
1176
|
},
|
|
1130
1177
|
{
|
|
1131
1178
|
id: "solflare",
|
|
@@ -1135,7 +1182,9 @@ var init_metadata = __esm({
|
|
|
1135
1182
|
logo: `${ASSETS_BASE_URL}/assets/wallets/solflare-logo.svg`,
|
|
1136
1183
|
emoji: "\u2600\uFE0F",
|
|
1137
1184
|
homepage: "https://solflare.com/",
|
|
1138
|
-
|
|
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) ?? ""
|
|
1139
1188
|
},
|
|
1140
1189
|
{
|
|
1141
1190
|
id: "backpack",
|
|
@@ -1144,8 +1193,25 @@ var init_metadata = __esm({
|
|
|
1144
1193
|
ecosystem: "solana",
|
|
1145
1194
|
logo: `${ASSETS_BASE_URL}/assets/wallets/backpack-logo.svg`,
|
|
1146
1195
|
emoji: "\u{1F392}",
|
|
1147
|
-
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
|
|
1148
1213
|
},
|
|
1214
|
+
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
1149
1215
|
{
|
|
1150
1216
|
id: "rabby",
|
|
1151
1217
|
name: "Rabby",
|
|
@@ -1156,6 +1222,7 @@ var init_metadata = __esm({
|
|
|
1156
1222
|
homepage: "https://rabby.io/",
|
|
1157
1223
|
chromeWebStore: "https://chromewebstore.google.com/detail/rabby/acmacodkjbdgmoleebolmdjonilkdbch",
|
|
1158
1224
|
detectFlags: ["isRabby"]
|
|
1225
|
+
// Extension only — no mobile app or deep link
|
|
1159
1226
|
},
|
|
1160
1227
|
{
|
|
1161
1228
|
id: "brave",
|
|
@@ -1166,25 +1233,7 @@ var init_metadata = __esm({
|
|
|
1166
1233
|
emoji: "\u{1F981}",
|
|
1167
1234
|
homepage: "https://brave.com/wallet/",
|
|
1168
1235
|
detectFlags: ["isBraveWallet"]
|
|
1169
|
-
|
|
1170
|
-
{
|
|
1171
|
-
id: "okx",
|
|
1172
|
-
name: "OKX",
|
|
1173
|
-
category: "injected",
|
|
1174
|
-
ecosystem: "evm",
|
|
1175
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
|
|
1176
|
-
emoji: "\u2B1B",
|
|
1177
|
-
homepage: "https://www.okx.com/web3",
|
|
1178
|
-
detectFlags: ["isOkxWallet"]
|
|
1179
|
-
},
|
|
1180
|
-
{
|
|
1181
|
-
id: "zerion",
|
|
1182
|
-
name: "Zerion",
|
|
1183
|
-
category: "app",
|
|
1184
|
-
ecosystem: "evm",
|
|
1185
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
|
|
1186
|
-
emoji: "\u{1F9FF}",
|
|
1187
|
-
homepage: "https://zerion.io/wallet/"
|
|
1236
|
+
// Built into Brave browser — no standalone deep link
|
|
1188
1237
|
},
|
|
1189
1238
|
{
|
|
1190
1239
|
id: "taho",
|
|
@@ -1195,16 +1244,7 @@ var init_metadata = __esm({
|
|
|
1195
1244
|
emoji: "\u{1F7EA}",
|
|
1196
1245
|
homepage: "https://taho.xyz/",
|
|
1197
1246
|
detectFlags: ["isTally", "isTallyWallet", "isTahoWallet"]
|
|
1198
|
-
|
|
1199
|
-
{
|
|
1200
|
-
id: "trust",
|
|
1201
|
-
name: "Trust Wallet",
|
|
1202
|
-
category: "app",
|
|
1203
|
-
ecosystem: "multi",
|
|
1204
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
|
|
1205
|
-
emoji: "\u{1F6E1}\uFE0F",
|
|
1206
|
-
homepage: "https://trustwallet.com/",
|
|
1207
|
-
detectFlags: ["isTrustWallet"]
|
|
1247
|
+
// Extension only — no mobile app
|
|
1208
1248
|
},
|
|
1209
1249
|
{
|
|
1210
1250
|
id: "bitget",
|
|
@@ -1214,7 +1254,22 @@ var init_metadata = __esm({
|
|
|
1214
1254
|
logo: `${ASSETS_BASE_URL}/assets/wallets/bitget.svg`,
|
|
1215
1255
|
emoji: "\u{1F7E9}",
|
|
1216
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",
|
|
1217
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
|
|
1218
1273
|
},
|
|
1219
1274
|
{
|
|
1220
1275
|
id: "safe",
|
|
@@ -1223,7 +1278,10 @@ var init_metadata = __esm({
|
|
|
1223
1278
|
ecosystem: "evm",
|
|
1224
1279
|
logo: `${ASSETS_BASE_URL}/assets/wallets/safe.svg`,
|
|
1225
1280
|
emoji: "\u{1F7E9}",
|
|
1226
|
-
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
|
|
1227
1285
|
},
|
|
1228
1286
|
{
|
|
1229
1287
|
id: "kucoin",
|
|
@@ -1232,7 +1290,10 @@ var init_metadata = __esm({
|
|
|
1232
1290
|
ecosystem: "evm",
|
|
1233
1291
|
logo: `${ASSETS_BASE_URL}/assets/wallets/kucoin.svg`,
|
|
1234
1292
|
emoji: "\u{1F7E6}",
|
|
1235
|
-
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
|
|
1236
1297
|
}
|
|
1237
1298
|
];
|
|
1238
1299
|
}
|
|
@@ -1410,6 +1471,14 @@ function useWalletDetection(timeoutMs = 400) {
|
|
|
1410
1471
|
);
|
|
1411
1472
|
return { detected, detectedIds };
|
|
1412
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
|
+
}
|
|
1413
1482
|
var import_react, WALLET_BY_ID, DETECT_PRIORITY, GENERIC_FLAGS, RDNS_WALLET_MAP, NAME_WALLET_MAP;
|
|
1414
1483
|
var init_detect = __esm({
|
|
1415
1484
|
"src/wallets/detect.ts"() {
|
|
@@ -4048,6 +4117,7 @@ var init_wallets = __esm({
|
|
|
4048
4117
|
init_adapters();
|
|
4049
4118
|
init_solana();
|
|
4050
4119
|
init_detect();
|
|
4120
|
+
init_metadata();
|
|
4051
4121
|
}
|
|
4052
4122
|
});
|
|
4053
4123
|
|
|
@@ -4195,11 +4265,6 @@ var init_routes = __esm({
|
|
|
4195
4265
|
});
|
|
4196
4266
|
|
|
4197
4267
|
// src/registry.ts
|
|
4198
|
-
var registry_exports = {};
|
|
4199
|
-
__export(registry_exports, {
|
|
4200
|
-
NATIVE: () => NATIVE,
|
|
4201
|
-
Registry: () => Registry
|
|
4202
|
-
});
|
|
4203
4268
|
function getChainAliases(chain) {
|
|
4204
4269
|
const values = [
|
|
4205
4270
|
chain.chainId,
|
|
@@ -4724,7 +4789,7 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
4724
4789
|
}
|
|
4725
4790
|
return stream();
|
|
4726
4791
|
}
|
|
4727
|
-
async function getBalances(chainRef, address) {
|
|
4792
|
+
async function getBalances(chainRef, address, opts) {
|
|
4728
4793
|
const reg = await ensureRegistry();
|
|
4729
4794
|
const chain = reg.chain(chainRef);
|
|
4730
4795
|
if (!chain) return [];
|
|
@@ -4739,8 +4804,10 @@ async function getBalances(chainRef, address) {
|
|
|
4739
4804
|
chain.nativeCurrency?.decimals ?? "",
|
|
4740
4805
|
normalizeChainType(chain) ?? ""
|
|
4741
4806
|
].join(":");
|
|
4742
|
-
|
|
4743
|
-
|
|
4807
|
+
if (!opts?.forceRefresh) {
|
|
4808
|
+
const cached = balanceCache.get(cacheKey);
|
|
4809
|
+
if (cached) return cached;
|
|
4810
|
+
}
|
|
4744
4811
|
const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
|
|
4745
4812
|
const response = await fetch(url, {
|
|
4746
4813
|
method: "GET",
|
|
@@ -4826,6 +4893,37 @@ var init_balances = __esm({
|
|
|
4826
4893
|
}
|
|
4827
4894
|
});
|
|
4828
4895
|
|
|
4896
|
+
// src/core/registryClient.ts
|
|
4897
|
+
var registryClient_exports = {};
|
|
4898
|
+
__export(registryClient_exports, {
|
|
4899
|
+
getSharedRegistry: () => getSharedRegistry
|
|
4900
|
+
});
|
|
4901
|
+
function registryCacheKey() {
|
|
4902
|
+
const base2 = apiBase();
|
|
4903
|
+
const apiKey = TrustwareConfigStore.peek()?.apiKey ?? "__uninitialized__";
|
|
4904
|
+
return `${base2}::${apiKey}`;
|
|
4905
|
+
}
|
|
4906
|
+
function getSharedRegistry() {
|
|
4907
|
+
const key = registryCacheKey();
|
|
4908
|
+
const existing = registryCache.get(key);
|
|
4909
|
+
if (existing) {
|
|
4910
|
+
return existing;
|
|
4911
|
+
}
|
|
4912
|
+
const registry = new Registry(apiBase());
|
|
4913
|
+
registryCache.set(key, registry);
|
|
4914
|
+
return registry;
|
|
4915
|
+
}
|
|
4916
|
+
var registryCache;
|
|
4917
|
+
var init_registryClient = __esm({
|
|
4918
|
+
"src/core/registryClient.ts"() {
|
|
4919
|
+
"use strict";
|
|
4920
|
+
init_config2();
|
|
4921
|
+
init_registry();
|
|
4922
|
+
init_http();
|
|
4923
|
+
registryCache = /* @__PURE__ */ new Map();
|
|
4924
|
+
}
|
|
4925
|
+
});
|
|
4926
|
+
|
|
4829
4927
|
// src/core/tx.ts
|
|
4830
4928
|
function backendChainId(chain, fallback) {
|
|
4831
4929
|
const preferred = chain?.networkIdentifier ?? chain?.chainId ?? chain?.id;
|
|
@@ -4897,10 +4995,9 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
4897
4995
|
if (w.ecosystem !== "solana") {
|
|
4898
4996
|
throw new Error("A Solana wallet is required for this route");
|
|
4899
4997
|
}
|
|
4900
|
-
const {
|
|
4901
|
-
const
|
|
4902
|
-
|
|
4903
|
-
await registry.ensureLoaded();
|
|
4998
|
+
const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
|
|
4999
|
+
const registry = getSharedRegistry2();
|
|
5000
|
+
await registry.ensureChainsLoaded();
|
|
4904
5001
|
const chain = registry.chain(
|
|
4905
5002
|
String(fallbackChainId ?? txReq.chainId ?? "")
|
|
4906
5003
|
);
|
|
@@ -4914,9 +5011,8 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
4914
5011
|
async function runTopUp(params) {
|
|
4915
5012
|
const w = walletManager.wallet;
|
|
4916
5013
|
if (!w) throw new Error("Trustware.wallet not configured");
|
|
4917
|
-
const {
|
|
4918
|
-
const
|
|
4919
|
-
const reg = new Registry2(apiBase2());
|
|
5014
|
+
const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
|
|
5015
|
+
const reg = getSharedRegistry2();
|
|
4920
5016
|
await reg.ensureLoaded();
|
|
4921
5017
|
const fromAddress = await w.getAddress();
|
|
4922
5018
|
const currentChainRef = w.ecosystem === "evm" ? String(await w.getChainId()) : await w.getChainKey?.() ?? "solana-mainnet-beta";
|
|
@@ -4972,33 +5068,6 @@ var init_tx = __esm({
|
|
|
4972
5068
|
}
|
|
4973
5069
|
});
|
|
4974
5070
|
|
|
4975
|
-
// src/core/registryClient.ts
|
|
4976
|
-
function registryCacheKey() {
|
|
4977
|
-
const base2 = apiBase();
|
|
4978
|
-
const apiKey = TrustwareConfigStore.peek()?.apiKey ?? "__uninitialized__";
|
|
4979
|
-
return `${base2}::${apiKey}`;
|
|
4980
|
-
}
|
|
4981
|
-
function getSharedRegistry() {
|
|
4982
|
-
const key = registryCacheKey();
|
|
4983
|
-
const existing = registryCache.get(key);
|
|
4984
|
-
if (existing) {
|
|
4985
|
-
return existing;
|
|
4986
|
-
}
|
|
4987
|
-
const registry = new Registry(apiBase());
|
|
4988
|
-
registryCache.set(key, registry);
|
|
4989
|
-
return registry;
|
|
4990
|
-
}
|
|
4991
|
-
var registryCache;
|
|
4992
|
-
var init_registryClient = __esm({
|
|
4993
|
-
"src/core/registryClient.ts"() {
|
|
4994
|
-
"use strict";
|
|
4995
|
-
init_config2();
|
|
4996
|
-
init_registry();
|
|
4997
|
-
init_http();
|
|
4998
|
-
registryCache = /* @__PURE__ */ new Map();
|
|
4999
|
-
}
|
|
5000
|
-
});
|
|
5001
|
-
|
|
5002
5071
|
// src/widget/helpers/chainHelpers.ts
|
|
5003
5072
|
function normalizeChainKey2(id) {
|
|
5004
5073
|
if (id === void 0 || id === null) return "";
|
|
@@ -7203,6 +7272,39 @@ var init_core = __esm({
|
|
|
7203
7272
|
getConfig() {
|
|
7204
7273
|
return TrustwareConfigStore.get();
|
|
7205
7274
|
},
|
|
7275
|
+
/**
|
|
7276
|
+
* Read the SDK's currently configured theme mode.
|
|
7277
|
+
*
|
|
7278
|
+
* Returns the raw setting — `"light" | "dark" | "system"` — i.e. whatever
|
|
7279
|
+
* was last passed to `init()` or `setTheme()`. When the mode is `"system"`,
|
|
7280
|
+
* the widget resolves the actual light/dark appearance itself (from the OS
|
|
7281
|
+
* `prefers-color-scheme`, or a saved preference if the user has used the
|
|
7282
|
+
* widget's built-in theme toggle), so this getter still reports `"system"`
|
|
7283
|
+
* rather than the resolved value.
|
|
7284
|
+
*/
|
|
7285
|
+
getTheme() {
|
|
7286
|
+
return TrustwareConfigStore.get().theme;
|
|
7287
|
+
},
|
|
7288
|
+
/**
|
|
7289
|
+
* Set the widget's theme at runtime.
|
|
7290
|
+
*
|
|
7291
|
+
* Call this from your own app's theme toggle to keep an embedded
|
|
7292
|
+
* `TrustwareWidget` in sync with your UI — no remount required, any
|
|
7293
|
+
* mounted widget picks up the change immediately.
|
|
7294
|
+
*
|
|
7295
|
+
* Passing `"light"` or `"dark"` pins the widget to that mode. Passing
|
|
7296
|
+
* `"system"` makes it follow the OS preference again — unless the user
|
|
7297
|
+
* previously used the widget's own in-widget theme toggle, in which case
|
|
7298
|
+
* their saved choice takes precedence until they toggle it again.
|
|
7299
|
+
*
|
|
7300
|
+
* @example
|
|
7301
|
+
* // In your app's own dark-mode toggle handler:
|
|
7302
|
+
* Trustware.setTheme(isDark ? "dark" : "light");
|
|
7303
|
+
*/
|
|
7304
|
+
setTheme(theme) {
|
|
7305
|
+
TrustwareConfigStore.update({ theme });
|
|
7306
|
+
return Trustware;
|
|
7307
|
+
},
|
|
7206
7308
|
setDestinationAddress(address) {
|
|
7207
7309
|
const prev = TrustwareConfigStore.get();
|
|
7208
7310
|
TrustwareConfigStore.update({
|
|
@@ -7631,7 +7733,6 @@ function useTrustwareConfig() {
|
|
|
7631
7733
|
toToken: "",
|
|
7632
7734
|
toAddress: void 0,
|
|
7633
7735
|
defaultSlippage: 1,
|
|
7634
|
-
routeType: "swap",
|
|
7635
7736
|
options: {}
|
|
7636
7737
|
},
|
|
7637
7738
|
autoDetectProvider: false,
|
|
@@ -9323,8 +9424,8 @@ var init_theme = __esm({
|
|
|
9323
9424
|
--tw-accent-foreground: 0 0% 100%;
|
|
9324
9425
|
--tw-destructive: 0 84% 60%;
|
|
9325
9426
|
--tw-destructive-foreground: 0 0% 100%;
|
|
9326
|
-
--tw-border: 220 13%
|
|
9327
|
-
--tw-input: 220 13%
|
|
9427
|
+
--tw-border: 220 13% 94%;
|
|
9428
|
+
--tw-input: 220 13% 94%;
|
|
9328
9429
|
--tw-ring: 217 91% 60%;
|
|
9329
9430
|
--tw-radius: 1rem;
|
|
9330
9431
|
|
|
@@ -13759,7 +13860,7 @@ function ChainSelectorPanel({
|
|
|
13759
13860
|
paddingTop: spacing[2],
|
|
13760
13861
|
paddingBottom: spacing[2],
|
|
13761
13862
|
fontSize: fontSize.sm,
|
|
13762
|
-
backgroundColor: colors.
|
|
13863
|
+
backgroundColor: colors.background,
|
|
13763
13864
|
border: `1px solid ${colors.border}`,
|
|
13764
13865
|
borderRadius: borderRadius.lg,
|
|
13765
13866
|
color: colors.foreground,
|
|
@@ -13973,7 +14074,7 @@ function TokenSearchInput({
|
|
|
13973
14074
|
paddingTop: spacing[2],
|
|
13974
14075
|
paddingBottom: spacing[2],
|
|
13975
14076
|
fontSize: fontSize.sm,
|
|
13976
|
-
backgroundColor: colors.
|
|
14077
|
+
backgroundColor: colors.background,
|
|
13977
14078
|
border: `1px solid ${colors.border}`,
|
|
13978
14079
|
borderRadius: borderRadius.lg,
|
|
13979
14080
|
color: colors.foreground,
|
|
@@ -16117,7 +16218,7 @@ var init_WalletNamespaceTabs = __esm({
|
|
|
16117
16218
|
});
|
|
16118
16219
|
|
|
16119
16220
|
// src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx
|
|
16120
|
-
function
|
|
16221
|
+
function DesktopWalletDropdownContent({
|
|
16121
16222
|
browserWallets,
|
|
16122
16223
|
handleWalletConnect,
|
|
16123
16224
|
handleWalletSelect
|
|
@@ -16181,7 +16282,263 @@ function CryptoWalletDropdownContent({
|
|
|
16181
16282
|
}
|
|
16182
16283
|
);
|
|
16183
16284
|
}
|
|
16184
|
-
|
|
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;
|
|
16185
16542
|
var init_CryptoWalletDropdownContent = __esm({
|
|
16186
16543
|
"src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx"() {
|
|
16187
16544
|
"use strict";
|
|
@@ -16192,6 +16549,8 @@ var init_CryptoWalletDropdownContent = __esm({
|
|
|
16192
16549
|
init_paymentOptionStyles();
|
|
16193
16550
|
init_WalletNamespaceTabs();
|
|
16194
16551
|
init_DepositContext();
|
|
16552
|
+
init_wallets();
|
|
16553
|
+
import_react34 = require("react");
|
|
16195
16554
|
import_jsx_runtime36 = require("react/jsx-runtime");
|
|
16196
16555
|
}
|
|
16197
16556
|
});
|
|
@@ -16661,12 +17020,12 @@ function useHomeWalletActions({
|
|
|
16661
17020
|
WalletConnect
|
|
16662
17021
|
// setCurrentStepInternal,
|
|
16663
17022
|
}) {
|
|
16664
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0,
|
|
16665
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0,
|
|
16666
|
-
const cryptoDropdownRef = (0,
|
|
16667
|
-
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);
|
|
16668
17027
|
const { disconnect } = useWalletInfo();
|
|
16669
|
-
(0,
|
|
17028
|
+
(0, import_react35.useEffect)(() => {
|
|
16670
17029
|
const handleClickOutside = (event) => {
|
|
16671
17030
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
16672
17031
|
setIsCryptoDropdownOpen(false);
|
|
@@ -16681,7 +17040,7 @@ function useHomeWalletActions({
|
|
|
16681
17040
|
const { resetNavigation } = useDepositNavigationState("home");
|
|
16682
17041
|
const { setYourWalletTokens } = useDepositWallet();
|
|
16683
17042
|
const { isConnected, walletMetaId, connectedVia } = useWalletInfo();
|
|
16684
|
-
const handleWalletSelect = (0,
|
|
17043
|
+
const handleWalletSelect = (0, import_react35.useCallback)(
|
|
16685
17044
|
async (wallet) => {
|
|
16686
17045
|
setIsCryptoDropdownOpen(false);
|
|
16687
17046
|
try {
|
|
@@ -16692,6 +17051,7 @@ function useHomeWalletActions({
|
|
|
16692
17051
|
setWalletType("other");
|
|
16693
17052
|
const { error } = await connectWallet(wallet);
|
|
16694
17053
|
if (error) {
|
|
17054
|
+
console.error("Wallet connection error:", error);
|
|
16695
17055
|
resetNavigation();
|
|
16696
17056
|
return;
|
|
16697
17057
|
}
|
|
@@ -16705,7 +17065,7 @@ function useHomeWalletActions({
|
|
|
16705
17065
|
const handleFiatSelect = () => {
|
|
16706
17066
|
setIsFiatDropdownOpen(false);
|
|
16707
17067
|
};
|
|
16708
|
-
const handleWalletConnect = (0,
|
|
17068
|
+
const handleWalletConnect = (0, import_react35.useCallback)(async () => {
|
|
16709
17069
|
if (connectedVia !== "walletconnect" && isConnected) {
|
|
16710
17070
|
disconnect();
|
|
16711
17071
|
setYourWalletTokens([]);
|
|
@@ -16713,7 +17073,7 @@ function useHomeWalletActions({
|
|
|
16713
17073
|
WalletConnect().catch(() => resetNavigation());
|
|
16714
17074
|
}, [setYourWalletTokens, disconnect]);
|
|
16715
17075
|
const { selectedNamespace } = useDepositWallet();
|
|
16716
|
-
const browserWallets = (0,
|
|
17076
|
+
const browserWallets = (0, import_react35.useMemo)(() => {
|
|
16717
17077
|
if (!detectedWallets?.length) return [];
|
|
16718
17078
|
return detectedWallets.filter(
|
|
16719
17079
|
(wallet) => wallet?.meta?.id !== "walletconnect" && wallet?.meta?.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase()
|
|
@@ -16732,11 +17092,11 @@ function useHomeWalletActions({
|
|
|
16732
17092
|
setIsFiatDropdownOpen
|
|
16733
17093
|
};
|
|
16734
17094
|
}
|
|
16735
|
-
var
|
|
17095
|
+
var import_react35;
|
|
16736
17096
|
var init_useHomeWalletActions = __esm({
|
|
16737
17097
|
"src/widget/features/wallet/hooks/useHomeWalletActions.ts"() {
|
|
16738
17098
|
"use strict";
|
|
16739
|
-
|
|
17099
|
+
import_react35 = require("react");
|
|
16740
17100
|
init_useDepositNavigationState();
|
|
16741
17101
|
init_DepositContext();
|
|
16742
17102
|
init_wallets();
|
|
@@ -17141,7 +17501,7 @@ function useRoutePreviewModel({
|
|
|
17141
17501
|
walletAddress
|
|
17142
17502
|
}) {
|
|
17143
17503
|
const { chains } = useChains();
|
|
17144
|
-
const destinationConfig = (0,
|
|
17504
|
+
const destinationConfig = (0, import_react36.useMemo)(
|
|
17145
17505
|
() => ({
|
|
17146
17506
|
dappName: config.messages?.title || "DApp",
|
|
17147
17507
|
toChain: config.routes.toChain,
|
|
@@ -17155,7 +17515,7 @@ function useRoutePreviewModel({
|
|
|
17155
17515
|
config.routes.toToken
|
|
17156
17516
|
]
|
|
17157
17517
|
);
|
|
17158
|
-
const routeConfig = (0,
|
|
17518
|
+
const routeConfig = (0, import_react36.useMemo)(() => {
|
|
17159
17519
|
const toChainId = config.routes.toChain;
|
|
17160
17520
|
const toChainKey = normalizeChainKey2(toChainId);
|
|
17161
17521
|
const toChain = toChainKey ? chains.find(
|
|
@@ -17192,7 +17552,7 @@ function useRoutePreviewModel({
|
|
|
17192
17552
|
...routeConfig,
|
|
17193
17553
|
enabled: !!isReady
|
|
17194
17554
|
});
|
|
17195
|
-
const routePrerequisiteError = (0,
|
|
17555
|
+
const routePrerequisiteError = (0, import_react36.useMemo)(() => {
|
|
17196
17556
|
if (!isReady) return;
|
|
17197
17557
|
if (!selectedChain) {
|
|
17198
17558
|
return "Select a source chain to fetch a route.";
|
|
@@ -17233,11 +17593,11 @@ function useRoutePreviewModel({
|
|
|
17233
17593
|
...routeBuilderState
|
|
17234
17594
|
};
|
|
17235
17595
|
}
|
|
17236
|
-
var
|
|
17596
|
+
var import_react36;
|
|
17237
17597
|
var init_useRoutePreviewModel = __esm({
|
|
17238
17598
|
"src/widget/features/route-preview/hooks/useRoutePreviewModel.ts"() {
|
|
17239
17599
|
"use strict";
|
|
17240
|
-
|
|
17600
|
+
import_react36 = require("react");
|
|
17241
17601
|
init_hooks2();
|
|
17242
17602
|
init_chainHelpers();
|
|
17243
17603
|
}
|
|
@@ -30798,7 +31158,7 @@ function useTransactionActionModel({
|
|
|
30798
31158
|
walletAddress,
|
|
30799
31159
|
walletStatus
|
|
30800
31160
|
}) {
|
|
30801
|
-
const feeDataCacheRef = (0,
|
|
31161
|
+
const feeDataCacheRef = (0, import_react37.useRef)({});
|
|
30802
31162
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
30803
31163
|
const { trackEvent } = useGTM(GTM_ID);
|
|
30804
31164
|
const destinationConfig = (() => {
|
|
@@ -30811,7 +31171,7 @@ function useTransactionActionModel({
|
|
|
30811
31171
|
const chainType = selectedChain?.type ?? selectedChain?.chainType;
|
|
30812
31172
|
const chainTypeNormalized = (chainType ?? "").toLowerCase();
|
|
30813
31173
|
const isEvm = chainTypeNormalized === "evm";
|
|
30814
|
-
const backendChainId2 = (0,
|
|
31174
|
+
const backendChainId2 = (0, import_react37.useMemo)(() => {
|
|
30815
31175
|
const chainRef = routeResult?.txReq?.chainId ?? selectedChain?.networkIdentifier ?? selectedChain?.chainId ?? selectedChain?.id;
|
|
30816
31176
|
if (chainRef == null) return null;
|
|
30817
31177
|
return String(chainRef);
|
|
@@ -30821,7 +31181,7 @@ function useTransactionActionModel({
|
|
|
30821
31181
|
selectedChain?.id,
|
|
30822
31182
|
selectedChain?.networkIdentifier
|
|
30823
31183
|
]);
|
|
30824
|
-
const selectedTokenOnBackendChain = (0,
|
|
31184
|
+
const selectedTokenOnBackendChain = (0, import_react37.useMemo)(() => {
|
|
30825
31185
|
if (!backendChainId2) return false;
|
|
30826
31186
|
const target = normalizeChainKey2(backendChainId2);
|
|
30827
31187
|
return [
|
|
@@ -30838,23 +31198,23 @@ function useTransactionActionModel({
|
|
|
30838
31198
|
selectedChain?.id,
|
|
30839
31199
|
selectedChain?.networkIdentifier
|
|
30840
31200
|
]);
|
|
30841
|
-
const isNativeSelected = (0,
|
|
31201
|
+
const isNativeSelected = (0, import_react37.useMemo)(() => {
|
|
30842
31202
|
const address = selectedToken?.address;
|
|
30843
31203
|
return isNativeTokenAddress(address, chainType) || isZeroAddrLike(address, chainType) || normalizeTokenAddressForCompare(selectedChain, address) === normalizeTokenAddressForCompare(
|
|
30844
31204
|
selectedChain,
|
|
30845
31205
|
getNativeTokenAddress2(chainType)
|
|
30846
31206
|
);
|
|
30847
31207
|
}, [chainType, selectedChain, selectedToken?.address]);
|
|
30848
|
-
const spender = (0,
|
|
31208
|
+
const spender = (0, import_react37.useMemo)(() => {
|
|
30849
31209
|
const txReq = routeResult?.txReq;
|
|
30850
31210
|
const addr = txReq?.to ?? txReq?.target;
|
|
30851
31211
|
return addr ?? null;
|
|
30852
31212
|
}, [routeResult?.txReq]);
|
|
30853
|
-
const [allowanceWei, setAllowanceWei] = (0,
|
|
30854
|
-
const [isReadingAllowance, setIsReadingAllowance] = (0,
|
|
30855
|
-
const [isApproving, setIsApproving] = (0,
|
|
30856
|
-
const [gasReservationWei, setGasReservationWei] = (0,
|
|
30857
|
-
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 () => {
|
|
30858
31218
|
if (!isEvm || isNativeSelected || !!routeResult?.sponsorship || // sponsored routes: SA approves bridge inside the UO batch
|
|
30859
31219
|
!backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
30860
31220
|
setAllowanceWei(0n);
|
|
@@ -30884,12 +31244,12 @@ function useTransactionActionModel({
|
|
|
30884
31244
|
spender,
|
|
30885
31245
|
walletAddress
|
|
30886
31246
|
]);
|
|
30887
|
-
(0,
|
|
31247
|
+
(0, import_react37.useEffect)(() => {
|
|
30888
31248
|
void readAllowance();
|
|
30889
31249
|
}, [readAllowance]);
|
|
30890
31250
|
const needsApproval = isEvm && !isNativeSelected && !routeResult?.sponsorship && // sponsored routes use Permit2 + SA internal batch — no EOA bridge approval
|
|
30891
31251
|
!!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
|
|
30892
|
-
const waitForApprovalConfirmation2 = (0,
|
|
31252
|
+
const waitForApprovalConfirmation2 = (0, import_react37.useCallback)(
|
|
30893
31253
|
async (chainId, txHash) => {
|
|
30894
31254
|
const timeoutMs = 12e4;
|
|
30895
31255
|
const intervalMs = 2e3;
|
|
@@ -30908,7 +31268,7 @@ function useTransactionActionModel({
|
|
|
30908
31268
|
},
|
|
30909
31269
|
[]
|
|
30910
31270
|
);
|
|
30911
|
-
const handleApproveExact = (0,
|
|
31271
|
+
const handleApproveExact = (0, import_react37.useCallback)(async () => {
|
|
30912
31272
|
if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
|
|
30913
31273
|
return;
|
|
30914
31274
|
}
|
|
@@ -31001,7 +31361,7 @@ function useTransactionActionModel({
|
|
|
31001
31361
|
waitForApprovalConfirmation2,
|
|
31002
31362
|
walletAddress
|
|
31003
31363
|
]);
|
|
31004
|
-
const getCachedFeeData = (0,
|
|
31364
|
+
const getCachedFeeData = (0, import_react37.useCallback)(async () => {
|
|
31005
31365
|
if (!backendChainId2) return {};
|
|
31006
31366
|
const now = Date.now();
|
|
31007
31367
|
const cache = feeDataCacheRef.current;
|
|
@@ -31024,7 +31384,7 @@ function useTransactionActionModel({
|
|
|
31024
31384
|
}
|
|
31025
31385
|
return cache.inflight;
|
|
31026
31386
|
}, [backendChainId2]);
|
|
31027
|
-
const estimateGasReservationWei = (0,
|
|
31387
|
+
const estimateGasReservationWei = (0, import_react37.useCallback)(async () => {
|
|
31028
31388
|
if (!isNativeSelected) {
|
|
31029
31389
|
setGasReservationWei(0n);
|
|
31030
31390
|
return 0n;
|
|
@@ -31088,16 +31448,16 @@ function useTransactionActionModel({
|
|
|
31088
31448
|
routeResult?.txReq,
|
|
31089
31449
|
walletAddress
|
|
31090
31450
|
]);
|
|
31091
|
-
(0,
|
|
31451
|
+
(0, import_react37.useEffect)(() => {
|
|
31092
31452
|
if (routeResult) {
|
|
31093
31453
|
void estimateGasReservationWei();
|
|
31094
31454
|
}
|
|
31095
31455
|
}, [estimateGasReservationWei, routeResult]);
|
|
31096
|
-
const [smartAccountFailed, setSmartAccountFailed] = (0,
|
|
31097
|
-
(0,
|
|
31456
|
+
const [smartAccountFailed, setSmartAccountFailed] = (0, import_react37.useState)(false);
|
|
31457
|
+
(0, import_react37.useEffect)(() => {
|
|
31098
31458
|
setSmartAccountFailed(false);
|
|
31099
31459
|
}, [routeResult?.intentId]);
|
|
31100
|
-
const handleConfirm = (0,
|
|
31460
|
+
const handleConfirm = (0, import_react37.useCallback)(async () => {
|
|
31101
31461
|
if (!routeResult) {
|
|
31102
31462
|
return;
|
|
31103
31463
|
}
|
|
@@ -31167,7 +31527,7 @@ function useTransactionActionModel({
|
|
|
31167
31527
|
trackEvent,
|
|
31168
31528
|
walletAddress
|
|
31169
31529
|
]);
|
|
31170
|
-
const handleSwipeConfirm = (0,
|
|
31530
|
+
const handleSwipeConfirm = (0, import_react37.useCallback)(async () => {
|
|
31171
31531
|
if (needsApproval) {
|
|
31172
31532
|
await handleApproveExact();
|
|
31173
31533
|
if (!backendChainId2 || !selectedTokenOnBackendChain || !selectedToken?.address || !walletAddress || !spender) {
|
|
@@ -31198,7 +31558,7 @@ function useTransactionActionModel({
|
|
|
31198
31558
|
]);
|
|
31199
31559
|
const isWalletConnected = walletStatus === "connected";
|
|
31200
31560
|
const canSwipe = parsedAmount > 0 && !!selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
|
|
31201
|
-
const swipeResetKey = (0,
|
|
31561
|
+
const swipeResetKey = (0, import_react37.useMemo)(() => {
|
|
31202
31562
|
const tokenAddress = selectedToken ? normalizeAddress2(
|
|
31203
31563
|
selectedToken.address,
|
|
31204
31564
|
selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType
|
|
@@ -31224,11 +31584,11 @@ function useTransactionActionModel({
|
|
|
31224
31584
|
swipeResetKey
|
|
31225
31585
|
};
|
|
31226
31586
|
}
|
|
31227
|
-
var
|
|
31587
|
+
var import_react37, import_viem42;
|
|
31228
31588
|
var init_useTransactionActionModel = __esm({
|
|
31229
31589
|
"src/widget/features/transaction/hooks/useTransactionActionModel.ts"() {
|
|
31230
31590
|
"use strict";
|
|
31231
|
-
|
|
31591
|
+
import_react37 = require("react");
|
|
31232
31592
|
import_viem42 = require("viem");
|
|
31233
31593
|
init_core2();
|
|
31234
31594
|
init_sdkRpc();
|
|
@@ -31432,9 +31792,9 @@ var init_DefaultCryptoPay = __esm({
|
|
|
31432
31792
|
|
|
31433
31793
|
// src/widget/pages/CryptoPay/RouteQuoteLoader.tsx
|
|
31434
31794
|
function RouteQuoteLoader({ selectedToken }) {
|
|
31435
|
-
const [messageIndex, setMessageIndex] = (0,
|
|
31436
|
-
const [visible, setVisible] = (0,
|
|
31437
|
-
(0,
|
|
31795
|
+
const [messageIndex, setMessageIndex] = (0, import_react38.useState)(0);
|
|
31796
|
+
const [visible, setVisible] = (0, import_react38.useState)(true);
|
|
31797
|
+
(0, import_react38.useEffect)(() => {
|
|
31438
31798
|
let t = null;
|
|
31439
31799
|
const interval = setInterval(() => {
|
|
31440
31800
|
setVisible(false);
|
|
@@ -31590,11 +31950,11 @@ function RouteQuoteLoader({ selectedToken }) {
|
|
|
31590
31950
|
}
|
|
31591
31951
|
);
|
|
31592
31952
|
}
|
|
31593
|
-
var
|
|
31953
|
+
var import_react38, import_jsx_runtime49, QUOTE_MESSAGES;
|
|
31594
31954
|
var init_RouteQuoteLoader = __esm({
|
|
31595
31955
|
"src/widget/pages/CryptoPay/RouteQuoteLoader.tsx"() {
|
|
31596
31956
|
"use strict";
|
|
31597
|
-
|
|
31957
|
+
import_react38 = require("react");
|
|
31598
31958
|
init_styles();
|
|
31599
31959
|
import_jsx_runtime49 = require("react/jsx-runtime");
|
|
31600
31960
|
QUOTE_MESSAGES = [
|
|
@@ -31634,17 +31994,17 @@ function CryptoPay({ style: _style }) {
|
|
|
31634
31994
|
const { goBack, setCurrentStep, currentStep } = useDepositNavigation();
|
|
31635
31995
|
const config = useTrustwareConfig();
|
|
31636
31996
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
31637
|
-
const routeRefreshMs = (0,
|
|
31997
|
+
const routeRefreshMs = (0, import_react39.useMemo)(() => {
|
|
31638
31998
|
const raw = config.routes?.options?.routeRefreshMs;
|
|
31639
31999
|
const n = Number(raw);
|
|
31640
32000
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
31641
32001
|
}, [config.routes?.options?.routeRefreshMs]);
|
|
31642
32002
|
const IsPos = (x) => x !== null && x !== void 0 && x.balance !== "0";
|
|
31643
|
-
const showDefaultCryptoPay = (0,
|
|
32003
|
+
const showDefaultCryptoPay = (0, import_react39.useMemo)(() => {
|
|
31644
32004
|
const nonZer0Tks = (yourWalletTokens ?? []).filter(IsPos);
|
|
31645
32005
|
return !yourWalletTokensLoading && nonZer0Tks.length === 0 && yourWalletTokens.length > 0;
|
|
31646
32006
|
}, [yourWalletTokens, yourWalletTokensLoading]);
|
|
31647
|
-
const showSkeleton = (0,
|
|
32007
|
+
const showSkeleton = (0, import_react39.useMemo)(() => {
|
|
31648
32008
|
return (yourWalletTokens ?? []).length === 0;
|
|
31649
32009
|
}, [yourWalletTokens]);
|
|
31650
32010
|
const isReady = selectedToken != null && selectedToken?.chainData !== void 0 && !showDefaultCryptoPay && !showSkeleton;
|
|
@@ -31720,7 +32080,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31720
32080
|
});
|
|
31721
32081
|
const { emitError } = useTrustware();
|
|
31722
32082
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
31723
|
-
(0,
|
|
32083
|
+
(0, import_react39.useEffect)(() => {
|
|
31724
32084
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
31725
32085
|
emitError?.(
|
|
31726
32086
|
new TrustwareError({
|
|
@@ -31749,7 +32109,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31749
32109
|
if (isFixedAmount) return;
|
|
31750
32110
|
setAmount(value.toString());
|
|
31751
32111
|
};
|
|
31752
|
-
const relayFeeUsd = (0,
|
|
32112
|
+
const relayFeeUsd = (0, import_react39.useMemo)(
|
|
31753
32113
|
() => computeRelayFeeUsd(routeResult, isNativeSelected),
|
|
31754
32114
|
[isNativeSelected, routeResult]
|
|
31755
32115
|
);
|
|
@@ -31919,11 +32279,11 @@ function CryptoPay({ style: _style }) {
|
|
|
31919
32279
|
}
|
|
31920
32280
|
);
|
|
31921
32281
|
}
|
|
31922
|
-
var
|
|
32282
|
+
var import_react39, import_jsx_runtime50, SHOW_FEE_SUMMARY;
|
|
31923
32283
|
var init_CryptoPay = __esm({
|
|
31924
32284
|
"src/widget/pages/CryptoPay/index.tsx"() {
|
|
31925
32285
|
"use strict";
|
|
31926
|
-
|
|
32286
|
+
import_react39 = require("react");
|
|
31927
32287
|
init_relayFeeUtils();
|
|
31928
32288
|
init_TrustwareError();
|
|
31929
32289
|
init_useTrustwareConfig();
|
|
@@ -31980,27 +32340,27 @@ function Processing({ style }) {
|
|
|
31980
32340
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
31981
32341
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
31982
32342
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
31983
|
-
const hasStartedPolling = (0,
|
|
31984
|
-
(0,
|
|
32343
|
+
const hasStartedPolling = (0, import_react40.useRef)(false);
|
|
32344
|
+
(0, import_react40.useEffect)(() => {
|
|
31985
32345
|
return () => {
|
|
31986
32346
|
hasStartedPolling.current = false;
|
|
31987
32347
|
};
|
|
31988
32348
|
}, []);
|
|
31989
|
-
(0,
|
|
32349
|
+
(0, import_react40.useEffect)(() => {
|
|
31990
32350
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
31991
32351
|
hasStartedPolling.current = true;
|
|
31992
32352
|
startPolling(intentId, transactionHash);
|
|
31993
32353
|
}
|
|
31994
32354
|
}, [intentId, transactionHash, isPolling, transactionStatus, startPolling]);
|
|
31995
|
-
const progress = (0,
|
|
32355
|
+
const progress = (0, import_react40.useMemo)(
|
|
31996
32356
|
() => getProgressFromStatus(transactionStatus),
|
|
31997
32357
|
[transactionStatus]
|
|
31998
32358
|
);
|
|
31999
|
-
const stepText = (0,
|
|
32359
|
+
const stepText = (0, import_react40.useMemo)(
|
|
32000
32360
|
() => getStepText(transactionStatus),
|
|
32001
32361
|
[transactionStatus]
|
|
32002
32362
|
);
|
|
32003
|
-
const explorerUrl = (0,
|
|
32363
|
+
const explorerUrl = (0, import_react40.useMemo)(() => {
|
|
32004
32364
|
if (transaction?.fromChainTxUrl) {
|
|
32005
32365
|
return transaction.fromChainTxUrl;
|
|
32006
32366
|
}
|
|
@@ -32135,11 +32495,11 @@ function Processing({ style }) {
|
|
|
32135
32495
|
}
|
|
32136
32496
|
);
|
|
32137
32497
|
}
|
|
32138
|
-
var
|
|
32498
|
+
var import_react40, import_jsx_runtime51;
|
|
32139
32499
|
var init_Processing = __esm({
|
|
32140
32500
|
"src/widget/pages/Processing.tsx"() {
|
|
32141
32501
|
"use strict";
|
|
32142
|
-
|
|
32502
|
+
import_react40 = require("react");
|
|
32143
32503
|
init_styles();
|
|
32144
32504
|
init_DepositContext();
|
|
32145
32505
|
init_components();
|
|
@@ -32154,8 +32514,8 @@ function Success({ style }) {
|
|
|
32154
32514
|
const { resetState } = useDepositNavigation();
|
|
32155
32515
|
const { transactionHash } = useDepositTransaction();
|
|
32156
32516
|
const { transaction } = useTransactionPolling();
|
|
32157
|
-
const parsedAmount = (0,
|
|
32158
|
-
const explorerUrl = (0,
|
|
32517
|
+
const parsedAmount = (0, import_react41.useMemo)(() => parseFloat(amount) || 0, [amount]);
|
|
32518
|
+
const explorerUrl = (0, import_react41.useMemo)(() => {
|
|
32159
32519
|
if (transaction?.toChainTxUrl) {
|
|
32160
32520
|
return transaction.toChainTxUrl;
|
|
32161
32521
|
}
|
|
@@ -32183,7 +32543,7 @@ function Success({ style }) {
|
|
|
32183
32543
|
...style
|
|
32184
32544
|
},
|
|
32185
32545
|
children: [
|
|
32186
|
-
/* @__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 }) }),
|
|
32187
32547
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(WidgetPageHeader, { title: "Deposit Complete" }),
|
|
32188
32548
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
32189
32549
|
"div",
|
|
@@ -32216,16 +32576,16 @@ function Success({ style }) {
|
|
|
32216
32576
|
}
|
|
32217
32577
|
);
|
|
32218
32578
|
}
|
|
32219
|
-
var
|
|
32579
|
+
var import_react41, import_jsx_runtime52, ConfettiEffect2;
|
|
32220
32580
|
var init_Success = __esm({
|
|
32221
32581
|
"src/widget/pages/Success.tsx"() {
|
|
32222
32582
|
"use strict";
|
|
32223
|
-
|
|
32583
|
+
import_react41 = require("react");
|
|
32224
32584
|
init_DepositContext();
|
|
32225
32585
|
init_components();
|
|
32226
32586
|
init_transaction2();
|
|
32227
32587
|
import_jsx_runtime52 = require("react/jsx-runtime");
|
|
32228
|
-
ConfettiEffect2 = (0,
|
|
32588
|
+
ConfettiEffect2 = (0, import_react41.lazy)(() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports)));
|
|
32229
32589
|
}
|
|
32230
32590
|
});
|
|
32231
32591
|
|
|
@@ -32387,8 +32747,8 @@ function Error2({ style: _style }) {
|
|
|
32387
32747
|
setErrorMessage,
|
|
32388
32748
|
transactionHash
|
|
32389
32749
|
} = useDepositTransaction();
|
|
32390
|
-
const mapped = (0,
|
|
32391
|
-
const explorerUrl = (0,
|
|
32750
|
+
const mapped = (0, import_react42.useMemo)(() => mapError(errorMessage), [errorMessage]);
|
|
32751
|
+
const explorerUrl = (0, import_react42.useMemo)(() => {
|
|
32392
32752
|
if (transactionHash && selectedChain?.blockExplorerUrls?.length) {
|
|
32393
32753
|
return `${selectedChain.blockExplorerUrls[0].replace(/\/+$/, "")}/tx/${transactionHash}`;
|
|
32394
32754
|
}
|
|
@@ -32411,11 +32771,11 @@ function Error2({ style: _style }) {
|
|
|
32411
32771
|
}
|
|
32412
32772
|
);
|
|
32413
32773
|
}
|
|
32414
|
-
var
|
|
32774
|
+
var import_react42, import_jsx_runtime53;
|
|
32415
32775
|
var init_Error = __esm({
|
|
32416
32776
|
"src/widget/pages/Error.tsx"() {
|
|
32417
32777
|
"use strict";
|
|
32418
|
-
|
|
32778
|
+
import_react42 = require("react");
|
|
32419
32779
|
init_DepositContext();
|
|
32420
32780
|
init_components();
|
|
32421
32781
|
init_mapError();
|
|
@@ -32456,11 +32816,11 @@ function WidgetRouter({
|
|
|
32456
32816
|
navigationDirection,
|
|
32457
32817
|
stepHistory
|
|
32458
32818
|
}) {
|
|
32459
|
-
const PageComponent = (0,
|
|
32819
|
+
const PageComponent = (0, import_react43.useMemo)(
|
|
32460
32820
|
() => PAGE_COMPONENTS[currentStep],
|
|
32461
32821
|
[currentStep]
|
|
32462
32822
|
);
|
|
32463
|
-
const animationClass = (0,
|
|
32823
|
+
const animationClass = (0, import_react43.useMemo)(() => {
|
|
32464
32824
|
return navigationDirection === "forward" ? "tw-animate-slide-in-right" : "tw-animate-slide-in-left";
|
|
32465
32825
|
}, [navigationDirection]);
|
|
32466
32826
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
@@ -32473,11 +32833,11 @@ function WidgetRouter({
|
|
|
32473
32833
|
`${currentStep}-${stepHistory.length}`
|
|
32474
32834
|
);
|
|
32475
32835
|
}
|
|
32476
|
-
var
|
|
32836
|
+
var import_react43, import_jsx_runtime54, pageContainerBaseStyle;
|
|
32477
32837
|
var init_WidgetRouter = __esm({
|
|
32478
32838
|
"src/widget/app/WidgetRouter.tsx"() {
|
|
32479
32839
|
"use strict";
|
|
32480
|
-
|
|
32840
|
+
import_react43 = require("react");
|
|
32481
32841
|
init_utils2();
|
|
32482
32842
|
init_widgetSteps();
|
|
32483
32843
|
import_jsx_runtime54 = require("react/jsx-runtime");
|
|
@@ -32491,13 +32851,13 @@ var init_WidgetRouter = __esm({
|
|
|
32491
32851
|
|
|
32492
32852
|
// src/modes/swap/hooks/useSwapRoute.ts
|
|
32493
32853
|
function useSwapRoute() {
|
|
32494
|
-
const [state, setState] = (0,
|
|
32854
|
+
const [state, setState] = (0, import_react44.useState)({
|
|
32495
32855
|
data: null,
|
|
32496
32856
|
loading: false,
|
|
32497
32857
|
error: null
|
|
32498
32858
|
});
|
|
32499
|
-
const abortRef = (0,
|
|
32500
|
-
const fetch2 = (0,
|
|
32859
|
+
const abortRef = (0, import_react44.useRef)(false);
|
|
32860
|
+
const fetch2 = (0, import_react44.useCallback)(
|
|
32501
32861
|
async (params) => {
|
|
32502
32862
|
const { fromToken, fromChain, toToken, toChain, amount, walletAddress } = params;
|
|
32503
32863
|
const decimals = fromToken.decimals ?? 18;
|
|
@@ -32538,18 +32898,18 @@ function useSwapRoute() {
|
|
|
32538
32898
|
},
|
|
32539
32899
|
[]
|
|
32540
32900
|
);
|
|
32541
|
-
const clear = (0,
|
|
32901
|
+
const clear = (0, import_react44.useCallback)(() => {
|
|
32542
32902
|
abortRef.current = true;
|
|
32543
32903
|
setState({ data: null, loading: false, error: null });
|
|
32544
32904
|
}, []);
|
|
32545
32905
|
return { ...state, fetch: fetch2, clear };
|
|
32546
32906
|
}
|
|
32547
|
-
var
|
|
32907
|
+
var import_react44;
|
|
32548
32908
|
var init_useSwapRoute = __esm({
|
|
32549
32909
|
"src/modes/swap/hooks/useSwapRoute.ts"() {
|
|
32550
32910
|
"use strict";
|
|
32551
32911
|
"use client";
|
|
32552
|
-
|
|
32912
|
+
import_react44 = require("react");
|
|
32553
32913
|
init_routes();
|
|
32554
32914
|
init_chainHelpers();
|
|
32555
32915
|
init_store();
|
|
@@ -32590,7 +32950,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
32590
32950
|
throw new Error("Timed out waiting for approval confirmation");
|
|
32591
32951
|
}
|
|
32592
32952
|
function useSwapExecution(fromChain) {
|
|
32593
|
-
const [state, setState] = (0,
|
|
32953
|
+
const [state, setState] = (0, import_react45.useState)({
|
|
32594
32954
|
txStatus: "idle",
|
|
32595
32955
|
txHash: null,
|
|
32596
32956
|
intentId: null,
|
|
@@ -32599,19 +32959,19 @@ function useSwapExecution(fromChain) {
|
|
|
32599
32959
|
isSubmitting: false,
|
|
32600
32960
|
allowanceStatus: "unknown"
|
|
32601
32961
|
});
|
|
32602
|
-
const saFailedUntilRef = (0,
|
|
32603
|
-
const pollingRef = (0,
|
|
32604
|
-
const timeoutRef = (0,
|
|
32605
|
-
const abortRef = (0,
|
|
32606
|
-
const pollCountRef = (0,
|
|
32607
|
-
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)(() => {
|
|
32608
32968
|
abortRef.current = true;
|
|
32609
32969
|
if (pollingRef.current) clearTimeout(pollingRef.current);
|
|
32610
32970
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
32611
32971
|
pollingRef.current = null;
|
|
32612
32972
|
timeoutRef.current = null;
|
|
32613
32973
|
}, []);
|
|
32614
|
-
const startPolling = (0,
|
|
32974
|
+
const startPolling = (0, import_react45.useCallback)(
|
|
32615
32975
|
(intentIdVal, onSuccess, onError) => {
|
|
32616
32976
|
clearPolling();
|
|
32617
32977
|
abortRef.current = false;
|
|
@@ -32656,7 +33016,7 @@ function useSwapExecution(fromChain) {
|
|
|
32656
33016
|
},
|
|
32657
33017
|
[clearPolling]
|
|
32658
33018
|
);
|
|
32659
|
-
const checkAllowance = (0,
|
|
33019
|
+
const checkAllowance = (0, import_react45.useCallback)(
|
|
32660
33020
|
async (params) => {
|
|
32661
33021
|
const { fromTokenAddress, walletAddress, routeResult } = params;
|
|
32662
33022
|
if (routeResult.sponsorship) {
|
|
@@ -32696,7 +33056,7 @@ function useSwapExecution(fromChain) {
|
|
|
32696
33056
|
},
|
|
32697
33057
|
[fromChain]
|
|
32698
33058
|
);
|
|
32699
|
-
const execute = (0,
|
|
33059
|
+
const execute = (0, import_react45.useCallback)(
|
|
32700
33060
|
async (routeResult, fromTokenAddress, fromTokenDecimals, walletAddress, maxApproval, onSuccess, onError) => {
|
|
32701
33061
|
if (!routeResult?.txReq) {
|
|
32702
33062
|
const msg = "Invalid route data. Please try again.";
|
|
@@ -32892,10 +33252,10 @@ function useSwapExecution(fromChain) {
|
|
|
32892
33252
|
},
|
|
32893
33253
|
[fromChain, startPolling]
|
|
32894
33254
|
);
|
|
32895
|
-
const resetSmartAccountFailure = (0,
|
|
33255
|
+
const resetSmartAccountFailure = (0, import_react45.useCallback)(() => {
|
|
32896
33256
|
saFailedUntilRef.current = 0;
|
|
32897
33257
|
}, []);
|
|
32898
|
-
const reset = (0,
|
|
33258
|
+
const reset = (0, import_react45.useCallback)(() => {
|
|
32899
33259
|
clearPolling();
|
|
32900
33260
|
saFailedUntilRef.current = 0;
|
|
32901
33261
|
setState({
|
|
@@ -32926,12 +33286,12 @@ function mapTxError(err) {
|
|
|
32926
33286
|
return "Transaction would fail. Try a different amount.";
|
|
32927
33287
|
return msg.length > 150 ? msg.slice(0, 147) + "..." : msg || "Transaction failed.";
|
|
32928
33288
|
}
|
|
32929
|
-
var
|
|
33289
|
+
var import_react45, import_viem43, FAST_POLL_MS, SLOW_POLL_MS, TIMEOUT_MS, SA_COOLDOWN_MS;
|
|
32930
33290
|
var init_useSwapExecution = __esm({
|
|
32931
33291
|
"src/modes/swap/hooks/useSwapExecution.ts"() {
|
|
32932
33292
|
"use strict";
|
|
32933
33293
|
"use client";
|
|
32934
|
-
|
|
33294
|
+
import_react45 = require("react");
|
|
32935
33295
|
import_viem43 = require("viem");
|
|
32936
33296
|
init_core2();
|
|
32937
33297
|
init_routes();
|
|
@@ -32969,11 +33329,11 @@ var init_forex = __esm({
|
|
|
32969
33329
|
|
|
32970
33330
|
// src/modes/swap/hooks/useForex.ts
|
|
32971
33331
|
function useForex() {
|
|
32972
|
-
const [rates, setRates] = (0,
|
|
32973
|
-
const [error, setError] = (0,
|
|
32974
|
-
const [lastUpdated, setLastUpdated] = (0,
|
|
32975
|
-
const timerRef = (0,
|
|
32976
|
-
(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)(() => {
|
|
32977
33337
|
let cancelled = false;
|
|
32978
33338
|
const load = () => {
|
|
32979
33339
|
fetchForexRates("USD").then((r) => {
|
|
@@ -33000,11 +33360,11 @@ function useForex() {
|
|
|
33000
33360
|
}, []);
|
|
33001
33361
|
return { rates, error, lastUpdated };
|
|
33002
33362
|
}
|
|
33003
|
-
var
|
|
33363
|
+
var import_react46, REFRESH_MS;
|
|
33004
33364
|
var init_useForex = __esm({
|
|
33005
33365
|
"src/modes/swap/hooks/useForex.ts"() {
|
|
33006
33366
|
"use strict";
|
|
33007
|
-
|
|
33367
|
+
import_react46 = require("react");
|
|
33008
33368
|
init_forex();
|
|
33009
33369
|
REFRESH_MS = 5 * 60 * 1e3;
|
|
33010
33370
|
}
|
|
@@ -33025,10 +33385,10 @@ function SwapTokenSelect({
|
|
|
33025
33385
|
allowedTokens,
|
|
33026
33386
|
excludeToken
|
|
33027
33387
|
}) {
|
|
33028
|
-
const [localChain, setLocalChain] = (0,
|
|
33029
|
-
const [pinnedTokens, setPinnedTokens] = (0,
|
|
33030
|
-
const [pinnedLoading, setPinnedLoading] = (0,
|
|
33031
|
-
(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)(() => {
|
|
33032
33392
|
if (!allowedTokens || allowedTokens.length === 0 || !localChain) {
|
|
33033
33393
|
setPinnedTokens([]);
|
|
33034
33394
|
return;
|
|
@@ -33109,26 +33469,26 @@ function SwapTokenSelect({
|
|
|
33109
33469
|
walletAddress,
|
|
33110
33470
|
yourWalletTokens
|
|
33111
33471
|
});
|
|
33112
|
-
const allowedSet = (0,
|
|
33472
|
+
const allowedSet = (0, import_react47.useMemo)(() => {
|
|
33113
33473
|
if (!allowedTokens || allowedTokens.length === 0) return null;
|
|
33114
33474
|
return new Set(
|
|
33115
33475
|
allowedTokens.map((t) => `${t.chainId}:${t.address.toLowerCase()}`)
|
|
33116
33476
|
);
|
|
33117
33477
|
}, [allowedTokens]);
|
|
33118
|
-
const filteredWalletTokens = (0,
|
|
33478
|
+
const filteredWalletTokens = (0, import_react47.useMemo)(() => {
|
|
33119
33479
|
if (!allowedSet) return rawWalletTokens;
|
|
33120
33480
|
return rawWalletTokens.filter(
|
|
33121
33481
|
(t) => allowedSet.has(`${Number(t.chainId)}:${t.address.toLowerCase()}`)
|
|
33122
33482
|
);
|
|
33123
33483
|
}, [rawWalletTokens, allowedSet]);
|
|
33124
33484
|
const excludeKey = excludeToken ? `${Number(excludeToken.chainId)}:${excludeToken.address.toLowerCase()}` : null;
|
|
33125
|
-
const visibleTokens = (0,
|
|
33485
|
+
const visibleTokens = (0, import_react47.useMemo)(() => {
|
|
33126
33486
|
if (!excludeKey) return filteredTokens;
|
|
33127
33487
|
return filteredTokens.filter(
|
|
33128
33488
|
(t) => `${Number(t.chainId)}:${t.address.toLowerCase()}` !== excludeKey
|
|
33129
33489
|
);
|
|
33130
33490
|
}, [filteredTokens, excludeKey]);
|
|
33131
|
-
const visibleWalletTokens = (0,
|
|
33491
|
+
const visibleWalletTokens = (0, import_react47.useMemo)(() => {
|
|
33132
33492
|
if (!excludeKey) return filteredWalletTokens;
|
|
33133
33493
|
return filteredWalletTokens.filter(
|
|
33134
33494
|
(t) => `${Number(t.chainId)}:${t.address.toLowerCase()}` !== excludeKey
|
|
@@ -33245,11 +33605,11 @@ function SwapTokenSelect({
|
|
|
33245
33605
|
}
|
|
33246
33606
|
);
|
|
33247
33607
|
}
|
|
33248
|
-
var
|
|
33608
|
+
var import_react47, import_jsx_runtime55;
|
|
33249
33609
|
var init_SwapTokenSelect = __esm({
|
|
33250
33610
|
"src/modes/swap/components/SwapTokenSelect.tsx"() {
|
|
33251
33611
|
"use strict";
|
|
33252
|
-
|
|
33612
|
+
import_react47 = require("react");
|
|
33253
33613
|
init_styles();
|
|
33254
33614
|
init_registryClient();
|
|
33255
33615
|
init_hooks2();
|
|
@@ -33275,16 +33635,16 @@ function SwapWalletSelector({
|
|
|
33275
33635
|
} = useWalletInfo();
|
|
33276
33636
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
33277
33637
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
33278
|
-
const [wcConnecting, setWcConnecting] = (0,
|
|
33279
|
-
const [connectingId, setConnectingId] = (0,
|
|
33280
|
-
const [timerExpired, setTimerExpired] = (0,
|
|
33281
|
-
const [selectedNamespace, setSelectedNamespace] = (0,
|
|
33282
|
-
const prevStatusRef = (0,
|
|
33283
|
-
(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)(() => {
|
|
33284
33644
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
33285
33645
|
return () => clearTimeout(t);
|
|
33286
33646
|
}, []);
|
|
33287
|
-
(0,
|
|
33647
|
+
(0, import_react48.useEffect)(() => {
|
|
33288
33648
|
const prev = prevStatusRef.current;
|
|
33289
33649
|
if (prev !== walletStatus) {
|
|
33290
33650
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -33293,7 +33653,7 @@ function SwapWalletSelector({
|
|
|
33293
33653
|
prevStatusRef.current = walletStatus;
|
|
33294
33654
|
}
|
|
33295
33655
|
}, [walletStatus]);
|
|
33296
|
-
const filteredWallets = (0,
|
|
33656
|
+
const filteredWallets = (0, import_react48.useMemo)(
|
|
33297
33657
|
() => detected.filter(
|
|
33298
33658
|
(w) => (w.meta?.ecosystem ?? "").toLowerCase() === selectedNamespace
|
|
33299
33659
|
),
|
|
@@ -33869,11 +34229,11 @@ function SwapWalletSelector({
|
|
|
33869
34229
|
] })
|
|
33870
34230
|
] });
|
|
33871
34231
|
}
|
|
33872
|
-
var
|
|
34232
|
+
var import_react48, import_jsx_runtime56;
|
|
33873
34233
|
var init_SwapWalletSelector = __esm({
|
|
33874
34234
|
"src/modes/swap/components/SwapWalletSelector.tsx"() {
|
|
33875
34235
|
"use strict";
|
|
33876
|
-
|
|
34236
|
+
import_react48 = require("react");
|
|
33877
34237
|
init_styles();
|
|
33878
34238
|
init_utils2();
|
|
33879
34239
|
init_wallets();
|
|
@@ -34048,41 +34408,41 @@ function SwapMode({
|
|
|
34048
34408
|
theme: themeProp,
|
|
34049
34409
|
style
|
|
34050
34410
|
}) {
|
|
34051
|
-
const [stage, setStage] = (0,
|
|
34052
|
-
const [fromToken, setFromToken] = (0,
|
|
34411
|
+
const [stage, setStage] = (0, import_react49.useState)("home");
|
|
34412
|
+
const [fromToken, setFromToken] = (0, import_react49.useState)(
|
|
34053
34413
|
null
|
|
34054
34414
|
);
|
|
34055
|
-
const [fromChain, setFromChain] = (0,
|
|
34056
|
-
const [toToken, setToToken] = (0,
|
|
34057
|
-
const [toChain, setToChain] = (0,
|
|
34058
|
-
const [amount, setAmount] = (0,
|
|
34059
|
-
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)(
|
|
34060
34420
|
"usd"
|
|
34061
34421
|
);
|
|
34062
|
-
const [hoverSell, setHoverSell] = (0,
|
|
34063
|
-
const [showRateDetails, setShowRateDetails] = (0,
|
|
34064
|
-
const [showReviewDetails, setShowReviewDetails] = (0,
|
|
34065
|
-
const [showSettings, setShowSettings] = (0,
|
|
34066
|
-
const [maxApproval, setMaxApproval] = (0,
|
|
34067
|
-
const [slippage, setSlippage] = (0,
|
|
34068
|
-
const [slippageInput, setSlippageInput] = (0,
|
|
34069
|
-
const [selectedCurrency, setSelectedCurrency] = (0,
|
|
34070
|
-
const [showCurrencyDropdown, setShowCurrencyDropdown] = (0,
|
|
34071
|
-
const [completedAt, setCompletedAt] = (0,
|
|
34072
|
-
const [copiedHash, setCopiedHash] = (0,
|
|
34073
|
-
const [rateUpdated, setRateUpdated] = (0,
|
|
34074
|
-
const prevToAmountRef = (0,
|
|
34075
|
-
const [destAddress, setDestAddress] = (0,
|
|
34076
|
-
const [quoteAge, setQuoteAge] = (0,
|
|
34077
|
-
const quoteTimestampRef = (0,
|
|
34078
|
-
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = (0,
|
|
34079
|
-
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = (0,
|
|
34080
|
-
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);
|
|
34081
34441
|
const { rates: forexRates } = useForex();
|
|
34082
34442
|
const currencyMeta = getCurrencyMeta(selectedCurrency);
|
|
34083
34443
|
const currencyRate = forexRates[selectedCurrency] ?? 1;
|
|
34084
34444
|
const currencySymbol = currencyMeta.symbol;
|
|
34085
|
-
const fmtLocal = (0,
|
|
34445
|
+
const fmtLocal = (0, import_react49.useCallback)(
|
|
34086
34446
|
(usdAmount) => {
|
|
34087
34447
|
const sym = getCurrencyMeta(selectedCurrency).symbol;
|
|
34088
34448
|
if (usdAmount === null || !isFinite(usdAmount) || usdAmount <= 0)
|
|
@@ -34093,8 +34453,8 @@ function SwapMode({
|
|
|
34093
34453
|
},
|
|
34094
34454
|
[currencyRate, selectedCurrency]
|
|
34095
34455
|
);
|
|
34096
|
-
const settingsRef = (0,
|
|
34097
|
-
const currencyDropdownRef = (0,
|
|
34456
|
+
const settingsRef = (0, import_react49.useRef)(null);
|
|
34457
|
+
const currencyDropdownRef = (0, import_react49.useRef)(null);
|
|
34098
34458
|
const { emitEvent } = useTrustware();
|
|
34099
34459
|
const { features, theme: configTheme } = useTrustwareConfig();
|
|
34100
34460
|
const effectiveThemeSetting = themeProp ?? configTheme ?? "system";
|
|
@@ -34110,26 +34470,26 @@ function SwapMode({
|
|
|
34110
34470
|
isLoading: chainsLoading,
|
|
34111
34471
|
error: chainsError
|
|
34112
34472
|
} = useChains();
|
|
34113
|
-
const allowedDestChainIds = (0,
|
|
34473
|
+
const allowedDestChainIds = (0, import_react49.useMemo)(() => {
|
|
34114
34474
|
if (!allowedDestTokens || allowedDestTokens.length === 0) return null;
|
|
34115
34475
|
return new Set(allowedDestTokens.map((t) => t.chainId));
|
|
34116
34476
|
}, [allowedDestTokens]);
|
|
34117
|
-
const toPopularChains = (0,
|
|
34477
|
+
const toPopularChains = (0, import_react49.useMemo)(
|
|
34118
34478
|
() => allowedDestChainIds ? popularChains.filter(
|
|
34119
34479
|
(c) => allowedDestChainIds.has(Number(c.chainId))
|
|
34120
34480
|
) : popularChains,
|
|
34121
34481
|
[popularChains, allowedDestChainIds]
|
|
34122
34482
|
);
|
|
34123
|
-
const toOtherChains = (0,
|
|
34483
|
+
const toOtherChains = (0, import_react49.useMemo)(
|
|
34124
34484
|
() => allowedDestChainIds ? otherChains.filter((c) => allowedDestChainIds.has(Number(c.chainId))) : otherChains,
|
|
34125
34485
|
[otherChains, allowedDestChainIds]
|
|
34126
34486
|
);
|
|
34127
|
-
const allChains = (0,
|
|
34487
|
+
const allChains = (0, import_react49.useMemo)(
|
|
34128
34488
|
() => [...popularChains, ...otherChains],
|
|
34129
34489
|
[popularChains, otherChains]
|
|
34130
34490
|
);
|
|
34131
|
-
const destInitialized = (0,
|
|
34132
|
-
(0,
|
|
34491
|
+
const destInitialized = (0, import_react49.useRef)(false);
|
|
34492
|
+
(0, import_react49.useEffect)(() => {
|
|
34133
34493
|
if (!defaultDestRef || destInitialized.current || allChains.length === 0)
|
|
34134
34494
|
return;
|
|
34135
34495
|
const chain = allChains.find(
|
|
@@ -34160,11 +34520,11 @@ function SwapMode({
|
|
|
34160
34520
|
});
|
|
34161
34521
|
}, [defaultDestRef, allChains]);
|
|
34162
34522
|
const { walletAddress, walletStatus, connectWallet, disconnectWallet } = useWalletSessionState();
|
|
34163
|
-
const setFromTokenStable = (0,
|
|
34523
|
+
const setFromTokenStable = (0, import_react49.useCallback)(
|
|
34164
34524
|
(t) => setFromToken(t),
|
|
34165
34525
|
[]
|
|
34166
34526
|
);
|
|
34167
|
-
const setFromChainStable = (0,
|
|
34527
|
+
const setFromChainStable = (0, import_react49.useCallback)(
|
|
34168
34528
|
(c) => setFromChain(c),
|
|
34169
34529
|
[]
|
|
34170
34530
|
);
|
|
@@ -34177,18 +34537,18 @@ function SwapMode({
|
|
|
34177
34537
|
});
|
|
34178
34538
|
const route = useSwapRoute();
|
|
34179
34539
|
const execution = useSwapExecution(fromChain);
|
|
34180
|
-
const fromTokenPriceUSD = (0,
|
|
34540
|
+
const fromTokenPriceUSD = (0, import_react49.useMemo)(() => {
|
|
34181
34541
|
const p = fromToken?.usdPrice;
|
|
34182
34542
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
34183
34543
|
}, [fromToken]);
|
|
34184
34544
|
const hasFromUsdPrice = fromTokenPriceUSD > 0;
|
|
34185
|
-
const toTokenPriceUSD = (0,
|
|
34545
|
+
const toTokenPriceUSD = (0, import_react49.useMemo)(() => {
|
|
34186
34546
|
const p = toToken?.usdPrice;
|
|
34187
34547
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
34188
34548
|
}, [toToken]);
|
|
34189
34549
|
const hasToUsdPrice = toTokenPriceUSD > 0;
|
|
34190
34550
|
const rawSellNum = parseFloat(amount) || 0;
|
|
34191
|
-
const usdSellNum = (0,
|
|
34551
|
+
const usdSellNum = (0, import_react49.useMemo)(() => {
|
|
34192
34552
|
if (amountInputMode === "usd") return rawSellNum / currencyRate;
|
|
34193
34553
|
return hasFromUsdPrice ? rawSellNum * fromTokenPriceUSD : 0;
|
|
34194
34554
|
}, [
|
|
@@ -34198,7 +34558,7 @@ function SwapMode({
|
|
|
34198
34558
|
hasFromUsdPrice,
|
|
34199
34559
|
fromTokenPriceUSD
|
|
34200
34560
|
]);
|
|
34201
|
-
const tokenSellNum = (0,
|
|
34561
|
+
const tokenSellNum = (0, import_react49.useMemo)(() => {
|
|
34202
34562
|
if (amountInputMode === "usd") {
|
|
34203
34563
|
return hasFromUsdPrice && fromTokenPriceUSD > 0 ? usdSellNum / fromTokenPriceUSD : 0;
|
|
34204
34564
|
}
|
|
@@ -34210,12 +34570,12 @@ function SwapMode({
|
|
|
34210
34570
|
hasFromUsdPrice,
|
|
34211
34571
|
fromTokenPriceUSD
|
|
34212
34572
|
]);
|
|
34213
|
-
const tokenAmountStr = (0,
|
|
34573
|
+
const tokenAmountStr = (0, import_react49.useMemo)(() => {
|
|
34214
34574
|
if (tokenSellNum <= 0) return "";
|
|
34215
34575
|
const decimals = fromToken?.decimals ?? 18;
|
|
34216
34576
|
return truncateDecimal(tokenSellNum, Math.min(decimals, 18));
|
|
34217
34577
|
}, [tokenSellNum, fromToken?.decimals]);
|
|
34218
|
-
const handleCurrencyChange = (0,
|
|
34578
|
+
const handleCurrencyChange = (0, import_react49.useCallback)(
|
|
34219
34579
|
(newCode) => {
|
|
34220
34580
|
if (amountInputMode === "usd" && amount) {
|
|
34221
34581
|
const oldRate = currencyRate;
|
|
@@ -34230,7 +34590,7 @@ function SwapMode({
|
|
|
34230
34590
|
},
|
|
34231
34591
|
[amountInputMode, amount, currencyRate, forexRates, route]
|
|
34232
34592
|
);
|
|
34233
|
-
const handleSelectFromToken = (0,
|
|
34593
|
+
const handleSelectFromToken = (0, import_react49.useCallback)(
|
|
34234
34594
|
(token, chain) => {
|
|
34235
34595
|
setFromToken(token);
|
|
34236
34596
|
setFromChain(chain);
|
|
@@ -34251,7 +34611,7 @@ function SwapMode({
|
|
|
34251
34611
|
},
|
|
34252
34612
|
[route, emitEvent, toToken, toChain, amount]
|
|
34253
34613
|
);
|
|
34254
|
-
const handleSelectToToken = (0,
|
|
34614
|
+
const handleSelectToToken = (0, import_react49.useCallback)(
|
|
34255
34615
|
(token, chain) => {
|
|
34256
34616
|
setToToken(token);
|
|
34257
34617
|
setToChain(chain);
|
|
@@ -34268,7 +34628,7 @@ function SwapMode({
|
|
|
34268
34628
|
},
|
|
34269
34629
|
[route, emitEvent, fromToken, fromChain, amount]
|
|
34270
34630
|
);
|
|
34271
|
-
const handleFlip = (0,
|
|
34631
|
+
const handleFlip = (0, import_react49.useCallback)(() => {
|
|
34272
34632
|
if (lockDestToken) return;
|
|
34273
34633
|
const newFrom = toToken ?? fromToken;
|
|
34274
34634
|
const newFromChain = toChain ?? fromChain;
|
|
@@ -34290,7 +34650,7 @@ function SwapMode({
|
|
|
34290
34650
|
const toChainType = normalizeChainType2(toChain);
|
|
34291
34651
|
const needsDestAddress = !!fromChainType && !!toChainType && fromChainType !== toChainType;
|
|
34292
34652
|
const isValidDestAddress = !needsDestAddress || validateDestAddress(destAddress, toChainType ?? "");
|
|
34293
|
-
const handleReview = (0,
|
|
34653
|
+
const handleReview = (0, import_react49.useCallback)(async () => {
|
|
34294
34654
|
if (!fromToken || !fromChain || !toToken || !toChain || !tokenAmountStr || !walletAddress) {
|
|
34295
34655
|
if (!walletAddress) setStage("connect-wallet");
|
|
34296
34656
|
return;
|
|
@@ -34325,19 +34685,24 @@ function SwapMode({
|
|
|
34325
34685
|
route,
|
|
34326
34686
|
slippage
|
|
34327
34687
|
]);
|
|
34328
|
-
const handleConnectAndReview = (0,
|
|
34688
|
+
const handleConnectAndReview = (0, import_react49.useCallback)(() => {
|
|
34329
34689
|
setStage("connect-wallet");
|
|
34330
34690
|
}, []);
|
|
34331
|
-
const handleWalletConnected = (0,
|
|
34691
|
+
const handleWalletConnected = (0, import_react49.useCallback)(() => {
|
|
34332
34692
|
setStage("home");
|
|
34333
34693
|
}, []);
|
|
34334
|
-
const handleExecute = (0,
|
|
34694
|
+
const handleExecute = (0, import_react49.useCallback)(async () => {
|
|
34335
34695
|
if (!route.data) return;
|
|
34336
34696
|
setStage("processing");
|
|
34337
34697
|
const fromTokenAddress = fromToken?.address ?? fromToken?.address;
|
|
34338
34698
|
const fromTokenDecimals = fromToken?.decimals ?? void 0;
|
|
34699
|
+
let routeToSend = route.data;
|
|
34700
|
+
if (isSerializedSolanaTxRequest(routeToSend.txReq) && latestFetchParamsRef.current) {
|
|
34701
|
+
const fresh = await route.fetch(latestFetchParamsRef.current);
|
|
34702
|
+
if (fresh) routeToSend = fresh;
|
|
34703
|
+
}
|
|
34339
34704
|
await execution.execute(
|
|
34340
|
-
|
|
34705
|
+
routeToSend,
|
|
34341
34706
|
fromTokenAddress,
|
|
34342
34707
|
fromTokenDecimals,
|
|
34343
34708
|
walletAddress ?? void 0,
|
|
@@ -34348,8 +34713,8 @@ function SwapMode({
|
|
|
34348
34713
|
},
|
|
34349
34714
|
() => setStage("error")
|
|
34350
34715
|
);
|
|
34351
|
-
}, [route
|
|
34352
|
-
const handleReset = (0,
|
|
34716
|
+
}, [route, execution, fromToken, walletAddress, maxApproval]);
|
|
34717
|
+
const handleReset = (0, import_react49.useCallback)(() => {
|
|
34353
34718
|
execution.reset();
|
|
34354
34719
|
route.clear();
|
|
34355
34720
|
setAmount("");
|
|
@@ -34359,7 +34724,7 @@ function SwapMode({
|
|
|
34359
34724
|
setStage("home");
|
|
34360
34725
|
reloadWalletTokens();
|
|
34361
34726
|
}, [execution, route, reloadWalletTokens]);
|
|
34362
|
-
const handleSwapBack = (0,
|
|
34727
|
+
const handleSwapBack = (0, import_react49.useCallback)(() => {
|
|
34363
34728
|
const prevFrom = fromToken;
|
|
34364
34729
|
const prevFromChain = fromChain;
|
|
34365
34730
|
setFromToken(toToken);
|
|
@@ -34383,14 +34748,14 @@ function SwapMode({
|
|
|
34383
34748
|
route,
|
|
34384
34749
|
reloadWalletTokens
|
|
34385
34750
|
]);
|
|
34386
|
-
const handleCopyHash = (0,
|
|
34751
|
+
const handleCopyHash = (0, import_react49.useCallback)((hash) => {
|
|
34387
34752
|
if (!navigator?.clipboard?.writeText) return;
|
|
34388
34753
|
void navigator.clipboard.writeText(hash).then(() => {
|
|
34389
34754
|
setCopiedHash(hash);
|
|
34390
34755
|
setTimeout(() => setCopiedHash((v) => v === hash ? null : v), 1500);
|
|
34391
34756
|
});
|
|
34392
34757
|
}, []);
|
|
34393
|
-
const handleToggleDenom = (0,
|
|
34758
|
+
const handleToggleDenom = (0, import_react49.useCallback)(() => {
|
|
34394
34759
|
if (!hasFromUsdPrice) return;
|
|
34395
34760
|
const parsed = parseFloat(amount) || 0;
|
|
34396
34761
|
if (amountInputMode === "usd") {
|
|
@@ -34416,7 +34781,7 @@ function SwapMode({
|
|
|
34416
34781
|
fromToken?.decimals,
|
|
34417
34782
|
route
|
|
34418
34783
|
]);
|
|
34419
|
-
const fromBalance = (0,
|
|
34784
|
+
const fromBalance = (0, import_react49.useMemo)(() => {
|
|
34420
34785
|
const walletToken = fromToken;
|
|
34421
34786
|
if (!walletToken || !("balance" in walletToken)) return null;
|
|
34422
34787
|
const raw = walletToken.balance;
|
|
@@ -34426,7 +34791,7 @@ function SwapMode({
|
|
|
34426
34791
|
return Number.isFinite(n) ? n : null;
|
|
34427
34792
|
}, [fromToken]);
|
|
34428
34793
|
const balanceUsd = fromBalance !== null && hasFromUsdPrice ? fromBalance * fromTokenPriceUSD : null;
|
|
34429
|
-
const estimatedToAmount = (0,
|
|
34794
|
+
const estimatedToAmount = (0, import_react49.useMemo)(() => {
|
|
34430
34795
|
if (tokenSellNum <= 0 || !hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
34431
34796
|
return tokenSellNum * (fromTokenPriceUSD / toTokenPriceUSD);
|
|
34432
34797
|
}, [
|
|
@@ -34436,10 +34801,10 @@ function SwapMode({
|
|
|
34436
34801
|
hasFromUsdPrice,
|
|
34437
34802
|
hasToUsdPrice
|
|
34438
34803
|
]);
|
|
34439
|
-
const backendToUsdStr = (0,
|
|
34804
|
+
const backendToUsdStr = (0, import_react49.useMemo)(() => {
|
|
34440
34805
|
return route.data?.finalExchangeRate?.toAmountMinUSD ?? route.data?.route?.estimate?.toAmountMinUsd ?? route.data?.route?.estimate?.toAmountUsd ?? null;
|
|
34441
34806
|
}, [route.data]);
|
|
34442
|
-
const toAmount = (0,
|
|
34807
|
+
const toAmount = (0, import_react49.useMemo)(() => {
|
|
34443
34808
|
if (backendToUsdStr && toTokenPriceUSD > 0) {
|
|
34444
34809
|
const usd = parseFloat(backendToUsdStr);
|
|
34445
34810
|
if (Number.isFinite(usd) && usd > 0) return usd / toTokenPriceUSD;
|
|
@@ -34465,7 +34830,7 @@ function SwapMode({
|
|
|
34465
34830
|
estimatedToAmount
|
|
34466
34831
|
]);
|
|
34467
34832
|
const fromUsd = usdSellNum;
|
|
34468
|
-
const toUsd = (0,
|
|
34833
|
+
const toUsd = (0, import_react49.useMemo)(() => {
|
|
34469
34834
|
if (backendToUsdStr) {
|
|
34470
34835
|
const n = parseFloat(backendToUsdStr);
|
|
34471
34836
|
if (Number.isFinite(n) && n > 0) return n;
|
|
@@ -34476,12 +34841,12 @@ function SwapMode({
|
|
|
34476
34841
|
const isEstimate = !route.data;
|
|
34477
34842
|
const USD_EPSILON = 1e-3;
|
|
34478
34843
|
const displayToUsd = toUsd > USD_EPSILON ? toUsd : estimatedToAmount !== null && hasToUsdPrice ? estimatedToAmount * toTokenPriceUSD : 0;
|
|
34479
|
-
const priceImpact = (0,
|
|
34844
|
+
const priceImpact = (0, import_react49.useMemo)(() => {
|
|
34480
34845
|
if (!route.data || fromUsd < 0.01 || displayToUsd < 0.01) return null;
|
|
34481
34846
|
const impact = 1 - displayToUsd / fromUsd;
|
|
34482
34847
|
return impact > 1e-3 ? impact : null;
|
|
34483
34848
|
}, [route.data, fromUsd, displayToUsd]);
|
|
34484
|
-
const routePath = (0,
|
|
34849
|
+
const routePath = (0, import_react49.useMemo)(() => {
|
|
34485
34850
|
if (!route.data) return null;
|
|
34486
34851
|
const provider = route.data.route?.provider;
|
|
34487
34852
|
const steps = route.data.route?.steps;
|
|
@@ -34508,19 +34873,19 @@ function SwapMode({
|
|
|
34508
34873
|
return null;
|
|
34509
34874
|
}, [route.data, fromToken?.symbol, toToken?.symbol]);
|
|
34510
34875
|
const isGasSponsored = !!route.data?.sponsorship;
|
|
34511
|
-
const networkCostUsd = (0,
|
|
34876
|
+
const networkCostUsd = (0, import_react49.useMemo)(() => {
|
|
34512
34877
|
const fees = route.data?.route?.estimate?.fees;
|
|
34513
34878
|
if (!fees?.length) return null;
|
|
34514
34879
|
const gasTotal = fees.filter((f) => f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
34515
34880
|
return gasTotal > 0 ? gasTotal : null;
|
|
34516
34881
|
}, [route.data]);
|
|
34517
|
-
const protocolFeeUsd = (0,
|
|
34882
|
+
const protocolFeeUsd = (0, import_react49.useMemo)(() => {
|
|
34518
34883
|
const fees = route.data?.route?.estimate?.fees;
|
|
34519
34884
|
if (!fees?.length) return null;
|
|
34520
34885
|
const total = fees.filter((f) => !f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
34521
34886
|
return total > 0 ? total : null;
|
|
34522
34887
|
}, [route.data]);
|
|
34523
|
-
const exchangeRate = (0,
|
|
34888
|
+
const exchangeRate = (0, import_react49.useMemo)(() => {
|
|
34524
34889
|
if (!hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
34525
34890
|
return toTokenPriceUSD / fromTokenPriceUSD;
|
|
34526
34891
|
}, [fromTokenPriceUSD, toTokenPriceUSD, hasFromUsdPrice, hasToUsdPrice]);
|
|
@@ -34529,13 +34894,13 @@ function SwapMode({
|
|
|
34529
34894
|
const hasAmount = rawSellNum > 0 && (amountInputMode === "token" || hasFromUsdPrice);
|
|
34530
34895
|
const isConnected = walletStatus === "connected" && !!walletAddress;
|
|
34531
34896
|
const canGetQuote = hasTokens && hasAmount && !insufficient && isConnected && (!needsDestAddress || isValidDestAddress);
|
|
34532
|
-
(0,
|
|
34897
|
+
(0, import_react49.useEffect)(() => {
|
|
34533
34898
|
if (!fromToken) return;
|
|
34534
34899
|
if (!hasFromUsdPrice && amountInputMode === "usd") {
|
|
34535
34900
|
setAmountInputMode("token");
|
|
34536
34901
|
}
|
|
34537
34902
|
}, [fromToken, hasFromUsdPrice, amountInputMode]);
|
|
34538
|
-
(0,
|
|
34903
|
+
(0, import_react49.useEffect)(() => {
|
|
34539
34904
|
if (displayToAmount === null) {
|
|
34540
34905
|
prevToAmountRef.current = null;
|
|
34541
34906
|
return;
|
|
@@ -34549,14 +34914,14 @@ function SwapMode({
|
|
|
34549
34914
|
const t = setTimeout(() => setRateUpdated(false), 700);
|
|
34550
34915
|
return () => clearTimeout(t);
|
|
34551
34916
|
}, [displayToAmount]);
|
|
34552
|
-
(0,
|
|
34917
|
+
(0, import_react49.useEffect)(() => {
|
|
34553
34918
|
setDestAddress("");
|
|
34554
34919
|
}, [toChainType]);
|
|
34555
|
-
const fetchRef = (0,
|
|
34556
|
-
(0,
|
|
34920
|
+
const fetchRef = (0, import_react49.useRef)(route.fetch);
|
|
34921
|
+
(0, import_react49.useEffect)(() => {
|
|
34557
34922
|
fetchRef.current = route.fetch;
|
|
34558
34923
|
});
|
|
34559
|
-
(0,
|
|
34924
|
+
(0, import_react49.useEffect)(() => {
|
|
34560
34925
|
if (!canGetQuote || stage !== "home") return;
|
|
34561
34926
|
if (!fromToken || !fromChain || !toToken || !toChain || !walletAddress)
|
|
34562
34927
|
return;
|
|
@@ -34585,7 +34950,7 @@ function SwapMode({
|
|
|
34585
34950
|
destAddress,
|
|
34586
34951
|
slippage
|
|
34587
34952
|
]);
|
|
34588
|
-
(0,
|
|
34953
|
+
(0, import_react49.useEffect)(() => {
|
|
34589
34954
|
if (!canGetQuote || !fromToken || !fromChain || !toToken || !toChain || !walletAddress) {
|
|
34590
34955
|
latestFetchParamsRef.current = null;
|
|
34591
34956
|
return;
|
|
@@ -34612,12 +34977,12 @@ function SwapMode({
|
|
|
34612
34977
|
destAddress,
|
|
34613
34978
|
slippage
|
|
34614
34979
|
]);
|
|
34615
|
-
(0,
|
|
34980
|
+
(0, import_react49.useEffect)(() => {
|
|
34616
34981
|
quoteTimestampRef.current = route.data ? Date.now() : null;
|
|
34617
34982
|
setQuoteAge(0);
|
|
34618
34983
|
}, [route.data]);
|
|
34619
|
-
const msgTimeoutRef = (0,
|
|
34620
|
-
(0,
|
|
34984
|
+
const msgTimeoutRef = (0, import_react49.useRef)(null);
|
|
34985
|
+
(0, import_react49.useEffect)(() => {
|
|
34621
34986
|
if (!route.loading) {
|
|
34622
34987
|
setQuoteLoadingMsgIdx(0);
|
|
34623
34988
|
setQuoteLoadingMsgVisible(true);
|
|
@@ -34635,7 +35000,7 @@ function SwapMode({
|
|
|
34635
35000
|
if (msgTimeoutRef.current !== null) clearTimeout(msgTimeoutRef.current);
|
|
34636
35001
|
};
|
|
34637
35002
|
}, [route.loading]);
|
|
34638
|
-
(0,
|
|
35003
|
+
(0, import_react49.useEffect)(() => {
|
|
34639
35004
|
if (!route.data) return;
|
|
34640
35005
|
const id = setInterval(() => {
|
|
34641
35006
|
const ts = quoteTimestampRef.current;
|
|
@@ -34649,7 +35014,7 @@ function SwapMode({
|
|
|
34649
35014
|
}, 1e3);
|
|
34650
35015
|
return () => clearInterval(id);
|
|
34651
35016
|
}, [route.data]);
|
|
34652
|
-
(0,
|
|
35017
|
+
(0, import_react49.useEffect)(() => {
|
|
34653
35018
|
if (stage !== "review") return;
|
|
34654
35019
|
if (!route.data || !walletAddress) return;
|
|
34655
35020
|
const fromTokenAddress = fromToken?.address;
|
|
@@ -34660,7 +35025,7 @@ function SwapMode({
|
|
|
34660
35025
|
routeResult: route.data
|
|
34661
35026
|
});
|
|
34662
35027
|
}, [stage, route.data, walletAddress, fromToken]);
|
|
34663
|
-
(0,
|
|
35028
|
+
(0, import_react49.useEffect)(() => {
|
|
34664
35029
|
if (!showSettings) {
|
|
34665
35030
|
setShowCurrencyDropdown(false);
|
|
34666
35031
|
return;
|
|
@@ -34673,7 +35038,7 @@ function SwapMode({
|
|
|
34673
35038
|
document.addEventListener("mousedown", handler);
|
|
34674
35039
|
return () => document.removeEventListener("mousedown", handler);
|
|
34675
35040
|
}, [showSettings]);
|
|
34676
|
-
(0,
|
|
35041
|
+
(0, import_react49.useEffect)(() => {
|
|
34677
35042
|
if (!showCurrencyDropdown) return;
|
|
34678
35043
|
const handler = (e2) => {
|
|
34679
35044
|
if (currencyDropdownRef.current && !currencyDropdownRef.current.contains(e2.target)) {
|
|
@@ -35215,7 +35580,7 @@ function SwapMode({
|
|
|
35215
35580
|
timeStyle: "short"
|
|
35216
35581
|
}) ?? null;
|
|
35217
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: [
|
|
35218
|
-
/* @__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 }) }),
|
|
35219
35584
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { style: { padding: `${spacing[6]} ${spacing[6]} 0` }, children: [
|
|
35220
35585
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
35221
35586
|
"div",
|
|
@@ -37823,8 +38188,8 @@ function ReviewDetailRow({
|
|
|
37823
38188
|
value,
|
|
37824
38189
|
tooltip
|
|
37825
38190
|
}) {
|
|
37826
|
-
const iconRef = (0,
|
|
37827
|
-
const [tipPos, setTipPos] = (0,
|
|
38191
|
+
const iconRef = (0, import_react49.useRef)(null);
|
|
38192
|
+
const [tipPos, setTipPos] = (0, import_react49.useState)(null);
|
|
37828
38193
|
const handleMouseEnter = () => {
|
|
37829
38194
|
if (!tooltip || !iconRef.current) return;
|
|
37830
38195
|
const r = iconRef.current.getBoundingClientRect();
|
|
@@ -38103,17 +38468,18 @@ function ProcessingStepLine({ done }) {
|
|
|
38103
38468
|
}
|
|
38104
38469
|
);
|
|
38105
38470
|
}
|
|
38106
|
-
var
|
|
38471
|
+
var import_react49, import_react_dom, import_jsx_runtime57, ConfettiEffect3, QUOTE_TTL, QUOTE_LOADING_MESSAGES, PERCENT_OPTIONS;
|
|
38107
38472
|
var init_SwapMode = __esm({
|
|
38108
38473
|
"src/modes/swap/SwapMode.tsx"() {
|
|
38109
38474
|
"use strict";
|
|
38110
|
-
|
|
38475
|
+
import_react49 = require("react");
|
|
38111
38476
|
import_react_dom = __toESM(require("react-dom"), 1);
|
|
38112
38477
|
init_styles();
|
|
38113
38478
|
init_utils2();
|
|
38114
38479
|
init_mapError();
|
|
38115
38480
|
init_components();
|
|
38116
38481
|
init_registryClient();
|
|
38482
|
+
init_routes();
|
|
38117
38483
|
init_useThemePreference();
|
|
38118
38484
|
init_useWalletSessionState();
|
|
38119
38485
|
init_useWalletTokenState();
|
|
@@ -38129,7 +38495,7 @@ var init_SwapMode = __esm({
|
|
|
38129
38495
|
init_SwapWalletSelector();
|
|
38130
38496
|
init_currency();
|
|
38131
38497
|
import_jsx_runtime57 = require("react/jsx-runtime");
|
|
38132
|
-
ConfettiEffect3 = (0,
|
|
38498
|
+
ConfettiEffect3 = (0, import_react49.lazy)(
|
|
38133
38499
|
() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports))
|
|
38134
38500
|
);
|
|
38135
38501
|
QUOTE_TTL = 60;
|
|
@@ -38170,7 +38536,7 @@ function WidgetContent({
|
|
|
38170
38536
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
38171
38537
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
38172
38538
|
useWalletExternalDisconnect(() => setCurrentStep("home"));
|
|
38173
|
-
(0,
|
|
38539
|
+
(0, import_react50.useEffect)(() => {
|
|
38174
38540
|
const state = {
|
|
38175
38541
|
currentStep,
|
|
38176
38542
|
amount,
|
|
@@ -38213,8 +38579,8 @@ function WidgetInner({
|
|
|
38213
38579
|
const { transactionStatus } = useDepositTransaction();
|
|
38214
38580
|
const { resolvedTheme } = useDepositUi();
|
|
38215
38581
|
const { status, revalidate, errors } = useTrustware();
|
|
38216
|
-
const [showConfirmDialog, setShowConfirmDialog] = (0,
|
|
38217
|
-
const handleCloseRequest = (0,
|
|
38582
|
+
const [showConfirmDialog, setShowConfirmDialog] = (0, import_react50.useState)(false);
|
|
38583
|
+
const handleCloseRequest = (0, import_react50.useCallback)(() => {
|
|
38218
38584
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
38219
38585
|
setShowConfirmDialog(true);
|
|
38220
38586
|
} else {
|
|
@@ -38225,20 +38591,20 @@ function WidgetInner({
|
|
|
38225
38591
|
onClose?.();
|
|
38226
38592
|
}
|
|
38227
38593
|
}, [transactionStatus, onClose, resetState]);
|
|
38228
|
-
(0,
|
|
38594
|
+
(0, import_react50.useEffect)(() => {
|
|
38229
38595
|
closeRequestRef.current = handleCloseRequest;
|
|
38230
38596
|
}, [handleCloseRequest, closeRequestRef]);
|
|
38231
|
-
const handleConfirmClose = (0,
|
|
38597
|
+
const handleConfirmClose = (0, import_react50.useCallback)(() => {
|
|
38232
38598
|
setShowConfirmDialog(false);
|
|
38233
38599
|
onClose?.();
|
|
38234
38600
|
}, [onClose]);
|
|
38235
|
-
const handleCancelClose = (0,
|
|
38601
|
+
const handleCancelClose = (0, import_react50.useCallback)(() => {
|
|
38236
38602
|
setShowConfirmDialog(false);
|
|
38237
38603
|
}, []);
|
|
38238
38604
|
const effectiveTheme = resolvedTheme;
|
|
38239
38605
|
const isRefreshing = status === "initializing";
|
|
38240
38606
|
const initBlocked = status === "error";
|
|
38241
|
-
const handleRefresh = (0,
|
|
38607
|
+
const handleRefresh = (0, import_react50.useCallback)(() => {
|
|
38242
38608
|
revalidate?.();
|
|
38243
38609
|
}, [revalidate]);
|
|
38244
38610
|
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
|
|
@@ -38272,11 +38638,11 @@ function WidgetInner({
|
|
|
38272
38638
|
)
|
|
38273
38639
|
] });
|
|
38274
38640
|
}
|
|
38275
|
-
var
|
|
38641
|
+
var import_react50, import_jsx_runtime58, widgetContentContainerStyle, themeToggleContainerStyle, TrustwareWidgetV2;
|
|
38276
38642
|
var init_TrustwareWidgetV2 = __esm({
|
|
38277
38643
|
"src/widget/TrustwareWidgetV2.tsx"() {
|
|
38278
38644
|
"use strict";
|
|
38279
|
-
|
|
38645
|
+
import_react50 = require("react");
|
|
38280
38646
|
init_utils2();
|
|
38281
38647
|
init_styles();
|
|
38282
38648
|
init_DepositContext();
|
|
@@ -38302,7 +38668,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38302
38668
|
right: spacing[3],
|
|
38303
38669
|
zIndex: 12
|
|
38304
38670
|
};
|
|
38305
|
-
TrustwareWidgetV2 = (0,
|
|
38671
|
+
TrustwareWidgetV2 = (0, import_react50.forwardRef)(function TrustwareWidgetV22({
|
|
38306
38672
|
theme,
|
|
38307
38673
|
style,
|
|
38308
38674
|
initialStep = "home",
|
|
@@ -38311,15 +38677,15 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38311
38677
|
onOpen,
|
|
38312
38678
|
showThemeToggle = true
|
|
38313
38679
|
}, ref) {
|
|
38314
|
-
const [isOpen, setIsOpen] = (0,
|
|
38315
|
-
const closeRequestRef = (0,
|
|
38680
|
+
const [isOpen, setIsOpen] = (0, import_react50.useState)(defaultOpen);
|
|
38681
|
+
const closeRequestRef = (0, import_react50.useRef)(null);
|
|
38316
38682
|
const config = useTrustwareConfig();
|
|
38317
38683
|
const effectiveInitialStep = initialStep;
|
|
38318
|
-
const open = (0,
|
|
38684
|
+
const open = (0, import_react50.useCallback)(() => {
|
|
38319
38685
|
setIsOpen(true);
|
|
38320
38686
|
onOpen?.();
|
|
38321
38687
|
}, [onOpen]);
|
|
38322
|
-
const close = (0,
|
|
38688
|
+
const close = (0, import_react50.useCallback)(() => {
|
|
38323
38689
|
if (closeRequestRef.current) {
|
|
38324
38690
|
closeRequestRef.current();
|
|
38325
38691
|
} else {
|
|
@@ -38327,11 +38693,11 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38327
38693
|
onClose?.();
|
|
38328
38694
|
}
|
|
38329
38695
|
}, [onClose]);
|
|
38330
|
-
const handleClose = (0,
|
|
38696
|
+
const handleClose = (0, import_react50.useCallback)(() => {
|
|
38331
38697
|
setIsOpen(false);
|
|
38332
38698
|
onClose?.();
|
|
38333
38699
|
}, [onClose]);
|
|
38334
|
-
(0,
|
|
38700
|
+
(0, import_react50.useImperativeHandle)(
|
|
38335
38701
|
ref,
|
|
38336
38702
|
() => ({
|
|
38337
38703
|
open,
|