@trustware/sdk-staging 1.1.8-staging.5 → 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-BqqBQ5nF.d.ts → core-BPYlJrNb.d.ts} +1 -1
- package/dist/{core-BcoaMbJ6.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-srLQtIzU.d.cts → detect-CWNTV5Wq.d.cts} +1 -1
- package/dist/{detect-F6garpnf.d.ts → detect-CaQQECVe.d.ts} +1 -1
- package/dist/index.cjs +613 -166
- 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 +640 -193
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-BWmNEeZb.d.cts → manager-DHCXknCG.d.cts} +1 -1
- package/dist/{manager-BojJyYIt.d.ts → manager-Dtmjibzl.d.ts} +1 -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 +613 -166
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +640 -193
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -420,7 +420,7 @@ var init_constants = __esm({
|
|
|
420
420
|
"src/constants.ts"() {
|
|
421
421
|
"use strict";
|
|
422
422
|
SDK_NAME = "@trustware/sdk";
|
|
423
|
-
SDK_VERSION = "1.1.8-staging.
|
|
423
|
+
SDK_VERSION = "1.1.8-staging.6";
|
|
424
424
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
425
425
|
GTM_ID = "GTM-TZDGNCXB";
|
|
426
426
|
API_PREFIX = "/api";
|
|
@@ -662,6 +662,134 @@ var init_sdkRpc = __esm({
|
|
|
662
662
|
});
|
|
663
663
|
|
|
664
664
|
// src/wallets/solana.ts
|
|
665
|
+
function encodeBase58(bytes) {
|
|
666
|
+
const digits = [0];
|
|
667
|
+
for (const byte of bytes) {
|
|
668
|
+
let carry = byte;
|
|
669
|
+
for (let i = 0; i < digits.length; i++) {
|
|
670
|
+
carry += digits[i] << 8;
|
|
671
|
+
digits[i] = carry % 58;
|
|
672
|
+
carry = carry / 58 | 0;
|
|
673
|
+
}
|
|
674
|
+
while (carry > 0) {
|
|
675
|
+
digits.push(carry % 58);
|
|
676
|
+
carry = carry / 58 | 0;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
let result = "";
|
|
680
|
+
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
|
|
681
|
+
result += "1";
|
|
682
|
+
}
|
|
683
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
684
|
+
result += BASE58_ALPHABET[digits[i]];
|
|
685
|
+
}
|
|
686
|
+
return result;
|
|
687
|
+
}
|
|
688
|
+
function collectWalletStandardWallets() {
|
|
689
|
+
if (typeof window === "undefined") return [];
|
|
690
|
+
const collected = [];
|
|
691
|
+
const api = {
|
|
692
|
+
register(...wallets) {
|
|
693
|
+
collected.push(...wallets);
|
|
694
|
+
return () => {
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
try {
|
|
699
|
+
window.dispatchEvent(
|
|
700
|
+
Object.assign(
|
|
701
|
+
new Event("wallet-standard:app-ready", { bubbles: false }),
|
|
702
|
+
{
|
|
703
|
+
detail: api
|
|
704
|
+
}
|
|
705
|
+
)
|
|
706
|
+
);
|
|
707
|
+
} catch {
|
|
708
|
+
}
|
|
709
|
+
return collected;
|
|
710
|
+
}
|
|
711
|
+
function walletStandardToSolanaProvider(wallet) {
|
|
712
|
+
let currentAccount = wallet.accounts[0] ?? null;
|
|
713
|
+
const provider = {
|
|
714
|
+
get isConnected() {
|
|
715
|
+
return !!currentAccount;
|
|
716
|
+
},
|
|
717
|
+
get publicKey() {
|
|
718
|
+
if (!currentAccount) return void 0;
|
|
719
|
+
const addr = currentAccount.address;
|
|
720
|
+
return { toString: () => addr };
|
|
721
|
+
},
|
|
722
|
+
async connect() {
|
|
723
|
+
const feature = wallet.features["standard:connect"];
|
|
724
|
+
if (!feature?.connect)
|
|
725
|
+
throw new Error("Wallet Standard connect not available");
|
|
726
|
+
const result = await feature.connect({ silent: false });
|
|
727
|
+
currentAccount = result.accounts[0] ?? null;
|
|
728
|
+
if (!currentAccount)
|
|
729
|
+
throw new Error("No Solana account returned from MetaMask");
|
|
730
|
+
return { publicKey: { toString: () => currentAccount.address } };
|
|
731
|
+
},
|
|
732
|
+
async disconnect() {
|
|
733
|
+
const feature = wallet.features["standard:disconnect"];
|
|
734
|
+
await feature?.disconnect?.();
|
|
735
|
+
currentAccount = null;
|
|
736
|
+
},
|
|
737
|
+
async signAndSendTransaction(transaction, options) {
|
|
738
|
+
const feature = wallet.features["solana:signAndSendTransaction"];
|
|
739
|
+
if (!feature?.signAndSendTransaction || !currentAccount) {
|
|
740
|
+
throw new Error("signAndSendTransaction not available");
|
|
741
|
+
}
|
|
742
|
+
const txBytes = transaction.serialize();
|
|
743
|
+
const results = await feature.signAndSendTransaction({
|
|
744
|
+
account: currentAccount,
|
|
745
|
+
transaction: txBytes,
|
|
746
|
+
chain: SOLANA_MAINNET_CHAIN,
|
|
747
|
+
options
|
|
748
|
+
});
|
|
749
|
+
const sig = results[0]?.signature;
|
|
750
|
+
if (!sig) throw new Error("No signature returned");
|
|
751
|
+
return typeof sig === "string" ? sig : encodeBase58(sig);
|
|
752
|
+
},
|
|
753
|
+
async signTransaction(transaction) {
|
|
754
|
+
const feature = wallet.features["solana:signTransaction"];
|
|
755
|
+
if (!feature?.signTransaction || !currentAccount) {
|
|
756
|
+
throw new Error("signTransaction not available");
|
|
757
|
+
}
|
|
758
|
+
const txBytes = transaction.serialize();
|
|
759
|
+
const results = await feature.signTransaction({
|
|
760
|
+
account: currentAccount,
|
|
761
|
+
transaction: txBytes,
|
|
762
|
+
chain: SOLANA_MAINNET_CHAIN
|
|
763
|
+
});
|
|
764
|
+
const signed = results[0]?.signedTransaction;
|
|
765
|
+
if (!signed) throw new Error("No signed transaction returned");
|
|
766
|
+
return { serialize: () => signed };
|
|
767
|
+
},
|
|
768
|
+
on() {
|
|
769
|
+
},
|
|
770
|
+
off() {
|
|
771
|
+
},
|
|
772
|
+
removeListener() {
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
return provider;
|
|
776
|
+
}
|
|
777
|
+
function detectMetaMaskSolanaWallet(wallets) {
|
|
778
|
+
const meta = wallets.find((w) => w.id === "metamask-solana");
|
|
779
|
+
if (!meta) return [];
|
|
780
|
+
const standardWallets = collectWalletStandardWallets();
|
|
781
|
+
const mmWallet = standardWallets.find(
|
|
782
|
+
(w) => w.name.toLowerCase().includes("metamask") && w.chains.some((c) => c.startsWith("solana:"))
|
|
783
|
+
);
|
|
784
|
+
if (!mmWallet) return [];
|
|
785
|
+
return [
|
|
786
|
+
{
|
|
787
|
+
meta,
|
|
788
|
+
provider: walletStandardToSolanaProvider(mmWallet),
|
|
789
|
+
via: "solana-window"
|
|
790
|
+
}
|
|
791
|
+
];
|
|
792
|
+
}
|
|
665
793
|
function getPublicKeyString(provider) {
|
|
666
794
|
const publicKey = provider?.publicKey;
|
|
667
795
|
if (!publicKey) return null;
|
|
@@ -723,12 +851,13 @@ function getSolanaProviders() {
|
|
|
723
851
|
}
|
|
724
852
|
function detectSolanaWallets(wallets) {
|
|
725
853
|
const providers = getSolanaProviders();
|
|
726
|
-
|
|
854
|
+
const windowDetected = SOLANA_WALLET_IDS.flatMap((walletId) => {
|
|
727
855
|
const provider = providers[walletId];
|
|
728
856
|
const meta = wallets.find((item) => item.id === walletId);
|
|
729
857
|
if (!provider || !meta) return [];
|
|
730
858
|
return [{ meta, provider, via: "solana-window" }];
|
|
731
859
|
});
|
|
860
|
+
return [...windowDetected, ...detectMetaMaskSolanaWallet(wallets)];
|
|
732
861
|
}
|
|
733
862
|
function bindSolanaProviderEvents(provider, handlers) {
|
|
734
863
|
const onConnect = () => handlers.onConnect?.();
|
|
@@ -793,7 +922,7 @@ function toSolanaWalletInterface(provider) {
|
|
|
793
922
|
}
|
|
794
923
|
};
|
|
795
924
|
}
|
|
796
|
-
var SOLANA_WALLET_IDS;
|
|
925
|
+
var SOLANA_WALLET_IDS, SOLANA_MAINNET_CHAIN, BASE58_ALPHABET;
|
|
797
926
|
var init_solana = __esm({
|
|
798
927
|
"src/wallets/solana.ts"() {
|
|
799
928
|
"use strict";
|
|
@@ -803,6 +932,8 @@ var init_solana = __esm({
|
|
|
803
932
|
"solflare",
|
|
804
933
|
"backpack"
|
|
805
934
|
];
|
|
935
|
+
SOLANA_MAINNET_CHAIN = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
936
|
+
BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
806
937
|
}
|
|
807
938
|
});
|
|
808
939
|
|
|
@@ -976,6 +1107,15 @@ var init_metadata = __esm({
|
|
|
976
1107
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
977
1108
|
deepLink: (url) => `phantom://browse/${encodeURIComponent(url)}`
|
|
978
1109
|
},
|
|
1110
|
+
{
|
|
1111
|
+
id: "metamask-solana",
|
|
1112
|
+
name: "MetaMask (Solana)",
|
|
1113
|
+
category: "injected",
|
|
1114
|
+
ecosystem: "solana",
|
|
1115
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1116
|
+
emoji: "\u{1F98A}",
|
|
1117
|
+
homepage: "https://metamask.io/"
|
|
1118
|
+
},
|
|
979
1119
|
{
|
|
980
1120
|
id: "solflare",
|
|
981
1121
|
name: "Solflare",
|
|
@@ -7260,7 +7400,9 @@ function applyWalletTokenState({
|
|
|
7260
7400
|
const selectedTokenStillExists = selectedToken && sortedTokens.some(
|
|
7261
7401
|
(token) => normalizeChainKey2(token.chainId) === normalizeChainKey2(selectedToken.chainId) && token.address === selectedToken.address
|
|
7262
7402
|
);
|
|
7263
|
-
const nextSelectedToken = selectedTokenStillExists && selectedToken ?
|
|
7403
|
+
const nextSelectedToken = selectedTokenStillExists && selectedToken ? sortedTokens.find(
|
|
7404
|
+
(token) => normalizeChainKey2(token.chainId) === normalizeChainKey2(selectedToken.chainId) && token.address === selectedToken.address
|
|
7405
|
+
) ?? selectedToken : sortedTokens.find((token) => Number(token.balance) > 0) ?? null;
|
|
7264
7406
|
setSelectedToken(nextSelectedToken);
|
|
7265
7407
|
if (nextSelectedToken && (!selectedChain || normalizeChainKey2(selectedChain.chainId) !== normalizeChainKey2(
|
|
7266
7408
|
hasChainData(nextSelectedToken) ? nextSelectedToken.chainData?.chainId ?? null : nextSelectedToken.chainId
|
|
@@ -13547,10 +13689,12 @@ function useDepositAmountModel({
|
|
|
13547
13689
|
]);
|
|
13548
13690
|
const amountWei = amountValidationError ? 0n : amountComputation.fromAmountWei ?? 0n;
|
|
13549
13691
|
const parsedAmount = parseFloat(fixedFromAmountString ?? amount) || 0;
|
|
13550
|
-
const maxTokenAmount = useMemo14(
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13692
|
+
const maxTokenAmount = useMemo14(() => {
|
|
13693
|
+
const cap = Math.min(normalizedTokenBalance, 1e4);
|
|
13694
|
+
const token = selectedToken;
|
|
13695
|
+
const isSolNative = token?.category === "native" && typeof token.chain_key === "string" && token.chain_key.toLowerCase().includes("solana");
|
|
13696
|
+
return isSolNative ? Math.max(0, cap - 0.01) : cap;
|
|
13697
|
+
}, [normalizedTokenBalance, selectedToken]);
|
|
13554
13698
|
const maxUsdAmount = useMemo14(() => {
|
|
13555
13699
|
if (!hasUsdPrice) return void 0;
|
|
13556
13700
|
return Math.min(maxTokenAmount * tokenPriceUSD, 1e4);
|
|
@@ -30496,7 +30640,8 @@ function sleep3(ms) {
|
|
|
30496
30640
|
}
|
|
30497
30641
|
function isUserRejection(err) {
|
|
30498
30642
|
if (!err) return false;
|
|
30499
|
-
const
|
|
30643
|
+
const e2 = err;
|
|
30644
|
+
const code = e2?.code ?? e2?.data?.code;
|
|
30500
30645
|
if (code === 4001) return true;
|
|
30501
30646
|
const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
|
|
30502
30647
|
return msg.includes("user rejected") || msg.includes("user denied") || msg.includes("cancelled");
|
|
@@ -30645,6 +30790,26 @@ function useSwapExecution(fromChain) {
|
|
|
30645
30790
|
);
|
|
30646
30791
|
const canUseSA = !!routeResult.sponsorship && Date.now() >= saFailedUntilRef.current && wallet?.ecosystem === "evm" && wallet.type === "eip1193" && !isNative && !!walletAddress && Number.isFinite(numericChainId);
|
|
30647
30792
|
if (canUseSA) {
|
|
30793
|
+
if (numericChainId && wallet) {
|
|
30794
|
+
try {
|
|
30795
|
+
const currentChainId = await wallet.getChainId();
|
|
30796
|
+
if (currentChainId !== numericChainId) {
|
|
30797
|
+
await wallet.switchChain(numericChainId);
|
|
30798
|
+
}
|
|
30799
|
+
} catch (switchErr) {
|
|
30800
|
+
if (isUserRejection(switchErr)) {
|
|
30801
|
+
const msg = mapTxError(switchErr);
|
|
30802
|
+
setState((p) => ({
|
|
30803
|
+
...p,
|
|
30804
|
+
isSubmitting: false,
|
|
30805
|
+
txStatus: "error",
|
|
30806
|
+
errorMessage: msg
|
|
30807
|
+
}));
|
|
30808
|
+
onError(msg);
|
|
30809
|
+
return;
|
|
30810
|
+
}
|
|
30811
|
+
}
|
|
30812
|
+
}
|
|
30648
30813
|
try {
|
|
30649
30814
|
const mod = await Promise.resolve().then(() => (init_smart_account2(), smart_account_exports));
|
|
30650
30815
|
const result = await mod.sendRouteAsUserOperation({
|
|
@@ -31182,8 +31347,8 @@ var init_SwapTokenSelect = __esm({
|
|
|
31182
31347
|
});
|
|
31183
31348
|
|
|
31184
31349
|
// src/modes/swap/components/SwapWalletSelector.tsx
|
|
31185
|
-
import { useEffect as useEffect29, useRef as useRef16, useState as useState27 } from "react";
|
|
31186
|
-
import { jsx as jsx55, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
31350
|
+
import { useEffect as useEffect29, useMemo as useMemo25, useRef as useRef16, useState as useState27 } from "react";
|
|
31351
|
+
import { Fragment as Fragment7, jsx as jsx55, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
31187
31352
|
function SwapWalletSelector({
|
|
31188
31353
|
walletStatus,
|
|
31189
31354
|
walletAddress,
|
|
@@ -31191,11 +31356,18 @@ function SwapWalletSelector({
|
|
|
31191
31356
|
onBack
|
|
31192
31357
|
}) {
|
|
31193
31358
|
const { detected } = useWalletDetection();
|
|
31359
|
+
const {
|
|
31360
|
+
isConnected: managerConnected,
|
|
31361
|
+
walletMetaId,
|
|
31362
|
+
connectedVia,
|
|
31363
|
+
disconnect
|
|
31364
|
+
} = useWalletInfo();
|
|
31365
|
+
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
31366
|
+
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
31367
|
+
const [wcConnecting, setWcConnecting] = useState27(false);
|
|
31194
31368
|
const [connectingId, setConnectingId] = useState27(null);
|
|
31195
|
-
const [connectedWalletId, setConnectedWalletId] = useState27(
|
|
31196
|
-
null
|
|
31197
|
-
);
|
|
31198
31369
|
const [timerExpired, setTimerExpired] = useState27(false);
|
|
31370
|
+
const [selectedNamespace, setSelectedNamespace] = useState27("evm");
|
|
31199
31371
|
const prevStatusRef = useRef16(walletStatus);
|
|
31200
31372
|
useEffect29(() => {
|
|
31201
31373
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
@@ -31210,16 +31382,48 @@ function SwapWalletSelector({
|
|
|
31210
31382
|
prevStatusRef.current = walletStatus;
|
|
31211
31383
|
}
|
|
31212
31384
|
}, [walletStatus]);
|
|
31385
|
+
const filteredWallets = useMemo25(
|
|
31386
|
+
() => detected.filter(
|
|
31387
|
+
(w) => (w.meta?.ecosystem ?? "").toLowerCase() === selectedNamespace
|
|
31388
|
+
),
|
|
31389
|
+
[detected, selectedNamespace]
|
|
31390
|
+
);
|
|
31391
|
+
const isDetecting = detected.length === 0 && !timerExpired;
|
|
31392
|
+
const handleDisconnect = () => {
|
|
31393
|
+
void disconnect();
|
|
31394
|
+
};
|
|
31395
|
+
const handleWalletConnect = async () => {
|
|
31396
|
+
if (wcConnecting) return;
|
|
31397
|
+
if (connectedVia === "walletconnect" && managerConnected) {
|
|
31398
|
+
onBack();
|
|
31399
|
+
return;
|
|
31400
|
+
}
|
|
31401
|
+
setWcConnecting(true);
|
|
31402
|
+
try {
|
|
31403
|
+
const { error } = await connectWC();
|
|
31404
|
+
if (error) {
|
|
31405
|
+
toast.error("WalletConnect Failed", error);
|
|
31406
|
+
}
|
|
31407
|
+
} catch (err) {
|
|
31408
|
+
const msg = err instanceof Error ? err.message : "WalletConnect failed";
|
|
31409
|
+
toast.error("WalletConnect Failed", msg);
|
|
31410
|
+
} finally {
|
|
31411
|
+
setWcConnecting(false);
|
|
31412
|
+
}
|
|
31413
|
+
};
|
|
31213
31414
|
const handleClick = async (wallet) => {
|
|
31214
31415
|
if (walletStatus === "connecting") return;
|
|
31215
31416
|
if (wallet.meta.id === "walletconnect" || wallet.via === "walletconnect") {
|
|
31216
31417
|
toast.error("Not Available", "WalletConnect is not currently available.");
|
|
31217
31418
|
return;
|
|
31218
31419
|
}
|
|
31420
|
+
if (managerConnected && walletMetaId === wallet.meta.id) {
|
|
31421
|
+
onBack();
|
|
31422
|
+
return;
|
|
31423
|
+
}
|
|
31219
31424
|
setConnectingId(wallet.meta.id);
|
|
31220
31425
|
try {
|
|
31221
31426
|
await connectWallet(wallet);
|
|
31222
|
-
setConnectedWalletId(wallet.meta.id);
|
|
31223
31427
|
} catch (err) {
|
|
31224
31428
|
setConnectingId(null);
|
|
31225
31429
|
const msg = err instanceof Error ? err.message : "Failed to connect wallet";
|
|
@@ -31233,7 +31437,10 @@ function SwapWalletSelector({
|
|
|
31233
31437
|
}
|
|
31234
31438
|
}
|
|
31235
31439
|
};
|
|
31236
|
-
const
|
|
31440
|
+
const tabs = [
|
|
31441
|
+
{ id: "evm", label: "EVM" },
|
|
31442
|
+
{ id: "solana", label: "Solana" }
|
|
31443
|
+
];
|
|
31237
31444
|
return /* @__PURE__ */ jsxs44("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
31238
31445
|
/* @__PURE__ */ jsxs44(
|
|
31239
31446
|
"div",
|
|
@@ -31290,134 +31497,348 @@ function SwapWalletSelector({
|
|
|
31290
31497
|
fontSize: fontSize.lg,
|
|
31291
31498
|
fontWeight: fontWeight.semibold,
|
|
31292
31499
|
color: colors.foreground,
|
|
31293
|
-
textAlign: "center"
|
|
31294
|
-
marginRight: "1.75rem"
|
|
31500
|
+
textAlign: "center"
|
|
31295
31501
|
},
|
|
31296
31502
|
children: "Connect Wallet"
|
|
31297
31503
|
}
|
|
31298
|
-
)
|
|
31299
|
-
|
|
31300
|
-
}
|
|
31301
|
-
),
|
|
31302
|
-
/* @__PURE__ */ jsx55("div", { style: { padding: spacing[4] }, children: isDetecting ? /* @__PURE__ */ jsxs44(
|
|
31303
|
-
"div",
|
|
31304
|
-
{
|
|
31305
|
-
style: {
|
|
31306
|
-
display: "flex",
|
|
31307
|
-
flexDirection: "column",
|
|
31308
|
-
gap: spacing[3]
|
|
31309
|
-
},
|
|
31310
|
-
children: [
|
|
31311
|
-
[1, 2].map((i) => /* @__PURE__ */ jsxs44(
|
|
31504
|
+
),
|
|
31505
|
+
/* @__PURE__ */ jsxs44(
|
|
31312
31506
|
"div",
|
|
31313
31507
|
{
|
|
31314
31508
|
style: {
|
|
31509
|
+
position: "relative",
|
|
31315
31510
|
display: "flex",
|
|
31316
31511
|
alignItems: "center",
|
|
31317
|
-
|
|
31318
|
-
|
|
31319
|
-
|
|
31320
|
-
|
|
31321
|
-
animation: "tw-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
31512
|
+
borderRadius: "9999px",
|
|
31513
|
+
background: colors.background,
|
|
31514
|
+
border: `1px solid ${colors.mutedForeground}`,
|
|
31515
|
+
padding: "3px"
|
|
31322
31516
|
},
|
|
31323
31517
|
children: [
|
|
31324
31518
|
/* @__PURE__ */ jsx55(
|
|
31325
31519
|
"div",
|
|
31326
31520
|
{
|
|
31327
31521
|
style: {
|
|
31328
|
-
|
|
31329
|
-
|
|
31330
|
-
|
|
31331
|
-
|
|
31522
|
+
position: "absolute",
|
|
31523
|
+
top: 3,
|
|
31524
|
+
bottom: 3,
|
|
31525
|
+
width: "calc(50% - 3px)",
|
|
31526
|
+
borderRadius: "9999px",
|
|
31527
|
+
background: `linear-gradient(to bottom, ${colors.zinc[100]}, ${colors.zinc[200]})`,
|
|
31528
|
+
border: `1px solid ${colors.mutedForeground}`,
|
|
31529
|
+
transition: "transform 300ms ease-out",
|
|
31530
|
+
transform: selectedNamespace === "evm" ? "translateX(0)" : "translateX(100%)"
|
|
31332
31531
|
}
|
|
31333
31532
|
}
|
|
31334
31533
|
),
|
|
31335
|
-
/* @__PURE__ */ jsx55(
|
|
31336
|
-
"
|
|
31534
|
+
tabs.map((t) => /* @__PURE__ */ jsx55(
|
|
31535
|
+
"button",
|
|
31337
31536
|
{
|
|
31537
|
+
onClick: () => setSelectedNamespace(t.id),
|
|
31338
31538
|
style: {
|
|
31339
|
-
|
|
31340
|
-
|
|
31341
|
-
|
|
31342
|
-
|
|
31343
|
-
|
|
31344
|
-
|
|
31345
|
-
|
|
31539
|
+
position: "relative",
|
|
31540
|
+
zIndex: 10,
|
|
31541
|
+
padding: "4px 11px",
|
|
31542
|
+
fontSize: "10px",
|
|
31543
|
+
outline: "none",
|
|
31544
|
+
fontWeight: 600,
|
|
31545
|
+
borderRadius: "9999px",
|
|
31546
|
+
background: "transparent",
|
|
31547
|
+
border: "none",
|
|
31548
|
+
cursor: "pointer",
|
|
31549
|
+
transition: "color 200ms",
|
|
31550
|
+
color: selectedNamespace === t.id ? colors.black : colors.mutedForeground
|
|
31551
|
+
},
|
|
31552
|
+
children: t.label
|
|
31553
|
+
},
|
|
31554
|
+
t.id
|
|
31555
|
+
))
|
|
31346
31556
|
]
|
|
31347
|
-
},
|
|
31348
|
-
i
|
|
31349
|
-
)),
|
|
31350
|
-
/* @__PURE__ */ jsx55(
|
|
31351
|
-
"p",
|
|
31352
|
-
{
|
|
31353
|
-
style: {
|
|
31354
|
-
textAlign: "center",
|
|
31355
|
-
fontSize: fontSize.sm,
|
|
31356
|
-
color: colors.mutedForeground,
|
|
31357
|
-
marginTop: spacing[4]
|
|
31358
|
-
},
|
|
31359
|
-
children: "Detecting wallets..."
|
|
31360
31557
|
}
|
|
31361
31558
|
)
|
|
31362
31559
|
]
|
|
31363
31560
|
}
|
|
31364
|
-
)
|
|
31365
|
-
|
|
31366
|
-
/* @__PURE__ */
|
|
31367
|
-
"
|
|
31561
|
+
),
|
|
31562
|
+
/* @__PURE__ */ jsxs44("div", { style: { padding: spacing[4] }, children: [
|
|
31563
|
+
isDetecting ? /* @__PURE__ */ jsxs44(
|
|
31564
|
+
"div",
|
|
31368
31565
|
{
|
|
31369
31566
|
style: {
|
|
31370
|
-
|
|
31371
|
-
|
|
31372
|
-
|
|
31373
|
-
marginBottom: spacing[2]
|
|
31567
|
+
display: "flex",
|
|
31568
|
+
flexDirection: "column",
|
|
31569
|
+
gap: spacing[3]
|
|
31374
31570
|
},
|
|
31375
|
-
children:
|
|
31571
|
+
children: [
|
|
31572
|
+
[1, 2].map((i) => /* @__PURE__ */ jsxs44(
|
|
31573
|
+
"div",
|
|
31574
|
+
{
|
|
31575
|
+
style: {
|
|
31576
|
+
display: "flex",
|
|
31577
|
+
alignItems: "center",
|
|
31578
|
+
gap: spacing[4],
|
|
31579
|
+
padding: spacing[4],
|
|
31580
|
+
borderRadius: borderRadius["2xl"],
|
|
31581
|
+
backgroundColor: colors.muted,
|
|
31582
|
+
animation: "tw-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
31583
|
+
},
|
|
31584
|
+
children: [
|
|
31585
|
+
/* @__PURE__ */ jsx55(
|
|
31586
|
+
"div",
|
|
31587
|
+
{
|
|
31588
|
+
style: {
|
|
31589
|
+
width: "3rem",
|
|
31590
|
+
height: "3rem",
|
|
31591
|
+
borderRadius: borderRadius.xl,
|
|
31592
|
+
backgroundColor: "rgba(161,161,170,0.2)"
|
|
31593
|
+
}
|
|
31594
|
+
}
|
|
31595
|
+
),
|
|
31596
|
+
/* @__PURE__ */ jsx55(
|
|
31597
|
+
"div",
|
|
31598
|
+
{
|
|
31599
|
+
style: {
|
|
31600
|
+
height: "1rem",
|
|
31601
|
+
width: "6rem",
|
|
31602
|
+
borderRadius: borderRadius.md,
|
|
31603
|
+
backgroundColor: "rgba(161,161,170,0.2)"
|
|
31604
|
+
}
|
|
31605
|
+
}
|
|
31606
|
+
)
|
|
31607
|
+
]
|
|
31608
|
+
},
|
|
31609
|
+
i
|
|
31610
|
+
)),
|
|
31611
|
+
/* @__PURE__ */ jsx55(
|
|
31612
|
+
"p",
|
|
31613
|
+
{
|
|
31614
|
+
style: {
|
|
31615
|
+
textAlign: "center",
|
|
31616
|
+
fontSize: fontSize.sm,
|
|
31617
|
+
color: colors.mutedForeground,
|
|
31618
|
+
marginTop: spacing[4]
|
|
31619
|
+
},
|
|
31620
|
+
children: "Detecting wallets..."
|
|
31621
|
+
}
|
|
31622
|
+
)
|
|
31623
|
+
]
|
|
31376
31624
|
}
|
|
31377
|
-
),
|
|
31378
|
-
|
|
31379
|
-
|
|
31625
|
+
) : filteredWallets.length === 0 ? /* @__PURE__ */ jsxs44("div", { style: { textAlign: "center", padding: `${spacing[8]} 0` }, children: [
|
|
31626
|
+
/* @__PURE__ */ jsx55("div", { style: { fontSize: "2.5rem", marginBottom: spacing[4] }, children: "\u{1F45B}" }),
|
|
31627
|
+
/* @__PURE__ */ jsx55(
|
|
31628
|
+
"h3",
|
|
31629
|
+
{
|
|
31630
|
+
style: {
|
|
31631
|
+
fontSize: fontSize.lg,
|
|
31632
|
+
fontWeight: fontWeight.semibold,
|
|
31633
|
+
color: colors.foreground,
|
|
31634
|
+
marginBottom: spacing[2]
|
|
31635
|
+
},
|
|
31636
|
+
children: "No Wallets Found"
|
|
31637
|
+
}
|
|
31638
|
+
),
|
|
31639
|
+
/* @__PURE__ */ jsx55(
|
|
31640
|
+
"p",
|
|
31641
|
+
{
|
|
31642
|
+
style: {
|
|
31643
|
+
fontSize: fontSize.sm,
|
|
31644
|
+
color: colors.mutedForeground,
|
|
31645
|
+
marginBottom: spacing[4]
|
|
31646
|
+
},
|
|
31647
|
+
children: "Please install a web3 wallet to continue."
|
|
31648
|
+
}
|
|
31649
|
+
),
|
|
31650
|
+
/* @__PURE__ */ jsx55(
|
|
31651
|
+
"a",
|
|
31652
|
+
{
|
|
31653
|
+
href: "https://metamask.io/download/",
|
|
31654
|
+
target: "_blank",
|
|
31655
|
+
rel: "noopener noreferrer",
|
|
31656
|
+
style: {
|
|
31657
|
+
display: "inline-flex",
|
|
31658
|
+
alignItems: "center",
|
|
31659
|
+
justifyContent: "center",
|
|
31660
|
+
padding: `${spacing[2]} ${spacing[4]}`,
|
|
31661
|
+
borderRadius: borderRadius.lg,
|
|
31662
|
+
backgroundColor: colors.primary,
|
|
31663
|
+
color: colors.primaryForeground,
|
|
31664
|
+
fontSize: fontSize.sm,
|
|
31665
|
+
fontWeight: fontWeight.medium,
|
|
31666
|
+
textDecoration: "none"
|
|
31667
|
+
},
|
|
31668
|
+
children: "Install MetaMask"
|
|
31669
|
+
}
|
|
31670
|
+
)
|
|
31671
|
+
] }) : /* @__PURE__ */ jsx55(
|
|
31672
|
+
"div",
|
|
31380
31673
|
{
|
|
31381
31674
|
style: {
|
|
31382
|
-
|
|
31383
|
-
|
|
31384
|
-
|
|
31675
|
+
display: "flex",
|
|
31676
|
+
flexDirection: "column",
|
|
31677
|
+
gap: spacing[3]
|
|
31385
31678
|
},
|
|
31386
|
-
children:
|
|
31679
|
+
children: filteredWallets.map((wallet) => {
|
|
31680
|
+
const isWalletConnected = managerConnected && walletMetaId === wallet.meta.id;
|
|
31681
|
+
const isConnecting = connectingId === wallet.meta.id && walletStatus === "connecting";
|
|
31682
|
+
return /* @__PURE__ */ jsxs44(
|
|
31683
|
+
"div",
|
|
31684
|
+
{
|
|
31685
|
+
style: mergeStyles(
|
|
31686
|
+
{
|
|
31687
|
+
width: "100%",
|
|
31688
|
+
display: "flex",
|
|
31689
|
+
alignItems: "center",
|
|
31690
|
+
gap: spacing[4],
|
|
31691
|
+
padding: spacing[4],
|
|
31692
|
+
borderRadius: borderRadius["2xl"],
|
|
31693
|
+
backgroundColor: colors.card,
|
|
31694
|
+
border: `1px solid ${colors.border}`
|
|
31695
|
+
},
|
|
31696
|
+
isWalletConnected && {
|
|
31697
|
+
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
31698
|
+
border: `1px solid ${colors.primary}`
|
|
31699
|
+
}
|
|
31700
|
+
),
|
|
31701
|
+
children: [
|
|
31702
|
+
/* @__PURE__ */ jsx55(
|
|
31703
|
+
"div",
|
|
31704
|
+
{
|
|
31705
|
+
style: {
|
|
31706
|
+
width: "3rem",
|
|
31707
|
+
height: "3rem",
|
|
31708
|
+
borderRadius: borderRadius.xl,
|
|
31709
|
+
backgroundColor: colors.muted,
|
|
31710
|
+
display: "flex",
|
|
31711
|
+
alignItems: "center",
|
|
31712
|
+
justifyContent: "center",
|
|
31713
|
+
overflow: "hidden",
|
|
31714
|
+
flexShrink: 0
|
|
31715
|
+
},
|
|
31716
|
+
children: wallet.meta.logo ? /* @__PURE__ */ jsx55(
|
|
31717
|
+
"img",
|
|
31718
|
+
{
|
|
31719
|
+
src: wallet.meta.logo,
|
|
31720
|
+
alt: wallet.meta.name,
|
|
31721
|
+
style: {
|
|
31722
|
+
width: "2rem",
|
|
31723
|
+
height: "2rem",
|
|
31724
|
+
objectFit: "contain"
|
|
31725
|
+
}
|
|
31726
|
+
}
|
|
31727
|
+
) : wallet.detail?.info?.icon ? /* @__PURE__ */ jsx55(
|
|
31728
|
+
"img",
|
|
31729
|
+
{
|
|
31730
|
+
src: wallet.detail.info.icon,
|
|
31731
|
+
alt: wallet.meta.name,
|
|
31732
|
+
style: {
|
|
31733
|
+
width: "2rem",
|
|
31734
|
+
height: "2rem",
|
|
31735
|
+
objectFit: "contain"
|
|
31736
|
+
}
|
|
31737
|
+
}
|
|
31738
|
+
) : /* @__PURE__ */ jsx55("span", { style: { fontSize: "1.5rem" }, children: wallet.meta.emoji || "\u{1F45B}" })
|
|
31739
|
+
}
|
|
31740
|
+
),
|
|
31741
|
+
/* @__PURE__ */ jsxs44("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
31742
|
+
/* @__PURE__ */ jsx55(
|
|
31743
|
+
"p",
|
|
31744
|
+
{
|
|
31745
|
+
style: {
|
|
31746
|
+
fontWeight: fontWeight.semibold,
|
|
31747
|
+
color: colors.foreground
|
|
31748
|
+
},
|
|
31749
|
+
children: wallet.meta.name
|
|
31750
|
+
}
|
|
31751
|
+
),
|
|
31752
|
+
isWalletConnected && walletAddress && /* @__PURE__ */ jsxs44(
|
|
31753
|
+
"p",
|
|
31754
|
+
{
|
|
31755
|
+
style: {
|
|
31756
|
+
fontSize: fontSize.xs,
|
|
31757
|
+
color: colors.mutedForeground
|
|
31758
|
+
},
|
|
31759
|
+
children: [
|
|
31760
|
+
walletAddress.slice(0, 6),
|
|
31761
|
+
"...",
|
|
31762
|
+
walletAddress.slice(-4)
|
|
31763
|
+
]
|
|
31764
|
+
}
|
|
31765
|
+
)
|
|
31766
|
+
] }),
|
|
31767
|
+
isConnecting ? /* @__PURE__ */ jsx55(
|
|
31768
|
+
"div",
|
|
31769
|
+
{
|
|
31770
|
+
style: {
|
|
31771
|
+
width: "1.25rem",
|
|
31772
|
+
height: "1.25rem",
|
|
31773
|
+
border: `2px solid ${colors.mutedForeground}`,
|
|
31774
|
+
borderTopColor: "transparent",
|
|
31775
|
+
borderRadius: "9999px",
|
|
31776
|
+
animation: "tw-spin 1s linear infinite",
|
|
31777
|
+
flexShrink: 0
|
|
31778
|
+
}
|
|
31779
|
+
}
|
|
31780
|
+
) : isWalletConnected ? /* @__PURE__ */ jsx55(
|
|
31781
|
+
"button",
|
|
31782
|
+
{
|
|
31783
|
+
onClick: handleDisconnect,
|
|
31784
|
+
style: {
|
|
31785
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31786
|
+
borderRadius: "9999px",
|
|
31787
|
+
backgroundColor: "rgba(239,68,68,0.1)",
|
|
31788
|
+
color: "#ef4444",
|
|
31789
|
+
fontSize: fontSize.xs,
|
|
31790
|
+
fontWeight: fontWeight.medium,
|
|
31791
|
+
border: 0,
|
|
31792
|
+
cursor: "pointer",
|
|
31793
|
+
flexShrink: 0
|
|
31794
|
+
},
|
|
31795
|
+
children: "Disconnect"
|
|
31796
|
+
}
|
|
31797
|
+
) : /* @__PURE__ */ jsx55(
|
|
31798
|
+
"button",
|
|
31799
|
+
{
|
|
31800
|
+
onClick: () => void handleClick(wallet),
|
|
31801
|
+
disabled: walletStatus === "connecting",
|
|
31802
|
+
style: mergeStyles(
|
|
31803
|
+
{
|
|
31804
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31805
|
+
borderRadius: "9999px",
|
|
31806
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
31807
|
+
color: colors.primary,
|
|
31808
|
+
fontSize: fontSize.xs,
|
|
31809
|
+
fontWeight: fontWeight.medium,
|
|
31810
|
+
border: 0,
|
|
31811
|
+
cursor: "pointer",
|
|
31812
|
+
flexShrink: 0
|
|
31813
|
+
},
|
|
31814
|
+
walletStatus === "connecting" && {
|
|
31815
|
+
opacity: 0.5,
|
|
31816
|
+
cursor: "not-allowed"
|
|
31817
|
+
}
|
|
31818
|
+
),
|
|
31819
|
+
children: "Connect"
|
|
31820
|
+
}
|
|
31821
|
+
)
|
|
31822
|
+
]
|
|
31823
|
+
},
|
|
31824
|
+
wallet.meta.id
|
|
31825
|
+
);
|
|
31826
|
+
})
|
|
31387
31827
|
}
|
|
31388
31828
|
),
|
|
31389
|
-
/* @__PURE__ */
|
|
31390
|
-
|
|
31391
|
-
|
|
31392
|
-
|
|
31393
|
-
|
|
31394
|
-
|
|
31395
|
-
|
|
31396
|
-
|
|
31397
|
-
|
|
31398
|
-
|
|
31399
|
-
|
|
31400
|
-
|
|
31401
|
-
|
|
31402
|
-
color: colors.primaryForeground,
|
|
31403
|
-
fontSize: fontSize.sm,
|
|
31404
|
-
fontWeight: fontWeight.medium,
|
|
31405
|
-
textDecoration: "none"
|
|
31406
|
-
},
|
|
31407
|
-
children: "Install MetaMask"
|
|
31408
|
-
}
|
|
31409
|
-
)
|
|
31410
|
-
] }) : /* @__PURE__ */ jsx55(
|
|
31411
|
-
"div",
|
|
31412
|
-
{
|
|
31413
|
-
style: {
|
|
31414
|
-
display: "flex",
|
|
31415
|
-
flexDirection: "column",
|
|
31416
|
-
gap: spacing[3]
|
|
31417
|
-
},
|
|
31418
|
-
children: detected.map((wallet) => {
|
|
31419
|
-
const isConnecting = connectingId === wallet.meta.id;
|
|
31420
|
-
const isConnected = walletStatus === "connected" && connectingId === null && walletAddress !== null && connectedWalletId === wallet.meta.id;
|
|
31829
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(Fragment7, { children: [
|
|
31830
|
+
/* @__PURE__ */ jsx55(
|
|
31831
|
+
"div",
|
|
31832
|
+
{
|
|
31833
|
+
style: {
|
|
31834
|
+
height: 1,
|
|
31835
|
+
backgroundColor: colors.border,
|
|
31836
|
+
margin: `${spacing[3]} 0`
|
|
31837
|
+
}
|
|
31838
|
+
}
|
|
31839
|
+
),
|
|
31840
|
+
(() => {
|
|
31841
|
+
const wcConnected = managerConnected && connectedVia === "walletconnect";
|
|
31421
31842
|
return /* @__PURE__ */ jsxs44(
|
|
31422
31843
|
"div",
|
|
31423
31844
|
{
|
|
@@ -31430,13 +31851,15 @@ function SwapWalletSelector({
|
|
|
31430
31851
|
padding: spacing[4],
|
|
31431
31852
|
borderRadius: borderRadius["2xl"],
|
|
31432
31853
|
backgroundColor: colors.card,
|
|
31433
|
-
border: `1px solid ${colors.border}
|
|
31854
|
+
border: `1px solid ${colors.border}`,
|
|
31855
|
+
cursor: "pointer"
|
|
31434
31856
|
},
|
|
31435
|
-
|
|
31857
|
+
wcConnected && {
|
|
31436
31858
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
31437
31859
|
border: `1px solid ${colors.primary}`
|
|
31438
31860
|
}
|
|
31439
31861
|
),
|
|
31862
|
+
onClick: !wcConnected ? () => void handleWalletConnect() : void 0,
|
|
31440
31863
|
children: [
|
|
31441
31864
|
/* @__PURE__ */ jsx55(
|
|
31442
31865
|
"div",
|
|
@@ -31449,35 +31872,24 @@ function SwapWalletSelector({
|
|
|
31449
31872
|
display: "flex",
|
|
31450
31873
|
alignItems: "center",
|
|
31451
31874
|
justifyContent: "center",
|
|
31452
|
-
overflow: "hidden",
|
|
31453
31875
|
flexShrink: 0
|
|
31454
31876
|
},
|
|
31455
|
-
children:
|
|
31456
|
-
"
|
|
31457
|
-
{
|
|
31458
|
-
src: wallet.meta.logo,
|
|
31459
|
-
alt: wallet.meta.name,
|
|
31460
|
-
style: {
|
|
31461
|
-
width: "2rem",
|
|
31462
|
-
height: "2rem",
|
|
31463
|
-
objectFit: "contain"
|
|
31464
|
-
}
|
|
31465
|
-
}
|
|
31466
|
-
) : wallet.detail?.info?.icon ? /* @__PURE__ */ jsx55(
|
|
31467
|
-
"img",
|
|
31877
|
+
children: /* @__PURE__ */ jsx55(
|
|
31878
|
+
"svg",
|
|
31468
31879
|
{
|
|
31469
|
-
src: wallet.detail.info.icon,
|
|
31470
|
-
alt: wallet.meta.name,
|
|
31471
31880
|
style: {
|
|
31472
|
-
width: "
|
|
31473
|
-
height: "
|
|
31474
|
-
|
|
31475
|
-
}
|
|
31881
|
+
width: "1.5rem",
|
|
31882
|
+
height: "1.5rem",
|
|
31883
|
+
color: colors.blue[500]
|
|
31884
|
+
},
|
|
31885
|
+
viewBox: "0 0 24 24",
|
|
31886
|
+
fill: "currentColor",
|
|
31887
|
+
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" })
|
|
31476
31888
|
}
|
|
31477
|
-
)
|
|
31889
|
+
)
|
|
31478
31890
|
}
|
|
31479
31891
|
),
|
|
31480
|
-
/* @__PURE__ */ jsxs44("div", { style: { flex: 1 }, children: [
|
|
31892
|
+
/* @__PURE__ */ jsxs44("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
31481
31893
|
/* @__PURE__ */ jsx55(
|
|
31482
31894
|
"p",
|
|
31483
31895
|
{
|
|
@@ -31485,10 +31897,10 @@ function SwapWalletSelector({
|
|
|
31485
31897
|
fontWeight: fontWeight.semibold,
|
|
31486
31898
|
color: colors.foreground
|
|
31487
31899
|
},
|
|
31488
|
-
children:
|
|
31900
|
+
children: "WalletConnect"
|
|
31489
31901
|
}
|
|
31490
31902
|
),
|
|
31491
|
-
|
|
31903
|
+
wcConnected && walletAddress && /* @__PURE__ */ jsxs44(
|
|
31492
31904
|
"p",
|
|
31493
31905
|
{
|
|
31494
31906
|
style: {
|
|
@@ -31503,7 +31915,7 @@ function SwapWalletSelector({
|
|
|
31503
31915
|
}
|
|
31504
31916
|
)
|
|
31505
31917
|
] }),
|
|
31506
|
-
|
|
31918
|
+
wcConnecting ? /* @__PURE__ */ jsx55(
|
|
31507
31919
|
"div",
|
|
31508
31920
|
{
|
|
31509
31921
|
style: {
|
|
@@ -31512,40 +31924,58 @@ function SwapWalletSelector({
|
|
|
31512
31924
|
border: `2px solid ${colors.mutedForeground}`,
|
|
31513
31925
|
borderTopColor: "transparent",
|
|
31514
31926
|
borderRadius: "9999px",
|
|
31515
|
-
animation: "tw-spin 1s linear infinite"
|
|
31927
|
+
animation: "tw-spin 1s linear infinite",
|
|
31928
|
+
flexShrink: 0
|
|
31516
31929
|
}
|
|
31517
31930
|
}
|
|
31931
|
+
) : wcConnected ? /* @__PURE__ */ jsx55(
|
|
31932
|
+
"button",
|
|
31933
|
+
{
|
|
31934
|
+
onClick: (e2) => {
|
|
31935
|
+
e2.stopPropagation();
|
|
31936
|
+
handleDisconnect();
|
|
31937
|
+
},
|
|
31938
|
+
style: {
|
|
31939
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31940
|
+
borderRadius: "9999px",
|
|
31941
|
+
backgroundColor: "rgba(239,68,68,0.1)",
|
|
31942
|
+
color: "#ef4444",
|
|
31943
|
+
fontSize: fontSize.xs,
|
|
31944
|
+
fontWeight: fontWeight.medium,
|
|
31945
|
+
border: 0,
|
|
31946
|
+
cursor: "pointer",
|
|
31947
|
+
flexShrink: 0
|
|
31948
|
+
},
|
|
31949
|
+
children: "Disconnect"
|
|
31950
|
+
}
|
|
31518
31951
|
) : /* @__PURE__ */ jsx55(
|
|
31519
31952
|
"button",
|
|
31520
31953
|
{
|
|
31521
|
-
onClick: () =>
|
|
31522
|
-
|
|
31523
|
-
|
|
31524
|
-
|
|
31525
|
-
|
|
31526
|
-
|
|
31527
|
-
|
|
31528
|
-
|
|
31529
|
-
|
|
31530
|
-
|
|
31531
|
-
|
|
31532
|
-
|
|
31533
|
-
|
|
31534
|
-
|
|
31535
|
-
|
|
31536
|
-
|
|
31537
|
-
}
|
|
31538
|
-
),
|
|
31954
|
+
onClick: (e2) => {
|
|
31955
|
+
e2.stopPropagation();
|
|
31956
|
+
void handleWalletConnect();
|
|
31957
|
+
},
|
|
31958
|
+
disabled: wcConnecting,
|
|
31959
|
+
style: {
|
|
31960
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31961
|
+
borderRadius: "9999px",
|
|
31962
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
31963
|
+
color: colors.primary,
|
|
31964
|
+
fontSize: fontSize.xs,
|
|
31965
|
+
fontWeight: fontWeight.medium,
|
|
31966
|
+
border: 0,
|
|
31967
|
+
cursor: "pointer",
|
|
31968
|
+
flexShrink: 0
|
|
31969
|
+
},
|
|
31539
31970
|
children: "Connect"
|
|
31540
31971
|
}
|
|
31541
31972
|
)
|
|
31542
31973
|
]
|
|
31543
|
-
}
|
|
31544
|
-
wallet.meta.id
|
|
31974
|
+
}
|
|
31545
31975
|
);
|
|
31546
|
-
})
|
|
31547
|
-
}
|
|
31548
|
-
|
|
31976
|
+
})()
|
|
31977
|
+
] })
|
|
31978
|
+
] })
|
|
31549
31979
|
] });
|
|
31550
31980
|
}
|
|
31551
31981
|
var init_SwapWalletSelector = __esm({
|
|
@@ -31554,6 +31984,7 @@ var init_SwapWalletSelector = __esm({
|
|
|
31554
31984
|
init_styles();
|
|
31555
31985
|
init_utils();
|
|
31556
31986
|
init_wallets();
|
|
31987
|
+
init_config2();
|
|
31557
31988
|
init_Toast();
|
|
31558
31989
|
}
|
|
31559
31990
|
});
|
|
@@ -31637,11 +32068,11 @@ import {
|
|
|
31637
32068
|
Suspense as Suspense2,
|
|
31638
32069
|
useCallback as useCallback22,
|
|
31639
32070
|
useEffect as useEffect30,
|
|
31640
|
-
useMemo as
|
|
32071
|
+
useMemo as useMemo26,
|
|
31641
32072
|
useRef as useRef17,
|
|
31642
32073
|
useState as useState28
|
|
31643
32074
|
} from "react";
|
|
31644
|
-
import { Fragment as
|
|
32075
|
+
import { Fragment as Fragment8, jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
31645
32076
|
function fmtAmount(n, max = 6) {
|
|
31646
32077
|
if (!isFinite(n) || n === 0) return "0";
|
|
31647
32078
|
return n.toLocaleString(void 0, { maximumFractionDigits: max });
|
|
@@ -31789,21 +32220,21 @@ function SwapMode({
|
|
|
31789
32220
|
isLoading: chainsLoading,
|
|
31790
32221
|
error: chainsError
|
|
31791
32222
|
} = useChains();
|
|
31792
|
-
const allowedDestChainIds =
|
|
32223
|
+
const allowedDestChainIds = useMemo26(() => {
|
|
31793
32224
|
if (!allowedDestTokens || allowedDestTokens.length === 0) return null;
|
|
31794
32225
|
return new Set(allowedDestTokens.map((t) => t.chainId));
|
|
31795
32226
|
}, [allowedDestTokens]);
|
|
31796
|
-
const toPopularChains =
|
|
32227
|
+
const toPopularChains = useMemo26(
|
|
31797
32228
|
() => allowedDestChainIds ? popularChains.filter(
|
|
31798
32229
|
(c) => allowedDestChainIds.has(Number(c.chainId))
|
|
31799
32230
|
) : popularChains,
|
|
31800
32231
|
[popularChains, allowedDestChainIds]
|
|
31801
32232
|
);
|
|
31802
|
-
const toOtherChains =
|
|
32233
|
+
const toOtherChains = useMemo26(
|
|
31803
32234
|
() => allowedDestChainIds ? otherChains.filter((c) => allowedDestChainIds.has(Number(c.chainId))) : otherChains,
|
|
31804
32235
|
[otherChains, allowedDestChainIds]
|
|
31805
32236
|
);
|
|
31806
|
-
const allChains =
|
|
32237
|
+
const allChains = useMemo26(
|
|
31807
32238
|
() => [...popularChains, ...otherChains],
|
|
31808
32239
|
[popularChains, otherChains]
|
|
31809
32240
|
);
|
|
@@ -31847,7 +32278,7 @@ function SwapMode({
|
|
|
31847
32278
|
(c) => setFromChain(c),
|
|
31848
32279
|
[]
|
|
31849
32280
|
);
|
|
31850
|
-
const { yourWalletTokens } = useWalletTokenState({
|
|
32281
|
+
const { yourWalletTokens, reloadWalletTokens } = useWalletTokenState({
|
|
31851
32282
|
walletAddress,
|
|
31852
32283
|
selectedChain: fromChain,
|
|
31853
32284
|
setSelectedChain: setFromChainStable,
|
|
@@ -31856,18 +32287,18 @@ function SwapMode({
|
|
|
31856
32287
|
});
|
|
31857
32288
|
const route = useSwapRoute();
|
|
31858
32289
|
const execution = useSwapExecution(fromChain);
|
|
31859
|
-
const fromTokenPriceUSD =
|
|
32290
|
+
const fromTokenPriceUSD = useMemo26(() => {
|
|
31860
32291
|
const p = fromToken?.usdPrice;
|
|
31861
32292
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
31862
32293
|
}, [fromToken]);
|
|
31863
32294
|
const hasFromUsdPrice = fromTokenPriceUSD > 0;
|
|
31864
|
-
const toTokenPriceUSD =
|
|
32295
|
+
const toTokenPriceUSD = useMemo26(() => {
|
|
31865
32296
|
const p = toToken?.usdPrice;
|
|
31866
32297
|
return typeof p === "number" && Number.isFinite(p) && p > 0 ? p : 0;
|
|
31867
32298
|
}, [toToken]);
|
|
31868
32299
|
const hasToUsdPrice = toTokenPriceUSD > 0;
|
|
31869
32300
|
const rawSellNum = parseFloat(amount) || 0;
|
|
31870
|
-
const usdSellNum =
|
|
32301
|
+
const usdSellNum = useMemo26(() => {
|
|
31871
32302
|
if (amountInputMode === "usd") return rawSellNum / currencyRate;
|
|
31872
32303
|
return hasFromUsdPrice ? rawSellNum * fromTokenPriceUSD : 0;
|
|
31873
32304
|
}, [
|
|
@@ -31877,7 +32308,7 @@ function SwapMode({
|
|
|
31877
32308
|
hasFromUsdPrice,
|
|
31878
32309
|
fromTokenPriceUSD
|
|
31879
32310
|
]);
|
|
31880
|
-
const tokenSellNum =
|
|
32311
|
+
const tokenSellNum = useMemo26(() => {
|
|
31881
32312
|
if (amountInputMode === "usd") {
|
|
31882
32313
|
return hasFromUsdPrice && fromTokenPriceUSD > 0 ? usdSellNum / fromTokenPriceUSD : 0;
|
|
31883
32314
|
}
|
|
@@ -31889,7 +32320,7 @@ function SwapMode({
|
|
|
31889
32320
|
hasFromUsdPrice,
|
|
31890
32321
|
fromTokenPriceUSD
|
|
31891
32322
|
]);
|
|
31892
|
-
const tokenAmountStr =
|
|
32323
|
+
const tokenAmountStr = useMemo26(() => {
|
|
31893
32324
|
if (tokenSellNum <= 0) return "";
|
|
31894
32325
|
const decimals = fromToken?.decimals ?? 18;
|
|
31895
32326
|
return truncateDecimal(tokenSellNum, Math.min(decimals, 18));
|
|
@@ -32037,7 +32468,8 @@ function SwapMode({
|
|
|
32037
32468
|
setCompletedAt(null);
|
|
32038
32469
|
setCopiedHash(null);
|
|
32039
32470
|
setStage("home");
|
|
32040
|
-
|
|
32471
|
+
reloadWalletTokens();
|
|
32472
|
+
}, [execution, route, reloadWalletTokens]);
|
|
32041
32473
|
const handleSwapBack = useCallback22(() => {
|
|
32042
32474
|
const prevFrom = fromToken;
|
|
32043
32475
|
const prevFromChain = fromChain;
|
|
@@ -32052,7 +32484,16 @@ function SwapMode({
|
|
|
32052
32484
|
setCompletedAt(null);
|
|
32053
32485
|
setCopiedHash(null);
|
|
32054
32486
|
setStage("home");
|
|
32055
|
-
|
|
32487
|
+
reloadWalletTokens();
|
|
32488
|
+
}, [
|
|
32489
|
+
fromToken,
|
|
32490
|
+
fromChain,
|
|
32491
|
+
toToken,
|
|
32492
|
+
toChain,
|
|
32493
|
+
execution,
|
|
32494
|
+
route,
|
|
32495
|
+
reloadWalletTokens
|
|
32496
|
+
]);
|
|
32056
32497
|
const handleCopyHash = useCallback22((hash) => {
|
|
32057
32498
|
if (!navigator?.clipboard?.writeText) return;
|
|
32058
32499
|
void navigator.clipboard.writeText(hash).then(() => {
|
|
@@ -32086,7 +32527,7 @@ function SwapMode({
|
|
|
32086
32527
|
fromToken?.decimals,
|
|
32087
32528
|
route
|
|
32088
32529
|
]);
|
|
32089
|
-
const fromBalance =
|
|
32530
|
+
const fromBalance = useMemo26(() => {
|
|
32090
32531
|
const walletToken = fromToken;
|
|
32091
32532
|
if (!walletToken || !("balance" in walletToken)) return null;
|
|
32092
32533
|
const raw = walletToken.balance;
|
|
@@ -32096,7 +32537,7 @@ function SwapMode({
|
|
|
32096
32537
|
return Number.isFinite(n) ? n : null;
|
|
32097
32538
|
}, [fromToken]);
|
|
32098
32539
|
const balanceUsd = fromBalance !== null && hasFromUsdPrice ? fromBalance * fromTokenPriceUSD : null;
|
|
32099
|
-
const estimatedToAmount =
|
|
32540
|
+
const estimatedToAmount = useMemo26(() => {
|
|
32100
32541
|
if (tokenSellNum <= 0 || !hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
32101
32542
|
return tokenSellNum * (fromTokenPriceUSD / toTokenPriceUSD);
|
|
32102
32543
|
}, [
|
|
@@ -32106,10 +32547,10 @@ function SwapMode({
|
|
|
32106
32547
|
hasFromUsdPrice,
|
|
32107
32548
|
hasToUsdPrice
|
|
32108
32549
|
]);
|
|
32109
|
-
const backendToUsdStr =
|
|
32550
|
+
const backendToUsdStr = useMemo26(() => {
|
|
32110
32551
|
return route.data?.finalExchangeRate?.toAmountMinUSD ?? route.data?.route?.estimate?.toAmountMinUsd ?? route.data?.route?.estimate?.toAmountUsd ?? null;
|
|
32111
32552
|
}, [route.data]);
|
|
32112
|
-
const toAmount =
|
|
32553
|
+
const toAmount = useMemo26(() => {
|
|
32113
32554
|
if (backendToUsdStr && toTokenPriceUSD > 0) {
|
|
32114
32555
|
const usd = parseFloat(backendToUsdStr);
|
|
32115
32556
|
if (Number.isFinite(usd) && usd > 0) return usd / toTokenPriceUSD;
|
|
@@ -32135,7 +32576,7 @@ function SwapMode({
|
|
|
32135
32576
|
estimatedToAmount
|
|
32136
32577
|
]);
|
|
32137
32578
|
const fromUsd = usdSellNum;
|
|
32138
|
-
const toUsd =
|
|
32579
|
+
const toUsd = useMemo26(() => {
|
|
32139
32580
|
if (backendToUsdStr) {
|
|
32140
32581
|
const n = parseFloat(backendToUsdStr);
|
|
32141
32582
|
if (Number.isFinite(n) && n > 0) return n;
|
|
@@ -32146,12 +32587,12 @@ function SwapMode({
|
|
|
32146
32587
|
const isEstimate = !route.data;
|
|
32147
32588
|
const USD_EPSILON = 1e-3;
|
|
32148
32589
|
const displayToUsd = toUsd > USD_EPSILON ? toUsd : estimatedToAmount !== null && hasToUsdPrice ? estimatedToAmount * toTokenPriceUSD : 0;
|
|
32149
|
-
const priceImpact =
|
|
32590
|
+
const priceImpact = useMemo26(() => {
|
|
32150
32591
|
if (!route.data || fromUsd < 0.01 || displayToUsd < 0.01) return null;
|
|
32151
32592
|
const impact = 1 - displayToUsd / fromUsd;
|
|
32152
32593
|
return impact > 1e-3 ? impact : null;
|
|
32153
32594
|
}, [route.data, fromUsd, displayToUsd]);
|
|
32154
|
-
const routePath =
|
|
32595
|
+
const routePath = useMemo26(() => {
|
|
32155
32596
|
if (!route.data) return null;
|
|
32156
32597
|
const provider = route.data.route?.provider;
|
|
32157
32598
|
const steps = route.data.route?.steps;
|
|
@@ -32178,19 +32619,19 @@ function SwapMode({
|
|
|
32178
32619
|
return null;
|
|
32179
32620
|
}, [route.data, fromToken?.symbol, toToken?.symbol]);
|
|
32180
32621
|
const isGasSponsored = !!route.data?.sponsorship;
|
|
32181
|
-
const networkCostUsd =
|
|
32622
|
+
const networkCostUsd = useMemo26(() => {
|
|
32182
32623
|
const fees = route.data?.route?.estimate?.fees;
|
|
32183
32624
|
if (!fees?.length) return null;
|
|
32184
32625
|
const gasTotal = fees.filter((f) => f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
32185
32626
|
return gasTotal > 0 ? gasTotal : null;
|
|
32186
32627
|
}, [route.data]);
|
|
32187
|
-
const protocolFeeUsd =
|
|
32628
|
+
const protocolFeeUsd = useMemo26(() => {
|
|
32188
32629
|
const fees = route.data?.route?.estimate?.fees;
|
|
32189
32630
|
if (!fees?.length) return null;
|
|
32190
32631
|
const total = fees.filter((f) => !f.type?.toLowerCase().includes("gas")).reduce((sum, f) => sum + (Number(f.amountUsd) || 0), 0);
|
|
32191
32632
|
return total > 0 ? total : null;
|
|
32192
32633
|
}, [route.data]);
|
|
32193
|
-
const exchangeRate =
|
|
32634
|
+
const exchangeRate = useMemo26(() => {
|
|
32194
32635
|
if (!hasFromUsdPrice || !hasToUsdPrice) return null;
|
|
32195
32636
|
return toTokenPriceUSD / fromTokenPriceUSD;
|
|
32196
32637
|
}, [fromTokenPriceUSD, toTokenPriceUSD, hasFromUsdPrice, hasToUsdPrice]);
|
|
@@ -32811,7 +33252,7 @@ function SwapMode({
|
|
|
32811
33252
|
padding: 0,
|
|
32812
33253
|
transition: "color 0.15s"
|
|
32813
33254
|
},
|
|
32814
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs45(
|
|
33255
|
+
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs45(Fragment8, { children: [
|
|
32815
33256
|
txHash.slice(0, 6),
|
|
32816
33257
|
"\u2026",
|
|
32817
33258
|
txHash.slice(-4),
|
|
@@ -33860,7 +34301,7 @@ function SwapMode({
|
|
|
33860
34301
|
) : /* @__PURE__ */ jsx56("span", { style: { color: colors.mutedForeground }, children: "\u2014" })
|
|
33861
34302
|
}
|
|
33862
34303
|
),
|
|
33863
|
-
showReviewDetails && /* @__PURE__ */ jsxs45(
|
|
34304
|
+
showReviewDetails && /* @__PURE__ */ jsxs45(Fragment8, { children: [
|
|
33864
34305
|
/* @__PURE__ */ jsx56(
|
|
33865
34306
|
ReviewDetailRow,
|
|
33866
34307
|
{
|
|
@@ -34434,9 +34875,15 @@ function SwapMode({
|
|
|
34434
34875
|
fromToken.address,
|
|
34435
34876
|
fromChainType ?? ""
|
|
34436
34877
|
) || isZeroAddrLike(fromToken.address, fromChainType));
|
|
34437
|
-
const
|
|
34878
|
+
const isSolana = normalizeChainType2(fromChain) === "solana";
|
|
34879
|
+
const effectiveAmount = (() => {
|
|
34880
|
+
if (!isNative || p.value !== 1)
|
|
34881
|
+
return fromBalance * p.value;
|
|
34882
|
+
if (isSolana) return Math.max(0, fromBalance - 0.01);
|
|
34883
|
+
return fromBalance * 0.995;
|
|
34884
|
+
})();
|
|
34438
34885
|
if (amountInputMode === "usd" && hasFromUsdPrice) {
|
|
34439
|
-
const fiatVal =
|
|
34886
|
+
const fiatVal = effectiveAmount * fromTokenPriceUSD * currencyRate;
|
|
34440
34887
|
const dp = fiatVal > 0 ? Math.min(
|
|
34441
34888
|
8,
|
|
34442
34889
|
Math.max(
|
|
@@ -34448,7 +34895,7 @@ function SwapMode({
|
|
|
34448
34895
|
} else {
|
|
34449
34896
|
setAmount(
|
|
34450
34897
|
truncateDecimal(
|
|
34451
|
-
|
|
34898
|
+
effectiveAmount,
|
|
34452
34899
|
Math.min(decimals, 6)
|
|
34453
34900
|
)
|
|
34454
34901
|
);
|
|
@@ -35743,7 +36190,7 @@ import {
|
|
|
35743
36190
|
useImperativeHandle,
|
|
35744
36191
|
forwardRef
|
|
35745
36192
|
} from "react";
|
|
35746
|
-
import { Fragment as
|
|
36193
|
+
import { Fragment as Fragment9, jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
35747
36194
|
function WidgetContent({
|
|
35748
36195
|
style,
|
|
35749
36196
|
onStateChange,
|
|
@@ -35825,7 +36272,7 @@ function WidgetInner({
|
|
|
35825
36272
|
const handleRefresh = useCallback23(() => {
|
|
35826
36273
|
revalidate?.();
|
|
35827
36274
|
}, [revalidate]);
|
|
35828
|
-
return /* @__PURE__ */ jsxs46(
|
|
36275
|
+
return /* @__PURE__ */ jsxs46(Fragment9, { children: [
|
|
35829
36276
|
/* @__PURE__ */ jsxs46(WidgetContainer, { theme: effectiveTheme, style, children: [
|
|
35830
36277
|
/* @__PURE__ */ jsx57(
|
|
35831
36278
|
WidgetContent,
|