@trustware/sdk-staging 1.1.8-staging.4 → 1.1.8-staging.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-DrWK6PT3.d.ts → core-BPYlJrNb.d.ts} +1 -1
- package/dist/{core-B9PJ0mUX.d.cts → core-CJMf4PvV.d.cts} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-Dn7A-Svt.d.cts → detect-CWNTV5Wq.d.cts} +1 -1
- package/dist/{detect-BLE9aPwJ.d.ts → detect-CaQQECVe.d.ts} +1 -1
- package/dist/index.cjs +643 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +670 -196
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-C85ARoxD.d.cts → manager-DHCXknCG.d.cts} +8 -1
- package/dist/{manager-PBjHXKjh.d.ts → manager-Dtmjibzl.d.ts} +8 -1
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.mjs +1 -1
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +144 -3
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +3 -3
- package/dist/wallet.d.ts +3 -3
- package/dist/wallet.mjs +144 -3
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +643 -169
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +670 -196
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -571,7 +571,7 @@ var init_constants = __esm({
|
|
|
571
571
|
"src/constants.ts"() {
|
|
572
572
|
"use strict";
|
|
573
573
|
SDK_NAME = "@trustware/sdk";
|
|
574
|
-
SDK_VERSION = "1.1.8-staging.
|
|
574
|
+
SDK_VERSION = "1.1.8-staging.6";
|
|
575
575
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
576
576
|
GTM_ID = "GTM-TZDGNCXB";
|
|
577
577
|
API_PREFIX = "/api";
|
|
@@ -4322,6 +4322,134 @@ var init_sdkRpc = __esm({
|
|
|
4322
4322
|
});
|
|
4323
4323
|
|
|
4324
4324
|
// src/wallets/solana.ts
|
|
4325
|
+
function encodeBase58(bytes) {
|
|
4326
|
+
const digits = [0];
|
|
4327
|
+
for (const byte of bytes) {
|
|
4328
|
+
let carry = byte;
|
|
4329
|
+
for (let i = 0; i < digits.length; i++) {
|
|
4330
|
+
carry += digits[i] << 8;
|
|
4331
|
+
digits[i] = carry % 58;
|
|
4332
|
+
carry = carry / 58 | 0;
|
|
4333
|
+
}
|
|
4334
|
+
while (carry > 0) {
|
|
4335
|
+
digits.push(carry % 58);
|
|
4336
|
+
carry = carry / 58 | 0;
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
let result = "";
|
|
4340
|
+
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
|
|
4341
|
+
result += "1";
|
|
4342
|
+
}
|
|
4343
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
4344
|
+
result += BASE58_ALPHABET[digits[i]];
|
|
4345
|
+
}
|
|
4346
|
+
return result;
|
|
4347
|
+
}
|
|
4348
|
+
function collectWalletStandardWallets() {
|
|
4349
|
+
if (typeof window === "undefined") return [];
|
|
4350
|
+
const collected = [];
|
|
4351
|
+
const api = {
|
|
4352
|
+
register(...wallets) {
|
|
4353
|
+
collected.push(...wallets);
|
|
4354
|
+
return () => {
|
|
4355
|
+
};
|
|
4356
|
+
}
|
|
4357
|
+
};
|
|
4358
|
+
try {
|
|
4359
|
+
window.dispatchEvent(
|
|
4360
|
+
Object.assign(
|
|
4361
|
+
new Event("wallet-standard:app-ready", { bubbles: false }),
|
|
4362
|
+
{
|
|
4363
|
+
detail: api
|
|
4364
|
+
}
|
|
4365
|
+
)
|
|
4366
|
+
);
|
|
4367
|
+
} catch {
|
|
4368
|
+
}
|
|
4369
|
+
return collected;
|
|
4370
|
+
}
|
|
4371
|
+
function walletStandardToSolanaProvider(wallet) {
|
|
4372
|
+
let currentAccount = wallet.accounts[0] ?? null;
|
|
4373
|
+
const provider = {
|
|
4374
|
+
get isConnected() {
|
|
4375
|
+
return !!currentAccount;
|
|
4376
|
+
},
|
|
4377
|
+
get publicKey() {
|
|
4378
|
+
if (!currentAccount) return void 0;
|
|
4379
|
+
const addr = currentAccount.address;
|
|
4380
|
+
return { toString: () => addr };
|
|
4381
|
+
},
|
|
4382
|
+
async connect() {
|
|
4383
|
+
const feature = wallet.features["standard:connect"];
|
|
4384
|
+
if (!feature?.connect)
|
|
4385
|
+
throw new Error("Wallet Standard connect not available");
|
|
4386
|
+
const result = await feature.connect({ silent: false });
|
|
4387
|
+
currentAccount = result.accounts[0] ?? null;
|
|
4388
|
+
if (!currentAccount)
|
|
4389
|
+
throw new Error("No Solana account returned from MetaMask");
|
|
4390
|
+
return { publicKey: { toString: () => currentAccount.address } };
|
|
4391
|
+
},
|
|
4392
|
+
async disconnect() {
|
|
4393
|
+
const feature = wallet.features["standard:disconnect"];
|
|
4394
|
+
await feature?.disconnect?.();
|
|
4395
|
+
currentAccount = null;
|
|
4396
|
+
},
|
|
4397
|
+
async signAndSendTransaction(transaction, options) {
|
|
4398
|
+
const feature = wallet.features["solana:signAndSendTransaction"];
|
|
4399
|
+
if (!feature?.signAndSendTransaction || !currentAccount) {
|
|
4400
|
+
throw new Error("signAndSendTransaction not available");
|
|
4401
|
+
}
|
|
4402
|
+
const txBytes = transaction.serialize();
|
|
4403
|
+
const results = await feature.signAndSendTransaction({
|
|
4404
|
+
account: currentAccount,
|
|
4405
|
+
transaction: txBytes,
|
|
4406
|
+
chain: SOLANA_MAINNET_CHAIN,
|
|
4407
|
+
options
|
|
4408
|
+
});
|
|
4409
|
+
const sig = results[0]?.signature;
|
|
4410
|
+
if (!sig) throw new Error("No signature returned");
|
|
4411
|
+
return typeof sig === "string" ? sig : encodeBase58(sig);
|
|
4412
|
+
},
|
|
4413
|
+
async signTransaction(transaction) {
|
|
4414
|
+
const feature = wallet.features["solana:signTransaction"];
|
|
4415
|
+
if (!feature?.signTransaction || !currentAccount) {
|
|
4416
|
+
throw new Error("signTransaction not available");
|
|
4417
|
+
}
|
|
4418
|
+
const txBytes = transaction.serialize();
|
|
4419
|
+
const results = await feature.signTransaction({
|
|
4420
|
+
account: currentAccount,
|
|
4421
|
+
transaction: txBytes,
|
|
4422
|
+
chain: SOLANA_MAINNET_CHAIN
|
|
4423
|
+
});
|
|
4424
|
+
const signed = results[0]?.signedTransaction;
|
|
4425
|
+
if (!signed) throw new Error("No signed transaction returned");
|
|
4426
|
+
return { serialize: () => signed };
|
|
4427
|
+
},
|
|
4428
|
+
on() {
|
|
4429
|
+
},
|
|
4430
|
+
off() {
|
|
4431
|
+
},
|
|
4432
|
+
removeListener() {
|
|
4433
|
+
}
|
|
4434
|
+
};
|
|
4435
|
+
return provider;
|
|
4436
|
+
}
|
|
4437
|
+
function detectMetaMaskSolanaWallet(wallets) {
|
|
4438
|
+
const meta = wallets.find((w) => w.id === "metamask-solana");
|
|
4439
|
+
if (!meta) return [];
|
|
4440
|
+
const standardWallets = collectWalletStandardWallets();
|
|
4441
|
+
const mmWallet = standardWallets.find(
|
|
4442
|
+
(w) => w.name.toLowerCase().includes("metamask") && w.chains.some((c) => c.startsWith("solana:"))
|
|
4443
|
+
);
|
|
4444
|
+
if (!mmWallet) return [];
|
|
4445
|
+
return [
|
|
4446
|
+
{
|
|
4447
|
+
meta,
|
|
4448
|
+
provider: walletStandardToSolanaProvider(mmWallet),
|
|
4449
|
+
via: "solana-window"
|
|
4450
|
+
}
|
|
4451
|
+
];
|
|
4452
|
+
}
|
|
4325
4453
|
function getPublicKeyString(provider) {
|
|
4326
4454
|
const publicKey = provider?.publicKey;
|
|
4327
4455
|
if (!publicKey) return null;
|
|
@@ -4383,12 +4511,13 @@ function getSolanaProviders() {
|
|
|
4383
4511
|
}
|
|
4384
4512
|
function detectSolanaWallets(wallets) {
|
|
4385
4513
|
const providers = getSolanaProviders();
|
|
4386
|
-
|
|
4514
|
+
const windowDetected = SOLANA_WALLET_IDS.flatMap((walletId) => {
|
|
4387
4515
|
const provider = providers[walletId];
|
|
4388
4516
|
const meta = wallets.find((item) => item.id === walletId);
|
|
4389
4517
|
if (!provider || !meta) return [];
|
|
4390
4518
|
return [{ meta, provider, via: "solana-window" }];
|
|
4391
4519
|
});
|
|
4520
|
+
return [...windowDetected, ...detectMetaMaskSolanaWallet(wallets)];
|
|
4392
4521
|
}
|
|
4393
4522
|
function bindSolanaProviderEvents(provider, handlers) {
|
|
4394
4523
|
const onConnect = () => handlers.onConnect?.();
|
|
@@ -4453,7 +4582,7 @@ function toSolanaWalletInterface(provider) {
|
|
|
4453
4582
|
}
|
|
4454
4583
|
};
|
|
4455
4584
|
}
|
|
4456
|
-
var SOLANA_WALLET_IDS;
|
|
4585
|
+
var SOLANA_WALLET_IDS, SOLANA_MAINNET_CHAIN, BASE58_ALPHABET;
|
|
4457
4586
|
var init_solana = __esm({
|
|
4458
4587
|
"src/wallets/solana.ts"() {
|
|
4459
4588
|
"use strict";
|
|
@@ -4463,6 +4592,8 @@ var init_solana = __esm({
|
|
|
4463
4592
|
"solflare",
|
|
4464
4593
|
"backpack"
|
|
4465
4594
|
];
|
|
4595
|
+
SOLANA_MAINNET_CHAIN = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
4596
|
+
BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
4466
4597
|
}
|
|
4467
4598
|
});
|
|
4468
4599
|
|
|
@@ -4636,6 +4767,15 @@ var init_metadata = __esm({
|
|
|
4636
4767
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
4637
4768
|
deepLink: (url) => `phantom://browse/${encodeURIComponent(url)}`
|
|
4638
4769
|
},
|
|
4770
|
+
{
|
|
4771
|
+
id: "metamask-solana",
|
|
4772
|
+
name: "MetaMask (Solana)",
|
|
4773
|
+
category: "injected",
|
|
4774
|
+
ecosystem: "solana",
|
|
4775
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
4776
|
+
emoji: "\u{1F98A}",
|
|
4777
|
+
homepage: "https://metamask.io/"
|
|
4778
|
+
},
|
|
4639
4779
|
{
|
|
4640
4780
|
id: "solflare",
|
|
4641
4781
|
name: "Solflare",
|
|
@@ -6630,7 +6770,9 @@ function applyWalletTokenState({
|
|
|
6630
6770
|
const selectedTokenStillExists = selectedToken && sortedTokens.some(
|
|
6631
6771
|
(token) => normalizeChainKey2(token.chainId) === normalizeChainKey2(selectedToken.chainId) && token.address === selectedToken.address
|
|
6632
6772
|
);
|
|
6633
|
-
const nextSelectedToken = selectedTokenStillExists && selectedToken ?
|
|
6773
|
+
const nextSelectedToken = selectedTokenStillExists && selectedToken ? sortedTokens.find(
|
|
6774
|
+
(token) => normalizeChainKey2(token.chainId) === normalizeChainKey2(selectedToken.chainId) && token.address === selectedToken.address
|
|
6775
|
+
) ?? selectedToken : sortedTokens.find((token) => Number(token.balance) > 0) ?? null;
|
|
6634
6776
|
setSelectedToken(nextSelectedToken);
|
|
6635
6777
|
if (nextSelectedToken && (!selectedChain || normalizeChainKey2(selectedChain.chainId) !== normalizeChainKey2(
|
|
6636
6778
|
hasChainData(nextSelectedToken) ? nextSelectedToken.chainData?.chainId ?? null : nextSelectedToken.chainId
|
|
@@ -13418,10 +13560,12 @@ function useDepositAmountModel({
|
|
|
13418
13560
|
]);
|
|
13419
13561
|
const amountWei = amountValidationError ? 0n : amountComputation.fromAmountWei ?? 0n;
|
|
13420
13562
|
const parsedAmount = parseFloat(fixedFromAmountString ?? amount) || 0;
|
|
13421
|
-
const maxTokenAmount = useMemo14(
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13563
|
+
const maxTokenAmount = useMemo14(() => {
|
|
13564
|
+
const cap = Math.min(normalizedTokenBalance, 1e4);
|
|
13565
|
+
const token = selectedToken;
|
|
13566
|
+
const isSolNative = token?.category === "native" && typeof token.chain_key === "string" && token.chain_key.toLowerCase().includes("solana");
|
|
13567
|
+
return isSolNative ? Math.max(0, cap - 0.01) : cap;
|
|
13568
|
+
}, [normalizedTokenBalance, selectedToken]);
|
|
13425
13569
|
const maxUsdAmount = useMemo14(() => {
|
|
13426
13570
|
if (!hasUsdPrice) return void 0;
|
|
13427
13571
|
return Math.min(maxTokenAmount * tokenPriceUSD, 1e4);
|
|
@@ -30367,7 +30511,8 @@ function sleep3(ms) {
|
|
|
30367
30511
|
}
|
|
30368
30512
|
function isUserRejection(err) {
|
|
30369
30513
|
if (!err) return false;
|
|
30370
|
-
const
|
|
30514
|
+
const e2 = err;
|
|
30515
|
+
const code = e2?.code ?? e2?.data?.code;
|
|
30371
30516
|
if (code === 4001) return true;
|
|
30372
30517
|
const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
|
|
30373
30518
|
return msg.includes("user rejected") || msg.includes("user denied") || msg.includes("cancelled");
|
|
@@ -30516,6 +30661,26 @@ function useSwapExecution(fromChain) {
|
|
|
30516
30661
|
);
|
|
30517
30662
|
const canUseSA = !!routeResult.sponsorship && Date.now() >= saFailedUntilRef.current && wallet?.ecosystem === "evm" && wallet.type === "eip1193" && !isNative && !!walletAddress && Number.isFinite(numericChainId);
|
|
30518
30663
|
if (canUseSA) {
|
|
30664
|
+
if (numericChainId && wallet) {
|
|
30665
|
+
try {
|
|
30666
|
+
const currentChainId = await wallet.getChainId();
|
|
30667
|
+
if (currentChainId !== numericChainId) {
|
|
30668
|
+
await wallet.switchChain(numericChainId);
|
|
30669
|
+
}
|
|
30670
|
+
} catch (switchErr) {
|
|
30671
|
+
if (isUserRejection(switchErr)) {
|
|
30672
|
+
const msg = mapTxError(switchErr);
|
|
30673
|
+
setState((p) => ({
|
|
30674
|
+
...p,
|
|
30675
|
+
isSubmitting: false,
|
|
30676
|
+
txStatus: "error",
|
|
30677
|
+
errorMessage: msg
|
|
30678
|
+
}));
|
|
30679
|
+
onError(msg);
|
|
30680
|
+
return;
|
|
30681
|
+
}
|
|
30682
|
+
}
|
|
30683
|
+
}
|
|
30519
30684
|
try {
|
|
30520
30685
|
const mod = await Promise.resolve().then(() => (init_smart_account2(), smart_account_exports));
|
|
30521
30686
|
const result = await mod.sendRouteAsUserOperation({
|
|
@@ -31053,8 +31218,8 @@ var init_SwapTokenSelect = __esm({
|
|
|
31053
31218
|
});
|
|
31054
31219
|
|
|
31055
31220
|
// src/modes/swap/components/SwapWalletSelector.tsx
|
|
31056
|
-
import { useEffect as useEffect29, useRef as useRef16, useState as useState27 } from "react";
|
|
31057
|
-
import { jsx as jsx55, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
31221
|
+
import { useEffect as useEffect29, useMemo as useMemo25, useRef as useRef16, useState as useState27 } from "react";
|
|
31222
|
+
import { Fragment as Fragment7, jsx as jsx55, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
31058
31223
|
function SwapWalletSelector({
|
|
31059
31224
|
walletStatus,
|
|
31060
31225
|
walletAddress,
|
|
@@ -31062,11 +31227,18 @@ function SwapWalletSelector({
|
|
|
31062
31227
|
onBack
|
|
31063
31228
|
}) {
|
|
31064
31229
|
const { detected } = useWalletDetection();
|
|
31230
|
+
const {
|
|
31231
|
+
isConnected: managerConnected,
|
|
31232
|
+
walletMetaId,
|
|
31233
|
+
connectedVia,
|
|
31234
|
+
disconnect
|
|
31235
|
+
} = useWalletInfo();
|
|
31236
|
+
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
31237
|
+
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
31238
|
+
const [wcConnecting, setWcConnecting] = useState27(false);
|
|
31065
31239
|
const [connectingId, setConnectingId] = useState27(null);
|
|
31066
|
-
const [connectedWalletId, setConnectedWalletId] = useState27(
|
|
31067
|
-
null
|
|
31068
|
-
);
|
|
31069
31240
|
const [timerExpired, setTimerExpired] = useState27(false);
|
|
31241
|
+
const [selectedNamespace, setSelectedNamespace] = useState27("evm");
|
|
31070
31242
|
const prevStatusRef = useRef16(walletStatus);
|
|
31071
31243
|
useEffect29(() => {
|
|
31072
31244
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
@@ -31081,16 +31253,48 @@ function SwapWalletSelector({
|
|
|
31081
31253
|
prevStatusRef.current = walletStatus;
|
|
31082
31254
|
}
|
|
31083
31255
|
}, [walletStatus]);
|
|
31256
|
+
const filteredWallets = useMemo25(
|
|
31257
|
+
() => detected.filter(
|
|
31258
|
+
(w) => (w.meta?.ecosystem ?? "").toLowerCase() === selectedNamespace
|
|
31259
|
+
),
|
|
31260
|
+
[detected, selectedNamespace]
|
|
31261
|
+
);
|
|
31262
|
+
const isDetecting = detected.length === 0 && !timerExpired;
|
|
31263
|
+
const handleDisconnect = () => {
|
|
31264
|
+
void disconnect();
|
|
31265
|
+
};
|
|
31266
|
+
const handleWalletConnect = async () => {
|
|
31267
|
+
if (wcConnecting) return;
|
|
31268
|
+
if (connectedVia === "walletconnect" && managerConnected) {
|
|
31269
|
+
onBack();
|
|
31270
|
+
return;
|
|
31271
|
+
}
|
|
31272
|
+
setWcConnecting(true);
|
|
31273
|
+
try {
|
|
31274
|
+
const { error } = await connectWC();
|
|
31275
|
+
if (error) {
|
|
31276
|
+
toast.error("WalletConnect Failed", error);
|
|
31277
|
+
}
|
|
31278
|
+
} catch (err) {
|
|
31279
|
+
const msg = err instanceof Error ? err.message : "WalletConnect failed";
|
|
31280
|
+
toast.error("WalletConnect Failed", msg);
|
|
31281
|
+
} finally {
|
|
31282
|
+
setWcConnecting(false);
|
|
31283
|
+
}
|
|
31284
|
+
};
|
|
31084
31285
|
const handleClick = async (wallet) => {
|
|
31085
31286
|
if (walletStatus === "connecting") return;
|
|
31086
31287
|
if (wallet.meta.id === "walletconnect" || wallet.via === "walletconnect") {
|
|
31087
31288
|
toast.error("Not Available", "WalletConnect is not currently available.");
|
|
31088
31289
|
return;
|
|
31089
31290
|
}
|
|
31291
|
+
if (managerConnected && walletMetaId === wallet.meta.id) {
|
|
31292
|
+
onBack();
|
|
31293
|
+
return;
|
|
31294
|
+
}
|
|
31090
31295
|
setConnectingId(wallet.meta.id);
|
|
31091
31296
|
try {
|
|
31092
31297
|
await connectWallet(wallet);
|
|
31093
|
-
setConnectedWalletId(wallet.meta.id);
|
|
31094
31298
|
} catch (err) {
|
|
31095
31299
|
setConnectingId(null);
|
|
31096
31300
|
const msg = err instanceof Error ? err.message : "Failed to connect wallet";
|
|
@@ -31104,7 +31308,10 @@ function SwapWalletSelector({
|
|
|
31104
31308
|
}
|
|
31105
31309
|
}
|
|
31106
31310
|
};
|
|
31107
|
-
const
|
|
31311
|
+
const tabs = [
|
|
31312
|
+
{ id: "evm", label: "EVM" },
|
|
31313
|
+
{ id: "solana", label: "Solana" }
|
|
31314
|
+
];
|
|
31108
31315
|
return /* @__PURE__ */ jsxs44("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
31109
31316
|
/* @__PURE__ */ jsxs44(
|
|
31110
31317
|
"div",
|
|
@@ -31161,134 +31368,348 @@ function SwapWalletSelector({
|
|
|
31161
31368
|
fontSize: fontSize.lg,
|
|
31162
31369
|
fontWeight: fontWeight.semibold,
|
|
31163
31370
|
color: colors.foreground,
|
|
31164
|
-
textAlign: "center"
|
|
31165
|
-
marginRight: "1.75rem"
|
|
31371
|
+
textAlign: "center"
|
|
31166
31372
|
},
|
|
31167
31373
|
children: "Connect Wallet"
|
|
31168
31374
|
}
|
|
31169
|
-
)
|
|
31170
|
-
|
|
31171
|
-
}
|
|
31172
|
-
),
|
|
31173
|
-
/* @__PURE__ */ jsx55("div", { style: { padding: spacing[4] }, children: isDetecting ? /* @__PURE__ */ jsxs44(
|
|
31174
|
-
"div",
|
|
31175
|
-
{
|
|
31176
|
-
style: {
|
|
31177
|
-
display: "flex",
|
|
31178
|
-
flexDirection: "column",
|
|
31179
|
-
gap: spacing[3]
|
|
31180
|
-
},
|
|
31181
|
-
children: [
|
|
31182
|
-
[1, 2].map((i) => /* @__PURE__ */ jsxs44(
|
|
31375
|
+
),
|
|
31376
|
+
/* @__PURE__ */ jsxs44(
|
|
31183
31377
|
"div",
|
|
31184
31378
|
{
|
|
31185
31379
|
style: {
|
|
31380
|
+
position: "relative",
|
|
31186
31381
|
display: "flex",
|
|
31187
31382
|
alignItems: "center",
|
|
31188
|
-
|
|
31189
|
-
|
|
31190
|
-
|
|
31191
|
-
|
|
31192
|
-
animation: "tw-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
31383
|
+
borderRadius: "9999px",
|
|
31384
|
+
background: colors.background,
|
|
31385
|
+
border: `1px solid ${colors.mutedForeground}`,
|
|
31386
|
+
padding: "3px"
|
|
31193
31387
|
},
|
|
31194
31388
|
children: [
|
|
31195
31389
|
/* @__PURE__ */ jsx55(
|
|
31196
31390
|
"div",
|
|
31197
31391
|
{
|
|
31198
31392
|
style: {
|
|
31199
|
-
|
|
31200
|
-
|
|
31201
|
-
|
|
31202
|
-
|
|
31393
|
+
position: "absolute",
|
|
31394
|
+
top: 3,
|
|
31395
|
+
bottom: 3,
|
|
31396
|
+
width: "calc(50% - 3px)",
|
|
31397
|
+
borderRadius: "9999px",
|
|
31398
|
+
background: `linear-gradient(to bottom, ${colors.zinc[100]}, ${colors.zinc[200]})`,
|
|
31399
|
+
border: `1px solid ${colors.mutedForeground}`,
|
|
31400
|
+
transition: "transform 300ms ease-out",
|
|
31401
|
+
transform: selectedNamespace === "evm" ? "translateX(0)" : "translateX(100%)"
|
|
31203
31402
|
}
|
|
31204
31403
|
}
|
|
31205
31404
|
),
|
|
31206
|
-
/* @__PURE__ */ jsx55(
|
|
31207
|
-
"
|
|
31405
|
+
tabs.map((t) => /* @__PURE__ */ jsx55(
|
|
31406
|
+
"button",
|
|
31208
31407
|
{
|
|
31408
|
+
onClick: () => setSelectedNamespace(t.id),
|
|
31209
31409
|
style: {
|
|
31210
|
-
|
|
31211
|
-
|
|
31212
|
-
|
|
31213
|
-
|
|
31214
|
-
|
|
31215
|
-
|
|
31216
|
-
|
|
31410
|
+
position: "relative",
|
|
31411
|
+
zIndex: 10,
|
|
31412
|
+
padding: "4px 11px",
|
|
31413
|
+
fontSize: "10px",
|
|
31414
|
+
outline: "none",
|
|
31415
|
+
fontWeight: 600,
|
|
31416
|
+
borderRadius: "9999px",
|
|
31417
|
+
background: "transparent",
|
|
31418
|
+
border: "none",
|
|
31419
|
+
cursor: "pointer",
|
|
31420
|
+
transition: "color 200ms",
|
|
31421
|
+
color: selectedNamespace === t.id ? colors.black : colors.mutedForeground
|
|
31422
|
+
},
|
|
31423
|
+
children: t.label
|
|
31424
|
+
},
|
|
31425
|
+
t.id
|
|
31426
|
+
))
|
|
31217
31427
|
]
|
|
31218
|
-
},
|
|
31219
|
-
i
|
|
31220
|
-
)),
|
|
31221
|
-
/* @__PURE__ */ jsx55(
|
|
31222
|
-
"p",
|
|
31223
|
-
{
|
|
31224
|
-
style: {
|
|
31225
|
-
textAlign: "center",
|
|
31226
|
-
fontSize: fontSize.sm,
|
|
31227
|
-
color: colors.mutedForeground,
|
|
31228
|
-
marginTop: spacing[4]
|
|
31229
|
-
},
|
|
31230
|
-
children: "Detecting wallets..."
|
|
31231
31428
|
}
|
|
31232
31429
|
)
|
|
31233
31430
|
]
|
|
31234
31431
|
}
|
|
31235
|
-
)
|
|
31236
|
-
|
|
31237
|
-
/* @__PURE__ */
|
|
31238
|
-
"
|
|
31432
|
+
),
|
|
31433
|
+
/* @__PURE__ */ jsxs44("div", { style: { padding: spacing[4] }, children: [
|
|
31434
|
+
isDetecting ? /* @__PURE__ */ jsxs44(
|
|
31435
|
+
"div",
|
|
31239
31436
|
{
|
|
31240
31437
|
style: {
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
31244
|
-
marginBottom: spacing[2]
|
|
31438
|
+
display: "flex",
|
|
31439
|
+
flexDirection: "column",
|
|
31440
|
+
gap: spacing[3]
|
|
31245
31441
|
},
|
|
31246
|
-
children:
|
|
31442
|
+
children: [
|
|
31443
|
+
[1, 2].map((i) => /* @__PURE__ */ jsxs44(
|
|
31444
|
+
"div",
|
|
31445
|
+
{
|
|
31446
|
+
style: {
|
|
31447
|
+
display: "flex",
|
|
31448
|
+
alignItems: "center",
|
|
31449
|
+
gap: spacing[4],
|
|
31450
|
+
padding: spacing[4],
|
|
31451
|
+
borderRadius: borderRadius["2xl"],
|
|
31452
|
+
backgroundColor: colors.muted,
|
|
31453
|
+
animation: "tw-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
31454
|
+
},
|
|
31455
|
+
children: [
|
|
31456
|
+
/* @__PURE__ */ jsx55(
|
|
31457
|
+
"div",
|
|
31458
|
+
{
|
|
31459
|
+
style: {
|
|
31460
|
+
width: "3rem",
|
|
31461
|
+
height: "3rem",
|
|
31462
|
+
borderRadius: borderRadius.xl,
|
|
31463
|
+
backgroundColor: "rgba(161,161,170,0.2)"
|
|
31464
|
+
}
|
|
31465
|
+
}
|
|
31466
|
+
),
|
|
31467
|
+
/* @__PURE__ */ jsx55(
|
|
31468
|
+
"div",
|
|
31469
|
+
{
|
|
31470
|
+
style: {
|
|
31471
|
+
height: "1rem",
|
|
31472
|
+
width: "6rem",
|
|
31473
|
+
borderRadius: borderRadius.md,
|
|
31474
|
+
backgroundColor: "rgba(161,161,170,0.2)"
|
|
31475
|
+
}
|
|
31476
|
+
}
|
|
31477
|
+
)
|
|
31478
|
+
]
|
|
31479
|
+
},
|
|
31480
|
+
i
|
|
31481
|
+
)),
|
|
31482
|
+
/* @__PURE__ */ jsx55(
|
|
31483
|
+
"p",
|
|
31484
|
+
{
|
|
31485
|
+
style: {
|
|
31486
|
+
textAlign: "center",
|
|
31487
|
+
fontSize: fontSize.sm,
|
|
31488
|
+
color: colors.mutedForeground,
|
|
31489
|
+
marginTop: spacing[4]
|
|
31490
|
+
},
|
|
31491
|
+
children: "Detecting wallets..."
|
|
31492
|
+
}
|
|
31493
|
+
)
|
|
31494
|
+
]
|
|
31247
31495
|
}
|
|
31248
|
-
),
|
|
31249
|
-
|
|
31250
|
-
|
|
31496
|
+
) : filteredWallets.length === 0 ? /* @__PURE__ */ jsxs44("div", { style: { textAlign: "center", padding: `${spacing[8]} 0` }, children: [
|
|
31497
|
+
/* @__PURE__ */ jsx55("div", { style: { fontSize: "2.5rem", marginBottom: spacing[4] }, children: "\u{1F45B}" }),
|
|
31498
|
+
/* @__PURE__ */ jsx55(
|
|
31499
|
+
"h3",
|
|
31500
|
+
{
|
|
31501
|
+
style: {
|
|
31502
|
+
fontSize: fontSize.lg,
|
|
31503
|
+
fontWeight: fontWeight.semibold,
|
|
31504
|
+
color: colors.foreground,
|
|
31505
|
+
marginBottom: spacing[2]
|
|
31506
|
+
},
|
|
31507
|
+
children: "No Wallets Found"
|
|
31508
|
+
}
|
|
31509
|
+
),
|
|
31510
|
+
/* @__PURE__ */ jsx55(
|
|
31511
|
+
"p",
|
|
31512
|
+
{
|
|
31513
|
+
style: {
|
|
31514
|
+
fontSize: fontSize.sm,
|
|
31515
|
+
color: colors.mutedForeground,
|
|
31516
|
+
marginBottom: spacing[4]
|
|
31517
|
+
},
|
|
31518
|
+
children: "Please install a web3 wallet to continue."
|
|
31519
|
+
}
|
|
31520
|
+
),
|
|
31521
|
+
/* @__PURE__ */ jsx55(
|
|
31522
|
+
"a",
|
|
31523
|
+
{
|
|
31524
|
+
href: "https://metamask.io/download/",
|
|
31525
|
+
target: "_blank",
|
|
31526
|
+
rel: "noopener noreferrer",
|
|
31527
|
+
style: {
|
|
31528
|
+
display: "inline-flex",
|
|
31529
|
+
alignItems: "center",
|
|
31530
|
+
justifyContent: "center",
|
|
31531
|
+
padding: `${spacing[2]} ${spacing[4]}`,
|
|
31532
|
+
borderRadius: borderRadius.lg,
|
|
31533
|
+
backgroundColor: colors.primary,
|
|
31534
|
+
color: colors.primaryForeground,
|
|
31535
|
+
fontSize: fontSize.sm,
|
|
31536
|
+
fontWeight: fontWeight.medium,
|
|
31537
|
+
textDecoration: "none"
|
|
31538
|
+
},
|
|
31539
|
+
children: "Install MetaMask"
|
|
31540
|
+
}
|
|
31541
|
+
)
|
|
31542
|
+
] }) : /* @__PURE__ */ jsx55(
|
|
31543
|
+
"div",
|
|
31251
31544
|
{
|
|
31252
31545
|
style: {
|
|
31253
|
-
|
|
31254
|
-
|
|
31255
|
-
|
|
31546
|
+
display: "flex",
|
|
31547
|
+
flexDirection: "column",
|
|
31548
|
+
gap: spacing[3]
|
|
31256
31549
|
},
|
|
31257
|
-
children:
|
|
31550
|
+
children: filteredWallets.map((wallet) => {
|
|
31551
|
+
const isWalletConnected = managerConnected && walletMetaId === wallet.meta.id;
|
|
31552
|
+
const isConnecting = connectingId === wallet.meta.id && walletStatus === "connecting";
|
|
31553
|
+
return /* @__PURE__ */ jsxs44(
|
|
31554
|
+
"div",
|
|
31555
|
+
{
|
|
31556
|
+
style: mergeStyles(
|
|
31557
|
+
{
|
|
31558
|
+
width: "100%",
|
|
31559
|
+
display: "flex",
|
|
31560
|
+
alignItems: "center",
|
|
31561
|
+
gap: spacing[4],
|
|
31562
|
+
padding: spacing[4],
|
|
31563
|
+
borderRadius: borderRadius["2xl"],
|
|
31564
|
+
backgroundColor: colors.card,
|
|
31565
|
+
border: `1px solid ${colors.border}`
|
|
31566
|
+
},
|
|
31567
|
+
isWalletConnected && {
|
|
31568
|
+
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
31569
|
+
border: `1px solid ${colors.primary}`
|
|
31570
|
+
}
|
|
31571
|
+
),
|
|
31572
|
+
children: [
|
|
31573
|
+
/* @__PURE__ */ jsx55(
|
|
31574
|
+
"div",
|
|
31575
|
+
{
|
|
31576
|
+
style: {
|
|
31577
|
+
width: "3rem",
|
|
31578
|
+
height: "3rem",
|
|
31579
|
+
borderRadius: borderRadius.xl,
|
|
31580
|
+
backgroundColor: colors.muted,
|
|
31581
|
+
display: "flex",
|
|
31582
|
+
alignItems: "center",
|
|
31583
|
+
justifyContent: "center",
|
|
31584
|
+
overflow: "hidden",
|
|
31585
|
+
flexShrink: 0
|
|
31586
|
+
},
|
|
31587
|
+
children: wallet.meta.logo ? /* @__PURE__ */ jsx55(
|
|
31588
|
+
"img",
|
|
31589
|
+
{
|
|
31590
|
+
src: wallet.meta.logo,
|
|
31591
|
+
alt: wallet.meta.name,
|
|
31592
|
+
style: {
|
|
31593
|
+
width: "2rem",
|
|
31594
|
+
height: "2rem",
|
|
31595
|
+
objectFit: "contain"
|
|
31596
|
+
}
|
|
31597
|
+
}
|
|
31598
|
+
) : wallet.detail?.info?.icon ? /* @__PURE__ */ jsx55(
|
|
31599
|
+
"img",
|
|
31600
|
+
{
|
|
31601
|
+
src: wallet.detail.info.icon,
|
|
31602
|
+
alt: wallet.meta.name,
|
|
31603
|
+
style: {
|
|
31604
|
+
width: "2rem",
|
|
31605
|
+
height: "2rem",
|
|
31606
|
+
objectFit: "contain"
|
|
31607
|
+
}
|
|
31608
|
+
}
|
|
31609
|
+
) : /* @__PURE__ */ jsx55("span", { style: { fontSize: "1.5rem" }, children: wallet.meta.emoji || "\u{1F45B}" })
|
|
31610
|
+
}
|
|
31611
|
+
),
|
|
31612
|
+
/* @__PURE__ */ jsxs44("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
31613
|
+
/* @__PURE__ */ jsx55(
|
|
31614
|
+
"p",
|
|
31615
|
+
{
|
|
31616
|
+
style: {
|
|
31617
|
+
fontWeight: fontWeight.semibold,
|
|
31618
|
+
color: colors.foreground
|
|
31619
|
+
},
|
|
31620
|
+
children: wallet.meta.name
|
|
31621
|
+
}
|
|
31622
|
+
),
|
|
31623
|
+
isWalletConnected && walletAddress && /* @__PURE__ */ jsxs44(
|
|
31624
|
+
"p",
|
|
31625
|
+
{
|
|
31626
|
+
style: {
|
|
31627
|
+
fontSize: fontSize.xs,
|
|
31628
|
+
color: colors.mutedForeground
|
|
31629
|
+
},
|
|
31630
|
+
children: [
|
|
31631
|
+
walletAddress.slice(0, 6),
|
|
31632
|
+
"...",
|
|
31633
|
+
walletAddress.slice(-4)
|
|
31634
|
+
]
|
|
31635
|
+
}
|
|
31636
|
+
)
|
|
31637
|
+
] }),
|
|
31638
|
+
isConnecting ? /* @__PURE__ */ jsx55(
|
|
31639
|
+
"div",
|
|
31640
|
+
{
|
|
31641
|
+
style: {
|
|
31642
|
+
width: "1.25rem",
|
|
31643
|
+
height: "1.25rem",
|
|
31644
|
+
border: `2px solid ${colors.mutedForeground}`,
|
|
31645
|
+
borderTopColor: "transparent",
|
|
31646
|
+
borderRadius: "9999px",
|
|
31647
|
+
animation: "tw-spin 1s linear infinite",
|
|
31648
|
+
flexShrink: 0
|
|
31649
|
+
}
|
|
31650
|
+
}
|
|
31651
|
+
) : isWalletConnected ? /* @__PURE__ */ jsx55(
|
|
31652
|
+
"button",
|
|
31653
|
+
{
|
|
31654
|
+
onClick: handleDisconnect,
|
|
31655
|
+
style: {
|
|
31656
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31657
|
+
borderRadius: "9999px",
|
|
31658
|
+
backgroundColor: "rgba(239,68,68,0.1)",
|
|
31659
|
+
color: "#ef4444",
|
|
31660
|
+
fontSize: fontSize.xs,
|
|
31661
|
+
fontWeight: fontWeight.medium,
|
|
31662
|
+
border: 0,
|
|
31663
|
+
cursor: "pointer",
|
|
31664
|
+
flexShrink: 0
|
|
31665
|
+
},
|
|
31666
|
+
children: "Disconnect"
|
|
31667
|
+
}
|
|
31668
|
+
) : /* @__PURE__ */ jsx55(
|
|
31669
|
+
"button",
|
|
31670
|
+
{
|
|
31671
|
+
onClick: () => void handleClick(wallet),
|
|
31672
|
+
disabled: walletStatus === "connecting",
|
|
31673
|
+
style: mergeStyles(
|
|
31674
|
+
{
|
|
31675
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31676
|
+
borderRadius: "9999px",
|
|
31677
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
31678
|
+
color: colors.primary,
|
|
31679
|
+
fontSize: fontSize.xs,
|
|
31680
|
+
fontWeight: fontWeight.medium,
|
|
31681
|
+
border: 0,
|
|
31682
|
+
cursor: "pointer",
|
|
31683
|
+
flexShrink: 0
|
|
31684
|
+
},
|
|
31685
|
+
walletStatus === "connecting" && {
|
|
31686
|
+
opacity: 0.5,
|
|
31687
|
+
cursor: "not-allowed"
|
|
31688
|
+
}
|
|
31689
|
+
),
|
|
31690
|
+
children: "Connect"
|
|
31691
|
+
}
|
|
31692
|
+
)
|
|
31693
|
+
]
|
|
31694
|
+
},
|
|
31695
|
+
wallet.meta.id
|
|
31696
|
+
);
|
|
31697
|
+
})
|
|
31258
31698
|
}
|
|
31259
31699
|
),
|
|
31260
|
-
/* @__PURE__ */
|
|
31261
|
-
|
|
31262
|
-
|
|
31263
|
-
|
|
31264
|
-
|
|
31265
|
-
|
|
31266
|
-
|
|
31267
|
-
|
|
31268
|
-
|
|
31269
|
-
|
|
31270
|
-
|
|
31271
|
-
|
|
31272
|
-
|
|
31273
|
-
color: colors.primaryForeground,
|
|
31274
|
-
fontSize: fontSize.sm,
|
|
31275
|
-
fontWeight: fontWeight.medium,
|
|
31276
|
-
textDecoration: "none"
|
|
31277
|
-
},
|
|
31278
|
-
children: "Install MetaMask"
|
|
31279
|
-
}
|
|
31280
|
-
)
|
|
31281
|
-
] }) : /* @__PURE__ */ jsx55(
|
|
31282
|
-
"div",
|
|
31283
|
-
{
|
|
31284
|
-
style: {
|
|
31285
|
-
display: "flex",
|
|
31286
|
-
flexDirection: "column",
|
|
31287
|
-
gap: spacing[3]
|
|
31288
|
-
},
|
|
31289
|
-
children: detected.map((wallet) => {
|
|
31290
|
-
const isConnecting = connectingId === wallet.meta.id;
|
|
31291
|
-
const isConnected = walletStatus === "connected" && connectingId === null && walletAddress !== null && connectedWalletId === wallet.meta.id;
|
|
31700
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(Fragment7, { children: [
|
|
31701
|
+
/* @__PURE__ */ jsx55(
|
|
31702
|
+
"div",
|
|
31703
|
+
{
|
|
31704
|
+
style: {
|
|
31705
|
+
height: 1,
|
|
31706
|
+
backgroundColor: colors.border,
|
|
31707
|
+
margin: `${spacing[3]} 0`
|
|
31708
|
+
}
|
|
31709
|
+
}
|
|
31710
|
+
),
|
|
31711
|
+
(() => {
|
|
31712
|
+
const wcConnected = managerConnected && connectedVia === "walletconnect";
|
|
31292
31713
|
return /* @__PURE__ */ jsxs44(
|
|
31293
31714
|
"div",
|
|
31294
31715
|
{
|
|
@@ -31301,13 +31722,15 @@ function SwapWalletSelector({
|
|
|
31301
31722
|
padding: spacing[4],
|
|
31302
31723
|
borderRadius: borderRadius["2xl"],
|
|
31303
31724
|
backgroundColor: colors.card,
|
|
31304
|
-
border: `1px solid ${colors.border}
|
|
31725
|
+
border: `1px solid ${colors.border}`,
|
|
31726
|
+
cursor: "pointer"
|
|
31305
31727
|
},
|
|
31306
|
-
|
|
31728
|
+
wcConnected && {
|
|
31307
31729
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
31308
31730
|
border: `1px solid ${colors.primary}`
|
|
31309
31731
|
}
|
|
31310
31732
|
),
|
|
31733
|
+
onClick: !wcConnected ? () => void handleWalletConnect() : void 0,
|
|
31311
31734
|
children: [
|
|
31312
31735
|
/* @__PURE__ */ jsx55(
|
|
31313
31736
|
"div",
|
|
@@ -31320,35 +31743,24 @@ function SwapWalletSelector({
|
|
|
31320
31743
|
display: "flex",
|
|
31321
31744
|
alignItems: "center",
|
|
31322
31745
|
justifyContent: "center",
|
|
31323
|
-
overflow: "hidden",
|
|
31324
31746
|
flexShrink: 0
|
|
31325
31747
|
},
|
|
31326
|
-
children:
|
|
31327
|
-
"
|
|
31328
|
-
{
|
|
31329
|
-
src: wallet.meta.logo,
|
|
31330
|
-
alt: wallet.meta.name,
|
|
31331
|
-
style: {
|
|
31332
|
-
width: "2rem",
|
|
31333
|
-
height: "2rem",
|
|
31334
|
-
objectFit: "contain"
|
|
31335
|
-
}
|
|
31336
|
-
}
|
|
31337
|
-
) : wallet.detail?.info?.icon ? /* @__PURE__ */ jsx55(
|
|
31338
|
-
"img",
|
|
31748
|
+
children: /* @__PURE__ */ jsx55(
|
|
31749
|
+
"svg",
|
|
31339
31750
|
{
|
|
31340
|
-
src: wallet.detail.info.icon,
|
|
31341
|
-
alt: wallet.meta.name,
|
|
31342
31751
|
style: {
|
|
31343
|
-
width: "
|
|
31344
|
-
height: "
|
|
31345
|
-
|
|
31346
|
-
}
|
|
31752
|
+
width: "1.5rem",
|
|
31753
|
+
height: "1.5rem",
|
|
31754
|
+
color: colors.blue[500]
|
|
31755
|
+
},
|
|
31756
|
+
viewBox: "0 0 24 24",
|
|
31757
|
+
fill: "currentColor",
|
|
31758
|
+
children: /* @__PURE__ */ jsx55("path", { d: "M6.09 10.56c3.26-3.2 8.56-3.2 11.82 0l.39.39a.4.4 0 010 .58l-1.34 1.31a.21.21 0 01-.3 0l-.54-.53c-2.28-2.23-5.97-2.23-8.24 0l-.58.56a.21.21 0 01-.3 0L5.66 11.6a.4.4 0 010-.58l.43-.46zm14.6 2.72l1.2 1.17a.4.4 0 010 .58l-5.38 5.27a.43.43 0 01-.6 0l-3.82-3.74a.11.11 0 00-.15 0l-3.82 3.74a.43.43 0 01-.6 0L2.15 15.03a.4.4 0 010-.58l1.2-1.17a.43.43 0 01.6 0l3.82 3.74c.04.04.1.04.15 0l3.82-3.74a.43.43 0 01.6 0l3.82 3.74c.04.04.1.04.15 0l3.82-3.74a.43.43 0 01.6 0z" })
|
|
31347
31759
|
}
|
|
31348
|
-
)
|
|
31760
|
+
)
|
|
31349
31761
|
}
|
|
31350
31762
|
),
|
|
31351
|
-
/* @__PURE__ */ jsxs44("div", { style: { flex: 1 }, children: [
|
|
31763
|
+
/* @__PURE__ */ jsxs44("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
31352
31764
|
/* @__PURE__ */ jsx55(
|
|
31353
31765
|
"p",
|
|
31354
31766
|
{
|
|
@@ -31356,10 +31768,10 @@ function SwapWalletSelector({
|
|
|
31356
31768
|
fontWeight: fontWeight.semibold,
|
|
31357
31769
|
color: colors.foreground
|
|
31358
31770
|
},
|
|
31359
|
-
children:
|
|
31771
|
+
children: "WalletConnect"
|
|
31360
31772
|
}
|
|
31361
31773
|
),
|
|
31362
|
-
|
|
31774
|
+
wcConnected && walletAddress && /* @__PURE__ */ jsxs44(
|
|
31363
31775
|
"p",
|
|
31364
31776
|
{
|
|
31365
31777
|
style: {
|
|
@@ -31374,7 +31786,7 @@ function SwapWalletSelector({
|
|
|
31374
31786
|
}
|
|
31375
31787
|
)
|
|
31376
31788
|
] }),
|
|
31377
|
-
|
|
31789
|
+
wcConnecting ? /* @__PURE__ */ jsx55(
|
|
31378
31790
|
"div",
|
|
31379
31791
|
{
|
|
31380
31792
|
style: {
|
|
@@ -31383,40 +31795,58 @@ function SwapWalletSelector({
|
|
|
31383
31795
|
border: `2px solid ${colors.mutedForeground}`,
|
|
31384
31796
|
borderTopColor: "transparent",
|
|
31385
31797
|
borderRadius: "9999px",
|
|
31386
|
-
animation: "tw-spin 1s linear infinite"
|
|
31798
|
+
animation: "tw-spin 1s linear infinite",
|
|
31799
|
+
flexShrink: 0
|
|
31387
31800
|
}
|
|
31388
31801
|
}
|
|
31802
|
+
) : wcConnected ? /* @__PURE__ */ jsx55(
|
|
31803
|
+
"button",
|
|
31804
|
+
{
|
|
31805
|
+
onClick: (e2) => {
|
|
31806
|
+
e2.stopPropagation();
|
|
31807
|
+
handleDisconnect();
|
|
31808
|
+
},
|
|
31809
|
+
style: {
|
|
31810
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31811
|
+
borderRadius: "9999px",
|
|
31812
|
+
backgroundColor: "rgba(239,68,68,0.1)",
|
|
31813
|
+
color: "#ef4444",
|
|
31814
|
+
fontSize: fontSize.xs,
|
|
31815
|
+
fontWeight: fontWeight.medium,
|
|
31816
|
+
border: 0,
|
|
31817
|
+
cursor: "pointer",
|
|
31818
|
+
flexShrink: 0
|
|
31819
|
+
},
|
|
31820
|
+
children: "Disconnect"
|
|
31821
|
+
}
|
|
31389
31822
|
) : /* @__PURE__ */ jsx55(
|
|
31390
31823
|
"button",
|
|
31391
31824
|
{
|
|
31392
|
-
onClick: () =>
|
|
31393
|
-
|
|
31394
|
-
|
|
31395
|
-
|
|
31396
|
-
|
|
31397
|
-
|
|
31398
|
-
|
|
31399
|
-
|
|
31400
|
-
|
|
31401
|
-
|
|
31402
|
-
|
|
31403
|
-
|
|
31404
|
-
|
|
31405
|
-
|
|
31406
|
-
|
|
31407
|
-
|
|
31408
|
-
}
|
|
31409
|
-
),
|
|
31825
|
+
onClick: (e2) => {
|
|
31826
|
+
e2.stopPropagation();
|
|
31827
|
+
void handleWalletConnect();
|
|
31828
|
+
},
|
|
31829
|
+
disabled: wcConnecting,
|
|
31830
|
+
style: {
|
|
31831
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31832
|
+
borderRadius: "9999px",
|
|
31833
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
31834
|
+
color: colors.primary,
|
|
31835
|
+
fontSize: fontSize.xs,
|
|
31836
|
+
fontWeight: fontWeight.medium,
|
|
31837
|
+
border: 0,
|
|
31838
|
+
cursor: "pointer",
|
|
31839
|
+
flexShrink: 0
|
|
31840
|
+
},
|
|
31410
31841
|
children: "Connect"
|
|
31411
31842
|
}
|
|
31412
31843
|
)
|
|
31413
31844
|
]
|
|
31414
|
-
}
|
|
31415
|
-
wallet.meta.id
|
|
31845
|
+
}
|
|
31416
31846
|
);
|
|
31417
|
-
})
|
|
31418
|
-
}
|
|
31419
|
-
|
|
31847
|
+
})()
|
|
31848
|
+
] })
|
|
31849
|
+
] })
|
|
31420
31850
|
] });
|
|
31421
31851
|
}
|
|
31422
31852
|
var init_SwapWalletSelector = __esm({
|
|
@@ -31425,6 +31855,7 @@ var init_SwapWalletSelector = __esm({
|
|
|
31425
31855
|
init_styles();
|
|
31426
31856
|
init_utils();
|
|
31427
31857
|
init_wallets();
|
|
31858
|
+
init_config2();
|
|
31428
31859
|
init_Toast();
|
|
31429
31860
|
}
|
|
31430
31861
|
});
|
|
@@ -31508,11 +31939,11 @@ import {
|
|
|
31508
31939
|
Suspense as Suspense2,
|
|
31509
31940
|
useCallback as useCallback22,
|
|
31510
31941
|
useEffect as useEffect30,
|
|
31511
|
-
useMemo as
|
|
31942
|
+
useMemo as useMemo26,
|
|
31512
31943
|
useRef as useRef17,
|
|
31513
31944
|
useState as useState28
|
|
31514
31945
|
} from "react";
|
|
31515
|
-
import { Fragment as
|
|
31946
|
+
import { Fragment as Fragment8, jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
31516
31947
|
function fmtAmount(n, max = 6) {
|
|
31517
31948
|
if (!isFinite(n) || n === 0) return "0";
|
|
31518
31949
|
return n.toLocaleString(void 0, { maximumFractionDigits: max });
|
|
@@ -31649,6 +32080,7 @@ function SwapMode({
|
|
|
31649
32080
|
);
|
|
31650
32081
|
const settingsRef = useRef17(null);
|
|
31651
32082
|
const currencyDropdownRef = useRef17(null);
|
|
32083
|
+
const { emitEvent } = useTrustware();
|
|
31652
32084
|
const { features } = useTrustwareConfig();
|
|
31653
32085
|
const defaultDestRef = features.swapDefaultDestToken;
|
|
31654
32086
|
const lockDestToken = features.swapLockDestToken && !!defaultDestRef;
|
|
@@ -31659,21 +32091,21 @@ function SwapMode({
|
|
|
31659
32091
|
isLoading: chainsLoading,
|
|
31660
32092
|
error: chainsError
|
|
31661
32093
|
} = useChains();
|
|
31662
|
-
const allowedDestChainIds =
|
|
32094
|
+
const allowedDestChainIds = useMemo26(() => {
|
|
31663
32095
|
if (!allowedDestTokens || allowedDestTokens.length === 0) return null;
|
|
31664
32096
|
return new Set(allowedDestTokens.map((t) => t.chainId));
|
|
31665
32097
|
}, [allowedDestTokens]);
|
|
31666
|
-
const toPopularChains =
|
|
32098
|
+
const toPopularChains = useMemo26(
|
|
31667
32099
|
() => allowedDestChainIds ? popularChains.filter(
|
|
31668
32100
|
(c) => allowedDestChainIds.has(Number(c.chainId))
|
|
31669
32101
|
) : popularChains,
|
|
31670
32102
|
[popularChains, allowedDestChainIds]
|
|
31671
32103
|
);
|
|
31672
|
-
const toOtherChains =
|
|
32104
|
+
const toOtherChains = useMemo26(
|
|
31673
32105
|
() => allowedDestChainIds ? otherChains.filter((c) => allowedDestChainIds.has(Number(c.chainId))) : otherChains,
|
|
31674
32106
|
[otherChains, allowedDestChainIds]
|
|
31675
32107
|
);
|
|
31676
|
-
const allChains =
|
|
32108
|
+
const allChains = useMemo26(
|
|
31677
32109
|
() => [...popularChains, ...otherChains],
|
|
31678
32110
|
[popularChains, otherChains]
|
|
31679
32111
|
);
|
|
@@ -31717,7 +32149,7 @@ function SwapMode({
|
|
|
31717
32149
|
(c) => setFromChain(c),
|
|
31718
32150
|
[]
|
|
31719
32151
|
);
|
|
31720
|
-
const { yourWalletTokens } = useWalletTokenState({
|
|
32152
|
+
const { yourWalletTokens, reloadWalletTokens } = useWalletTokenState({
|
|
31721
32153
|
walletAddress,
|
|
31722
32154
|
selectedChain: fromChain,
|
|
31723
32155
|
setSelectedChain: setFromChainStable,
|
|
@@ -31726,18 +32158,18 @@ function SwapMode({
|
|
|
31726
32158
|
});
|
|
31727
32159
|
const route = useSwapRoute();
|
|
31728
32160
|
const execution = useSwapExecution(fromChain);
|
|
31729
|
-
const fromTokenPriceUSD =
|
|
32161
|
+
const fromTokenPriceUSD = useMemo26(() => {
|
|
31730
32162
|
const p = fromToken?.usdPrice;
|
|
31731
32163
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
31732
32164
|
}, [fromToken]);
|
|
31733
32165
|
const hasFromUsdPrice = fromTokenPriceUSD > 0;
|
|
31734
|
-
const toTokenPriceUSD =
|
|
32166
|
+
const toTokenPriceUSD = useMemo26(() => {
|
|
31735
32167
|
const p = toToken?.usdPrice;
|
|
31736
32168
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
31737
32169
|
}, [toToken]);
|
|
31738
32170
|
const hasToUsdPrice = toTokenPriceUSD > 0;
|
|
31739
32171
|
const rawSellNum = parseFloat(amount) || 0;
|
|
31740
|
-
const usdSellNum =
|
|
32172
|
+
const usdSellNum = useMemo26(() => {
|
|
31741
32173
|
if (amountInputMode === "usd") return rawSellNum / currencyRate;
|
|
31742
32174
|
return hasFromUsdPrice ? rawSellNum * fromTokenPriceUSD : 0;
|
|
31743
32175
|
}, [
|
|
@@ -31747,7 +32179,7 @@ function SwapMode({
|
|
|
31747
32179
|
hasFromUsdPrice,
|
|
31748
32180
|
fromTokenPriceUSD
|
|
31749
32181
|
]);
|
|
31750
|
-
const tokenSellNum =
|
|
32182
|
+
const tokenSellNum = useMemo26(() => {
|
|
31751
32183
|
if (amountInputMode === "usd") {
|
|
31752
32184
|
return hasFromUsdPrice && fromTokenPriceUSD > 0 ? usdSellNum / fromTokenPriceUSD : 0;
|
|
31753
32185
|
}
|
|
@@ -31759,7 +32191,7 @@ function SwapMode({
|
|
|
31759
32191
|
hasFromUsdPrice,
|
|
31760
32192
|
fromTokenPriceUSD
|
|
31761
32193
|
]);
|
|
31762
|
-
const tokenAmountStr =
|
|
32194
|
+
const tokenAmountStr = useMemo26(() => {
|
|
31763
32195
|
if (tokenSellNum <= 0) return "";
|
|
31764
32196
|
const decimals = fromToken?.decimals ?? 18;
|
|
31765
32197
|
return truncateDecimal(tokenSellNum, Math.min(decimals, 18));
|
|
@@ -31789,8 +32221,16 @@ function SwapMode({
|
|
|
31789
32221
|
setAmountInputMode("usd");
|
|
31790
32222
|
}
|
|
31791
32223
|
setStage("home");
|
|
32224
|
+
emitEvent?.({
|
|
32225
|
+
type: "swap_route_changed",
|
|
32226
|
+
fromChain: String(chain.chainId),
|
|
32227
|
+
fromToken: token.address,
|
|
32228
|
+
toChain: String(toChain?.chainId ?? ""),
|
|
32229
|
+
toToken: toToken?.address ?? "",
|
|
32230
|
+
...amount ? { amount } : {}
|
|
32231
|
+
});
|
|
31792
32232
|
},
|
|
31793
|
-
[route]
|
|
32233
|
+
[route, emitEvent, toToken, toChain, amount]
|
|
31794
32234
|
);
|
|
31795
32235
|
const handleSelectToToken = useCallback22(
|
|
31796
32236
|
(token, chain) => {
|
|
@@ -31798,18 +32238,35 @@ function SwapMode({
|
|
|
31798
32238
|
setToChain(chain);
|
|
31799
32239
|
route.clear();
|
|
31800
32240
|
setStage("home");
|
|
32241
|
+
emitEvent?.({
|
|
32242
|
+
type: "swap_route_changed",
|
|
32243
|
+
fromChain: String(fromChain?.chainId ?? ""),
|
|
32244
|
+
fromToken: fromToken?.address ?? "",
|
|
32245
|
+
toChain: String(chain.chainId),
|
|
32246
|
+
toToken: token.address,
|
|
32247
|
+
...amount ? { amount } : {}
|
|
32248
|
+
});
|
|
31801
32249
|
},
|
|
31802
|
-
[route]
|
|
32250
|
+
[route, emitEvent, fromToken, fromChain, amount]
|
|
31803
32251
|
);
|
|
31804
32252
|
const handleFlip = useCallback22(() => {
|
|
31805
32253
|
if (lockDestToken) return;
|
|
32254
|
+
const newFrom = toToken ?? fromToken;
|
|
32255
|
+
const newFromChain = toChain ?? fromChain;
|
|
31806
32256
|
setFromToken((prev) => toToken ?? prev);
|
|
31807
32257
|
setFromChain((prev) => toChain ?? prev);
|
|
31808
32258
|
setToToken(fromToken);
|
|
31809
32259
|
setToChain(fromChain);
|
|
31810
32260
|
setAmount("");
|
|
31811
32261
|
route.clear();
|
|
31812
|
-
|
|
32262
|
+
emitEvent?.({
|
|
32263
|
+
type: "swap_route_changed",
|
|
32264
|
+
fromChain: String(newFromChain?.chainId ?? ""),
|
|
32265
|
+
fromToken: newFrom?.address ?? "",
|
|
32266
|
+
toChain: String(fromChain?.chainId ?? ""),
|
|
32267
|
+
toToken: fromToken?.address ?? ""
|
|
32268
|
+
});
|
|
32269
|
+
}, [lockDestToken, fromToken, fromChain, toToken, toChain, route, emitEvent]);
|
|
31813
32270
|
const fromChainType = normalizeChainType2(fromChain);
|
|
31814
32271
|
const toChainType = normalizeChainType2(toChain);
|
|
31815
32272
|
const needsDestAddress = !!fromChainType && !!toChainType && fromChainType !== toChainType;
|
|
@@ -31882,7 +32339,8 @@ function SwapMode({
|
|
|
31882
32339
|
setCompletedAt(null);
|
|
31883
32340
|
setCopiedHash(null);
|
|
31884
32341
|
setStage("home");
|
|
31885
|
-
|
|
32342
|
+
reloadWalletTokens();
|
|
32343
|
+
}, [execution, route, reloadWalletTokens]);
|
|
31886
32344
|
const handleSwapBack = useCallback22(() => {
|
|
31887
32345
|
const prevFrom = fromToken;
|
|
31888
32346
|
const prevFromChain = fromChain;
|
|
@@ -31897,7 +32355,16 @@ function SwapMode({
|
|
|
31897
32355
|
setCompletedAt(null);
|
|
31898
32356
|
setCopiedHash(null);
|
|
31899
32357
|
setStage("home");
|
|
31900
|
-
|
|
32358
|
+
reloadWalletTokens();
|
|
32359
|
+
}, [
|
|
32360
|
+
fromToken,
|
|
32361
|
+
fromChain,
|
|
32362
|
+
toToken,
|
|
32363
|
+
toChain,
|
|
32364
|
+
execution,
|
|
32365
|
+
route,
|
|
32366
|
+
reloadWalletTokens
|
|
32367
|
+
]);
|
|
31901
32368
|
const handleCopyHash = useCallback22((hash) => {
|
|
31902
32369
|
if (!navigator?.clipboard?.writeText) return;
|
|
31903
32370
|
void navigator.clipboard.writeText(hash).then(() => {
|
|
@@ -31931,7 +32398,7 @@ function SwapMode({
|
|
|
31931
32398
|
fromToken?.decimals,
|
|
31932
32399
|
route
|
|
31933
32400
|
]);
|
|
31934
|
-
const fromBalance =
|
|
32401
|
+
const fromBalance = useMemo26(() => {
|
|
31935
32402
|
const walletToken = fromToken;
|
|
31936
32403
|
if (!walletToken || !("balance" in walletToken)) return null;
|
|
31937
32404
|
const raw = walletToken.balance;
|
|
@@ -31941,7 +32408,7 @@ function SwapMode({
|
|
|
31941
32408
|
return Number.isFinite(n) ? n : null;
|
|
31942
32409
|
}, [fromToken]);
|
|
31943
32410
|
const balanceUsd = fromBalance !== null && hasFromUsdPrice ? fromBalance * fromTokenPriceUSD : null;
|
|
31944
|
-
const estimatedToAmount =
|
|
32411
|
+
const estimatedToAmount = useMemo26(() => {
|
|
31945
32412
|
if (tokenSellNum <= 0 || !hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
31946
32413
|
return tokenSellNum * (fromTokenPriceUSD / toTokenPriceUSD);
|
|
31947
32414
|
}, [
|
|
@@ -31951,10 +32418,10 @@ function SwapMode({
|
|
|
31951
32418
|
hasFromUsdPrice,
|
|
31952
32419
|
hasToUsdPrice
|
|
31953
32420
|
]);
|
|
31954
|
-
const backendToUsdStr =
|
|
32421
|
+
const backendToUsdStr = useMemo26(() => {
|
|
31955
32422
|
return route.data?.finalExchangeRate?.toAmountMinUSD ?? route.data?.route?.estimate?.toAmountMinUsd ?? route.data?.route?.estimate?.toAmountUsd ?? null;
|
|
31956
32423
|
}, [route.data]);
|
|
31957
|
-
const toAmount =
|
|
32424
|
+
const toAmount = useMemo26(() => {
|
|
31958
32425
|
if (backendToUsdStr && toTokenPriceUSD > 0) {
|
|
31959
32426
|
const usd = parseFloat(backendToUsdStr);
|
|
31960
32427
|
if (Number.isFinite(usd) && usd > 0) return usd / toTokenPriceUSD;
|
|
@@ -31980,7 +32447,7 @@ function SwapMode({
|
|
|
31980
32447
|
estimatedToAmount
|
|
31981
32448
|
]);
|
|
31982
32449
|
const fromUsd = usdSellNum;
|
|
31983
|
-
const toUsd =
|
|
32450
|
+
const toUsd = useMemo26(() => {
|
|
31984
32451
|
if (backendToUsdStr) {
|
|
31985
32452
|
const n = parseFloat(backendToUsdStr);
|
|
31986
32453
|
if (Number.isFinite(n) && n > 0) return n;
|
|
@@ -31991,12 +32458,12 @@ function SwapMode({
|
|
|
31991
32458
|
const isEstimate = !route.data;
|
|
31992
32459
|
const USD_EPSILON = 1e-3;
|
|
31993
32460
|
const displayToUsd = toUsd > USD_EPSILON ? toUsd : estimatedToAmount !== null && hasToUsdPrice ? estimatedToAmount * toTokenPriceUSD : 0;
|
|
31994
|
-
const priceImpact =
|
|
32461
|
+
const priceImpact = useMemo26(() => {
|
|
31995
32462
|
if (!route.data || fromUsd < 0.01 || displayToUsd < 0.01) return null;
|
|
31996
32463
|
const impact = 1 - displayToUsd / fromUsd;
|
|
31997
32464
|
return impact > 1e-3 ? impact : null;
|
|
31998
32465
|
}, [route.data, fromUsd, displayToUsd]);
|
|
31999
|
-
const routePath =
|
|
32466
|
+
const routePath = useMemo26(() => {
|
|
32000
32467
|
if (!route.data) return null;
|
|
32001
32468
|
const provider = route.data.route?.provider;
|
|
32002
32469
|
const steps = route.data.route?.steps;
|
|
@@ -32023,19 +32490,19 @@ function SwapMode({
|
|
|
32023
32490
|
return null;
|
|
32024
32491
|
}, [route.data, fromToken?.symbol, toToken?.symbol]);
|
|
32025
32492
|
const isGasSponsored = !!route.data?.sponsorship;
|
|
32026
|
-
const networkCostUsd =
|
|
32493
|
+
const networkCostUsd = useMemo26(() => {
|
|
32027
32494
|
const fees = route.data?.route?.estimate?.fees;
|
|
32028
32495
|
if (!fees?.length) return null;
|
|
32029
32496
|
const gasTotal = fees.filter((f) => f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
32030
32497
|
return gasTotal > 0 ? gasTotal : null;
|
|
32031
32498
|
}, [route.data]);
|
|
32032
|
-
const protocolFeeUsd =
|
|
32499
|
+
const protocolFeeUsd = useMemo26(() => {
|
|
32033
32500
|
const fees = route.data?.route?.estimate?.fees;
|
|
32034
32501
|
if (!fees?.length) return null;
|
|
32035
32502
|
const total = fees.filter((f) => !f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
32036
32503
|
return total > 0 ? total : null;
|
|
32037
32504
|
}, [route.data]);
|
|
32038
|
-
const exchangeRate =
|
|
32505
|
+
const exchangeRate = useMemo26(() => {
|
|
32039
32506
|
if (!hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
32040
32507
|
return toTokenPriceUSD / fromTokenPriceUSD;
|
|
32041
32508
|
}, [fromTokenPriceUSD, toTokenPriceUSD, hasFromUsdPrice, hasToUsdPrice]);
|
|
@@ -32656,7 +33123,7 @@ function SwapMode({
|
|
|
32656
33123
|
padding: 0,
|
|
32657
33124
|
transition: "color 0.15s"
|
|
32658
33125
|
},
|
|
32659
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs45(
|
|
33126
|
+
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs45(Fragment8, { children: [
|
|
32660
33127
|
txHash.slice(0, 6),
|
|
32661
33128
|
"\u2026",
|
|
32662
33129
|
txHash.slice(-4),
|
|
@@ -33705,7 +34172,7 @@ function SwapMode({
|
|
|
33705
34172
|
) : /* @__PURE__ */ jsx56("span", { style: { color: colors.mutedForeground }, children: "\u2014" })
|
|
33706
34173
|
}
|
|
33707
34174
|
),
|
|
33708
|
-
showReviewDetails && /* @__PURE__ */ jsxs45(
|
|
34175
|
+
showReviewDetails && /* @__PURE__ */ jsxs45(Fragment8, { children: [
|
|
33709
34176
|
/* @__PURE__ */ jsx56(
|
|
33710
34177
|
ReviewDetailRow,
|
|
33711
34178
|
{
|
|
@@ -34279,9 +34746,15 @@ function SwapMode({
|
|
|
34279
34746
|
fromToken.address,
|
|
34280
34747
|
fromChainType ?? ""
|
|
34281
34748
|
) || isZeroAddrLike(fromToken.address, fromChainType));
|
|
34282
|
-
const
|
|
34749
|
+
const isSolana = normalizeChainType2(fromChain) === "solana";
|
|
34750
|
+
const effectiveAmount = (() => {
|
|
34751
|
+
if (!isNative || p.value !== 1)
|
|
34752
|
+
return fromBalance * p.value;
|
|
34753
|
+
if (isSolana) return Math.max(0, fromBalance - 0.01);
|
|
34754
|
+
return fromBalance * 0.995;
|
|
34755
|
+
})();
|
|
34283
34756
|
if (amountInputMode === "usd" && hasFromUsdPrice) {
|
|
34284
|
-
const fiatVal =
|
|
34757
|
+
const fiatVal = effectiveAmount * fromTokenPriceUSD * currencyRate;
|
|
34285
34758
|
const dp = fiatVal > 0 ? Math.min(
|
|
34286
34759
|
8,
|
|
34287
34760
|
Math.max(
|
|
@@ -34293,7 +34766,7 @@ function SwapMode({
|
|
|
34293
34766
|
} else {
|
|
34294
34767
|
setAmount(
|
|
34295
34768
|
truncateDecimal(
|
|
34296
|
-
|
|
34769
|
+
effectiveAmount,
|
|
34297
34770
|
Math.min(decimals, 6)
|
|
34298
34771
|
)
|
|
34299
34772
|
);
|
|
@@ -35551,6 +36024,7 @@ var init_SwapMode = __esm({
|
|
|
35551
36024
|
init_tokenAmount();
|
|
35552
36025
|
init_chainHelpers();
|
|
35553
36026
|
init_hooks();
|
|
36027
|
+
init_provider();
|
|
35554
36028
|
init_useSwapRoute();
|
|
35555
36029
|
init_useSwapExecution();
|
|
35556
36030
|
init_useForex();
|
|
@@ -35587,7 +36061,7 @@ import {
|
|
|
35587
36061
|
useImperativeHandle,
|
|
35588
36062
|
forwardRef
|
|
35589
36063
|
} from "react";
|
|
35590
|
-
import { Fragment as
|
|
36064
|
+
import { Fragment as Fragment9, jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
35591
36065
|
function WidgetContent({
|
|
35592
36066
|
style,
|
|
35593
36067
|
onStateChange,
|
|
@@ -35669,7 +36143,7 @@ function WidgetInner({
|
|
|
35669
36143
|
const handleRefresh = useCallback23(() => {
|
|
35670
36144
|
revalidate?.();
|
|
35671
36145
|
}, [revalidate]);
|
|
35672
|
-
return /* @__PURE__ */ jsxs46(
|
|
36146
|
+
return /* @__PURE__ */ jsxs46(Fragment9, { children: [
|
|
35673
36147
|
/* @__PURE__ */ jsxs46(WidgetContainer, { theme: effectiveTheme, style, children: [
|
|
35674
36148
|
/* @__PURE__ */ jsx57(
|
|
35675
36149
|
WidgetContent,
|