@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.cjs
CHANGED
|
@@ -593,7 +593,7 @@ var init_constants = __esm({
|
|
|
593
593
|
"src/constants.ts"() {
|
|
594
594
|
"use strict";
|
|
595
595
|
SDK_NAME = "@trustware/sdk";
|
|
596
|
-
SDK_VERSION = "1.1.8-staging.
|
|
596
|
+
SDK_VERSION = "1.1.8-staging.6";
|
|
597
597
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
598
598
|
GTM_ID = "GTM-TZDGNCXB";
|
|
599
599
|
API_PREFIX = "/api";
|
|
@@ -4349,6 +4349,134 @@ var init_sdkRpc = __esm({
|
|
|
4349
4349
|
});
|
|
4350
4350
|
|
|
4351
4351
|
// src/wallets/solana.ts
|
|
4352
|
+
function encodeBase58(bytes) {
|
|
4353
|
+
const digits = [0];
|
|
4354
|
+
for (const byte of bytes) {
|
|
4355
|
+
let carry = byte;
|
|
4356
|
+
for (let i = 0; i < digits.length; i++) {
|
|
4357
|
+
carry += digits[i] << 8;
|
|
4358
|
+
digits[i] = carry % 58;
|
|
4359
|
+
carry = carry / 58 | 0;
|
|
4360
|
+
}
|
|
4361
|
+
while (carry > 0) {
|
|
4362
|
+
digits.push(carry % 58);
|
|
4363
|
+
carry = carry / 58 | 0;
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
let result = "";
|
|
4367
|
+
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
|
|
4368
|
+
result += "1";
|
|
4369
|
+
}
|
|
4370
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
4371
|
+
result += BASE58_ALPHABET[digits[i]];
|
|
4372
|
+
}
|
|
4373
|
+
return result;
|
|
4374
|
+
}
|
|
4375
|
+
function collectWalletStandardWallets() {
|
|
4376
|
+
if (typeof window === "undefined") return [];
|
|
4377
|
+
const collected = [];
|
|
4378
|
+
const api = {
|
|
4379
|
+
register(...wallets) {
|
|
4380
|
+
collected.push(...wallets);
|
|
4381
|
+
return () => {
|
|
4382
|
+
};
|
|
4383
|
+
}
|
|
4384
|
+
};
|
|
4385
|
+
try {
|
|
4386
|
+
window.dispatchEvent(
|
|
4387
|
+
Object.assign(
|
|
4388
|
+
new Event("wallet-standard:app-ready", { bubbles: false }),
|
|
4389
|
+
{
|
|
4390
|
+
detail: api
|
|
4391
|
+
}
|
|
4392
|
+
)
|
|
4393
|
+
);
|
|
4394
|
+
} catch {
|
|
4395
|
+
}
|
|
4396
|
+
return collected;
|
|
4397
|
+
}
|
|
4398
|
+
function walletStandardToSolanaProvider(wallet) {
|
|
4399
|
+
let currentAccount = wallet.accounts[0] ?? null;
|
|
4400
|
+
const provider = {
|
|
4401
|
+
get isConnected() {
|
|
4402
|
+
return !!currentAccount;
|
|
4403
|
+
},
|
|
4404
|
+
get publicKey() {
|
|
4405
|
+
if (!currentAccount) return void 0;
|
|
4406
|
+
const addr = currentAccount.address;
|
|
4407
|
+
return { toString: () => addr };
|
|
4408
|
+
},
|
|
4409
|
+
async connect() {
|
|
4410
|
+
const feature = wallet.features["standard:connect"];
|
|
4411
|
+
if (!feature?.connect)
|
|
4412
|
+
throw new Error("Wallet Standard connect not available");
|
|
4413
|
+
const result = await feature.connect({ silent: false });
|
|
4414
|
+
currentAccount = result.accounts[0] ?? null;
|
|
4415
|
+
if (!currentAccount)
|
|
4416
|
+
throw new Error("No Solana account returned from MetaMask");
|
|
4417
|
+
return { publicKey: { toString: () => currentAccount.address } };
|
|
4418
|
+
},
|
|
4419
|
+
async disconnect() {
|
|
4420
|
+
const feature = wallet.features["standard:disconnect"];
|
|
4421
|
+
await feature?.disconnect?.();
|
|
4422
|
+
currentAccount = null;
|
|
4423
|
+
},
|
|
4424
|
+
async signAndSendTransaction(transaction, options) {
|
|
4425
|
+
const feature = wallet.features["solana:signAndSendTransaction"];
|
|
4426
|
+
if (!feature?.signAndSendTransaction || !currentAccount) {
|
|
4427
|
+
throw new Error("signAndSendTransaction not available");
|
|
4428
|
+
}
|
|
4429
|
+
const txBytes = transaction.serialize();
|
|
4430
|
+
const results = await feature.signAndSendTransaction({
|
|
4431
|
+
account: currentAccount,
|
|
4432
|
+
transaction: txBytes,
|
|
4433
|
+
chain: SOLANA_MAINNET_CHAIN,
|
|
4434
|
+
options
|
|
4435
|
+
});
|
|
4436
|
+
const sig = results[0]?.signature;
|
|
4437
|
+
if (!sig) throw new Error("No signature returned");
|
|
4438
|
+
return typeof sig === "string" ? sig : encodeBase58(sig);
|
|
4439
|
+
},
|
|
4440
|
+
async signTransaction(transaction) {
|
|
4441
|
+
const feature = wallet.features["solana:signTransaction"];
|
|
4442
|
+
if (!feature?.signTransaction || !currentAccount) {
|
|
4443
|
+
throw new Error("signTransaction not available");
|
|
4444
|
+
}
|
|
4445
|
+
const txBytes = transaction.serialize();
|
|
4446
|
+
const results = await feature.signTransaction({
|
|
4447
|
+
account: currentAccount,
|
|
4448
|
+
transaction: txBytes,
|
|
4449
|
+
chain: SOLANA_MAINNET_CHAIN
|
|
4450
|
+
});
|
|
4451
|
+
const signed = results[0]?.signedTransaction;
|
|
4452
|
+
if (!signed) throw new Error("No signed transaction returned");
|
|
4453
|
+
return { serialize: () => signed };
|
|
4454
|
+
},
|
|
4455
|
+
on() {
|
|
4456
|
+
},
|
|
4457
|
+
off() {
|
|
4458
|
+
},
|
|
4459
|
+
removeListener() {
|
|
4460
|
+
}
|
|
4461
|
+
};
|
|
4462
|
+
return provider;
|
|
4463
|
+
}
|
|
4464
|
+
function detectMetaMaskSolanaWallet(wallets) {
|
|
4465
|
+
const meta = wallets.find((w) => w.id === "metamask-solana");
|
|
4466
|
+
if (!meta) return [];
|
|
4467
|
+
const standardWallets = collectWalletStandardWallets();
|
|
4468
|
+
const mmWallet = standardWallets.find(
|
|
4469
|
+
(w) => w.name.toLowerCase().includes("metamask") && w.chains.some((c) => c.startsWith("solana:"))
|
|
4470
|
+
);
|
|
4471
|
+
if (!mmWallet) return [];
|
|
4472
|
+
return [
|
|
4473
|
+
{
|
|
4474
|
+
meta,
|
|
4475
|
+
provider: walletStandardToSolanaProvider(mmWallet),
|
|
4476
|
+
via: "solana-window"
|
|
4477
|
+
}
|
|
4478
|
+
];
|
|
4479
|
+
}
|
|
4352
4480
|
function getPublicKeyString(provider) {
|
|
4353
4481
|
const publicKey = provider?.publicKey;
|
|
4354
4482
|
if (!publicKey) return null;
|
|
@@ -4410,12 +4538,13 @@ function getSolanaProviders() {
|
|
|
4410
4538
|
}
|
|
4411
4539
|
function detectSolanaWallets(wallets) {
|
|
4412
4540
|
const providers = getSolanaProviders();
|
|
4413
|
-
|
|
4541
|
+
const windowDetected = SOLANA_WALLET_IDS.flatMap((walletId) => {
|
|
4414
4542
|
const provider = providers[walletId];
|
|
4415
4543
|
const meta = wallets.find((item) => item.id === walletId);
|
|
4416
4544
|
if (!provider || !meta) return [];
|
|
4417
4545
|
return [{ meta, provider, via: "solana-window" }];
|
|
4418
4546
|
});
|
|
4547
|
+
return [...windowDetected, ...detectMetaMaskSolanaWallet(wallets)];
|
|
4419
4548
|
}
|
|
4420
4549
|
function bindSolanaProviderEvents(provider, handlers) {
|
|
4421
4550
|
const onConnect = () => handlers.onConnect?.();
|
|
@@ -4480,7 +4609,7 @@ function toSolanaWalletInterface(provider) {
|
|
|
4480
4609
|
}
|
|
4481
4610
|
};
|
|
4482
4611
|
}
|
|
4483
|
-
var SOLANA_WALLET_IDS;
|
|
4612
|
+
var SOLANA_WALLET_IDS, SOLANA_MAINNET_CHAIN, BASE58_ALPHABET;
|
|
4484
4613
|
var init_solana = __esm({
|
|
4485
4614
|
"src/wallets/solana.ts"() {
|
|
4486
4615
|
"use strict";
|
|
@@ -4490,6 +4619,8 @@ var init_solana = __esm({
|
|
|
4490
4619
|
"solflare",
|
|
4491
4620
|
"backpack"
|
|
4492
4621
|
];
|
|
4622
|
+
SOLANA_MAINNET_CHAIN = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
4623
|
+
BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
4493
4624
|
}
|
|
4494
4625
|
});
|
|
4495
4626
|
|
|
@@ -4663,6 +4794,15 @@ var init_metadata = __esm({
|
|
|
4663
4794
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
4664
4795
|
deepLink: (url) => `phantom://browse/${encodeURIComponent(url)}`
|
|
4665
4796
|
},
|
|
4797
|
+
{
|
|
4798
|
+
id: "metamask-solana",
|
|
4799
|
+
name: "MetaMask (Solana)",
|
|
4800
|
+
category: "injected",
|
|
4801
|
+
ecosystem: "solana",
|
|
4802
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
4803
|
+
emoji: "\u{1F98A}",
|
|
4804
|
+
homepage: "https://metamask.io/"
|
|
4805
|
+
},
|
|
4666
4806
|
{
|
|
4667
4807
|
id: "solflare",
|
|
4668
4808
|
name: "Solflare",
|
|
@@ -6656,7 +6796,9 @@ function applyWalletTokenState({
|
|
|
6656
6796
|
const selectedTokenStillExists = selectedToken && sortedTokens.some(
|
|
6657
6797
|
(token) => normalizeChainKey2(token.chainId) === normalizeChainKey2(selectedToken.chainId) && token.address === selectedToken.address
|
|
6658
6798
|
);
|
|
6659
|
-
const nextSelectedToken = selectedTokenStillExists && selectedToken ?
|
|
6799
|
+
const nextSelectedToken = selectedTokenStillExists && selectedToken ? sortedTokens.find(
|
|
6800
|
+
(token) => normalizeChainKey2(token.chainId) === normalizeChainKey2(selectedToken.chainId) && token.address === selectedToken.address
|
|
6801
|
+
) ?? selectedToken : sortedTokens.find((token) => Number(token.balance) > 0) ?? null;
|
|
6660
6802
|
setSelectedToken(nextSelectedToken);
|
|
6661
6803
|
if (nextSelectedToken && (!selectedChain || normalizeChainKey2(selectedChain.chainId) !== normalizeChainKey2(
|
|
6662
6804
|
hasChainData(nextSelectedToken) ? nextSelectedToken.chainData?.chainId ?? null : nextSelectedToken.chainId
|
|
@@ -13457,10 +13599,12 @@ function useDepositAmountModel({
|
|
|
13457
13599
|
]);
|
|
13458
13600
|
const amountWei = amountValidationError ? 0n : amountComputation.fromAmountWei ?? 0n;
|
|
13459
13601
|
const parsedAmount = parseFloat(fixedFromAmountString ?? amount) || 0;
|
|
13460
|
-
const maxTokenAmount = (0, import_react31.useMemo)(
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13602
|
+
const maxTokenAmount = (0, import_react31.useMemo)(() => {
|
|
13603
|
+
const cap = Math.min(normalizedTokenBalance, 1e4);
|
|
13604
|
+
const token = selectedToken;
|
|
13605
|
+
const isSolNative = token?.category === "native" && typeof token.chain_key === "string" && token.chain_key.toLowerCase().includes("solana");
|
|
13606
|
+
return isSolNative ? Math.max(0, cap - 0.01) : cap;
|
|
13607
|
+
}, [normalizedTokenBalance, selectedToken]);
|
|
13464
13608
|
const maxUsdAmount = (0, import_react31.useMemo)(() => {
|
|
13465
13609
|
if (!hasUsdPrice) return void 0;
|
|
13466
13610
|
return Math.min(maxTokenAmount * tokenPriceUSD, 1e4);
|
|
@@ -30429,7 +30573,8 @@ function sleep3(ms) {
|
|
|
30429
30573
|
}
|
|
30430
30574
|
function isUserRejection(err) {
|
|
30431
30575
|
if (!err) return false;
|
|
30432
|
-
const
|
|
30576
|
+
const e2 = err;
|
|
30577
|
+
const code = e2?.code ?? e2?.data?.code;
|
|
30433
30578
|
if (code === 4001) return true;
|
|
30434
30579
|
const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
|
|
30435
30580
|
return msg.includes("user rejected") || msg.includes("user denied") || msg.includes("cancelled");
|
|
@@ -30578,6 +30723,26 @@ function useSwapExecution(fromChain) {
|
|
|
30578
30723
|
);
|
|
30579
30724
|
const canUseSA = !!routeResult.sponsorship && Date.now() >= saFailedUntilRef.current && wallet?.ecosystem === "evm" && wallet.type === "eip1193" && !isNative && !!walletAddress && Number.isFinite(numericChainId);
|
|
30580
30725
|
if (canUseSA) {
|
|
30726
|
+
if (numericChainId && wallet) {
|
|
30727
|
+
try {
|
|
30728
|
+
const currentChainId = await wallet.getChainId();
|
|
30729
|
+
if (currentChainId !== numericChainId) {
|
|
30730
|
+
await wallet.switchChain(numericChainId);
|
|
30731
|
+
}
|
|
30732
|
+
} catch (switchErr) {
|
|
30733
|
+
if (isUserRejection(switchErr)) {
|
|
30734
|
+
const msg = mapTxError(switchErr);
|
|
30735
|
+
setState((p) => ({
|
|
30736
|
+
...p,
|
|
30737
|
+
isSubmitting: false,
|
|
30738
|
+
txStatus: "error",
|
|
30739
|
+
errorMessage: msg
|
|
30740
|
+
}));
|
|
30741
|
+
onError(msg);
|
|
30742
|
+
return;
|
|
30743
|
+
}
|
|
30744
|
+
}
|
|
30745
|
+
}
|
|
30581
30746
|
try {
|
|
30582
30747
|
const mod = await Promise.resolve().then(() => (init_smart_account2(), smart_account_exports));
|
|
30583
30748
|
const result = await mod.sendRouteAsUserOperation({
|
|
@@ -31125,11 +31290,18 @@ function SwapWalletSelector({
|
|
|
31125
31290
|
onBack
|
|
31126
31291
|
}) {
|
|
31127
31292
|
const { detected } = useWalletDetection();
|
|
31293
|
+
const {
|
|
31294
|
+
isConnected: managerConnected,
|
|
31295
|
+
walletMetaId,
|
|
31296
|
+
connectedVia,
|
|
31297
|
+
disconnect
|
|
31298
|
+
} = useWalletInfo();
|
|
31299
|
+
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
31300
|
+
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
31301
|
+
const [wcConnecting, setWcConnecting] = (0, import_react45.useState)(false);
|
|
31128
31302
|
const [connectingId, setConnectingId] = (0, import_react45.useState)(null);
|
|
31129
|
-
const [connectedWalletId, setConnectedWalletId] = (0, import_react45.useState)(
|
|
31130
|
-
null
|
|
31131
|
-
);
|
|
31132
31303
|
const [timerExpired, setTimerExpired] = (0, import_react45.useState)(false);
|
|
31304
|
+
const [selectedNamespace, setSelectedNamespace] = (0, import_react45.useState)("evm");
|
|
31133
31305
|
const prevStatusRef = (0, import_react45.useRef)(walletStatus);
|
|
31134
31306
|
(0, import_react45.useEffect)(() => {
|
|
31135
31307
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
@@ -31144,16 +31316,48 @@ function SwapWalletSelector({
|
|
|
31144
31316
|
prevStatusRef.current = walletStatus;
|
|
31145
31317
|
}
|
|
31146
31318
|
}, [walletStatus]);
|
|
31319
|
+
const filteredWallets = (0, import_react45.useMemo)(
|
|
31320
|
+
() => detected.filter(
|
|
31321
|
+
(w) => (w.meta?.ecosystem ?? "").toLowerCase() === selectedNamespace
|
|
31322
|
+
),
|
|
31323
|
+
[detected, selectedNamespace]
|
|
31324
|
+
);
|
|
31325
|
+
const isDetecting = detected.length === 0 && !timerExpired;
|
|
31326
|
+
const handleDisconnect = () => {
|
|
31327
|
+
void disconnect();
|
|
31328
|
+
};
|
|
31329
|
+
const handleWalletConnect = async () => {
|
|
31330
|
+
if (wcConnecting) return;
|
|
31331
|
+
if (connectedVia === "walletconnect" && managerConnected) {
|
|
31332
|
+
onBack();
|
|
31333
|
+
return;
|
|
31334
|
+
}
|
|
31335
|
+
setWcConnecting(true);
|
|
31336
|
+
try {
|
|
31337
|
+
const { error } = await connectWC();
|
|
31338
|
+
if (error) {
|
|
31339
|
+
toast.error("WalletConnect Failed", error);
|
|
31340
|
+
}
|
|
31341
|
+
} catch (err) {
|
|
31342
|
+
const msg = err instanceof Error ? err.message : "WalletConnect failed";
|
|
31343
|
+
toast.error("WalletConnect Failed", msg);
|
|
31344
|
+
} finally {
|
|
31345
|
+
setWcConnecting(false);
|
|
31346
|
+
}
|
|
31347
|
+
};
|
|
31147
31348
|
const handleClick = async (wallet) => {
|
|
31148
31349
|
if (walletStatus === "connecting") return;
|
|
31149
31350
|
if (wallet.meta.id === "walletconnect" || wallet.via === "walletconnect") {
|
|
31150
31351
|
toast.error("Not Available", "WalletConnect is not currently available.");
|
|
31151
31352
|
return;
|
|
31152
31353
|
}
|
|
31354
|
+
if (managerConnected && walletMetaId === wallet.meta.id) {
|
|
31355
|
+
onBack();
|
|
31356
|
+
return;
|
|
31357
|
+
}
|
|
31153
31358
|
setConnectingId(wallet.meta.id);
|
|
31154
31359
|
try {
|
|
31155
31360
|
await connectWallet(wallet);
|
|
31156
|
-
setConnectedWalletId(wallet.meta.id);
|
|
31157
31361
|
} catch (err) {
|
|
31158
31362
|
setConnectingId(null);
|
|
31159
31363
|
const msg = err instanceof Error ? err.message : "Failed to connect wallet";
|
|
@@ -31167,7 +31371,10 @@ function SwapWalletSelector({
|
|
|
31167
31371
|
}
|
|
31168
31372
|
}
|
|
31169
31373
|
};
|
|
31170
|
-
const
|
|
31374
|
+
const tabs = [
|
|
31375
|
+
{ id: "evm", label: "EVM" },
|
|
31376
|
+
{ id: "solana", label: "Solana" }
|
|
31377
|
+
];
|
|
31171
31378
|
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
31172
31379
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31173
31380
|
"div",
|
|
@@ -31224,134 +31431,348 @@ function SwapWalletSelector({
|
|
|
31224
31431
|
fontSize: fontSize.lg,
|
|
31225
31432
|
fontWeight: fontWeight.semibold,
|
|
31226
31433
|
color: colors.foreground,
|
|
31227
|
-
textAlign: "center"
|
|
31228
|
-
marginRight: "1.75rem"
|
|
31434
|
+
textAlign: "center"
|
|
31229
31435
|
},
|
|
31230
31436
|
children: "Connect Wallet"
|
|
31231
31437
|
}
|
|
31232
|
-
)
|
|
31233
|
-
|
|
31234
|
-
}
|
|
31235
|
-
),
|
|
31236
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { style: { padding: spacing[4] }, children: isDetecting ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31237
|
-
"div",
|
|
31238
|
-
{
|
|
31239
|
-
style: {
|
|
31240
|
-
display: "flex",
|
|
31241
|
-
flexDirection: "column",
|
|
31242
|
-
gap: spacing[3]
|
|
31243
|
-
},
|
|
31244
|
-
children: [
|
|
31245
|
-
[1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31438
|
+
),
|
|
31439
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31246
31440
|
"div",
|
|
31247
31441
|
{
|
|
31248
31442
|
style: {
|
|
31443
|
+
position: "relative",
|
|
31249
31444
|
display: "flex",
|
|
31250
31445
|
alignItems: "center",
|
|
31251
|
-
|
|
31252
|
-
|
|
31253
|
-
|
|
31254
|
-
|
|
31255
|
-
animation: "tw-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
31446
|
+
borderRadius: "9999px",
|
|
31447
|
+
background: colors.background,
|
|
31448
|
+
border: `1px solid ${colors.mutedForeground}`,
|
|
31449
|
+
padding: "3px"
|
|
31256
31450
|
},
|
|
31257
31451
|
children: [
|
|
31258
31452
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31259
31453
|
"div",
|
|
31260
31454
|
{
|
|
31261
31455
|
style: {
|
|
31262
|
-
|
|
31263
|
-
|
|
31264
|
-
|
|
31265
|
-
|
|
31456
|
+
position: "absolute",
|
|
31457
|
+
top: 3,
|
|
31458
|
+
bottom: 3,
|
|
31459
|
+
width: "calc(50% - 3px)",
|
|
31460
|
+
borderRadius: "9999px",
|
|
31461
|
+
background: `linear-gradient(to bottom, ${colors.zinc[100]}, ${colors.zinc[200]})`,
|
|
31462
|
+
border: `1px solid ${colors.mutedForeground}`,
|
|
31463
|
+
transition: "transform 300ms ease-out",
|
|
31464
|
+
transform: selectedNamespace === "evm" ? "translateX(0)" : "translateX(100%)"
|
|
31266
31465
|
}
|
|
31267
31466
|
}
|
|
31268
31467
|
),
|
|
31269
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31270
|
-
"
|
|
31468
|
+
tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31469
|
+
"button",
|
|
31271
31470
|
{
|
|
31471
|
+
onClick: () => setSelectedNamespace(t.id),
|
|
31272
31472
|
style: {
|
|
31273
|
-
|
|
31274
|
-
|
|
31275
|
-
|
|
31276
|
-
|
|
31277
|
-
|
|
31278
|
-
|
|
31279
|
-
|
|
31473
|
+
position: "relative",
|
|
31474
|
+
zIndex: 10,
|
|
31475
|
+
padding: "4px 11px",
|
|
31476
|
+
fontSize: "10px",
|
|
31477
|
+
outline: "none",
|
|
31478
|
+
fontWeight: 600,
|
|
31479
|
+
borderRadius: "9999px",
|
|
31480
|
+
background: "transparent",
|
|
31481
|
+
border: "none",
|
|
31482
|
+
cursor: "pointer",
|
|
31483
|
+
transition: "color 200ms",
|
|
31484
|
+
color: selectedNamespace === t.id ? colors.black : colors.mutedForeground
|
|
31485
|
+
},
|
|
31486
|
+
children: t.label
|
|
31487
|
+
},
|
|
31488
|
+
t.id
|
|
31489
|
+
))
|
|
31280
31490
|
]
|
|
31281
|
-
},
|
|
31282
|
-
i
|
|
31283
|
-
)),
|
|
31284
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31285
|
-
"p",
|
|
31286
|
-
{
|
|
31287
|
-
style: {
|
|
31288
|
-
textAlign: "center",
|
|
31289
|
-
fontSize: fontSize.sm,
|
|
31290
|
-
color: colors.mutedForeground,
|
|
31291
|
-
marginTop: spacing[4]
|
|
31292
|
-
},
|
|
31293
|
-
children: "Detecting wallets..."
|
|
31294
31491
|
}
|
|
31295
31492
|
)
|
|
31296
31493
|
]
|
|
31297
31494
|
}
|
|
31298
|
-
)
|
|
31299
|
-
|
|
31300
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.
|
|
31301
|
-
"
|
|
31495
|
+
),
|
|
31496
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { style: { padding: spacing[4] }, children: [
|
|
31497
|
+
isDetecting ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31498
|
+
"div",
|
|
31302
31499
|
{
|
|
31303
31500
|
style: {
|
|
31304
|
-
|
|
31305
|
-
|
|
31306
|
-
|
|
31307
|
-
marginBottom: spacing[2]
|
|
31501
|
+
display: "flex",
|
|
31502
|
+
flexDirection: "column",
|
|
31503
|
+
gap: spacing[3]
|
|
31308
31504
|
},
|
|
31309
|
-
children:
|
|
31505
|
+
children: [
|
|
31506
|
+
[1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31507
|
+
"div",
|
|
31508
|
+
{
|
|
31509
|
+
style: {
|
|
31510
|
+
display: "flex",
|
|
31511
|
+
alignItems: "center",
|
|
31512
|
+
gap: spacing[4],
|
|
31513
|
+
padding: spacing[4],
|
|
31514
|
+
borderRadius: borderRadius["2xl"],
|
|
31515
|
+
backgroundColor: colors.muted,
|
|
31516
|
+
animation: "tw-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
31517
|
+
},
|
|
31518
|
+
children: [
|
|
31519
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31520
|
+
"div",
|
|
31521
|
+
{
|
|
31522
|
+
style: {
|
|
31523
|
+
width: "3rem",
|
|
31524
|
+
height: "3rem",
|
|
31525
|
+
borderRadius: borderRadius.xl,
|
|
31526
|
+
backgroundColor: "rgba(161,161,170,0.2)"
|
|
31527
|
+
}
|
|
31528
|
+
}
|
|
31529
|
+
),
|
|
31530
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31531
|
+
"div",
|
|
31532
|
+
{
|
|
31533
|
+
style: {
|
|
31534
|
+
height: "1rem",
|
|
31535
|
+
width: "6rem",
|
|
31536
|
+
borderRadius: borderRadius.md,
|
|
31537
|
+
backgroundColor: "rgba(161,161,170,0.2)"
|
|
31538
|
+
}
|
|
31539
|
+
}
|
|
31540
|
+
)
|
|
31541
|
+
]
|
|
31542
|
+
},
|
|
31543
|
+
i
|
|
31544
|
+
)),
|
|
31545
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31546
|
+
"p",
|
|
31547
|
+
{
|
|
31548
|
+
style: {
|
|
31549
|
+
textAlign: "center",
|
|
31550
|
+
fontSize: fontSize.sm,
|
|
31551
|
+
color: colors.mutedForeground,
|
|
31552
|
+
marginTop: spacing[4]
|
|
31553
|
+
},
|
|
31554
|
+
children: "Detecting wallets..."
|
|
31555
|
+
}
|
|
31556
|
+
)
|
|
31557
|
+
]
|
|
31310
31558
|
}
|
|
31311
|
-
),
|
|
31312
|
-
|
|
31313
|
-
|
|
31559
|
+
) : filteredWallets.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { style: { textAlign: "center", padding: `${spacing[8]} 0` }, children: [
|
|
31560
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { style: { fontSize: "2.5rem", marginBottom: spacing[4] }, children: "\u{1F45B}" }),
|
|
31561
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31562
|
+
"h3",
|
|
31563
|
+
{
|
|
31564
|
+
style: {
|
|
31565
|
+
fontSize: fontSize.lg,
|
|
31566
|
+
fontWeight: fontWeight.semibold,
|
|
31567
|
+
color: colors.foreground,
|
|
31568
|
+
marginBottom: spacing[2]
|
|
31569
|
+
},
|
|
31570
|
+
children: "No Wallets Found"
|
|
31571
|
+
}
|
|
31572
|
+
),
|
|
31573
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31574
|
+
"p",
|
|
31575
|
+
{
|
|
31576
|
+
style: {
|
|
31577
|
+
fontSize: fontSize.sm,
|
|
31578
|
+
color: colors.mutedForeground,
|
|
31579
|
+
marginBottom: spacing[4]
|
|
31580
|
+
},
|
|
31581
|
+
children: "Please install a web3 wallet to continue."
|
|
31582
|
+
}
|
|
31583
|
+
),
|
|
31584
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31585
|
+
"a",
|
|
31586
|
+
{
|
|
31587
|
+
href: "https://metamask.io/download/",
|
|
31588
|
+
target: "_blank",
|
|
31589
|
+
rel: "noopener noreferrer",
|
|
31590
|
+
style: {
|
|
31591
|
+
display: "inline-flex",
|
|
31592
|
+
alignItems: "center",
|
|
31593
|
+
justifyContent: "center",
|
|
31594
|
+
padding: `${spacing[2]} ${spacing[4]}`,
|
|
31595
|
+
borderRadius: borderRadius.lg,
|
|
31596
|
+
backgroundColor: colors.primary,
|
|
31597
|
+
color: colors.primaryForeground,
|
|
31598
|
+
fontSize: fontSize.sm,
|
|
31599
|
+
fontWeight: fontWeight.medium,
|
|
31600
|
+
textDecoration: "none"
|
|
31601
|
+
},
|
|
31602
|
+
children: "Install MetaMask"
|
|
31603
|
+
}
|
|
31604
|
+
)
|
|
31605
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31606
|
+
"div",
|
|
31314
31607
|
{
|
|
31315
31608
|
style: {
|
|
31316
|
-
|
|
31317
|
-
|
|
31318
|
-
|
|
31609
|
+
display: "flex",
|
|
31610
|
+
flexDirection: "column",
|
|
31611
|
+
gap: spacing[3]
|
|
31319
31612
|
},
|
|
31320
|
-
children:
|
|
31613
|
+
children: filteredWallets.map((wallet) => {
|
|
31614
|
+
const isWalletConnected = managerConnected && walletMetaId === wallet.meta.id;
|
|
31615
|
+
const isConnecting = connectingId === wallet.meta.id && walletStatus === "connecting";
|
|
31616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31617
|
+
"div",
|
|
31618
|
+
{
|
|
31619
|
+
style: mergeStyles(
|
|
31620
|
+
{
|
|
31621
|
+
width: "100%",
|
|
31622
|
+
display: "flex",
|
|
31623
|
+
alignItems: "center",
|
|
31624
|
+
gap: spacing[4],
|
|
31625
|
+
padding: spacing[4],
|
|
31626
|
+
borderRadius: borderRadius["2xl"],
|
|
31627
|
+
backgroundColor: colors.card,
|
|
31628
|
+
border: `1px solid ${colors.border}`
|
|
31629
|
+
},
|
|
31630
|
+
isWalletConnected && {
|
|
31631
|
+
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
31632
|
+
border: `1px solid ${colors.primary}`
|
|
31633
|
+
}
|
|
31634
|
+
),
|
|
31635
|
+
children: [
|
|
31636
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31637
|
+
"div",
|
|
31638
|
+
{
|
|
31639
|
+
style: {
|
|
31640
|
+
width: "3rem",
|
|
31641
|
+
height: "3rem",
|
|
31642
|
+
borderRadius: borderRadius.xl,
|
|
31643
|
+
backgroundColor: colors.muted,
|
|
31644
|
+
display: "flex",
|
|
31645
|
+
alignItems: "center",
|
|
31646
|
+
justifyContent: "center",
|
|
31647
|
+
overflow: "hidden",
|
|
31648
|
+
flexShrink: 0
|
|
31649
|
+
},
|
|
31650
|
+
children: wallet.meta.logo ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31651
|
+
"img",
|
|
31652
|
+
{
|
|
31653
|
+
src: wallet.meta.logo,
|
|
31654
|
+
alt: wallet.meta.name,
|
|
31655
|
+
style: {
|
|
31656
|
+
width: "2rem",
|
|
31657
|
+
height: "2rem",
|
|
31658
|
+
objectFit: "contain"
|
|
31659
|
+
}
|
|
31660
|
+
}
|
|
31661
|
+
) : wallet.detail?.info?.icon ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31662
|
+
"img",
|
|
31663
|
+
{
|
|
31664
|
+
src: wallet.detail.info.icon,
|
|
31665
|
+
alt: wallet.meta.name,
|
|
31666
|
+
style: {
|
|
31667
|
+
width: "2rem",
|
|
31668
|
+
height: "2rem",
|
|
31669
|
+
objectFit: "contain"
|
|
31670
|
+
}
|
|
31671
|
+
}
|
|
31672
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { style: { fontSize: "1.5rem" }, children: wallet.meta.emoji || "\u{1F45B}" })
|
|
31673
|
+
}
|
|
31674
|
+
),
|
|
31675
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
31676
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31677
|
+
"p",
|
|
31678
|
+
{
|
|
31679
|
+
style: {
|
|
31680
|
+
fontWeight: fontWeight.semibold,
|
|
31681
|
+
color: colors.foreground
|
|
31682
|
+
},
|
|
31683
|
+
children: wallet.meta.name
|
|
31684
|
+
}
|
|
31685
|
+
),
|
|
31686
|
+
isWalletConnected && walletAddress && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31687
|
+
"p",
|
|
31688
|
+
{
|
|
31689
|
+
style: {
|
|
31690
|
+
fontSize: fontSize.xs,
|
|
31691
|
+
color: colors.mutedForeground
|
|
31692
|
+
},
|
|
31693
|
+
children: [
|
|
31694
|
+
walletAddress.slice(0, 6),
|
|
31695
|
+
"...",
|
|
31696
|
+
walletAddress.slice(-4)
|
|
31697
|
+
]
|
|
31698
|
+
}
|
|
31699
|
+
)
|
|
31700
|
+
] }),
|
|
31701
|
+
isConnecting ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31702
|
+
"div",
|
|
31703
|
+
{
|
|
31704
|
+
style: {
|
|
31705
|
+
width: "1.25rem",
|
|
31706
|
+
height: "1.25rem",
|
|
31707
|
+
border: `2px solid ${colors.mutedForeground}`,
|
|
31708
|
+
borderTopColor: "transparent",
|
|
31709
|
+
borderRadius: "9999px",
|
|
31710
|
+
animation: "tw-spin 1s linear infinite",
|
|
31711
|
+
flexShrink: 0
|
|
31712
|
+
}
|
|
31713
|
+
}
|
|
31714
|
+
) : isWalletConnected ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31715
|
+
"button",
|
|
31716
|
+
{
|
|
31717
|
+
onClick: handleDisconnect,
|
|
31718
|
+
style: {
|
|
31719
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31720
|
+
borderRadius: "9999px",
|
|
31721
|
+
backgroundColor: "rgba(239,68,68,0.1)",
|
|
31722
|
+
color: "#ef4444",
|
|
31723
|
+
fontSize: fontSize.xs,
|
|
31724
|
+
fontWeight: fontWeight.medium,
|
|
31725
|
+
border: 0,
|
|
31726
|
+
cursor: "pointer",
|
|
31727
|
+
flexShrink: 0
|
|
31728
|
+
},
|
|
31729
|
+
children: "Disconnect"
|
|
31730
|
+
}
|
|
31731
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31732
|
+
"button",
|
|
31733
|
+
{
|
|
31734
|
+
onClick: () => void handleClick(wallet),
|
|
31735
|
+
disabled: walletStatus === "connecting",
|
|
31736
|
+
style: mergeStyles(
|
|
31737
|
+
{
|
|
31738
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31739
|
+
borderRadius: "9999px",
|
|
31740
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
31741
|
+
color: colors.primary,
|
|
31742
|
+
fontSize: fontSize.xs,
|
|
31743
|
+
fontWeight: fontWeight.medium,
|
|
31744
|
+
border: 0,
|
|
31745
|
+
cursor: "pointer",
|
|
31746
|
+
flexShrink: 0
|
|
31747
|
+
},
|
|
31748
|
+
walletStatus === "connecting" && {
|
|
31749
|
+
opacity: 0.5,
|
|
31750
|
+
cursor: "not-allowed"
|
|
31751
|
+
}
|
|
31752
|
+
),
|
|
31753
|
+
children: "Connect"
|
|
31754
|
+
}
|
|
31755
|
+
)
|
|
31756
|
+
]
|
|
31757
|
+
},
|
|
31758
|
+
wallet.meta.id
|
|
31759
|
+
);
|
|
31760
|
+
})
|
|
31321
31761
|
}
|
|
31322
31762
|
),
|
|
31323
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.
|
|
31324
|
-
|
|
31325
|
-
|
|
31326
|
-
|
|
31327
|
-
|
|
31328
|
-
|
|
31329
|
-
|
|
31330
|
-
|
|
31331
|
-
|
|
31332
|
-
|
|
31333
|
-
|
|
31334
|
-
|
|
31335
|
-
|
|
31336
|
-
color: colors.primaryForeground,
|
|
31337
|
-
fontSize: fontSize.sm,
|
|
31338
|
-
fontWeight: fontWeight.medium,
|
|
31339
|
-
textDecoration: "none"
|
|
31340
|
-
},
|
|
31341
|
-
children: "Install MetaMask"
|
|
31342
|
-
}
|
|
31343
|
-
)
|
|
31344
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31345
|
-
"div",
|
|
31346
|
-
{
|
|
31347
|
-
style: {
|
|
31348
|
-
display: "flex",
|
|
31349
|
-
flexDirection: "column",
|
|
31350
|
-
gap: spacing[3]
|
|
31351
|
-
},
|
|
31352
|
-
children: detected.map((wallet) => {
|
|
31353
|
-
const isConnecting = connectingId === wallet.meta.id;
|
|
31354
|
-
const isConnected = walletStatus === "connected" && connectingId === null && walletAddress !== null && connectedWalletId === wallet.meta.id;
|
|
31763
|
+
selectedNamespace === "evm" && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
31764
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31765
|
+
"div",
|
|
31766
|
+
{
|
|
31767
|
+
style: {
|
|
31768
|
+
height: 1,
|
|
31769
|
+
backgroundColor: colors.border,
|
|
31770
|
+
margin: `${spacing[3]} 0`
|
|
31771
|
+
}
|
|
31772
|
+
}
|
|
31773
|
+
),
|
|
31774
|
+
(() => {
|
|
31775
|
+
const wcConnected = managerConnected && connectedVia === "walletconnect";
|
|
31355
31776
|
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31356
31777
|
"div",
|
|
31357
31778
|
{
|
|
@@ -31364,13 +31785,15 @@ function SwapWalletSelector({
|
|
|
31364
31785
|
padding: spacing[4],
|
|
31365
31786
|
borderRadius: borderRadius["2xl"],
|
|
31366
31787
|
backgroundColor: colors.card,
|
|
31367
|
-
border: `1px solid ${colors.border}
|
|
31788
|
+
border: `1px solid ${colors.border}`,
|
|
31789
|
+
cursor: "pointer"
|
|
31368
31790
|
},
|
|
31369
|
-
|
|
31791
|
+
wcConnected && {
|
|
31370
31792
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
31371
31793
|
border: `1px solid ${colors.primary}`
|
|
31372
31794
|
}
|
|
31373
31795
|
),
|
|
31796
|
+
onClick: !wcConnected ? () => void handleWalletConnect() : void 0,
|
|
31374
31797
|
children: [
|
|
31375
31798
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31376
31799
|
"div",
|
|
@@ -31383,35 +31806,24 @@ function SwapWalletSelector({
|
|
|
31383
31806
|
display: "flex",
|
|
31384
31807
|
alignItems: "center",
|
|
31385
31808
|
justifyContent: "center",
|
|
31386
|
-
overflow: "hidden",
|
|
31387
31809
|
flexShrink: 0
|
|
31388
31810
|
},
|
|
31389
|
-
children:
|
|
31390
|
-
"
|
|
31391
|
-
{
|
|
31392
|
-
src: wallet.meta.logo,
|
|
31393
|
-
alt: wallet.meta.name,
|
|
31394
|
-
style: {
|
|
31395
|
-
width: "2rem",
|
|
31396
|
-
height: "2rem",
|
|
31397
|
-
objectFit: "contain"
|
|
31398
|
-
}
|
|
31399
|
-
}
|
|
31400
|
-
) : wallet.detail?.info?.icon ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31401
|
-
"img",
|
|
31811
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31812
|
+
"svg",
|
|
31402
31813
|
{
|
|
31403
|
-
src: wallet.detail.info.icon,
|
|
31404
|
-
alt: wallet.meta.name,
|
|
31405
31814
|
style: {
|
|
31406
|
-
width: "
|
|
31407
|
-
height: "
|
|
31408
|
-
|
|
31409
|
-
}
|
|
31815
|
+
width: "1.5rem",
|
|
31816
|
+
height: "1.5rem",
|
|
31817
|
+
color: colors.blue[500]
|
|
31818
|
+
},
|
|
31819
|
+
viewBox: "0 0 24 24",
|
|
31820
|
+
fill: "currentColor",
|
|
31821
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("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" })
|
|
31410
31822
|
}
|
|
31411
|
-
)
|
|
31823
|
+
)
|
|
31412
31824
|
}
|
|
31413
31825
|
),
|
|
31414
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { style: { flex: 1 }, children: [
|
|
31826
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
31415
31827
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31416
31828
|
"p",
|
|
31417
31829
|
{
|
|
@@ -31419,10 +31831,10 @@ function SwapWalletSelector({
|
|
|
31419
31831
|
fontWeight: fontWeight.semibold,
|
|
31420
31832
|
color: colors.foreground
|
|
31421
31833
|
},
|
|
31422
|
-
children:
|
|
31834
|
+
children: "WalletConnect"
|
|
31423
31835
|
}
|
|
31424
31836
|
),
|
|
31425
|
-
|
|
31837
|
+
wcConnected && walletAddress && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
31426
31838
|
"p",
|
|
31427
31839
|
{
|
|
31428
31840
|
style: {
|
|
@@ -31437,7 +31849,7 @@ function SwapWalletSelector({
|
|
|
31437
31849
|
}
|
|
31438
31850
|
)
|
|
31439
31851
|
] }),
|
|
31440
|
-
|
|
31852
|
+
wcConnecting ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31441
31853
|
"div",
|
|
31442
31854
|
{
|
|
31443
31855
|
style: {
|
|
@@ -31446,40 +31858,58 @@ function SwapWalletSelector({
|
|
|
31446
31858
|
border: `2px solid ${colors.mutedForeground}`,
|
|
31447
31859
|
borderTopColor: "transparent",
|
|
31448
31860
|
borderRadius: "9999px",
|
|
31449
|
-
animation: "tw-spin 1s linear infinite"
|
|
31861
|
+
animation: "tw-spin 1s linear infinite",
|
|
31862
|
+
flexShrink: 0
|
|
31450
31863
|
}
|
|
31451
31864
|
}
|
|
31865
|
+
) : wcConnected ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31866
|
+
"button",
|
|
31867
|
+
{
|
|
31868
|
+
onClick: (e2) => {
|
|
31869
|
+
e2.stopPropagation();
|
|
31870
|
+
handleDisconnect();
|
|
31871
|
+
},
|
|
31872
|
+
style: {
|
|
31873
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31874
|
+
borderRadius: "9999px",
|
|
31875
|
+
backgroundColor: "rgba(239,68,68,0.1)",
|
|
31876
|
+
color: "#ef4444",
|
|
31877
|
+
fontSize: fontSize.xs,
|
|
31878
|
+
fontWeight: fontWeight.medium,
|
|
31879
|
+
border: 0,
|
|
31880
|
+
cursor: "pointer",
|
|
31881
|
+
flexShrink: 0
|
|
31882
|
+
},
|
|
31883
|
+
children: "Disconnect"
|
|
31884
|
+
}
|
|
31452
31885
|
) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
31453
31886
|
"button",
|
|
31454
31887
|
{
|
|
31455
|
-
onClick: () =>
|
|
31456
|
-
|
|
31457
|
-
|
|
31458
|
-
|
|
31459
|
-
|
|
31460
|
-
|
|
31461
|
-
|
|
31462
|
-
|
|
31463
|
-
|
|
31464
|
-
|
|
31465
|
-
|
|
31466
|
-
|
|
31467
|
-
|
|
31468
|
-
|
|
31469
|
-
|
|
31470
|
-
|
|
31471
|
-
}
|
|
31472
|
-
),
|
|
31888
|
+
onClick: (e2) => {
|
|
31889
|
+
e2.stopPropagation();
|
|
31890
|
+
void handleWalletConnect();
|
|
31891
|
+
},
|
|
31892
|
+
disabled: wcConnecting,
|
|
31893
|
+
style: {
|
|
31894
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
31895
|
+
borderRadius: "9999px",
|
|
31896
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
31897
|
+
color: colors.primary,
|
|
31898
|
+
fontSize: fontSize.xs,
|
|
31899
|
+
fontWeight: fontWeight.medium,
|
|
31900
|
+
border: 0,
|
|
31901
|
+
cursor: "pointer",
|
|
31902
|
+
flexShrink: 0
|
|
31903
|
+
},
|
|
31473
31904
|
children: "Connect"
|
|
31474
31905
|
}
|
|
31475
31906
|
)
|
|
31476
31907
|
]
|
|
31477
|
-
}
|
|
31478
|
-
wallet.meta.id
|
|
31908
|
+
}
|
|
31479
31909
|
);
|
|
31480
|
-
})
|
|
31481
|
-
}
|
|
31482
|
-
|
|
31910
|
+
})()
|
|
31911
|
+
] })
|
|
31912
|
+
] })
|
|
31483
31913
|
] });
|
|
31484
31914
|
}
|
|
31485
31915
|
var import_react45, import_jsx_runtime55;
|
|
@@ -31490,6 +31920,7 @@ var init_SwapWalletSelector = __esm({
|
|
|
31490
31920
|
init_styles();
|
|
31491
31921
|
init_utils();
|
|
31492
31922
|
init_wallets();
|
|
31923
|
+
init_config2();
|
|
31493
31924
|
init_Toast();
|
|
31494
31925
|
import_jsx_runtime55 = require("react/jsx-runtime");
|
|
31495
31926
|
}
|
|
@@ -31705,6 +32136,7 @@ function SwapMode({
|
|
|
31705
32136
|
);
|
|
31706
32137
|
const settingsRef = (0, import_react46.useRef)(null);
|
|
31707
32138
|
const currencyDropdownRef = (0, import_react46.useRef)(null);
|
|
32139
|
+
const { emitEvent } = useTrustware();
|
|
31708
32140
|
const { features } = useTrustwareConfig();
|
|
31709
32141
|
const defaultDestRef = features.swapDefaultDestToken;
|
|
31710
32142
|
const lockDestToken = features.swapLockDestToken && !!defaultDestRef;
|
|
@@ -31773,7 +32205,7 @@ function SwapMode({
|
|
|
31773
32205
|
(c) => setFromChain(c),
|
|
31774
32206
|
[]
|
|
31775
32207
|
);
|
|
31776
|
-
const { yourWalletTokens } = useWalletTokenState({
|
|
32208
|
+
const { yourWalletTokens, reloadWalletTokens } = useWalletTokenState({
|
|
31777
32209
|
walletAddress,
|
|
31778
32210
|
selectedChain: fromChain,
|
|
31779
32211
|
setSelectedChain: setFromChainStable,
|
|
@@ -31845,8 +32277,16 @@ function SwapMode({
|
|
|
31845
32277
|
setAmountInputMode("usd");
|
|
31846
32278
|
}
|
|
31847
32279
|
setStage("home");
|
|
32280
|
+
emitEvent?.({
|
|
32281
|
+
type: "swap_route_changed",
|
|
32282
|
+
fromChain: String(chain.chainId),
|
|
32283
|
+
fromToken: token.address,
|
|
32284
|
+
toChain: String(toChain?.chainId ?? ""),
|
|
32285
|
+
toToken: toToken?.address ?? "",
|
|
32286
|
+
...amount ? { amount } : {}
|
|
32287
|
+
});
|
|
31848
32288
|
},
|
|
31849
|
-
[route]
|
|
32289
|
+
[route, emitEvent, toToken, toChain, amount]
|
|
31850
32290
|
);
|
|
31851
32291
|
const handleSelectToToken = (0, import_react46.useCallback)(
|
|
31852
32292
|
(token, chain) => {
|
|
@@ -31854,18 +32294,35 @@ function SwapMode({
|
|
|
31854
32294
|
setToChain(chain);
|
|
31855
32295
|
route.clear();
|
|
31856
32296
|
setStage("home");
|
|
32297
|
+
emitEvent?.({
|
|
32298
|
+
type: "swap_route_changed",
|
|
32299
|
+
fromChain: String(fromChain?.chainId ?? ""),
|
|
32300
|
+
fromToken: fromToken?.address ?? "",
|
|
32301
|
+
toChain: String(chain.chainId),
|
|
32302
|
+
toToken: token.address,
|
|
32303
|
+
...amount ? { amount } : {}
|
|
32304
|
+
});
|
|
31857
32305
|
},
|
|
31858
|
-
[route]
|
|
32306
|
+
[route, emitEvent, fromToken, fromChain, amount]
|
|
31859
32307
|
);
|
|
31860
32308
|
const handleFlip = (0, import_react46.useCallback)(() => {
|
|
31861
32309
|
if (lockDestToken) return;
|
|
32310
|
+
const newFrom = toToken ?? fromToken;
|
|
32311
|
+
const newFromChain = toChain ?? fromChain;
|
|
31862
32312
|
setFromToken((prev) => toToken ?? prev);
|
|
31863
32313
|
setFromChain((prev) => toChain ?? prev);
|
|
31864
32314
|
setToToken(fromToken);
|
|
31865
32315
|
setToChain(fromChain);
|
|
31866
32316
|
setAmount("");
|
|
31867
32317
|
route.clear();
|
|
31868
|
-
|
|
32318
|
+
emitEvent?.({
|
|
32319
|
+
type: "swap_route_changed",
|
|
32320
|
+
fromChain: String(newFromChain?.chainId ?? ""),
|
|
32321
|
+
fromToken: newFrom?.address ?? "",
|
|
32322
|
+
toChain: String(fromChain?.chainId ?? ""),
|
|
32323
|
+
toToken: fromToken?.address ?? ""
|
|
32324
|
+
});
|
|
32325
|
+
}, [lockDestToken, fromToken, fromChain, toToken, toChain, route, emitEvent]);
|
|
31869
32326
|
const fromChainType = normalizeChainType2(fromChain);
|
|
31870
32327
|
const toChainType = normalizeChainType2(toChain);
|
|
31871
32328
|
const needsDestAddress = !!fromChainType && !!toChainType && fromChainType !== toChainType;
|
|
@@ -31938,7 +32395,8 @@ function SwapMode({
|
|
|
31938
32395
|
setCompletedAt(null);
|
|
31939
32396
|
setCopiedHash(null);
|
|
31940
32397
|
setStage("home");
|
|
31941
|
-
|
|
32398
|
+
reloadWalletTokens();
|
|
32399
|
+
}, [execution, route, reloadWalletTokens]);
|
|
31942
32400
|
const handleSwapBack = (0, import_react46.useCallback)(() => {
|
|
31943
32401
|
const prevFrom = fromToken;
|
|
31944
32402
|
const prevFromChain = fromChain;
|
|
@@ -31953,7 +32411,16 @@ function SwapMode({
|
|
|
31953
32411
|
setCompletedAt(null);
|
|
31954
32412
|
setCopiedHash(null);
|
|
31955
32413
|
setStage("home");
|
|
31956
|
-
|
|
32414
|
+
reloadWalletTokens();
|
|
32415
|
+
}, [
|
|
32416
|
+
fromToken,
|
|
32417
|
+
fromChain,
|
|
32418
|
+
toToken,
|
|
32419
|
+
toChain,
|
|
32420
|
+
execution,
|
|
32421
|
+
route,
|
|
32422
|
+
reloadWalletTokens
|
|
32423
|
+
]);
|
|
31957
32424
|
const handleCopyHash = (0, import_react46.useCallback)((hash) => {
|
|
31958
32425
|
if (!navigator?.clipboard?.writeText) return;
|
|
31959
32426
|
void navigator.clipboard.writeText(hash).then(() => {
|
|
@@ -34335,9 +34802,15 @@ function SwapMode({
|
|
|
34335
34802
|
fromToken.address,
|
|
34336
34803
|
fromChainType ?? ""
|
|
34337
34804
|
) || isZeroAddrLike(fromToken.address, fromChainType));
|
|
34338
|
-
const
|
|
34805
|
+
const isSolana = normalizeChainType2(fromChain) === "solana";
|
|
34806
|
+
const effectiveAmount = (() => {
|
|
34807
|
+
if (!isNative || p.value !== 1)
|
|
34808
|
+
return fromBalance * p.value;
|
|
34809
|
+
if (isSolana) return Math.max(0, fromBalance - 0.01);
|
|
34810
|
+
return fromBalance * 0.995;
|
|
34811
|
+
})();
|
|
34339
34812
|
if (amountInputMode === "usd" && hasFromUsdPrice) {
|
|
34340
|
-
const fiatVal =
|
|
34813
|
+
const fiatVal = effectiveAmount * fromTokenPriceUSD * currencyRate;
|
|
34341
34814
|
const dp = fiatVal > 0 ? Math.min(
|
|
34342
34815
|
8,
|
|
34343
34816
|
Math.max(
|
|
@@ -34349,7 +34822,7 @@ function SwapMode({
|
|
|
34349
34822
|
} else {
|
|
34350
34823
|
setAmount(
|
|
34351
34824
|
truncateDecimal(
|
|
34352
|
-
|
|
34825
|
+
effectiveAmount,
|
|
34353
34826
|
Math.min(decimals, 6)
|
|
34354
34827
|
)
|
|
34355
34828
|
);
|
|
@@ -35608,6 +36081,7 @@ var init_SwapMode = __esm({
|
|
|
35608
36081
|
init_tokenAmount();
|
|
35609
36082
|
init_chainHelpers();
|
|
35610
36083
|
init_hooks();
|
|
36084
|
+
init_provider();
|
|
35611
36085
|
init_useSwapRoute();
|
|
35612
36086
|
init_useSwapExecution();
|
|
35613
36087
|
init_useForex();
|