@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/widget.mjs
CHANGED
|
@@ -563,7 +563,7 @@ var init_constants = __esm({
|
|
|
563
563
|
"src/constants.ts"() {
|
|
564
564
|
"use strict";
|
|
565
565
|
SDK_NAME = "@trustware/sdk";
|
|
566
|
-
SDK_VERSION = "1.1.9-staging.
|
|
566
|
+
SDK_VERSION = "1.1.9-staging.7";
|
|
567
567
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
568
568
|
GTM_ID = "GTM-TZDGNCXB";
|
|
569
569
|
API_PREFIX = "/api";
|
|
@@ -774,7 +774,9 @@ var init_chains = __esm({
|
|
|
774
774
|
btc: "bitcoin",
|
|
775
775
|
bitcoin: "bitcoin",
|
|
776
776
|
sei: "cosmos",
|
|
777
|
-
"pacific-1": "cosmos"
|
|
777
|
+
"pacific-1": "cosmos",
|
|
778
|
+
nibiru: "cosmos",
|
|
779
|
+
"cataclysm-1": "cosmos"
|
|
778
780
|
};
|
|
779
781
|
}
|
|
780
782
|
});
|
|
@@ -1971,16 +1973,23 @@ function validateEvmAddress(address) {
|
|
|
1971
1973
|
}
|
|
1972
1974
|
return { isValid: true };
|
|
1973
1975
|
}
|
|
1974
|
-
function
|
|
1976
|
+
function resolveCosmosBech32Prefix(chain) {
|
|
1977
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
1978
|
+
const identifier = chainDef?.networkIdentifier ?? chainDef?.chainId ?? chainDef?.id ?? (typeof chain === "string" ? chain : void 0);
|
|
1979
|
+
const normalized = String(identifier ?? "").trim().toLowerCase();
|
|
1980
|
+
return COSMOS_BECH32_PREFIX_BY_CHAIN_ID[normalized] ?? "sei";
|
|
1981
|
+
}
|
|
1982
|
+
function validateCosmosAddress(address, chain) {
|
|
1975
1983
|
const trimmed = address.trim();
|
|
1976
|
-
|
|
1984
|
+
const prefix = resolveCosmosBech32Prefix(chain);
|
|
1985
|
+
if (prefix === "sei" && isEvmAddress(trimmed)) {
|
|
1977
1986
|
return { isValid: true };
|
|
1978
1987
|
}
|
|
1979
|
-
const result = validateBech32LikeAddress(trimmed,
|
|
1988
|
+
const result = validateBech32LikeAddress(trimmed, prefix);
|
|
1980
1989
|
if (result.isValid) return result;
|
|
1981
1990
|
return {
|
|
1982
1991
|
isValid: false,
|
|
1983
|
-
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
1992
|
+
error: prefix === "sei" ? "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings." : `Address must be a valid ${prefix}1 bech32 string.`
|
|
1984
1993
|
};
|
|
1985
1994
|
}
|
|
1986
1995
|
function validateSolanaAddress(address) {
|
|
@@ -2030,15 +2039,12 @@ function validateAddressForChain(address, chain) {
|
|
|
2030
2039
|
case "bitcoin":
|
|
2031
2040
|
return validateBtcAddress(trimmed);
|
|
2032
2041
|
case "cosmos":
|
|
2033
|
-
|
|
2034
|
-
return validateSeiAddress(trimmed);
|
|
2035
|
-
}
|
|
2036
|
-
return validateBech32LikeAddress(trimmed, "sei");
|
|
2042
|
+
return validateCosmosAddress(trimmed, chainDef ?? chain);
|
|
2037
2043
|
default:
|
|
2038
2044
|
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
2039
2045
|
}
|
|
2040
2046
|
}
|
|
2041
|
-
function validateAddressForRouteChain(address, chainType) {
|
|
2047
|
+
function validateAddressForRouteChain(address, chainType, chainRef) {
|
|
2042
2048
|
switch (normalizeChainType(chainType)) {
|
|
2043
2049
|
case "evm":
|
|
2044
2050
|
return validateEvmAddress(address);
|
|
@@ -2047,7 +2053,7 @@ function validateAddressForRouteChain(address, chainType) {
|
|
|
2047
2053
|
case "bitcoin":
|
|
2048
2054
|
return validateBtcAddress(address);
|
|
2049
2055
|
case "cosmos":
|
|
2050
|
-
return
|
|
2056
|
+
return validateCosmosAddress(address, chainRef ?? chainType);
|
|
2051
2057
|
default:
|
|
2052
2058
|
return { isValid: false, error: "Unsupported chain type." };
|
|
2053
2059
|
}
|
|
@@ -2069,14 +2075,18 @@ function validateRouteAddresses(params) {
|
|
|
2069
2075
|
const normalizedDirection = params.direction?.trim().toLowerCase();
|
|
2070
2076
|
const isDepositFlow = normalizedDirection === "deposit" || (toType === "evm" || toType === "cosmos") && (fromType === "bitcoin" || fromType === "solana");
|
|
2071
2077
|
if (isDepositFlow) {
|
|
2072
|
-
const fromResult2 = validateAddressForRouteChain(
|
|
2078
|
+
const fromResult2 = validateAddressForRouteChain(
|
|
2079
|
+
fromAddress,
|
|
2080
|
+
fromType,
|
|
2081
|
+
params.fromChain
|
|
2082
|
+
);
|
|
2073
2083
|
if (!fromResult2.isValid) {
|
|
2074
2084
|
return {
|
|
2075
2085
|
isValid: false,
|
|
2076
2086
|
error: `From address: ${fromResult2.error ?? "Invalid address."}`
|
|
2077
2087
|
};
|
|
2078
2088
|
}
|
|
2079
|
-
const toResult2 = toType === "cosmos" ?
|
|
2089
|
+
const toResult2 = toType === "cosmos" ? validateCosmosAddress(toAddress, params.toChain) : validateEvmAddress(toAddress);
|
|
2080
2090
|
if (!toResult2.isValid) {
|
|
2081
2091
|
return {
|
|
2082
2092
|
isValid: false,
|
|
@@ -2101,14 +2111,22 @@ function validateRouteAddresses(params) {
|
|
|
2101
2111
|
}
|
|
2102
2112
|
return { isValid: true };
|
|
2103
2113
|
}
|
|
2104
|
-
const fromResult = validateAddressForRouteChain(
|
|
2114
|
+
const fromResult = validateAddressForRouteChain(
|
|
2115
|
+
fromAddress,
|
|
2116
|
+
fromType,
|
|
2117
|
+
params.fromChain
|
|
2118
|
+
);
|
|
2105
2119
|
if (!fromResult.isValid) {
|
|
2106
2120
|
return {
|
|
2107
2121
|
isValid: false,
|
|
2108
2122
|
error: `From address: ${fromResult.error ?? "Invalid address."}`
|
|
2109
2123
|
};
|
|
2110
2124
|
}
|
|
2111
|
-
const toResult = validateAddressForRouteChain(
|
|
2125
|
+
const toResult = validateAddressForRouteChain(
|
|
2126
|
+
toAddress,
|
|
2127
|
+
toType,
|
|
2128
|
+
params.toChain
|
|
2129
|
+
);
|
|
2112
2130
|
if (!toResult.isValid) {
|
|
2113
2131
|
return {
|
|
2114
2132
|
isValid: false,
|
|
@@ -2117,13 +2135,19 @@ function validateRouteAddresses(params) {
|
|
|
2117
2135
|
}
|
|
2118
2136
|
return { isValid: true };
|
|
2119
2137
|
}
|
|
2120
|
-
var BECH32_CHARSET;
|
|
2138
|
+
var BECH32_CHARSET, COSMOS_BECH32_PREFIX_BY_CHAIN_ID;
|
|
2121
2139
|
var init_address = __esm({
|
|
2122
2140
|
"src/validation/address.ts"() {
|
|
2123
2141
|
"use strict";
|
|
2124
2142
|
init_index_node4();
|
|
2125
2143
|
init_chains();
|
|
2126
2144
|
BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
2145
|
+
COSMOS_BECH32_PREFIX_BY_CHAIN_ID = {
|
|
2146
|
+
"pacific-1": "sei",
|
|
2147
|
+
sei: "sei",
|
|
2148
|
+
"cataclysm-1": "nibi",
|
|
2149
|
+
nibiru: "nibi"
|
|
2150
|
+
};
|
|
2127
2151
|
}
|
|
2128
2152
|
});
|
|
2129
2153
|
|
|
@@ -2515,7 +2539,7 @@ async function buildDepositAddress(body, signal) {
|
|
|
2515
2539
|
route
|
|
2516
2540
|
};
|
|
2517
2541
|
}
|
|
2518
|
-
async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
2542
|
+
async function submitReceipt(intentId, txHash, sponsorshipRequestId, eoaAddress) {
|
|
2519
2543
|
const r = await rateLimitedFetch(
|
|
2520
2544
|
`${apiBase()}/v1/route-intent/${intentId}/receipt`,
|
|
2521
2545
|
{
|
|
@@ -2523,7 +2547,8 @@ async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
|
2523
2547
|
headers: jsonHeaders({ "Idempotency-Key": txHash }),
|
|
2524
2548
|
body: JSON.stringify({
|
|
2525
2549
|
txHash,
|
|
2526
|
-
...sponsorshipRequestId ? { sponsorshipRequestId } : {}
|
|
2550
|
+
...sponsorshipRequestId ? { sponsorshipRequestId } : {},
|
|
2551
|
+
...eoaAddress ? { eoaAddress } : {}
|
|
2527
2552
|
})
|
|
2528
2553
|
}
|
|
2529
2554
|
);
|
|
@@ -2833,6 +2858,7 @@ function useTrustwareConfig() {
|
|
|
2833
2858
|
} catch {
|
|
2834
2859
|
return {
|
|
2835
2860
|
apiKey: "",
|
|
2861
|
+
mode: "deposit",
|
|
2836
2862
|
routes: {
|
|
2837
2863
|
toChain: "",
|
|
2838
2864
|
toToken: "",
|
|
@@ -3095,7 +3121,9 @@ var init_chainHelpers = __esm({
|
|
|
3095
3121
|
btc: "bitcoin",
|
|
3096
3122
|
bitcoin: "bitcoin",
|
|
3097
3123
|
sei: "cosmos",
|
|
3098
|
-
"pacific-1": "cosmos"
|
|
3124
|
+
"pacific-1": "cosmos",
|
|
3125
|
+
nibiru: "cosmos",
|
|
3126
|
+
"cataclysm-1": "cosmos"
|
|
3099
3127
|
};
|
|
3100
3128
|
SEI_EVM_CHAIN_ID = "1329";
|
|
3101
3129
|
SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
@@ -3311,7 +3339,8 @@ function filterSupportedChains(chains) {
|
|
|
3311
3339
|
}
|
|
3312
3340
|
if (chainType === "cosmos") {
|
|
3313
3341
|
const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
|
|
3314
|
-
|
|
3342
|
+
const isNibiru = normalizeChainKey2(chain.chainId ?? chain.id) === NIBIRU_COSMOS_CHAIN_ID;
|
|
3343
|
+
if (seiKey !== "sei" && !isNibiru) {
|
|
3315
3344
|
return false;
|
|
3316
3345
|
}
|
|
3317
3346
|
}
|
|
@@ -3411,7 +3440,7 @@ function useChains() {
|
|
|
3411
3440
|
error
|
|
3412
3441
|
};
|
|
3413
3442
|
}
|
|
3414
|
-
var POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT;
|
|
3443
|
+
var POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT, NIBIRU_COSMOS_CHAIN_ID;
|
|
3415
3444
|
var init_useChains = __esm({
|
|
3416
3445
|
"src/core/useChains.ts"() {
|
|
3417
3446
|
"use strict";
|
|
@@ -3421,6 +3450,7 @@ var init_useChains = __esm({
|
|
|
3421
3450
|
init_popularChains();
|
|
3422
3451
|
POPULAR_CHAINS_BY_TVL = popularChains_default.byTvl;
|
|
3423
3452
|
POPULAR_LIMIT = popularChains_default.popularLimit;
|
|
3453
|
+
NIBIRU_COSMOS_CHAIN_ID = "cataclysm-1";
|
|
3424
3454
|
}
|
|
3425
3455
|
});
|
|
3426
3456
|
|
|
@@ -6213,21 +6243,28 @@ function formatDeepLink(id, currentUrl) {
|
|
|
6213
6243
|
const enc = encodeURIComponent(currentUrl);
|
|
6214
6244
|
switch (id) {
|
|
6215
6245
|
// EVM
|
|
6246
|
+
// MetaMask's dapp browser also exposes its Wallet Standard Solana
|
|
6247
|
+
// provider in the same session, so "metamask-solana" reuses this link.
|
|
6216
6248
|
case "metamask":
|
|
6249
|
+
case "metamask-solana":
|
|
6217
6250
|
return `metamask://dapp/${currentUrl}`;
|
|
6218
6251
|
case "coinbase":
|
|
6219
6252
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
6220
6253
|
case "rainbow":
|
|
6221
|
-
return `rainbow
|
|
6254
|
+
return `https://rainbow.me/dapp?url=${enc}`;
|
|
6222
6255
|
case "trust":
|
|
6223
6256
|
return `https://link.trustwallet.com/open_url?coin_id=60&url=${enc}`;
|
|
6224
6257
|
case "okx":
|
|
6225
6258
|
return `okx://wallet/dapp/url?dappUrl=${enc}`;
|
|
6226
6259
|
// Solana
|
|
6260
|
+
// Phantom is one app with one in-app browser — browsing there injects
|
|
6261
|
+
// both window.ethereum and window.phantom.solana, so "phantom-evm"
|
|
6262
|
+
// reuses the same browse link as "phantom-solana".
|
|
6227
6263
|
case "phantom-solana":
|
|
6228
|
-
|
|
6264
|
+
case "phantom-evm":
|
|
6265
|
+
return `https://phantom.app/ul/browse/${enc}?ref=${enc}`;
|
|
6229
6266
|
case "solflare":
|
|
6230
|
-
return `solflare
|
|
6267
|
+
return `https://solflare.com/ul/v1/browse/${enc}?ref=${enc}`;
|
|
6231
6268
|
case "backpack":
|
|
6232
6269
|
return `https://backpack.app/ul/v1/browse/${enc}?ref=${enc}`;
|
|
6233
6270
|
// No confirmed deep link scheme
|
|
@@ -6337,8 +6374,10 @@ var init_metadata = __esm({
|
|
|
6337
6374
|
homepage: "https://phantom.app/",
|
|
6338
6375
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
6339
6376
|
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
6340
|
-
detectFlags: ["isPhantom"]
|
|
6341
|
-
//
|
|
6377
|
+
detectFlags: ["isPhantom"],
|
|
6378
|
+
// Same app/in-app browser as "phantom-solana" — browsing there injects
|
|
6379
|
+
// window.ethereum too.
|
|
6380
|
+
deepLink: (url) => formatDeepLink("phantom-evm", url) ?? ""
|
|
6342
6381
|
},
|
|
6343
6382
|
{
|
|
6344
6383
|
id: "phantom-solana",
|
|
@@ -6386,8 +6425,10 @@ var init_metadata = __esm({
|
|
|
6386
6425
|
emoji: "\u{1F98A}",
|
|
6387
6426
|
homepage: "https://metamask.io/",
|
|
6388
6427
|
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
6389
|
-
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
6390
|
-
//
|
|
6428
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
6429
|
+
// Same app/in-app browser as "metamask" — its Wallet Standard Solana
|
|
6430
|
+
// provider is exposed in that same browse session.
|
|
6431
|
+
deepLink: (url) => formatDeepLink("metamask-solana", url) ?? ""
|
|
6391
6432
|
},
|
|
6392
6433
|
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
6393
6434
|
{
|
|
@@ -6898,7 +6939,7 @@ var init_walletconnect = __esm({
|
|
|
6898
6939
|
solanaMainnet = {
|
|
6899
6940
|
id: 900,
|
|
6900
6941
|
chainNamespace: "solana",
|
|
6901
|
-
caipNetworkId: "solana:
|
|
6942
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
6902
6943
|
name: "Solana Mainnet",
|
|
6903
6944
|
nativeCurrency: {
|
|
6904
6945
|
name: "Solana",
|
|
@@ -7777,8 +7818,62 @@ function getChainMeta(chainId) {
|
|
|
7777
7818
|
rpcUrls: chain.rpcUrls.default.http
|
|
7778
7819
|
};
|
|
7779
7820
|
}
|
|
7780
|
-
|
|
7821
|
+
function extractSolanaAddress(connector) {
|
|
7822
|
+
const caipAccount = connector.provider.session?.namespaces?.solana?.accounts?.[0];
|
|
7823
|
+
if (!caipAccount) return null;
|
|
7824
|
+
return caipAccount.split(":")[2] ?? null;
|
|
7825
|
+
}
|
|
7826
|
+
function buildWalletConnectSolanaProvider(connector) {
|
|
7827
|
+
return {
|
|
7828
|
+
get publicKey() {
|
|
7829
|
+
const address = extractSolanaAddress(connector);
|
|
7830
|
+
return address ? { toString: () => address } : void 0;
|
|
7831
|
+
},
|
|
7832
|
+
async connect() {
|
|
7833
|
+
const address = extractSolanaAddress(connector);
|
|
7834
|
+
if (!address) {
|
|
7835
|
+
throw new Error(
|
|
7836
|
+
"This wallet did not approve a Solana account over WalletConnect."
|
|
7837
|
+
);
|
|
7838
|
+
}
|
|
7839
|
+
return { publicKey: { toString: () => address } };
|
|
7840
|
+
},
|
|
7841
|
+
async disconnect() {
|
|
7842
|
+
},
|
|
7843
|
+
async signTransaction(transaction) {
|
|
7844
|
+
const tx = transaction;
|
|
7845
|
+
const rawBytes = "version" in tx ? tx.serialize() : tx.serialize({
|
|
7846
|
+
requireAllSignatures: false,
|
|
7847
|
+
verifySignatures: false
|
|
7848
|
+
});
|
|
7849
|
+
const result = await connector.provider.request(
|
|
7850
|
+
{
|
|
7851
|
+
method: "solana_signTransaction",
|
|
7852
|
+
params: { transaction: encodeBase64(rawBytes) }
|
|
7853
|
+
},
|
|
7854
|
+
solanaMainnet.caipNetworkId
|
|
7855
|
+
);
|
|
7856
|
+
if (!result.transaction) {
|
|
7857
|
+
throw new Error(
|
|
7858
|
+
"WalletConnect wallet did not return a signed Solana transaction."
|
|
7859
|
+
);
|
|
7860
|
+
}
|
|
7861
|
+
const signedBytes = decodeBase64(result.transaction);
|
|
7862
|
+
return { serialize: () => signedBytes };
|
|
7863
|
+
},
|
|
7864
|
+
on() {
|
|
7865
|
+
},
|
|
7866
|
+
off() {
|
|
7867
|
+
},
|
|
7868
|
+
removeListener() {
|
|
7869
|
+
}
|
|
7870
|
+
};
|
|
7871
|
+
}
|
|
7872
|
+
async function buildWalletConnectAPI(walletCfg, ecosystem = "evm") {
|
|
7781
7873
|
const connector = await getUniversalConnector(walletCfg);
|
|
7874
|
+
if (ecosystem === "solana") {
|
|
7875
|
+
return toSolanaWalletInterface(buildWalletConnectSolanaProvider(connector));
|
|
7876
|
+
}
|
|
7782
7877
|
const provider = connector.provider;
|
|
7783
7878
|
const api = {
|
|
7784
7879
|
ecosystem: "evm",
|
|
@@ -7848,7 +7943,7 @@ function bindWalletConnectEvents(provider, callbacks) {
|
|
|
7848
7943
|
function useWalletConnectConnect(walletCfg) {
|
|
7849
7944
|
const cfgRef = { current: walletCfg };
|
|
7850
7945
|
return useCallback4(
|
|
7851
|
-
() => walletManager.connectWalletConnect(cfgRef.current),
|
|
7946
|
+
(ecosystem) => walletManager.connectWalletConnect(cfgRef.current, ecosystem),
|
|
7852
7947
|
[]
|
|
7853
7948
|
);
|
|
7854
7949
|
}
|
|
@@ -7868,6 +7963,7 @@ function useWalletInfo(wagmi) {
|
|
|
7868
7963
|
connectedVia: snapshot.connectedVia,
|
|
7869
7964
|
walletType: snapshot.walletType,
|
|
7870
7965
|
status: snapshot.status,
|
|
7966
|
+
detected: snapshot.detected,
|
|
7871
7967
|
disconnect
|
|
7872
7968
|
};
|
|
7873
7969
|
}
|
|
@@ -8018,44 +8114,39 @@ var init_manager = __esm({
|
|
|
8018
8114
|
this.emit();
|
|
8019
8115
|
}
|
|
8020
8116
|
}
|
|
8021
|
-
async connectWalletConnect(walletCfg) {
|
|
8022
|
-
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet) {
|
|
8117
|
+
async connectWalletConnect(walletCfg, ecosystem = "evm") {
|
|
8118
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet && this._wallet.ecosystem === ecosystem) {
|
|
8023
8119
|
this.emit();
|
|
8024
8120
|
return { error: null, api: this._wallet };
|
|
8025
8121
|
}
|
|
8122
|
+
if (this._connectedVia === "walletconnect" && this._wallet) {
|
|
8123
|
+
await this._wallet.disconnect?.().catch(() => {
|
|
8124
|
+
});
|
|
8125
|
+
resetUniversalConnector();
|
|
8126
|
+
}
|
|
8026
8127
|
this._status = "connecting";
|
|
8027
8128
|
this.clearConnectedState();
|
|
8028
8129
|
this.emit();
|
|
8029
8130
|
try {
|
|
8030
8131
|
const connector = await getUniversalConnector(walletCfg);
|
|
8031
8132
|
await connector.connect();
|
|
8032
|
-
const api = await buildWalletConnectAPI(walletCfg);
|
|
8133
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
8134
|
+
try {
|
|
8135
|
+
await api.getAddress();
|
|
8136
|
+
} catch {
|
|
8137
|
+
await api.disconnect?.().catch(() => {
|
|
8138
|
+
});
|
|
8139
|
+
resetUniversalConnector();
|
|
8140
|
+
throw new Error(
|
|
8141
|
+
`This wallet did not approve a${ecosystem === "evm" ? "n" : ""} ${ecosystem === "evm" ? "EVM" : "Solana"} account over WalletConnect.`
|
|
8142
|
+
);
|
|
8143
|
+
}
|
|
8033
8144
|
this._wallet = api;
|
|
8034
8145
|
this._connectedVia = "walletconnect";
|
|
8035
8146
|
this._connectedWalletId = "walletconnect";
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
if (accounts.length === 0) {
|
|
8040
|
-
this.fullReset();
|
|
8041
|
-
this.triggerExternalDisconnect();
|
|
8042
|
-
this.emit();
|
|
8043
|
-
return;
|
|
8044
|
-
}
|
|
8045
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
8046
|
-
this.emit();
|
|
8047
|
-
},
|
|
8048
|
-
onChainChanged: () => {
|
|
8049
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
8050
|
-
this.emit();
|
|
8051
|
-
},
|
|
8052
|
-
onDisconnect: () => {
|
|
8053
|
-
this.fullReset();
|
|
8054
|
-
resetUniversalConnector();
|
|
8055
|
-
this.triggerExternalDisconnect();
|
|
8056
|
-
this.emit();
|
|
8057
|
-
}
|
|
8058
|
-
});
|
|
8147
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
8148
|
+
connector.provider
|
|
8149
|
+
);
|
|
8059
8150
|
await this.syncIdentityFromWallet("walletconnect");
|
|
8060
8151
|
this._status = "connected";
|
|
8061
8152
|
this._error = null;
|
|
@@ -8070,6 +8161,100 @@ var init_manager = __esm({
|
|
|
8070
8161
|
return { error: message, api: null };
|
|
8071
8162
|
}
|
|
8072
8163
|
}
|
|
8164
|
+
bindWalletConnectProviderEvents(provider) {
|
|
8165
|
+
return bindWalletConnectEvents(provider, {
|
|
8166
|
+
onAccountsChanged: (accounts) => {
|
|
8167
|
+
if (accounts.length === 0) {
|
|
8168
|
+
this.fullReset();
|
|
8169
|
+
this.triggerExternalDisconnect();
|
|
8170
|
+
this.emit();
|
|
8171
|
+
return;
|
|
8172
|
+
}
|
|
8173
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
8174
|
+
this.emit();
|
|
8175
|
+
},
|
|
8176
|
+
onChainChanged: () => {
|
|
8177
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
8178
|
+
this.emit();
|
|
8179
|
+
},
|
|
8180
|
+
onDisconnect: () => {
|
|
8181
|
+
this.fullReset();
|
|
8182
|
+
resetUniversalConnector();
|
|
8183
|
+
this.triggerExternalDisconnect();
|
|
8184
|
+
this.emit();
|
|
8185
|
+
}
|
|
8186
|
+
});
|
|
8187
|
+
}
|
|
8188
|
+
// WalletConnect's own SignClient auto-restores the last persisted session
|
|
8189
|
+
// from storage on every init — including after a fresh page load — but
|
|
8190
|
+
// that restoration happens silently inside the library. Nothing calls back
|
|
8191
|
+
// into our code for it. On mobile, backgrounding the tab to approve in a
|
|
8192
|
+
// wallet app can cause the OS to reload the page before the original
|
|
8193
|
+
// connect() promise ever resolves, so the connect flow that triggered the
|
|
8194
|
+
// approval never gets to record it as "connected" here — even though
|
|
8195
|
+
// WalletConnect itself already has a live, approved session sitting in
|
|
8196
|
+
// storage. Call this on mount to pick that back up.
|
|
8197
|
+
async restoreWalletConnectSession(walletCfg) {
|
|
8198
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect") {
|
|
8199
|
+
return this._wallet?.ecosystem === "solana" ? "solana" : "evm";
|
|
8200
|
+
}
|
|
8201
|
+
if (typeof window === "undefined") return null;
|
|
8202
|
+
try {
|
|
8203
|
+
if (!Object.keys(window.localStorage).some((key) => key.startsWith("wc@2"))) {
|
|
8204
|
+
return null;
|
|
8205
|
+
}
|
|
8206
|
+
} catch {
|
|
8207
|
+
}
|
|
8208
|
+
let connector;
|
|
8209
|
+
try {
|
|
8210
|
+
connector = await getUniversalConnector(walletCfg);
|
|
8211
|
+
} catch (e2) {
|
|
8212
|
+
console.warn(
|
|
8213
|
+
"[Trustware SDK] Failed to restore WalletConnect session:",
|
|
8214
|
+
e2
|
|
8215
|
+
);
|
|
8216
|
+
return null;
|
|
8217
|
+
}
|
|
8218
|
+
const session = connector.provider.session;
|
|
8219
|
+
if (!session) return null;
|
|
8220
|
+
const ecosystem = session.namespaces?.solana?.accounts?.length ? "solana" : session.namespaces?.eip155?.accounts?.length ? "evm" : null;
|
|
8221
|
+
if (!ecosystem) return null;
|
|
8222
|
+
try {
|
|
8223
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
8224
|
+
this._wallet = api;
|
|
8225
|
+
this._connectedVia = "walletconnect";
|
|
8226
|
+
this._connectedWalletId = "walletconnect";
|
|
8227
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
8228
|
+
connector.provider
|
|
8229
|
+
);
|
|
8230
|
+
await this.syncIdentityFromWallet("walletconnect");
|
|
8231
|
+
this._status = "connected";
|
|
8232
|
+
this._error = null;
|
|
8233
|
+
this.emit();
|
|
8234
|
+
return ecosystem;
|
|
8235
|
+
} catch {
|
|
8236
|
+
return null;
|
|
8237
|
+
}
|
|
8238
|
+
}
|
|
8239
|
+
// Forcibly abandon an in-progress connect() call the caller has decided is
|
|
8240
|
+
// stuck (e.g. the UI's own connect timeout elapsed with no response).
|
|
8241
|
+
// There's no clean way to cancel a pending WalletConnect pairing proposal
|
|
8242
|
+
// from this side, so this tears down the whole connector — the next
|
|
8243
|
+
// connect attempt starts against a brand new SignClient/pairing instead of
|
|
8244
|
+
// racing the abandoned one, which would otherwise risk reproducing the
|
|
8245
|
+
// "No matching key. proposal" class of error a real retry needs to avoid.
|
|
8246
|
+
cancelWalletConnectAttempt() {
|
|
8247
|
+
if (this._connectedVia === "walletconnect" && this._status === "connected") {
|
|
8248
|
+
return;
|
|
8249
|
+
}
|
|
8250
|
+
resetUniversalConnector();
|
|
8251
|
+
if (this._status === "connecting") {
|
|
8252
|
+
this.clearConnectedState();
|
|
8253
|
+
this._status = "idle";
|
|
8254
|
+
this._error = null;
|
|
8255
|
+
this.emit();
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8073
8258
|
async disconnect(wagmi) {
|
|
8074
8259
|
if (wagmi && this._connectedVia === "extension") {
|
|
8075
8260
|
await wagmi.disconnect().catch(() => {
|
|
@@ -8600,46 +8785,80 @@ function normalizeSlippage(v) {
|
|
|
8600
8785
|
if (n > 5) return 5;
|
|
8601
8786
|
return n;
|
|
8602
8787
|
}
|
|
8788
|
+
function warnDeprecatedSwapModeFlag() {
|
|
8789
|
+
if (hasWarnedDeprecatedSwapModeFlag) return;
|
|
8790
|
+
hasWarnedDeprecatedSwapModeFlag = true;
|
|
8791
|
+
console.warn(
|
|
8792
|
+
'[Trustware SDK] `features.swapMode` is deprecated \u2014 use `mode: "swap"` on the top-level config instead.'
|
|
8793
|
+
);
|
|
8794
|
+
}
|
|
8795
|
+
function resolveMode(input) {
|
|
8796
|
+
if (input.mode === "swap") return "swap";
|
|
8797
|
+
if (input.mode === "deposit") return "deposit";
|
|
8798
|
+
if (input.features?.swapMode) {
|
|
8799
|
+
warnDeprecatedSwapModeFlag();
|
|
8800
|
+
return "swap";
|
|
8801
|
+
}
|
|
8802
|
+
return "deposit";
|
|
8803
|
+
}
|
|
8603
8804
|
function resolveConfig(input) {
|
|
8604
8805
|
if (!input?.apiKey) {
|
|
8605
|
-
throw new
|
|
8806
|
+
throw new TrustwareError({
|
|
8807
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
8808
|
+
message: "TrustwareConfig: 'apiKey' is required.",
|
|
8809
|
+
userMessage: "Missing required API key configuration."
|
|
8810
|
+
});
|
|
8606
8811
|
}
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8812
|
+
const mode = resolveMode(input);
|
|
8813
|
+
if (mode === "deposit" && (!input.routes?.toChain || !input.routes?.toToken)) {
|
|
8814
|
+
throw new TrustwareError({
|
|
8815
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
8816
|
+
message: "TrustwareConfig: 'routes.toChain' and 'routes.toToken' are required in deposit mode.",
|
|
8817
|
+
userMessage: "Missing required destination chain/token configuration."
|
|
8818
|
+
});
|
|
8611
8819
|
}
|
|
8612
|
-
const toChain = input.routes
|
|
8613
|
-
if (input.routes
|
|
8820
|
+
const toChain = input.routes?.toChain;
|
|
8821
|
+
if (input.routes?.toAddress && toChain) {
|
|
8614
8822
|
const result = validateAddressForChain(input.routes.toAddress, toChain);
|
|
8615
8823
|
if (!result.isValid) {
|
|
8616
8824
|
console.error(`[Trustware SDK] Invalid toAddress: ${result.error}`);
|
|
8617
|
-
throw new
|
|
8825
|
+
throw new TrustwareError({
|
|
8826
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
8827
|
+
message: `Invalid toAddress: ${result.error}`,
|
|
8828
|
+
userMessage: "The configured destination address is invalid."
|
|
8829
|
+
});
|
|
8618
8830
|
}
|
|
8619
8831
|
}
|
|
8620
|
-
if (input.routes
|
|
8621
|
-
const
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8832
|
+
if (input.routes?.fromAddress) {
|
|
8833
|
+
const fromChain = input.routes.fromChain ?? toChain;
|
|
8834
|
+
if (fromChain) {
|
|
8835
|
+
const result = validateAddressForChain(
|
|
8836
|
+
input.routes.fromAddress,
|
|
8837
|
+
fromChain
|
|
8838
|
+
);
|
|
8839
|
+
if (!result.isValid) {
|
|
8840
|
+
console.error(`[Trustware SDK] Invalid fromAddress: ${result.error}`);
|
|
8841
|
+
throw new TrustwareError({
|
|
8842
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
8843
|
+
message: `Invalid fromAddress: ${result.error}`,
|
|
8844
|
+
userMessage: "The configured source address is invalid."
|
|
8845
|
+
});
|
|
8846
|
+
}
|
|
8628
8847
|
}
|
|
8629
8848
|
}
|
|
8630
8849
|
const autoDetectProvider = typeof input.autoDetectProvider === "boolean" ? input.autoDetectProvider : DEFAULT_AUTO_DETECT_PROVIDER;
|
|
8631
8850
|
const routes = {
|
|
8632
|
-
toChain: input.routes
|
|
8633
|
-
toToken: input.routes
|
|
8634
|
-
fromToken: input.routes
|
|
8635
|
-
fromAddress: input.routes
|
|
8636
|
-
fromChain: input.routes
|
|
8637
|
-
toAddress: input.routes
|
|
8851
|
+
toChain: input.routes?.toChain ?? "",
|
|
8852
|
+
toToken: input.routes?.toToken ?? "",
|
|
8853
|
+
fromToken: input.routes?.fromToken,
|
|
8854
|
+
fromAddress: input.routes?.fromAddress,
|
|
8855
|
+
fromChain: input.routes?.fromChain,
|
|
8856
|
+
toAddress: input.routes?.toAddress,
|
|
8638
8857
|
defaultSlippage: normalizeSlippage(
|
|
8639
|
-
input.routes
|
|
8858
|
+
input.routes?.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
8640
8859
|
),
|
|
8641
8860
|
options: {
|
|
8642
|
-
...input.routes
|
|
8861
|
+
...input.routes?.options
|
|
8643
8862
|
}
|
|
8644
8863
|
};
|
|
8645
8864
|
const theme = input.theme ?? "system";
|
|
@@ -8658,13 +8877,16 @@ function resolveConfig(input) {
|
|
|
8658
8877
|
tokensPagination: input.features?.tokensPagination ?? DEFAULT_FEATURE_FLAGS.tokensPagination,
|
|
8659
8878
|
balanceStreaming: input.features?.balanceStreaming ?? DEFAULT_FEATURE_FLAGS.balanceStreaming,
|
|
8660
8879
|
shouldAllowGA4: input.features?.shouldAllowGA4 ?? DEFAULT_FEATURE_FLAGS.shouldAllowGA4,
|
|
8661
|
-
|
|
8880
|
+
// Always mirrors the canonical `mode`, however the caller set it (new `mode` field
|
|
8881
|
+
// or the deprecated `features.swapMode` flag).
|
|
8882
|
+
swapMode: mode === "swap",
|
|
8662
8883
|
swapDefaultDestToken: input.features?.swapDefaultDestToken ?? DEFAULT_FEATURE_FLAGS.swapDefaultDestToken,
|
|
8663
8884
|
swapLockDestToken: input.features?.swapLockDestToken ?? DEFAULT_FEATURE_FLAGS.swapLockDestToken,
|
|
8664
8885
|
swapAllowedDestTokens: input.features?.swapAllowedDestTokens ?? DEFAULT_FEATURE_FLAGS.swapAllowedDestTokens
|
|
8665
8886
|
};
|
|
8666
8887
|
return {
|
|
8667
8888
|
apiKey: input.apiKey,
|
|
8889
|
+
mode,
|
|
8668
8890
|
routes,
|
|
8669
8891
|
autoDetectProvider,
|
|
8670
8892
|
theme,
|
|
@@ -8677,12 +8899,15 @@ function resolveConfig(input) {
|
|
|
8677
8899
|
onEvent: input.onEvent
|
|
8678
8900
|
};
|
|
8679
8901
|
}
|
|
8902
|
+
var hasWarnedDeprecatedSwapModeFlag;
|
|
8680
8903
|
var init_merge = __esm({
|
|
8681
8904
|
"src/config/merge.ts"() {
|
|
8682
8905
|
"use strict";
|
|
8683
8906
|
init_defaults();
|
|
8684
8907
|
init_config();
|
|
8685
8908
|
init_index();
|
|
8909
|
+
init_TrustwareError();
|
|
8910
|
+
hasWarnedDeprecatedSwapModeFlag = false;
|
|
8686
8911
|
}
|
|
8687
8912
|
});
|
|
8688
8913
|
|
|
@@ -9270,15 +9495,74 @@ var init_useWalletSessionState = __esm({
|
|
|
9270
9495
|
});
|
|
9271
9496
|
|
|
9272
9497
|
// src/widget/state/deposit/useWalletConnect.ts
|
|
9273
|
-
import { useCallback as useCallback10 } from "react";
|
|
9498
|
+
import { useCallback as useCallback10, useEffect as useEffect13, useRef as useRef5, useState as useState13 } from "react";
|
|
9274
9499
|
function useWalletConnect({
|
|
9275
9500
|
setWalletType,
|
|
9276
|
-
setCurrentStep
|
|
9501
|
+
setCurrentStep,
|
|
9502
|
+
selectedNamespace,
|
|
9503
|
+
setSelectedNamespace
|
|
9277
9504
|
}) {
|
|
9278
9505
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
9279
9506
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
9507
|
+
const ecosystem = selectedNamespace.trim().toLowerCase() === "solana" ? "solana" : "evm";
|
|
9508
|
+
const [wcStatus, setWcStatus] = useState13("idle");
|
|
9509
|
+
const [wcErrorMessage, setWcErrorMessage] = useState13(null);
|
|
9510
|
+
const wcTimeoutRef = useRef5(null);
|
|
9511
|
+
const clearWcTimeout = useCallback10(() => {
|
|
9512
|
+
if (wcTimeoutRef.current !== null) {
|
|
9513
|
+
clearTimeout(wcTimeoutRef.current);
|
|
9514
|
+
wcTimeoutRef.current = null;
|
|
9515
|
+
}
|
|
9516
|
+
}, []);
|
|
9517
|
+
const beginWcAttempt = useCallback10(() => {
|
|
9518
|
+
setWcStatus("connecting");
|
|
9519
|
+
setWcErrorMessage(null);
|
|
9520
|
+
clearWcTimeout();
|
|
9521
|
+
wcTimeoutRef.current = setTimeout(() => {
|
|
9522
|
+
wcTimeoutRef.current = null;
|
|
9523
|
+
setWcStatus((prev) => prev === "connecting" ? "timedOut" : prev);
|
|
9524
|
+
}, WC_CONNECT_TIMEOUT_MS);
|
|
9525
|
+
}, [clearWcTimeout]);
|
|
9526
|
+
const resolveWcAttempt = useCallback10(() => {
|
|
9527
|
+
clearWcTimeout();
|
|
9528
|
+
setWcStatus("idle");
|
|
9529
|
+
setWcErrorMessage(null);
|
|
9530
|
+
}, [clearWcTimeout]);
|
|
9531
|
+
const failWcAttempt = useCallback10(
|
|
9532
|
+
(message) => {
|
|
9533
|
+
clearWcTimeout();
|
|
9534
|
+
setWcStatus("failed");
|
|
9535
|
+
setWcErrorMessage(message);
|
|
9536
|
+
},
|
|
9537
|
+
[clearWcTimeout]
|
|
9538
|
+
);
|
|
9539
|
+
const dismissWcStatus = useCallback10(() => {
|
|
9540
|
+
clearWcTimeout();
|
|
9541
|
+
setWcStatus("idle");
|
|
9542
|
+
setWcErrorMessage(null);
|
|
9543
|
+
}, [clearWcTimeout]);
|
|
9544
|
+
useEffect13(() => clearWcTimeout, [clearWcTimeout]);
|
|
9545
|
+
useEffect13(() => {
|
|
9546
|
+
let cancelled = false;
|
|
9547
|
+
beginWcAttempt();
|
|
9548
|
+
void (async () => {
|
|
9549
|
+
const restoredEcosystem = await walletManager.restoreWalletConnectSession(walletConnectCfg);
|
|
9550
|
+
if (cancelled) return;
|
|
9551
|
+
resolveWcAttempt();
|
|
9552
|
+
if (!restoredEcosystem) return;
|
|
9553
|
+
setWalletType("walletconnect");
|
|
9554
|
+
if (restoredEcosystem === "solana") {
|
|
9555
|
+
setSelectedNamespace("Solana");
|
|
9556
|
+
}
|
|
9557
|
+
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
9558
|
+
if (address) setCurrentStep("crypto-pay");
|
|
9559
|
+
})();
|
|
9560
|
+
return () => {
|
|
9561
|
+
cancelled = true;
|
|
9562
|
+
};
|
|
9563
|
+
}, []);
|
|
9280
9564
|
const WalletConnect = useCallback10(async () => {
|
|
9281
|
-
if (walletManager.status === "connected" && walletManager.connectedVia === "walletconnect") {
|
|
9565
|
+
if (walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" && walletManager.wallet?.ecosystem === ecosystem) {
|
|
9282
9566
|
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
9283
9567
|
if (address) {
|
|
9284
9568
|
setWalletType("walletconnect");
|
|
@@ -9287,38 +9571,64 @@ function useWalletConnect({
|
|
|
9287
9571
|
}
|
|
9288
9572
|
}
|
|
9289
9573
|
setWalletType("walletconnect");
|
|
9290
|
-
|
|
9574
|
+
beginWcAttempt();
|
|
9575
|
+
const { error } = await connectWC(ecosystem);
|
|
9291
9576
|
if (!error) {
|
|
9292
9577
|
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
9293
9578
|
if (address) {
|
|
9579
|
+
resolveWcAttempt();
|
|
9294
9580
|
setCurrentStep("crypto-pay");
|
|
9581
|
+
} else {
|
|
9582
|
+
const message = `WalletConnect session established but no address resolved for ecosystem "${ecosystem}".`;
|
|
9583
|
+
console.error(`[Trustware SDK] ${message}`);
|
|
9584
|
+
failWcAttempt(message);
|
|
9295
9585
|
}
|
|
9296
9586
|
} else {
|
|
9587
|
+
console.error("[Trustware SDK] WalletConnect connection failed:", error);
|
|
9588
|
+
failWcAttempt(error);
|
|
9297
9589
|
setWalletType("other");
|
|
9298
9590
|
}
|
|
9299
|
-
}, [
|
|
9591
|
+
}, [
|
|
9592
|
+
beginWcAttempt,
|
|
9593
|
+
connectWC,
|
|
9594
|
+
ecosystem,
|
|
9595
|
+
failWcAttempt,
|
|
9596
|
+
resolveWcAttempt,
|
|
9597
|
+
setCurrentStep,
|
|
9598
|
+
setWalletType
|
|
9599
|
+
]);
|
|
9600
|
+
const retryWalletConnect = useCallback10(() => {
|
|
9601
|
+
walletManager.cancelWalletConnectAttempt();
|
|
9602
|
+
void WalletConnect();
|
|
9603
|
+
}, [WalletConnect]);
|
|
9300
9604
|
const disconnectWalletConnect = useCallback10(async () => {
|
|
9301
9605
|
await walletManager.disconnect();
|
|
9302
9606
|
setWalletType("other");
|
|
9303
9607
|
setCurrentStep("home");
|
|
9304
9608
|
}, [setCurrentStep, setWalletType]);
|
|
9305
|
-
const walletConnectAddress = walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" ? walletManager.
|
|
9609
|
+
const walletConnectAddress = walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" ? walletManager.identity?.addresses[0]?.address ?? null : null;
|
|
9306
9610
|
return {
|
|
9307
9611
|
walletConnectAddress,
|
|
9308
9612
|
WalletConnect,
|
|
9309
|
-
disconnectWalletConnect
|
|
9613
|
+
disconnectWalletConnect,
|
|
9614
|
+
wcStatus,
|
|
9615
|
+
wcErrorMessage,
|
|
9616
|
+
retryWalletConnect,
|
|
9617
|
+
dismissWcStatus
|
|
9310
9618
|
};
|
|
9311
9619
|
}
|
|
9620
|
+
var WC_CONNECT_TIMEOUT_MS;
|
|
9312
9621
|
var init_useWalletConnect = __esm({
|
|
9313
9622
|
"src/widget/state/deposit/useWalletConnect.ts"() {
|
|
9314
9623
|
"use strict";
|
|
9315
9624
|
init_config2();
|
|
9316
9625
|
init_wallets();
|
|
9626
|
+
WC_CONNECT_TIMEOUT_MS = 3e4;
|
|
9317
9627
|
}
|
|
9318
9628
|
});
|
|
9319
9629
|
|
|
9320
9630
|
// src/widget/context/DepositContext.tsx
|
|
9321
|
-
import React2, { createContext as createContext2, useContext as useContext2, useState as
|
|
9631
|
+
import React2, { createContext as createContext2, useContext as useContext2, useState as useState14, useMemo as useMemo7 } from "react";
|
|
9322
9632
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
9323
9633
|
function DepositProvider({
|
|
9324
9634
|
children,
|
|
@@ -9343,20 +9653,30 @@ function DepositProvider({
|
|
|
9343
9653
|
connectWallet,
|
|
9344
9654
|
disconnectWallet
|
|
9345
9655
|
} = useWalletSessionState();
|
|
9346
|
-
const [amountInputMode, setAmountInputMode] =
|
|
9656
|
+
const [amountInputMode, setAmountInputMode] = useState14(
|
|
9347
9657
|
"usd"
|
|
9348
9658
|
);
|
|
9349
|
-
const [walletType, setWalletType] =
|
|
9659
|
+
const [walletType, setWalletType] = useState14(
|
|
9350
9660
|
"other"
|
|
9351
9661
|
);
|
|
9352
|
-
const
|
|
9662
|
+
const [selectedNamespace, setSelectedNamespace] = useState14("evm");
|
|
9663
|
+
const {
|
|
9664
|
+
walletConnectAddress,
|
|
9665
|
+
WalletConnect,
|
|
9666
|
+
disconnectWalletConnect,
|
|
9667
|
+
wcStatus,
|
|
9668
|
+
wcErrorMessage,
|
|
9669
|
+
retryWalletConnect,
|
|
9670
|
+
dismissWcStatus
|
|
9671
|
+
} = useWalletConnect({
|
|
9353
9672
|
setWalletType,
|
|
9354
|
-
setCurrentStep
|
|
9673
|
+
setCurrentStep,
|
|
9674
|
+
selectedNamespace,
|
|
9675
|
+
setSelectedNamespace
|
|
9355
9676
|
});
|
|
9356
|
-
const [selectedToken, setSelectedToken] =
|
|
9357
|
-
const [selectedChain, setSelectedChain] =
|
|
9358
|
-
const [amount, setAmount] =
|
|
9359
|
-
const [selectedNamespace, setSelectedNamespace] = useState13("evm");
|
|
9677
|
+
const [selectedToken, setSelectedToken] = useState14(null);
|
|
9678
|
+
const [selectedChain, setSelectedChain] = useState14(null);
|
|
9679
|
+
const [amount, setAmount] = useState14("");
|
|
9360
9680
|
const walletAddress = useMemo7(
|
|
9361
9681
|
() => walletType === "walletconnect" ? walletConnectAddress : otherWalletAddress,
|
|
9362
9682
|
[walletType, walletConnectAddress, otherWalletAddress]
|
|
@@ -9374,11 +9694,11 @@ function DepositProvider({
|
|
|
9374
9694
|
selectedToken,
|
|
9375
9695
|
setSelectedToken
|
|
9376
9696
|
});
|
|
9377
|
-
const [transactionStatus, setTransactionStatus] =
|
|
9378
|
-
const [transactionHash, setTransactionHash] =
|
|
9379
|
-
const [errorMessage, setErrorMessage] =
|
|
9380
|
-
const [intentId, setIntentId] =
|
|
9381
|
-
const [paymentMethod, setPaymentMethod] =
|
|
9697
|
+
const [transactionStatus, setTransactionStatus] = useState14("idle");
|
|
9698
|
+
const [transactionHash, setTransactionHash] = useState14(null);
|
|
9699
|
+
const [errorMessage, setErrorMessage] = useState14(null);
|
|
9700
|
+
const [intentId, setIntentId] = useState14(null);
|
|
9701
|
+
const [paymentMethod, setPaymentMethod] = useState14("crypto");
|
|
9382
9702
|
const resetState = React2.useCallback(() => {
|
|
9383
9703
|
resetNavigation();
|
|
9384
9704
|
setSelectedToken(null);
|
|
@@ -9428,7 +9748,11 @@ function DepositProvider({
|
|
|
9428
9748
|
setWalletType,
|
|
9429
9749
|
walletType,
|
|
9430
9750
|
selectedNamespace,
|
|
9431
|
-
setSelectedNamespace
|
|
9751
|
+
setSelectedNamespace,
|
|
9752
|
+
wcStatus,
|
|
9753
|
+
wcErrorMessage,
|
|
9754
|
+
retryWalletConnect,
|
|
9755
|
+
dismissWcStatus
|
|
9432
9756
|
}),
|
|
9433
9757
|
[
|
|
9434
9758
|
WalletConnect,
|
|
@@ -9444,7 +9768,11 @@ function DepositProvider({
|
|
|
9444
9768
|
yourWalletTokens,
|
|
9445
9769
|
yourWalletTokensLoading,
|
|
9446
9770
|
selectedNamespace,
|
|
9447
|
-
setSelectedNamespace
|
|
9771
|
+
setSelectedNamespace,
|
|
9772
|
+
wcStatus,
|
|
9773
|
+
wcErrorMessage,
|
|
9774
|
+
retryWalletConnect,
|
|
9775
|
+
dismissWcStatus
|
|
9448
9776
|
]
|
|
9449
9777
|
);
|
|
9450
9778
|
const formValue = useMemo7(
|
|
@@ -9887,7 +10215,7 @@ var init_AmountSlider = __esm({
|
|
|
9887
10215
|
});
|
|
9888
10216
|
|
|
9889
10217
|
// src/widget/components/AmountInputDisplay.tsx
|
|
9890
|
-
import { useRef as
|
|
10218
|
+
import { useRef as useRef6, useState as useState15 } from "react";
|
|
9891
10219
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
9892
10220
|
function formatDisplayAmount(value) {
|
|
9893
10221
|
if (!Number.isFinite(value) || value <= 0) return "0";
|
|
@@ -9926,8 +10254,8 @@ function AmountInputDisplay({
|
|
|
9926
10254
|
style,
|
|
9927
10255
|
inputAriaLabel = "Deposit amount"
|
|
9928
10256
|
}) {
|
|
9929
|
-
const [isEditing, setIsEditing] =
|
|
9930
|
-
const inputRef =
|
|
10257
|
+
const [isEditing, setIsEditing] = useState15(false);
|
|
10258
|
+
const inputRef = useRef6(null);
|
|
9931
10259
|
const handleAmountClick = () => {
|
|
9932
10260
|
if (isFixedAmount) return;
|
|
9933
10261
|
const isZeroish = !amount || parseFloat(amount) === 0;
|
|
@@ -10160,15 +10488,15 @@ __export(ConfettiEffect_exports, {
|
|
|
10160
10488
|
ConfettiEffect: () => ConfettiEffect,
|
|
10161
10489
|
default: () => ConfettiEffect_default
|
|
10162
10490
|
});
|
|
10163
|
-
import { useEffect as
|
|
10491
|
+
import { useEffect as useEffect14, useState as useState16 } from "react";
|
|
10164
10492
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
10165
10493
|
function ConfettiEffect({
|
|
10166
10494
|
isActive,
|
|
10167
10495
|
clearDelay = 3e3,
|
|
10168
10496
|
pieceCount = 50
|
|
10169
10497
|
}) {
|
|
10170
|
-
const [pieces, setPieces] =
|
|
10171
|
-
|
|
10498
|
+
const [pieces, setPieces] = useState16([]);
|
|
10499
|
+
useEffect14(() => {
|
|
10172
10500
|
if (isActive) {
|
|
10173
10501
|
const colors2 = [
|
|
10174
10502
|
"#10b981",
|
|
@@ -10253,7 +10581,7 @@ var init_ConfettiEffect = __esm({
|
|
|
10253
10581
|
});
|
|
10254
10582
|
|
|
10255
10583
|
// src/widget/components/Dialog.tsx
|
|
10256
|
-
import { useEffect as
|
|
10584
|
+
import { useEffect as useEffect15, useRef as useRef7 } from "react";
|
|
10257
10585
|
import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
10258
10586
|
var Dialog;
|
|
10259
10587
|
var init_Dialog = __esm({
|
|
@@ -10270,11 +10598,11 @@ var init_Dialog = __esm({
|
|
|
10270
10598
|
confirmText = "Close Anyway",
|
|
10271
10599
|
isDark = false
|
|
10272
10600
|
}) => {
|
|
10273
|
-
const dialogRef =
|
|
10274
|
-
const overlayRef =
|
|
10275
|
-
const firstButtonRef =
|
|
10276
|
-
const lastButtonRef =
|
|
10277
|
-
|
|
10601
|
+
const dialogRef = useRef7(null);
|
|
10602
|
+
const overlayRef = useRef7(null);
|
|
10603
|
+
const firstButtonRef = useRef7(null);
|
|
10604
|
+
const lastButtonRef = useRef7(null);
|
|
10605
|
+
useEffect15(() => {
|
|
10278
10606
|
const handleEscape = (e2) => {
|
|
10279
10607
|
if (e2.key === "Escape" && open) {
|
|
10280
10608
|
e2.preventDefault();
|
|
@@ -10288,7 +10616,7 @@ var init_Dialog = __esm({
|
|
|
10288
10616
|
document.removeEventListener("keydown", handleEscape);
|
|
10289
10617
|
};
|
|
10290
10618
|
}, [open, onCancel]);
|
|
10291
|
-
|
|
10619
|
+
useEffect15(() => {
|
|
10292
10620
|
const handleTabKey = (e2) => {
|
|
10293
10621
|
if (!open) return;
|
|
10294
10622
|
if (e2.key === "Tab") {
|
|
@@ -10312,7 +10640,7 @@ var init_Dialog = __esm({
|
|
|
10312
10640
|
document.removeEventListener("keydown", handleTabKey);
|
|
10313
10641
|
};
|
|
10314
10642
|
}, [open]);
|
|
10315
|
-
|
|
10643
|
+
useEffect15(() => {
|
|
10316
10644
|
if (open) {
|
|
10317
10645
|
const originalStyle = window.getComputedStyle(document.body).overflow;
|
|
10318
10646
|
document.body.style.overflow = "hidden";
|
|
@@ -10618,7 +10946,7 @@ var init_TransactionHashLink = __esm({
|
|
|
10618
10946
|
});
|
|
10619
10947
|
|
|
10620
10948
|
// src/widget/components/SwipeToConfirmTokens.tsx
|
|
10621
|
-
import { useState as
|
|
10949
|
+
import { useState as useState17, useRef as useRef8, useCallback as useCallback12, useEffect as useEffect16 } from "react";
|
|
10622
10950
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
10623
10951
|
function SwipeToConfirmTokens({
|
|
10624
10952
|
fromToken,
|
|
@@ -10633,16 +10961,16 @@ function SwipeToConfirmTokens({
|
|
|
10633
10961
|
style,
|
|
10634
10962
|
text
|
|
10635
10963
|
}) {
|
|
10636
|
-
const [dragX, setDragX] =
|
|
10637
|
-
const [isDragging, setIsDragging] =
|
|
10638
|
-
const [isComplete, setIsComplete] =
|
|
10639
|
-
const trackRef =
|
|
10640
|
-
const thumbRef =
|
|
10641
|
-
const [isLongPressing, setIsLongPressing] =
|
|
10642
|
-
const [longPressProgress, setLongPressProgress] =
|
|
10643
|
-
const longPressTimerRef =
|
|
10644
|
-
const longPressStartRef =
|
|
10645
|
-
const longPressAnimationRef =
|
|
10964
|
+
const [dragX, setDragX] = useState17(0);
|
|
10965
|
+
const [isDragging, setIsDragging] = useState17(false);
|
|
10966
|
+
const [isComplete, setIsComplete] = useState17(false);
|
|
10967
|
+
const trackRef = useRef8(null);
|
|
10968
|
+
const thumbRef = useRef8(null);
|
|
10969
|
+
const [isLongPressing, setIsLongPressing] = useState17(false);
|
|
10970
|
+
const [longPressProgress, setLongPressProgress] = useState17(0);
|
|
10971
|
+
const longPressTimerRef = useRef8(null);
|
|
10972
|
+
const longPressStartRef = useRef8(null);
|
|
10973
|
+
const longPressAnimationRef = useRef8(null);
|
|
10646
10974
|
const LONG_PRESS_DURATION = 1500;
|
|
10647
10975
|
const thumbSize = 48;
|
|
10648
10976
|
const padding = 4;
|
|
@@ -10740,7 +11068,7 @@ function SwipeToConfirmTokens({
|
|
|
10740
11068
|
},
|
|
10741
11069
|
[cancelLongPress]
|
|
10742
11070
|
);
|
|
10743
|
-
|
|
11071
|
+
useEffect16(() => {
|
|
10744
11072
|
return () => {
|
|
10745
11073
|
if (longPressTimerRef.current) clearTimeout(longPressTimerRef.current);
|
|
10746
11074
|
if (longPressAnimationRef.current)
|
|
@@ -10759,7 +11087,7 @@ function SwipeToConfirmTokens({
|
|
|
10759
11087
|
const handleTouchStart = () => handleDragStart();
|
|
10760
11088
|
const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
|
|
10761
11089
|
const handleTouchEnd = () => handleDragEnd();
|
|
10762
|
-
|
|
11090
|
+
useEffect16(() => {
|
|
10763
11091
|
if (isDragging) {
|
|
10764
11092
|
window.addEventListener("mousemove", handleMouseMove);
|
|
10765
11093
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -10771,8 +11099,8 @@ function SwipeToConfirmTokens({
|
|
|
10771
11099
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
10772
11100
|
const progress = getProgress();
|
|
10773
11101
|
const effectiveProgress = isLongPressing ? longPressProgress : progress;
|
|
10774
|
-
const [blinkOpacity, setBlinkOpacity] =
|
|
10775
|
-
|
|
11102
|
+
const [blinkOpacity, setBlinkOpacity] = useState17(1);
|
|
11103
|
+
useEffect16(() => {
|
|
10776
11104
|
if (disabled || isComplete || isDragging || isLongPressing) {
|
|
10777
11105
|
setBlinkOpacity(1);
|
|
10778
11106
|
return;
|
|
@@ -11234,7 +11562,7 @@ var init_ThemeToggle = __esm({
|
|
|
11234
11562
|
});
|
|
11235
11563
|
|
|
11236
11564
|
// src/widget/components/Toast.tsx
|
|
11237
|
-
import { useEffect as
|
|
11565
|
+
import { useEffect as useEffect17, useState as useState18, useCallback as useCallback13 } from "react";
|
|
11238
11566
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
11239
11567
|
function ToastItem({
|
|
11240
11568
|
id,
|
|
@@ -11244,14 +11572,14 @@ function ToastItem({
|
|
|
11244
11572
|
duration = 4e3,
|
|
11245
11573
|
onDismiss
|
|
11246
11574
|
}) {
|
|
11247
|
-
const [isExiting, setIsExiting] =
|
|
11248
|
-
|
|
11575
|
+
const [isExiting, setIsExiting] = useState18(false);
|
|
11576
|
+
useEffect17(() => {
|
|
11249
11577
|
const timer = setTimeout(() => {
|
|
11250
11578
|
setIsExiting(true);
|
|
11251
11579
|
}, duration);
|
|
11252
11580
|
return () => clearTimeout(timer);
|
|
11253
11581
|
}, [duration]);
|
|
11254
|
-
|
|
11582
|
+
useEffect17(() => {
|
|
11255
11583
|
if (isExiting) {
|
|
11256
11584
|
const exitTimer = setTimeout(() => {
|
|
11257
11585
|
onDismiss(id);
|
|
@@ -11450,8 +11778,8 @@ function toast(data) {
|
|
|
11450
11778
|
};
|
|
11451
11779
|
}
|
|
11452
11780
|
function ToastContainer() {
|
|
11453
|
-
const [activeToasts, setActiveToasts] =
|
|
11454
|
-
|
|
11781
|
+
const [activeToasts, setActiveToasts] = useState18([]);
|
|
11782
|
+
useEffect17(() => {
|
|
11455
11783
|
const listener = (newToasts) => {
|
|
11456
11784
|
setActiveToasts(newToasts);
|
|
11457
11785
|
};
|
|
@@ -11533,10 +11861,10 @@ var init_Toast = __esm({
|
|
|
11533
11861
|
|
|
11534
11862
|
// src/widget/components/TokenSwipePill.tsx
|
|
11535
11863
|
import React9, {
|
|
11536
|
-
useState as
|
|
11537
|
-
useRef as
|
|
11864
|
+
useState as useState19,
|
|
11865
|
+
useRef as useRef9,
|
|
11538
11866
|
useCallback as useCallback14,
|
|
11539
|
-
useEffect as
|
|
11867
|
+
useEffect as useEffect18,
|
|
11540
11868
|
useMemo as useMemo9
|
|
11541
11869
|
} from "react";
|
|
11542
11870
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
@@ -11549,10 +11877,10 @@ function TokenSwipePill({
|
|
|
11549
11877
|
walletAddress,
|
|
11550
11878
|
style
|
|
11551
11879
|
}) {
|
|
11552
|
-
const [isDragging, setIsDragging] =
|
|
11553
|
-
const [dragOffset, setDragOffset] =
|
|
11554
|
-
const startXRef =
|
|
11555
|
-
const containerRef =
|
|
11880
|
+
const [isDragging, setIsDragging] = useState19(false);
|
|
11881
|
+
const [dragOffset, setDragOffset] = useState19(0);
|
|
11882
|
+
const startXRef = useRef9(0);
|
|
11883
|
+
const containerRef = useRef9(null);
|
|
11556
11884
|
const currentIndex = tokens.findIndex(
|
|
11557
11885
|
(t) => normalizeAddress2(
|
|
11558
11886
|
t.address,
|
|
@@ -11623,7 +11951,7 @@ function TokenSwipePill({
|
|
|
11623
11951
|
const handleTouchEnd = () => {
|
|
11624
11952
|
handleDragEnd();
|
|
11625
11953
|
};
|
|
11626
|
-
|
|
11954
|
+
useEffect18(() => {
|
|
11627
11955
|
if (isDragging) {
|
|
11628
11956
|
window.addEventListener("mousemove", handleMouseMove);
|
|
11629
11957
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -12328,7 +12656,7 @@ var init_TransactionSteps = __esm({
|
|
|
12328
12656
|
});
|
|
12329
12657
|
|
|
12330
12658
|
// src/widget/components/WidgetContainer.tsx
|
|
12331
|
-
import { useEffect as
|
|
12659
|
+
import { useEffect as useEffect19, useState as useState20 } from "react";
|
|
12332
12660
|
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
12333
12661
|
function WidgetContainer({
|
|
12334
12662
|
children,
|
|
@@ -12336,8 +12664,8 @@ function WidgetContainer({
|
|
|
12336
12664
|
className,
|
|
12337
12665
|
style
|
|
12338
12666
|
}) {
|
|
12339
|
-
const [resolvedTheme, setResolvedTheme] =
|
|
12340
|
-
|
|
12667
|
+
const [resolvedTheme, setResolvedTheme] = useState20("light");
|
|
12668
|
+
useEffect19(() => {
|
|
12341
12669
|
if (theme === "system") {
|
|
12342
12670
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
12343
12671
|
setResolvedTheme(mediaQuery.matches ? "dark" : "light");
|
|
@@ -12882,7 +13210,7 @@ var init_ErrorPage = __esm({
|
|
|
12882
13210
|
});
|
|
12883
13211
|
|
|
12884
13212
|
// src/widget/components/ImageLoader.tsx
|
|
12885
|
-
import { useCallback as useCallback15, useEffect as
|
|
13213
|
+
import { useCallback as useCallback15, useEffect as useEffect20, useMemo as useMemo11, useRef as useRef10, useState as useState21 } from "react";
|
|
12886
13214
|
import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
12887
13215
|
function Skeleton({
|
|
12888
13216
|
background,
|
|
@@ -12911,18 +13239,18 @@ function ImageLoader({
|
|
|
12911
13239
|
onLoad,
|
|
12912
13240
|
onError
|
|
12913
13241
|
}) {
|
|
12914
|
-
const [status, setStatus] =
|
|
12915
|
-
const [attempt, setAttempt] =
|
|
12916
|
-
const [srcIsEmpty, setSrcIsEmpty] =
|
|
12917
|
-
const imgRef =
|
|
12918
|
-
const observerRef =
|
|
12919
|
-
const onLoadRef =
|
|
12920
|
-
const onErrorRef =
|
|
12921
|
-
|
|
13242
|
+
const [status, setStatus] = useState21("idle");
|
|
13243
|
+
const [attempt, setAttempt] = useState21(0);
|
|
13244
|
+
const [srcIsEmpty, setSrcIsEmpty] = useState21(false);
|
|
13245
|
+
const imgRef = useRef10(null);
|
|
13246
|
+
const observerRef = useRef10(null);
|
|
13247
|
+
const onLoadRef = useRef10(onLoad);
|
|
13248
|
+
const onErrorRef = useRef10(onError);
|
|
13249
|
+
useEffect20(() => {
|
|
12922
13250
|
onLoadRef.current = onLoad;
|
|
12923
13251
|
onErrorRef.current = onError;
|
|
12924
13252
|
}, [onLoad, onError]);
|
|
12925
|
-
|
|
13253
|
+
useEffect20(() => {
|
|
12926
13254
|
if (status === "error" && attempt < retry) {
|
|
12927
13255
|
const timer = setTimeout(() => {
|
|
12928
13256
|
setAttempt((prev) => prev + 1);
|
|
@@ -12949,7 +13277,7 @@ function ImageLoader({
|
|
|
12949
13277
|
onErrorRef.current?.();
|
|
12950
13278
|
};
|
|
12951
13279
|
}, [src]);
|
|
12952
|
-
|
|
13280
|
+
useEffect20(() => {
|
|
12953
13281
|
if (!lazy3) {
|
|
12954
13282
|
const timer = setTimeout(() => loadImage(), 0);
|
|
12955
13283
|
return () => clearTimeout(timer);
|
|
@@ -13419,7 +13747,7 @@ var init_AvailableTokenListItem = __esm({
|
|
|
13419
13747
|
});
|
|
13420
13748
|
|
|
13421
13749
|
// src/widget/features/token-selection/components/ChainSelectorPanel.tsx
|
|
13422
|
-
import { useState as
|
|
13750
|
+
import { useState as useState22, useMemo as useMemo12 } from "react";
|
|
13423
13751
|
import { Fragment as Fragment3, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
13424
13752
|
function ChainItem({
|
|
13425
13753
|
chain,
|
|
@@ -13631,7 +13959,7 @@ function ChainSelectorPanel({
|
|
|
13631
13959
|
otherChains,
|
|
13632
13960
|
popularChains
|
|
13633
13961
|
}) {
|
|
13634
|
-
const [chainSearch, setChainSearch] =
|
|
13962
|
+
const [chainSearch, setChainSearch] = useState22("");
|
|
13635
13963
|
const filteredPopular = useMemo12(() => {
|
|
13636
13964
|
if (!chainSearch) return popularChains;
|
|
13637
13965
|
const q = chainSearch.toLowerCase();
|
|
@@ -14390,7 +14718,7 @@ var init_WalletTokenListItem = __esm({
|
|
|
14390
14718
|
});
|
|
14391
14719
|
|
|
14392
14720
|
// src/widget/features/token-selection/components/TokenSelectorPanel.tsx
|
|
14393
|
-
import { useState as
|
|
14721
|
+
import { useState as useState23, useEffect as useEffect21 } from "react";
|
|
14394
14722
|
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
14395
14723
|
function TokenSectionLabel({
|
|
14396
14724
|
children,
|
|
@@ -14486,8 +14814,8 @@ function TokenSelectorPanel({
|
|
|
14486
14814
|
setSearchQuery,
|
|
14487
14815
|
tokensError
|
|
14488
14816
|
}) {
|
|
14489
|
-
const [showAll, setShowAll] =
|
|
14490
|
-
|
|
14817
|
+
const [showAll, setShowAll] = useState23(false);
|
|
14818
|
+
useEffect21(() => {
|
|
14491
14819
|
setShowAll(false);
|
|
14492
14820
|
}, [selectedChain, searchQuery]);
|
|
14493
14821
|
const hasWalletTokens = filteredWalletTokens.length > 0;
|
|
@@ -15411,7 +15739,7 @@ var init_CryptoPayAmountSection = __esm({
|
|
|
15411
15739
|
});
|
|
15412
15740
|
|
|
15413
15741
|
// src/widget/features/amount/hooks/useDepositAmountModel.ts
|
|
15414
|
-
import { useEffect as
|
|
15742
|
+
import { useEffect as useEffect22, useMemo as useMemo15 } from "react";
|
|
15415
15743
|
function useDepositAmountModel({
|
|
15416
15744
|
amount,
|
|
15417
15745
|
setAmount,
|
|
@@ -15432,7 +15760,7 @@ function useDepositAmountModel({
|
|
|
15432
15760
|
);
|
|
15433
15761
|
return Number.isFinite(normalized) ? normalized : 0;
|
|
15434
15762
|
}, [selectedToken?.balance, selectedToken?.decimals]);
|
|
15435
|
-
|
|
15763
|
+
useEffect22(() => {
|
|
15436
15764
|
if (fixedFromAmountString) return;
|
|
15437
15765
|
if (isReady && !hasUsdPrice && amountInputMode === "usd") {
|
|
15438
15766
|
setAmountInputMode("token");
|
|
@@ -15444,7 +15772,7 @@ function useDepositAmountModel({
|
|
|
15444
15772
|
isReady,
|
|
15445
15773
|
setAmountInputMode
|
|
15446
15774
|
]);
|
|
15447
|
-
|
|
15775
|
+
useEffect22(() => {
|
|
15448
15776
|
if (!fixedFromAmountString) return;
|
|
15449
15777
|
if (amount !== fixedFromAmountString) {
|
|
15450
15778
|
setAmount(fixedFromAmountString);
|
|
@@ -15622,7 +15950,7 @@ var init_useDepositAmountModel = __esm({
|
|
|
15622
15950
|
});
|
|
15623
15951
|
|
|
15624
15952
|
// src/widget/features/amount/hooks/useHomeAmountModel.ts
|
|
15625
|
-
import { useEffect as
|
|
15953
|
+
import { useEffect as useEffect23, useMemo as useMemo16 } from "react";
|
|
15626
15954
|
function useHomeAmountModel({
|
|
15627
15955
|
amount,
|
|
15628
15956
|
setAmount,
|
|
@@ -15633,7 +15961,7 @@ function useHomeAmountModel({
|
|
|
15633
15961
|
minAmountUsd,
|
|
15634
15962
|
maxAmountUsd
|
|
15635
15963
|
}) {
|
|
15636
|
-
|
|
15964
|
+
useEffect23(() => {
|
|
15637
15965
|
if (!fixedFromAmountString) return;
|
|
15638
15966
|
if (amount !== fixedFromAmountString) {
|
|
15639
15967
|
setAmount(fixedFromAmountString);
|
|
@@ -16043,8 +16371,20 @@ var init_WalletNamespaceTabs = __esm({
|
|
|
16043
16371
|
});
|
|
16044
16372
|
|
|
16045
16373
|
// src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx
|
|
16046
|
-
import { useEffect as
|
|
16374
|
+
import { useEffect as useEffect24, useMemo as useMemo17, useRef as useRef11, useState as useState24 } from "react";
|
|
16047
16375
|
import { Fragment as Fragment7, jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
16376
|
+
function ecosystemToNamespace(ecosystem) {
|
|
16377
|
+
switch (ecosystem.trim().toLowerCase()) {
|
|
16378
|
+
case "evm":
|
|
16379
|
+
return "evm";
|
|
16380
|
+
case "solana":
|
|
16381
|
+
return "Solana";
|
|
16382
|
+
case "bitcoin":
|
|
16383
|
+
return "bitcoin";
|
|
16384
|
+
default:
|
|
16385
|
+
return null;
|
|
16386
|
+
}
|
|
16387
|
+
}
|
|
16048
16388
|
function DesktopWalletDropdownContent({
|
|
16049
16389
|
browserWallets,
|
|
16050
16390
|
handleWalletConnect,
|
|
@@ -16110,38 +16450,70 @@ function DesktopWalletDropdownContent({
|
|
|
16110
16450
|
);
|
|
16111
16451
|
}
|
|
16112
16452
|
function MobileWalletDropdownContent({
|
|
16113
|
-
|
|
16453
|
+
browserWallets,
|
|
16454
|
+
handleWalletConnect,
|
|
16455
|
+
handleWalletSelect: connectDetectedWallet2
|
|
16114
16456
|
}) {
|
|
16115
16457
|
const { setCurrentStep } = useDepositNavigation();
|
|
16116
|
-
const { selectedNamespace } = useDepositWallet();
|
|
16117
|
-
const { walletMetaId, isConnected, status } = useWalletInfo();
|
|
16118
|
-
const [hoveredId, setHoveredId] =
|
|
16119
|
-
const storeFallbackTimeoutRef =
|
|
16458
|
+
const { selectedNamespace, setSelectedNamespace } = useDepositWallet();
|
|
16459
|
+
const { walletMetaId, isConnected, status, detected } = useWalletInfo();
|
|
16460
|
+
const [hoveredId, setHoveredId] = useState24(null);
|
|
16461
|
+
const storeFallbackTimeoutRef = useRef11(
|
|
16120
16462
|
null
|
|
16121
16463
|
);
|
|
16122
|
-
|
|
16464
|
+
useEffect24(() => {
|
|
16123
16465
|
return () => {
|
|
16124
16466
|
if (storeFallbackTimeoutRef.current !== null) {
|
|
16125
16467
|
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16126
16468
|
}
|
|
16127
16469
|
};
|
|
16128
16470
|
}, []);
|
|
16471
|
+
useEffect24(() => {
|
|
16472
|
+
if (browserWallets.length > 0) return;
|
|
16473
|
+
const otherEcosystemWallet = detected.find((d) => {
|
|
16474
|
+
if (d.meta.id === "walletconnect") return false;
|
|
16475
|
+
const ecosystem = d.meta.ecosystem.trim().toLowerCase();
|
|
16476
|
+
return ecosystem !== "multi" && ecosystem !== selectedNamespace.trim().toLowerCase();
|
|
16477
|
+
});
|
|
16478
|
+
if (!otherEcosystemWallet) return;
|
|
16479
|
+
const nextNamespace = ecosystemToNamespace(
|
|
16480
|
+
otherEcosystemWallet.meta.ecosystem
|
|
16481
|
+
);
|
|
16482
|
+
if (nextNamespace) setSelectedNamespace(nextNamespace);
|
|
16483
|
+
}, [browserWallets, detected, selectedNamespace, setSelectedNamespace]);
|
|
16129
16484
|
const connectedWalletId = isConnected ? walletMetaId : null;
|
|
16130
16485
|
const currentUrl = window.location.href;
|
|
16131
|
-
const mobileWallets = useMemo17(
|
|
16132
|
-
|
|
16133
|
-
if (w.id === "walletconnect")
|
|
16486
|
+
const mobileWallets = useMemo17(() => {
|
|
16487
|
+
const entries = WALLETS.filter((w) => {
|
|
16488
|
+
if (w.id === "walletconnect") {
|
|
16489
|
+
return selectedNamespace.trim().toLowerCase() === "evm";
|
|
16490
|
+
}
|
|
16491
|
+
const isDetected = browserWallets.some((d) => d.meta.id === w.id);
|
|
16134
16492
|
const hasMobileLink = Boolean(w.deepLink);
|
|
16135
|
-
if (!hasMobileLink) return false;
|
|
16493
|
+
if (!hasMobileLink && !isDetected) return false;
|
|
16136
16494
|
return w.ecosystem.trim().toLowerCase() === "multi" || w.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase();
|
|
16137
|
-
})
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
16495
|
+
}).map((meta) => ({
|
|
16496
|
+
meta,
|
|
16497
|
+
detectedWallet: browserWallets.find((d) => d.meta.id === meta.id) ?? null
|
|
16498
|
+
}));
|
|
16499
|
+
const listedIds = new Set(entries.map((e2) => e2.meta.id));
|
|
16500
|
+
for (const detected2 of browserWallets) {
|
|
16501
|
+
if (!listedIds.has(detected2.meta.id)) {
|
|
16502
|
+
entries.push({ meta: detected2.meta, detectedWallet: detected2 });
|
|
16503
|
+
}
|
|
16504
|
+
}
|
|
16505
|
+
return entries;
|
|
16506
|
+
}, [browserWallets, selectedNamespace]);
|
|
16507
|
+
const handleWalletSelect = (entry) => {
|
|
16508
|
+
const { meta: wallet, detectedWallet } = entry;
|
|
16141
16509
|
if (wallet.id === "walletconnect") {
|
|
16142
16510
|
handleWalletConnect();
|
|
16143
16511
|
return;
|
|
16144
16512
|
}
|
|
16513
|
+
if (detectedWallet) {
|
|
16514
|
+
void connectDetectedWallet2(detectedWallet);
|
|
16515
|
+
return;
|
|
16516
|
+
}
|
|
16145
16517
|
if (wallet.deepLink) {
|
|
16146
16518
|
const deepLinkUrl = wallet.deepLink(currentUrl);
|
|
16147
16519
|
if (deepLinkUrl) {
|
|
@@ -16211,15 +16583,16 @@ function MobileWalletDropdownContent({
|
|
|
16211
16583
|
scrollbarWidth: "thin",
|
|
16212
16584
|
scrollbarColor: `${colors.muted} transparent`
|
|
16213
16585
|
},
|
|
16214
|
-
children: mobileWallets.map((
|
|
16586
|
+
children: mobileWallets.map((entry) => {
|
|
16587
|
+
const wallet = entry.meta;
|
|
16215
16588
|
const isConnectedWallet = wallet.id === connectedWalletId;
|
|
16216
|
-
const isDisabled = isConnected && !isConnectedWallet;
|
|
16589
|
+
const isDisabled = isConnected && !isConnectedWallet && !entry.detectedWallet;
|
|
16217
16590
|
const isHovered = hoveredId === wallet.id;
|
|
16218
16591
|
return /* @__PURE__ */ jsxs30(
|
|
16219
16592
|
"button",
|
|
16220
16593
|
{
|
|
16221
16594
|
type: "button",
|
|
16222
|
-
onClick: () => !isDisabled && handleWalletSelect(
|
|
16595
|
+
onClick: () => !isDisabled && handleWalletSelect(entry),
|
|
16223
16596
|
onMouseEnter: () => !isDisabled && setHoveredId(wallet.id),
|
|
16224
16597
|
onMouseLeave: () => setHoveredId(null),
|
|
16225
16598
|
style: {
|
|
@@ -16295,7 +16668,7 @@ function MobileWalletDropdownContent({
|
|
|
16295
16668
|
}
|
|
16296
16669
|
}
|
|
16297
16670
|
),
|
|
16298
|
-
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "
|
|
16671
|
+
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "Continue" })
|
|
16299
16672
|
]
|
|
16300
16673
|
}
|
|
16301
16674
|
)
|
|
@@ -16360,7 +16733,9 @@ function CryptoWalletDropdownContent({
|
|
|
16360
16733
|
isMobile && /* @__PURE__ */ jsx36(
|
|
16361
16734
|
MobileWalletDropdownContent,
|
|
16362
16735
|
{
|
|
16363
|
-
|
|
16736
|
+
browserWallets,
|
|
16737
|
+
handleWalletConnect,
|
|
16738
|
+
handleWalletSelect
|
|
16364
16739
|
}
|
|
16365
16740
|
)
|
|
16366
16741
|
] });
|
|
@@ -16830,7 +17205,7 @@ var init_HomePaymentOptions = __esm({
|
|
|
16830
17205
|
});
|
|
16831
17206
|
|
|
16832
17207
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
16833
|
-
import { useCallback as useCallback18, useEffect as
|
|
17208
|
+
import { useCallback as useCallback18, useEffect as useEffect25, useMemo as useMemo18, useRef as useRef12, useState as useState25 } from "react";
|
|
16834
17209
|
function useHomeWalletActions({
|
|
16835
17210
|
connectWallet,
|
|
16836
17211
|
detectedWallets,
|
|
@@ -16839,12 +17214,12 @@ function useHomeWalletActions({
|
|
|
16839
17214
|
WalletConnect
|
|
16840
17215
|
// setCurrentStepInternal,
|
|
16841
17216
|
}) {
|
|
16842
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] =
|
|
16843
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] =
|
|
16844
|
-
const cryptoDropdownRef =
|
|
16845
|
-
const fiatDropdownRef =
|
|
17217
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = useState25(false);
|
|
17218
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = useState25(false);
|
|
17219
|
+
const cryptoDropdownRef = useRef12(null);
|
|
17220
|
+
const fiatDropdownRef = useRef12(null);
|
|
16846
17221
|
const { disconnect } = useWalletInfo();
|
|
16847
|
-
|
|
17222
|
+
useEffect25(() => {
|
|
16848
17223
|
const handleClickOutside = (event) => {
|
|
16849
17224
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
16850
17225
|
setIsCryptoDropdownOpen(false);
|
|
@@ -16894,9 +17269,11 @@ function useHomeWalletActions({
|
|
|
16894
17269
|
const { selectedNamespace } = useDepositWallet();
|
|
16895
17270
|
const browserWallets = useMemo18(() => {
|
|
16896
17271
|
if (!detectedWallets?.length) return [];
|
|
16897
|
-
return detectedWallets.filter(
|
|
16898
|
-
(wallet
|
|
16899
|
-
|
|
17272
|
+
return detectedWallets.filter((wallet) => {
|
|
17273
|
+
if (wallet?.meta?.id === "walletconnect") return false;
|
|
17274
|
+
const ecosystem = wallet?.meta?.ecosystem.trim().toLowerCase();
|
|
17275
|
+
return ecosystem === "multi" || ecosystem === selectedNamespace.trim().toLowerCase();
|
|
17276
|
+
});
|
|
16900
17277
|
}, [detectedWallets, selectedNamespace]);
|
|
16901
17278
|
return {
|
|
16902
17279
|
browserWallets,
|
|
@@ -16930,11 +17307,114 @@ var init_wallet = __esm({
|
|
|
16930
17307
|
});
|
|
16931
17308
|
|
|
16932
17309
|
// src/widget/pages/Home.tsx
|
|
16933
|
-
import { jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
17310
|
+
import { Fragment as Fragment8, jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
17311
|
+
function WalletConnectStatusBanner({
|
|
17312
|
+
status,
|
|
17313
|
+
errorMessage,
|
|
17314
|
+
onRetry,
|
|
17315
|
+
onDismiss
|
|
17316
|
+
}) {
|
|
17317
|
+
const isDone = status !== "connecting";
|
|
17318
|
+
const isFailed = status === "failed";
|
|
17319
|
+
const { text, icon } = wcBannerCopy[status];
|
|
17320
|
+
return /* @__PURE__ */ jsxs35(
|
|
17321
|
+
"div",
|
|
17322
|
+
{
|
|
17323
|
+
style: {
|
|
17324
|
+
display: "flex",
|
|
17325
|
+
alignItems: "center",
|
|
17326
|
+
gap: spacing[2],
|
|
17327
|
+
width: "100%",
|
|
17328
|
+
padding: `${spacing[2.5]} ${spacing[3]}`,
|
|
17329
|
+
marginBottom: spacing[4],
|
|
17330
|
+
borderRadius: borderRadius.lg,
|
|
17331
|
+
backgroundColor: isFailed ? "rgba(239,68,68,0.1)" : isDone ? "rgba(234,179,8,0.1)" : colors.muted,
|
|
17332
|
+
border: isFailed ? "1px solid rgba(239,68,68,0.4)" : isDone ? "1px solid rgba(234,179,8,0.4)" : `1px solid ${colors.border}`
|
|
17333
|
+
},
|
|
17334
|
+
children: [
|
|
17335
|
+
icon === "spinner" ? /* @__PURE__ */ jsx44(
|
|
17336
|
+
"div",
|
|
17337
|
+
{
|
|
17338
|
+
style: {
|
|
17339
|
+
width: "0.875rem",
|
|
17340
|
+
height: "0.875rem",
|
|
17341
|
+
border: `2px solid ${colors.mutedForeground}`,
|
|
17342
|
+
borderTopColor: "transparent",
|
|
17343
|
+
borderRadius: "9999px",
|
|
17344
|
+
animation: "tw-spin 1s linear infinite",
|
|
17345
|
+
flexShrink: 0
|
|
17346
|
+
}
|
|
17347
|
+
}
|
|
17348
|
+
) : /* @__PURE__ */ jsx44("span", { style: { fontSize: fontSize.sm, flexShrink: 0 }, "aria-hidden": true, children: icon }),
|
|
17349
|
+
/* @__PURE__ */ jsxs35(
|
|
17350
|
+
"p",
|
|
17351
|
+
{
|
|
17352
|
+
style: {
|
|
17353
|
+
flex: 1,
|
|
17354
|
+
fontSize: fontSize.xs,
|
|
17355
|
+
color: isDone ? colors.foreground : colors.mutedForeground,
|
|
17356
|
+
margin: 0
|
|
17357
|
+
},
|
|
17358
|
+
children: [
|
|
17359
|
+
text,
|
|
17360
|
+
isFailed && errorMessage ? ` ${errorMessage}` : ""
|
|
17361
|
+
]
|
|
17362
|
+
}
|
|
17363
|
+
),
|
|
17364
|
+
isDone && /* @__PURE__ */ jsxs35(Fragment8, { children: [
|
|
17365
|
+
/* @__PURE__ */ jsx44(
|
|
17366
|
+
"button",
|
|
17367
|
+
{
|
|
17368
|
+
type: "button",
|
|
17369
|
+
onClick: onRetry,
|
|
17370
|
+
style: {
|
|
17371
|
+
fontSize: fontSize.xs,
|
|
17372
|
+
fontWeight: fontWeight.semibold,
|
|
17373
|
+
color: colors.primary,
|
|
17374
|
+
backgroundColor: "transparent",
|
|
17375
|
+
border: 0,
|
|
17376
|
+
cursor: "pointer",
|
|
17377
|
+
flexShrink: 0
|
|
17378
|
+
},
|
|
17379
|
+
children: "Retry"
|
|
17380
|
+
}
|
|
17381
|
+
),
|
|
17382
|
+
/* @__PURE__ */ jsx44(
|
|
17383
|
+
"button",
|
|
17384
|
+
{
|
|
17385
|
+
type: "button",
|
|
17386
|
+
onClick: onDismiss,
|
|
17387
|
+
"aria-label": "Dismiss",
|
|
17388
|
+
style: {
|
|
17389
|
+
fontSize: fontSize.xs,
|
|
17390
|
+
color: colors.mutedForeground,
|
|
17391
|
+
backgroundColor: "transparent",
|
|
17392
|
+
border: 0,
|
|
17393
|
+
cursor: "pointer",
|
|
17394
|
+
flexShrink: 0,
|
|
17395
|
+
padding: 0,
|
|
17396
|
+
lineHeight: 1
|
|
17397
|
+
},
|
|
17398
|
+
children: "\xD7"
|
|
17399
|
+
}
|
|
17400
|
+
)
|
|
17401
|
+
] })
|
|
17402
|
+
]
|
|
17403
|
+
}
|
|
17404
|
+
);
|
|
17405
|
+
}
|
|
16934
17406
|
function Home({ style: _style }) {
|
|
16935
17407
|
const { amount, setAmount, amountInputMode, setAmountInputMode } = useDepositForm();
|
|
16936
17408
|
const { setCurrentStep, setCurrentStepInternal } = useDepositNavigation();
|
|
16937
|
-
const {
|
|
17409
|
+
const {
|
|
17410
|
+
connectWallet,
|
|
17411
|
+
WalletConnect,
|
|
17412
|
+
setWalletType,
|
|
17413
|
+
wcStatus,
|
|
17414
|
+
wcErrorMessage,
|
|
17415
|
+
retryWalletConnect,
|
|
17416
|
+
dismissWcStatus
|
|
17417
|
+
} = useDepositWallet();
|
|
16938
17418
|
const { resolvedTheme } = useDepositUi();
|
|
16939
17419
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
16940
17420
|
const { detected: detectedWallets } = useWalletDetection();
|
|
@@ -17016,6 +17496,15 @@ function Home({ style: _style }) {
|
|
|
17016
17496
|
position: "relative"
|
|
17017
17497
|
},
|
|
17018
17498
|
children: [
|
|
17499
|
+
wcStatus !== "idle" && /* @__PURE__ */ jsx44(
|
|
17500
|
+
WalletConnectStatusBanner,
|
|
17501
|
+
{
|
|
17502
|
+
status: wcStatus,
|
|
17503
|
+
errorMessage: wcErrorMessage,
|
|
17504
|
+
onRetry: retryWalletConnect,
|
|
17505
|
+
onDismiss: dismissWcStatus
|
|
17506
|
+
}
|
|
17507
|
+
),
|
|
17019
17508
|
/* @__PURE__ */ jsx44(
|
|
17020
17509
|
"p",
|
|
17021
17510
|
{
|
|
@@ -17091,6 +17580,7 @@ function Home({ style: _style }) {
|
|
|
17091
17580
|
}
|
|
17092
17581
|
);
|
|
17093
17582
|
}
|
|
17583
|
+
var wcBannerCopy;
|
|
17094
17584
|
var init_Home = __esm({
|
|
17095
17585
|
"src/widget/pages/Home.tsx"() {
|
|
17096
17586
|
"use strict";
|
|
@@ -17100,6 +17590,20 @@ var init_Home = __esm({
|
|
|
17100
17590
|
init_amount();
|
|
17101
17591
|
init_wallets();
|
|
17102
17592
|
init_wallet();
|
|
17593
|
+
wcBannerCopy = {
|
|
17594
|
+
connecting: {
|
|
17595
|
+
text: "Waiting for wallet approval via WalletConnect\u2026",
|
|
17596
|
+
icon: "spinner"
|
|
17597
|
+
},
|
|
17598
|
+
timedOut: {
|
|
17599
|
+
text: "Still waiting on WalletConnect \u2014 this is taking longer than expected.",
|
|
17600
|
+
icon: "\u26A0\uFE0F"
|
|
17601
|
+
},
|
|
17602
|
+
failed: {
|
|
17603
|
+
text: "WalletConnect connection failed.",
|
|
17604
|
+
icon: "\u2715"
|
|
17605
|
+
}
|
|
17606
|
+
};
|
|
17103
17607
|
}
|
|
17104
17608
|
});
|
|
17105
17609
|
|
|
@@ -30905,7 +31409,7 @@ async function sendRouteAsUserOperation(params) {
|
|
|
30905
31409
|
);
|
|
30906
31410
|
}
|
|
30907
31411
|
console.debug("[send] UserOp included", { userOpHash, txHash });
|
|
30908
|
-
await submitReceipt(intentId, txHash, getSponsorshipRequestId());
|
|
31412
|
+
await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
|
|
30909
31413
|
return { userOpHash, txHash, intentId };
|
|
30910
31414
|
}
|
|
30911
31415
|
var NATIVE_ADDRS;
|
|
@@ -30950,7 +31454,7 @@ var init_smart_account2 = __esm({
|
|
|
30950
31454
|
});
|
|
30951
31455
|
|
|
30952
31456
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
30953
|
-
import { useCallback as useCallback19, useEffect as
|
|
31457
|
+
import { useCallback as useCallback19, useEffect as useEffect26, useMemo as useMemo20, useRef as useRef13, useState as useState26 } from "react";
|
|
30954
31458
|
import { encodeFunctionData as encodeFunctionData8, erc20Abi } from "viem";
|
|
30955
31459
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
30956
31460
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
@@ -30972,7 +31476,7 @@ function useTransactionActionModel({
|
|
|
30972
31476
|
walletAddress,
|
|
30973
31477
|
walletStatus
|
|
30974
31478
|
}) {
|
|
30975
|
-
const feeDataCacheRef =
|
|
31479
|
+
const feeDataCacheRef = useRef13({});
|
|
30976
31480
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
30977
31481
|
const { trackEvent } = useGTM(GTM_ID);
|
|
30978
31482
|
const destinationConfig = (() => {
|
|
@@ -31024,10 +31528,10 @@ function useTransactionActionModel({
|
|
|
31024
31528
|
const addr = txReq?.to ?? txReq?.target;
|
|
31025
31529
|
return addr ?? null;
|
|
31026
31530
|
}, [routeResult?.txReq]);
|
|
31027
|
-
const [allowanceWei, setAllowanceWei] =
|
|
31028
|
-
const [isReadingAllowance, setIsReadingAllowance] =
|
|
31029
|
-
const [isApproving, setIsApproving] =
|
|
31030
|
-
const [gasReservationWei, setGasReservationWei] =
|
|
31531
|
+
const [allowanceWei, setAllowanceWei] = useState26(0n);
|
|
31532
|
+
const [isReadingAllowance, setIsReadingAllowance] = useState26(false);
|
|
31533
|
+
const [isApproving, setIsApproving] = useState26(false);
|
|
31534
|
+
const [gasReservationWei, setGasReservationWei] = useState26(0n);
|
|
31031
31535
|
const readAllowance = useCallback19(async () => {
|
|
31032
31536
|
if (!isEvm || isNativeSelected || !!routeResult?.sponsorship || // sponsored routes: SA approves bridge inside the UO batch
|
|
31033
31537
|
!backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
@@ -31058,7 +31562,7 @@ function useTransactionActionModel({
|
|
|
31058
31562
|
spender,
|
|
31059
31563
|
walletAddress
|
|
31060
31564
|
]);
|
|
31061
|
-
|
|
31565
|
+
useEffect26(() => {
|
|
31062
31566
|
void readAllowance();
|
|
31063
31567
|
}, [readAllowance]);
|
|
31064
31568
|
const needsApproval = isEvm && !isNativeSelected && !routeResult?.sponsorship && // sponsored routes use Permit2 + SA internal batch — no EOA bridge approval
|
|
@@ -31262,13 +31766,13 @@ function useTransactionActionModel({
|
|
|
31262
31766
|
routeResult?.txReq,
|
|
31263
31767
|
walletAddress
|
|
31264
31768
|
]);
|
|
31265
|
-
|
|
31769
|
+
useEffect26(() => {
|
|
31266
31770
|
if (routeResult) {
|
|
31267
31771
|
void estimateGasReservationWei();
|
|
31268
31772
|
}
|
|
31269
31773
|
}, [estimateGasReservationWei, routeResult]);
|
|
31270
|
-
const [smartAccountFailed, setSmartAccountFailed] =
|
|
31271
|
-
|
|
31774
|
+
const [smartAccountFailed, setSmartAccountFailed] = useState26(false);
|
|
31775
|
+
useEffect26(() => {
|
|
31272
31776
|
setSmartAccountFailed(false);
|
|
31273
31777
|
}, [routeResult?.intentId]);
|
|
31274
31778
|
const handleConfirm = useCallback19(async () => {
|
|
@@ -31602,12 +32106,12 @@ var init_DefaultCryptoPay = __esm({
|
|
|
31602
32106
|
});
|
|
31603
32107
|
|
|
31604
32108
|
// src/widget/pages/CryptoPay/RouteQuoteLoader.tsx
|
|
31605
|
-
import { useState as
|
|
32109
|
+
import { useState as useState27, useEffect as useEffect27 } from "react";
|
|
31606
32110
|
import { jsx as jsx49, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
31607
32111
|
function RouteQuoteLoader({ selectedToken }) {
|
|
31608
|
-
const [messageIndex, setMessageIndex] =
|
|
31609
|
-
const [visible, setVisible] =
|
|
31610
|
-
|
|
32112
|
+
const [messageIndex, setMessageIndex] = useState27(0);
|
|
32113
|
+
const [visible, setVisible] = useState27(true);
|
|
32114
|
+
useEffect27(() => {
|
|
31611
32115
|
let t = null;
|
|
31612
32116
|
const interval = setInterval(() => {
|
|
31613
32117
|
setVisible(false);
|
|
@@ -31783,8 +32287,8 @@ var init_RouteQuoteLoader = __esm({
|
|
|
31783
32287
|
});
|
|
31784
32288
|
|
|
31785
32289
|
// src/widget/pages/CryptoPay/index.tsx
|
|
31786
|
-
import { useEffect as
|
|
31787
|
-
import { Fragment as
|
|
32290
|
+
import { useEffect as useEffect28, useMemo as useMemo21 } from "react";
|
|
32291
|
+
import { Fragment as Fragment9, jsx as jsx50, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
31788
32292
|
function CryptoPay({ style: _style }) {
|
|
31789
32293
|
const {
|
|
31790
32294
|
amount,
|
|
@@ -31893,7 +32397,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31893
32397
|
});
|
|
31894
32398
|
const { emitError } = useTrustware();
|
|
31895
32399
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
31896
|
-
|
|
32400
|
+
useEffect28(() => {
|
|
31897
32401
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
31898
32402
|
emitError?.(
|
|
31899
32403
|
new TrustwareError({
|
|
@@ -32023,7 +32527,7 @@ function CryptoPay({ style: _style }) {
|
|
|
32023
32527
|
]
|
|
32024
32528
|
}
|
|
32025
32529
|
),
|
|
32026
|
-
showSkeleton ? /* @__PURE__ */ jsx50(
|
|
32530
|
+
showSkeleton ? /* @__PURE__ */ jsx50(Fragment9, { children: /* @__PURE__ */ jsx50(
|
|
32027
32531
|
"div",
|
|
32028
32532
|
{
|
|
32029
32533
|
style: {
|
|
@@ -32034,8 +32538,8 @@ function CryptoPay({ style: _style }) {
|
|
|
32034
32538
|
},
|
|
32035
32539
|
children: /* @__PURE__ */ jsx50(LoadingSkeleton, {})
|
|
32036
32540
|
}
|
|
32037
|
-
) }) : /* @__PURE__ */ jsxs40(
|
|
32038
|
-
isReady && /* @__PURE__ */ jsx50(
|
|
32541
|
+
) }) : /* @__PURE__ */ jsxs40(Fragment9, { children: [
|
|
32542
|
+
isReady && /* @__PURE__ */ jsx50(Fragment9, { children: isLoadingRoute && !routeResult ? /* @__PURE__ */ jsx50(RouteQuoteLoader, { selectedToken: readySelectedToken }) : /* @__PURE__ */ jsxs40(Fragment9, { children: [
|
|
32039
32543
|
/* @__PURE__ */ jsx50(
|
|
32040
32544
|
CryptoPayAmountSection,
|
|
32041
32545
|
{
|
|
@@ -32114,7 +32618,7 @@ var init_CryptoPay = __esm({
|
|
|
32114
32618
|
});
|
|
32115
32619
|
|
|
32116
32620
|
// src/widget/pages/Processing.tsx
|
|
32117
|
-
import { useEffect as
|
|
32621
|
+
import { useEffect as useEffect29, useMemo as useMemo22, useRef as useRef14 } from "react";
|
|
32118
32622
|
import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
32119
32623
|
function getProgressFromStatus(status) {
|
|
32120
32624
|
switch (status) {
|
|
@@ -32153,13 +32657,13 @@ function Processing({ style }) {
|
|
|
32153
32657
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
32154
32658
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
32155
32659
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
32156
|
-
const hasStartedPolling =
|
|
32157
|
-
|
|
32660
|
+
const hasStartedPolling = useRef14(false);
|
|
32661
|
+
useEffect29(() => {
|
|
32158
32662
|
return () => {
|
|
32159
32663
|
hasStartedPolling.current = false;
|
|
32160
32664
|
};
|
|
32161
32665
|
}, []);
|
|
32162
|
-
|
|
32666
|
+
useEffect29(() => {
|
|
32163
32667
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
32164
32668
|
hasStartedPolling.current = true;
|
|
32165
32669
|
startPolling(intentId, transactionHash);
|
|
@@ -32659,14 +33163,14 @@ var init_WidgetRouter = __esm({
|
|
|
32659
33163
|
});
|
|
32660
33164
|
|
|
32661
33165
|
// src/modes/swap/hooks/useSwapRoute.ts
|
|
32662
|
-
import { useCallback as useCallback20, useRef as
|
|
33166
|
+
import { useCallback as useCallback20, useRef as useRef15, useState as useState28 } from "react";
|
|
32663
33167
|
function useSwapRoute() {
|
|
32664
|
-
const [state, setState] =
|
|
33168
|
+
const [state, setState] = useState28({
|
|
32665
33169
|
data: null,
|
|
32666
33170
|
loading: false,
|
|
32667
33171
|
error: null
|
|
32668
33172
|
});
|
|
32669
|
-
const abortRef =
|
|
33173
|
+
const abortRef = useRef15(false);
|
|
32670
33174
|
const fetch2 = useCallback20(
|
|
32671
33175
|
async (params) => {
|
|
32672
33176
|
const { fromToken, fromChain, toToken, toChain, amount, walletAddress } = params;
|
|
@@ -32725,7 +33229,7 @@ var init_useSwapRoute = __esm({
|
|
|
32725
33229
|
});
|
|
32726
33230
|
|
|
32727
33231
|
// src/modes/swap/hooks/useSwapExecution.ts
|
|
32728
|
-
import { useCallback as useCallback21, useRef as
|
|
33232
|
+
import { useCallback as useCallback21, useRef as useRef16, useState as useState29 } from "react";
|
|
32729
33233
|
import { encodeFunctionData as encodeFunctionData9, erc20Abi as erc20Abi2 } from "viem";
|
|
32730
33234
|
function normalizeTx(raw) {
|
|
32731
33235
|
const r = raw;
|
|
@@ -32760,7 +33264,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
32760
33264
|
throw new Error("Timed out waiting for approval confirmation");
|
|
32761
33265
|
}
|
|
32762
33266
|
function useSwapExecution(fromChain) {
|
|
32763
|
-
const [state, setState] =
|
|
33267
|
+
const [state, setState] = useState29({
|
|
32764
33268
|
txStatus: "idle",
|
|
32765
33269
|
txHash: null,
|
|
32766
33270
|
intentId: null,
|
|
@@ -32769,11 +33273,11 @@ function useSwapExecution(fromChain) {
|
|
|
32769
33273
|
isSubmitting: false,
|
|
32770
33274
|
allowanceStatus: "unknown"
|
|
32771
33275
|
});
|
|
32772
|
-
const saFailedUntilRef =
|
|
32773
|
-
const pollingRef =
|
|
32774
|
-
const timeoutRef =
|
|
32775
|
-
const abortRef =
|
|
32776
|
-
const pollCountRef =
|
|
33276
|
+
const saFailedUntilRef = useRef16(0);
|
|
33277
|
+
const pollingRef = useRef16(null);
|
|
33278
|
+
const timeoutRef = useRef16(null);
|
|
33279
|
+
const abortRef = useRef16(false);
|
|
33280
|
+
const pollCountRef = useRef16(0);
|
|
32777
33281
|
const clearPolling = useCallback21(() => {
|
|
32778
33282
|
abortRef.current = true;
|
|
32779
33283
|
if (pollingRef.current) clearTimeout(pollingRef.current);
|
|
@@ -33136,13 +33640,13 @@ var init_forex = __esm({
|
|
|
33136
33640
|
});
|
|
33137
33641
|
|
|
33138
33642
|
// src/modes/swap/hooks/useForex.ts
|
|
33139
|
-
import { useEffect as
|
|
33643
|
+
import { useEffect as useEffect30, useRef as useRef17, useState as useState30 } from "react";
|
|
33140
33644
|
function useForex() {
|
|
33141
|
-
const [rates, setRates] =
|
|
33142
|
-
const [error, setError] =
|
|
33143
|
-
const [lastUpdated, setLastUpdated] =
|
|
33144
|
-
const timerRef =
|
|
33145
|
-
|
|
33645
|
+
const [rates, setRates] = useState30({ USD: 1 });
|
|
33646
|
+
const [error, setError] = useState30(null);
|
|
33647
|
+
const [lastUpdated, setLastUpdated] = useState30(null);
|
|
33648
|
+
const timerRef = useRef17(null);
|
|
33649
|
+
useEffect30(() => {
|
|
33146
33650
|
let cancelled = false;
|
|
33147
33651
|
const load = () => {
|
|
33148
33652
|
fetchForexRates("USD").then((r) => {
|
|
@@ -33179,7 +33683,7 @@ var init_useForex = __esm({
|
|
|
33179
33683
|
});
|
|
33180
33684
|
|
|
33181
33685
|
// src/modes/swap/components/SwapTokenSelect.tsx
|
|
33182
|
-
import { useState as
|
|
33686
|
+
import { useState as useState31, useMemo as useMemo26, useEffect as useEffect31 } from "react";
|
|
33183
33687
|
import { jsx as jsx55, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
33184
33688
|
function SwapTokenSelect({
|
|
33185
33689
|
side,
|
|
@@ -33195,10 +33699,10 @@ function SwapTokenSelect({
|
|
|
33195
33699
|
allowedTokens,
|
|
33196
33700
|
excludeToken
|
|
33197
33701
|
}) {
|
|
33198
|
-
const [localChain, setLocalChain] =
|
|
33199
|
-
const [pinnedTokens, setPinnedTokens] =
|
|
33200
|
-
const [pinnedLoading, setPinnedLoading] =
|
|
33201
|
-
|
|
33702
|
+
const [localChain, setLocalChain] = useState31(initialChain);
|
|
33703
|
+
const [pinnedTokens, setPinnedTokens] = useState31([]);
|
|
33704
|
+
const [pinnedLoading, setPinnedLoading] = useState31(false);
|
|
33705
|
+
useEffect31(() => {
|
|
33202
33706
|
if (!allowedTokens || allowedTokens.length === 0 || !localChain) {
|
|
33203
33707
|
setPinnedTokens([]);
|
|
33204
33708
|
return;
|
|
@@ -33500,8 +34004,8 @@ var init_currency = __esm({
|
|
|
33500
34004
|
});
|
|
33501
34005
|
|
|
33502
34006
|
// src/modes/swap/components/SwapWalletSelector/SwapWalletSelectorMobile.tsx
|
|
33503
|
-
import { useEffect as
|
|
33504
|
-
import { Fragment as
|
|
34007
|
+
import { useEffect as useEffect32, useMemo as useMemo27, useRef as useRef18, useState as useState32 } from "react";
|
|
34008
|
+
import { Fragment as Fragment10, jsx as jsx56, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
33505
34009
|
function SwapWalletSelectorMobile({
|
|
33506
34010
|
walletStatus,
|
|
33507
34011
|
walletAddress,
|
|
@@ -33518,14 +34022,14 @@ function SwapWalletSelectorMobile({
|
|
|
33518
34022
|
} = useWalletInfo();
|
|
33519
34023
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
33520
34024
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
33521
|
-
const [wcConnecting, setWcConnecting] =
|
|
33522
|
-
const [connectingId, setConnectingId] =
|
|
33523
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
33524
|
-
const prevStatusRef =
|
|
33525
|
-
const storeFallbackTimeoutRef =
|
|
34025
|
+
const [wcConnecting, setWcConnecting] = useState32(false);
|
|
34026
|
+
const [connectingId, setConnectingId] = useState32(null);
|
|
34027
|
+
const [selectedNamespace, setSelectedNamespace] = useState32("evm");
|
|
34028
|
+
const prevStatusRef = useRef18(walletStatus);
|
|
34029
|
+
const storeFallbackTimeoutRef = useRef18(
|
|
33526
34030
|
null
|
|
33527
34031
|
);
|
|
33528
|
-
|
|
34032
|
+
useEffect32(() => {
|
|
33529
34033
|
const prev = prevStatusRef.current;
|
|
33530
34034
|
if (prev !== walletStatus) {
|
|
33531
34035
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -33534,7 +34038,7 @@ function SwapWalletSelectorMobile({
|
|
|
33534
34038
|
prevStatusRef.current = walletStatus;
|
|
33535
34039
|
}
|
|
33536
34040
|
}, [walletStatus]);
|
|
33537
|
-
|
|
34041
|
+
useEffect32(() => {
|
|
33538
34042
|
return () => {
|
|
33539
34043
|
if (storeFallbackTimeoutRef.current !== null) {
|
|
33540
34044
|
clearTimeout(storeFallbackTimeoutRef.current);
|
|
@@ -33799,6 +34303,7 @@ function SwapWalletSelectorMobile({
|
|
|
33799
34303
|
const { meta } = entry;
|
|
33800
34304
|
const isWalletConnected = managerConnected && walletMetaId === meta.id;
|
|
33801
34305
|
const isConnecting = connectingId === meta.id && walletStatus === "connecting";
|
|
34306
|
+
const isRowDisabled = managerConnected && !isWalletConnected && !entry.detectedWallet;
|
|
33802
34307
|
return /* @__PURE__ */ jsxs44(
|
|
33803
34308
|
"div",
|
|
33804
34309
|
{
|
|
@@ -33816,7 +34321,8 @@ function SwapWalletSelectorMobile({
|
|
|
33816
34321
|
isWalletConnected && {
|
|
33817
34322
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
33818
34323
|
border: `1px solid ${colors.primary}`
|
|
33819
|
-
}
|
|
34324
|
+
},
|
|
34325
|
+
isRowDisabled && { opacity: 0.4 }
|
|
33820
34326
|
),
|
|
33821
34327
|
children: [
|
|
33822
34328
|
/* @__PURE__ */ jsx56(
|
|
@@ -33907,7 +34413,7 @@ function SwapWalletSelectorMobile({
|
|
|
33907
34413
|
"button",
|
|
33908
34414
|
{
|
|
33909
34415
|
onClick: () => void handleClick(entry),
|
|
33910
|
-
disabled: walletStatus === "connecting",
|
|
34416
|
+
disabled: walletStatus === "connecting" || isRowDisabled,
|
|
33911
34417
|
style: mergeStyles(
|
|
33912
34418
|
{
|
|
33913
34419
|
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
@@ -33920,7 +34426,7 @@ function SwapWalletSelectorMobile({
|
|
|
33920
34426
|
cursor: "pointer",
|
|
33921
34427
|
flexShrink: 0
|
|
33922
34428
|
},
|
|
33923
|
-
walletStatus === "connecting" && {
|
|
34429
|
+
(walletStatus === "connecting" || isRowDisabled) && {
|
|
33924
34430
|
opacity: 0.5,
|
|
33925
34431
|
cursor: "not-allowed"
|
|
33926
34432
|
}
|
|
@@ -33935,7 +34441,7 @@ function SwapWalletSelectorMobile({
|
|
|
33935
34441
|
})
|
|
33936
34442
|
}
|
|
33937
34443
|
),
|
|
33938
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(
|
|
34444
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(Fragment10, { children: [
|
|
33939
34445
|
/* @__PURE__ */ jsx56(
|
|
33940
34446
|
"div",
|
|
33941
34447
|
{
|
|
@@ -33948,6 +34454,7 @@ function SwapWalletSelectorMobile({
|
|
|
33948
34454
|
),
|
|
33949
34455
|
(() => {
|
|
33950
34456
|
const wcConnected = managerConnected && connectedVia === "walletconnect";
|
|
34457
|
+
const wcRowDisabled = managerConnected && !wcConnected;
|
|
33951
34458
|
return /* @__PURE__ */ jsxs44(
|
|
33952
34459
|
"div",
|
|
33953
34460
|
{
|
|
@@ -33966,9 +34473,10 @@ function SwapWalletSelectorMobile({
|
|
|
33966
34473
|
wcConnected && {
|
|
33967
34474
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
33968
34475
|
border: `1px solid ${colors.primary}`
|
|
33969
|
-
}
|
|
34476
|
+
},
|
|
34477
|
+
wcRowDisabled && { opacity: 0.4, cursor: "not-allowed" }
|
|
33970
34478
|
),
|
|
33971
|
-
onClick: !wcConnected ? () => void handleWalletConnect() : void 0,
|
|
34479
|
+
onClick: !wcConnected && !wcRowDisabled ? () => void handleWalletConnect() : void 0,
|
|
33972
34480
|
children: [
|
|
33973
34481
|
/* @__PURE__ */ jsx56(
|
|
33974
34482
|
"div",
|
|
@@ -34064,18 +34572,24 @@ function SwapWalletSelectorMobile({
|
|
|
34064
34572
|
e2.stopPropagation();
|
|
34065
34573
|
void handleWalletConnect();
|
|
34066
34574
|
},
|
|
34067
|
-
disabled: wcConnecting,
|
|
34068
|
-
style:
|
|
34069
|
-
|
|
34070
|
-
|
|
34071
|
-
|
|
34072
|
-
|
|
34073
|
-
|
|
34074
|
-
|
|
34075
|
-
|
|
34076
|
-
|
|
34077
|
-
|
|
34078
|
-
|
|
34575
|
+
disabled: wcConnecting || wcRowDisabled,
|
|
34576
|
+
style: mergeStyles(
|
|
34577
|
+
{
|
|
34578
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
34579
|
+
borderRadius: "9999px",
|
|
34580
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
34581
|
+
color: colors.primary,
|
|
34582
|
+
fontSize: fontSize.xs,
|
|
34583
|
+
fontWeight: fontWeight.medium,
|
|
34584
|
+
border: 0,
|
|
34585
|
+
cursor: "pointer",
|
|
34586
|
+
flexShrink: 0
|
|
34587
|
+
},
|
|
34588
|
+
(wcConnecting || wcRowDisabled) && {
|
|
34589
|
+
opacity: 0.5,
|
|
34590
|
+
cursor: "not-allowed"
|
|
34591
|
+
}
|
|
34592
|
+
),
|
|
34079
34593
|
children: "Connect"
|
|
34080
34594
|
}
|
|
34081
34595
|
)
|
|
@@ -34106,8 +34620,8 @@ var init_SwapWalletSelectorMobile = __esm({
|
|
|
34106
34620
|
});
|
|
34107
34621
|
|
|
34108
34622
|
// src/modes/swap/components/SwapWalletSelector/SwapWalletSelectorDesktop.tsx
|
|
34109
|
-
import { useEffect as
|
|
34110
|
-
import { Fragment as
|
|
34623
|
+
import { useEffect as useEffect33, useMemo as useMemo28, useRef as useRef19, useState as useState33 } from "react";
|
|
34624
|
+
import { Fragment as Fragment11, jsx as jsx57, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
34111
34625
|
function SwapWalletSelectorDesktop({
|
|
34112
34626
|
walletStatus,
|
|
34113
34627
|
walletAddress,
|
|
@@ -34123,16 +34637,16 @@ function SwapWalletSelectorDesktop({
|
|
|
34123
34637
|
} = useWalletInfo();
|
|
34124
34638
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
34125
34639
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
34126
|
-
const [wcConnecting, setWcConnecting] =
|
|
34127
|
-
const [connectingId, setConnectingId] =
|
|
34128
|
-
const [timerExpired, setTimerExpired] =
|
|
34129
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
34130
|
-
const prevStatusRef =
|
|
34131
|
-
|
|
34640
|
+
const [wcConnecting, setWcConnecting] = useState33(false);
|
|
34641
|
+
const [connectingId, setConnectingId] = useState33(null);
|
|
34642
|
+
const [timerExpired, setTimerExpired] = useState33(false);
|
|
34643
|
+
const [selectedNamespace, setSelectedNamespace] = useState33("evm");
|
|
34644
|
+
const prevStatusRef = useRef19(walletStatus);
|
|
34645
|
+
useEffect33(() => {
|
|
34132
34646
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
34133
34647
|
return () => clearTimeout(t);
|
|
34134
34648
|
}, []);
|
|
34135
|
-
|
|
34649
|
+
useEffect33(() => {
|
|
34136
34650
|
const prev = prevStatusRef.current;
|
|
34137
34651
|
if (prev !== walletStatus) {
|
|
34138
34652
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -34565,7 +35079,7 @@ function SwapWalletSelectorDesktop({
|
|
|
34565
35079
|
})
|
|
34566
35080
|
}
|
|
34567
35081
|
),
|
|
34568
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs45(
|
|
35082
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs45(Fragment11, { children: [
|
|
34569
35083
|
/* @__PURE__ */ jsx57(
|
|
34570
35084
|
"div",
|
|
34571
35085
|
{
|
|
@@ -34729,7 +35243,7 @@ var init_SwapWalletSelectorDesktop = __esm({
|
|
|
34729
35243
|
});
|
|
34730
35244
|
|
|
34731
35245
|
// src/modes/swap/components/SwapWalletSelector/index.tsx
|
|
34732
|
-
import { Fragment as
|
|
35246
|
+
import { Fragment as Fragment12, jsx as jsx58, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
34733
35247
|
function SwapWalletSelector({
|
|
34734
35248
|
walletStatus,
|
|
34735
35249
|
walletAddress,
|
|
@@ -34737,7 +35251,7 @@ function SwapWalletSelector({
|
|
|
34737
35251
|
onBack
|
|
34738
35252
|
}) {
|
|
34739
35253
|
const isMobile = useIsMobile();
|
|
34740
|
-
return /* @__PURE__ */ jsxs46(
|
|
35254
|
+
return /* @__PURE__ */ jsxs46(Fragment12, { children: [
|
|
34741
35255
|
isMobile && /* @__PURE__ */ jsx58(
|
|
34742
35256
|
SwapWalletSelectorMobile_default,
|
|
34743
35257
|
{
|
|
@@ -34782,13 +35296,13 @@ import {
|
|
|
34782
35296
|
lazy as lazy2,
|
|
34783
35297
|
Suspense as Suspense2,
|
|
34784
35298
|
useCallback as useCallback22,
|
|
34785
|
-
useEffect as
|
|
35299
|
+
useEffect as useEffect34,
|
|
34786
35300
|
useMemo as useMemo29,
|
|
34787
|
-
useRef as
|
|
34788
|
-
useState as
|
|
35301
|
+
useRef as useRef20,
|
|
35302
|
+
useState as useState34
|
|
34789
35303
|
} from "react";
|
|
34790
35304
|
import ReactDOM from "react-dom";
|
|
34791
|
-
import { Fragment as
|
|
35305
|
+
import { Fragment as Fragment13, jsx as jsx59, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
34792
35306
|
function fmtAmount(n, max = 6) {
|
|
34793
35307
|
if (!isFinite(n) || n === 0) return "0";
|
|
34794
35308
|
return n.toLocaleString(void 0, { maximumFractionDigits: max });
|
|
@@ -34880,36 +35394,36 @@ function SwapMode({
|
|
|
34880
35394
|
theme: themeProp,
|
|
34881
35395
|
style
|
|
34882
35396
|
}) {
|
|
34883
|
-
const [stage, setStage] =
|
|
34884
|
-
const [fromToken, setFromToken] =
|
|
35397
|
+
const [stage, setStage] = useState34("home");
|
|
35398
|
+
const [fromToken, setFromToken] = useState34(
|
|
34885
35399
|
null
|
|
34886
35400
|
);
|
|
34887
|
-
const [fromChain, setFromChain] =
|
|
34888
|
-
const [toToken, setToToken] =
|
|
34889
|
-
const [toChain, setToChain] =
|
|
34890
|
-
const [amount, setAmount] =
|
|
34891
|
-
const [amountInputMode, setAmountInputMode] =
|
|
35401
|
+
const [fromChain, setFromChain] = useState34(null);
|
|
35402
|
+
const [toToken, setToToken] = useState34(null);
|
|
35403
|
+
const [toChain, setToChain] = useState34(null);
|
|
35404
|
+
const [amount, setAmount] = useState34("");
|
|
35405
|
+
const [amountInputMode, setAmountInputMode] = useState34(
|
|
34892
35406
|
"usd"
|
|
34893
35407
|
);
|
|
34894
|
-
const [hoverSell, setHoverSell] =
|
|
34895
|
-
const [showRateDetails, setShowRateDetails] =
|
|
34896
|
-
const [showReviewDetails, setShowReviewDetails] =
|
|
34897
|
-
const [showSettings, setShowSettings] =
|
|
34898
|
-
const [maxApproval, setMaxApproval] =
|
|
34899
|
-
const [slippage, setSlippage] =
|
|
34900
|
-
const [slippageInput, setSlippageInput] =
|
|
34901
|
-
const [selectedCurrency, setSelectedCurrency] =
|
|
34902
|
-
const [showCurrencyDropdown, setShowCurrencyDropdown] =
|
|
34903
|
-
const [completedAt, setCompletedAt] =
|
|
34904
|
-
const [copiedHash, setCopiedHash] =
|
|
34905
|
-
const [rateUpdated, setRateUpdated] =
|
|
34906
|
-
const prevToAmountRef =
|
|
34907
|
-
const [destAddress, setDestAddress] =
|
|
34908
|
-
const [quoteAge, setQuoteAge] =
|
|
34909
|
-
const quoteTimestampRef =
|
|
34910
|
-
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] =
|
|
34911
|
-
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] =
|
|
34912
|
-
const latestFetchParamsRef =
|
|
35408
|
+
const [hoverSell, setHoverSell] = useState34(false);
|
|
35409
|
+
const [showRateDetails, setShowRateDetails] = useState34(false);
|
|
35410
|
+
const [showReviewDetails, setShowReviewDetails] = useState34(false);
|
|
35411
|
+
const [showSettings, setShowSettings] = useState34(false);
|
|
35412
|
+
const [maxApproval, setMaxApproval] = useState34(false);
|
|
35413
|
+
const [slippage, setSlippage] = useState34(0.5);
|
|
35414
|
+
const [slippageInput, setSlippageInput] = useState34("");
|
|
35415
|
+
const [selectedCurrency, setSelectedCurrency] = useState34("USD");
|
|
35416
|
+
const [showCurrencyDropdown, setShowCurrencyDropdown] = useState34(false);
|
|
35417
|
+
const [completedAt, setCompletedAt] = useState34(null);
|
|
35418
|
+
const [copiedHash, setCopiedHash] = useState34(null);
|
|
35419
|
+
const [rateUpdated, setRateUpdated] = useState34(false);
|
|
35420
|
+
const prevToAmountRef = useRef20(null);
|
|
35421
|
+
const [destAddress, setDestAddress] = useState34("");
|
|
35422
|
+
const [quoteAge, setQuoteAge] = useState34(0);
|
|
35423
|
+
const quoteTimestampRef = useRef20(null);
|
|
35424
|
+
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = useState34(0);
|
|
35425
|
+
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = useState34(true);
|
|
35426
|
+
const latestFetchParamsRef = useRef20(null);
|
|
34913
35427
|
const { rates: forexRates } = useForex();
|
|
34914
35428
|
const currencyMeta = getCurrencyMeta(selectedCurrency);
|
|
34915
35429
|
const currencyRate = forexRates[selectedCurrency] ?? 1;
|
|
@@ -34925,8 +35439,8 @@ function SwapMode({
|
|
|
34925
35439
|
},
|
|
34926
35440
|
[currencyRate, selectedCurrency]
|
|
34927
35441
|
);
|
|
34928
|
-
const settingsRef =
|
|
34929
|
-
const currencyDropdownRef =
|
|
35442
|
+
const settingsRef = useRef20(null);
|
|
35443
|
+
const currencyDropdownRef = useRef20(null);
|
|
34930
35444
|
const { emitEvent } = useTrustware();
|
|
34931
35445
|
const { features, theme: configTheme } = useTrustwareConfig();
|
|
34932
35446
|
const effectiveThemeSetting = themeProp ?? configTheme ?? "system";
|
|
@@ -34960,8 +35474,8 @@ function SwapMode({
|
|
|
34960
35474
|
() => [...popularChains, ...otherChains],
|
|
34961
35475
|
[popularChains, otherChains]
|
|
34962
35476
|
);
|
|
34963
|
-
const destInitialized =
|
|
34964
|
-
|
|
35477
|
+
const destInitialized = useRef20(false);
|
|
35478
|
+
useEffect34(() => {
|
|
34965
35479
|
if (!defaultDestRef || destInitialized.current || allChains.length === 0)
|
|
34966
35480
|
return;
|
|
34967
35481
|
const chain = allChains.find(
|
|
@@ -34991,7 +35505,7 @@ function SwapMode({
|
|
|
34991
35505
|
}).catch(() => {
|
|
34992
35506
|
});
|
|
34993
35507
|
}, [defaultDestRef, allChains]);
|
|
34994
|
-
const { walletAddress, walletStatus, connectWallet
|
|
35508
|
+
const { walletAddress, walletStatus, connectWallet } = useWalletSessionState();
|
|
34995
35509
|
const setFromTokenStable = useCallback22(
|
|
34996
35510
|
(t) => setFromToken(t),
|
|
34997
35511
|
[]
|
|
@@ -35366,13 +35880,13 @@ function SwapMode({
|
|
|
35366
35880
|
const hasAmount = rawSellNum > 0 && (amountInputMode === "token" || hasFromUsdPrice);
|
|
35367
35881
|
const isConnected = walletStatus === "connected" && !!walletAddress;
|
|
35368
35882
|
const canGetQuote = hasTokens && hasAmount && !insufficient && isConnected && (!needsDestAddress || isValidDestAddress);
|
|
35369
|
-
|
|
35883
|
+
useEffect34(() => {
|
|
35370
35884
|
if (!fromToken) return;
|
|
35371
35885
|
if (!hasFromUsdPrice && amountInputMode === "usd") {
|
|
35372
35886
|
setAmountInputMode("token");
|
|
35373
35887
|
}
|
|
35374
35888
|
}, [fromToken, hasFromUsdPrice, amountInputMode]);
|
|
35375
|
-
|
|
35889
|
+
useEffect34(() => {
|
|
35376
35890
|
if (displayToAmount === null) {
|
|
35377
35891
|
prevToAmountRef.current = null;
|
|
35378
35892
|
return;
|
|
@@ -35386,14 +35900,14 @@ function SwapMode({
|
|
|
35386
35900
|
const t = setTimeout(() => setRateUpdated(false), 700);
|
|
35387
35901
|
return () => clearTimeout(t);
|
|
35388
35902
|
}, [displayToAmount]);
|
|
35389
|
-
|
|
35903
|
+
useEffect34(() => {
|
|
35390
35904
|
setDestAddress("");
|
|
35391
35905
|
}, [toChainType]);
|
|
35392
|
-
const fetchRef =
|
|
35393
|
-
|
|
35906
|
+
const fetchRef = useRef20(route.fetch);
|
|
35907
|
+
useEffect34(() => {
|
|
35394
35908
|
fetchRef.current = route.fetch;
|
|
35395
35909
|
});
|
|
35396
|
-
|
|
35910
|
+
useEffect34(() => {
|
|
35397
35911
|
if (!canGetQuote || stage !== "home") return;
|
|
35398
35912
|
if (!fromToken || !fromChain || !toToken || !toChain || !walletAddress)
|
|
35399
35913
|
return;
|
|
@@ -35422,7 +35936,7 @@ function SwapMode({
|
|
|
35422
35936
|
destAddress,
|
|
35423
35937
|
slippage
|
|
35424
35938
|
]);
|
|
35425
|
-
|
|
35939
|
+
useEffect34(() => {
|
|
35426
35940
|
if (!canGetQuote || !fromToken || !fromChain || !toToken || !toChain || !walletAddress) {
|
|
35427
35941
|
latestFetchParamsRef.current = null;
|
|
35428
35942
|
return;
|
|
@@ -35449,12 +35963,12 @@ function SwapMode({
|
|
|
35449
35963
|
destAddress,
|
|
35450
35964
|
slippage
|
|
35451
35965
|
]);
|
|
35452
|
-
|
|
35966
|
+
useEffect34(() => {
|
|
35453
35967
|
quoteTimestampRef.current = route.data ? Date.now() : null;
|
|
35454
35968
|
setQuoteAge(0);
|
|
35455
35969
|
}, [route.data]);
|
|
35456
|
-
const msgTimeoutRef =
|
|
35457
|
-
|
|
35970
|
+
const msgTimeoutRef = useRef20(null);
|
|
35971
|
+
useEffect34(() => {
|
|
35458
35972
|
if (!route.loading) {
|
|
35459
35973
|
setQuoteLoadingMsgIdx(0);
|
|
35460
35974
|
setQuoteLoadingMsgVisible(true);
|
|
@@ -35472,7 +35986,7 @@ function SwapMode({
|
|
|
35472
35986
|
if (msgTimeoutRef.current !== null) clearTimeout(msgTimeoutRef.current);
|
|
35473
35987
|
};
|
|
35474
35988
|
}, [route.loading]);
|
|
35475
|
-
|
|
35989
|
+
useEffect34(() => {
|
|
35476
35990
|
if (!route.data) return;
|
|
35477
35991
|
const id = setInterval(() => {
|
|
35478
35992
|
const ts = quoteTimestampRef.current;
|
|
@@ -35486,7 +36000,7 @@ function SwapMode({
|
|
|
35486
36000
|
}, 1e3);
|
|
35487
36001
|
return () => clearInterval(id);
|
|
35488
36002
|
}, [route.data]);
|
|
35489
|
-
|
|
36003
|
+
useEffect34(() => {
|
|
35490
36004
|
if (stage !== "review") return;
|
|
35491
36005
|
if (!route.data || !walletAddress) return;
|
|
35492
36006
|
const fromTokenAddress = fromToken?.address;
|
|
@@ -35497,7 +36011,7 @@ function SwapMode({
|
|
|
35497
36011
|
routeResult: route.data
|
|
35498
36012
|
});
|
|
35499
36013
|
}, [stage, route.data, walletAddress, fromToken]);
|
|
35500
|
-
|
|
36014
|
+
useEffect34(() => {
|
|
35501
36015
|
if (!showSettings) {
|
|
35502
36016
|
setShowCurrencyDropdown(false);
|
|
35503
36017
|
return;
|
|
@@ -35510,7 +36024,7 @@ function SwapMode({
|
|
|
35510
36024
|
document.addEventListener("mousedown", handler);
|
|
35511
36025
|
return () => document.removeEventListener("mousedown", handler);
|
|
35512
36026
|
}, [showSettings]);
|
|
35513
|
-
|
|
36027
|
+
useEffect34(() => {
|
|
35514
36028
|
if (!showCurrencyDropdown) return;
|
|
35515
36029
|
const handler = (e2) => {
|
|
35516
36030
|
if (currencyDropdownRef.current && !currencyDropdownRef.current.contains(e2.target)) {
|
|
@@ -35997,7 +36511,7 @@ function SwapMode({
|
|
|
35997
36511
|
padding: 0,
|
|
35998
36512
|
transition: "color 0.15s"
|
|
35999
36513
|
},
|
|
36000
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs47(
|
|
36514
|
+
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs47(Fragment13, { children: [
|
|
36001
36515
|
txHash.slice(0, 6),
|
|
36002
36516
|
"\u2026",
|
|
36003
36517
|
txHash.slice(-4),
|
|
@@ -37069,7 +37583,7 @@ function SwapMode({
|
|
|
37069
37583
|
walletAddress ? /* @__PURE__ */ jsxs47(
|
|
37070
37584
|
"button",
|
|
37071
37585
|
{
|
|
37072
|
-
onClick:
|
|
37586
|
+
onClick: handleConnectAndReview,
|
|
37073
37587
|
style: {
|
|
37074
37588
|
fontSize: fontSize.xs,
|
|
37075
37589
|
color: colors.mutedForeground,
|
|
@@ -37080,8 +37594,7 @@ function SwapMode({
|
|
|
37080
37594
|
children: [
|
|
37081
37595
|
walletAddress.slice(0, 6),
|
|
37082
37596
|
"...",
|
|
37083
|
-
walletAddress.slice(-4)
|
|
37084
|
-
" \xD7"
|
|
37597
|
+
walletAddress.slice(-4)
|
|
37085
37598
|
]
|
|
37086
37599
|
}
|
|
37087
37600
|
) : /* @__PURE__ */ jsx59(
|
|
@@ -38660,8 +39173,8 @@ function ReviewDetailRow({
|
|
|
38660
39173
|
value,
|
|
38661
39174
|
tooltip
|
|
38662
39175
|
}) {
|
|
38663
|
-
const iconRef =
|
|
38664
|
-
const [tipPos, setTipPos] =
|
|
39176
|
+
const iconRef = useRef20(null);
|
|
39177
|
+
const [tipPos, setTipPos] = useState34(null);
|
|
38665
39178
|
const handleMouseEnter = () => {
|
|
38666
39179
|
if (!tooltip || !iconRef.current) return;
|
|
38667
39180
|
const r = iconRef.current.getBoundingClientRect();
|
|
@@ -38996,14 +39509,14 @@ var init_swap = __esm({
|
|
|
38996
39509
|
|
|
38997
39510
|
// src/widget/TrustwareWidgetV2.tsx
|
|
38998
39511
|
import {
|
|
38999
|
-
useState as
|
|
39000
|
-
useEffect as
|
|
39001
|
-
useRef as
|
|
39512
|
+
useState as useState35,
|
|
39513
|
+
useEffect as useEffect35,
|
|
39514
|
+
useRef as useRef21,
|
|
39002
39515
|
useCallback as useCallback23,
|
|
39003
39516
|
useImperativeHandle,
|
|
39004
39517
|
forwardRef
|
|
39005
39518
|
} from "react";
|
|
39006
|
-
import { Fragment as
|
|
39519
|
+
import { Fragment as Fragment14, jsx as jsx60, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
39007
39520
|
function WidgetContent({
|
|
39008
39521
|
style,
|
|
39009
39522
|
onStateChange,
|
|
@@ -39014,7 +39527,7 @@ function WidgetContent({
|
|
|
39014
39527
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
39015
39528
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
39016
39529
|
useWalletExternalDisconnect(() => setCurrentStep("home"));
|
|
39017
|
-
|
|
39530
|
+
useEffect35(() => {
|
|
39018
39531
|
const state = {
|
|
39019
39532
|
currentStep,
|
|
39020
39533
|
amount,
|
|
@@ -39057,7 +39570,7 @@ function WidgetInner({
|
|
|
39057
39570
|
const { transactionStatus } = useDepositTransaction();
|
|
39058
39571
|
const { resolvedTheme } = useDepositUi();
|
|
39059
39572
|
const { status, revalidate, errors } = useTrustware();
|
|
39060
|
-
const [showConfirmDialog, setShowConfirmDialog] =
|
|
39573
|
+
const [showConfirmDialog, setShowConfirmDialog] = useState35(false);
|
|
39061
39574
|
const handleCloseRequest = useCallback23(() => {
|
|
39062
39575
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
39063
39576
|
setShowConfirmDialog(true);
|
|
@@ -39069,7 +39582,7 @@ function WidgetInner({
|
|
|
39069
39582
|
onClose?.();
|
|
39070
39583
|
}
|
|
39071
39584
|
}, [transactionStatus, onClose, resetState]);
|
|
39072
|
-
|
|
39585
|
+
useEffect35(() => {
|
|
39073
39586
|
closeRequestRef.current = handleCloseRequest;
|
|
39074
39587
|
}, [handleCloseRequest, closeRequestRef]);
|
|
39075
39588
|
const handleConfirmClose = useCallback23(() => {
|
|
@@ -39085,7 +39598,7 @@ function WidgetInner({
|
|
|
39085
39598
|
const handleRefresh = useCallback23(() => {
|
|
39086
39599
|
revalidate?.();
|
|
39087
39600
|
}, [revalidate]);
|
|
39088
|
-
return /* @__PURE__ */ jsxs48(
|
|
39601
|
+
return /* @__PURE__ */ jsxs48(Fragment14, { children: [
|
|
39089
39602
|
/* @__PURE__ */ jsxs48(WidgetContainer, { theme: effectiveTheme, style, children: [
|
|
39090
39603
|
/* @__PURE__ */ jsx60(
|
|
39091
39604
|
WidgetContent,
|
|
@@ -39153,8 +39666,8 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
39153
39666
|
onOpen,
|
|
39154
39667
|
showThemeToggle = true
|
|
39155
39668
|
}, ref) {
|
|
39156
|
-
const [isOpen, setIsOpen] =
|
|
39157
|
-
const closeRequestRef =
|
|
39669
|
+
const [isOpen, setIsOpen] = useState35(defaultOpen);
|
|
39670
|
+
const closeRequestRef = useRef21(null);
|
|
39158
39671
|
const config = useTrustwareConfig();
|
|
39159
39672
|
const effectiveInitialStep = initialStep;
|
|
39160
39673
|
const open = useCallback23(() => {
|
|
@@ -39185,7 +39698,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
39185
39698
|
if (!isOpen) {
|
|
39186
39699
|
return null;
|
|
39187
39700
|
}
|
|
39188
|
-
if (config.
|
|
39701
|
+
if (config.mode === "swap") {
|
|
39189
39702
|
return /* @__PURE__ */ jsx60(SwapMode, { theme, style });
|
|
39190
39703
|
}
|
|
39191
39704
|
return /* @__PURE__ */ jsx60(DepositProvider, { initialStep: effectiveInitialStep, children: /* @__PURE__ */ jsx60(
|