@trustware/sdk-staging 1.1.8-staging.8 → 1.1.9-staging.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/{blockchain-BONedEsU.d.cts → blockchain-BxAFzp0s.d.cts} +5 -1
- package/dist/{blockchain-BONedEsU.d.ts → blockchain-BxAFzp0s.d.ts} +5 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/{core-BQ0mFnLc.d.ts → core-CwT8Wd1x.d.ts} +32 -4
- package/dist/{core-BjQwlpoI.d.cts → core-Dy_rZl5y.d.cts} +32 -4
- package/dist/core.cjs +69 -32
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +4 -4
- package/dist/core.d.ts +4 -4
- package/dist/core.mjs +69 -32
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-DlbgTrkm.d.cts → detect-DVpECOTa.d.cts} +2 -2
- package/dist/{detect-MWKHLhn9.d.ts → detect-d2PUaxE_.d.ts} +2 -2
- package/dist/index.cjs +699 -333
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -10
- package/dist/index.d.ts +9 -10
- package/dist/index.mjs +653 -287
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-aOd3vkF9.d.ts → manager-B5aklGtm.d.cts} +2 -4
- package/dist/{manager-DKVW7zeh.d.cts → manager-xFiq0SHr.d.ts} +2 -4
- package/dist/smart-account.cjs +1 -2
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +31 -3
- package/dist/smart-account.d.ts +31 -3
- package/dist/smart-account.mjs +1 -2
- package/dist/smart-account.mjs.map +1 -1
- package/dist/{types-MtdjJgwT.d.ts → types-BJY9r-mz.d.ts} +1 -1
- package/dist/{types-B3nKHW6H.d.cts → types-DX3HtFcn.d.cts} +1 -1
- package/dist/wallet.cjs +124 -53
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +4 -4
- package/dist/wallet.d.ts +4 -4
- package/dist/wallet.mjs +124 -53
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +672 -306
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.d.cts +2 -2
- package/dist/widget.d.ts +2 -2
- package/dist/widget.mjs +626 -260
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/widget.cjs
CHANGED
|
@@ -266,8 +266,8 @@ var init_theme = __esm({
|
|
|
266
266
|
--tw-accent-foreground: 0 0% 100%;
|
|
267
267
|
--tw-destructive: 0 84% 60%;
|
|
268
268
|
--tw-destructive-foreground: 0 0% 100%;
|
|
269
|
-
--tw-border: 220 13%
|
|
270
|
-
--tw-input: 220 13%
|
|
269
|
+
--tw-border: 220 13% 94%;
|
|
270
|
+
--tw-input: 220 13% 94%;
|
|
271
271
|
--tw-ring: 217 91% 60%;
|
|
272
272
|
--tw-radius: 1rem;
|
|
273
273
|
|
|
@@ -585,7 +585,7 @@ var init_constants = __esm({
|
|
|
585
585
|
"src/constants.ts"() {
|
|
586
586
|
"use strict";
|
|
587
587
|
SDK_NAME = "@trustware/sdk";
|
|
588
|
-
SDK_VERSION = "1.1.
|
|
588
|
+
SDK_VERSION = "1.1.9-staging.3";
|
|
589
589
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
590
590
|
GTM_ID = "GTM-TZDGNCXB";
|
|
591
591
|
API_PREFIX = "/api";
|
|
@@ -605,16 +605,6 @@ var init_config2 = __esm({
|
|
|
605
605
|
});
|
|
606
606
|
|
|
607
607
|
// src/core/http.ts
|
|
608
|
-
var http_exports = {};
|
|
609
|
-
__export(http_exports, {
|
|
610
|
-
RateLimitError: () => RateLimitError,
|
|
611
|
-
apiBase: () => apiBase,
|
|
612
|
-
assertOK: () => assertOK,
|
|
613
|
-
jsonHeaders: () => jsonHeaders,
|
|
614
|
-
parseRateLimitHeaders: () => parseRateLimitHeaders,
|
|
615
|
-
rateLimitedFetch: () => rateLimitedFetch,
|
|
616
|
-
validateSdkAccess: () => validateSdkAccess
|
|
617
|
-
});
|
|
618
608
|
function apiBase() {
|
|
619
609
|
return `${API_ROOT}${API_PREFIX}`;
|
|
620
610
|
}
|
|
@@ -812,11 +802,6 @@ var init_chains = __esm({
|
|
|
812
802
|
});
|
|
813
803
|
|
|
814
804
|
// src/registry.ts
|
|
815
|
-
var registry_exports = {};
|
|
816
|
-
__export(registry_exports, {
|
|
817
|
-
NATIVE: () => NATIVE,
|
|
818
|
-
Registry: () => Registry
|
|
819
|
-
});
|
|
820
805
|
function getChainAliases(chain) {
|
|
821
806
|
const values = [
|
|
822
807
|
chain.chainId,
|
|
@@ -2350,7 +2335,7 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
2350
2335
|
}
|
|
2351
2336
|
return stream();
|
|
2352
2337
|
}
|
|
2353
|
-
async function getBalances(chainRef, address) {
|
|
2338
|
+
async function getBalances(chainRef, address, opts) {
|
|
2354
2339
|
const reg = await ensureRegistry();
|
|
2355
2340
|
const chain = reg.chain(chainRef);
|
|
2356
2341
|
if (!chain) return [];
|
|
@@ -2365,8 +2350,10 @@ async function getBalances(chainRef, address) {
|
|
|
2365
2350
|
chain.nativeCurrency?.decimals ?? "",
|
|
2366
2351
|
normalizeChainType(chain) ?? ""
|
|
2367
2352
|
].join(":");
|
|
2368
|
-
|
|
2369
|
-
|
|
2353
|
+
if (!opts?.forceRefresh) {
|
|
2354
|
+
const cached = balanceCache.get(cacheKey);
|
|
2355
|
+
if (cached) return cached;
|
|
2356
|
+
}
|
|
2370
2357
|
const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
|
|
2371
2358
|
const response = await fetch(url, {
|
|
2372
2359
|
method: "GET",
|
|
@@ -2873,7 +2860,6 @@ function useTrustwareConfig() {
|
|
|
2873
2860
|
toToken: "",
|
|
2874
2861
|
toAddress: void 0,
|
|
2875
2862
|
defaultSlippage: 1,
|
|
2876
|
-
routeType: "swap",
|
|
2877
2863
|
options: {}
|
|
2878
2864
|
},
|
|
2879
2865
|
autoDetectProvider: false,
|
|
@@ -2986,6 +2972,10 @@ var init_useAmountConstraints = __esm({
|
|
|
2986
2972
|
});
|
|
2987
2973
|
|
|
2988
2974
|
// src/core/registryClient.ts
|
|
2975
|
+
var registryClient_exports = {};
|
|
2976
|
+
__export(registryClient_exports, {
|
|
2977
|
+
getSharedRegistry: () => getSharedRegistry
|
|
2978
|
+
});
|
|
2989
2979
|
function registryCacheKey() {
|
|
2990
2980
|
const base2 = apiBase();
|
|
2991
2981
|
const apiKey = TrustwareConfigStore.peek()?.apiKey ?? "__uninitialized__";
|
|
@@ -6116,11 +6106,27 @@ function toSolanaWalletInterface(provider) {
|
|
|
6116
6106
|
serializedTransactionBase64
|
|
6117
6107
|
);
|
|
6118
6108
|
if (provider.signAndSendTransaction) {
|
|
6119
|
-
const
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6109
|
+
const MAX_INTERNAL_ERROR_ATTEMPTS = 3;
|
|
6110
|
+
const INTERNAL_ERROR_RETRY_DELAY_MS = 500;
|
|
6111
|
+
for (let attempt = 1; attempt <= MAX_INTERNAL_ERROR_ATTEMPTS; attempt++) {
|
|
6112
|
+
try {
|
|
6113
|
+
const result = await provider.signAndSendTransaction(transaction, {
|
|
6114
|
+
skipPreflight: true
|
|
6115
|
+
});
|
|
6116
|
+
if (typeof result === "string") return result;
|
|
6117
|
+
if (result?.signature) return result.signature;
|
|
6118
|
+
break;
|
|
6119
|
+
} catch (err) {
|
|
6120
|
+
const code = err?.code;
|
|
6121
|
+
if (code === -32603 && attempt < MAX_INTERNAL_ERROR_ATTEMPTS) {
|
|
6122
|
+
await new Promise(
|
|
6123
|
+
(resolve) => setTimeout(resolve, INTERNAL_ERROR_RETRY_DELAY_MS * attempt)
|
|
6124
|
+
);
|
|
6125
|
+
continue;
|
|
6126
|
+
}
|
|
6127
|
+
throw err;
|
|
6128
|
+
}
|
|
6129
|
+
}
|
|
6124
6130
|
}
|
|
6125
6131
|
if (!provider.signTransaction) {
|
|
6126
6132
|
throw new Error("Connected Solana wallet cannot sign transactions");
|
|
@@ -6233,12 +6239,25 @@ var init_connect = __esm({
|
|
|
6233
6239
|
function formatDeepLink(id, currentUrl) {
|
|
6234
6240
|
const enc = encodeURIComponent(currentUrl);
|
|
6235
6241
|
switch (id) {
|
|
6242
|
+
// EVM
|
|
6236
6243
|
case "metamask":
|
|
6237
6244
|
return `metamask://dapp/${currentUrl}`;
|
|
6238
6245
|
case "coinbase":
|
|
6239
6246
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
6240
6247
|
case "rainbow":
|
|
6241
6248
|
return `rainbow://connect?uri=${enc}`;
|
|
6249
|
+
case "trust":
|
|
6250
|
+
return `https://link.trustwallet.com/open_url?coin_id=60&url=${enc}`;
|
|
6251
|
+
case "okx":
|
|
6252
|
+
return `okx://wallet/dapp/url?dappUrl=${enc}`;
|
|
6253
|
+
// Solana
|
|
6254
|
+
case "phantom-solana":
|
|
6255
|
+
return `phantom://browse/${enc}`;
|
|
6256
|
+
case "solflare":
|
|
6257
|
+
return `solflare://ul/v1/browse/${enc}`;
|
|
6258
|
+
case "backpack":
|
|
6259
|
+
return `https://backpack.app/ul/v1/browse/${enc}?ref=${enc}`;
|
|
6260
|
+
// No confirmed deep link scheme
|
|
6242
6261
|
default:
|
|
6243
6262
|
return void 0;
|
|
6244
6263
|
}
|
|
@@ -6266,6 +6285,8 @@ var init_metadata = __esm({
|
|
|
6266
6285
|
emoji: "\u{1F98A}",
|
|
6267
6286
|
homepage: "https://metamask.io/",
|
|
6268
6287
|
chromeWebStore: "https://chromewebstore.google.com/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",
|
|
6288
|
+
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
6289
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
6269
6290
|
detectFlags: ["isMetaMask"],
|
|
6270
6291
|
deepLink: (url) => formatDeepLink("metamask", url) ?? ""
|
|
6271
6292
|
},
|
|
@@ -6277,6 +6298,8 @@ var init_metadata = __esm({
|
|
|
6277
6298
|
logo: `${ASSETS_BASE_URL}/assets/wallets/coinbase.svg`,
|
|
6278
6299
|
emoji: "\u{1F7E6}",
|
|
6279
6300
|
homepage: "https://www.coinbase.com/wallet",
|
|
6301
|
+
ios: "https://apps.apple.com/app/coinbase-wallet/id1278383455",
|
|
6302
|
+
android: "https://play.google.com/store/apps/details?id=org.toshi",
|
|
6280
6303
|
detectFlags: ["isCoinbaseWallet"],
|
|
6281
6304
|
deepLink: (url) => formatDeepLink("coinbase", url) ?? ""
|
|
6282
6305
|
},
|
|
@@ -6288,6 +6311,7 @@ var init_metadata = __esm({
|
|
|
6288
6311
|
logo: `${ASSETS_BASE_URL}/assets/wallets/walletconnect.svg`,
|
|
6289
6312
|
emoji: "\u{1FA9D}",
|
|
6290
6313
|
homepage: "https://walletconnect.com/"
|
|
6314
|
+
// No deep link — opens its own modal
|
|
6291
6315
|
},
|
|
6292
6316
|
{
|
|
6293
6317
|
id: "rainbow",
|
|
@@ -6297,8 +6321,38 @@ var init_metadata = __esm({
|
|
|
6297
6321
|
logo: `${ASSETS_BASE_URL}/assets/wallets/rainbow.svg`,
|
|
6298
6322
|
emoji: "\u{1F308}",
|
|
6299
6323
|
homepage: "https://rainbow.me/",
|
|
6300
|
-
|
|
6301
|
-
|
|
6324
|
+
ios: "https://apps.apple.com/app/rainbow-ethereum-wallet/id1457119021",
|
|
6325
|
+
android: "https://play.google.com/store/apps/details?id=me.rainbow",
|
|
6326
|
+
detectFlags: ["isRainbow"],
|
|
6327
|
+
deepLink: (url) => formatDeepLink("rainbow", url) ?? ""
|
|
6328
|
+
},
|
|
6329
|
+
{
|
|
6330
|
+
id: "trust",
|
|
6331
|
+
name: "Trust Wallet",
|
|
6332
|
+
category: "app",
|
|
6333
|
+
ecosystem: "multi",
|
|
6334
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
|
|
6335
|
+
emoji: "\u{1F6E1}\uFE0F",
|
|
6336
|
+
homepage: "https://trustwallet.com/",
|
|
6337
|
+
ios: "https://apps.apple.com/app/trust-crypto-bitcoin-wallet/id1288339409",
|
|
6338
|
+
android: "https://play.google.com/store/apps/details?id=com.wallet.crypto.trustapp",
|
|
6339
|
+
detectFlags: ["isTrustWallet"],
|
|
6340
|
+
deepLink: (url) => formatDeepLink("trust", url) ?? ""
|
|
6341
|
+
// ✅ Added
|
|
6342
|
+
},
|
|
6343
|
+
{
|
|
6344
|
+
id: "okx",
|
|
6345
|
+
name: "OKX",
|
|
6346
|
+
category: "injected",
|
|
6347
|
+
ecosystem: "evm",
|
|
6348
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
|
|
6349
|
+
emoji: "\u2B1B",
|
|
6350
|
+
homepage: "https://www.okx.com/web3",
|
|
6351
|
+
ios: "https://apps.apple.com/app/okx-buy-bitcoin-eth-crypto/id1327268470",
|
|
6352
|
+
android: "https://play.google.com/store/apps/details?id=com.okinc.okex.gp",
|
|
6353
|
+
detectFlags: ["isOkxWallet"],
|
|
6354
|
+
deepLink: (url) => formatDeepLink("okx", url) ?? ""
|
|
6355
|
+
// ✅ Added
|
|
6302
6356
|
},
|
|
6303
6357
|
{
|
|
6304
6358
|
id: "phantom-evm",
|
|
@@ -6308,7 +6362,10 @@ var init_metadata = __esm({
|
|
|
6308
6362
|
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
6309
6363
|
emoji: "\u{1F47B}",
|
|
6310
6364
|
homepage: "https://phantom.app/",
|
|
6365
|
+
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
6366
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
6311
6367
|
detectFlags: ["isPhantom"]
|
|
6368
|
+
// No EVM dapp browser deep link — falls back to app store
|
|
6312
6369
|
},
|
|
6313
6370
|
{
|
|
6314
6371
|
id: "phantom-solana",
|
|
@@ -6318,18 +6375,9 @@ var init_metadata = __esm({
|
|
|
6318
6375
|
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
6319
6376
|
emoji: "\u{1F47B}",
|
|
6320
6377
|
homepage: "https://phantom.app/",
|
|
6321
|
-
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
6322
6378
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
{
|
|
6326
|
-
id: "metamask-solana",
|
|
6327
|
-
name: "MetaMask (Solana)",
|
|
6328
|
-
category: "injected",
|
|
6329
|
-
ecosystem: "solana",
|
|
6330
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
6331
|
-
emoji: "\u{1F98A}",
|
|
6332
|
-
homepage: "https://metamask.io/"
|
|
6379
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
6380
|
+
deepLink: (url) => formatDeepLink("phantom-solana", url) ?? ""
|
|
6333
6381
|
},
|
|
6334
6382
|
{
|
|
6335
6383
|
id: "solflare",
|
|
@@ -6339,7 +6387,9 @@ var init_metadata = __esm({
|
|
|
6339
6387
|
logo: `${ASSETS_BASE_URL}/assets/wallets/solflare-logo.svg`,
|
|
6340
6388
|
emoji: "\u2600\uFE0F",
|
|
6341
6389
|
homepage: "https://solflare.com/",
|
|
6342
|
-
|
|
6390
|
+
ios: "https://apps.apple.com/app/solflare-solana-wallet/id1580902717",
|
|
6391
|
+
android: "https://play.google.com/store/apps/details?id=com.solflare.mobile",
|
|
6392
|
+
deepLink: (url) => formatDeepLink("solflare", url) ?? ""
|
|
6343
6393
|
},
|
|
6344
6394
|
{
|
|
6345
6395
|
id: "backpack",
|
|
@@ -6348,8 +6398,25 @@ var init_metadata = __esm({
|
|
|
6348
6398
|
ecosystem: "solana",
|
|
6349
6399
|
logo: `${ASSETS_BASE_URL}/assets/wallets/backpack-logo.svg`,
|
|
6350
6400
|
emoji: "\u{1F392}",
|
|
6351
|
-
homepage: "https://backpack.app/"
|
|
6401
|
+
homepage: "https://backpack.app/",
|
|
6402
|
+
ios: "https://apps.apple.com/app/backpack-crypto-wallet/id6445964121",
|
|
6403
|
+
android: "https://play.google.com/store/apps/details?id=app.backpack.mobile",
|
|
6404
|
+
deepLink: (url) => formatDeepLink("backpack", url) ?? ""
|
|
6405
|
+
// ✅ Added
|
|
6352
6406
|
},
|
|
6407
|
+
{
|
|
6408
|
+
id: "metamask-solana",
|
|
6409
|
+
name: "MetaMask (Solana)",
|
|
6410
|
+
category: "injected",
|
|
6411
|
+
ecosystem: "solana",
|
|
6412
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
6413
|
+
emoji: "\u{1F98A}",
|
|
6414
|
+
homepage: "https://metamask.io/",
|
|
6415
|
+
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
6416
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
6417
|
+
// No Solana-specific deep link for MetaMask
|
|
6418
|
+
},
|
|
6419
|
+
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
6353
6420
|
{
|
|
6354
6421
|
id: "rabby",
|
|
6355
6422
|
name: "Rabby",
|
|
@@ -6360,6 +6427,7 @@ var init_metadata = __esm({
|
|
|
6360
6427
|
homepage: "https://rabby.io/",
|
|
6361
6428
|
chromeWebStore: "https://chromewebstore.google.com/detail/rabby/acmacodkjbdgmoleebolmdjonilkdbch",
|
|
6362
6429
|
detectFlags: ["isRabby"]
|
|
6430
|
+
// Extension only — no mobile app or deep link
|
|
6363
6431
|
},
|
|
6364
6432
|
{
|
|
6365
6433
|
id: "brave",
|
|
@@ -6370,25 +6438,7 @@ var init_metadata = __esm({
|
|
|
6370
6438
|
emoji: "\u{1F981}",
|
|
6371
6439
|
homepage: "https://brave.com/wallet/",
|
|
6372
6440
|
detectFlags: ["isBraveWallet"]
|
|
6373
|
-
|
|
6374
|
-
{
|
|
6375
|
-
id: "okx",
|
|
6376
|
-
name: "OKX",
|
|
6377
|
-
category: "injected",
|
|
6378
|
-
ecosystem: "evm",
|
|
6379
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
|
|
6380
|
-
emoji: "\u2B1B",
|
|
6381
|
-
homepage: "https://www.okx.com/web3",
|
|
6382
|
-
detectFlags: ["isOkxWallet"]
|
|
6383
|
-
},
|
|
6384
|
-
{
|
|
6385
|
-
id: "zerion",
|
|
6386
|
-
name: "Zerion",
|
|
6387
|
-
category: "app",
|
|
6388
|
-
ecosystem: "evm",
|
|
6389
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
|
|
6390
|
-
emoji: "\u{1F9FF}",
|
|
6391
|
-
homepage: "https://zerion.io/wallet/"
|
|
6441
|
+
// Built into Brave browser — no standalone deep link
|
|
6392
6442
|
},
|
|
6393
6443
|
{
|
|
6394
6444
|
id: "taho",
|
|
@@ -6399,16 +6449,7 @@ var init_metadata = __esm({
|
|
|
6399
6449
|
emoji: "\u{1F7EA}",
|
|
6400
6450
|
homepage: "https://taho.xyz/",
|
|
6401
6451
|
detectFlags: ["isTally", "isTallyWallet", "isTahoWallet"]
|
|
6402
|
-
|
|
6403
|
-
{
|
|
6404
|
-
id: "trust",
|
|
6405
|
-
name: "Trust Wallet",
|
|
6406
|
-
category: "app",
|
|
6407
|
-
ecosystem: "multi",
|
|
6408
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
|
|
6409
|
-
emoji: "\u{1F6E1}\uFE0F",
|
|
6410
|
-
homepage: "https://trustwallet.com/",
|
|
6411
|
-
detectFlags: ["isTrustWallet"]
|
|
6452
|
+
// Extension only — no mobile app
|
|
6412
6453
|
},
|
|
6413
6454
|
{
|
|
6414
6455
|
id: "bitget",
|
|
@@ -6418,7 +6459,22 @@ var init_metadata = __esm({
|
|
|
6418
6459
|
logo: `${ASSETS_BASE_URL}/assets/wallets/bitget.svg`,
|
|
6419
6460
|
emoji: "\u{1F7E9}",
|
|
6420
6461
|
homepage: "https://web3.bitget.com/",
|
|
6462
|
+
ios: "https://apps.apple.com/app/bitget-wallet-ex-bitkeep/id1395301115",
|
|
6463
|
+
android: "https://play.google.com/store/apps/details?id=com.bitkeep.wallet",
|
|
6421
6464
|
detectFlags: ["isBitGetWallet"]
|
|
6465
|
+
// No public deep link scheme documented
|
|
6466
|
+
},
|
|
6467
|
+
{
|
|
6468
|
+
id: "zerion",
|
|
6469
|
+
name: "Zerion",
|
|
6470
|
+
category: "app",
|
|
6471
|
+
ecosystem: "evm",
|
|
6472
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
|
|
6473
|
+
emoji: "\u{1F9FF}",
|
|
6474
|
+
homepage: "https://zerion.io/wallet/",
|
|
6475
|
+
ios: "https://apps.apple.com/app/zerion-crypto-defi-wallet/id1456732565",
|
|
6476
|
+
android: "https://play.google.com/store/apps/details?id=io.zerion.android"
|
|
6477
|
+
// Uses WalletConnect URI — not a simple page URL deep link
|
|
6422
6478
|
},
|
|
6423
6479
|
{
|
|
6424
6480
|
id: "safe",
|
|
@@ -6427,7 +6483,10 @@ var init_metadata = __esm({
|
|
|
6427
6483
|
ecosystem: "evm",
|
|
6428
6484
|
logo: `${ASSETS_BASE_URL}/assets/wallets/safe.svg`,
|
|
6429
6485
|
emoji: "\u{1F7E9}",
|
|
6430
|
-
homepage: "https://safe.global/"
|
|
6486
|
+
homepage: "https://safe.global/",
|
|
6487
|
+
ios: "https://apps.apple.com/app/safe-gnosis-safe/id1515759131",
|
|
6488
|
+
android: "https://play.google.com/store/apps/details?id=io.gnosis.safe"
|
|
6489
|
+
// Uses WalletConnect — no dapp browser deep link
|
|
6431
6490
|
},
|
|
6432
6491
|
{
|
|
6433
6492
|
id: "kucoin",
|
|
@@ -6436,7 +6495,10 @@ var init_metadata = __esm({
|
|
|
6436
6495
|
ecosystem: "evm",
|
|
6437
6496
|
logo: `${ASSETS_BASE_URL}/assets/wallets/kucoin.svg`,
|
|
6438
6497
|
emoji: "\u{1F7E6}",
|
|
6439
|
-
homepage: "https://www.kucoin.com/"
|
|
6498
|
+
homepage: "https://www.kucoin.com/",
|
|
6499
|
+
ios: "https://apps.apple.com/app/kucoin-buy-bitcoin-crypto/id1378956601",
|
|
6500
|
+
android: "https://play.google.com/store/apps/details?id=com.kubi.kucoin"
|
|
6501
|
+
// No public deep link scheme documented
|
|
6440
6502
|
}
|
|
6441
6503
|
];
|
|
6442
6504
|
}
|
|
@@ -6614,6 +6676,14 @@ function useWalletDetection(timeoutMs = 400) {
|
|
|
6614
6676
|
);
|
|
6615
6677
|
return { detected, detectedIds };
|
|
6616
6678
|
}
|
|
6679
|
+
function useIsMobile() {
|
|
6680
|
+
const [isMobile, set] = (0, import_react9.useState)(false);
|
|
6681
|
+
(0, import_react9.useEffect)(() => {
|
|
6682
|
+
const ua = navigator.userAgent || "";
|
|
6683
|
+
set(/Android|iPhone|iPad|iPod/i.test(ua));
|
|
6684
|
+
}, []);
|
|
6685
|
+
return isMobile;
|
|
6686
|
+
}
|
|
6617
6687
|
var import_react9, WALLET_BY_ID, DETECT_PRIORITY, GENERIC_FLAGS, RDNS_WALLET_MAP, NAME_WALLET_MAP;
|
|
6618
6688
|
var init_detect = __esm({
|
|
6619
6689
|
"src/wallets/detect.ts"() {
|
|
@@ -8167,6 +8237,7 @@ var init_wallets = __esm({
|
|
|
8167
8237
|
init_adapters();
|
|
8168
8238
|
init_solana();
|
|
8169
8239
|
init_detect();
|
|
8240
|
+
init_metadata();
|
|
8170
8241
|
}
|
|
8171
8242
|
});
|
|
8172
8243
|
|
|
@@ -8595,7 +8666,6 @@ function resolveConfig(input) {
|
|
|
8595
8666
|
defaultSlippage: normalizeSlippage(
|
|
8596
8667
|
input.routes.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
8597
8668
|
),
|
|
8598
|
-
routeType: input.routes.routeType ?? "swap",
|
|
8599
8669
|
options: {
|
|
8600
8670
|
...input.routes.options
|
|
8601
8671
|
}
|
|
@@ -8795,10 +8865,9 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
8795
8865
|
if (w.ecosystem !== "solana") {
|
|
8796
8866
|
throw new Error("A Solana wallet is required for this route");
|
|
8797
8867
|
}
|
|
8798
|
-
const {
|
|
8799
|
-
const
|
|
8800
|
-
|
|
8801
|
-
await registry.ensureLoaded();
|
|
8868
|
+
const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
|
|
8869
|
+
const registry = getSharedRegistry2();
|
|
8870
|
+
await registry.ensureChainsLoaded();
|
|
8802
8871
|
const chain = registry.chain(
|
|
8803
8872
|
String(fallbackChainId ?? txReq.chainId ?? "")
|
|
8804
8873
|
);
|
|
@@ -8812,9 +8881,8 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
8812
8881
|
async function runTopUp(params) {
|
|
8813
8882
|
const w = walletManager.wallet;
|
|
8814
8883
|
if (!w) throw new Error("Trustware.wallet not configured");
|
|
8815
|
-
const {
|
|
8816
|
-
const
|
|
8817
|
-
const reg = new Registry2(apiBase2());
|
|
8884
|
+
const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
|
|
8885
|
+
const reg = getSharedRegistry2();
|
|
8818
8886
|
await reg.ensureLoaded();
|
|
8819
8887
|
const fromAddress = await w.getAddress();
|
|
8820
8888
|
const currentChainRef = w.ecosystem === "evm" ? String(await w.getChainId()) : await w.getChainKey?.() ?? "solana-mainnet-beta";
|
|
@@ -8925,6 +8993,39 @@ var init_core = __esm({
|
|
|
8925
8993
|
getConfig() {
|
|
8926
8994
|
return TrustwareConfigStore.get();
|
|
8927
8995
|
},
|
|
8996
|
+
/**
|
|
8997
|
+
* Read the SDK's currently configured theme mode.
|
|
8998
|
+
*
|
|
8999
|
+
* Returns the raw setting — `"light" | "dark" | "system"` — i.e. whatever
|
|
9000
|
+
* was last passed to `init()` or `setTheme()`. When the mode is `"system"`,
|
|
9001
|
+
* the widget resolves the actual light/dark appearance itself (from the OS
|
|
9002
|
+
* `prefers-color-scheme`, or a saved preference if the user has used the
|
|
9003
|
+
* widget's built-in theme toggle), so this getter still reports `"system"`
|
|
9004
|
+
* rather than the resolved value.
|
|
9005
|
+
*/
|
|
9006
|
+
getTheme() {
|
|
9007
|
+
return TrustwareConfigStore.get().theme;
|
|
9008
|
+
},
|
|
9009
|
+
/**
|
|
9010
|
+
* Set the widget's theme at runtime.
|
|
9011
|
+
*
|
|
9012
|
+
* Call this from your own app's theme toggle to keep an embedded
|
|
9013
|
+
* `TrustwareWidget` in sync with your UI — no remount required, any
|
|
9014
|
+
* mounted widget picks up the change immediately.
|
|
9015
|
+
*
|
|
9016
|
+
* Passing `"light"` or `"dark"` pins the widget to that mode. Passing
|
|
9017
|
+
* `"system"` makes it follow the OS preference again — unless the user
|
|
9018
|
+
* previously used the widget's own in-widget theme toggle, in which case
|
|
9019
|
+
* their saved choice takes precedence until they toggle it again.
|
|
9020
|
+
*
|
|
9021
|
+
* @example
|
|
9022
|
+
* // In your app's own dark-mode toggle handler:
|
|
9023
|
+
* Trustware.setTheme(isDark ? "dark" : "light");
|
|
9024
|
+
*/
|
|
9025
|
+
setTheme(theme) {
|
|
9026
|
+
TrustwareConfigStore.update({ theme });
|
|
9027
|
+
return Trustware;
|
|
9028
|
+
},
|
|
8928
9029
|
setDestinationAddress(address) {
|
|
8929
9030
|
const prev = TrustwareConfigStore.get();
|
|
8930
9031
|
TrustwareConfigStore.update({
|
|
@@ -13630,7 +13731,7 @@ function ChainSelectorPanel({
|
|
|
13630
13731
|
paddingTop: spacing[2],
|
|
13631
13732
|
paddingBottom: spacing[2],
|
|
13632
13733
|
fontSize: fontSize.sm,
|
|
13633
|
-
backgroundColor: colors.
|
|
13734
|
+
backgroundColor: colors.background,
|
|
13634
13735
|
border: `1px solid ${colors.border}`,
|
|
13635
13736
|
borderRadius: borderRadius.lg,
|
|
13636
13737
|
color: colors.foreground,
|
|
@@ -13844,7 +13945,7 @@ function TokenSearchInput({
|
|
|
13844
13945
|
paddingTop: spacing[2],
|
|
13845
13946
|
paddingBottom: spacing[2],
|
|
13846
13947
|
fontSize: fontSize.sm,
|
|
13847
|
-
backgroundColor: colors.
|
|
13948
|
+
backgroundColor: colors.background,
|
|
13848
13949
|
border: `1px solid ${colors.border}`,
|
|
13849
13950
|
borderRadius: borderRadius.lg,
|
|
13850
13951
|
color: colors.foreground,
|
|
@@ -15988,7 +16089,7 @@ var init_WalletNamespaceTabs = __esm({
|
|
|
15988
16089
|
});
|
|
15989
16090
|
|
|
15990
16091
|
// src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx
|
|
15991
|
-
function
|
|
16092
|
+
function DesktopWalletDropdownContent({
|
|
15992
16093
|
browserWallets,
|
|
15993
16094
|
handleWalletConnect,
|
|
15994
16095
|
handleWalletSelect
|
|
@@ -16052,7 +16153,263 @@ function CryptoWalletDropdownContent({
|
|
|
16052
16153
|
}
|
|
16053
16154
|
);
|
|
16054
16155
|
}
|
|
16055
|
-
|
|
16156
|
+
function MobileWalletDropdownContent({
|
|
16157
|
+
handleWalletConnect
|
|
16158
|
+
}) {
|
|
16159
|
+
const { setCurrentStep } = useDepositNavigation();
|
|
16160
|
+
const { selectedNamespace } = useDepositWallet();
|
|
16161
|
+
const { walletMetaId, isConnected, status } = useWalletInfo();
|
|
16162
|
+
const [hoveredId, setHoveredId] = (0, import_react34.useState)(null);
|
|
16163
|
+
const storeFallbackTimeoutRef = (0, import_react34.useRef)(
|
|
16164
|
+
null
|
|
16165
|
+
);
|
|
16166
|
+
(0, import_react34.useEffect)(() => {
|
|
16167
|
+
return () => {
|
|
16168
|
+
if (storeFallbackTimeoutRef.current !== null) {
|
|
16169
|
+
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16170
|
+
}
|
|
16171
|
+
};
|
|
16172
|
+
}, []);
|
|
16173
|
+
const connectedWalletId = isConnected ? walletMetaId : null;
|
|
16174
|
+
const currentUrl = window.location.href;
|
|
16175
|
+
const mobileWallets = (0, import_react34.useMemo)(
|
|
16176
|
+
() => WALLETS.filter((w) => {
|
|
16177
|
+
if (w.id === "walletconnect") return true;
|
|
16178
|
+
const hasMobileLink = Boolean(w.deepLink || w.ios || w.android);
|
|
16179
|
+
if (!hasMobileLink) return false;
|
|
16180
|
+
return w.ecosystem.trim().toLowerCase() === "multi" || w.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase();
|
|
16181
|
+
}),
|
|
16182
|
+
[selectedNamespace]
|
|
16183
|
+
);
|
|
16184
|
+
const handleWalletSelect = (wallet) => {
|
|
16185
|
+
if (wallet.id === "walletconnect") {
|
|
16186
|
+
handleWalletConnect();
|
|
16187
|
+
return;
|
|
16188
|
+
}
|
|
16189
|
+
if (wallet.deepLink) {
|
|
16190
|
+
const deepLinkUrl = wallet.deepLink(currentUrl);
|
|
16191
|
+
if (deepLinkUrl) {
|
|
16192
|
+
window.location.assign(deepLinkUrl);
|
|
16193
|
+
if (storeFallbackTimeoutRef.current !== null) {
|
|
16194
|
+
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16195
|
+
}
|
|
16196
|
+
storeFallbackTimeoutRef.current = setTimeout(() => {
|
|
16197
|
+
storeFallbackTimeoutRef.current = null;
|
|
16198
|
+
const isIos2 = /iPhone|iPad/i.test(navigator.userAgent);
|
|
16199
|
+
const storeUrl2 = isIos2 ? wallet.ios : wallet.android;
|
|
16200
|
+
if (storeUrl2) window.location.assign(storeUrl2);
|
|
16201
|
+
}, 1500);
|
|
16202
|
+
return;
|
|
16203
|
+
}
|
|
16204
|
+
}
|
|
16205
|
+
const isIos = /iPhone|iPad/i.test(navigator.userAgent);
|
|
16206
|
+
const storeUrl = isIos ? wallet.ios : wallet.android;
|
|
16207
|
+
if (storeUrl) window.location.assign(storeUrl);
|
|
16208
|
+
};
|
|
16209
|
+
const handleContinue = () => {
|
|
16210
|
+
if (isConnected && status === "connected") {
|
|
16211
|
+
setCurrentStep("crypto-pay");
|
|
16212
|
+
} else {
|
|
16213
|
+
alert("Please connect your wallet first.");
|
|
16214
|
+
}
|
|
16215
|
+
};
|
|
16216
|
+
const showContinueButton = (0, import_react34.useMemo)(
|
|
16217
|
+
() => isConnected && status === "connected",
|
|
16218
|
+
[isConnected, status]
|
|
16219
|
+
);
|
|
16220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16221
|
+
"div",
|
|
16222
|
+
{
|
|
16223
|
+
style: {
|
|
16224
|
+
...dropdownSurfaceStyle,
|
|
16225
|
+
maxHeight: "16rem",
|
|
16226
|
+
backgroundColor: colors.card,
|
|
16227
|
+
borderRadius: borderRadius.xl,
|
|
16228
|
+
boxShadow: shadows.large,
|
|
16229
|
+
border: `1px solid rgba(63, 63, 70, 0.5)`,
|
|
16230
|
+
zIndex: 100,
|
|
16231
|
+
overflow: "hidden",
|
|
16232
|
+
// changed from auto
|
|
16233
|
+
animation: "tw-fade-in 0.2s ease-out",
|
|
16234
|
+
display: "flex",
|
|
16235
|
+
flexDirection: "column"
|
|
16236
|
+
},
|
|
16237
|
+
children: [
|
|
16238
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16239
|
+
"div",
|
|
16240
|
+
{
|
|
16241
|
+
style: {
|
|
16242
|
+
width: "100%",
|
|
16243
|
+
padding: spacing[2]
|
|
16244
|
+
},
|
|
16245
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { style: { display: "flex", gap: spacing[2] }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(WalletNamespaceTabs, { showBitcoin: false }) })
|
|
16246
|
+
}
|
|
16247
|
+
),
|
|
16248
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16249
|
+
"div",
|
|
16250
|
+
{
|
|
16251
|
+
style: {
|
|
16252
|
+
padding: spacing[3],
|
|
16253
|
+
overflowY: "auto",
|
|
16254
|
+
flex: 1,
|
|
16255
|
+
scrollbarWidth: "thin",
|
|
16256
|
+
scrollbarColor: `${colors.muted} transparent`
|
|
16257
|
+
},
|
|
16258
|
+
children: mobileWallets.map((wallet) => {
|
|
16259
|
+
const isConnectedWallet = wallet.id === connectedWalletId;
|
|
16260
|
+
const isDisabled = isConnected && !isConnectedWallet;
|
|
16261
|
+
const isHovered = hoveredId === wallet.id;
|
|
16262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16263
|
+
"button",
|
|
16264
|
+
{
|
|
16265
|
+
type: "button",
|
|
16266
|
+
onClick: () => !isDisabled && handleWalletSelect(wallet),
|
|
16267
|
+
onMouseEnter: () => !isDisabled && setHoveredId(wallet.id),
|
|
16268
|
+
onMouseLeave: () => setHoveredId(null),
|
|
16269
|
+
style: {
|
|
16270
|
+
width: "100%",
|
|
16271
|
+
display: "flex",
|
|
16272
|
+
alignItems: "center",
|
|
16273
|
+
justifyContent: "space-between",
|
|
16274
|
+
padding: spacing[2],
|
|
16275
|
+
borderRadius: borderRadius.lg,
|
|
16276
|
+
transition: "background-color 0.2s",
|
|
16277
|
+
border: "none",
|
|
16278
|
+
backgroundColor: isHovered ? "rgba(255,255,255,0.06)" : "transparent",
|
|
16279
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
16280
|
+
opacity: isDisabled ? 0.4 : 1,
|
|
16281
|
+
fontFamily: "inherit",
|
|
16282
|
+
fontSize: fontSize.sm,
|
|
16283
|
+
outline: "none"
|
|
16284
|
+
},
|
|
16285
|
+
children: [
|
|
16286
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16287
|
+
"div",
|
|
16288
|
+
{
|
|
16289
|
+
style: {
|
|
16290
|
+
display: "flex",
|
|
16291
|
+
alignItems: "center",
|
|
16292
|
+
gap: spacing[2]
|
|
16293
|
+
},
|
|
16294
|
+
children: [
|
|
16295
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16296
|
+
"img",
|
|
16297
|
+
{
|
|
16298
|
+
src: wallet.logo ?? wallet.emoji,
|
|
16299
|
+
alt: wallet.name,
|
|
16300
|
+
style: {
|
|
16301
|
+
width: "2rem",
|
|
16302
|
+
height: "2rem",
|
|
16303
|
+
borderRadius: borderRadius.lg,
|
|
16304
|
+
objectFit: "cover"
|
|
16305
|
+
}
|
|
16306
|
+
}
|
|
16307
|
+
),
|
|
16308
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16309
|
+
"span",
|
|
16310
|
+
{
|
|
16311
|
+
style: {
|
|
16312
|
+
fontWeight: fontWeight.medium,
|
|
16313
|
+
fontSize: fontSize.sm,
|
|
16314
|
+
color: colors.foreground
|
|
16315
|
+
},
|
|
16316
|
+
children: wallet.name
|
|
16317
|
+
}
|
|
16318
|
+
)
|
|
16319
|
+
]
|
|
16320
|
+
}
|
|
16321
|
+
),
|
|
16322
|
+
isConnectedWallet && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16323
|
+
"div",
|
|
16324
|
+
{
|
|
16325
|
+
style: {
|
|
16326
|
+
display: "flex",
|
|
16327
|
+
alignItems: "center",
|
|
16328
|
+
gap: spacing[1]
|
|
16329
|
+
},
|
|
16330
|
+
children: [
|
|
16331
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16332
|
+
"div",
|
|
16333
|
+
{
|
|
16334
|
+
style: {
|
|
16335
|
+
width: "0.5rem",
|
|
16336
|
+
height: "0.5rem",
|
|
16337
|
+
borderRadius: "50%",
|
|
16338
|
+
backgroundColor: "#22c55e"
|
|
16339
|
+
}
|
|
16340
|
+
}
|
|
16341
|
+
),
|
|
16342
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "Connected" })
|
|
16343
|
+
]
|
|
16344
|
+
}
|
|
16345
|
+
)
|
|
16346
|
+
]
|
|
16347
|
+
},
|
|
16348
|
+
wallet.id
|
|
16349
|
+
);
|
|
16350
|
+
})
|
|
16351
|
+
}
|
|
16352
|
+
),
|
|
16353
|
+
showContinueButton && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16354
|
+
"div",
|
|
16355
|
+
{
|
|
16356
|
+
style: {
|
|
16357
|
+
padding: spacing[3],
|
|
16358
|
+
borderTop: `1px solid rgba(63, 63, 70, 0.5)`,
|
|
16359
|
+
backgroundColor: colors.card
|
|
16360
|
+
},
|
|
16361
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16362
|
+
"button",
|
|
16363
|
+
{
|
|
16364
|
+
onClick: handleContinue,
|
|
16365
|
+
style: {
|
|
16366
|
+
width: "100%",
|
|
16367
|
+
padding: `${spacing[2]} ${spacing[3]}`,
|
|
16368
|
+
borderRadius: borderRadius.lg,
|
|
16369
|
+
border: "none",
|
|
16370
|
+
backgroundColor: colors.primary,
|
|
16371
|
+
color: "#fff",
|
|
16372
|
+
fontFamily: "inherit",
|
|
16373
|
+
fontSize: fontSize.sm,
|
|
16374
|
+
fontWeight: fontWeight.medium,
|
|
16375
|
+
cursor: "pointer",
|
|
16376
|
+
transition: "opacity 0.2s"
|
|
16377
|
+
},
|
|
16378
|
+
onMouseEnter: (e2) => e2.currentTarget.style.opacity = "0.85",
|
|
16379
|
+
onMouseLeave: (e2) => e2.currentTarget.style.opacity = "1",
|
|
16380
|
+
children: "Continue \u2192"
|
|
16381
|
+
}
|
|
16382
|
+
)
|
|
16383
|
+
}
|
|
16384
|
+
)
|
|
16385
|
+
]
|
|
16386
|
+
}
|
|
16387
|
+
);
|
|
16388
|
+
}
|
|
16389
|
+
function CryptoWalletDropdownContent({
|
|
16390
|
+
browserWallets,
|
|
16391
|
+
handleWalletConnect,
|
|
16392
|
+
handleWalletSelect
|
|
16393
|
+
}) {
|
|
16394
|
+
const isMobile = useIsMobile();
|
|
16395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
16396
|
+
!isMobile && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16397
|
+
DesktopWalletDropdownContent,
|
|
16398
|
+
{
|
|
16399
|
+
browserWallets,
|
|
16400
|
+
handleWalletConnect,
|
|
16401
|
+
handleWalletSelect
|
|
16402
|
+
}
|
|
16403
|
+
),
|
|
16404
|
+
isMobile && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16405
|
+
MobileWalletDropdownContent,
|
|
16406
|
+
{
|
|
16407
|
+
handleWalletConnect
|
|
16408
|
+
}
|
|
16409
|
+
)
|
|
16410
|
+
] });
|
|
16411
|
+
}
|
|
16412
|
+
var import_react34, import_jsx_runtime36;
|
|
16056
16413
|
var init_CryptoWalletDropdownContent = __esm({
|
|
16057
16414
|
"src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx"() {
|
|
16058
16415
|
"use strict";
|
|
@@ -16063,6 +16420,8 @@ var init_CryptoWalletDropdownContent = __esm({
|
|
|
16063
16420
|
init_paymentOptionStyles();
|
|
16064
16421
|
init_WalletNamespaceTabs();
|
|
16065
16422
|
init_DepositContext();
|
|
16423
|
+
init_wallets();
|
|
16424
|
+
import_react34 = require("react");
|
|
16066
16425
|
import_jsx_runtime36 = require("react/jsx-runtime");
|
|
16067
16426
|
}
|
|
16068
16427
|
});
|
|
@@ -16532,12 +16891,12 @@ function useHomeWalletActions({
|
|
|
16532
16891
|
WalletConnect
|
|
16533
16892
|
// setCurrentStepInternal,
|
|
16534
16893
|
}) {
|
|
16535
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0,
|
|
16536
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0,
|
|
16537
|
-
const cryptoDropdownRef = (0,
|
|
16538
|
-
const fiatDropdownRef = (0,
|
|
16894
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0, import_react35.useState)(false);
|
|
16895
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0, import_react35.useState)(false);
|
|
16896
|
+
const cryptoDropdownRef = (0, import_react35.useRef)(null);
|
|
16897
|
+
const fiatDropdownRef = (0, import_react35.useRef)(null);
|
|
16539
16898
|
const { disconnect } = useWalletInfo();
|
|
16540
|
-
(0,
|
|
16899
|
+
(0, import_react35.useEffect)(() => {
|
|
16541
16900
|
const handleClickOutside = (event) => {
|
|
16542
16901
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
16543
16902
|
setIsCryptoDropdownOpen(false);
|
|
@@ -16552,7 +16911,7 @@ function useHomeWalletActions({
|
|
|
16552
16911
|
const { resetNavigation } = useDepositNavigationState("home");
|
|
16553
16912
|
const { setYourWalletTokens } = useDepositWallet();
|
|
16554
16913
|
const { isConnected, walletMetaId, connectedVia } = useWalletInfo();
|
|
16555
|
-
const handleWalletSelect = (0,
|
|
16914
|
+
const handleWalletSelect = (0, import_react35.useCallback)(
|
|
16556
16915
|
async (wallet) => {
|
|
16557
16916
|
setIsCryptoDropdownOpen(false);
|
|
16558
16917
|
try {
|
|
@@ -16563,6 +16922,7 @@ function useHomeWalletActions({
|
|
|
16563
16922
|
setWalletType("other");
|
|
16564
16923
|
const { error } = await connectWallet(wallet);
|
|
16565
16924
|
if (error) {
|
|
16925
|
+
console.error("Wallet connection error:", error);
|
|
16566
16926
|
resetNavigation();
|
|
16567
16927
|
return;
|
|
16568
16928
|
}
|
|
@@ -16576,7 +16936,7 @@ function useHomeWalletActions({
|
|
|
16576
16936
|
const handleFiatSelect = () => {
|
|
16577
16937
|
setIsFiatDropdownOpen(false);
|
|
16578
16938
|
};
|
|
16579
|
-
const handleWalletConnect = (0,
|
|
16939
|
+
const handleWalletConnect = (0, import_react35.useCallback)(async () => {
|
|
16580
16940
|
if (connectedVia !== "walletconnect" && isConnected) {
|
|
16581
16941
|
disconnect();
|
|
16582
16942
|
setYourWalletTokens([]);
|
|
@@ -16584,7 +16944,7 @@ function useHomeWalletActions({
|
|
|
16584
16944
|
WalletConnect().catch(() => resetNavigation());
|
|
16585
16945
|
}, [setYourWalletTokens, disconnect]);
|
|
16586
16946
|
const { selectedNamespace } = useDepositWallet();
|
|
16587
|
-
const browserWallets = (0,
|
|
16947
|
+
const browserWallets = (0, import_react35.useMemo)(() => {
|
|
16588
16948
|
if (!detectedWallets?.length) return [];
|
|
16589
16949
|
return detectedWallets.filter(
|
|
16590
16950
|
(wallet) => wallet?.meta?.id !== "walletconnect" && wallet?.meta?.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase()
|
|
@@ -16603,11 +16963,11 @@ function useHomeWalletActions({
|
|
|
16603
16963
|
setIsFiatDropdownOpen
|
|
16604
16964
|
};
|
|
16605
16965
|
}
|
|
16606
|
-
var
|
|
16966
|
+
var import_react35;
|
|
16607
16967
|
var init_useHomeWalletActions = __esm({
|
|
16608
16968
|
"src/widget/features/wallet/hooks/useHomeWalletActions.ts"() {
|
|
16609
16969
|
"use strict";
|
|
16610
|
-
|
|
16970
|
+
import_react35 = require("react");
|
|
16611
16971
|
init_useDepositNavigationState();
|
|
16612
16972
|
init_DepositContext();
|
|
16613
16973
|
init_wallets();
|
|
@@ -17012,7 +17372,7 @@ function useRoutePreviewModel({
|
|
|
17012
17372
|
walletAddress
|
|
17013
17373
|
}) {
|
|
17014
17374
|
const { chains } = useChains();
|
|
17015
|
-
const destinationConfig = (0,
|
|
17375
|
+
const destinationConfig = (0, import_react36.useMemo)(
|
|
17016
17376
|
() => ({
|
|
17017
17377
|
dappName: config.messages?.title || "DApp",
|
|
17018
17378
|
toChain: config.routes.toChain,
|
|
@@ -17026,7 +17386,7 @@ function useRoutePreviewModel({
|
|
|
17026
17386
|
config.routes.toToken
|
|
17027
17387
|
]
|
|
17028
17388
|
);
|
|
17029
|
-
const routeConfig = (0,
|
|
17389
|
+
const routeConfig = (0, import_react36.useMemo)(() => {
|
|
17030
17390
|
const toChainId = config.routes.toChain;
|
|
17031
17391
|
const toChainKey = normalizeChainKey2(toChainId);
|
|
17032
17392
|
const toChain = toChainKey ? chains.find(
|
|
@@ -17063,7 +17423,7 @@ function useRoutePreviewModel({
|
|
|
17063
17423
|
...routeConfig,
|
|
17064
17424
|
enabled: !!isReady
|
|
17065
17425
|
});
|
|
17066
|
-
const routePrerequisiteError = (0,
|
|
17426
|
+
const routePrerequisiteError = (0, import_react36.useMemo)(() => {
|
|
17067
17427
|
if (!isReady) return;
|
|
17068
17428
|
if (!selectedChain) {
|
|
17069
17429
|
return "Select a source chain to fetch a route.";
|
|
@@ -17104,11 +17464,11 @@ function useRoutePreviewModel({
|
|
|
17104
17464
|
...routeBuilderState
|
|
17105
17465
|
};
|
|
17106
17466
|
}
|
|
17107
|
-
var
|
|
17467
|
+
var import_react36;
|
|
17108
17468
|
var init_useRoutePreviewModel = __esm({
|
|
17109
17469
|
"src/widget/features/route-preview/hooks/useRoutePreviewModel.ts"() {
|
|
17110
17470
|
"use strict";
|
|
17111
|
-
|
|
17471
|
+
import_react36 = require("react");
|
|
17112
17472
|
init_hooks2();
|
|
17113
17473
|
init_chainHelpers();
|
|
17114
17474
|
}
|
|
@@ -30669,7 +31029,7 @@ function useTransactionActionModel({
|
|
|
30669
31029
|
walletAddress,
|
|
30670
31030
|
walletStatus
|
|
30671
31031
|
}) {
|
|
30672
|
-
const feeDataCacheRef = (0,
|
|
31032
|
+
const feeDataCacheRef = (0, import_react37.useRef)({});
|
|
30673
31033
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
30674
31034
|
const { trackEvent } = useGTM(GTM_ID);
|
|
30675
31035
|
const destinationConfig = (() => {
|
|
@@ -30682,7 +31042,7 @@ function useTransactionActionModel({
|
|
|
30682
31042
|
const chainType = selectedChain?.type ?? selectedChain?.chainType;
|
|
30683
31043
|
const chainTypeNormalized = (chainType ?? "").toLowerCase();
|
|
30684
31044
|
const isEvm = chainTypeNormalized === "evm";
|
|
30685
|
-
const backendChainId2 = (0,
|
|
31045
|
+
const backendChainId2 = (0, import_react37.useMemo)(() => {
|
|
30686
31046
|
const chainRef = routeResult?.txReq?.chainId ?? selectedChain?.networkIdentifier ?? selectedChain?.chainId ?? selectedChain?.id;
|
|
30687
31047
|
if (chainRef == null) return null;
|
|
30688
31048
|
return String(chainRef);
|
|
@@ -30692,7 +31052,7 @@ function useTransactionActionModel({
|
|
|
30692
31052
|
selectedChain?.id,
|
|
30693
31053
|
selectedChain?.networkIdentifier
|
|
30694
31054
|
]);
|
|
30695
|
-
const selectedTokenOnBackendChain = (0,
|
|
31055
|
+
const selectedTokenOnBackendChain = (0, import_react37.useMemo)(() => {
|
|
30696
31056
|
if (!backendChainId2) return false;
|
|
30697
31057
|
const target = normalizeChainKey2(backendChainId2);
|
|
30698
31058
|
return [
|
|
@@ -30709,23 +31069,23 @@ function useTransactionActionModel({
|
|
|
30709
31069
|
selectedChain?.id,
|
|
30710
31070
|
selectedChain?.networkIdentifier
|
|
30711
31071
|
]);
|
|
30712
|
-
const isNativeSelected = (0,
|
|
31072
|
+
const isNativeSelected = (0, import_react37.useMemo)(() => {
|
|
30713
31073
|
const address = selectedToken?.address;
|
|
30714
31074
|
return isNativeTokenAddress(address, chainType) || isZeroAddrLike(address, chainType) || normalizeTokenAddressForCompare(selectedChain, address) === normalizeTokenAddressForCompare(
|
|
30715
31075
|
selectedChain,
|
|
30716
31076
|
getNativeTokenAddress2(chainType)
|
|
30717
31077
|
);
|
|
30718
31078
|
}, [chainType, selectedChain, selectedToken?.address]);
|
|
30719
|
-
const spender = (0,
|
|
31079
|
+
const spender = (0, import_react37.useMemo)(() => {
|
|
30720
31080
|
const txReq = routeResult?.txReq;
|
|
30721
31081
|
const addr = txReq?.to ?? txReq?.target;
|
|
30722
31082
|
return addr ?? null;
|
|
30723
31083
|
}, [routeResult?.txReq]);
|
|
30724
|
-
const [allowanceWei, setAllowanceWei] = (0,
|
|
30725
|
-
const [isReadingAllowance, setIsReadingAllowance] = (0,
|
|
30726
|
-
const [isApproving, setIsApproving] = (0,
|
|
30727
|
-
const [gasReservationWei, setGasReservationWei] = (0,
|
|
30728
|
-
const readAllowance = (0,
|
|
31084
|
+
const [allowanceWei, setAllowanceWei] = (0, import_react37.useState)(0n);
|
|
31085
|
+
const [isReadingAllowance, setIsReadingAllowance] = (0, import_react37.useState)(false);
|
|
31086
|
+
const [isApproving, setIsApproving] = (0, import_react37.useState)(false);
|
|
31087
|
+
const [gasReservationWei, setGasReservationWei] = (0, import_react37.useState)(0n);
|
|
31088
|
+
const readAllowance = (0, import_react37.useCallback)(async () => {
|
|
30729
31089
|
if (!isEvm || isNativeSelected || !!routeResult?.sponsorship || // sponsored routes: SA approves bridge inside the UO batch
|
|
30730
31090
|
!backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
30731
31091
|
setAllowanceWei(0n);
|
|
@@ -30755,12 +31115,12 @@ function useTransactionActionModel({
|
|
|
30755
31115
|
spender,
|
|
30756
31116
|
walletAddress
|
|
30757
31117
|
]);
|
|
30758
|
-
(0,
|
|
31118
|
+
(0, import_react37.useEffect)(() => {
|
|
30759
31119
|
void readAllowance();
|
|
30760
31120
|
}, [readAllowance]);
|
|
30761
31121
|
const needsApproval = isEvm && !isNativeSelected && !routeResult?.sponsorship && // sponsored routes use Permit2 + SA internal batch — no EOA bridge approval
|
|
30762
31122
|
!!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
|
|
30763
|
-
const waitForApprovalConfirmation2 = (0,
|
|
31123
|
+
const waitForApprovalConfirmation2 = (0, import_react37.useCallback)(
|
|
30764
31124
|
async (chainId, txHash) => {
|
|
30765
31125
|
const timeoutMs = 12e4;
|
|
30766
31126
|
const intervalMs = 2e3;
|
|
@@ -30779,7 +31139,7 @@ function useTransactionActionModel({
|
|
|
30779
31139
|
},
|
|
30780
31140
|
[]
|
|
30781
31141
|
);
|
|
30782
|
-
const handleApproveExact = (0,
|
|
31142
|
+
const handleApproveExact = (0, import_react37.useCallback)(async () => {
|
|
30783
31143
|
if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
|
|
30784
31144
|
return;
|
|
30785
31145
|
}
|
|
@@ -30872,7 +31232,7 @@ function useTransactionActionModel({
|
|
|
30872
31232
|
waitForApprovalConfirmation2,
|
|
30873
31233
|
walletAddress
|
|
30874
31234
|
]);
|
|
30875
|
-
const getCachedFeeData = (0,
|
|
31235
|
+
const getCachedFeeData = (0, import_react37.useCallback)(async () => {
|
|
30876
31236
|
if (!backendChainId2) return {};
|
|
30877
31237
|
const now = Date.now();
|
|
30878
31238
|
const cache = feeDataCacheRef.current;
|
|
@@ -30895,7 +31255,7 @@ function useTransactionActionModel({
|
|
|
30895
31255
|
}
|
|
30896
31256
|
return cache.inflight;
|
|
30897
31257
|
}, [backendChainId2]);
|
|
30898
|
-
const estimateGasReservationWei = (0,
|
|
31258
|
+
const estimateGasReservationWei = (0, import_react37.useCallback)(async () => {
|
|
30899
31259
|
if (!isNativeSelected) {
|
|
30900
31260
|
setGasReservationWei(0n);
|
|
30901
31261
|
return 0n;
|
|
@@ -30959,16 +31319,16 @@ function useTransactionActionModel({
|
|
|
30959
31319
|
routeResult?.txReq,
|
|
30960
31320
|
walletAddress
|
|
30961
31321
|
]);
|
|
30962
|
-
(0,
|
|
31322
|
+
(0, import_react37.useEffect)(() => {
|
|
30963
31323
|
if (routeResult) {
|
|
30964
31324
|
void estimateGasReservationWei();
|
|
30965
31325
|
}
|
|
30966
31326
|
}, [estimateGasReservationWei, routeResult]);
|
|
30967
|
-
const [smartAccountFailed, setSmartAccountFailed] = (0,
|
|
30968
|
-
(0,
|
|
31327
|
+
const [smartAccountFailed, setSmartAccountFailed] = (0, import_react37.useState)(false);
|
|
31328
|
+
(0, import_react37.useEffect)(() => {
|
|
30969
31329
|
setSmartAccountFailed(false);
|
|
30970
31330
|
}, [routeResult?.intentId]);
|
|
30971
|
-
const handleConfirm = (0,
|
|
31331
|
+
const handleConfirm = (0, import_react37.useCallback)(async () => {
|
|
30972
31332
|
if (!routeResult) {
|
|
30973
31333
|
return;
|
|
30974
31334
|
}
|
|
@@ -31038,7 +31398,7 @@ function useTransactionActionModel({
|
|
|
31038
31398
|
trackEvent,
|
|
31039
31399
|
walletAddress
|
|
31040
31400
|
]);
|
|
31041
|
-
const handleSwipeConfirm = (0,
|
|
31401
|
+
const handleSwipeConfirm = (0, import_react37.useCallback)(async () => {
|
|
31042
31402
|
if (needsApproval) {
|
|
31043
31403
|
await handleApproveExact();
|
|
31044
31404
|
if (!backendChainId2 || !selectedTokenOnBackendChain || !selectedToken?.address || !walletAddress || !spender) {
|
|
@@ -31069,7 +31429,7 @@ function useTransactionActionModel({
|
|
|
31069
31429
|
]);
|
|
31070
31430
|
const isWalletConnected = walletStatus === "connected";
|
|
31071
31431
|
const canSwipe = parsedAmount > 0 && !!selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
|
|
31072
|
-
const swipeResetKey = (0,
|
|
31432
|
+
const swipeResetKey = (0, import_react37.useMemo)(() => {
|
|
31073
31433
|
const tokenAddress = selectedToken ? normalizeAddress2(
|
|
31074
31434
|
selectedToken.address,
|
|
31075
31435
|
selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType
|
|
@@ -31095,11 +31455,11 @@ function useTransactionActionModel({
|
|
|
31095
31455
|
swipeResetKey
|
|
31096
31456
|
};
|
|
31097
31457
|
}
|
|
31098
|
-
var
|
|
31458
|
+
var import_react37, import_viem42;
|
|
31099
31459
|
var init_useTransactionActionModel = __esm({
|
|
31100
31460
|
"src/widget/features/transaction/hooks/useTransactionActionModel.ts"() {
|
|
31101
31461
|
"use strict";
|
|
31102
|
-
|
|
31462
|
+
import_react37 = require("react");
|
|
31103
31463
|
import_viem42 = require("viem");
|
|
31104
31464
|
init_core2();
|
|
31105
31465
|
init_sdkRpc();
|
|
@@ -31303,9 +31663,9 @@ var init_DefaultCryptoPay = __esm({
|
|
|
31303
31663
|
|
|
31304
31664
|
// src/widget/pages/CryptoPay/RouteQuoteLoader.tsx
|
|
31305
31665
|
function RouteQuoteLoader({ selectedToken }) {
|
|
31306
|
-
const [messageIndex, setMessageIndex] = (0,
|
|
31307
|
-
const [visible, setVisible] = (0,
|
|
31308
|
-
(0,
|
|
31666
|
+
const [messageIndex, setMessageIndex] = (0, import_react38.useState)(0);
|
|
31667
|
+
const [visible, setVisible] = (0, import_react38.useState)(true);
|
|
31668
|
+
(0, import_react38.useEffect)(() => {
|
|
31309
31669
|
let t = null;
|
|
31310
31670
|
const interval = setInterval(() => {
|
|
31311
31671
|
setVisible(false);
|
|
@@ -31461,11 +31821,11 @@ function RouteQuoteLoader({ selectedToken }) {
|
|
|
31461
31821
|
}
|
|
31462
31822
|
);
|
|
31463
31823
|
}
|
|
31464
|
-
var
|
|
31824
|
+
var import_react38, import_jsx_runtime49, QUOTE_MESSAGES;
|
|
31465
31825
|
var init_RouteQuoteLoader = __esm({
|
|
31466
31826
|
"src/widget/pages/CryptoPay/RouteQuoteLoader.tsx"() {
|
|
31467
31827
|
"use strict";
|
|
31468
|
-
|
|
31828
|
+
import_react38 = require("react");
|
|
31469
31829
|
init_styles();
|
|
31470
31830
|
import_jsx_runtime49 = require("react/jsx-runtime");
|
|
31471
31831
|
QUOTE_MESSAGES = [
|
|
@@ -31505,17 +31865,17 @@ function CryptoPay({ style: _style }) {
|
|
|
31505
31865
|
const { goBack, setCurrentStep, currentStep } = useDepositNavigation();
|
|
31506
31866
|
const config = useTrustwareConfig();
|
|
31507
31867
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
31508
|
-
const routeRefreshMs = (0,
|
|
31868
|
+
const routeRefreshMs = (0, import_react39.useMemo)(() => {
|
|
31509
31869
|
const raw = config.routes?.options?.routeRefreshMs;
|
|
31510
31870
|
const n = Number(raw);
|
|
31511
31871
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
31512
31872
|
}, [config.routes?.options?.routeRefreshMs]);
|
|
31513
31873
|
const IsPos = (x) => x !== null && x !== void 0 && x.balance !== "0";
|
|
31514
|
-
const showDefaultCryptoPay = (0,
|
|
31874
|
+
const showDefaultCryptoPay = (0, import_react39.useMemo)(() => {
|
|
31515
31875
|
const nonZer0Tks = (yourWalletTokens ?? []).filter(IsPos);
|
|
31516
31876
|
return !yourWalletTokensLoading && nonZer0Tks.length === 0 && yourWalletTokens.length > 0;
|
|
31517
31877
|
}, [yourWalletTokens, yourWalletTokensLoading]);
|
|
31518
|
-
const showSkeleton = (0,
|
|
31878
|
+
const showSkeleton = (0, import_react39.useMemo)(() => {
|
|
31519
31879
|
return (yourWalletTokens ?? []).length === 0;
|
|
31520
31880
|
}, [yourWalletTokens]);
|
|
31521
31881
|
const isReady = selectedToken != null && selectedToken?.chainData !== void 0 && !showDefaultCryptoPay && !showSkeleton;
|
|
@@ -31591,7 +31951,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31591
31951
|
});
|
|
31592
31952
|
const { emitError } = useTrustware();
|
|
31593
31953
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
31594
|
-
(0,
|
|
31954
|
+
(0, import_react39.useEffect)(() => {
|
|
31595
31955
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
31596
31956
|
emitError?.(
|
|
31597
31957
|
new TrustwareError({
|
|
@@ -31620,7 +31980,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31620
31980
|
if (isFixedAmount) return;
|
|
31621
31981
|
setAmount(value.toString());
|
|
31622
31982
|
};
|
|
31623
|
-
const relayFeeUsd = (0,
|
|
31983
|
+
const relayFeeUsd = (0, import_react39.useMemo)(
|
|
31624
31984
|
() => computeRelayFeeUsd(routeResult, isNativeSelected),
|
|
31625
31985
|
[isNativeSelected, routeResult]
|
|
31626
31986
|
);
|
|
@@ -31790,11 +32150,11 @@ function CryptoPay({ style: _style }) {
|
|
|
31790
32150
|
}
|
|
31791
32151
|
);
|
|
31792
32152
|
}
|
|
31793
|
-
var
|
|
32153
|
+
var import_react39, import_jsx_runtime50, SHOW_FEE_SUMMARY;
|
|
31794
32154
|
var init_CryptoPay = __esm({
|
|
31795
32155
|
"src/widget/pages/CryptoPay/index.tsx"() {
|
|
31796
32156
|
"use strict";
|
|
31797
|
-
|
|
32157
|
+
import_react39 = require("react");
|
|
31798
32158
|
init_relayFeeUtils();
|
|
31799
32159
|
init_TrustwareError();
|
|
31800
32160
|
init_useTrustwareConfig();
|
|
@@ -31851,27 +32211,27 @@ function Processing({ style }) {
|
|
|
31851
32211
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
31852
32212
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
31853
32213
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
31854
|
-
const hasStartedPolling = (0,
|
|
31855
|
-
(0,
|
|
32214
|
+
const hasStartedPolling = (0, import_react40.useRef)(false);
|
|
32215
|
+
(0, import_react40.useEffect)(() => {
|
|
31856
32216
|
return () => {
|
|
31857
32217
|
hasStartedPolling.current = false;
|
|
31858
32218
|
};
|
|
31859
32219
|
}, []);
|
|
31860
|
-
(0,
|
|
32220
|
+
(0, import_react40.useEffect)(() => {
|
|
31861
32221
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
31862
32222
|
hasStartedPolling.current = true;
|
|
31863
32223
|
startPolling(intentId, transactionHash);
|
|
31864
32224
|
}
|
|
31865
32225
|
}, [intentId, transactionHash, isPolling, transactionStatus, startPolling]);
|
|
31866
|
-
const progress = (0,
|
|
32226
|
+
const progress = (0, import_react40.useMemo)(
|
|
31867
32227
|
() => getProgressFromStatus(transactionStatus),
|
|
31868
32228
|
[transactionStatus]
|
|
31869
32229
|
);
|
|
31870
|
-
const stepText = (0,
|
|
32230
|
+
const stepText = (0, import_react40.useMemo)(
|
|
31871
32231
|
() => getStepText(transactionStatus),
|
|
31872
32232
|
[transactionStatus]
|
|
31873
32233
|
);
|
|
31874
|
-
const explorerUrl = (0,
|
|
32234
|
+
const explorerUrl = (0, import_react40.useMemo)(() => {
|
|
31875
32235
|
if (transaction?.fromChainTxUrl) {
|
|
31876
32236
|
return transaction.fromChainTxUrl;
|
|
31877
32237
|
}
|
|
@@ -32006,11 +32366,11 @@ function Processing({ style }) {
|
|
|
32006
32366
|
}
|
|
32007
32367
|
);
|
|
32008
32368
|
}
|
|
32009
|
-
var
|
|
32369
|
+
var import_react40, import_jsx_runtime51;
|
|
32010
32370
|
var init_Processing = __esm({
|
|
32011
32371
|
"src/widget/pages/Processing.tsx"() {
|
|
32012
32372
|
"use strict";
|
|
32013
|
-
|
|
32373
|
+
import_react40 = require("react");
|
|
32014
32374
|
init_styles();
|
|
32015
32375
|
init_DepositContext();
|
|
32016
32376
|
init_components();
|
|
@@ -32025,8 +32385,8 @@ function Success({ style }) {
|
|
|
32025
32385
|
const { resetState } = useDepositNavigation();
|
|
32026
32386
|
const { transactionHash } = useDepositTransaction();
|
|
32027
32387
|
const { transaction } = useTransactionPolling();
|
|
32028
|
-
const parsedAmount = (0,
|
|
32029
|
-
const explorerUrl = (0,
|
|
32388
|
+
const parsedAmount = (0, import_react41.useMemo)(() => parseFloat(amount) || 0, [amount]);
|
|
32389
|
+
const explorerUrl = (0, import_react41.useMemo)(() => {
|
|
32030
32390
|
if (transaction?.toChainTxUrl) {
|
|
32031
32391
|
return transaction.toChainTxUrl;
|
|
32032
32392
|
}
|
|
@@ -32054,7 +32414,7 @@ function Success({ style }) {
|
|
|
32054
32414
|
...style
|
|
32055
32415
|
},
|
|
32056
32416
|
children: [
|
|
32057
|
-
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
32417
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react41.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ConfettiEffect2, { isActive: true, pieceCount: 60, clearDelay: 4e3 }) }),
|
|
32058
32418
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(WidgetPageHeader, { title: "Deposit Complete" }),
|
|
32059
32419
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
32060
32420
|
"div",
|
|
@@ -32087,16 +32447,16 @@ function Success({ style }) {
|
|
|
32087
32447
|
}
|
|
32088
32448
|
);
|
|
32089
32449
|
}
|
|
32090
|
-
var
|
|
32450
|
+
var import_react41, import_jsx_runtime52, ConfettiEffect2;
|
|
32091
32451
|
var init_Success = __esm({
|
|
32092
32452
|
"src/widget/pages/Success.tsx"() {
|
|
32093
32453
|
"use strict";
|
|
32094
|
-
|
|
32454
|
+
import_react41 = require("react");
|
|
32095
32455
|
init_DepositContext();
|
|
32096
32456
|
init_components();
|
|
32097
32457
|
init_transaction2();
|
|
32098
32458
|
import_jsx_runtime52 = require("react/jsx-runtime");
|
|
32099
|
-
ConfettiEffect2 = (0,
|
|
32459
|
+
ConfettiEffect2 = (0, import_react41.lazy)(() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports)));
|
|
32100
32460
|
}
|
|
32101
32461
|
});
|
|
32102
32462
|
|
|
@@ -32258,8 +32618,8 @@ function Error2({ style: _style }) {
|
|
|
32258
32618
|
setErrorMessage,
|
|
32259
32619
|
transactionHash
|
|
32260
32620
|
} = useDepositTransaction();
|
|
32261
|
-
const mapped = (0,
|
|
32262
|
-
const explorerUrl = (0,
|
|
32621
|
+
const mapped = (0, import_react42.useMemo)(() => mapError(errorMessage), [errorMessage]);
|
|
32622
|
+
const explorerUrl = (0, import_react42.useMemo)(() => {
|
|
32263
32623
|
if (transactionHash && selectedChain?.blockExplorerUrls?.length) {
|
|
32264
32624
|
return `${selectedChain.blockExplorerUrls[0].replace(/\/+$/, "")}/tx/${transactionHash}`;
|
|
32265
32625
|
}
|
|
@@ -32282,11 +32642,11 @@ function Error2({ style: _style }) {
|
|
|
32282
32642
|
}
|
|
32283
32643
|
);
|
|
32284
32644
|
}
|
|
32285
|
-
var
|
|
32645
|
+
var import_react42, import_jsx_runtime53;
|
|
32286
32646
|
var init_Error = __esm({
|
|
32287
32647
|
"src/widget/pages/Error.tsx"() {
|
|
32288
32648
|
"use strict";
|
|
32289
|
-
|
|
32649
|
+
import_react42 = require("react");
|
|
32290
32650
|
init_DepositContext();
|
|
32291
32651
|
init_components();
|
|
32292
32652
|
init_mapError();
|
|
@@ -32327,11 +32687,11 @@ function WidgetRouter({
|
|
|
32327
32687
|
navigationDirection,
|
|
32328
32688
|
stepHistory
|
|
32329
32689
|
}) {
|
|
32330
|
-
const PageComponent = (0,
|
|
32690
|
+
const PageComponent = (0, import_react43.useMemo)(
|
|
32331
32691
|
() => PAGE_COMPONENTS[currentStep],
|
|
32332
32692
|
[currentStep]
|
|
32333
32693
|
);
|
|
32334
|
-
const animationClass = (0,
|
|
32694
|
+
const animationClass = (0, import_react43.useMemo)(() => {
|
|
32335
32695
|
return navigationDirection === "forward" ? "tw-animate-slide-in-right" : "tw-animate-slide-in-left";
|
|
32336
32696
|
}, [navigationDirection]);
|
|
32337
32697
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
@@ -32344,11 +32704,11 @@ function WidgetRouter({
|
|
|
32344
32704
|
`${currentStep}-${stepHistory.length}`
|
|
32345
32705
|
);
|
|
32346
32706
|
}
|
|
32347
|
-
var
|
|
32707
|
+
var import_react43, import_jsx_runtime54, pageContainerBaseStyle;
|
|
32348
32708
|
var init_WidgetRouter = __esm({
|
|
32349
32709
|
"src/widget/app/WidgetRouter.tsx"() {
|
|
32350
32710
|
"use strict";
|
|
32351
|
-
|
|
32711
|
+
import_react43 = require("react");
|
|
32352
32712
|
init_utils();
|
|
32353
32713
|
init_widgetSteps();
|
|
32354
32714
|
import_jsx_runtime54 = require("react/jsx-runtime");
|
|
@@ -32362,13 +32722,13 @@ var init_WidgetRouter = __esm({
|
|
|
32362
32722
|
|
|
32363
32723
|
// src/modes/swap/hooks/useSwapRoute.ts
|
|
32364
32724
|
function useSwapRoute() {
|
|
32365
|
-
const [state, setState] = (0,
|
|
32725
|
+
const [state, setState] = (0, import_react44.useState)({
|
|
32366
32726
|
data: null,
|
|
32367
32727
|
loading: false,
|
|
32368
32728
|
error: null
|
|
32369
32729
|
});
|
|
32370
|
-
const abortRef = (0,
|
|
32371
|
-
const fetch2 = (0,
|
|
32730
|
+
const abortRef = (0, import_react44.useRef)(false);
|
|
32731
|
+
const fetch2 = (0, import_react44.useCallback)(
|
|
32372
32732
|
async (params) => {
|
|
32373
32733
|
const { fromToken, fromChain, toToken, toChain, amount, walletAddress } = params;
|
|
32374
32734
|
const decimals = fromToken.decimals ?? 18;
|
|
@@ -32409,18 +32769,18 @@ function useSwapRoute() {
|
|
|
32409
32769
|
},
|
|
32410
32770
|
[]
|
|
32411
32771
|
);
|
|
32412
|
-
const clear = (0,
|
|
32772
|
+
const clear = (0, import_react44.useCallback)(() => {
|
|
32413
32773
|
abortRef.current = true;
|
|
32414
32774
|
setState({ data: null, loading: false, error: null });
|
|
32415
32775
|
}, []);
|
|
32416
32776
|
return { ...state, fetch: fetch2, clear };
|
|
32417
32777
|
}
|
|
32418
|
-
var
|
|
32778
|
+
var import_react44;
|
|
32419
32779
|
var init_useSwapRoute = __esm({
|
|
32420
32780
|
"src/modes/swap/hooks/useSwapRoute.ts"() {
|
|
32421
32781
|
"use strict";
|
|
32422
32782
|
"use client";
|
|
32423
|
-
|
|
32783
|
+
import_react44 = require("react");
|
|
32424
32784
|
init_routes();
|
|
32425
32785
|
init_chainHelpers();
|
|
32426
32786
|
init_store();
|
|
@@ -32461,7 +32821,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
32461
32821
|
throw new Error("Timed out waiting for approval confirmation");
|
|
32462
32822
|
}
|
|
32463
32823
|
function useSwapExecution(fromChain) {
|
|
32464
|
-
const [state, setState] = (0,
|
|
32824
|
+
const [state, setState] = (0, import_react45.useState)({
|
|
32465
32825
|
txStatus: "idle",
|
|
32466
32826
|
txHash: null,
|
|
32467
32827
|
intentId: null,
|
|
@@ -32470,19 +32830,19 @@ function useSwapExecution(fromChain) {
|
|
|
32470
32830
|
isSubmitting: false,
|
|
32471
32831
|
allowanceStatus: "unknown"
|
|
32472
32832
|
});
|
|
32473
|
-
const saFailedUntilRef = (0,
|
|
32474
|
-
const pollingRef = (0,
|
|
32475
|
-
const timeoutRef = (0,
|
|
32476
|
-
const abortRef = (0,
|
|
32477
|
-
const pollCountRef = (0,
|
|
32478
|
-
const clearPolling = (0,
|
|
32833
|
+
const saFailedUntilRef = (0, import_react45.useRef)(0);
|
|
32834
|
+
const pollingRef = (0, import_react45.useRef)(null);
|
|
32835
|
+
const timeoutRef = (0, import_react45.useRef)(null);
|
|
32836
|
+
const abortRef = (0, import_react45.useRef)(false);
|
|
32837
|
+
const pollCountRef = (0, import_react45.useRef)(0);
|
|
32838
|
+
const clearPolling = (0, import_react45.useCallback)(() => {
|
|
32479
32839
|
abortRef.current = true;
|
|
32480
32840
|
if (pollingRef.current) clearTimeout(pollingRef.current);
|
|
32481
32841
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
32482
32842
|
pollingRef.current = null;
|
|
32483
32843
|
timeoutRef.current = null;
|
|
32484
32844
|
}, []);
|
|
32485
|
-
const startPolling = (0,
|
|
32845
|
+
const startPolling = (0, import_react45.useCallback)(
|
|
32486
32846
|
(intentIdVal, onSuccess, onError) => {
|
|
32487
32847
|
clearPolling();
|
|
32488
32848
|
abortRef.current = false;
|
|
@@ -32527,7 +32887,7 @@ function useSwapExecution(fromChain) {
|
|
|
32527
32887
|
},
|
|
32528
32888
|
[clearPolling]
|
|
32529
32889
|
);
|
|
32530
|
-
const checkAllowance = (0,
|
|
32890
|
+
const checkAllowance = (0, import_react45.useCallback)(
|
|
32531
32891
|
async (params) => {
|
|
32532
32892
|
const { fromTokenAddress, walletAddress, routeResult } = params;
|
|
32533
32893
|
if (routeResult.sponsorship) {
|
|
@@ -32567,7 +32927,7 @@ function useSwapExecution(fromChain) {
|
|
|
32567
32927
|
},
|
|
32568
32928
|
[fromChain]
|
|
32569
32929
|
);
|
|
32570
|
-
const execute = (0,
|
|
32930
|
+
const execute = (0, import_react45.useCallback)(
|
|
32571
32931
|
async (routeResult, fromTokenAddress, fromTokenDecimals, walletAddress, maxApproval, onSuccess, onError) => {
|
|
32572
32932
|
if (!routeResult?.txReq) {
|
|
32573
32933
|
const msg = "Invalid route data. Please try again.";
|
|
@@ -32763,10 +33123,10 @@ function useSwapExecution(fromChain) {
|
|
|
32763
33123
|
},
|
|
32764
33124
|
[fromChain, startPolling]
|
|
32765
33125
|
);
|
|
32766
|
-
const resetSmartAccountFailure = (0,
|
|
33126
|
+
const resetSmartAccountFailure = (0, import_react45.useCallback)(() => {
|
|
32767
33127
|
saFailedUntilRef.current = 0;
|
|
32768
33128
|
}, []);
|
|
32769
|
-
const reset = (0,
|
|
33129
|
+
const reset = (0, import_react45.useCallback)(() => {
|
|
32770
33130
|
clearPolling();
|
|
32771
33131
|
saFailedUntilRef.current = 0;
|
|
32772
33132
|
setState({
|
|
@@ -32797,12 +33157,12 @@ function mapTxError(err) {
|
|
|
32797
33157
|
return "Transaction would fail. Try a different amount.";
|
|
32798
33158
|
return msg.length > 150 ? msg.slice(0, 147) + "..." : msg || "Transaction failed.";
|
|
32799
33159
|
}
|
|
32800
|
-
var
|
|
33160
|
+
var import_react45, import_viem43, FAST_POLL_MS, SLOW_POLL_MS, TIMEOUT_MS, SA_COOLDOWN_MS;
|
|
32801
33161
|
var init_useSwapExecution = __esm({
|
|
32802
33162
|
"src/modes/swap/hooks/useSwapExecution.ts"() {
|
|
32803
33163
|
"use strict";
|
|
32804
33164
|
"use client";
|
|
32805
|
-
|
|
33165
|
+
import_react45 = require("react");
|
|
32806
33166
|
import_viem43 = require("viem");
|
|
32807
33167
|
init_core2();
|
|
32808
33168
|
init_routes();
|
|
@@ -32840,11 +33200,11 @@ var init_forex = __esm({
|
|
|
32840
33200
|
|
|
32841
33201
|
// src/modes/swap/hooks/useForex.ts
|
|
32842
33202
|
function useForex() {
|
|
32843
|
-
const [rates, setRates] = (0,
|
|
32844
|
-
const [error, setError] = (0,
|
|
32845
|
-
const [lastUpdated, setLastUpdated] = (0,
|
|
32846
|
-
const timerRef = (0,
|
|
32847
|
-
(0,
|
|
33203
|
+
const [rates, setRates] = (0, import_react46.useState)({ USD: 1 });
|
|
33204
|
+
const [error, setError] = (0, import_react46.useState)(null);
|
|
33205
|
+
const [lastUpdated, setLastUpdated] = (0, import_react46.useState)(null);
|
|
33206
|
+
const timerRef = (0, import_react46.useRef)(null);
|
|
33207
|
+
(0, import_react46.useEffect)(() => {
|
|
32848
33208
|
let cancelled = false;
|
|
32849
33209
|
const load = () => {
|
|
32850
33210
|
fetchForexRates("USD").then((r) => {
|
|
@@ -32871,11 +33231,11 @@ function useForex() {
|
|
|
32871
33231
|
}, []);
|
|
32872
33232
|
return { rates, error, lastUpdated };
|
|
32873
33233
|
}
|
|
32874
|
-
var
|
|
33234
|
+
var import_react46, REFRESH_MS;
|
|
32875
33235
|
var init_useForex = __esm({
|
|
32876
33236
|
"src/modes/swap/hooks/useForex.ts"() {
|
|
32877
33237
|
"use strict";
|
|
32878
|
-
|
|
33238
|
+
import_react46 = require("react");
|
|
32879
33239
|
init_forex();
|
|
32880
33240
|
REFRESH_MS = 5 * 60 * 1e3;
|
|
32881
33241
|
}
|
|
@@ -32896,10 +33256,10 @@ function SwapTokenSelect({
|
|
|
32896
33256
|
allowedTokens,
|
|
32897
33257
|
excludeToken
|
|
32898
33258
|
}) {
|
|
32899
|
-
const [localChain, setLocalChain] = (0,
|
|
32900
|
-
const [pinnedTokens, setPinnedTokens] = (0,
|
|
32901
|
-
const [pinnedLoading, setPinnedLoading] = (0,
|
|
32902
|
-
(0,
|
|
33259
|
+
const [localChain, setLocalChain] = (0, import_react47.useState)(initialChain);
|
|
33260
|
+
const [pinnedTokens, setPinnedTokens] = (0, import_react47.useState)([]);
|
|
33261
|
+
const [pinnedLoading, setPinnedLoading] = (0, import_react47.useState)(false);
|
|
33262
|
+
(0, import_react47.useEffect)(() => {
|
|
32903
33263
|
if (!allowedTokens || allowedTokens.length === 0 || !localChain) {
|
|
32904
33264
|
setPinnedTokens([]);
|
|
32905
33265
|
return;
|
|
@@ -32980,26 +33340,26 @@ function SwapTokenSelect({
|
|
|
32980
33340
|
walletAddress,
|
|
32981
33341
|
yourWalletTokens
|
|
32982
33342
|
});
|
|
32983
|
-
const allowedSet = (0,
|
|
33343
|
+
const allowedSet = (0, import_react47.useMemo)(() => {
|
|
32984
33344
|
if (!allowedTokens || allowedTokens.length === 0) return null;
|
|
32985
33345
|
return new Set(
|
|
32986
33346
|
allowedTokens.map((t) => `${t.chainId}:${t.address.toLowerCase()}`)
|
|
32987
33347
|
);
|
|
32988
33348
|
}, [allowedTokens]);
|
|
32989
|
-
const filteredWalletTokens = (0,
|
|
33349
|
+
const filteredWalletTokens = (0, import_react47.useMemo)(() => {
|
|
32990
33350
|
if (!allowedSet) return rawWalletTokens;
|
|
32991
33351
|
return rawWalletTokens.filter(
|
|
32992
33352
|
(t) => allowedSet.has(`${Number(t.chainId)}:${t.address.toLowerCase()}`)
|
|
32993
33353
|
);
|
|
32994
33354
|
}, [rawWalletTokens, allowedSet]);
|
|
32995
33355
|
const excludeKey = excludeToken ? `${Number(excludeToken.chainId)}:${excludeToken.address.toLowerCase()}` : null;
|
|
32996
|
-
const visibleTokens = (0,
|
|
33356
|
+
const visibleTokens = (0, import_react47.useMemo)(() => {
|
|
32997
33357
|
if (!excludeKey) return filteredTokens;
|
|
32998
33358
|
return filteredTokens.filter(
|
|
32999
33359
|
(t) => `${Number(t.chainId)}:${t.address.toLowerCase()}` !== excludeKey
|
|
33000
33360
|
);
|
|
33001
33361
|
}, [filteredTokens, excludeKey]);
|
|
33002
|
-
const visibleWalletTokens = (0,
|
|
33362
|
+
const visibleWalletTokens = (0, import_react47.useMemo)(() => {
|
|
33003
33363
|
if (!excludeKey) return filteredWalletTokens;
|
|
33004
33364
|
return filteredWalletTokens.filter(
|
|
33005
33365
|
(t) => `${Number(t.chainId)}:${t.address.toLowerCase()}` !== excludeKey
|
|
@@ -33116,11 +33476,11 @@ function SwapTokenSelect({
|
|
|
33116
33476
|
}
|
|
33117
33477
|
);
|
|
33118
33478
|
}
|
|
33119
|
-
var
|
|
33479
|
+
var import_react47, import_jsx_runtime55;
|
|
33120
33480
|
var init_SwapTokenSelect = __esm({
|
|
33121
33481
|
"src/modes/swap/components/SwapTokenSelect.tsx"() {
|
|
33122
33482
|
"use strict";
|
|
33123
|
-
|
|
33483
|
+
import_react47 = require("react");
|
|
33124
33484
|
init_styles();
|
|
33125
33485
|
init_registryClient();
|
|
33126
33486
|
init_hooks2();
|
|
@@ -33146,16 +33506,16 @@ function SwapWalletSelector({
|
|
|
33146
33506
|
} = useWalletInfo();
|
|
33147
33507
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
33148
33508
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
33149
|
-
const [wcConnecting, setWcConnecting] = (0,
|
|
33150
|
-
const [connectingId, setConnectingId] = (0,
|
|
33151
|
-
const [timerExpired, setTimerExpired] = (0,
|
|
33152
|
-
const [selectedNamespace, setSelectedNamespace] = (0,
|
|
33153
|
-
const prevStatusRef = (0,
|
|
33154
|
-
(0,
|
|
33509
|
+
const [wcConnecting, setWcConnecting] = (0, import_react48.useState)(false);
|
|
33510
|
+
const [connectingId, setConnectingId] = (0, import_react48.useState)(null);
|
|
33511
|
+
const [timerExpired, setTimerExpired] = (0, import_react48.useState)(false);
|
|
33512
|
+
const [selectedNamespace, setSelectedNamespace] = (0, import_react48.useState)("evm");
|
|
33513
|
+
const prevStatusRef = (0, import_react48.useRef)(walletStatus);
|
|
33514
|
+
(0, import_react48.useEffect)(() => {
|
|
33155
33515
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
33156
33516
|
return () => clearTimeout(t);
|
|
33157
33517
|
}, []);
|
|
33158
|
-
(0,
|
|
33518
|
+
(0, import_react48.useEffect)(() => {
|
|
33159
33519
|
const prev = prevStatusRef.current;
|
|
33160
33520
|
if (prev !== walletStatus) {
|
|
33161
33521
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -33164,7 +33524,7 @@ function SwapWalletSelector({
|
|
|
33164
33524
|
prevStatusRef.current = walletStatus;
|
|
33165
33525
|
}
|
|
33166
33526
|
}, [walletStatus]);
|
|
33167
|
-
const filteredWallets = (0,
|
|
33527
|
+
const filteredWallets = (0, import_react48.useMemo)(
|
|
33168
33528
|
() => detected.filter(
|
|
33169
33529
|
(w) => (w.meta?.ecosystem ?? "").toLowerCase() === selectedNamespace
|
|
33170
33530
|
),
|
|
@@ -33740,11 +34100,11 @@ function SwapWalletSelector({
|
|
|
33740
34100
|
] })
|
|
33741
34101
|
] });
|
|
33742
34102
|
}
|
|
33743
|
-
var
|
|
34103
|
+
var import_react48, import_jsx_runtime56;
|
|
33744
34104
|
var init_SwapWalletSelector = __esm({
|
|
33745
34105
|
"src/modes/swap/components/SwapWalletSelector.tsx"() {
|
|
33746
34106
|
"use strict";
|
|
33747
|
-
|
|
34107
|
+
import_react48 = require("react");
|
|
33748
34108
|
init_styles();
|
|
33749
34109
|
init_utils();
|
|
33750
34110
|
init_wallets();
|
|
@@ -33919,41 +34279,41 @@ function SwapMode({
|
|
|
33919
34279
|
theme: themeProp,
|
|
33920
34280
|
style
|
|
33921
34281
|
}) {
|
|
33922
|
-
const [stage, setStage] = (0,
|
|
33923
|
-
const [fromToken, setFromToken] = (0,
|
|
34282
|
+
const [stage, setStage] = (0, import_react49.useState)("home");
|
|
34283
|
+
const [fromToken, setFromToken] = (0, import_react49.useState)(
|
|
33924
34284
|
null
|
|
33925
34285
|
);
|
|
33926
|
-
const [fromChain, setFromChain] = (0,
|
|
33927
|
-
const [toToken, setToToken] = (0,
|
|
33928
|
-
const [toChain, setToChain] = (0,
|
|
33929
|
-
const [amount, setAmount] = (0,
|
|
33930
|
-
const [amountInputMode, setAmountInputMode] = (0,
|
|
34286
|
+
const [fromChain, setFromChain] = (0, import_react49.useState)(null);
|
|
34287
|
+
const [toToken, setToToken] = (0, import_react49.useState)(null);
|
|
34288
|
+
const [toChain, setToChain] = (0, import_react49.useState)(null);
|
|
34289
|
+
const [amount, setAmount] = (0, import_react49.useState)("");
|
|
34290
|
+
const [amountInputMode, setAmountInputMode] = (0, import_react49.useState)(
|
|
33931
34291
|
"usd"
|
|
33932
34292
|
);
|
|
33933
|
-
const [hoverSell, setHoverSell] = (0,
|
|
33934
|
-
const [showRateDetails, setShowRateDetails] = (0,
|
|
33935
|
-
const [showReviewDetails, setShowReviewDetails] = (0,
|
|
33936
|
-
const [showSettings, setShowSettings] = (0,
|
|
33937
|
-
const [maxApproval, setMaxApproval] = (0,
|
|
33938
|
-
const [slippage, setSlippage] = (0,
|
|
33939
|
-
const [slippageInput, setSlippageInput] = (0,
|
|
33940
|
-
const [selectedCurrency, setSelectedCurrency] = (0,
|
|
33941
|
-
const [showCurrencyDropdown, setShowCurrencyDropdown] = (0,
|
|
33942
|
-
const [completedAt, setCompletedAt] = (0,
|
|
33943
|
-
const [copiedHash, setCopiedHash] = (0,
|
|
33944
|
-
const [rateUpdated, setRateUpdated] = (0,
|
|
33945
|
-
const prevToAmountRef = (0,
|
|
33946
|
-
const [destAddress, setDestAddress] = (0,
|
|
33947
|
-
const [quoteAge, setQuoteAge] = (0,
|
|
33948
|
-
const quoteTimestampRef = (0,
|
|
33949
|
-
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = (0,
|
|
33950
|
-
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = (0,
|
|
33951
|
-
const latestFetchParamsRef = (0,
|
|
34293
|
+
const [hoverSell, setHoverSell] = (0, import_react49.useState)(false);
|
|
34294
|
+
const [showRateDetails, setShowRateDetails] = (0, import_react49.useState)(false);
|
|
34295
|
+
const [showReviewDetails, setShowReviewDetails] = (0, import_react49.useState)(false);
|
|
34296
|
+
const [showSettings, setShowSettings] = (0, import_react49.useState)(false);
|
|
34297
|
+
const [maxApproval, setMaxApproval] = (0, import_react49.useState)(false);
|
|
34298
|
+
const [slippage, setSlippage] = (0, import_react49.useState)(0.5);
|
|
34299
|
+
const [slippageInput, setSlippageInput] = (0, import_react49.useState)("");
|
|
34300
|
+
const [selectedCurrency, setSelectedCurrency] = (0, import_react49.useState)("USD");
|
|
34301
|
+
const [showCurrencyDropdown, setShowCurrencyDropdown] = (0, import_react49.useState)(false);
|
|
34302
|
+
const [completedAt, setCompletedAt] = (0, import_react49.useState)(null);
|
|
34303
|
+
const [copiedHash, setCopiedHash] = (0, import_react49.useState)(null);
|
|
34304
|
+
const [rateUpdated, setRateUpdated] = (0, import_react49.useState)(false);
|
|
34305
|
+
const prevToAmountRef = (0, import_react49.useRef)(null);
|
|
34306
|
+
const [destAddress, setDestAddress] = (0, import_react49.useState)("");
|
|
34307
|
+
const [quoteAge, setQuoteAge] = (0, import_react49.useState)(0);
|
|
34308
|
+
const quoteTimestampRef = (0, import_react49.useRef)(null);
|
|
34309
|
+
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = (0, import_react49.useState)(0);
|
|
34310
|
+
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = (0, import_react49.useState)(true);
|
|
34311
|
+
const latestFetchParamsRef = (0, import_react49.useRef)(null);
|
|
33952
34312
|
const { rates: forexRates } = useForex();
|
|
33953
34313
|
const currencyMeta = getCurrencyMeta(selectedCurrency);
|
|
33954
34314
|
const currencyRate = forexRates[selectedCurrency] ?? 1;
|
|
33955
34315
|
const currencySymbol = currencyMeta.symbol;
|
|
33956
|
-
const fmtLocal = (0,
|
|
34316
|
+
const fmtLocal = (0, import_react49.useCallback)(
|
|
33957
34317
|
(usdAmount) => {
|
|
33958
34318
|
const sym = getCurrencyMeta(selectedCurrency).symbol;
|
|
33959
34319
|
if (usdAmount === null || !isFinite(usdAmount) || usdAmount <= 0)
|
|
@@ -33964,8 +34324,8 @@ function SwapMode({
|
|
|
33964
34324
|
},
|
|
33965
34325
|
[currencyRate, selectedCurrency]
|
|
33966
34326
|
);
|
|
33967
|
-
const settingsRef = (0,
|
|
33968
|
-
const currencyDropdownRef = (0,
|
|
34327
|
+
const settingsRef = (0, import_react49.useRef)(null);
|
|
34328
|
+
const currencyDropdownRef = (0, import_react49.useRef)(null);
|
|
33969
34329
|
const { emitEvent } = useTrustware();
|
|
33970
34330
|
const { features, theme: configTheme } = useTrustwareConfig();
|
|
33971
34331
|
const effectiveThemeSetting = themeProp ?? configTheme ?? "system";
|
|
@@ -33981,26 +34341,26 @@ function SwapMode({
|
|
|
33981
34341
|
isLoading: chainsLoading,
|
|
33982
34342
|
error: chainsError
|
|
33983
34343
|
} = useChains();
|
|
33984
|
-
const allowedDestChainIds = (0,
|
|
34344
|
+
const allowedDestChainIds = (0, import_react49.useMemo)(() => {
|
|
33985
34345
|
if (!allowedDestTokens || allowedDestTokens.length === 0) return null;
|
|
33986
34346
|
return new Set(allowedDestTokens.map((t) => t.chainId));
|
|
33987
34347
|
}, [allowedDestTokens]);
|
|
33988
|
-
const toPopularChains = (0,
|
|
34348
|
+
const toPopularChains = (0, import_react49.useMemo)(
|
|
33989
34349
|
() => allowedDestChainIds ? popularChains.filter(
|
|
33990
34350
|
(c) => allowedDestChainIds.has(Number(c.chainId))
|
|
33991
34351
|
) : popularChains,
|
|
33992
34352
|
[popularChains, allowedDestChainIds]
|
|
33993
34353
|
);
|
|
33994
|
-
const toOtherChains = (0,
|
|
34354
|
+
const toOtherChains = (0, import_react49.useMemo)(
|
|
33995
34355
|
() => allowedDestChainIds ? otherChains.filter((c) => allowedDestChainIds.has(Number(c.chainId))) : otherChains,
|
|
33996
34356
|
[otherChains, allowedDestChainIds]
|
|
33997
34357
|
);
|
|
33998
|
-
const allChains = (0,
|
|
34358
|
+
const allChains = (0, import_react49.useMemo)(
|
|
33999
34359
|
() => [...popularChains, ...otherChains],
|
|
34000
34360
|
[popularChains, otherChains]
|
|
34001
34361
|
);
|
|
34002
|
-
const destInitialized = (0,
|
|
34003
|
-
(0,
|
|
34362
|
+
const destInitialized = (0, import_react49.useRef)(false);
|
|
34363
|
+
(0, import_react49.useEffect)(() => {
|
|
34004
34364
|
if (!defaultDestRef || destInitialized.current || allChains.length === 0)
|
|
34005
34365
|
return;
|
|
34006
34366
|
const chain = allChains.find(
|
|
@@ -34031,11 +34391,11 @@ function SwapMode({
|
|
|
34031
34391
|
});
|
|
34032
34392
|
}, [defaultDestRef, allChains]);
|
|
34033
34393
|
const { walletAddress, walletStatus, connectWallet, disconnectWallet } = useWalletSessionState();
|
|
34034
|
-
const setFromTokenStable = (0,
|
|
34394
|
+
const setFromTokenStable = (0, import_react49.useCallback)(
|
|
34035
34395
|
(t) => setFromToken(t),
|
|
34036
34396
|
[]
|
|
34037
34397
|
);
|
|
34038
|
-
const setFromChainStable = (0,
|
|
34398
|
+
const setFromChainStable = (0, import_react49.useCallback)(
|
|
34039
34399
|
(c) => setFromChain(c),
|
|
34040
34400
|
[]
|
|
34041
34401
|
);
|
|
@@ -34048,18 +34408,18 @@ function SwapMode({
|
|
|
34048
34408
|
});
|
|
34049
34409
|
const route = useSwapRoute();
|
|
34050
34410
|
const execution = useSwapExecution(fromChain);
|
|
34051
|
-
const fromTokenPriceUSD = (0,
|
|
34411
|
+
const fromTokenPriceUSD = (0, import_react49.useMemo)(() => {
|
|
34052
34412
|
const p = fromToken?.usdPrice;
|
|
34053
34413
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
34054
34414
|
}, [fromToken]);
|
|
34055
34415
|
const hasFromUsdPrice = fromTokenPriceUSD > 0;
|
|
34056
|
-
const toTokenPriceUSD = (0,
|
|
34416
|
+
const toTokenPriceUSD = (0, import_react49.useMemo)(() => {
|
|
34057
34417
|
const p = toToken?.usdPrice;
|
|
34058
34418
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
34059
34419
|
}, [toToken]);
|
|
34060
34420
|
const hasToUsdPrice = toTokenPriceUSD > 0;
|
|
34061
34421
|
const rawSellNum = parseFloat(amount) || 0;
|
|
34062
|
-
const usdSellNum = (0,
|
|
34422
|
+
const usdSellNum = (0, import_react49.useMemo)(() => {
|
|
34063
34423
|
if (amountInputMode === "usd") return rawSellNum / currencyRate;
|
|
34064
34424
|
return hasFromUsdPrice ? rawSellNum * fromTokenPriceUSD : 0;
|
|
34065
34425
|
}, [
|
|
@@ -34069,7 +34429,7 @@ function SwapMode({
|
|
|
34069
34429
|
hasFromUsdPrice,
|
|
34070
34430
|
fromTokenPriceUSD
|
|
34071
34431
|
]);
|
|
34072
|
-
const tokenSellNum = (0,
|
|
34432
|
+
const tokenSellNum = (0, import_react49.useMemo)(() => {
|
|
34073
34433
|
if (amountInputMode === "usd") {
|
|
34074
34434
|
return hasFromUsdPrice && fromTokenPriceUSD > 0 ? usdSellNum / fromTokenPriceUSD : 0;
|
|
34075
34435
|
}
|
|
@@ -34081,12 +34441,12 @@ function SwapMode({
|
|
|
34081
34441
|
hasFromUsdPrice,
|
|
34082
34442
|
fromTokenPriceUSD
|
|
34083
34443
|
]);
|
|
34084
|
-
const tokenAmountStr = (0,
|
|
34444
|
+
const tokenAmountStr = (0, import_react49.useMemo)(() => {
|
|
34085
34445
|
if (tokenSellNum <= 0) return "";
|
|
34086
34446
|
const decimals = fromToken?.decimals ?? 18;
|
|
34087
34447
|
return truncateDecimal(tokenSellNum, Math.min(decimals, 18));
|
|
34088
34448
|
}, [tokenSellNum, fromToken?.decimals]);
|
|
34089
|
-
const handleCurrencyChange = (0,
|
|
34449
|
+
const handleCurrencyChange = (0, import_react49.useCallback)(
|
|
34090
34450
|
(newCode) => {
|
|
34091
34451
|
if (amountInputMode === "usd" && amount) {
|
|
34092
34452
|
const oldRate = currencyRate;
|
|
@@ -34101,7 +34461,7 @@ function SwapMode({
|
|
|
34101
34461
|
},
|
|
34102
34462
|
[amountInputMode, amount, currencyRate, forexRates, route]
|
|
34103
34463
|
);
|
|
34104
|
-
const handleSelectFromToken = (0,
|
|
34464
|
+
const handleSelectFromToken = (0, import_react49.useCallback)(
|
|
34105
34465
|
(token, chain) => {
|
|
34106
34466
|
setFromToken(token);
|
|
34107
34467
|
setFromChain(chain);
|
|
@@ -34122,7 +34482,7 @@ function SwapMode({
|
|
|
34122
34482
|
},
|
|
34123
34483
|
[route, emitEvent, toToken, toChain, amount]
|
|
34124
34484
|
);
|
|
34125
|
-
const handleSelectToToken = (0,
|
|
34485
|
+
const handleSelectToToken = (0, import_react49.useCallback)(
|
|
34126
34486
|
(token, chain) => {
|
|
34127
34487
|
setToToken(token);
|
|
34128
34488
|
setToChain(chain);
|
|
@@ -34139,7 +34499,7 @@ function SwapMode({
|
|
|
34139
34499
|
},
|
|
34140
34500
|
[route, emitEvent, fromToken, fromChain, amount]
|
|
34141
34501
|
);
|
|
34142
|
-
const handleFlip = (0,
|
|
34502
|
+
const handleFlip = (0, import_react49.useCallback)(() => {
|
|
34143
34503
|
if (lockDestToken) return;
|
|
34144
34504
|
const newFrom = toToken ?? fromToken;
|
|
34145
34505
|
const newFromChain = toChain ?? fromChain;
|
|
@@ -34161,7 +34521,7 @@ function SwapMode({
|
|
|
34161
34521
|
const toChainType = normalizeChainType2(toChain);
|
|
34162
34522
|
const needsDestAddress = !!fromChainType && !!toChainType && fromChainType !== toChainType;
|
|
34163
34523
|
const isValidDestAddress = !needsDestAddress || validateDestAddress(destAddress, toChainType ?? "");
|
|
34164
|
-
const handleReview = (0,
|
|
34524
|
+
const handleReview = (0, import_react49.useCallback)(async () => {
|
|
34165
34525
|
if (!fromToken || !fromChain || !toToken || !toChain || !tokenAmountStr || !walletAddress) {
|
|
34166
34526
|
if (!walletAddress) setStage("connect-wallet");
|
|
34167
34527
|
return;
|
|
@@ -34196,19 +34556,24 @@ function SwapMode({
|
|
|
34196
34556
|
route,
|
|
34197
34557
|
slippage
|
|
34198
34558
|
]);
|
|
34199
|
-
const handleConnectAndReview = (0,
|
|
34559
|
+
const handleConnectAndReview = (0, import_react49.useCallback)(() => {
|
|
34200
34560
|
setStage("connect-wallet");
|
|
34201
34561
|
}, []);
|
|
34202
|
-
const handleWalletConnected = (0,
|
|
34562
|
+
const handleWalletConnected = (0, import_react49.useCallback)(() => {
|
|
34203
34563
|
setStage("home");
|
|
34204
34564
|
}, []);
|
|
34205
|
-
const handleExecute = (0,
|
|
34565
|
+
const handleExecute = (0, import_react49.useCallback)(async () => {
|
|
34206
34566
|
if (!route.data) return;
|
|
34207
34567
|
setStage("processing");
|
|
34208
34568
|
const fromTokenAddress = fromToken?.address ?? fromToken?.address;
|
|
34209
34569
|
const fromTokenDecimals = fromToken?.decimals ?? void 0;
|
|
34570
|
+
let routeToSend = route.data;
|
|
34571
|
+
if (isSerializedSolanaTxRequest(routeToSend.txReq) && latestFetchParamsRef.current) {
|
|
34572
|
+
const fresh = await route.fetch(latestFetchParamsRef.current);
|
|
34573
|
+
if (fresh) routeToSend = fresh;
|
|
34574
|
+
}
|
|
34210
34575
|
await execution.execute(
|
|
34211
|
-
|
|
34576
|
+
routeToSend,
|
|
34212
34577
|
fromTokenAddress,
|
|
34213
34578
|
fromTokenDecimals,
|
|
34214
34579
|
walletAddress ?? void 0,
|
|
@@ -34219,8 +34584,8 @@ function SwapMode({
|
|
|
34219
34584
|
},
|
|
34220
34585
|
() => setStage("error")
|
|
34221
34586
|
);
|
|
34222
|
-
}, [route
|
|
34223
|
-
const handleReset = (0,
|
|
34587
|
+
}, [route, execution, fromToken, walletAddress, maxApproval]);
|
|
34588
|
+
const handleReset = (0, import_react49.useCallback)(() => {
|
|
34224
34589
|
execution.reset();
|
|
34225
34590
|
route.clear();
|
|
34226
34591
|
setAmount("");
|
|
@@ -34230,7 +34595,7 @@ function SwapMode({
|
|
|
34230
34595
|
setStage("home");
|
|
34231
34596
|
reloadWalletTokens();
|
|
34232
34597
|
}, [execution, route, reloadWalletTokens]);
|
|
34233
|
-
const handleSwapBack = (0,
|
|
34598
|
+
const handleSwapBack = (0, import_react49.useCallback)(() => {
|
|
34234
34599
|
const prevFrom = fromToken;
|
|
34235
34600
|
const prevFromChain = fromChain;
|
|
34236
34601
|
setFromToken(toToken);
|
|
@@ -34254,14 +34619,14 @@ function SwapMode({
|
|
|
34254
34619
|
route,
|
|
34255
34620
|
reloadWalletTokens
|
|
34256
34621
|
]);
|
|
34257
|
-
const handleCopyHash = (0,
|
|
34622
|
+
const handleCopyHash = (0, import_react49.useCallback)((hash) => {
|
|
34258
34623
|
if (!navigator?.clipboard?.writeText) return;
|
|
34259
34624
|
void navigator.clipboard.writeText(hash).then(() => {
|
|
34260
34625
|
setCopiedHash(hash);
|
|
34261
34626
|
setTimeout(() => setCopiedHash((v) => v === hash ? null : v), 1500);
|
|
34262
34627
|
});
|
|
34263
34628
|
}, []);
|
|
34264
|
-
const handleToggleDenom = (0,
|
|
34629
|
+
const handleToggleDenom = (0, import_react49.useCallback)(() => {
|
|
34265
34630
|
if (!hasFromUsdPrice) return;
|
|
34266
34631
|
const parsed = parseFloat(amount) || 0;
|
|
34267
34632
|
if (amountInputMode === "usd") {
|
|
@@ -34287,7 +34652,7 @@ function SwapMode({
|
|
|
34287
34652
|
fromToken?.decimals,
|
|
34288
34653
|
route
|
|
34289
34654
|
]);
|
|
34290
|
-
const fromBalance = (0,
|
|
34655
|
+
const fromBalance = (0, import_react49.useMemo)(() => {
|
|
34291
34656
|
const walletToken = fromToken;
|
|
34292
34657
|
if (!walletToken || !("balance" in walletToken)) return null;
|
|
34293
34658
|
const raw = walletToken.balance;
|
|
@@ -34297,7 +34662,7 @@ function SwapMode({
|
|
|
34297
34662
|
return Number.isFinite(n) ? n : null;
|
|
34298
34663
|
}, [fromToken]);
|
|
34299
34664
|
const balanceUsd = fromBalance !== null && hasFromUsdPrice ? fromBalance * fromTokenPriceUSD : null;
|
|
34300
|
-
const estimatedToAmount = (0,
|
|
34665
|
+
const estimatedToAmount = (0, import_react49.useMemo)(() => {
|
|
34301
34666
|
if (tokenSellNum <= 0 || !hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
34302
34667
|
return tokenSellNum * (fromTokenPriceUSD / toTokenPriceUSD);
|
|
34303
34668
|
}, [
|
|
@@ -34307,10 +34672,10 @@ function SwapMode({
|
|
|
34307
34672
|
hasFromUsdPrice,
|
|
34308
34673
|
hasToUsdPrice
|
|
34309
34674
|
]);
|
|
34310
|
-
const backendToUsdStr = (0,
|
|
34675
|
+
const backendToUsdStr = (0, import_react49.useMemo)(() => {
|
|
34311
34676
|
return route.data?.finalExchangeRate?.toAmountMinUSD ?? route.data?.route?.estimate?.toAmountMinUsd ?? route.data?.route?.estimate?.toAmountUsd ?? null;
|
|
34312
34677
|
}, [route.data]);
|
|
34313
|
-
const toAmount = (0,
|
|
34678
|
+
const toAmount = (0, import_react49.useMemo)(() => {
|
|
34314
34679
|
if (backendToUsdStr && toTokenPriceUSD > 0) {
|
|
34315
34680
|
const usd = parseFloat(backendToUsdStr);
|
|
34316
34681
|
if (Number.isFinite(usd) && usd > 0) return usd / toTokenPriceUSD;
|
|
@@ -34336,7 +34701,7 @@ function SwapMode({
|
|
|
34336
34701
|
estimatedToAmount
|
|
34337
34702
|
]);
|
|
34338
34703
|
const fromUsd = usdSellNum;
|
|
34339
|
-
const toUsd = (0,
|
|
34704
|
+
const toUsd = (0, import_react49.useMemo)(() => {
|
|
34340
34705
|
if (backendToUsdStr) {
|
|
34341
34706
|
const n = parseFloat(backendToUsdStr);
|
|
34342
34707
|
if (Number.isFinite(n) && n > 0) return n;
|
|
@@ -34347,12 +34712,12 @@ function SwapMode({
|
|
|
34347
34712
|
const isEstimate = !route.data;
|
|
34348
34713
|
const USD_EPSILON = 1e-3;
|
|
34349
34714
|
const displayToUsd = toUsd > USD_EPSILON ? toUsd : estimatedToAmount !== null && hasToUsdPrice ? estimatedToAmount * toTokenPriceUSD : 0;
|
|
34350
|
-
const priceImpact = (0,
|
|
34715
|
+
const priceImpact = (0, import_react49.useMemo)(() => {
|
|
34351
34716
|
if (!route.data || fromUsd < 0.01 || displayToUsd < 0.01) return null;
|
|
34352
34717
|
const impact = 1 - displayToUsd / fromUsd;
|
|
34353
34718
|
return impact > 1e-3 ? impact : null;
|
|
34354
34719
|
}, [route.data, fromUsd, displayToUsd]);
|
|
34355
|
-
const routePath = (0,
|
|
34720
|
+
const routePath = (0, import_react49.useMemo)(() => {
|
|
34356
34721
|
if (!route.data) return null;
|
|
34357
34722
|
const provider = route.data.route?.provider;
|
|
34358
34723
|
const steps = route.data.route?.steps;
|
|
@@ -34379,19 +34744,19 @@ function SwapMode({
|
|
|
34379
34744
|
return null;
|
|
34380
34745
|
}, [route.data, fromToken?.symbol, toToken?.symbol]);
|
|
34381
34746
|
const isGasSponsored = !!route.data?.sponsorship;
|
|
34382
|
-
const networkCostUsd = (0,
|
|
34747
|
+
const networkCostUsd = (0, import_react49.useMemo)(() => {
|
|
34383
34748
|
const fees = route.data?.route?.estimate?.fees;
|
|
34384
34749
|
if (!fees?.length) return null;
|
|
34385
34750
|
const gasTotal = fees.filter((f) => f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
34386
34751
|
return gasTotal > 0 ? gasTotal : null;
|
|
34387
34752
|
}, [route.data]);
|
|
34388
|
-
const protocolFeeUsd = (0,
|
|
34753
|
+
const protocolFeeUsd = (0, import_react49.useMemo)(() => {
|
|
34389
34754
|
const fees = route.data?.route?.estimate?.fees;
|
|
34390
34755
|
if (!fees?.length) return null;
|
|
34391
34756
|
const total = fees.filter((f) => !f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
34392
34757
|
return total > 0 ? total : null;
|
|
34393
34758
|
}, [route.data]);
|
|
34394
|
-
const exchangeRate = (0,
|
|
34759
|
+
const exchangeRate = (0, import_react49.useMemo)(() => {
|
|
34395
34760
|
if (!hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
34396
34761
|
return toTokenPriceUSD / fromTokenPriceUSD;
|
|
34397
34762
|
}, [fromTokenPriceUSD, toTokenPriceUSD, hasFromUsdPrice, hasToUsdPrice]);
|
|
@@ -34400,13 +34765,13 @@ function SwapMode({
|
|
|
34400
34765
|
const hasAmount = rawSellNum > 0 && (amountInputMode === "token" || hasFromUsdPrice);
|
|
34401
34766
|
const isConnected = walletStatus === "connected" && !!walletAddress;
|
|
34402
34767
|
const canGetQuote = hasTokens && hasAmount && !insufficient && isConnected && (!needsDestAddress || isValidDestAddress);
|
|
34403
|
-
(0,
|
|
34768
|
+
(0, import_react49.useEffect)(() => {
|
|
34404
34769
|
if (!fromToken) return;
|
|
34405
34770
|
if (!hasFromUsdPrice && amountInputMode === "usd") {
|
|
34406
34771
|
setAmountInputMode("token");
|
|
34407
34772
|
}
|
|
34408
34773
|
}, [fromToken, hasFromUsdPrice, amountInputMode]);
|
|
34409
|
-
(0,
|
|
34774
|
+
(0, import_react49.useEffect)(() => {
|
|
34410
34775
|
if (displayToAmount === null) {
|
|
34411
34776
|
prevToAmountRef.current = null;
|
|
34412
34777
|
return;
|
|
@@ -34420,14 +34785,14 @@ function SwapMode({
|
|
|
34420
34785
|
const t = setTimeout(() => setRateUpdated(false), 700);
|
|
34421
34786
|
return () => clearTimeout(t);
|
|
34422
34787
|
}, [displayToAmount]);
|
|
34423
|
-
(0,
|
|
34788
|
+
(0, import_react49.useEffect)(() => {
|
|
34424
34789
|
setDestAddress("");
|
|
34425
34790
|
}, [toChainType]);
|
|
34426
|
-
const fetchRef = (0,
|
|
34427
|
-
(0,
|
|
34791
|
+
const fetchRef = (0, import_react49.useRef)(route.fetch);
|
|
34792
|
+
(0, import_react49.useEffect)(() => {
|
|
34428
34793
|
fetchRef.current = route.fetch;
|
|
34429
34794
|
});
|
|
34430
|
-
(0,
|
|
34795
|
+
(0, import_react49.useEffect)(() => {
|
|
34431
34796
|
if (!canGetQuote || stage !== "home") return;
|
|
34432
34797
|
if (!fromToken || !fromChain || !toToken || !toChain || !walletAddress)
|
|
34433
34798
|
return;
|
|
@@ -34456,7 +34821,7 @@ function SwapMode({
|
|
|
34456
34821
|
destAddress,
|
|
34457
34822
|
slippage
|
|
34458
34823
|
]);
|
|
34459
|
-
(0,
|
|
34824
|
+
(0, import_react49.useEffect)(() => {
|
|
34460
34825
|
if (!canGetQuote || !fromToken || !fromChain || !toToken || !toChain || !walletAddress) {
|
|
34461
34826
|
latestFetchParamsRef.current = null;
|
|
34462
34827
|
return;
|
|
@@ -34483,12 +34848,12 @@ function SwapMode({
|
|
|
34483
34848
|
destAddress,
|
|
34484
34849
|
slippage
|
|
34485
34850
|
]);
|
|
34486
|
-
(0,
|
|
34851
|
+
(0, import_react49.useEffect)(() => {
|
|
34487
34852
|
quoteTimestampRef.current = route.data ? Date.now() : null;
|
|
34488
34853
|
setQuoteAge(0);
|
|
34489
34854
|
}, [route.data]);
|
|
34490
|
-
const msgTimeoutRef = (0,
|
|
34491
|
-
(0,
|
|
34855
|
+
const msgTimeoutRef = (0, import_react49.useRef)(null);
|
|
34856
|
+
(0, import_react49.useEffect)(() => {
|
|
34492
34857
|
if (!route.loading) {
|
|
34493
34858
|
setQuoteLoadingMsgIdx(0);
|
|
34494
34859
|
setQuoteLoadingMsgVisible(true);
|
|
@@ -34506,7 +34871,7 @@ function SwapMode({
|
|
|
34506
34871
|
if (msgTimeoutRef.current !== null) clearTimeout(msgTimeoutRef.current);
|
|
34507
34872
|
};
|
|
34508
34873
|
}, [route.loading]);
|
|
34509
|
-
(0,
|
|
34874
|
+
(0, import_react49.useEffect)(() => {
|
|
34510
34875
|
if (!route.data) return;
|
|
34511
34876
|
const id = setInterval(() => {
|
|
34512
34877
|
const ts = quoteTimestampRef.current;
|
|
@@ -34520,7 +34885,7 @@ function SwapMode({
|
|
|
34520
34885
|
}, 1e3);
|
|
34521
34886
|
return () => clearInterval(id);
|
|
34522
34887
|
}, [route.data]);
|
|
34523
|
-
(0,
|
|
34888
|
+
(0, import_react49.useEffect)(() => {
|
|
34524
34889
|
if (stage !== "review") return;
|
|
34525
34890
|
if (!route.data || !walletAddress) return;
|
|
34526
34891
|
const fromTokenAddress = fromToken?.address;
|
|
@@ -34531,7 +34896,7 @@ function SwapMode({
|
|
|
34531
34896
|
routeResult: route.data
|
|
34532
34897
|
});
|
|
34533
34898
|
}, [stage, route.data, walletAddress, fromToken]);
|
|
34534
|
-
(0,
|
|
34899
|
+
(0, import_react49.useEffect)(() => {
|
|
34535
34900
|
if (!showSettings) {
|
|
34536
34901
|
setShowCurrencyDropdown(false);
|
|
34537
34902
|
return;
|
|
@@ -34544,7 +34909,7 @@ function SwapMode({
|
|
|
34544
34909
|
document.addEventListener("mousedown", handler);
|
|
34545
34910
|
return () => document.removeEventListener("mousedown", handler);
|
|
34546
34911
|
}, [showSettings]);
|
|
34547
|
-
(0,
|
|
34912
|
+
(0, import_react49.useEffect)(() => {
|
|
34548
34913
|
if (!showCurrencyDropdown) return;
|
|
34549
34914
|
const handler = (e2) => {
|
|
34550
34915
|
if (currencyDropdownRef.current && !currencyDropdownRef.current.contains(e2.target)) {
|
|
@@ -35086,7 +35451,7 @@ function SwapMode({
|
|
|
35086
35451
|
timeStyle: "short"
|
|
35087
35452
|
}) ?? null;
|
|
35088
35453
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(WidgetContainer, { theme: resolvedTheme, style, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { style: { position: "relative", overflow: "hidden" }, children: [
|
|
35089
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
35454
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_react49.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ConfettiEffect3, { isActive: true, pieceCount: 60, clearDelay: 4e3 }) }),
|
|
35090
35455
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { style: { padding: `${spacing[6]} ${spacing[6]} 0` }, children: [
|
|
35091
35456
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
35092
35457
|
"div",
|
|
@@ -37694,8 +38059,8 @@ function ReviewDetailRow({
|
|
|
37694
38059
|
value,
|
|
37695
38060
|
tooltip
|
|
37696
38061
|
}) {
|
|
37697
|
-
const iconRef = (0,
|
|
37698
|
-
const [tipPos, setTipPos] = (0,
|
|
38062
|
+
const iconRef = (0, import_react49.useRef)(null);
|
|
38063
|
+
const [tipPos, setTipPos] = (0, import_react49.useState)(null);
|
|
37699
38064
|
const handleMouseEnter = () => {
|
|
37700
38065
|
if (!tooltip || !iconRef.current) return;
|
|
37701
38066
|
const r = iconRef.current.getBoundingClientRect();
|
|
@@ -37974,17 +38339,18 @@ function ProcessingStepLine({ done }) {
|
|
|
37974
38339
|
}
|
|
37975
38340
|
);
|
|
37976
38341
|
}
|
|
37977
|
-
var
|
|
38342
|
+
var import_react49, import_react_dom, import_jsx_runtime57, ConfettiEffect3, QUOTE_TTL, QUOTE_LOADING_MESSAGES, PERCENT_OPTIONS;
|
|
37978
38343
|
var init_SwapMode = __esm({
|
|
37979
38344
|
"src/modes/swap/SwapMode.tsx"() {
|
|
37980
38345
|
"use strict";
|
|
37981
|
-
|
|
38346
|
+
import_react49 = require("react");
|
|
37982
38347
|
import_react_dom = __toESM(require("react-dom"), 1);
|
|
37983
38348
|
init_styles();
|
|
37984
38349
|
init_utils();
|
|
37985
38350
|
init_mapError();
|
|
37986
38351
|
init_components();
|
|
37987
38352
|
init_registryClient();
|
|
38353
|
+
init_routes();
|
|
37988
38354
|
init_useThemePreference();
|
|
37989
38355
|
init_useWalletSessionState();
|
|
37990
38356
|
init_useWalletTokenState();
|
|
@@ -38000,7 +38366,7 @@ var init_SwapMode = __esm({
|
|
|
38000
38366
|
init_SwapWalletSelector();
|
|
38001
38367
|
init_currency();
|
|
38002
38368
|
import_jsx_runtime57 = require("react/jsx-runtime");
|
|
38003
|
-
ConfettiEffect3 = (0,
|
|
38369
|
+
ConfettiEffect3 = (0, import_react49.lazy)(
|
|
38004
38370
|
() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports))
|
|
38005
38371
|
);
|
|
38006
38372
|
QUOTE_TTL = 60;
|
|
@@ -38041,7 +38407,7 @@ function WidgetContent({
|
|
|
38041
38407
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
38042
38408
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
38043
38409
|
useWalletExternalDisconnect(() => setCurrentStep("home"));
|
|
38044
|
-
(0,
|
|
38410
|
+
(0, import_react50.useEffect)(() => {
|
|
38045
38411
|
const state = {
|
|
38046
38412
|
currentStep,
|
|
38047
38413
|
amount,
|
|
@@ -38084,8 +38450,8 @@ function WidgetInner({
|
|
|
38084
38450
|
const { transactionStatus } = useDepositTransaction();
|
|
38085
38451
|
const { resolvedTheme } = useDepositUi();
|
|
38086
38452
|
const { status, revalidate, errors } = useTrustware();
|
|
38087
|
-
const [showConfirmDialog, setShowConfirmDialog] = (0,
|
|
38088
|
-
const handleCloseRequest = (0,
|
|
38453
|
+
const [showConfirmDialog, setShowConfirmDialog] = (0, import_react50.useState)(false);
|
|
38454
|
+
const handleCloseRequest = (0, import_react50.useCallback)(() => {
|
|
38089
38455
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
38090
38456
|
setShowConfirmDialog(true);
|
|
38091
38457
|
} else {
|
|
@@ -38096,20 +38462,20 @@ function WidgetInner({
|
|
|
38096
38462
|
onClose?.();
|
|
38097
38463
|
}
|
|
38098
38464
|
}, [transactionStatus, onClose, resetState]);
|
|
38099
|
-
(0,
|
|
38465
|
+
(0, import_react50.useEffect)(() => {
|
|
38100
38466
|
closeRequestRef.current = handleCloseRequest;
|
|
38101
38467
|
}, [handleCloseRequest, closeRequestRef]);
|
|
38102
|
-
const handleConfirmClose = (0,
|
|
38468
|
+
const handleConfirmClose = (0, import_react50.useCallback)(() => {
|
|
38103
38469
|
setShowConfirmDialog(false);
|
|
38104
38470
|
onClose?.();
|
|
38105
38471
|
}, [onClose]);
|
|
38106
|
-
const handleCancelClose = (0,
|
|
38472
|
+
const handleCancelClose = (0, import_react50.useCallback)(() => {
|
|
38107
38473
|
setShowConfirmDialog(false);
|
|
38108
38474
|
}, []);
|
|
38109
38475
|
const effectiveTheme = resolvedTheme;
|
|
38110
38476
|
const isRefreshing = status === "initializing";
|
|
38111
38477
|
const initBlocked = status === "error";
|
|
38112
|
-
const handleRefresh = (0,
|
|
38478
|
+
const handleRefresh = (0, import_react50.useCallback)(() => {
|
|
38113
38479
|
revalidate?.();
|
|
38114
38480
|
}, [revalidate]);
|
|
38115
38481
|
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
|
|
@@ -38143,11 +38509,11 @@ function WidgetInner({
|
|
|
38143
38509
|
)
|
|
38144
38510
|
] });
|
|
38145
38511
|
}
|
|
38146
|
-
var
|
|
38512
|
+
var import_react50, import_jsx_runtime58, widgetContentContainerStyle, themeToggleContainerStyle, TrustwareWidgetV2;
|
|
38147
38513
|
var init_TrustwareWidgetV2 = __esm({
|
|
38148
38514
|
"src/widget/TrustwareWidgetV2.tsx"() {
|
|
38149
38515
|
"use strict";
|
|
38150
|
-
|
|
38516
|
+
import_react50 = require("react");
|
|
38151
38517
|
init_utils();
|
|
38152
38518
|
init_styles();
|
|
38153
38519
|
init_DepositContext();
|
|
@@ -38173,7 +38539,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38173
38539
|
right: spacing[3],
|
|
38174
38540
|
zIndex: 12
|
|
38175
38541
|
};
|
|
38176
|
-
TrustwareWidgetV2 = (0,
|
|
38542
|
+
TrustwareWidgetV2 = (0, import_react50.forwardRef)(function TrustwareWidgetV22({
|
|
38177
38543
|
theme,
|
|
38178
38544
|
style,
|
|
38179
38545
|
initialStep = "home",
|
|
@@ -38182,15 +38548,15 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38182
38548
|
onOpen,
|
|
38183
38549
|
showThemeToggle = true
|
|
38184
38550
|
}, ref) {
|
|
38185
|
-
const [isOpen, setIsOpen] = (0,
|
|
38186
|
-
const closeRequestRef = (0,
|
|
38551
|
+
const [isOpen, setIsOpen] = (0, import_react50.useState)(defaultOpen);
|
|
38552
|
+
const closeRequestRef = (0, import_react50.useRef)(null);
|
|
38187
38553
|
const config = useTrustwareConfig();
|
|
38188
38554
|
const effectiveInitialStep = initialStep;
|
|
38189
|
-
const open = (0,
|
|
38555
|
+
const open = (0, import_react50.useCallback)(() => {
|
|
38190
38556
|
setIsOpen(true);
|
|
38191
38557
|
onOpen?.();
|
|
38192
38558
|
}, [onOpen]);
|
|
38193
|
-
const close = (0,
|
|
38559
|
+
const close = (0, import_react50.useCallback)(() => {
|
|
38194
38560
|
if (closeRequestRef.current) {
|
|
38195
38561
|
closeRequestRef.current();
|
|
38196
38562
|
} else {
|
|
@@ -38198,11 +38564,11 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
38198
38564
|
onClose?.();
|
|
38199
38565
|
}
|
|
38200
38566
|
}, [onClose]);
|
|
38201
|
-
const handleClose = (0,
|
|
38567
|
+
const handleClose = (0, import_react50.useCallback)(() => {
|
|
38202
38568
|
setIsOpen(false);
|
|
38203
38569
|
onClose?.();
|
|
38204
38570
|
}, [onClose]);
|
|
38205
|
-
(0,
|
|
38571
|
+
(0, import_react50.useImperativeHandle)(
|
|
38206
38572
|
ref,
|
|
38207
38573
|
() => ({
|
|
38208
38574
|
open,
|