@trustware/sdk-staging 1.1.9-staging.5 → 1.1.9-staging.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -4
- package/README.md +32 -1
- package/THIRD_PARTY_NOTICES.md +118 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-CwT8Wd1x.d.ts → core-DzqVEWwP.d.ts} +3 -2
- package/dist/{core-Dy_rZl5y.d.cts → core-gNyi5xsp.d.cts} +3 -2
- package/dist/core.cjs +287 -75
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +287 -75
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-d2PUaxE_.d.ts → detect-Cprq6X9o.d.ts} +1 -1
- package/dist/{detect-DVpECOTa.d.cts → detect-DWL4uExV.d.cts} +1 -1
- package/dist/index.cjs +685 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +936 -410
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-B5aklGtm.d.cts → manager-DWFNyouP.d.cts} +48 -20
- package/dist/{manager-xFiq0SHr.d.ts → manager-Dn4muk74.d.ts} +48 -20
- package/dist/smart-account.cjs +117 -39
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.mjs +117 -39
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +308 -72
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +6 -4
- package/dist/wallet.d.ts +6 -4
- package/dist/wallet.mjs +306 -72
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +650 -139
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +868 -355
- package/dist/widget.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,31 @@ var init_config = __esm({
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
// src/errors/TrustwareError.ts
|
|
53
|
+
var TrustwareError;
|
|
54
|
+
var init_TrustwareError = __esm({
|
|
55
|
+
"src/errors/TrustwareError.ts"() {
|
|
56
|
+
"use strict";
|
|
57
|
+
TrustwareError = class extends Error {
|
|
58
|
+
constructor(params) {
|
|
59
|
+
super(params.message);
|
|
60
|
+
this.name = "TrustwareError";
|
|
61
|
+
this.code = params.code;
|
|
62
|
+
this.userMessage = params.userMessage;
|
|
63
|
+
this.cause = params.cause;
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return {
|
|
67
|
+
name: this.name,
|
|
68
|
+
code: this.code,
|
|
69
|
+
message: this.message,
|
|
70
|
+
userMessage: this.userMessage
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
52
77
|
// src/config/merge.ts
|
|
53
78
|
function deepMerge(base2, patch) {
|
|
54
79
|
if (!patch) return { ...base2 };
|
|
@@ -69,46 +94,80 @@ function normalizeSlippage(v) {
|
|
|
69
94
|
if (n > 5) return 5;
|
|
70
95
|
return n;
|
|
71
96
|
}
|
|
97
|
+
function warnDeprecatedSwapModeFlag() {
|
|
98
|
+
if (hasWarnedDeprecatedSwapModeFlag) return;
|
|
99
|
+
hasWarnedDeprecatedSwapModeFlag = true;
|
|
100
|
+
console.warn(
|
|
101
|
+
'[Trustware SDK] `features.swapMode` is deprecated \u2014 use `mode: "swap"` on the top-level config instead.'
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function resolveMode(input) {
|
|
105
|
+
if (input.mode === "swap") return "swap";
|
|
106
|
+
if (input.mode === "deposit") return "deposit";
|
|
107
|
+
if (input.features?.swapMode) {
|
|
108
|
+
warnDeprecatedSwapModeFlag();
|
|
109
|
+
return "swap";
|
|
110
|
+
}
|
|
111
|
+
return "deposit";
|
|
112
|
+
}
|
|
72
113
|
function resolveConfig(input) {
|
|
73
114
|
if (!input?.apiKey) {
|
|
74
|
-
throw new
|
|
115
|
+
throw new TrustwareError({
|
|
116
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
117
|
+
message: "TrustwareConfig: 'apiKey' is required.",
|
|
118
|
+
userMessage: "Missing required API key configuration."
|
|
119
|
+
});
|
|
75
120
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
121
|
+
const mode = resolveMode(input);
|
|
122
|
+
if (mode === "deposit" && (!input.routes?.toChain || !input.routes?.toToken)) {
|
|
123
|
+
throw new TrustwareError({
|
|
124
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
125
|
+
message: "TrustwareConfig: 'routes.toChain' and 'routes.toToken' are required in deposit mode.",
|
|
126
|
+
userMessage: "Missing required destination chain/token configuration."
|
|
127
|
+
});
|
|
80
128
|
}
|
|
81
|
-
const toChain = input.routes
|
|
82
|
-
if (input.routes
|
|
129
|
+
const toChain = input.routes?.toChain;
|
|
130
|
+
if (input.routes?.toAddress && toChain) {
|
|
83
131
|
const result = validateAddressForChain(input.routes.toAddress, toChain);
|
|
84
132
|
if (!result.isValid) {
|
|
85
133
|
console.error(`[Trustware SDK] Invalid toAddress: ${result.error}`);
|
|
86
|
-
throw new
|
|
134
|
+
throw new TrustwareError({
|
|
135
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
136
|
+
message: `Invalid toAddress: ${result.error}`,
|
|
137
|
+
userMessage: "The configured destination address is invalid."
|
|
138
|
+
});
|
|
87
139
|
}
|
|
88
140
|
}
|
|
89
|
-
if (input.routes
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
141
|
+
if (input.routes?.fromAddress) {
|
|
142
|
+
const fromChain = input.routes.fromChain ?? toChain;
|
|
143
|
+
if (fromChain) {
|
|
144
|
+
const result = validateAddressForChain(
|
|
145
|
+
input.routes.fromAddress,
|
|
146
|
+
fromChain
|
|
147
|
+
);
|
|
148
|
+
if (!result.isValid) {
|
|
149
|
+
console.error(`[Trustware SDK] Invalid fromAddress: ${result.error}`);
|
|
150
|
+
throw new TrustwareError({
|
|
151
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
152
|
+
message: `Invalid fromAddress: ${result.error}`,
|
|
153
|
+
userMessage: "The configured source address is invalid."
|
|
154
|
+
});
|
|
155
|
+
}
|
|
97
156
|
}
|
|
98
157
|
}
|
|
99
158
|
const autoDetectProvider = typeof input.autoDetectProvider === "boolean" ? input.autoDetectProvider : DEFAULT_AUTO_DETECT_PROVIDER;
|
|
100
159
|
const routes = {
|
|
101
|
-
toChain: input.routes
|
|
102
|
-
toToken: input.routes
|
|
103
|
-
fromToken: input.routes
|
|
104
|
-
fromAddress: input.routes
|
|
105
|
-
fromChain: input.routes
|
|
106
|
-
toAddress: input.routes
|
|
160
|
+
toChain: input.routes?.toChain ?? "",
|
|
161
|
+
toToken: input.routes?.toToken ?? "",
|
|
162
|
+
fromToken: input.routes?.fromToken,
|
|
163
|
+
fromAddress: input.routes?.fromAddress,
|
|
164
|
+
fromChain: input.routes?.fromChain,
|
|
165
|
+
toAddress: input.routes?.toAddress,
|
|
107
166
|
defaultSlippage: normalizeSlippage(
|
|
108
|
-
input.routes
|
|
167
|
+
input.routes?.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
109
168
|
),
|
|
110
169
|
options: {
|
|
111
|
-
...input.routes
|
|
170
|
+
...input.routes?.options
|
|
112
171
|
}
|
|
113
172
|
};
|
|
114
173
|
const theme = input.theme ?? "system";
|
|
@@ -127,13 +186,16 @@ function resolveConfig(input) {
|
|
|
127
186
|
tokensPagination: input.features?.tokensPagination ?? DEFAULT_FEATURE_FLAGS.tokensPagination,
|
|
128
187
|
balanceStreaming: input.features?.balanceStreaming ?? DEFAULT_FEATURE_FLAGS.balanceStreaming,
|
|
129
188
|
shouldAllowGA4: input.features?.shouldAllowGA4 ?? DEFAULT_FEATURE_FLAGS.shouldAllowGA4,
|
|
130
|
-
|
|
189
|
+
// Always mirrors the canonical `mode`, however the caller set it (new `mode` field
|
|
190
|
+
// or the deprecated `features.swapMode` flag).
|
|
191
|
+
swapMode: mode === "swap",
|
|
131
192
|
swapDefaultDestToken: input.features?.swapDefaultDestToken ?? DEFAULT_FEATURE_FLAGS.swapDefaultDestToken,
|
|
132
193
|
swapLockDestToken: input.features?.swapLockDestToken ?? DEFAULT_FEATURE_FLAGS.swapLockDestToken,
|
|
133
194
|
swapAllowedDestTokens: input.features?.swapAllowedDestTokens ?? DEFAULT_FEATURE_FLAGS.swapAllowedDestTokens
|
|
134
195
|
};
|
|
135
196
|
return {
|
|
136
197
|
apiKey: input.apiKey,
|
|
198
|
+
mode,
|
|
137
199
|
routes,
|
|
138
200
|
autoDetectProvider,
|
|
139
201
|
theme,
|
|
@@ -146,12 +208,15 @@ function resolveConfig(input) {
|
|
|
146
208
|
onEvent: input.onEvent
|
|
147
209
|
};
|
|
148
210
|
}
|
|
211
|
+
var hasWarnedDeprecatedSwapModeFlag;
|
|
149
212
|
var init_merge = __esm({
|
|
150
213
|
"src/config/merge.ts"() {
|
|
151
214
|
"use strict";
|
|
152
215
|
init_defaults();
|
|
153
216
|
init_config();
|
|
154
217
|
init_index();
|
|
218
|
+
init_TrustwareError();
|
|
219
|
+
hasWarnedDeprecatedSwapModeFlag = false;
|
|
155
220
|
}
|
|
156
221
|
});
|
|
157
222
|
|
|
@@ -408,7 +473,7 @@ var init_constants = __esm({
|
|
|
408
473
|
"src/constants.ts"() {
|
|
409
474
|
"use strict";
|
|
410
475
|
SDK_NAME = "@trustware/sdk";
|
|
411
|
-
SDK_VERSION = "1.1.9-staging.
|
|
476
|
+
SDK_VERSION = "1.1.9-staging.7";
|
|
412
477
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
413
478
|
GTM_ID = "GTM-TZDGNCXB";
|
|
414
479
|
API_PREFIX = "/api";
|
|
@@ -1013,21 +1078,28 @@ function formatDeepLink(id, currentUrl) {
|
|
|
1013
1078
|
const enc = encodeURIComponent(currentUrl);
|
|
1014
1079
|
switch (id) {
|
|
1015
1080
|
// EVM
|
|
1081
|
+
// MetaMask's dapp browser also exposes its Wallet Standard Solana
|
|
1082
|
+
// provider in the same session, so "metamask-solana" reuses this link.
|
|
1016
1083
|
case "metamask":
|
|
1084
|
+
case "metamask-solana":
|
|
1017
1085
|
return `metamask://dapp/${currentUrl}`;
|
|
1018
1086
|
case "coinbase":
|
|
1019
1087
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
1020
1088
|
case "rainbow":
|
|
1021
|
-
return `rainbow
|
|
1089
|
+
return `https://rainbow.me/dapp?url=${enc}`;
|
|
1022
1090
|
case "trust":
|
|
1023
1091
|
return `https://link.trustwallet.com/open_url?coin_id=60&url=${enc}`;
|
|
1024
1092
|
case "okx":
|
|
1025
1093
|
return `okx://wallet/dapp/url?dappUrl=${enc}`;
|
|
1026
1094
|
// Solana
|
|
1095
|
+
// Phantom is one app with one in-app browser — browsing there injects
|
|
1096
|
+
// both window.ethereum and window.phantom.solana, so "phantom-evm"
|
|
1097
|
+
// reuses the same browse link as "phantom-solana".
|
|
1027
1098
|
case "phantom-solana":
|
|
1028
|
-
|
|
1099
|
+
case "phantom-evm":
|
|
1100
|
+
return `https://phantom.app/ul/browse/${enc}?ref=${enc}`;
|
|
1029
1101
|
case "solflare":
|
|
1030
|
-
return `solflare
|
|
1102
|
+
return `https://solflare.com/ul/v1/browse/${enc}?ref=${enc}`;
|
|
1031
1103
|
case "backpack":
|
|
1032
1104
|
return `https://backpack.app/ul/v1/browse/${enc}?ref=${enc}`;
|
|
1033
1105
|
// No confirmed deep link scheme
|
|
@@ -1137,8 +1209,10 @@ var init_metadata = __esm({
|
|
|
1137
1209
|
homepage: "https://phantom.app/",
|
|
1138
1210
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1139
1211
|
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1140
|
-
detectFlags: ["isPhantom"]
|
|
1141
|
-
//
|
|
1212
|
+
detectFlags: ["isPhantom"],
|
|
1213
|
+
// Same app/in-app browser as "phantom-solana" — browsing there injects
|
|
1214
|
+
// window.ethereum too.
|
|
1215
|
+
deepLink: (url) => formatDeepLink("phantom-evm", url) ?? ""
|
|
1142
1216
|
},
|
|
1143
1217
|
{
|
|
1144
1218
|
id: "phantom-solana",
|
|
@@ -1186,8 +1260,10 @@ var init_metadata = __esm({
|
|
|
1186
1260
|
emoji: "\u{1F98A}",
|
|
1187
1261
|
homepage: "https://metamask.io/",
|
|
1188
1262
|
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
1189
|
-
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
1190
|
-
//
|
|
1263
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
1264
|
+
// Same app/in-app browser as "metamask" — its Wallet Standard Solana
|
|
1265
|
+
// provider is exposed in that same browse session.
|
|
1266
|
+
deepLink: (url) => formatDeepLink("metamask-solana", url) ?? ""
|
|
1191
1267
|
},
|
|
1192
1268
|
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
1193
1269
|
{
|
|
@@ -2381,7 +2457,9 @@ var init_chains = __esm({
|
|
|
2381
2457
|
btc: "bitcoin",
|
|
2382
2458
|
bitcoin: "bitcoin",
|
|
2383
2459
|
sei: "cosmos",
|
|
2384
|
-
"pacific-1": "cosmos"
|
|
2460
|
+
"pacific-1": "cosmos",
|
|
2461
|
+
nibiru: "cosmos",
|
|
2462
|
+
"cataclysm-1": "cosmos"
|
|
2385
2463
|
};
|
|
2386
2464
|
}
|
|
2387
2465
|
});
|
|
@@ -2437,6 +2515,25 @@ function validateSeiAddress(address) {
|
|
|
2437
2515
|
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
2438
2516
|
};
|
|
2439
2517
|
}
|
|
2518
|
+
function resolveCosmosBech32Prefix(chain) {
|
|
2519
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
2520
|
+
const identifier = chainDef?.networkIdentifier ?? chainDef?.chainId ?? chainDef?.id ?? (typeof chain === "string" ? chain : void 0);
|
|
2521
|
+
const normalized = String(identifier ?? "").trim().toLowerCase();
|
|
2522
|
+
return COSMOS_BECH32_PREFIX_BY_CHAIN_ID[normalized] ?? "sei";
|
|
2523
|
+
}
|
|
2524
|
+
function validateCosmosAddress(address, chain) {
|
|
2525
|
+
const trimmed = address.trim();
|
|
2526
|
+
const prefix = resolveCosmosBech32Prefix(chain);
|
|
2527
|
+
if (prefix === "sei" && isEvmAddress(trimmed)) {
|
|
2528
|
+
return { isValid: true };
|
|
2529
|
+
}
|
|
2530
|
+
const result = validateBech32LikeAddress(trimmed, prefix);
|
|
2531
|
+
if (result.isValid) return result;
|
|
2532
|
+
return {
|
|
2533
|
+
isValid: false,
|
|
2534
|
+
error: prefix === "sei" ? "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings." : `Address must be a valid ${prefix}1 bech32 string.`
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2440
2537
|
function validateSolanaAddress(address) {
|
|
2441
2538
|
const trimmed = address.trim();
|
|
2442
2539
|
if (trimmed.startsWith("0x") || isEvmAddress(trimmed)) {
|
|
@@ -2484,15 +2581,12 @@ function validateAddressForChain(address, chain) {
|
|
|
2484
2581
|
case "bitcoin":
|
|
2485
2582
|
return validateBtcAddress(trimmed);
|
|
2486
2583
|
case "cosmos":
|
|
2487
|
-
|
|
2488
|
-
return validateSeiAddress(trimmed);
|
|
2489
|
-
}
|
|
2490
|
-
return validateBech32LikeAddress(trimmed, "sei");
|
|
2584
|
+
return validateCosmosAddress(trimmed, chainDef ?? chain);
|
|
2491
2585
|
default:
|
|
2492
2586
|
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
2493
2587
|
}
|
|
2494
2588
|
}
|
|
2495
|
-
function validateAddressForRouteChain(address, chainType) {
|
|
2589
|
+
function validateAddressForRouteChain(address, chainType, chainRef) {
|
|
2496
2590
|
switch (normalizeChainType(chainType)) {
|
|
2497
2591
|
case "evm":
|
|
2498
2592
|
return validateEvmAddress(address);
|
|
@@ -2501,7 +2595,7 @@ function validateAddressForRouteChain(address, chainType) {
|
|
|
2501
2595
|
case "bitcoin":
|
|
2502
2596
|
return validateBtcAddress(address);
|
|
2503
2597
|
case "cosmos":
|
|
2504
|
-
return
|
|
2598
|
+
return validateCosmosAddress(address, chainRef ?? chainType);
|
|
2505
2599
|
default:
|
|
2506
2600
|
return { isValid: false, error: "Unsupported chain type." };
|
|
2507
2601
|
}
|
|
@@ -2523,14 +2617,18 @@ function validateRouteAddresses(params) {
|
|
|
2523
2617
|
const normalizedDirection = params.direction?.trim().toLowerCase();
|
|
2524
2618
|
const isDepositFlow = normalizedDirection === "deposit" || (toType === "evm" || toType === "cosmos") && (fromType === "bitcoin" || fromType === "solana");
|
|
2525
2619
|
if (isDepositFlow) {
|
|
2526
|
-
const fromResult2 = validateAddressForRouteChain(
|
|
2620
|
+
const fromResult2 = validateAddressForRouteChain(
|
|
2621
|
+
fromAddress,
|
|
2622
|
+
fromType,
|
|
2623
|
+
params.fromChain
|
|
2624
|
+
);
|
|
2527
2625
|
if (!fromResult2.isValid) {
|
|
2528
2626
|
return {
|
|
2529
2627
|
isValid: false,
|
|
2530
2628
|
error: `From address: ${fromResult2.error ?? "Invalid address."}`
|
|
2531
2629
|
};
|
|
2532
2630
|
}
|
|
2533
|
-
const toResult2 = toType === "cosmos" ?
|
|
2631
|
+
const toResult2 = toType === "cosmos" ? validateCosmosAddress(toAddress, params.toChain) : validateEvmAddress(toAddress);
|
|
2534
2632
|
if (!toResult2.isValid) {
|
|
2535
2633
|
return {
|
|
2536
2634
|
isValid: false,
|
|
@@ -2555,14 +2653,22 @@ function validateRouteAddresses(params) {
|
|
|
2555
2653
|
}
|
|
2556
2654
|
return { isValid: true };
|
|
2557
2655
|
}
|
|
2558
|
-
const fromResult = validateAddressForRouteChain(
|
|
2656
|
+
const fromResult = validateAddressForRouteChain(
|
|
2657
|
+
fromAddress,
|
|
2658
|
+
fromType,
|
|
2659
|
+
params.fromChain
|
|
2660
|
+
);
|
|
2559
2661
|
if (!fromResult.isValid) {
|
|
2560
2662
|
return {
|
|
2561
2663
|
isValid: false,
|
|
2562
2664
|
error: `From address: ${fromResult.error ?? "Invalid address."}`
|
|
2563
2665
|
};
|
|
2564
2666
|
}
|
|
2565
|
-
const toResult = validateAddressForRouteChain(
|
|
2667
|
+
const toResult = validateAddressForRouteChain(
|
|
2668
|
+
toAddress,
|
|
2669
|
+
toType,
|
|
2670
|
+
params.toChain
|
|
2671
|
+
);
|
|
2566
2672
|
if (!toResult.isValid) {
|
|
2567
2673
|
return {
|
|
2568
2674
|
isValid: false,
|
|
@@ -2571,13 +2677,19 @@ function validateRouteAddresses(params) {
|
|
|
2571
2677
|
}
|
|
2572
2678
|
return { isValid: true };
|
|
2573
2679
|
}
|
|
2574
|
-
var BECH32_CHARSET;
|
|
2680
|
+
var BECH32_CHARSET, COSMOS_BECH32_PREFIX_BY_CHAIN_ID;
|
|
2575
2681
|
var init_address = __esm({
|
|
2576
2682
|
"src/validation/address.ts"() {
|
|
2577
2683
|
"use strict";
|
|
2578
2684
|
init_index_node4();
|
|
2579
2685
|
init_chains();
|
|
2580
2686
|
BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
2687
|
+
COSMOS_BECH32_PREFIX_BY_CHAIN_ID = {
|
|
2688
|
+
"pacific-1": "sei",
|
|
2689
|
+
sei: "sei",
|
|
2690
|
+
"cataclysm-1": "nibi",
|
|
2691
|
+
nibiru: "nibi"
|
|
2692
|
+
};
|
|
2581
2693
|
}
|
|
2582
2694
|
});
|
|
2583
2695
|
|
|
@@ -2776,7 +2888,7 @@ var init_walletconnect = __esm({
|
|
|
2776
2888
|
solanaMainnet = {
|
|
2777
2889
|
id: 900,
|
|
2778
2890
|
chainNamespace: "solana",
|
|
2779
|
-
caipNetworkId: "solana:
|
|
2891
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
2780
2892
|
name: "Solana Mainnet",
|
|
2781
2893
|
nativeCurrency: {
|
|
2782
2894
|
name: "Solana",
|
|
@@ -3655,8 +3767,62 @@ function getChainMeta(chainId) {
|
|
|
3655
3767
|
rpcUrls: chain.rpcUrls.default.http
|
|
3656
3768
|
};
|
|
3657
3769
|
}
|
|
3658
|
-
|
|
3770
|
+
function extractSolanaAddress(connector) {
|
|
3771
|
+
const caipAccount = connector.provider.session?.namespaces?.solana?.accounts?.[0];
|
|
3772
|
+
if (!caipAccount) return null;
|
|
3773
|
+
return caipAccount.split(":")[2] ?? null;
|
|
3774
|
+
}
|
|
3775
|
+
function buildWalletConnectSolanaProvider(connector) {
|
|
3776
|
+
return {
|
|
3777
|
+
get publicKey() {
|
|
3778
|
+
const address = extractSolanaAddress(connector);
|
|
3779
|
+
return address ? { toString: () => address } : void 0;
|
|
3780
|
+
},
|
|
3781
|
+
async connect() {
|
|
3782
|
+
const address = extractSolanaAddress(connector);
|
|
3783
|
+
if (!address) {
|
|
3784
|
+
throw new Error(
|
|
3785
|
+
"This wallet did not approve a Solana account over WalletConnect."
|
|
3786
|
+
);
|
|
3787
|
+
}
|
|
3788
|
+
return { publicKey: { toString: () => address } };
|
|
3789
|
+
},
|
|
3790
|
+
async disconnect() {
|
|
3791
|
+
},
|
|
3792
|
+
async signTransaction(transaction) {
|
|
3793
|
+
const tx = transaction;
|
|
3794
|
+
const rawBytes = "version" in tx ? tx.serialize() : tx.serialize({
|
|
3795
|
+
requireAllSignatures: false,
|
|
3796
|
+
verifySignatures: false
|
|
3797
|
+
});
|
|
3798
|
+
const result = await connector.provider.request(
|
|
3799
|
+
{
|
|
3800
|
+
method: "solana_signTransaction",
|
|
3801
|
+
params: { transaction: encodeBase64(rawBytes) }
|
|
3802
|
+
},
|
|
3803
|
+
solanaMainnet.caipNetworkId
|
|
3804
|
+
);
|
|
3805
|
+
if (!result.transaction) {
|
|
3806
|
+
throw new Error(
|
|
3807
|
+
"WalletConnect wallet did not return a signed Solana transaction."
|
|
3808
|
+
);
|
|
3809
|
+
}
|
|
3810
|
+
const signedBytes = decodeBase64(result.transaction);
|
|
3811
|
+
return { serialize: () => signedBytes };
|
|
3812
|
+
},
|
|
3813
|
+
on() {
|
|
3814
|
+
},
|
|
3815
|
+
off() {
|
|
3816
|
+
},
|
|
3817
|
+
removeListener() {
|
|
3818
|
+
}
|
|
3819
|
+
};
|
|
3820
|
+
}
|
|
3821
|
+
async function buildWalletConnectAPI(walletCfg, ecosystem = "evm") {
|
|
3659
3822
|
const connector = await getUniversalConnector(walletCfg);
|
|
3823
|
+
if (ecosystem === "solana") {
|
|
3824
|
+
return toSolanaWalletInterface(buildWalletConnectSolanaProvider(connector));
|
|
3825
|
+
}
|
|
3660
3826
|
const provider = connector.provider;
|
|
3661
3827
|
const api = {
|
|
3662
3828
|
ecosystem: "evm",
|
|
@@ -3732,7 +3898,7 @@ function useWireDetectionIntoManager() {
|
|
|
3732
3898
|
function useWalletConnectConnect(walletCfg) {
|
|
3733
3899
|
const cfgRef = { current: walletCfg };
|
|
3734
3900
|
return useCallback(
|
|
3735
|
-
() => walletManager.connectWalletConnect(cfgRef.current),
|
|
3901
|
+
(ecosystem) => walletManager.connectWalletConnect(cfgRef.current, ecosystem),
|
|
3736
3902
|
[]
|
|
3737
3903
|
);
|
|
3738
3904
|
}
|
|
@@ -3752,6 +3918,7 @@ function useWalletInfo(wagmi) {
|
|
|
3752
3918
|
connectedVia: snapshot.connectedVia,
|
|
3753
3919
|
walletType: snapshot.walletType,
|
|
3754
3920
|
status: snapshot.status,
|
|
3921
|
+
detected: snapshot.detected,
|
|
3755
3922
|
disconnect
|
|
3756
3923
|
};
|
|
3757
3924
|
}
|
|
@@ -3903,44 +4070,39 @@ var init_manager = __esm({
|
|
|
3903
4070
|
this.emit();
|
|
3904
4071
|
}
|
|
3905
4072
|
}
|
|
3906
|
-
async connectWalletConnect(walletCfg) {
|
|
3907
|
-
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet) {
|
|
4073
|
+
async connectWalletConnect(walletCfg, ecosystem = "evm") {
|
|
4074
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet && this._wallet.ecosystem === ecosystem) {
|
|
3908
4075
|
this.emit();
|
|
3909
4076
|
return { error: null, api: this._wallet };
|
|
3910
4077
|
}
|
|
4078
|
+
if (this._connectedVia === "walletconnect" && this._wallet) {
|
|
4079
|
+
await this._wallet.disconnect?.().catch(() => {
|
|
4080
|
+
});
|
|
4081
|
+
resetUniversalConnector();
|
|
4082
|
+
}
|
|
3911
4083
|
this._status = "connecting";
|
|
3912
4084
|
this.clearConnectedState();
|
|
3913
4085
|
this.emit();
|
|
3914
4086
|
try {
|
|
3915
4087
|
const connector = await getUniversalConnector(walletCfg);
|
|
3916
4088
|
await connector.connect();
|
|
3917
|
-
const api = await buildWalletConnectAPI(walletCfg);
|
|
4089
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
4090
|
+
try {
|
|
4091
|
+
await api.getAddress();
|
|
4092
|
+
} catch {
|
|
4093
|
+
await api.disconnect?.().catch(() => {
|
|
4094
|
+
});
|
|
4095
|
+
resetUniversalConnector();
|
|
4096
|
+
throw new Error(
|
|
4097
|
+
`This wallet did not approve a${ecosystem === "evm" ? "n" : ""} ${ecosystem === "evm" ? "EVM" : "Solana"} account over WalletConnect.`
|
|
4098
|
+
);
|
|
4099
|
+
}
|
|
3918
4100
|
this._wallet = api;
|
|
3919
4101
|
this._connectedVia = "walletconnect";
|
|
3920
4102
|
this._connectedWalletId = "walletconnect";
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
if (accounts.length === 0) {
|
|
3925
|
-
this.fullReset();
|
|
3926
|
-
this.triggerExternalDisconnect();
|
|
3927
|
-
this.emit();
|
|
3928
|
-
return;
|
|
3929
|
-
}
|
|
3930
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3931
|
-
this.emit();
|
|
3932
|
-
},
|
|
3933
|
-
onChainChanged: () => {
|
|
3934
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3935
|
-
this.emit();
|
|
3936
|
-
},
|
|
3937
|
-
onDisconnect: () => {
|
|
3938
|
-
this.fullReset();
|
|
3939
|
-
resetUniversalConnector();
|
|
3940
|
-
this.triggerExternalDisconnect();
|
|
3941
|
-
this.emit();
|
|
3942
|
-
}
|
|
3943
|
-
});
|
|
4103
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
4104
|
+
connector.provider
|
|
4105
|
+
);
|
|
3944
4106
|
await this.syncIdentityFromWallet("walletconnect");
|
|
3945
4107
|
this._status = "connected";
|
|
3946
4108
|
this._error = null;
|
|
@@ -3955,6 +4117,100 @@ var init_manager = __esm({
|
|
|
3955
4117
|
return { error: message, api: null };
|
|
3956
4118
|
}
|
|
3957
4119
|
}
|
|
4120
|
+
bindWalletConnectProviderEvents(provider) {
|
|
4121
|
+
return bindWalletConnectEvents(provider, {
|
|
4122
|
+
onAccountsChanged: (accounts) => {
|
|
4123
|
+
if (accounts.length === 0) {
|
|
4124
|
+
this.fullReset();
|
|
4125
|
+
this.triggerExternalDisconnect();
|
|
4126
|
+
this.emit();
|
|
4127
|
+
return;
|
|
4128
|
+
}
|
|
4129
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
4130
|
+
this.emit();
|
|
4131
|
+
},
|
|
4132
|
+
onChainChanged: () => {
|
|
4133
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
4134
|
+
this.emit();
|
|
4135
|
+
},
|
|
4136
|
+
onDisconnect: () => {
|
|
4137
|
+
this.fullReset();
|
|
4138
|
+
resetUniversalConnector();
|
|
4139
|
+
this.triggerExternalDisconnect();
|
|
4140
|
+
this.emit();
|
|
4141
|
+
}
|
|
4142
|
+
});
|
|
4143
|
+
}
|
|
4144
|
+
// WalletConnect's own SignClient auto-restores the last persisted session
|
|
4145
|
+
// from storage on every init — including after a fresh page load — but
|
|
4146
|
+
// that restoration happens silently inside the library. Nothing calls back
|
|
4147
|
+
// into our code for it. On mobile, backgrounding the tab to approve in a
|
|
4148
|
+
// wallet app can cause the OS to reload the page before the original
|
|
4149
|
+
// connect() promise ever resolves, so the connect flow that triggered the
|
|
4150
|
+
// approval never gets to record it as "connected" here — even though
|
|
4151
|
+
// WalletConnect itself already has a live, approved session sitting in
|
|
4152
|
+
// storage. Call this on mount to pick that back up.
|
|
4153
|
+
async restoreWalletConnectSession(walletCfg) {
|
|
4154
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect") {
|
|
4155
|
+
return this._wallet?.ecosystem === "solana" ? "solana" : "evm";
|
|
4156
|
+
}
|
|
4157
|
+
if (typeof window === "undefined") return null;
|
|
4158
|
+
try {
|
|
4159
|
+
if (!Object.keys(window.localStorage).some((key) => key.startsWith("wc@2"))) {
|
|
4160
|
+
return null;
|
|
4161
|
+
}
|
|
4162
|
+
} catch {
|
|
4163
|
+
}
|
|
4164
|
+
let connector;
|
|
4165
|
+
try {
|
|
4166
|
+
connector = await getUniversalConnector(walletCfg);
|
|
4167
|
+
} catch (e2) {
|
|
4168
|
+
console.warn(
|
|
4169
|
+
"[Trustware SDK] Failed to restore WalletConnect session:",
|
|
4170
|
+
e2
|
|
4171
|
+
);
|
|
4172
|
+
return null;
|
|
4173
|
+
}
|
|
4174
|
+
const session = connector.provider.session;
|
|
4175
|
+
if (!session) return null;
|
|
4176
|
+
const ecosystem = session.namespaces?.solana?.accounts?.length ? "solana" : session.namespaces?.eip155?.accounts?.length ? "evm" : null;
|
|
4177
|
+
if (!ecosystem) return null;
|
|
4178
|
+
try {
|
|
4179
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
4180
|
+
this._wallet = api;
|
|
4181
|
+
this._connectedVia = "walletconnect";
|
|
4182
|
+
this._connectedWalletId = "walletconnect";
|
|
4183
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
4184
|
+
connector.provider
|
|
4185
|
+
);
|
|
4186
|
+
await this.syncIdentityFromWallet("walletconnect");
|
|
4187
|
+
this._status = "connected";
|
|
4188
|
+
this._error = null;
|
|
4189
|
+
this.emit();
|
|
4190
|
+
return ecosystem;
|
|
4191
|
+
} catch {
|
|
4192
|
+
return null;
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
// Forcibly abandon an in-progress connect() call the caller has decided is
|
|
4196
|
+
// stuck (e.g. the UI's own connect timeout elapsed with no response).
|
|
4197
|
+
// There's no clean way to cancel a pending WalletConnect pairing proposal
|
|
4198
|
+
// from this side, so this tears down the whole connector — the next
|
|
4199
|
+
// connect attempt starts against a brand new SignClient/pairing instead of
|
|
4200
|
+
// racing the abandoned one, which would otherwise risk reproducing the
|
|
4201
|
+
// "No matching key. proposal" class of error a real retry needs to avoid.
|
|
4202
|
+
cancelWalletConnectAttempt() {
|
|
4203
|
+
if (this._connectedVia === "walletconnect" && this._status === "connected") {
|
|
4204
|
+
return;
|
|
4205
|
+
}
|
|
4206
|
+
resetUniversalConnector();
|
|
4207
|
+
if (this._status === "connecting") {
|
|
4208
|
+
this.clearConnectedState();
|
|
4209
|
+
this._status = "idle";
|
|
4210
|
+
this._error = null;
|
|
4211
|
+
this.emit();
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
3958
4214
|
async disconnect(wagmi) {
|
|
3959
4215
|
if (wagmi && this._connectedVia === "extension") {
|
|
3960
4216
|
await wagmi.disconnect().catch(() => {
|
|
@@ -4197,7 +4453,7 @@ async function buildDepositAddress(body, signal) {
|
|
|
4197
4453
|
route
|
|
4198
4454
|
};
|
|
4199
4455
|
}
|
|
4200
|
-
async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
4456
|
+
async function submitReceipt(intentId, txHash, sponsorshipRequestId, eoaAddress) {
|
|
4201
4457
|
const r = await rateLimitedFetch(
|
|
4202
4458
|
`${apiBase()}/v1/route-intent/${intentId}/receipt`,
|
|
4203
4459
|
{
|
|
@@ -4205,7 +4461,8 @@ async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
|
4205
4461
|
headers: jsonHeaders({ "Idempotency-Key": txHash }),
|
|
4206
4462
|
body: JSON.stringify({
|
|
4207
4463
|
txHash,
|
|
4208
|
-
...sponsorshipRequestId ? { sponsorshipRequestId } : {}
|
|
4464
|
+
...sponsorshipRequestId ? { sponsorshipRequestId } : {},
|
|
4465
|
+
...eoaAddress ? { eoaAddress } : {}
|
|
4209
4466
|
})
|
|
4210
4467
|
}
|
|
4211
4468
|
);
|
|
@@ -5163,7 +5420,9 @@ var init_chainHelpers = __esm({
|
|
|
5163
5420
|
btc: "bitcoin",
|
|
5164
5421
|
bitcoin: "bitcoin",
|
|
5165
5422
|
sei: "cosmos",
|
|
5166
|
-
"pacific-1": "cosmos"
|
|
5423
|
+
"pacific-1": "cosmos",
|
|
5424
|
+
nibiru: "cosmos",
|
|
5425
|
+
"cataclysm-1": "cosmos"
|
|
5167
5426
|
};
|
|
5168
5427
|
SEI_EVM_CHAIN_ID = "1329";
|
|
5169
5428
|
SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
@@ -5379,7 +5638,8 @@ function filterSupportedChains(chains) {
|
|
|
5379
5638
|
}
|
|
5380
5639
|
if (chainType === "cosmos") {
|
|
5381
5640
|
const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
|
|
5382
|
-
|
|
5641
|
+
const isNibiru = normalizeChainKey2(chain.chainId ?? chain.id) === NIBIRU_COSMOS_CHAIN_ID;
|
|
5642
|
+
if (seiKey !== "sei" && !isNibiru) {
|
|
5383
5643
|
return false;
|
|
5384
5644
|
}
|
|
5385
5645
|
}
|
|
@@ -5479,7 +5739,7 @@ function useChains() {
|
|
|
5479
5739
|
error
|
|
5480
5740
|
};
|
|
5481
5741
|
}
|
|
5482
|
-
var POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT;
|
|
5742
|
+
var POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT, NIBIRU_COSMOS_CHAIN_ID;
|
|
5483
5743
|
var init_useChains = __esm({
|
|
5484
5744
|
"src/core/useChains.ts"() {
|
|
5485
5745
|
"use strict";
|
|
@@ -5489,6 +5749,7 @@ var init_useChains = __esm({
|
|
|
5489
5749
|
init_popularChains();
|
|
5490
5750
|
POPULAR_CHAINS_BY_TVL = popularChains_default.byTvl;
|
|
5491
5751
|
POPULAR_LIMIT = popularChains_default.popularLimit;
|
|
5752
|
+
NIBIRU_COSMOS_CHAIN_ID = "cataclysm-1";
|
|
5492
5753
|
}
|
|
5493
5754
|
});
|
|
5494
5755
|
|
|
@@ -7169,31 +7430,6 @@ var init_useTokens = __esm({
|
|
|
7169
7430
|
}
|
|
7170
7431
|
});
|
|
7171
7432
|
|
|
7172
|
-
// src/errors/TrustwareError.ts
|
|
7173
|
-
var TrustwareError;
|
|
7174
|
-
var init_TrustwareError = __esm({
|
|
7175
|
-
"src/errors/TrustwareError.ts"() {
|
|
7176
|
-
"use strict";
|
|
7177
|
-
TrustwareError = class extends Error {
|
|
7178
|
-
constructor(params) {
|
|
7179
|
-
super(params.message);
|
|
7180
|
-
this.name = "TrustwareError";
|
|
7181
|
-
this.code = params.code;
|
|
7182
|
-
this.userMessage = params.userMessage;
|
|
7183
|
-
this.cause = params.cause;
|
|
7184
|
-
}
|
|
7185
|
-
toJSON() {
|
|
7186
|
-
return {
|
|
7187
|
-
name: this.name,
|
|
7188
|
-
code: this.code,
|
|
7189
|
-
message: this.message,
|
|
7190
|
-
userMessage: this.userMessage
|
|
7191
|
-
};
|
|
7192
|
-
}
|
|
7193
|
-
};
|
|
7194
|
-
}
|
|
7195
|
-
});
|
|
7196
|
-
|
|
7197
7433
|
// src/core/index.ts
|
|
7198
7434
|
var _lastValidatedKey, Trustware;
|
|
7199
7435
|
var init_core = __esm({
|
|
@@ -7654,15 +7890,74 @@ var init_useWalletSessionState = __esm({
|
|
|
7654
7890
|
});
|
|
7655
7891
|
|
|
7656
7892
|
// src/widget/state/deposit/useWalletConnect.ts
|
|
7657
|
-
import { useCallback as useCallback6 } from "react";
|
|
7893
|
+
import { useCallback as useCallback6, useEffect as useEffect8, useRef, useState as useState8 } from "react";
|
|
7658
7894
|
function useWalletConnect({
|
|
7659
7895
|
setWalletType,
|
|
7660
|
-
setCurrentStep
|
|
7896
|
+
setCurrentStep,
|
|
7897
|
+
selectedNamespace,
|
|
7898
|
+
setSelectedNamespace
|
|
7661
7899
|
}) {
|
|
7662
7900
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
7663
7901
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
7902
|
+
const ecosystem = selectedNamespace.trim().toLowerCase() === "solana" ? "solana" : "evm";
|
|
7903
|
+
const [wcStatus, setWcStatus] = useState8("idle");
|
|
7904
|
+
const [wcErrorMessage, setWcErrorMessage] = useState8(null);
|
|
7905
|
+
const wcTimeoutRef = useRef(null);
|
|
7906
|
+
const clearWcTimeout = useCallback6(() => {
|
|
7907
|
+
if (wcTimeoutRef.current !== null) {
|
|
7908
|
+
clearTimeout(wcTimeoutRef.current);
|
|
7909
|
+
wcTimeoutRef.current = null;
|
|
7910
|
+
}
|
|
7911
|
+
}, []);
|
|
7912
|
+
const beginWcAttempt = useCallback6(() => {
|
|
7913
|
+
setWcStatus("connecting");
|
|
7914
|
+
setWcErrorMessage(null);
|
|
7915
|
+
clearWcTimeout();
|
|
7916
|
+
wcTimeoutRef.current = setTimeout(() => {
|
|
7917
|
+
wcTimeoutRef.current = null;
|
|
7918
|
+
setWcStatus((prev) => prev === "connecting" ? "timedOut" : prev);
|
|
7919
|
+
}, WC_CONNECT_TIMEOUT_MS);
|
|
7920
|
+
}, [clearWcTimeout]);
|
|
7921
|
+
const resolveWcAttempt = useCallback6(() => {
|
|
7922
|
+
clearWcTimeout();
|
|
7923
|
+
setWcStatus("idle");
|
|
7924
|
+
setWcErrorMessage(null);
|
|
7925
|
+
}, [clearWcTimeout]);
|
|
7926
|
+
const failWcAttempt = useCallback6(
|
|
7927
|
+
(message) => {
|
|
7928
|
+
clearWcTimeout();
|
|
7929
|
+
setWcStatus("failed");
|
|
7930
|
+
setWcErrorMessage(message);
|
|
7931
|
+
},
|
|
7932
|
+
[clearWcTimeout]
|
|
7933
|
+
);
|
|
7934
|
+
const dismissWcStatus = useCallback6(() => {
|
|
7935
|
+
clearWcTimeout();
|
|
7936
|
+
setWcStatus("idle");
|
|
7937
|
+
setWcErrorMessage(null);
|
|
7938
|
+
}, [clearWcTimeout]);
|
|
7939
|
+
useEffect8(() => clearWcTimeout, [clearWcTimeout]);
|
|
7940
|
+
useEffect8(() => {
|
|
7941
|
+
let cancelled = false;
|
|
7942
|
+
beginWcAttempt();
|
|
7943
|
+
void (async () => {
|
|
7944
|
+
const restoredEcosystem = await walletManager.restoreWalletConnectSession(walletConnectCfg);
|
|
7945
|
+
if (cancelled) return;
|
|
7946
|
+
resolveWcAttempt();
|
|
7947
|
+
if (!restoredEcosystem) return;
|
|
7948
|
+
setWalletType("walletconnect");
|
|
7949
|
+
if (restoredEcosystem === "solana") {
|
|
7950
|
+
setSelectedNamespace("Solana");
|
|
7951
|
+
}
|
|
7952
|
+
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
7953
|
+
if (address) setCurrentStep("crypto-pay");
|
|
7954
|
+
})();
|
|
7955
|
+
return () => {
|
|
7956
|
+
cancelled = true;
|
|
7957
|
+
};
|
|
7958
|
+
}, []);
|
|
7664
7959
|
const WalletConnect = useCallback6(async () => {
|
|
7665
|
-
if (walletManager.status === "connected" && walletManager.connectedVia === "walletconnect") {
|
|
7960
|
+
if (walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" && walletManager.wallet?.ecosystem === ecosystem) {
|
|
7666
7961
|
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
7667
7962
|
if (address) {
|
|
7668
7963
|
setWalletType("walletconnect");
|
|
@@ -7671,45 +7966,72 @@ function useWalletConnect({
|
|
|
7671
7966
|
}
|
|
7672
7967
|
}
|
|
7673
7968
|
setWalletType("walletconnect");
|
|
7674
|
-
|
|
7969
|
+
beginWcAttempt();
|
|
7970
|
+
const { error } = await connectWC(ecosystem);
|
|
7675
7971
|
if (!error) {
|
|
7676
7972
|
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
7677
7973
|
if (address) {
|
|
7974
|
+
resolveWcAttempt();
|
|
7678
7975
|
setCurrentStep("crypto-pay");
|
|
7976
|
+
} else {
|
|
7977
|
+
const message = `WalletConnect session established but no address resolved for ecosystem "${ecosystem}".`;
|
|
7978
|
+
console.error(`[Trustware SDK] ${message}`);
|
|
7979
|
+
failWcAttempt(message);
|
|
7679
7980
|
}
|
|
7680
7981
|
} else {
|
|
7982
|
+
console.error("[Trustware SDK] WalletConnect connection failed:", error);
|
|
7983
|
+
failWcAttempt(error);
|
|
7681
7984
|
setWalletType("other");
|
|
7682
7985
|
}
|
|
7683
|
-
}, [
|
|
7986
|
+
}, [
|
|
7987
|
+
beginWcAttempt,
|
|
7988
|
+
connectWC,
|
|
7989
|
+
ecosystem,
|
|
7990
|
+
failWcAttempt,
|
|
7991
|
+
resolveWcAttempt,
|
|
7992
|
+
setCurrentStep,
|
|
7993
|
+
setWalletType
|
|
7994
|
+
]);
|
|
7995
|
+
const retryWalletConnect = useCallback6(() => {
|
|
7996
|
+
walletManager.cancelWalletConnectAttempt();
|
|
7997
|
+
void WalletConnect();
|
|
7998
|
+
}, [WalletConnect]);
|
|
7684
7999
|
const disconnectWalletConnect = useCallback6(async () => {
|
|
7685
8000
|
await walletManager.disconnect();
|
|
7686
8001
|
setWalletType("other");
|
|
7687
8002
|
setCurrentStep("home");
|
|
7688
8003
|
}, [setCurrentStep, setWalletType]);
|
|
7689
|
-
const walletConnectAddress = walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" ? walletManager.
|
|
8004
|
+
const walletConnectAddress = walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" ? walletManager.identity?.addresses[0]?.address ?? null : null;
|
|
7690
8005
|
return {
|
|
7691
8006
|
walletConnectAddress,
|
|
7692
8007
|
WalletConnect,
|
|
7693
|
-
disconnectWalletConnect
|
|
8008
|
+
disconnectWalletConnect,
|
|
8009
|
+
wcStatus,
|
|
8010
|
+
wcErrorMessage,
|
|
8011
|
+
retryWalletConnect,
|
|
8012
|
+
dismissWcStatus
|
|
7694
8013
|
};
|
|
7695
8014
|
}
|
|
8015
|
+
var WC_CONNECT_TIMEOUT_MS;
|
|
7696
8016
|
var init_useWalletConnect = __esm({
|
|
7697
8017
|
"src/widget/state/deposit/useWalletConnect.ts"() {
|
|
7698
8018
|
"use strict";
|
|
7699
8019
|
init_config2();
|
|
7700
8020
|
init_wallets();
|
|
8021
|
+
WC_CONNECT_TIMEOUT_MS = 3e4;
|
|
7701
8022
|
}
|
|
7702
8023
|
});
|
|
7703
8024
|
|
|
7704
8025
|
// src/hooks/useTrustwareConfig.ts
|
|
7705
|
-
import { useEffect as
|
|
8026
|
+
import { useEffect as useEffect9, useState as useState9 } from "react";
|
|
7706
8027
|
function useTrustwareConfig() {
|
|
7707
|
-
const [cfg, setCfg] =
|
|
8028
|
+
const [cfg, setCfg] = useState9(() => {
|
|
7708
8029
|
try {
|
|
7709
8030
|
return TrustwareConfigStore.get();
|
|
7710
8031
|
} catch {
|
|
7711
8032
|
return {
|
|
7712
8033
|
apiKey: "",
|
|
8034
|
+
mode: "deposit",
|
|
7713
8035
|
routes: {
|
|
7714
8036
|
toChain: "",
|
|
7715
8037
|
toToken: "",
|
|
@@ -7741,7 +8063,7 @@ function useTrustwareConfig() {
|
|
|
7741
8063
|
};
|
|
7742
8064
|
}
|
|
7743
8065
|
});
|
|
7744
|
-
|
|
8066
|
+
useEffect9(() => {
|
|
7745
8067
|
const unsubscribe = TrustwareConfigStore.subscribe(setCfg);
|
|
7746
8068
|
return () => {
|
|
7747
8069
|
unsubscribe();
|
|
@@ -7758,7 +8080,7 @@ var init_useTrustwareConfig = __esm({
|
|
|
7758
8080
|
});
|
|
7759
8081
|
|
|
7760
8082
|
// src/widget/context/DepositContext.tsx
|
|
7761
|
-
import React2, { createContext as createContext2, useContext as useContext2, useState as
|
|
8083
|
+
import React2, { createContext as createContext2, useContext as useContext2, useState as useState10, useMemo as useMemo5 } from "react";
|
|
7762
8084
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
7763
8085
|
function DepositProvider({
|
|
7764
8086
|
children,
|
|
@@ -7783,20 +8105,30 @@ function DepositProvider({
|
|
|
7783
8105
|
connectWallet,
|
|
7784
8106
|
disconnectWallet
|
|
7785
8107
|
} = useWalletSessionState();
|
|
7786
|
-
const [amountInputMode, setAmountInputMode] =
|
|
8108
|
+
const [amountInputMode, setAmountInputMode] = useState10(
|
|
7787
8109
|
"usd"
|
|
7788
8110
|
);
|
|
7789
|
-
const [walletType, setWalletType] =
|
|
8111
|
+
const [walletType, setWalletType] = useState10(
|
|
7790
8112
|
"other"
|
|
7791
8113
|
);
|
|
7792
|
-
const
|
|
8114
|
+
const [selectedNamespace, setSelectedNamespace] = useState10("evm");
|
|
8115
|
+
const {
|
|
8116
|
+
walletConnectAddress,
|
|
8117
|
+
WalletConnect,
|
|
8118
|
+
disconnectWalletConnect,
|
|
8119
|
+
wcStatus,
|
|
8120
|
+
wcErrorMessage,
|
|
8121
|
+
retryWalletConnect,
|
|
8122
|
+
dismissWcStatus
|
|
8123
|
+
} = useWalletConnect({
|
|
7793
8124
|
setWalletType,
|
|
7794
|
-
setCurrentStep
|
|
8125
|
+
setCurrentStep,
|
|
8126
|
+
selectedNamespace,
|
|
8127
|
+
setSelectedNamespace
|
|
7795
8128
|
});
|
|
7796
|
-
const [selectedToken, setSelectedToken] =
|
|
7797
|
-
const [selectedChain, setSelectedChain] =
|
|
7798
|
-
const [amount, setAmount] =
|
|
7799
|
-
const [selectedNamespace, setSelectedNamespace] = useState9("evm");
|
|
8129
|
+
const [selectedToken, setSelectedToken] = useState10(null);
|
|
8130
|
+
const [selectedChain, setSelectedChain] = useState10(null);
|
|
8131
|
+
const [amount, setAmount] = useState10("");
|
|
7800
8132
|
const walletAddress = useMemo5(
|
|
7801
8133
|
() => walletType === "walletconnect" ? walletConnectAddress : otherWalletAddress,
|
|
7802
8134
|
[walletType, walletConnectAddress, otherWalletAddress]
|
|
@@ -7814,11 +8146,11 @@ function DepositProvider({
|
|
|
7814
8146
|
selectedToken,
|
|
7815
8147
|
setSelectedToken
|
|
7816
8148
|
});
|
|
7817
|
-
const [transactionStatus, setTransactionStatus] =
|
|
7818
|
-
const [transactionHash, setTransactionHash] =
|
|
7819
|
-
const [errorMessage, setErrorMessage] =
|
|
7820
|
-
const [intentId, setIntentId] =
|
|
7821
|
-
const [paymentMethod, setPaymentMethod] =
|
|
8149
|
+
const [transactionStatus, setTransactionStatus] = useState10("idle");
|
|
8150
|
+
const [transactionHash, setTransactionHash] = useState10(null);
|
|
8151
|
+
const [errorMessage, setErrorMessage] = useState10(null);
|
|
8152
|
+
const [intentId, setIntentId] = useState10(null);
|
|
8153
|
+
const [paymentMethod, setPaymentMethod] = useState10("crypto");
|
|
7822
8154
|
const resetState = React2.useCallback(() => {
|
|
7823
8155
|
resetNavigation();
|
|
7824
8156
|
setSelectedToken(null);
|
|
@@ -7868,7 +8200,11 @@ function DepositProvider({
|
|
|
7868
8200
|
setWalletType,
|
|
7869
8201
|
walletType,
|
|
7870
8202
|
selectedNamespace,
|
|
7871
|
-
setSelectedNamespace
|
|
8203
|
+
setSelectedNamespace,
|
|
8204
|
+
wcStatus,
|
|
8205
|
+
wcErrorMessage,
|
|
8206
|
+
retryWalletConnect,
|
|
8207
|
+
dismissWcStatus
|
|
7872
8208
|
}),
|
|
7873
8209
|
[
|
|
7874
8210
|
WalletConnect,
|
|
@@ -7884,7 +8220,11 @@ function DepositProvider({
|
|
|
7884
8220
|
yourWalletTokens,
|
|
7885
8221
|
yourWalletTokensLoading,
|
|
7886
8222
|
selectedNamespace,
|
|
7887
|
-
setSelectedNamespace
|
|
8223
|
+
setSelectedNamespace,
|
|
8224
|
+
wcStatus,
|
|
8225
|
+
wcErrorMessage,
|
|
8226
|
+
retryWalletConnect,
|
|
8227
|
+
dismissWcStatus
|
|
7888
8228
|
]
|
|
7889
8229
|
);
|
|
7890
8230
|
const formValue = useMemo5(
|
|
@@ -7987,7 +8327,7 @@ var init_DepositContext = __esm({
|
|
|
7987
8327
|
});
|
|
7988
8328
|
|
|
7989
8329
|
// src/widget/hooks/useRouteBuilder.ts
|
|
7990
|
-
import { useEffect as
|
|
8330
|
+
import { useEffect as useEffect10, useMemo as useMemo6, useRef as useRef2, useState as useState11 } from "react";
|
|
7991
8331
|
function useRouteBuilder({
|
|
7992
8332
|
enabled = true,
|
|
7993
8333
|
debounceMs = 300,
|
|
@@ -8008,7 +8348,7 @@ function useRouteBuilder({
|
|
|
8008
8348
|
const { selectedToken, selectedChain, amount } = useDepositForm();
|
|
8009
8349
|
const { walletAddress } = useDepositWallet();
|
|
8010
8350
|
const { errorMessage } = useDepositTransaction();
|
|
8011
|
-
const [state, setState] =
|
|
8351
|
+
const [state, setState] = useState11({
|
|
8012
8352
|
isLoadingRoute: false,
|
|
8013
8353
|
networkFees: null,
|
|
8014
8354
|
estimatedReceive: null,
|
|
@@ -8016,8 +8356,8 @@ function useRouteBuilder({
|
|
|
8016
8356
|
intentId: null,
|
|
8017
8357
|
routeResult: null
|
|
8018
8358
|
});
|
|
8019
|
-
const abortRef =
|
|
8020
|
-
const [refreshTick, setRefreshTick] =
|
|
8359
|
+
const abortRef = useRef2(null);
|
|
8360
|
+
const [refreshTick, setRefreshTick] = useState11(0);
|
|
8021
8361
|
const routeKey = useMemo6(() => {
|
|
8022
8362
|
if (!enabled || !selectedToken || !selectedChain || !amount || !walletAddress) {
|
|
8023
8363
|
return null;
|
|
@@ -8058,7 +8398,7 @@ function useRouteBuilder({
|
|
|
8058
8398
|
]);
|
|
8059
8399
|
const hasFromChainId = fromChainId !== void 0 && fromChainId !== null && String(fromChainId).trim() !== "";
|
|
8060
8400
|
const hasToChainId = toChainId !== void 0 && toChainId !== null && String(toChainId).trim() !== "";
|
|
8061
|
-
|
|
8401
|
+
useEffect10(() => {
|
|
8062
8402
|
if (!fromChain || !hasFromChainId || !hasToChainId || !fromToken || !toToken || !fromAmountWei || !fromAddress || !toAddress)
|
|
8063
8403
|
return;
|
|
8064
8404
|
abortRef.current?.abort();
|
|
@@ -8194,7 +8534,7 @@ function useRouteBuilder({
|
|
|
8194
8534
|
walletAddress,
|
|
8195
8535
|
errorMessage
|
|
8196
8536
|
]);
|
|
8197
|
-
|
|
8537
|
+
useEffect10(() => {
|
|
8198
8538
|
if (!enabled || !routeKey || !refreshMs || refreshMs <= 0) return;
|
|
8199
8539
|
const id = setInterval(() => {
|
|
8200
8540
|
setRefreshTick((tick) => tick + 1);
|
|
@@ -8317,7 +8657,7 @@ var init_useAmountConstraints = __esm({
|
|
|
8317
8657
|
});
|
|
8318
8658
|
|
|
8319
8659
|
// src/widget/hooks/useTransactionSubmit.ts
|
|
8320
|
-
import { useCallback as useCallback7, useState as
|
|
8660
|
+
import { useCallback as useCallback7, useState as useState12 } from "react";
|
|
8321
8661
|
function useTransactionSubmit() {
|
|
8322
8662
|
const { selectedChain } = useDepositForm();
|
|
8323
8663
|
const { setCurrentStep } = useDepositNavigation();
|
|
@@ -8327,7 +8667,7 @@ function useTransactionSubmit() {
|
|
|
8327
8667
|
setErrorMessage,
|
|
8328
8668
|
setIntentId
|
|
8329
8669
|
} = useDepositTransaction();
|
|
8330
|
-
const [state, setState] =
|
|
8670
|
+
const [state, setState] = useState12({
|
|
8331
8671
|
isSubmitting: false,
|
|
8332
8672
|
txHash: null,
|
|
8333
8673
|
error: null
|
|
@@ -8461,10 +8801,10 @@ var init_useTransactionSubmit = __esm({
|
|
|
8461
8801
|
});
|
|
8462
8802
|
|
|
8463
8803
|
// src/hooks/useGTM.ts
|
|
8464
|
-
import { useEffect as
|
|
8804
|
+
import { useEffect as useEffect11, useRef as useRef3, useCallback as useCallback8 } from "react";
|
|
8465
8805
|
function useGTM(gtmId) {
|
|
8466
|
-
const isInitialized =
|
|
8467
|
-
const scriptRef =
|
|
8806
|
+
const isInitialized = useRef3(false);
|
|
8807
|
+
const scriptRef = useRef3(null);
|
|
8468
8808
|
const isGA4Allowed = useCallback8(() => {
|
|
8469
8809
|
try {
|
|
8470
8810
|
return Trustware.getConfig().features.shouldAllowGA4;
|
|
@@ -8472,7 +8812,7 @@ function useGTM(gtmId) {
|
|
|
8472
8812
|
return false;
|
|
8473
8813
|
}
|
|
8474
8814
|
}, []);
|
|
8475
|
-
|
|
8815
|
+
useEffect11(() => {
|
|
8476
8816
|
if (!isGA4Allowed()) {
|
|
8477
8817
|
console.warn(
|
|
8478
8818
|
"useGTM: GA4 tracking is disabled or Trustware config not initialized."
|
|
@@ -8610,7 +8950,7 @@ var init_hooks = __esm({
|
|
|
8610
8950
|
});
|
|
8611
8951
|
|
|
8612
8952
|
// src/widget/hooks/useTransactionPolling.ts
|
|
8613
|
-
import { useCallback as useCallback9, useEffect as
|
|
8953
|
+
import { useCallback as useCallback9, useEffect as useEffect12, useRef as useRef4, useState as useState13 } from "react";
|
|
8614
8954
|
function useTransactionPolling() {
|
|
8615
8955
|
const { setCurrentStep } = useDepositNavigation();
|
|
8616
8956
|
const { setTransactionStatus, setErrorMessage } = useDepositTransaction();
|
|
@@ -8624,18 +8964,18 @@ function useTransactionPolling() {
|
|
|
8624
8964
|
}
|
|
8625
8965
|
})();
|
|
8626
8966
|
const { trackEvent } = useGTM(GTM_ID);
|
|
8627
|
-
const [state, setState] =
|
|
8967
|
+
const [state, setState] = useState13({
|
|
8628
8968
|
isPolling: false,
|
|
8629
8969
|
apiStatus: null,
|
|
8630
8970
|
error: null,
|
|
8631
8971
|
transaction: null,
|
|
8632
8972
|
receiptSubmitted: false
|
|
8633
8973
|
});
|
|
8634
|
-
const pollingRef =
|
|
8635
|
-
const timeoutRef =
|
|
8636
|
-
const abortRef =
|
|
8637
|
-
const startTimeRef =
|
|
8638
|
-
const pollCountRef =
|
|
8974
|
+
const pollingRef = useRef4(null);
|
|
8975
|
+
const timeoutRef = useRef4(null);
|
|
8976
|
+
const abortRef = useRef4(false);
|
|
8977
|
+
const startTimeRef = useRef4(0);
|
|
8978
|
+
const pollCountRef = useRef4(0);
|
|
8639
8979
|
const clearPolling = useCallback9(() => {
|
|
8640
8980
|
abortRef.current = true;
|
|
8641
8981
|
if (pollingRef.current) {
|
|
@@ -8793,9 +9133,9 @@ function useTransactionPolling() {
|
|
|
8793
9133
|
receiptSubmitted: false
|
|
8794
9134
|
});
|
|
8795
9135
|
}, [clearPolling]);
|
|
8796
|
-
const clearPollingRef =
|
|
9136
|
+
const clearPollingRef = useRef4(clearPolling);
|
|
8797
9137
|
clearPollingRef.current = clearPolling;
|
|
8798
|
-
|
|
9138
|
+
useEffect12(() => {
|
|
8799
9139
|
return () => {
|
|
8800
9140
|
clearPollingRef.current();
|
|
8801
9141
|
};
|
|
@@ -8884,7 +9224,7 @@ var init_hooks2 = __esm({
|
|
|
8884
9224
|
});
|
|
8885
9225
|
|
|
8886
9226
|
// src/widget/state/deposit/useWalletTokenState.ts
|
|
8887
|
-
import { useCallback as useCallback10, useEffect as
|
|
9227
|
+
import { useCallback as useCallback10, useEffect as useEffect13, useRef as useRef5, useState as useState14 } from "react";
|
|
8888
9228
|
function useWalletTokenState({
|
|
8889
9229
|
walletAddress,
|
|
8890
9230
|
selectedChain,
|
|
@@ -8892,19 +9232,19 @@ function useWalletTokenState({
|
|
|
8892
9232
|
selectedToken,
|
|
8893
9233
|
setSelectedToken
|
|
8894
9234
|
}) {
|
|
8895
|
-
const [yourWalletTokens, setYourWalletTokens] =
|
|
8896
|
-
const [yourWalletTokensLoading, setYourWalletTokensLoading] =
|
|
8897
|
-
const [walletTokensReloadNonce, setWalletTokensReloadNonce] =
|
|
8898
|
-
const lastLoadedWalletRef =
|
|
9235
|
+
const [yourWalletTokens, setYourWalletTokens] = useState14([]);
|
|
9236
|
+
const [yourWalletTokensLoading, setYourWalletTokensLoading] = useState14(false);
|
|
9237
|
+
const [walletTokensReloadNonce, setWalletTokensReloadNonce] = useState14(0);
|
|
9238
|
+
const lastLoadedWalletRef = useRef5(null);
|
|
8899
9239
|
const { tokens } = useTokens(null);
|
|
8900
9240
|
const { chains } = useChains();
|
|
8901
|
-
const selectedChainRef =
|
|
9241
|
+
const selectedChainRef = useRef5(selectedChain);
|
|
8902
9242
|
selectedChainRef.current = selectedChain;
|
|
8903
|
-
const selectedTokenRef =
|
|
9243
|
+
const selectedTokenRef = useRef5(selectedToken);
|
|
8904
9244
|
selectedTokenRef.current = selectedToken;
|
|
8905
|
-
const setSelectedChainRef =
|
|
9245
|
+
const setSelectedChainRef = useRef5(setSelectedChain);
|
|
8906
9246
|
setSelectedChainRef.current = setSelectedChain;
|
|
8907
|
-
const setSelectedTokenRef =
|
|
9247
|
+
const setSelectedTokenRef = useRef5(setSelectedToken);
|
|
8908
9248
|
setSelectedTokenRef.current = setSelectedToken;
|
|
8909
9249
|
const { address: fallbackAddress } = useWalletInfo();
|
|
8910
9250
|
const getCurrentWalletAddress = useCallback10(
|
|
@@ -8913,7 +9253,7 @@ function useWalletTokenState({
|
|
|
8913
9253
|
},
|
|
8914
9254
|
[fallbackAddress]
|
|
8915
9255
|
);
|
|
8916
|
-
|
|
9256
|
+
useEffect13(() => {
|
|
8917
9257
|
if (!walletAddress || chains.length === 0 || tokens.length === 0) {
|
|
8918
9258
|
setYourWalletTokens([]);
|
|
8919
9259
|
if (!walletAddress) {
|
|
@@ -10016,7 +10356,7 @@ var init_AmountSlider = __esm({
|
|
|
10016
10356
|
});
|
|
10017
10357
|
|
|
10018
10358
|
// src/widget/components/AmountInputDisplay.tsx
|
|
10019
|
-
import { useRef as
|
|
10359
|
+
import { useRef as useRef6, useState as useState15 } from "react";
|
|
10020
10360
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
10021
10361
|
function formatDisplayAmount(value) {
|
|
10022
10362
|
if (!Number.isFinite(value) || value <= 0) return "0";
|
|
@@ -10055,8 +10395,8 @@ function AmountInputDisplay({
|
|
|
10055
10395
|
style,
|
|
10056
10396
|
inputAriaLabel = "Deposit amount"
|
|
10057
10397
|
}) {
|
|
10058
|
-
const [isEditing, setIsEditing] =
|
|
10059
|
-
const inputRef =
|
|
10398
|
+
const [isEditing, setIsEditing] = useState15(false);
|
|
10399
|
+
const inputRef = useRef6(null);
|
|
10060
10400
|
const handleAmountClick = () => {
|
|
10061
10401
|
if (isFixedAmount) return;
|
|
10062
10402
|
const isZeroish = !amount || parseFloat(amount) === 0;
|
|
@@ -10289,15 +10629,15 @@ __export(ConfettiEffect_exports, {
|
|
|
10289
10629
|
ConfettiEffect: () => ConfettiEffect,
|
|
10290
10630
|
default: () => ConfettiEffect_default
|
|
10291
10631
|
});
|
|
10292
|
-
import { useEffect as
|
|
10632
|
+
import { useEffect as useEffect14, useState as useState16 } from "react";
|
|
10293
10633
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
10294
10634
|
function ConfettiEffect({
|
|
10295
10635
|
isActive,
|
|
10296
10636
|
clearDelay = 3e3,
|
|
10297
10637
|
pieceCount = 50
|
|
10298
10638
|
}) {
|
|
10299
|
-
const [pieces, setPieces] =
|
|
10300
|
-
|
|
10639
|
+
const [pieces, setPieces] = useState16([]);
|
|
10640
|
+
useEffect14(() => {
|
|
10301
10641
|
if (isActive) {
|
|
10302
10642
|
const colors2 = [
|
|
10303
10643
|
"#10b981",
|
|
@@ -10382,7 +10722,7 @@ var init_ConfettiEffect = __esm({
|
|
|
10382
10722
|
});
|
|
10383
10723
|
|
|
10384
10724
|
// src/widget/components/Dialog.tsx
|
|
10385
|
-
import { useEffect as
|
|
10725
|
+
import { useEffect as useEffect15, useRef as useRef7 } from "react";
|
|
10386
10726
|
import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
10387
10727
|
var Dialog;
|
|
10388
10728
|
var init_Dialog = __esm({
|
|
@@ -10399,11 +10739,11 @@ var init_Dialog = __esm({
|
|
|
10399
10739
|
confirmText = "Close Anyway",
|
|
10400
10740
|
isDark = false
|
|
10401
10741
|
}) => {
|
|
10402
|
-
const dialogRef =
|
|
10403
|
-
const overlayRef =
|
|
10404
|
-
const firstButtonRef =
|
|
10405
|
-
const lastButtonRef =
|
|
10406
|
-
|
|
10742
|
+
const dialogRef = useRef7(null);
|
|
10743
|
+
const overlayRef = useRef7(null);
|
|
10744
|
+
const firstButtonRef = useRef7(null);
|
|
10745
|
+
const lastButtonRef = useRef7(null);
|
|
10746
|
+
useEffect15(() => {
|
|
10407
10747
|
const handleEscape = (e2) => {
|
|
10408
10748
|
if (e2.key === "Escape" && open) {
|
|
10409
10749
|
e2.preventDefault();
|
|
@@ -10417,7 +10757,7 @@ var init_Dialog = __esm({
|
|
|
10417
10757
|
document.removeEventListener("keydown", handleEscape);
|
|
10418
10758
|
};
|
|
10419
10759
|
}, [open, onCancel]);
|
|
10420
|
-
|
|
10760
|
+
useEffect15(() => {
|
|
10421
10761
|
const handleTabKey = (e2) => {
|
|
10422
10762
|
if (!open) return;
|
|
10423
10763
|
if (e2.key === "Tab") {
|
|
@@ -10441,7 +10781,7 @@ var init_Dialog = __esm({
|
|
|
10441
10781
|
document.removeEventListener("keydown", handleTabKey);
|
|
10442
10782
|
};
|
|
10443
10783
|
}, [open]);
|
|
10444
|
-
|
|
10784
|
+
useEffect15(() => {
|
|
10445
10785
|
if (open) {
|
|
10446
10786
|
const originalStyle = window.getComputedStyle(document.body).overflow;
|
|
10447
10787
|
document.body.style.overflow = "hidden";
|
|
@@ -10747,7 +11087,7 @@ var init_TransactionHashLink = __esm({
|
|
|
10747
11087
|
});
|
|
10748
11088
|
|
|
10749
11089
|
// src/widget/components/SwipeToConfirmTokens.tsx
|
|
10750
|
-
import { useState as
|
|
11090
|
+
import { useState as useState17, useRef as useRef8, useCallback as useCallback12, useEffect as useEffect16 } from "react";
|
|
10751
11091
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
10752
11092
|
function SwipeToConfirmTokens({
|
|
10753
11093
|
fromToken,
|
|
@@ -10762,16 +11102,16 @@ function SwipeToConfirmTokens({
|
|
|
10762
11102
|
style,
|
|
10763
11103
|
text
|
|
10764
11104
|
}) {
|
|
10765
|
-
const [dragX, setDragX] =
|
|
10766
|
-
const [isDragging, setIsDragging] =
|
|
10767
|
-
const [isComplete, setIsComplete] =
|
|
10768
|
-
const trackRef =
|
|
10769
|
-
const thumbRef =
|
|
10770
|
-
const [isLongPressing, setIsLongPressing] =
|
|
10771
|
-
const [longPressProgress, setLongPressProgress] =
|
|
10772
|
-
const longPressTimerRef =
|
|
10773
|
-
const longPressStartRef =
|
|
10774
|
-
const longPressAnimationRef =
|
|
11105
|
+
const [dragX, setDragX] = useState17(0);
|
|
11106
|
+
const [isDragging, setIsDragging] = useState17(false);
|
|
11107
|
+
const [isComplete, setIsComplete] = useState17(false);
|
|
11108
|
+
const trackRef = useRef8(null);
|
|
11109
|
+
const thumbRef = useRef8(null);
|
|
11110
|
+
const [isLongPressing, setIsLongPressing] = useState17(false);
|
|
11111
|
+
const [longPressProgress, setLongPressProgress] = useState17(0);
|
|
11112
|
+
const longPressTimerRef = useRef8(null);
|
|
11113
|
+
const longPressStartRef = useRef8(null);
|
|
11114
|
+
const longPressAnimationRef = useRef8(null);
|
|
10775
11115
|
const LONG_PRESS_DURATION = 1500;
|
|
10776
11116
|
const thumbSize = 48;
|
|
10777
11117
|
const padding = 4;
|
|
@@ -10869,7 +11209,7 @@ function SwipeToConfirmTokens({
|
|
|
10869
11209
|
},
|
|
10870
11210
|
[cancelLongPress]
|
|
10871
11211
|
);
|
|
10872
|
-
|
|
11212
|
+
useEffect16(() => {
|
|
10873
11213
|
return () => {
|
|
10874
11214
|
if (longPressTimerRef.current) clearTimeout(longPressTimerRef.current);
|
|
10875
11215
|
if (longPressAnimationRef.current)
|
|
@@ -10888,7 +11228,7 @@ function SwipeToConfirmTokens({
|
|
|
10888
11228
|
const handleTouchStart = () => handleDragStart();
|
|
10889
11229
|
const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
|
|
10890
11230
|
const handleTouchEnd = () => handleDragEnd();
|
|
10891
|
-
|
|
11231
|
+
useEffect16(() => {
|
|
10892
11232
|
if (isDragging) {
|
|
10893
11233
|
window.addEventListener("mousemove", handleMouseMove);
|
|
10894
11234
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -10900,8 +11240,8 @@ function SwipeToConfirmTokens({
|
|
|
10900
11240
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
10901
11241
|
const progress = getProgress();
|
|
10902
11242
|
const effectiveProgress = isLongPressing ? longPressProgress : progress;
|
|
10903
|
-
const [blinkOpacity, setBlinkOpacity] =
|
|
10904
|
-
|
|
11243
|
+
const [blinkOpacity, setBlinkOpacity] = useState17(1);
|
|
11244
|
+
useEffect16(() => {
|
|
10905
11245
|
if (disabled || isComplete || isDragging || isLongPressing) {
|
|
10906
11246
|
setBlinkOpacity(1);
|
|
10907
11247
|
return;
|
|
@@ -11363,7 +11703,7 @@ var init_ThemeToggle = __esm({
|
|
|
11363
11703
|
});
|
|
11364
11704
|
|
|
11365
11705
|
// src/widget/components/Toast.tsx
|
|
11366
|
-
import { useEffect as
|
|
11706
|
+
import { useEffect as useEffect17, useState as useState18, useCallback as useCallback13 } from "react";
|
|
11367
11707
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
11368
11708
|
function ToastItem({
|
|
11369
11709
|
id,
|
|
@@ -11373,14 +11713,14 @@ function ToastItem({
|
|
|
11373
11713
|
duration = 4e3,
|
|
11374
11714
|
onDismiss
|
|
11375
11715
|
}) {
|
|
11376
|
-
const [isExiting, setIsExiting] =
|
|
11377
|
-
|
|
11716
|
+
const [isExiting, setIsExiting] = useState18(false);
|
|
11717
|
+
useEffect17(() => {
|
|
11378
11718
|
const timer = setTimeout(() => {
|
|
11379
11719
|
setIsExiting(true);
|
|
11380
11720
|
}, duration);
|
|
11381
11721
|
return () => clearTimeout(timer);
|
|
11382
11722
|
}, [duration]);
|
|
11383
|
-
|
|
11723
|
+
useEffect17(() => {
|
|
11384
11724
|
if (isExiting) {
|
|
11385
11725
|
const exitTimer = setTimeout(() => {
|
|
11386
11726
|
onDismiss(id);
|
|
@@ -11579,8 +11919,8 @@ function toast(data) {
|
|
|
11579
11919
|
};
|
|
11580
11920
|
}
|
|
11581
11921
|
function ToastContainer() {
|
|
11582
|
-
const [activeToasts, setActiveToasts] =
|
|
11583
|
-
|
|
11922
|
+
const [activeToasts, setActiveToasts] = useState18([]);
|
|
11923
|
+
useEffect17(() => {
|
|
11584
11924
|
const listener = (newToasts) => {
|
|
11585
11925
|
setActiveToasts(newToasts);
|
|
11586
11926
|
};
|
|
@@ -11662,10 +12002,10 @@ var init_Toast = __esm({
|
|
|
11662
12002
|
|
|
11663
12003
|
// src/widget/components/TokenSwipePill.tsx
|
|
11664
12004
|
import React9, {
|
|
11665
|
-
useState as
|
|
11666
|
-
useRef as
|
|
12005
|
+
useState as useState19,
|
|
12006
|
+
useRef as useRef9,
|
|
11667
12007
|
useCallback as useCallback14,
|
|
11668
|
-
useEffect as
|
|
12008
|
+
useEffect as useEffect18,
|
|
11669
12009
|
useMemo as useMemo9
|
|
11670
12010
|
} from "react";
|
|
11671
12011
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
@@ -11678,10 +12018,10 @@ function TokenSwipePill({
|
|
|
11678
12018
|
walletAddress,
|
|
11679
12019
|
style
|
|
11680
12020
|
}) {
|
|
11681
|
-
const [isDragging, setIsDragging] =
|
|
11682
|
-
const [dragOffset, setDragOffset] =
|
|
11683
|
-
const startXRef =
|
|
11684
|
-
const containerRef =
|
|
12021
|
+
const [isDragging, setIsDragging] = useState19(false);
|
|
12022
|
+
const [dragOffset, setDragOffset] = useState19(0);
|
|
12023
|
+
const startXRef = useRef9(0);
|
|
12024
|
+
const containerRef = useRef9(null);
|
|
11685
12025
|
const currentIndex = tokens.findIndex(
|
|
11686
12026
|
(t) => normalizeAddress2(
|
|
11687
12027
|
t.address,
|
|
@@ -11752,7 +12092,7 @@ function TokenSwipePill({
|
|
|
11752
12092
|
const handleTouchEnd = () => {
|
|
11753
12093
|
handleDragEnd();
|
|
11754
12094
|
};
|
|
11755
|
-
|
|
12095
|
+
useEffect18(() => {
|
|
11756
12096
|
if (isDragging) {
|
|
11757
12097
|
window.addEventListener("mousemove", handleMouseMove);
|
|
11758
12098
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -12457,7 +12797,7 @@ var init_TransactionSteps = __esm({
|
|
|
12457
12797
|
});
|
|
12458
12798
|
|
|
12459
12799
|
// src/widget/components/WidgetContainer.tsx
|
|
12460
|
-
import { useEffect as
|
|
12800
|
+
import { useEffect as useEffect19, useState as useState20 } from "react";
|
|
12461
12801
|
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
12462
12802
|
function WidgetContainer({
|
|
12463
12803
|
children,
|
|
@@ -12465,8 +12805,8 @@ function WidgetContainer({
|
|
|
12465
12805
|
className,
|
|
12466
12806
|
style
|
|
12467
12807
|
}) {
|
|
12468
|
-
const [resolvedTheme, setResolvedTheme] =
|
|
12469
|
-
|
|
12808
|
+
const [resolvedTheme, setResolvedTheme] = useState20("light");
|
|
12809
|
+
useEffect19(() => {
|
|
12470
12810
|
if (theme === "system") {
|
|
12471
12811
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
12472
12812
|
setResolvedTheme(mediaQuery.matches ? "dark" : "light");
|
|
@@ -13011,7 +13351,7 @@ var init_ErrorPage = __esm({
|
|
|
13011
13351
|
});
|
|
13012
13352
|
|
|
13013
13353
|
// src/widget/components/ImageLoader.tsx
|
|
13014
|
-
import { useCallback as useCallback15, useEffect as
|
|
13354
|
+
import { useCallback as useCallback15, useEffect as useEffect20, useMemo as useMemo11, useRef as useRef10, useState as useState21 } from "react";
|
|
13015
13355
|
import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
13016
13356
|
function Skeleton({
|
|
13017
13357
|
background,
|
|
@@ -13040,18 +13380,18 @@ function ImageLoader({
|
|
|
13040
13380
|
onLoad,
|
|
13041
13381
|
onError
|
|
13042
13382
|
}) {
|
|
13043
|
-
const [status, setStatus] =
|
|
13044
|
-
const [attempt, setAttempt] =
|
|
13045
|
-
const [srcIsEmpty, setSrcIsEmpty] =
|
|
13046
|
-
const imgRef =
|
|
13047
|
-
const observerRef =
|
|
13048
|
-
const onLoadRef =
|
|
13049
|
-
const onErrorRef =
|
|
13050
|
-
|
|
13383
|
+
const [status, setStatus] = useState21("idle");
|
|
13384
|
+
const [attempt, setAttempt] = useState21(0);
|
|
13385
|
+
const [srcIsEmpty, setSrcIsEmpty] = useState21(false);
|
|
13386
|
+
const imgRef = useRef10(null);
|
|
13387
|
+
const observerRef = useRef10(null);
|
|
13388
|
+
const onLoadRef = useRef10(onLoad);
|
|
13389
|
+
const onErrorRef = useRef10(onError);
|
|
13390
|
+
useEffect20(() => {
|
|
13051
13391
|
onLoadRef.current = onLoad;
|
|
13052
13392
|
onErrorRef.current = onError;
|
|
13053
13393
|
}, [onLoad, onError]);
|
|
13054
|
-
|
|
13394
|
+
useEffect20(() => {
|
|
13055
13395
|
if (status === "error" && attempt < retry) {
|
|
13056
13396
|
const timer = setTimeout(() => {
|
|
13057
13397
|
setAttempt((prev) => prev + 1);
|
|
@@ -13078,7 +13418,7 @@ function ImageLoader({
|
|
|
13078
13418
|
onErrorRef.current?.();
|
|
13079
13419
|
};
|
|
13080
13420
|
}, [src]);
|
|
13081
|
-
|
|
13421
|
+
useEffect20(() => {
|
|
13082
13422
|
if (!lazy3) {
|
|
13083
13423
|
const timer = setTimeout(() => loadImage(), 0);
|
|
13084
13424
|
return () => clearTimeout(timer);
|
|
@@ -13548,7 +13888,7 @@ var init_AvailableTokenListItem = __esm({
|
|
|
13548
13888
|
});
|
|
13549
13889
|
|
|
13550
13890
|
// src/widget/features/token-selection/components/ChainSelectorPanel.tsx
|
|
13551
|
-
import { useState as
|
|
13891
|
+
import { useState as useState22, useMemo as useMemo12 } from "react";
|
|
13552
13892
|
import { Fragment as Fragment3, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
13553
13893
|
function ChainItem({
|
|
13554
13894
|
chain,
|
|
@@ -13760,7 +14100,7 @@ function ChainSelectorPanel({
|
|
|
13760
14100
|
otherChains,
|
|
13761
14101
|
popularChains
|
|
13762
14102
|
}) {
|
|
13763
|
-
const [chainSearch, setChainSearch] =
|
|
14103
|
+
const [chainSearch, setChainSearch] = useState22("");
|
|
13764
14104
|
const filteredPopular = useMemo12(() => {
|
|
13765
14105
|
if (!chainSearch) return popularChains;
|
|
13766
14106
|
const q = chainSearch.toLowerCase();
|
|
@@ -14519,7 +14859,7 @@ var init_WalletTokenListItem = __esm({
|
|
|
14519
14859
|
});
|
|
14520
14860
|
|
|
14521
14861
|
// src/widget/features/token-selection/components/TokenSelectorPanel.tsx
|
|
14522
|
-
import { useState as
|
|
14862
|
+
import { useState as useState23, useEffect as useEffect21 } from "react";
|
|
14523
14863
|
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
14524
14864
|
function TokenSectionLabel({
|
|
14525
14865
|
children,
|
|
@@ -14615,8 +14955,8 @@ function TokenSelectorPanel({
|
|
|
14615
14955
|
setSearchQuery,
|
|
14616
14956
|
tokensError
|
|
14617
14957
|
}) {
|
|
14618
|
-
const [showAll, setShowAll] =
|
|
14619
|
-
|
|
14958
|
+
const [showAll, setShowAll] = useState23(false);
|
|
14959
|
+
useEffect21(() => {
|
|
14620
14960
|
setShowAll(false);
|
|
14621
14961
|
}, [selectedChain, searchQuery]);
|
|
14622
14962
|
const hasWalletTokens = filteredWalletTokens.length > 0;
|
|
@@ -15540,7 +15880,7 @@ var init_CryptoPayAmountSection = __esm({
|
|
|
15540
15880
|
});
|
|
15541
15881
|
|
|
15542
15882
|
// src/widget/features/amount/hooks/useDepositAmountModel.ts
|
|
15543
|
-
import { useEffect as
|
|
15883
|
+
import { useEffect as useEffect22, useMemo as useMemo15 } from "react";
|
|
15544
15884
|
function useDepositAmountModel({
|
|
15545
15885
|
amount,
|
|
15546
15886
|
setAmount,
|
|
@@ -15561,7 +15901,7 @@ function useDepositAmountModel({
|
|
|
15561
15901
|
);
|
|
15562
15902
|
return Number.isFinite(normalized) ? normalized : 0;
|
|
15563
15903
|
}, [selectedToken?.balance, selectedToken?.decimals]);
|
|
15564
|
-
|
|
15904
|
+
useEffect22(() => {
|
|
15565
15905
|
if (fixedFromAmountString) return;
|
|
15566
15906
|
if (isReady && !hasUsdPrice && amountInputMode === "usd") {
|
|
15567
15907
|
setAmountInputMode("token");
|
|
@@ -15573,7 +15913,7 @@ function useDepositAmountModel({
|
|
|
15573
15913
|
isReady,
|
|
15574
15914
|
setAmountInputMode
|
|
15575
15915
|
]);
|
|
15576
|
-
|
|
15916
|
+
useEffect22(() => {
|
|
15577
15917
|
if (!fixedFromAmountString) return;
|
|
15578
15918
|
if (amount !== fixedFromAmountString) {
|
|
15579
15919
|
setAmount(fixedFromAmountString);
|
|
@@ -15751,7 +16091,7 @@ var init_useDepositAmountModel = __esm({
|
|
|
15751
16091
|
});
|
|
15752
16092
|
|
|
15753
16093
|
// src/widget/features/amount/hooks/useHomeAmountModel.ts
|
|
15754
|
-
import { useEffect as
|
|
16094
|
+
import { useEffect as useEffect23, useMemo as useMemo16 } from "react";
|
|
15755
16095
|
function useHomeAmountModel({
|
|
15756
16096
|
amount,
|
|
15757
16097
|
setAmount,
|
|
@@ -15762,7 +16102,7 @@ function useHomeAmountModel({
|
|
|
15762
16102
|
minAmountUsd,
|
|
15763
16103
|
maxAmountUsd
|
|
15764
16104
|
}) {
|
|
15765
|
-
|
|
16105
|
+
useEffect23(() => {
|
|
15766
16106
|
if (!fixedFromAmountString) return;
|
|
15767
16107
|
if (amount !== fixedFromAmountString) {
|
|
15768
16108
|
setAmount(fixedFromAmountString);
|
|
@@ -16172,8 +16512,20 @@ var init_WalletNamespaceTabs = __esm({
|
|
|
16172
16512
|
});
|
|
16173
16513
|
|
|
16174
16514
|
// src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx
|
|
16175
|
-
import { useEffect as
|
|
16515
|
+
import { useEffect as useEffect24, useMemo as useMemo17, useRef as useRef11, useState as useState24 } from "react";
|
|
16176
16516
|
import { Fragment as Fragment7, jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
16517
|
+
function ecosystemToNamespace(ecosystem) {
|
|
16518
|
+
switch (ecosystem.trim().toLowerCase()) {
|
|
16519
|
+
case "evm":
|
|
16520
|
+
return "evm";
|
|
16521
|
+
case "solana":
|
|
16522
|
+
return "Solana";
|
|
16523
|
+
case "bitcoin":
|
|
16524
|
+
return "bitcoin";
|
|
16525
|
+
default:
|
|
16526
|
+
return null;
|
|
16527
|
+
}
|
|
16528
|
+
}
|
|
16177
16529
|
function DesktopWalletDropdownContent({
|
|
16178
16530
|
browserWallets,
|
|
16179
16531
|
handleWalletConnect,
|
|
@@ -16239,38 +16591,70 @@ function DesktopWalletDropdownContent({
|
|
|
16239
16591
|
);
|
|
16240
16592
|
}
|
|
16241
16593
|
function MobileWalletDropdownContent({
|
|
16242
|
-
|
|
16594
|
+
browserWallets,
|
|
16595
|
+
handleWalletConnect,
|
|
16596
|
+
handleWalletSelect: connectDetectedWallet2
|
|
16243
16597
|
}) {
|
|
16244
16598
|
const { setCurrentStep } = useDepositNavigation();
|
|
16245
|
-
const { selectedNamespace } = useDepositWallet();
|
|
16246
|
-
const { walletMetaId, isConnected, status } = useWalletInfo();
|
|
16247
|
-
const [hoveredId, setHoveredId] =
|
|
16248
|
-
const storeFallbackTimeoutRef =
|
|
16599
|
+
const { selectedNamespace, setSelectedNamespace } = useDepositWallet();
|
|
16600
|
+
const { walletMetaId, isConnected, status, detected } = useWalletInfo();
|
|
16601
|
+
const [hoveredId, setHoveredId] = useState24(null);
|
|
16602
|
+
const storeFallbackTimeoutRef = useRef11(
|
|
16249
16603
|
null
|
|
16250
16604
|
);
|
|
16251
|
-
|
|
16605
|
+
useEffect24(() => {
|
|
16252
16606
|
return () => {
|
|
16253
16607
|
if (storeFallbackTimeoutRef.current !== null) {
|
|
16254
16608
|
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16255
16609
|
}
|
|
16256
16610
|
};
|
|
16257
16611
|
}, []);
|
|
16612
|
+
useEffect24(() => {
|
|
16613
|
+
if (browserWallets.length > 0) return;
|
|
16614
|
+
const otherEcosystemWallet = detected.find((d) => {
|
|
16615
|
+
if (d.meta.id === "walletconnect") return false;
|
|
16616
|
+
const ecosystem = d.meta.ecosystem.trim().toLowerCase();
|
|
16617
|
+
return ecosystem !== "multi" && ecosystem !== selectedNamespace.trim().toLowerCase();
|
|
16618
|
+
});
|
|
16619
|
+
if (!otherEcosystemWallet) return;
|
|
16620
|
+
const nextNamespace = ecosystemToNamespace(
|
|
16621
|
+
otherEcosystemWallet.meta.ecosystem
|
|
16622
|
+
);
|
|
16623
|
+
if (nextNamespace) setSelectedNamespace(nextNamespace);
|
|
16624
|
+
}, [browserWallets, detected, selectedNamespace, setSelectedNamespace]);
|
|
16258
16625
|
const connectedWalletId = isConnected ? walletMetaId : null;
|
|
16259
16626
|
const currentUrl = window.location.href;
|
|
16260
|
-
const mobileWallets = useMemo17(
|
|
16261
|
-
|
|
16262
|
-
if (w.id === "walletconnect")
|
|
16627
|
+
const mobileWallets = useMemo17(() => {
|
|
16628
|
+
const entries = WALLETS.filter((w) => {
|
|
16629
|
+
if (w.id === "walletconnect") {
|
|
16630
|
+
return selectedNamespace.trim().toLowerCase() === "evm";
|
|
16631
|
+
}
|
|
16632
|
+
const isDetected = browserWallets.some((d) => d.meta.id === w.id);
|
|
16263
16633
|
const hasMobileLink = Boolean(w.deepLink);
|
|
16264
|
-
if (!hasMobileLink) return false;
|
|
16634
|
+
if (!hasMobileLink && !isDetected) return false;
|
|
16265
16635
|
return w.ecosystem.trim().toLowerCase() === "multi" || w.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase();
|
|
16266
|
-
})
|
|
16267
|
-
|
|
16268
|
-
|
|
16269
|
-
|
|
16636
|
+
}).map((meta) => ({
|
|
16637
|
+
meta,
|
|
16638
|
+
detectedWallet: browserWallets.find((d) => d.meta.id === meta.id) ?? null
|
|
16639
|
+
}));
|
|
16640
|
+
const listedIds = new Set(entries.map((e2) => e2.meta.id));
|
|
16641
|
+
for (const detected2 of browserWallets) {
|
|
16642
|
+
if (!listedIds.has(detected2.meta.id)) {
|
|
16643
|
+
entries.push({ meta: detected2.meta, detectedWallet: detected2 });
|
|
16644
|
+
}
|
|
16645
|
+
}
|
|
16646
|
+
return entries;
|
|
16647
|
+
}, [browserWallets, selectedNamespace]);
|
|
16648
|
+
const handleWalletSelect = (entry) => {
|
|
16649
|
+
const { meta: wallet, detectedWallet } = entry;
|
|
16270
16650
|
if (wallet.id === "walletconnect") {
|
|
16271
16651
|
handleWalletConnect();
|
|
16272
16652
|
return;
|
|
16273
16653
|
}
|
|
16654
|
+
if (detectedWallet) {
|
|
16655
|
+
void connectDetectedWallet2(detectedWallet);
|
|
16656
|
+
return;
|
|
16657
|
+
}
|
|
16274
16658
|
if (wallet.deepLink) {
|
|
16275
16659
|
const deepLinkUrl = wallet.deepLink(currentUrl);
|
|
16276
16660
|
if (deepLinkUrl) {
|
|
@@ -16340,15 +16724,16 @@ function MobileWalletDropdownContent({
|
|
|
16340
16724
|
scrollbarWidth: "thin",
|
|
16341
16725
|
scrollbarColor: `${colors.muted} transparent`
|
|
16342
16726
|
},
|
|
16343
|
-
children: mobileWallets.map((
|
|
16727
|
+
children: mobileWallets.map((entry) => {
|
|
16728
|
+
const wallet = entry.meta;
|
|
16344
16729
|
const isConnectedWallet = wallet.id === connectedWalletId;
|
|
16345
|
-
const isDisabled = isConnected && !isConnectedWallet;
|
|
16730
|
+
const isDisabled = isConnected && !isConnectedWallet && !entry.detectedWallet;
|
|
16346
16731
|
const isHovered = hoveredId === wallet.id;
|
|
16347
16732
|
return /* @__PURE__ */ jsxs30(
|
|
16348
16733
|
"button",
|
|
16349
16734
|
{
|
|
16350
16735
|
type: "button",
|
|
16351
|
-
onClick: () => !isDisabled && handleWalletSelect(
|
|
16736
|
+
onClick: () => !isDisabled && handleWalletSelect(entry),
|
|
16352
16737
|
onMouseEnter: () => !isDisabled && setHoveredId(wallet.id),
|
|
16353
16738
|
onMouseLeave: () => setHoveredId(null),
|
|
16354
16739
|
style: {
|
|
@@ -16424,7 +16809,7 @@ function MobileWalletDropdownContent({
|
|
|
16424
16809
|
}
|
|
16425
16810
|
}
|
|
16426
16811
|
),
|
|
16427
|
-
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "
|
|
16812
|
+
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "Continue" })
|
|
16428
16813
|
]
|
|
16429
16814
|
}
|
|
16430
16815
|
)
|
|
@@ -16489,7 +16874,9 @@ function CryptoWalletDropdownContent({
|
|
|
16489
16874
|
isMobile && /* @__PURE__ */ jsx36(
|
|
16490
16875
|
MobileWalletDropdownContent,
|
|
16491
16876
|
{
|
|
16492
|
-
|
|
16877
|
+
browserWallets,
|
|
16878
|
+
handleWalletConnect,
|
|
16879
|
+
handleWalletSelect
|
|
16493
16880
|
}
|
|
16494
16881
|
)
|
|
16495
16882
|
] });
|
|
@@ -16959,7 +17346,7 @@ var init_HomePaymentOptions = __esm({
|
|
|
16959
17346
|
});
|
|
16960
17347
|
|
|
16961
17348
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
16962
|
-
import { useCallback as useCallback18, useEffect as
|
|
17349
|
+
import { useCallback as useCallback18, useEffect as useEffect25, useMemo as useMemo18, useRef as useRef12, useState as useState25 } from "react";
|
|
16963
17350
|
function useHomeWalletActions({
|
|
16964
17351
|
connectWallet,
|
|
16965
17352
|
detectedWallets,
|
|
@@ -16968,12 +17355,12 @@ function useHomeWalletActions({
|
|
|
16968
17355
|
WalletConnect
|
|
16969
17356
|
// setCurrentStepInternal,
|
|
16970
17357
|
}) {
|
|
16971
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] =
|
|
16972
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] =
|
|
16973
|
-
const cryptoDropdownRef =
|
|
16974
|
-
const fiatDropdownRef =
|
|
17358
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = useState25(false);
|
|
17359
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = useState25(false);
|
|
17360
|
+
const cryptoDropdownRef = useRef12(null);
|
|
17361
|
+
const fiatDropdownRef = useRef12(null);
|
|
16975
17362
|
const { disconnect } = useWalletInfo();
|
|
16976
|
-
|
|
17363
|
+
useEffect25(() => {
|
|
16977
17364
|
const handleClickOutside = (event) => {
|
|
16978
17365
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
16979
17366
|
setIsCryptoDropdownOpen(false);
|
|
@@ -17023,9 +17410,11 @@ function useHomeWalletActions({
|
|
|
17023
17410
|
const { selectedNamespace } = useDepositWallet();
|
|
17024
17411
|
const browserWallets = useMemo18(() => {
|
|
17025
17412
|
if (!detectedWallets?.length) return [];
|
|
17026
|
-
return detectedWallets.filter(
|
|
17027
|
-
(wallet
|
|
17028
|
-
|
|
17413
|
+
return detectedWallets.filter((wallet) => {
|
|
17414
|
+
if (wallet?.meta?.id === "walletconnect") return false;
|
|
17415
|
+
const ecosystem = wallet?.meta?.ecosystem.trim().toLowerCase();
|
|
17416
|
+
return ecosystem === "multi" || ecosystem === selectedNamespace.trim().toLowerCase();
|
|
17417
|
+
});
|
|
17029
17418
|
}, [detectedWallets, selectedNamespace]);
|
|
17030
17419
|
return {
|
|
17031
17420
|
browserWallets,
|
|
@@ -17059,11 +17448,114 @@ var init_wallet = __esm({
|
|
|
17059
17448
|
});
|
|
17060
17449
|
|
|
17061
17450
|
// src/widget/pages/Home.tsx
|
|
17062
|
-
import { jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
17451
|
+
import { Fragment as Fragment8, jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
17452
|
+
function WalletConnectStatusBanner({
|
|
17453
|
+
status,
|
|
17454
|
+
errorMessage,
|
|
17455
|
+
onRetry,
|
|
17456
|
+
onDismiss
|
|
17457
|
+
}) {
|
|
17458
|
+
const isDone = status !== "connecting";
|
|
17459
|
+
const isFailed = status === "failed";
|
|
17460
|
+
const { text, icon } = wcBannerCopy[status];
|
|
17461
|
+
return /* @__PURE__ */ jsxs35(
|
|
17462
|
+
"div",
|
|
17463
|
+
{
|
|
17464
|
+
style: {
|
|
17465
|
+
display: "flex",
|
|
17466
|
+
alignItems: "center",
|
|
17467
|
+
gap: spacing[2],
|
|
17468
|
+
width: "100%",
|
|
17469
|
+
padding: `${spacing[2.5]} ${spacing[3]}`,
|
|
17470
|
+
marginBottom: spacing[4],
|
|
17471
|
+
borderRadius: borderRadius.lg,
|
|
17472
|
+
backgroundColor: isFailed ? "rgba(239,68,68,0.1)" : isDone ? "rgba(234,179,8,0.1)" : colors.muted,
|
|
17473
|
+
border: isFailed ? "1px solid rgba(239,68,68,0.4)" : isDone ? "1px solid rgba(234,179,8,0.4)" : `1px solid ${colors.border}`
|
|
17474
|
+
},
|
|
17475
|
+
children: [
|
|
17476
|
+
icon === "spinner" ? /* @__PURE__ */ jsx44(
|
|
17477
|
+
"div",
|
|
17478
|
+
{
|
|
17479
|
+
style: {
|
|
17480
|
+
width: "0.875rem",
|
|
17481
|
+
height: "0.875rem",
|
|
17482
|
+
border: `2px solid ${colors.mutedForeground}`,
|
|
17483
|
+
borderTopColor: "transparent",
|
|
17484
|
+
borderRadius: "9999px",
|
|
17485
|
+
animation: "tw-spin 1s linear infinite",
|
|
17486
|
+
flexShrink: 0
|
|
17487
|
+
}
|
|
17488
|
+
}
|
|
17489
|
+
) : /* @__PURE__ */ jsx44("span", { style: { fontSize: fontSize.sm, flexShrink: 0 }, "aria-hidden": true, children: icon }),
|
|
17490
|
+
/* @__PURE__ */ jsxs35(
|
|
17491
|
+
"p",
|
|
17492
|
+
{
|
|
17493
|
+
style: {
|
|
17494
|
+
flex: 1,
|
|
17495
|
+
fontSize: fontSize.xs,
|
|
17496
|
+
color: isDone ? colors.foreground : colors.mutedForeground,
|
|
17497
|
+
margin: 0
|
|
17498
|
+
},
|
|
17499
|
+
children: [
|
|
17500
|
+
text,
|
|
17501
|
+
isFailed && errorMessage ? ` ${errorMessage}` : ""
|
|
17502
|
+
]
|
|
17503
|
+
}
|
|
17504
|
+
),
|
|
17505
|
+
isDone && /* @__PURE__ */ jsxs35(Fragment8, { children: [
|
|
17506
|
+
/* @__PURE__ */ jsx44(
|
|
17507
|
+
"button",
|
|
17508
|
+
{
|
|
17509
|
+
type: "button",
|
|
17510
|
+
onClick: onRetry,
|
|
17511
|
+
style: {
|
|
17512
|
+
fontSize: fontSize.xs,
|
|
17513
|
+
fontWeight: fontWeight.semibold,
|
|
17514
|
+
color: colors.primary,
|
|
17515
|
+
backgroundColor: "transparent",
|
|
17516
|
+
border: 0,
|
|
17517
|
+
cursor: "pointer",
|
|
17518
|
+
flexShrink: 0
|
|
17519
|
+
},
|
|
17520
|
+
children: "Retry"
|
|
17521
|
+
}
|
|
17522
|
+
),
|
|
17523
|
+
/* @__PURE__ */ jsx44(
|
|
17524
|
+
"button",
|
|
17525
|
+
{
|
|
17526
|
+
type: "button",
|
|
17527
|
+
onClick: onDismiss,
|
|
17528
|
+
"aria-label": "Dismiss",
|
|
17529
|
+
style: {
|
|
17530
|
+
fontSize: fontSize.xs,
|
|
17531
|
+
color: colors.mutedForeground,
|
|
17532
|
+
backgroundColor: "transparent",
|
|
17533
|
+
border: 0,
|
|
17534
|
+
cursor: "pointer",
|
|
17535
|
+
flexShrink: 0,
|
|
17536
|
+
padding: 0,
|
|
17537
|
+
lineHeight: 1
|
|
17538
|
+
},
|
|
17539
|
+
children: "\xD7"
|
|
17540
|
+
}
|
|
17541
|
+
)
|
|
17542
|
+
] })
|
|
17543
|
+
]
|
|
17544
|
+
}
|
|
17545
|
+
);
|
|
17546
|
+
}
|
|
17063
17547
|
function Home({ style: _style }) {
|
|
17064
17548
|
const { amount, setAmount, amountInputMode, setAmountInputMode } = useDepositForm();
|
|
17065
17549
|
const { setCurrentStep, setCurrentStepInternal } = useDepositNavigation();
|
|
17066
|
-
const {
|
|
17550
|
+
const {
|
|
17551
|
+
connectWallet,
|
|
17552
|
+
WalletConnect,
|
|
17553
|
+
setWalletType,
|
|
17554
|
+
wcStatus,
|
|
17555
|
+
wcErrorMessage,
|
|
17556
|
+
retryWalletConnect,
|
|
17557
|
+
dismissWcStatus
|
|
17558
|
+
} = useDepositWallet();
|
|
17067
17559
|
const { resolvedTheme } = useDepositUi();
|
|
17068
17560
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
17069
17561
|
const { detected: detectedWallets } = useWalletDetection();
|
|
@@ -17145,6 +17637,15 @@ function Home({ style: _style }) {
|
|
|
17145
17637
|
position: "relative"
|
|
17146
17638
|
},
|
|
17147
17639
|
children: [
|
|
17640
|
+
wcStatus !== "idle" && /* @__PURE__ */ jsx44(
|
|
17641
|
+
WalletConnectStatusBanner,
|
|
17642
|
+
{
|
|
17643
|
+
status: wcStatus,
|
|
17644
|
+
errorMessage: wcErrorMessage,
|
|
17645
|
+
onRetry: retryWalletConnect,
|
|
17646
|
+
onDismiss: dismissWcStatus
|
|
17647
|
+
}
|
|
17648
|
+
),
|
|
17148
17649
|
/* @__PURE__ */ jsx44(
|
|
17149
17650
|
"p",
|
|
17150
17651
|
{
|
|
@@ -17220,6 +17721,7 @@ function Home({ style: _style }) {
|
|
|
17220
17721
|
}
|
|
17221
17722
|
);
|
|
17222
17723
|
}
|
|
17724
|
+
var wcBannerCopy;
|
|
17223
17725
|
var init_Home = __esm({
|
|
17224
17726
|
"src/widget/pages/Home.tsx"() {
|
|
17225
17727
|
"use strict";
|
|
@@ -17229,6 +17731,20 @@ var init_Home = __esm({
|
|
|
17229
17731
|
init_amount();
|
|
17230
17732
|
init_wallets();
|
|
17231
17733
|
init_wallet();
|
|
17734
|
+
wcBannerCopy = {
|
|
17735
|
+
connecting: {
|
|
17736
|
+
text: "Waiting for wallet approval via WalletConnect\u2026",
|
|
17737
|
+
icon: "spinner"
|
|
17738
|
+
},
|
|
17739
|
+
timedOut: {
|
|
17740
|
+
text: "Still waiting on WalletConnect \u2014 this is taking longer than expected.",
|
|
17741
|
+
icon: "\u26A0\uFE0F"
|
|
17742
|
+
},
|
|
17743
|
+
failed: {
|
|
17744
|
+
text: "WalletConnect connection failed.",
|
|
17745
|
+
icon: "\u2715"
|
|
17746
|
+
}
|
|
17747
|
+
};
|
|
17232
17748
|
}
|
|
17233
17749
|
});
|
|
17234
17750
|
|
|
@@ -31034,7 +31550,7 @@ async function sendRouteAsUserOperation(params) {
|
|
|
31034
31550
|
);
|
|
31035
31551
|
}
|
|
31036
31552
|
console.debug("[send] UserOp included", { userOpHash, txHash });
|
|
31037
|
-
await submitReceipt(intentId, txHash, getSponsorshipRequestId());
|
|
31553
|
+
await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
|
|
31038
31554
|
return { userOpHash, txHash, intentId };
|
|
31039
31555
|
}
|
|
31040
31556
|
var NATIVE_ADDRS;
|
|
@@ -31079,7 +31595,7 @@ var init_smart_account2 = __esm({
|
|
|
31079
31595
|
});
|
|
31080
31596
|
|
|
31081
31597
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
31082
|
-
import { useCallback as useCallback19, useEffect as
|
|
31598
|
+
import { useCallback as useCallback19, useEffect as useEffect26, useMemo as useMemo20, useRef as useRef13, useState as useState26 } from "react";
|
|
31083
31599
|
import { encodeFunctionData as encodeFunctionData8, erc20Abi } from "viem";
|
|
31084
31600
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
31085
31601
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
@@ -31101,7 +31617,7 @@ function useTransactionActionModel({
|
|
|
31101
31617
|
walletAddress,
|
|
31102
31618
|
walletStatus
|
|
31103
31619
|
}) {
|
|
31104
|
-
const feeDataCacheRef =
|
|
31620
|
+
const feeDataCacheRef = useRef13({});
|
|
31105
31621
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
31106
31622
|
const { trackEvent } = useGTM(GTM_ID);
|
|
31107
31623
|
const destinationConfig = (() => {
|
|
@@ -31153,10 +31669,10 @@ function useTransactionActionModel({
|
|
|
31153
31669
|
const addr = txReq?.to ?? txReq?.target;
|
|
31154
31670
|
return addr ?? null;
|
|
31155
31671
|
}, [routeResult?.txReq]);
|
|
31156
|
-
const [allowanceWei, setAllowanceWei] =
|
|
31157
|
-
const [isReadingAllowance, setIsReadingAllowance] =
|
|
31158
|
-
const [isApproving, setIsApproving] =
|
|
31159
|
-
const [gasReservationWei, setGasReservationWei] =
|
|
31672
|
+
const [allowanceWei, setAllowanceWei] = useState26(0n);
|
|
31673
|
+
const [isReadingAllowance, setIsReadingAllowance] = useState26(false);
|
|
31674
|
+
const [isApproving, setIsApproving] = useState26(false);
|
|
31675
|
+
const [gasReservationWei, setGasReservationWei] = useState26(0n);
|
|
31160
31676
|
const readAllowance = useCallback19(async () => {
|
|
31161
31677
|
if (!isEvm || isNativeSelected || !!routeResult?.sponsorship || // sponsored routes: SA approves bridge inside the UO batch
|
|
31162
31678
|
!backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
@@ -31187,7 +31703,7 @@ function useTransactionActionModel({
|
|
|
31187
31703
|
spender,
|
|
31188
31704
|
walletAddress
|
|
31189
31705
|
]);
|
|
31190
|
-
|
|
31706
|
+
useEffect26(() => {
|
|
31191
31707
|
void readAllowance();
|
|
31192
31708
|
}, [readAllowance]);
|
|
31193
31709
|
const needsApproval = isEvm && !isNativeSelected && !routeResult?.sponsorship && // sponsored routes use Permit2 + SA internal batch — no EOA bridge approval
|
|
@@ -31391,13 +31907,13 @@ function useTransactionActionModel({
|
|
|
31391
31907
|
routeResult?.txReq,
|
|
31392
31908
|
walletAddress
|
|
31393
31909
|
]);
|
|
31394
|
-
|
|
31910
|
+
useEffect26(() => {
|
|
31395
31911
|
if (routeResult) {
|
|
31396
31912
|
void estimateGasReservationWei();
|
|
31397
31913
|
}
|
|
31398
31914
|
}, [estimateGasReservationWei, routeResult]);
|
|
31399
|
-
const [smartAccountFailed, setSmartAccountFailed] =
|
|
31400
|
-
|
|
31915
|
+
const [smartAccountFailed, setSmartAccountFailed] = useState26(false);
|
|
31916
|
+
useEffect26(() => {
|
|
31401
31917
|
setSmartAccountFailed(false);
|
|
31402
31918
|
}, [routeResult?.intentId]);
|
|
31403
31919
|
const handleConfirm = useCallback19(async () => {
|
|
@@ -31731,12 +32247,12 @@ var init_DefaultCryptoPay = __esm({
|
|
|
31731
32247
|
});
|
|
31732
32248
|
|
|
31733
32249
|
// src/widget/pages/CryptoPay/RouteQuoteLoader.tsx
|
|
31734
|
-
import { useState as
|
|
32250
|
+
import { useState as useState27, useEffect as useEffect27 } from "react";
|
|
31735
32251
|
import { jsx as jsx49, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
31736
32252
|
function RouteQuoteLoader({ selectedToken }) {
|
|
31737
|
-
const [messageIndex, setMessageIndex] =
|
|
31738
|
-
const [visible, setVisible] =
|
|
31739
|
-
|
|
32253
|
+
const [messageIndex, setMessageIndex] = useState27(0);
|
|
32254
|
+
const [visible, setVisible] = useState27(true);
|
|
32255
|
+
useEffect27(() => {
|
|
31740
32256
|
let t = null;
|
|
31741
32257
|
const interval = setInterval(() => {
|
|
31742
32258
|
setVisible(false);
|
|
@@ -31912,8 +32428,8 @@ var init_RouteQuoteLoader = __esm({
|
|
|
31912
32428
|
});
|
|
31913
32429
|
|
|
31914
32430
|
// src/widget/pages/CryptoPay/index.tsx
|
|
31915
|
-
import { useEffect as
|
|
31916
|
-
import { Fragment as
|
|
32431
|
+
import { useEffect as useEffect28, useMemo as useMemo21 } from "react";
|
|
32432
|
+
import { Fragment as Fragment9, jsx as jsx50, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
31917
32433
|
function CryptoPay({ style: _style }) {
|
|
31918
32434
|
const {
|
|
31919
32435
|
amount,
|
|
@@ -32022,7 +32538,7 @@ function CryptoPay({ style: _style }) {
|
|
|
32022
32538
|
});
|
|
32023
32539
|
const { emitError } = useTrustware();
|
|
32024
32540
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
32025
|
-
|
|
32541
|
+
useEffect28(() => {
|
|
32026
32542
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
32027
32543
|
emitError?.(
|
|
32028
32544
|
new TrustwareError({
|
|
@@ -32152,7 +32668,7 @@ function CryptoPay({ style: _style }) {
|
|
|
32152
32668
|
]
|
|
32153
32669
|
}
|
|
32154
32670
|
),
|
|
32155
|
-
showSkeleton ? /* @__PURE__ */ jsx50(
|
|
32671
|
+
showSkeleton ? /* @__PURE__ */ jsx50(Fragment9, { children: /* @__PURE__ */ jsx50(
|
|
32156
32672
|
"div",
|
|
32157
32673
|
{
|
|
32158
32674
|
style: {
|
|
@@ -32163,8 +32679,8 @@ function CryptoPay({ style: _style }) {
|
|
|
32163
32679
|
},
|
|
32164
32680
|
children: /* @__PURE__ */ jsx50(LoadingSkeleton, {})
|
|
32165
32681
|
}
|
|
32166
|
-
) }) : /* @__PURE__ */ jsxs40(
|
|
32167
|
-
isReady && /* @__PURE__ */ jsx50(
|
|
32682
|
+
) }) : /* @__PURE__ */ jsxs40(Fragment9, { children: [
|
|
32683
|
+
isReady && /* @__PURE__ */ jsx50(Fragment9, { children: isLoadingRoute && !routeResult ? /* @__PURE__ */ jsx50(RouteQuoteLoader, { selectedToken: readySelectedToken }) : /* @__PURE__ */ jsxs40(Fragment9, { children: [
|
|
32168
32684
|
/* @__PURE__ */ jsx50(
|
|
32169
32685
|
CryptoPayAmountSection,
|
|
32170
32686
|
{
|
|
@@ -32243,7 +32759,7 @@ var init_CryptoPay = __esm({
|
|
|
32243
32759
|
});
|
|
32244
32760
|
|
|
32245
32761
|
// src/widget/pages/Processing.tsx
|
|
32246
|
-
import { useEffect as
|
|
32762
|
+
import { useEffect as useEffect29, useMemo as useMemo22, useRef as useRef14 } from "react";
|
|
32247
32763
|
import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
32248
32764
|
function getProgressFromStatus(status) {
|
|
32249
32765
|
switch (status) {
|
|
@@ -32282,13 +32798,13 @@ function Processing({ style }) {
|
|
|
32282
32798
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
32283
32799
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
32284
32800
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
32285
|
-
const hasStartedPolling =
|
|
32286
|
-
|
|
32801
|
+
const hasStartedPolling = useRef14(false);
|
|
32802
|
+
useEffect29(() => {
|
|
32287
32803
|
return () => {
|
|
32288
32804
|
hasStartedPolling.current = false;
|
|
32289
32805
|
};
|
|
32290
32806
|
}, []);
|
|
32291
|
-
|
|
32807
|
+
useEffect29(() => {
|
|
32292
32808
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
32293
32809
|
hasStartedPolling.current = true;
|
|
32294
32810
|
startPolling(intentId, transactionHash);
|
|
@@ -32788,14 +33304,14 @@ var init_WidgetRouter = __esm({
|
|
|
32788
33304
|
});
|
|
32789
33305
|
|
|
32790
33306
|
// src/modes/swap/hooks/useSwapRoute.ts
|
|
32791
|
-
import { useCallback as useCallback20, useRef as
|
|
33307
|
+
import { useCallback as useCallback20, useRef as useRef15, useState as useState28 } from "react";
|
|
32792
33308
|
function useSwapRoute() {
|
|
32793
|
-
const [state, setState] =
|
|
33309
|
+
const [state, setState] = useState28({
|
|
32794
33310
|
data: null,
|
|
32795
33311
|
loading: false,
|
|
32796
33312
|
error: null
|
|
32797
33313
|
});
|
|
32798
|
-
const abortRef =
|
|
33314
|
+
const abortRef = useRef15(false);
|
|
32799
33315
|
const fetch2 = useCallback20(
|
|
32800
33316
|
async (params) => {
|
|
32801
33317
|
const { fromToken, fromChain, toToken, toChain, amount, walletAddress } = params;
|
|
@@ -32854,7 +33370,7 @@ var init_useSwapRoute = __esm({
|
|
|
32854
33370
|
});
|
|
32855
33371
|
|
|
32856
33372
|
// src/modes/swap/hooks/useSwapExecution.ts
|
|
32857
|
-
import { useCallback as useCallback21, useRef as
|
|
33373
|
+
import { useCallback as useCallback21, useRef as useRef16, useState as useState29 } from "react";
|
|
32858
33374
|
import { encodeFunctionData as encodeFunctionData9, erc20Abi as erc20Abi2 } from "viem";
|
|
32859
33375
|
function normalizeTx(raw) {
|
|
32860
33376
|
const r = raw;
|
|
@@ -32889,7 +33405,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
32889
33405
|
throw new Error("Timed out waiting for approval confirmation");
|
|
32890
33406
|
}
|
|
32891
33407
|
function useSwapExecution(fromChain) {
|
|
32892
|
-
const [state, setState] =
|
|
33408
|
+
const [state, setState] = useState29({
|
|
32893
33409
|
txStatus: "idle",
|
|
32894
33410
|
txHash: null,
|
|
32895
33411
|
intentId: null,
|
|
@@ -32898,11 +33414,11 @@ function useSwapExecution(fromChain) {
|
|
|
32898
33414
|
isSubmitting: false,
|
|
32899
33415
|
allowanceStatus: "unknown"
|
|
32900
33416
|
});
|
|
32901
|
-
const saFailedUntilRef =
|
|
32902
|
-
const pollingRef =
|
|
32903
|
-
const timeoutRef =
|
|
32904
|
-
const abortRef =
|
|
32905
|
-
const pollCountRef =
|
|
33417
|
+
const saFailedUntilRef = useRef16(0);
|
|
33418
|
+
const pollingRef = useRef16(null);
|
|
33419
|
+
const timeoutRef = useRef16(null);
|
|
33420
|
+
const abortRef = useRef16(false);
|
|
33421
|
+
const pollCountRef = useRef16(0);
|
|
32906
33422
|
const clearPolling = useCallback21(() => {
|
|
32907
33423
|
abortRef.current = true;
|
|
32908
33424
|
if (pollingRef.current) clearTimeout(pollingRef.current);
|
|
@@ -33265,13 +33781,13 @@ var init_forex = __esm({
|
|
|
33265
33781
|
});
|
|
33266
33782
|
|
|
33267
33783
|
// src/modes/swap/hooks/useForex.ts
|
|
33268
|
-
import { useEffect as
|
|
33784
|
+
import { useEffect as useEffect30, useRef as useRef17, useState as useState30 } from "react";
|
|
33269
33785
|
function useForex() {
|
|
33270
|
-
const [rates, setRates] =
|
|
33271
|
-
const [error, setError] =
|
|
33272
|
-
const [lastUpdated, setLastUpdated] =
|
|
33273
|
-
const timerRef =
|
|
33274
|
-
|
|
33786
|
+
const [rates, setRates] = useState30({ USD: 1 });
|
|
33787
|
+
const [error, setError] = useState30(null);
|
|
33788
|
+
const [lastUpdated, setLastUpdated] = useState30(null);
|
|
33789
|
+
const timerRef = useRef17(null);
|
|
33790
|
+
useEffect30(() => {
|
|
33275
33791
|
let cancelled = false;
|
|
33276
33792
|
const load = () => {
|
|
33277
33793
|
fetchForexRates("USD").then((r) => {
|
|
@@ -33308,7 +33824,7 @@ var init_useForex = __esm({
|
|
|
33308
33824
|
});
|
|
33309
33825
|
|
|
33310
33826
|
// src/modes/swap/components/SwapTokenSelect.tsx
|
|
33311
|
-
import { useState as
|
|
33827
|
+
import { useState as useState31, useMemo as useMemo26, useEffect as useEffect31 } from "react";
|
|
33312
33828
|
import { jsx as jsx55, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
33313
33829
|
function SwapTokenSelect({
|
|
33314
33830
|
side,
|
|
@@ -33324,10 +33840,10 @@ function SwapTokenSelect({
|
|
|
33324
33840
|
allowedTokens,
|
|
33325
33841
|
excludeToken
|
|
33326
33842
|
}) {
|
|
33327
|
-
const [localChain, setLocalChain] =
|
|
33328
|
-
const [pinnedTokens, setPinnedTokens] =
|
|
33329
|
-
const [pinnedLoading, setPinnedLoading] =
|
|
33330
|
-
|
|
33843
|
+
const [localChain, setLocalChain] = useState31(initialChain);
|
|
33844
|
+
const [pinnedTokens, setPinnedTokens] = useState31([]);
|
|
33845
|
+
const [pinnedLoading, setPinnedLoading] = useState31(false);
|
|
33846
|
+
useEffect31(() => {
|
|
33331
33847
|
if (!allowedTokens || allowedTokens.length === 0 || !localChain) {
|
|
33332
33848
|
setPinnedTokens([]);
|
|
33333
33849
|
return;
|
|
@@ -33629,8 +34145,8 @@ var init_currency = __esm({
|
|
|
33629
34145
|
});
|
|
33630
34146
|
|
|
33631
34147
|
// src/modes/swap/components/SwapWalletSelector/SwapWalletSelectorMobile.tsx
|
|
33632
|
-
import { useEffect as
|
|
33633
|
-
import { Fragment as
|
|
34148
|
+
import { useEffect as useEffect32, useMemo as useMemo27, useRef as useRef18, useState as useState32 } from "react";
|
|
34149
|
+
import { Fragment as Fragment10, jsx as jsx56, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
33634
34150
|
function SwapWalletSelectorMobile({
|
|
33635
34151
|
walletStatus,
|
|
33636
34152
|
walletAddress,
|
|
@@ -33647,14 +34163,14 @@ function SwapWalletSelectorMobile({
|
|
|
33647
34163
|
} = useWalletInfo();
|
|
33648
34164
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
33649
34165
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
33650
|
-
const [wcConnecting, setWcConnecting] =
|
|
33651
|
-
const [connectingId, setConnectingId] =
|
|
33652
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
33653
|
-
const prevStatusRef =
|
|
33654
|
-
const storeFallbackTimeoutRef =
|
|
34166
|
+
const [wcConnecting, setWcConnecting] = useState32(false);
|
|
34167
|
+
const [connectingId, setConnectingId] = useState32(null);
|
|
34168
|
+
const [selectedNamespace, setSelectedNamespace] = useState32("evm");
|
|
34169
|
+
const prevStatusRef = useRef18(walletStatus);
|
|
34170
|
+
const storeFallbackTimeoutRef = useRef18(
|
|
33655
34171
|
null
|
|
33656
34172
|
);
|
|
33657
|
-
|
|
34173
|
+
useEffect32(() => {
|
|
33658
34174
|
const prev = prevStatusRef.current;
|
|
33659
34175
|
if (prev !== walletStatus) {
|
|
33660
34176
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -33663,7 +34179,7 @@ function SwapWalletSelectorMobile({
|
|
|
33663
34179
|
prevStatusRef.current = walletStatus;
|
|
33664
34180
|
}
|
|
33665
34181
|
}, [walletStatus]);
|
|
33666
|
-
|
|
34182
|
+
useEffect32(() => {
|
|
33667
34183
|
return () => {
|
|
33668
34184
|
if (storeFallbackTimeoutRef.current !== null) {
|
|
33669
34185
|
clearTimeout(storeFallbackTimeoutRef.current);
|
|
@@ -33928,6 +34444,7 @@ function SwapWalletSelectorMobile({
|
|
|
33928
34444
|
const { meta } = entry;
|
|
33929
34445
|
const isWalletConnected = managerConnected && walletMetaId === meta.id;
|
|
33930
34446
|
const isConnecting = connectingId === meta.id && walletStatus === "connecting";
|
|
34447
|
+
const isRowDisabled = managerConnected && !isWalletConnected && !entry.detectedWallet;
|
|
33931
34448
|
return /* @__PURE__ */ jsxs44(
|
|
33932
34449
|
"div",
|
|
33933
34450
|
{
|
|
@@ -33945,7 +34462,8 @@ function SwapWalletSelectorMobile({
|
|
|
33945
34462
|
isWalletConnected && {
|
|
33946
34463
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
33947
34464
|
border: `1px solid ${colors.primary}`
|
|
33948
|
-
}
|
|
34465
|
+
},
|
|
34466
|
+
isRowDisabled && { opacity: 0.4 }
|
|
33949
34467
|
),
|
|
33950
34468
|
children: [
|
|
33951
34469
|
/* @__PURE__ */ jsx56(
|
|
@@ -34036,7 +34554,7 @@ function SwapWalletSelectorMobile({
|
|
|
34036
34554
|
"button",
|
|
34037
34555
|
{
|
|
34038
34556
|
onClick: () => void handleClick(entry),
|
|
34039
|
-
disabled: walletStatus === "connecting",
|
|
34557
|
+
disabled: walletStatus === "connecting" || isRowDisabled,
|
|
34040
34558
|
style: mergeStyles(
|
|
34041
34559
|
{
|
|
34042
34560
|
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
@@ -34049,7 +34567,7 @@ function SwapWalletSelectorMobile({
|
|
|
34049
34567
|
cursor: "pointer",
|
|
34050
34568
|
flexShrink: 0
|
|
34051
34569
|
},
|
|
34052
|
-
walletStatus === "connecting" && {
|
|
34570
|
+
(walletStatus === "connecting" || isRowDisabled) && {
|
|
34053
34571
|
opacity: 0.5,
|
|
34054
34572
|
cursor: "not-allowed"
|
|
34055
34573
|
}
|
|
@@ -34064,7 +34582,7 @@ function SwapWalletSelectorMobile({
|
|
|
34064
34582
|
})
|
|
34065
34583
|
}
|
|
34066
34584
|
),
|
|
34067
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(
|
|
34585
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(Fragment10, { children: [
|
|
34068
34586
|
/* @__PURE__ */ jsx56(
|
|
34069
34587
|
"div",
|
|
34070
34588
|
{
|
|
@@ -34077,6 +34595,7 @@ function SwapWalletSelectorMobile({
|
|
|
34077
34595
|
),
|
|
34078
34596
|
(() => {
|
|
34079
34597
|
const wcConnected = managerConnected && connectedVia === "walletconnect";
|
|
34598
|
+
const wcRowDisabled = managerConnected && !wcConnected;
|
|
34080
34599
|
return /* @__PURE__ */ jsxs44(
|
|
34081
34600
|
"div",
|
|
34082
34601
|
{
|
|
@@ -34095,9 +34614,10 @@ function SwapWalletSelectorMobile({
|
|
|
34095
34614
|
wcConnected && {
|
|
34096
34615
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
34097
34616
|
border: `1px solid ${colors.primary}`
|
|
34098
|
-
}
|
|
34617
|
+
},
|
|
34618
|
+
wcRowDisabled && { opacity: 0.4, cursor: "not-allowed" }
|
|
34099
34619
|
),
|
|
34100
|
-
onClick: !wcConnected ? () => void handleWalletConnect() : void 0,
|
|
34620
|
+
onClick: !wcConnected && !wcRowDisabled ? () => void handleWalletConnect() : void 0,
|
|
34101
34621
|
children: [
|
|
34102
34622
|
/* @__PURE__ */ jsx56(
|
|
34103
34623
|
"div",
|
|
@@ -34193,18 +34713,24 @@ function SwapWalletSelectorMobile({
|
|
|
34193
34713
|
e2.stopPropagation();
|
|
34194
34714
|
void handleWalletConnect();
|
|
34195
34715
|
},
|
|
34196
|
-
disabled: wcConnecting,
|
|
34197
|
-
style:
|
|
34198
|
-
|
|
34199
|
-
|
|
34200
|
-
|
|
34201
|
-
|
|
34202
|
-
|
|
34203
|
-
|
|
34204
|
-
|
|
34205
|
-
|
|
34206
|
-
|
|
34207
|
-
|
|
34716
|
+
disabled: wcConnecting || wcRowDisabled,
|
|
34717
|
+
style: mergeStyles(
|
|
34718
|
+
{
|
|
34719
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
34720
|
+
borderRadius: "9999px",
|
|
34721
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
34722
|
+
color: colors.primary,
|
|
34723
|
+
fontSize: fontSize.xs,
|
|
34724
|
+
fontWeight: fontWeight.medium,
|
|
34725
|
+
border: 0,
|
|
34726
|
+
cursor: "pointer",
|
|
34727
|
+
flexShrink: 0
|
|
34728
|
+
},
|
|
34729
|
+
(wcConnecting || wcRowDisabled) && {
|
|
34730
|
+
opacity: 0.5,
|
|
34731
|
+
cursor: "not-allowed"
|
|
34732
|
+
}
|
|
34733
|
+
),
|
|
34208
34734
|
children: "Connect"
|
|
34209
34735
|
}
|
|
34210
34736
|
)
|
|
@@ -34235,8 +34761,8 @@ var init_SwapWalletSelectorMobile = __esm({
|
|
|
34235
34761
|
});
|
|
34236
34762
|
|
|
34237
34763
|
// src/modes/swap/components/SwapWalletSelector/SwapWalletSelectorDesktop.tsx
|
|
34238
|
-
import { useEffect as
|
|
34239
|
-
import { Fragment as
|
|
34764
|
+
import { useEffect as useEffect33, useMemo as useMemo28, useRef as useRef19, useState as useState33 } from "react";
|
|
34765
|
+
import { Fragment as Fragment11, jsx as jsx57, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
34240
34766
|
function SwapWalletSelectorDesktop({
|
|
34241
34767
|
walletStatus,
|
|
34242
34768
|
walletAddress,
|
|
@@ -34252,16 +34778,16 @@ function SwapWalletSelectorDesktop({
|
|
|
34252
34778
|
} = useWalletInfo();
|
|
34253
34779
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
34254
34780
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
34255
|
-
const [wcConnecting, setWcConnecting] =
|
|
34256
|
-
const [connectingId, setConnectingId] =
|
|
34257
|
-
const [timerExpired, setTimerExpired] =
|
|
34258
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
34259
|
-
const prevStatusRef =
|
|
34260
|
-
|
|
34781
|
+
const [wcConnecting, setWcConnecting] = useState33(false);
|
|
34782
|
+
const [connectingId, setConnectingId] = useState33(null);
|
|
34783
|
+
const [timerExpired, setTimerExpired] = useState33(false);
|
|
34784
|
+
const [selectedNamespace, setSelectedNamespace] = useState33("evm");
|
|
34785
|
+
const prevStatusRef = useRef19(walletStatus);
|
|
34786
|
+
useEffect33(() => {
|
|
34261
34787
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
34262
34788
|
return () => clearTimeout(t);
|
|
34263
34789
|
}, []);
|
|
34264
|
-
|
|
34790
|
+
useEffect33(() => {
|
|
34265
34791
|
const prev = prevStatusRef.current;
|
|
34266
34792
|
if (prev !== walletStatus) {
|
|
34267
34793
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -34694,7 +35220,7 @@ function SwapWalletSelectorDesktop({
|
|
|
34694
35220
|
})
|
|
34695
35221
|
}
|
|
34696
35222
|
),
|
|
34697
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs45(
|
|
35223
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs45(Fragment11, { children: [
|
|
34698
35224
|
/* @__PURE__ */ jsx57(
|
|
34699
35225
|
"div",
|
|
34700
35226
|
{
|
|
@@ -34858,7 +35384,7 @@ var init_SwapWalletSelectorDesktop = __esm({
|
|
|
34858
35384
|
});
|
|
34859
35385
|
|
|
34860
35386
|
// src/modes/swap/components/SwapWalletSelector/index.tsx
|
|
34861
|
-
import { Fragment as
|
|
35387
|
+
import { Fragment as Fragment12, jsx as jsx58, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
34862
35388
|
function SwapWalletSelector({
|
|
34863
35389
|
walletStatus,
|
|
34864
35390
|
walletAddress,
|
|
@@ -34866,7 +35392,7 @@ function SwapWalletSelector({
|
|
|
34866
35392
|
onBack
|
|
34867
35393
|
}) {
|
|
34868
35394
|
const isMobile = useIsMobile();
|
|
34869
|
-
return /* @__PURE__ */ jsxs46(
|
|
35395
|
+
return /* @__PURE__ */ jsxs46(Fragment12, { children: [
|
|
34870
35396
|
isMobile && /* @__PURE__ */ jsx58(
|
|
34871
35397
|
SwapWalletSelectorMobile_default,
|
|
34872
35398
|
{
|
|
@@ -34911,13 +35437,13 @@ import {
|
|
|
34911
35437
|
lazy as lazy2,
|
|
34912
35438
|
Suspense as Suspense2,
|
|
34913
35439
|
useCallback as useCallback22,
|
|
34914
|
-
useEffect as
|
|
35440
|
+
useEffect as useEffect34,
|
|
34915
35441
|
useMemo as useMemo29,
|
|
34916
|
-
useRef as
|
|
34917
|
-
useState as
|
|
35442
|
+
useRef as useRef20,
|
|
35443
|
+
useState as useState34
|
|
34918
35444
|
} from "react";
|
|
34919
35445
|
import ReactDOM from "react-dom";
|
|
34920
|
-
import { Fragment as
|
|
35446
|
+
import { Fragment as Fragment13, jsx as jsx59, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
34921
35447
|
function fmtAmount(n, max = 6) {
|
|
34922
35448
|
if (!isFinite(n) || n === 0) return "0";
|
|
34923
35449
|
return n.toLocaleString(void 0, { maximumFractionDigits: max });
|
|
@@ -35009,36 +35535,36 @@ function SwapMode({
|
|
|
35009
35535
|
theme: themeProp,
|
|
35010
35536
|
style
|
|
35011
35537
|
}) {
|
|
35012
|
-
const [stage, setStage] =
|
|
35013
|
-
const [fromToken, setFromToken] =
|
|
35538
|
+
const [stage, setStage] = useState34("home");
|
|
35539
|
+
const [fromToken, setFromToken] = useState34(
|
|
35014
35540
|
null
|
|
35015
35541
|
);
|
|
35016
|
-
const [fromChain, setFromChain] =
|
|
35017
|
-
const [toToken, setToToken] =
|
|
35018
|
-
const [toChain, setToChain] =
|
|
35019
|
-
const [amount, setAmount] =
|
|
35020
|
-
const [amountInputMode, setAmountInputMode] =
|
|
35542
|
+
const [fromChain, setFromChain] = useState34(null);
|
|
35543
|
+
const [toToken, setToToken] = useState34(null);
|
|
35544
|
+
const [toChain, setToChain] = useState34(null);
|
|
35545
|
+
const [amount, setAmount] = useState34("");
|
|
35546
|
+
const [amountInputMode, setAmountInputMode] = useState34(
|
|
35021
35547
|
"usd"
|
|
35022
35548
|
);
|
|
35023
|
-
const [hoverSell, setHoverSell] =
|
|
35024
|
-
const [showRateDetails, setShowRateDetails] =
|
|
35025
|
-
const [showReviewDetails, setShowReviewDetails] =
|
|
35026
|
-
const [showSettings, setShowSettings] =
|
|
35027
|
-
const [maxApproval, setMaxApproval] =
|
|
35028
|
-
const [slippage, setSlippage] =
|
|
35029
|
-
const [slippageInput, setSlippageInput] =
|
|
35030
|
-
const [selectedCurrency, setSelectedCurrency] =
|
|
35031
|
-
const [showCurrencyDropdown, setShowCurrencyDropdown] =
|
|
35032
|
-
const [completedAt, setCompletedAt] =
|
|
35033
|
-
const [copiedHash, setCopiedHash] =
|
|
35034
|
-
const [rateUpdated, setRateUpdated] =
|
|
35035
|
-
const prevToAmountRef =
|
|
35036
|
-
const [destAddress, setDestAddress] =
|
|
35037
|
-
const [quoteAge, setQuoteAge] =
|
|
35038
|
-
const quoteTimestampRef =
|
|
35039
|
-
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] =
|
|
35040
|
-
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] =
|
|
35041
|
-
const latestFetchParamsRef =
|
|
35549
|
+
const [hoverSell, setHoverSell] = useState34(false);
|
|
35550
|
+
const [showRateDetails, setShowRateDetails] = useState34(false);
|
|
35551
|
+
const [showReviewDetails, setShowReviewDetails] = useState34(false);
|
|
35552
|
+
const [showSettings, setShowSettings] = useState34(false);
|
|
35553
|
+
const [maxApproval, setMaxApproval] = useState34(false);
|
|
35554
|
+
const [slippage, setSlippage] = useState34(0.5);
|
|
35555
|
+
const [slippageInput, setSlippageInput] = useState34("");
|
|
35556
|
+
const [selectedCurrency, setSelectedCurrency] = useState34("USD");
|
|
35557
|
+
const [showCurrencyDropdown, setShowCurrencyDropdown] = useState34(false);
|
|
35558
|
+
const [completedAt, setCompletedAt] = useState34(null);
|
|
35559
|
+
const [copiedHash, setCopiedHash] = useState34(null);
|
|
35560
|
+
const [rateUpdated, setRateUpdated] = useState34(false);
|
|
35561
|
+
const prevToAmountRef = useRef20(null);
|
|
35562
|
+
const [destAddress, setDestAddress] = useState34("");
|
|
35563
|
+
const [quoteAge, setQuoteAge] = useState34(0);
|
|
35564
|
+
const quoteTimestampRef = useRef20(null);
|
|
35565
|
+
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = useState34(0);
|
|
35566
|
+
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = useState34(true);
|
|
35567
|
+
const latestFetchParamsRef = useRef20(null);
|
|
35042
35568
|
const { rates: forexRates } = useForex();
|
|
35043
35569
|
const currencyMeta = getCurrencyMeta(selectedCurrency);
|
|
35044
35570
|
const currencyRate = forexRates[selectedCurrency] ?? 1;
|
|
@@ -35054,8 +35580,8 @@ function SwapMode({
|
|
|
35054
35580
|
},
|
|
35055
35581
|
[currencyRate, selectedCurrency]
|
|
35056
35582
|
);
|
|
35057
|
-
const settingsRef =
|
|
35058
|
-
const currencyDropdownRef =
|
|
35583
|
+
const settingsRef = useRef20(null);
|
|
35584
|
+
const currencyDropdownRef = useRef20(null);
|
|
35059
35585
|
const { emitEvent } = useTrustware();
|
|
35060
35586
|
const { features, theme: configTheme } = useTrustwareConfig();
|
|
35061
35587
|
const effectiveThemeSetting = themeProp ?? configTheme ?? "system";
|
|
@@ -35089,8 +35615,8 @@ function SwapMode({
|
|
|
35089
35615
|
() => [...popularChains, ...otherChains],
|
|
35090
35616
|
[popularChains, otherChains]
|
|
35091
35617
|
);
|
|
35092
|
-
const destInitialized =
|
|
35093
|
-
|
|
35618
|
+
const destInitialized = useRef20(false);
|
|
35619
|
+
useEffect34(() => {
|
|
35094
35620
|
if (!defaultDestRef || destInitialized.current || allChains.length === 0)
|
|
35095
35621
|
return;
|
|
35096
35622
|
const chain = allChains.find(
|
|
@@ -35120,7 +35646,7 @@ function SwapMode({
|
|
|
35120
35646
|
}).catch(() => {
|
|
35121
35647
|
});
|
|
35122
35648
|
}, [defaultDestRef, allChains]);
|
|
35123
|
-
const { walletAddress, walletStatus, connectWallet
|
|
35649
|
+
const { walletAddress, walletStatus, connectWallet } = useWalletSessionState();
|
|
35124
35650
|
const setFromTokenStable = useCallback22(
|
|
35125
35651
|
(t) => setFromToken(t),
|
|
35126
35652
|
[]
|
|
@@ -35495,13 +36021,13 @@ function SwapMode({
|
|
|
35495
36021
|
const hasAmount = rawSellNum > 0 && (amountInputMode === "token" || hasFromUsdPrice);
|
|
35496
36022
|
const isConnected = walletStatus === "connected" && !!walletAddress;
|
|
35497
36023
|
const canGetQuote = hasTokens && hasAmount && !insufficient && isConnected && (!needsDestAddress || isValidDestAddress);
|
|
35498
|
-
|
|
36024
|
+
useEffect34(() => {
|
|
35499
36025
|
if (!fromToken) return;
|
|
35500
36026
|
if (!hasFromUsdPrice && amountInputMode === "usd") {
|
|
35501
36027
|
setAmountInputMode("token");
|
|
35502
36028
|
}
|
|
35503
36029
|
}, [fromToken, hasFromUsdPrice, amountInputMode]);
|
|
35504
|
-
|
|
36030
|
+
useEffect34(() => {
|
|
35505
36031
|
if (displayToAmount === null) {
|
|
35506
36032
|
prevToAmountRef.current = null;
|
|
35507
36033
|
return;
|
|
@@ -35515,14 +36041,14 @@ function SwapMode({
|
|
|
35515
36041
|
const t = setTimeout(() => setRateUpdated(false), 700);
|
|
35516
36042
|
return () => clearTimeout(t);
|
|
35517
36043
|
}, [displayToAmount]);
|
|
35518
|
-
|
|
36044
|
+
useEffect34(() => {
|
|
35519
36045
|
setDestAddress("");
|
|
35520
36046
|
}, [toChainType]);
|
|
35521
|
-
const fetchRef =
|
|
35522
|
-
|
|
36047
|
+
const fetchRef = useRef20(route.fetch);
|
|
36048
|
+
useEffect34(() => {
|
|
35523
36049
|
fetchRef.current = route.fetch;
|
|
35524
36050
|
});
|
|
35525
|
-
|
|
36051
|
+
useEffect34(() => {
|
|
35526
36052
|
if (!canGetQuote || stage !== "home") return;
|
|
35527
36053
|
if (!fromToken || !fromChain || !toToken || !toChain || !walletAddress)
|
|
35528
36054
|
return;
|
|
@@ -35551,7 +36077,7 @@ function SwapMode({
|
|
|
35551
36077
|
destAddress,
|
|
35552
36078
|
slippage
|
|
35553
36079
|
]);
|
|
35554
|
-
|
|
36080
|
+
useEffect34(() => {
|
|
35555
36081
|
if (!canGetQuote || !fromToken || !fromChain || !toToken || !toChain || !walletAddress) {
|
|
35556
36082
|
latestFetchParamsRef.current = null;
|
|
35557
36083
|
return;
|
|
@@ -35578,12 +36104,12 @@ function SwapMode({
|
|
|
35578
36104
|
destAddress,
|
|
35579
36105
|
slippage
|
|
35580
36106
|
]);
|
|
35581
|
-
|
|
36107
|
+
useEffect34(() => {
|
|
35582
36108
|
quoteTimestampRef.current = route.data ? Date.now() : null;
|
|
35583
36109
|
setQuoteAge(0);
|
|
35584
36110
|
}, [route.data]);
|
|
35585
|
-
const msgTimeoutRef =
|
|
35586
|
-
|
|
36111
|
+
const msgTimeoutRef = useRef20(null);
|
|
36112
|
+
useEffect34(() => {
|
|
35587
36113
|
if (!route.loading) {
|
|
35588
36114
|
setQuoteLoadingMsgIdx(0);
|
|
35589
36115
|
setQuoteLoadingMsgVisible(true);
|
|
@@ -35601,7 +36127,7 @@ function SwapMode({
|
|
|
35601
36127
|
if (msgTimeoutRef.current !== null) clearTimeout(msgTimeoutRef.current);
|
|
35602
36128
|
};
|
|
35603
36129
|
}, [route.loading]);
|
|
35604
|
-
|
|
36130
|
+
useEffect34(() => {
|
|
35605
36131
|
if (!route.data) return;
|
|
35606
36132
|
const id = setInterval(() => {
|
|
35607
36133
|
const ts = quoteTimestampRef.current;
|
|
@@ -35615,7 +36141,7 @@ function SwapMode({
|
|
|
35615
36141
|
}, 1e3);
|
|
35616
36142
|
return () => clearInterval(id);
|
|
35617
36143
|
}, [route.data]);
|
|
35618
|
-
|
|
36144
|
+
useEffect34(() => {
|
|
35619
36145
|
if (stage !== "review") return;
|
|
35620
36146
|
if (!route.data || !walletAddress) return;
|
|
35621
36147
|
const fromTokenAddress = fromToken?.address;
|
|
@@ -35626,7 +36152,7 @@ function SwapMode({
|
|
|
35626
36152
|
routeResult: route.data
|
|
35627
36153
|
});
|
|
35628
36154
|
}, [stage, route.data, walletAddress, fromToken]);
|
|
35629
|
-
|
|
36155
|
+
useEffect34(() => {
|
|
35630
36156
|
if (!showSettings) {
|
|
35631
36157
|
setShowCurrencyDropdown(false);
|
|
35632
36158
|
return;
|
|
@@ -35639,7 +36165,7 @@ function SwapMode({
|
|
|
35639
36165
|
document.addEventListener("mousedown", handler);
|
|
35640
36166
|
return () => document.removeEventListener("mousedown", handler);
|
|
35641
36167
|
}, [showSettings]);
|
|
35642
|
-
|
|
36168
|
+
useEffect34(() => {
|
|
35643
36169
|
if (!showCurrencyDropdown) return;
|
|
35644
36170
|
const handler = (e2) => {
|
|
35645
36171
|
if (currencyDropdownRef.current && !currencyDropdownRef.current.contains(e2.target)) {
|
|
@@ -36126,7 +36652,7 @@ function SwapMode({
|
|
|
36126
36652
|
padding: 0,
|
|
36127
36653
|
transition: "color 0.15s"
|
|
36128
36654
|
},
|
|
36129
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs47(
|
|
36655
|
+
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs47(Fragment13, { children: [
|
|
36130
36656
|
txHash.slice(0, 6),
|
|
36131
36657
|
"\u2026",
|
|
36132
36658
|
txHash.slice(-4),
|
|
@@ -37198,7 +37724,7 @@ function SwapMode({
|
|
|
37198
37724
|
walletAddress ? /* @__PURE__ */ jsxs47(
|
|
37199
37725
|
"button",
|
|
37200
37726
|
{
|
|
37201
|
-
onClick:
|
|
37727
|
+
onClick: handleConnectAndReview,
|
|
37202
37728
|
style: {
|
|
37203
37729
|
fontSize: fontSize.xs,
|
|
37204
37730
|
color: colors.mutedForeground,
|
|
@@ -37209,8 +37735,7 @@ function SwapMode({
|
|
|
37209
37735
|
children: [
|
|
37210
37736
|
walletAddress.slice(0, 6),
|
|
37211
37737
|
"...",
|
|
37212
|
-
walletAddress.slice(-4)
|
|
37213
|
-
" \xD7"
|
|
37738
|
+
walletAddress.slice(-4)
|
|
37214
37739
|
]
|
|
37215
37740
|
}
|
|
37216
37741
|
) : /* @__PURE__ */ jsx59(
|
|
@@ -38789,8 +39314,8 @@ function ReviewDetailRow({
|
|
|
38789
39314
|
value,
|
|
38790
39315
|
tooltip
|
|
38791
39316
|
}) {
|
|
38792
|
-
const iconRef =
|
|
38793
|
-
const [tipPos, setTipPos] =
|
|
39317
|
+
const iconRef = useRef20(null);
|
|
39318
|
+
const [tipPos, setTipPos] = useState34(null);
|
|
38794
39319
|
const handleMouseEnter = () => {
|
|
38795
39320
|
if (!tooltip || !iconRef.current) return;
|
|
38796
39321
|
const r = iconRef.current.getBoundingClientRect();
|
|
@@ -39125,14 +39650,14 @@ var init_swap = __esm({
|
|
|
39125
39650
|
|
|
39126
39651
|
// src/widget/TrustwareWidgetV2.tsx
|
|
39127
39652
|
import {
|
|
39128
|
-
useState as
|
|
39129
|
-
useEffect as
|
|
39130
|
-
useRef as
|
|
39653
|
+
useState as useState35,
|
|
39654
|
+
useEffect as useEffect35,
|
|
39655
|
+
useRef as useRef21,
|
|
39131
39656
|
useCallback as useCallback23,
|
|
39132
39657
|
useImperativeHandle,
|
|
39133
39658
|
forwardRef
|
|
39134
39659
|
} from "react";
|
|
39135
|
-
import { Fragment as
|
|
39660
|
+
import { Fragment as Fragment14, jsx as jsx60, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
39136
39661
|
function WidgetContent({
|
|
39137
39662
|
style,
|
|
39138
39663
|
onStateChange,
|
|
@@ -39143,7 +39668,7 @@ function WidgetContent({
|
|
|
39143
39668
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
39144
39669
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
39145
39670
|
useWalletExternalDisconnect(() => setCurrentStep("home"));
|
|
39146
|
-
|
|
39671
|
+
useEffect35(() => {
|
|
39147
39672
|
const state = {
|
|
39148
39673
|
currentStep,
|
|
39149
39674
|
amount,
|
|
@@ -39186,7 +39711,7 @@ function WidgetInner({
|
|
|
39186
39711
|
const { transactionStatus } = useDepositTransaction();
|
|
39187
39712
|
const { resolvedTheme } = useDepositUi();
|
|
39188
39713
|
const { status, revalidate, errors } = useTrustware();
|
|
39189
|
-
const [showConfirmDialog, setShowConfirmDialog] =
|
|
39714
|
+
const [showConfirmDialog, setShowConfirmDialog] = useState35(false);
|
|
39190
39715
|
const handleCloseRequest = useCallback23(() => {
|
|
39191
39716
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
39192
39717
|
setShowConfirmDialog(true);
|
|
@@ -39198,7 +39723,7 @@ function WidgetInner({
|
|
|
39198
39723
|
onClose?.();
|
|
39199
39724
|
}
|
|
39200
39725
|
}, [transactionStatus, onClose, resetState]);
|
|
39201
|
-
|
|
39726
|
+
useEffect35(() => {
|
|
39202
39727
|
closeRequestRef.current = handleCloseRequest;
|
|
39203
39728
|
}, [handleCloseRequest, closeRequestRef]);
|
|
39204
39729
|
const handleConfirmClose = useCallback23(() => {
|
|
@@ -39214,7 +39739,7 @@ function WidgetInner({
|
|
|
39214
39739
|
const handleRefresh = useCallback23(() => {
|
|
39215
39740
|
revalidate?.();
|
|
39216
39741
|
}, [revalidate]);
|
|
39217
|
-
return /* @__PURE__ */ jsxs48(
|
|
39742
|
+
return /* @__PURE__ */ jsxs48(Fragment14, { children: [
|
|
39218
39743
|
/* @__PURE__ */ jsxs48(WidgetContainer, { theme: effectiveTheme, style, children: [
|
|
39219
39744
|
/* @__PURE__ */ jsx60(
|
|
39220
39745
|
WidgetContent,
|
|
@@ -39282,8 +39807,8 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
39282
39807
|
onOpen,
|
|
39283
39808
|
showThemeToggle = true
|
|
39284
39809
|
}, ref) {
|
|
39285
|
-
const [isOpen, setIsOpen] =
|
|
39286
|
-
const closeRequestRef =
|
|
39810
|
+
const [isOpen, setIsOpen] = useState35(defaultOpen);
|
|
39811
|
+
const closeRequestRef = useRef21(null);
|
|
39287
39812
|
const config = useTrustwareConfig();
|
|
39288
39813
|
const effectiveInitialStep = initialStep;
|
|
39289
39814
|
const open = useCallback23(() => {
|
|
@@ -39314,7 +39839,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
39314
39839
|
if (!isOpen) {
|
|
39315
39840
|
return null;
|
|
39316
39841
|
}
|
|
39317
|
-
if (config.
|
|
39842
|
+
if (config.mode === "swap") {
|
|
39318
39843
|
return /* @__PURE__ */ jsx60(SwapMode, { theme, style });
|
|
39319
39844
|
}
|
|
39320
39845
|
return /* @__PURE__ */ jsx60(DepositProvider, { initialStep: effectiveInitialStep, children: /* @__PURE__ */ jsx60(
|
|
@@ -39444,6 +39969,7 @@ export {
|
|
|
39444
39969
|
useWireDetectionIntoManager,
|
|
39445
39970
|
validateAddressForChain,
|
|
39446
39971
|
validateBtcAddress,
|
|
39972
|
+
validateCosmosAddress,
|
|
39447
39973
|
validateEvmAddress,
|
|
39448
39974
|
validateRouteAddresses,
|
|
39449
39975
|
validateSeiAddress,
|