coinley-pay 0.19.0 → 0.21.0
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/{CoinleyPayment-DK-cf2Vl.js → CoinleyPayment-pbTQ15wF.js} +296 -649
- package/dist/{appKitEVM-DNxsUg-8.js → appKitEVM-Bs-au6VA.js} +2 -2
- package/dist/{appKitSolana-fo6vF0_g.js → appKitSolana-KE60037B.js} +2 -2
- package/dist/coinley-vanilla.min.js +1474 -1474
- package/dist/{index-BCVqFOuo.js → index-BLIQ06qE.js} +3 -3
- package/dist/{index-z0MvwxcY.js → index-Y4crJwqS.js} +3 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +9 -9
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
5
5
|
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
|
6
6
|
import { useConnect, useAccount, useSwitchChain, useSendTransaction, useWaitForTransactionReceipt, WagmiProvider, useDisconnect } from "wagmi";
|
|
7
7
|
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
|
|
8
|
-
import { s as sdkAnalytics, c as clarityAnalytics, d as dist, a as Buffer2, B as Buffer$1, g as getCurrencyInfo, p as prefetchRates, i as isSupportedCurrency, b as convertToUSD, f as formatCurrency } from "./index-
|
|
8
|
+
import { s as sdkAnalytics, c as clarityAnalytics, d as dist, a as Buffer2, B as Buffer$1, g as getCurrencyInfo, p as prefetchRates, i as isSupportedCurrency, b as convertToUSD, f as formatCurrency } from "./index-BLIQ06qE.js";
|
|
9
9
|
import { createConfig, fallback, http, getAccount as getAccount$1, getWalletClient, simulateContract, writeContract, readContract, waitForTransactionReceipt, estimateFeesPerGas as estimateFeesPerGas$1 } from "@wagmi/core";
|
|
10
10
|
import { injected, metaMask, coinbaseWallet, walletConnect } from "@wagmi/connectors";
|
|
11
11
|
import { defineChain as defineChain$1, erc20Abi, http as http$1, createPublicClient, fallback as fallback$1 } from "viem";
|
|
@@ -2414,28 +2414,36 @@ class SimplePaymentAPI {
|
|
|
2414
2414
|
async getDepositBalance(paymentId) {
|
|
2415
2415
|
return await this.request(`/api/deposits/balance/${paymentId}`);
|
|
2416
2416
|
}
|
|
2417
|
-
// ==================== BRIDGE
|
|
2418
|
-
async
|
|
2419
|
-
const response = await this.request("/api/bridge/
|
|
2420
|
-
timeout: 3e4
|
|
2421
|
-
});
|
|
2422
|
-
return response.tokens || [];
|
|
2423
|
-
}
|
|
2424
|
-
async getAcrossApproval(params) {
|
|
2425
|
-
const response = await this.request("/api/bridge/across/approval", {
|
|
2417
|
+
// ==================== BRIDGE ROUTING API ====================
|
|
2418
|
+
async getBridgeRoute(params) {
|
|
2419
|
+
const response = await this.request("/api/bridge/quote", {
|
|
2426
2420
|
method: "POST",
|
|
2427
2421
|
body: JSON.stringify(params),
|
|
2428
2422
|
timeout: 45e3
|
|
2429
2423
|
});
|
|
2430
|
-
return response.
|
|
2424
|
+
return response.route;
|
|
2425
|
+
}
|
|
2426
|
+
async getBridgeTokens(chainId) {
|
|
2427
|
+
const query = new URLSearchParams({ chainId: String(chainId) }).toString();
|
|
2428
|
+
const response = await this.request(`/api/bridge/tokens?${query}`, {
|
|
2429
|
+
timeout: 3e4
|
|
2430
|
+
});
|
|
2431
|
+
return response.tokens || [];
|
|
2431
2432
|
}
|
|
2432
|
-
async
|
|
2433
|
+
async getBridgeStatusV2(params) {
|
|
2433
2434
|
const query = new URLSearchParams(params).toString();
|
|
2434
|
-
const response = await this.request(`/api/bridge/
|
|
2435
|
+
const response = await this.request(`/api/bridge/status?${query}`, {
|
|
2435
2436
|
timeout: 2e4
|
|
2436
2437
|
});
|
|
2437
2438
|
return response.status;
|
|
2438
2439
|
}
|
|
2440
|
+
async trackBridge(params) {
|
|
2441
|
+
return await this.request("/api/bridge/track", {
|
|
2442
|
+
method: "POST",
|
|
2443
|
+
body: JSON.stringify(params),
|
|
2444
|
+
timeout: 2e4
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2439
2447
|
/**
|
|
2440
2448
|
* Check if a network supports deposit address payments
|
|
2441
2449
|
* @param {number|string} chainId - Chain ID
|
|
@@ -2447,8 +2455,6 @@ class SimplePaymentAPI {
|
|
|
2447
2455
|
}
|
|
2448
2456
|
}
|
|
2449
2457
|
const LIFI_API_URL = "https://li.quest/v1";
|
|
2450
|
-
const LIFI_API_KEY = "c344f311-d6d3-4f0c-8ea4-f3aee507f37e.78f5b82d-440a-4463-a841-c6bf11078d22";
|
|
2451
|
-
const LIFI_INTEGRATOR = "coinley";
|
|
2452
2458
|
const LIFI_SOLANA_CHAIN_ID = 1151111081099710;
|
|
2453
2459
|
const BRIDGE_DESTINATION_PRIORITY = [
|
|
2454
2460
|
"base",
|
|
@@ -2535,26 +2541,6 @@ const SOLANA_TOKEN_ADDRESSES = {
|
|
|
2535
2541
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
2536
2542
|
USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"
|
|
2537
2543
|
};
|
|
2538
|
-
const extractBridgeTokens = (chainData) => {
|
|
2539
|
-
const chainId = parseInt((chainData == null ? void 0 : chainData.id) || (chainData == null ? void 0 : chainData.chainId), 10);
|
|
2540
|
-
const lifiTokens = (chainData == null ? void 0 : chainData.tokens) || (chainData == null ? void 0 : chainData.featuredTokens) || [];
|
|
2541
|
-
let usdc = null;
|
|
2542
|
-
let usdt = null;
|
|
2543
|
-
for (const token of lifiTokens) {
|
|
2544
|
-
const symbol = (token.symbol || "").toUpperCase();
|
|
2545
|
-
if (!usdc && symbol.startsWith("USDC") && token.address) {
|
|
2546
|
-
usdc = { address: token.address, decimals: token.decimals || 6 };
|
|
2547
|
-
}
|
|
2548
|
-
if (!usdt && symbol.startsWith("USDT") && token.address) {
|
|
2549
|
-
usdt = { address: token.address, decimals: token.decimals || 6 };
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
const known = Number.isFinite(chainId) ? getKnownBridgeTokens(chainId) : {};
|
|
2553
|
-
return {
|
|
2554
|
-
usdc: usdc || known.usdc || null,
|
|
2555
|
-
usdt: usdt || known.usdt || null
|
|
2556
|
-
};
|
|
2557
|
-
};
|
|
2558
2544
|
const getBridgeTokenAddress = (symbol, bridgeTokens) => {
|
|
2559
2545
|
var _a, _b;
|
|
2560
2546
|
const upper = symbol == null ? void 0 : symbol.toUpperCase();
|
|
@@ -2658,44 +2644,29 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
|
|
|
2658
2644
|
merchantNetworks.filter((n) => n.chainId && n.shortName !== "solana" && n.chainType !== "solana").map((n) => parseInt(n.chainId))
|
|
2659
2645
|
);
|
|
2660
2646
|
if (merchantChainIds.size === 0) return;
|
|
2661
|
-
const response = await fetch(`${LIFI_API_URL}/chains?chainTypes=EVM`, {
|
|
2662
|
-
method: "GET",
|
|
2663
|
-
headers: {
|
|
2664
|
-
"Content-Type": "application/json",
|
|
2665
|
-
...LIFI_API_KEY ? { "x-lifi-api-key": LIFI_API_KEY } : {}
|
|
2666
|
-
},
|
|
2667
|
-
signal: AbortSignal.timeout(1e4)
|
|
2668
|
-
});
|
|
2669
|
-
if (!response.ok) return;
|
|
2670
|
-
const data = await response.json();
|
|
2671
|
-
const lifiChains = data.chains || data || [];
|
|
2672
2647
|
const bestDest = getBestDestinationChain(merchantNetworks);
|
|
2673
2648
|
if (!bestDest) return;
|
|
2674
2649
|
const destChainId = parseInt(bestDest.chainId);
|
|
2675
|
-
const
|
|
2676
|
-
const
|
|
2677
|
-
|
|
2678
|
-
const chainId = parseInt(chain.id || chain.chainId, 10);
|
|
2650
|
+
const destBridgeTokens = getKnownBridgeTokens(destChainId);
|
|
2651
|
+
const bridgeNets = Object.entries(CHAIN_ID_TO_SHORT_NAME).filter(([chainIdText]) => {
|
|
2652
|
+
const chainId = parseInt(chainIdText, 10);
|
|
2679
2653
|
if (!chainId) return false;
|
|
2680
2654
|
if (merchantChainIds.has(chainId)) return false;
|
|
2681
|
-
const bridgeTokens =
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
const
|
|
2686
|
-
const shortName = CHAIN_ID_TO_SHORT_NAME[chainId] || chain.name;
|
|
2687
|
-
const bridgeTokens = extractBridgeTokens(chain);
|
|
2655
|
+
const bridgeTokens = getKnownBridgeTokens(chainId);
|
|
2656
|
+
return !!(bridgeTokens.usdc || bridgeTokens.usdt);
|
|
2657
|
+
}).map(([chainIdText, shortName]) => {
|
|
2658
|
+
const chainId = parseInt(chainIdText, 10);
|
|
2659
|
+
const bridgeTokens = getKnownBridgeTokens(chainId);
|
|
2688
2660
|
return {
|
|
2689
2661
|
id: `bridge-${chainId}`,
|
|
2690
|
-
name:
|
|
2662
|
+
name: shortName || `Chain ${chainId}`,
|
|
2691
2663
|
shortName: shortName || `chain-${chainId}`,
|
|
2692
2664
|
chainId,
|
|
2693
2665
|
chainType: "evm",
|
|
2694
2666
|
isBridgeNetwork: true,
|
|
2695
2667
|
bridgeDestination: { ...bestDest, bridgeTokens: destBridgeTokens },
|
|
2696
2668
|
bridgeTokens,
|
|
2697
|
-
|
|
2698
|
-
logo: chain.logoURI || null
|
|
2669
|
+
logo: null
|
|
2699
2670
|
};
|
|
2700
2671
|
});
|
|
2701
2672
|
setBridgeNetworks(bridgeNets);
|
|
@@ -4021,7 +3992,8 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
4021
3992
|
setTransactionStep("swapping");
|
|
4022
3993
|
const action = swapQuote.isSwap && !swapQuote.isSameChain ? "swap & bridge" : "swap";
|
|
4023
3994
|
onProgress == null ? void 0 : onProgress("swapping", `Swapping ${swapQuote.originTokenSymbol} → ${swapQuote.destTokenSymbol}...`);
|
|
4024
|
-
const
|
|
3995
|
+
const quoteWithPaymentId = paymentId ? { ...swapQuote, paymentId } : swapQuote;
|
|
3996
|
+
const result = await bridgeHook.executeBridge(quoteWithPaymentId, walletClient, (step, msg) => {
|
|
4025
3997
|
onProgress == null ? void 0 : onProgress(step, msg);
|
|
4026
3998
|
});
|
|
4027
3999
|
if (!result.success) {
|
|
@@ -20451,85 +20423,88 @@ const PaymentStatus = ({
|
|
|
20451
20423
|
] });
|
|
20452
20424
|
}
|
|
20453
20425
|
if (status === "success") {
|
|
20454
|
-
|
|
20455
|
-
|
|
20456
|
-
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
|
|
20462
|
-
|
|
20463
|
-
|
|
20464
|
-
|
|
20426
|
+
const displayAmount = (payment == null ? void 0 : payment.totalAmount) || (payment == null ? void 0 : payment.amount) || (payment == null ? void 0 : payment.totalAmountUSD) || (payment == null ? void 0 : payment.amountUSD) || 0;
|
|
20427
|
+
const tokenSymbol = (selectedPaymentMethod == null ? void 0 : selectedPaymentMethod.symbol) || (selectedPaymentMethod == null ? void 0 : selectedPaymentMethod.currency) || (selectedPaymentMethod == null ? void 0 : selectedPaymentMethod.tokenSymbol) || (selectedPaymentMethod == null ? void 0 : selectedPaymentMethod.name) || "Token";
|
|
20428
|
+
const networkName = (selectedNetwork == null ? void 0 : selectedNetwork.name) || (selectedNetwork == null ? void 0 : selectedNetwork.displayName) || (selectedNetwork == null ? void 0 : selectedNetwork.shortName) || "Network";
|
|
20429
|
+
const explorerUrl = getExplorerUrl(transactionHash, selectedNetwork);
|
|
20430
|
+
const explorerName = getExplorerName(selectedNetwork);
|
|
20431
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex h-full w-full flex-col px-3 pb-0 pt-[84px]", children: [
|
|
20432
|
+
onClose && /* @__PURE__ */ jsx(
|
|
20433
|
+
"button",
|
|
20434
|
+
{
|
|
20435
|
+
type: "button",
|
|
20436
|
+
onClick: onClose,
|
|
20437
|
+
className: "absolute right-1 top-1 flex h-8 w-8 items-center justify-center rounded-full text-black transition-colors hover:bg-gray-100",
|
|
20438
|
+
"aria-label": "Close",
|
|
20439
|
+
children: /* @__PURE__ */ jsx("svg", { className: "h-6 w-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
20440
|
+
}
|
|
20441
|
+
),
|
|
20442
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center text-center", children: [
|
|
20443
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex h-16 w-16 items-center justify-center rounded-full bg-[#D8F8E7] p-2", children: /* @__PURE__ */ jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-[#0CCB63] text-white", children: /* @__PURE__ */ jsx("svg", { className: "h-6 w-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2.5, d: "M5 13l4 4L19 7" }) }) }) }),
|
|
20444
|
+
/* @__PURE__ */ jsx("h3", { className: "mb-3 text-base font-semibold text-black", children: "Payment Successful" }),
|
|
20445
|
+
/* @__PURE__ */ jsxs("p", { className: "mb-9 text-base text-[#A9ABB2]", children: [
|
|
20446
|
+
/* @__PURE__ */ jsxs("span", { className: "font-semibold text-black", children: [
|
|
20447
|
+
"$",
|
|
20448
|
+
Number(displayAmount || 0).toFixed(2)
|
|
20449
|
+
] }),
|
|
20450
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
20451
|
+
" sent to ",
|
|
20452
|
+
merchantName
|
|
20453
|
+
] })
|
|
20454
|
+
] })
|
|
20465
20455
|
] }),
|
|
20466
|
-
|
|
20467
|
-
/* @__PURE__ */ jsx("p", { className: "text-
|
|
20456
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
20457
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-medium text-[#4B5563]", children: "Transaction ID" }),
|
|
20468
20458
|
/* @__PURE__ */ jsxs(
|
|
20469
|
-
"
|
|
20459
|
+
"button",
|
|
20470
20460
|
{
|
|
20471
|
-
|
|
20461
|
+
type: "button",
|
|
20472
20462
|
onClick: copyTransactionHash,
|
|
20463
|
+
className: "mb-4 flex h-11 w-full items-center justify-between rounded-lg border border-[#EEF0F4] bg-[#FAFAFB] px-3 text-left transition-colors hover:bg-gray-100",
|
|
20473
20464
|
children: [
|
|
20474
|
-
/* @__PURE__ */ jsx("span", { className: "font-mono text-sm text-
|
|
20475
|
-
/* @__PURE__ */ jsxs("
|
|
20476
|
-
copiedHash
|
|
20477
|
-
/* @__PURE__ */ jsx(
|
|
20478
|
-
"svg",
|
|
20479
|
-
{
|
|
20480
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
20481
|
-
className: "h-4 w-4 text-gray-500",
|
|
20482
|
-
fill: "none",
|
|
20483
|
-
viewBox: "0 0 24 24",
|
|
20484
|
-
stroke: "currentColor",
|
|
20485
|
-
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" })
|
|
20486
|
-
}
|
|
20487
|
-
)
|
|
20465
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-sm font-semibold text-black", children: formatTransactionHash(transactionHash) }),
|
|
20466
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-black", children: [
|
|
20467
|
+
copiedHash && /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-[#0CCB63]", children: "Copied" }),
|
|
20468
|
+
/* @__PURE__ */ jsx("svg", { className: "h-5 w-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.7, d: "M8 7a2 2 0 012-2h8a2 2 0 012 2v8a2 2 0 01-2 2h-2M6 9H5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-1" }) })
|
|
20488
20469
|
] })
|
|
20489
20470
|
]
|
|
20490
20471
|
}
|
|
20491
20472
|
),
|
|
20492
|
-
(
|
|
20493
|
-
|
|
20494
|
-
|
|
20495
|
-
|
|
20496
|
-
|
|
20497
|
-
|
|
20498
|
-
|
|
20499
|
-
|
|
20500
|
-
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
|
|
20515
|
-
|
|
20516
|
-
|
|
20517
|
-
|
|
20518
|
-
)
|
|
20519
|
-
]
|
|
20520
|
-
}
|
|
20521
|
-
);
|
|
20522
|
-
})()
|
|
20473
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-0", children: [
|
|
20474
|
+
/* @__PURE__ */ jsxs("div", { className: "flex h-11 items-center justify-between border-b border-[#EEF0F4]", children: [
|
|
20475
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-[#A9ABB2]", children: "Network" }),
|
|
20476
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold text-black", children: networkName })
|
|
20477
|
+
] }),
|
|
20478
|
+
/* @__PURE__ */ jsxs("div", { className: "flex h-11 items-center justify-between border-b border-[#EEF0F4]", children: [
|
|
20479
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-[#A9ABB2]", children: "Token" }),
|
|
20480
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold text-black", children: tokenSymbol })
|
|
20481
|
+
] })
|
|
20482
|
+
] }),
|
|
20483
|
+
explorerUrl && /* @__PURE__ */ jsxs(
|
|
20484
|
+
"a",
|
|
20485
|
+
{
|
|
20486
|
+
href: explorerUrl,
|
|
20487
|
+
target: "_blank",
|
|
20488
|
+
rel: "noopener noreferrer",
|
|
20489
|
+
className: "mt-3 flex h-[43px] w-full items-center justify-center gap-2 rounded-lg border border-[#B997FF] bg-white text-sm font-semibold text-[#7042D2] transition-colors hover:bg-purple-50",
|
|
20490
|
+
children: [
|
|
20491
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
20492
|
+
"View on ",
|
|
20493
|
+
explorerName
|
|
20494
|
+
] }),
|
|
20495
|
+
/* @__PURE__ */ jsx("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) })
|
|
20496
|
+
]
|
|
20497
|
+
}
|
|
20498
|
+
)
|
|
20523
20499
|
] }),
|
|
20524
|
-
onClose && /* @__PURE__ */ jsx(
|
|
20500
|
+
onClose && /* @__PURE__ */ jsx("div", { className: "mt-auto pt-5", children: /* @__PURE__ */ jsx(
|
|
20525
20501
|
"button",
|
|
20526
20502
|
{
|
|
20527
20503
|
onClick: onClose,
|
|
20528
|
-
className: "w-full
|
|
20529
|
-
style: { fontFamily: "Gilroy-Medium, Gilroy-Regular, sans-serif" },
|
|
20504
|
+
className: "h-11 w-full rounded-lg bg-[#7042D2] px-4 text-base font-semibold text-white transition-colors hover:bg-[#5b34b1]",
|
|
20530
20505
|
children: "Close"
|
|
20531
20506
|
}
|
|
20532
|
-
)
|
|
20507
|
+
) })
|
|
20533
20508
|
] });
|
|
20534
20509
|
}
|
|
20535
20510
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
|
|
@@ -21120,7 +21095,7 @@ const WalletSelector = ({
|
|
|
21120
21095
|
try {
|
|
21121
21096
|
setAppKitError(null);
|
|
21122
21097
|
setWalletConnectAddress(solanaAccountState.address);
|
|
21123
|
-
const { createWalletConnectAdapter } = await import("./appKitSolana-
|
|
21098
|
+
const { createWalletConnectAdapter } = await import("./appKitSolana-KE60037B.js");
|
|
21124
21099
|
const adapter = createWalletConnectAdapter(solanaAccountState.address);
|
|
21125
21100
|
await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
|
|
21126
21101
|
console.log("✅ WalletConnect synced with SDK");
|
|
@@ -21225,7 +21200,7 @@ const WalletSelector = ({
|
|
|
21225
21200
|
setAppKitLoading(true);
|
|
21226
21201
|
setAppKitError(null);
|
|
21227
21202
|
try {
|
|
21228
|
-
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-
|
|
21203
|
+
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-Bs-au6VA.js");
|
|
21229
21204
|
await initializeAppKitEVM(wagmiConfig);
|
|
21230
21205
|
await openAppKitModal();
|
|
21231
21206
|
} catch (error) {
|
|
@@ -21245,7 +21220,7 @@ const WalletSelector = ({
|
|
|
21245
21220
|
setAppKitError(null);
|
|
21246
21221
|
try {
|
|
21247
21222
|
console.log("📦 Loading AppKit Solana module...");
|
|
21248
|
-
const { initializeAppKitSolana } = await import("./appKitSolana-
|
|
21223
|
+
const { initializeAppKitSolana } = await import("./appKitSolana-KE60037B.js");
|
|
21249
21224
|
console.log("✅ Module loaded, initializing...");
|
|
21250
21225
|
const modal = await initializeAppKitSolana(solanaWallet);
|
|
21251
21226
|
console.log("✅ AppKit Solana initialized successfully");
|
|
@@ -21491,94 +21466,6 @@ const PaymentAlternatives = ({ currentPaymentType, onSelectMethod, isDepositSupp
|
|
|
21491
21466
|
}) })
|
|
21492
21467
|
] });
|
|
21493
21468
|
};
|
|
21494
|
-
const __vite_import_meta_env__ = {};
|
|
21495
|
-
const ACROSS_FALLBACK_ENABLED = (__vite_import_meta_env__ == null ? void 0 : __vite_import_meta_env__.VITE_COINLEY_ENABLE_ACROSS_FALLBACK) !== "false";
|
|
21496
|
-
const ACROSS_SUPPORTED_USDC_SOURCE_CHAINS = /* @__PURE__ */ new Set([
|
|
21497
|
-
1,
|
|
21498
|
-
10,
|
|
21499
|
-
130,
|
|
21500
|
-
137,
|
|
21501
|
-
143,
|
|
21502
|
-
232,
|
|
21503
|
-
480,
|
|
21504
|
-
999,
|
|
21505
|
-
1868,
|
|
21506
|
-
42161,
|
|
21507
|
-
534352,
|
|
21508
|
-
57073,
|
|
21509
|
-
59144,
|
|
21510
|
-
324
|
|
21511
|
-
]);
|
|
21512
|
-
const ACROSS_SUPPORTED_USDT_SOURCE_CHAINS = /* @__PURE__ */ new Set([
|
|
21513
|
-
1,
|
|
21514
|
-
10,
|
|
21515
|
-
130,
|
|
21516
|
-
137,
|
|
21517
|
-
143,
|
|
21518
|
-
999,
|
|
21519
|
-
1868,
|
|
21520
|
-
42161,
|
|
21521
|
-
534352,
|
|
21522
|
-
59144,
|
|
21523
|
-
57073,
|
|
21524
|
-
324
|
|
21525
|
-
]);
|
|
21526
|
-
const ACROSS_SUPPORTED_DESTINATION_CHAINS = /* @__PURE__ */ new Set([
|
|
21527
|
-
8453,
|
|
21528
|
-
// Base
|
|
21529
|
-
42161,
|
|
21530
|
-
// Arbitrum
|
|
21531
|
-
10,
|
|
21532
|
-
// Optimism
|
|
21533
|
-
137,
|
|
21534
|
-
// Polygon
|
|
21535
|
-
56
|
|
21536
|
-
// BSC
|
|
21537
|
-
]);
|
|
21538
|
-
const TOKEN_ALIASES = {
|
|
21539
|
-
USDC: /* @__PURE__ */ new Set(["USDC", "USDC.E", "USDBC", "USDC0", "AXLUSDC"]),
|
|
21540
|
-
USDT: /* @__PURE__ */ new Set(["USDT", "USDT0", "USDT.E", "USDTB", "AXLUSDT"])
|
|
21541
|
-
};
|
|
21542
|
-
const normalizeAcrossSymbol = (symbol) => {
|
|
21543
|
-
const upper = String(symbol || "").toUpperCase();
|
|
21544
|
-
if (TOKEN_ALIASES.USDC.has(upper)) return "USDC";
|
|
21545
|
-
if (TOKEN_ALIASES.USDT.has(upper)) return "USDT";
|
|
21546
|
-
if (upper === "ETH" || upper === "WETH") return upper;
|
|
21547
|
-
return upper;
|
|
21548
|
-
};
|
|
21549
|
-
const isAcrossRouteCandidate = ({ originChainId, destChainId, originTokenSymbol, destTokenSymbol }) => {
|
|
21550
|
-
if (!ACROSS_FALLBACK_ENABLED) return false;
|
|
21551
|
-
if (!ACROSS_SUPPORTED_DESTINATION_CHAINS.has(Number(destChainId))) return false;
|
|
21552
|
-
const originSymbol = normalizeAcrossSymbol(originTokenSymbol);
|
|
21553
|
-
const destSymbol = normalizeAcrossSymbol(destTokenSymbol);
|
|
21554
|
-
if (originSymbol !== destSymbol) return false;
|
|
21555
|
-
if (originSymbol === "USDC") {
|
|
21556
|
-
return ACROSS_SUPPORTED_USDC_SOURCE_CHAINS.has(Number(originChainId));
|
|
21557
|
-
}
|
|
21558
|
-
if (originSymbol === "USDT") {
|
|
21559
|
-
return ACROSS_SUPPORTED_USDT_SOURCE_CHAINS.has(Number(originChainId));
|
|
21560
|
-
}
|
|
21561
|
-
return false;
|
|
21562
|
-
};
|
|
21563
|
-
const pickAcrossToken = (tokens, chainId, symbol, address) => {
|
|
21564
|
-
const normalizedSymbol = normalizeAcrossSymbol(symbol);
|
|
21565
|
-
const normalizedAddress = typeof address === "string" ? address.toLowerCase() : null;
|
|
21566
|
-
const chainTokens = (tokens || []).filter((token) => Number(token.chainId) === Number(chainId));
|
|
21567
|
-
if (normalizedAddress && normalizedAddress !== "native") {
|
|
21568
|
-
const byAddress = chainTokens.find((token) => {
|
|
21569
|
-
var _a;
|
|
21570
|
-
return ((_a = token.address) == null ? void 0 : _a.toLowerCase()) === normalizedAddress;
|
|
21571
|
-
});
|
|
21572
|
-
if (byAddress) return byAddress;
|
|
21573
|
-
}
|
|
21574
|
-
const aliases = TOKEN_ALIASES[normalizedSymbol] || /* @__PURE__ */ new Set([normalizedSymbol]);
|
|
21575
|
-
const candidates = chainTokens.filter((token) => aliases.has(String(token.symbol || "").toUpperCase()));
|
|
21576
|
-
if (candidates.length === 0) return null;
|
|
21577
|
-
return candidates.find((token) => {
|
|
21578
|
-
const price = Number(token.priceUsd || 0);
|
|
21579
|
-
return price >= 0.95 && price <= 1.05;
|
|
21580
|
-
}) || candidates[0];
|
|
21581
|
-
};
|
|
21582
21469
|
const createDebugId = (prefix = "lifi-sdk") => `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
21583
21470
|
const normalizeAddress = (value) => {
|
|
21584
21471
|
if (typeof value !== "string") return null;
|
|
@@ -21589,152 +21476,46 @@ const extractQuoteRecipient = (quote) => {
|
|
|
21589
21476
|
var _a, _b, _c;
|
|
21590
21477
|
return normalizeAddress((_a = quote == null ? void 0 : quote.action) == null ? void 0 : _a.toAddress) || normalizeAddress(quote == null ? void 0 : quote.toAddress) || normalizeAddress((_b = quote == null ? void 0 : quote.estimate) == null ? void 0 : _b.toAddress) || normalizeAddress((_c = quote == null ? void 0 : quote.transactionRequest) == null ? void 0 : _c.toAddress) || null;
|
|
21591
21478
|
};
|
|
21592
|
-
|
|
21593
|
-
|
|
21594
|
-
|
|
21595
|
-
const
|
|
21596
|
-
|
|
21597
|
-
|
|
21598
|
-
|
|
21599
|
-
|
|
21600
|
-
|
|
21601
|
-
}
|
|
21602
|
-
|
|
21603
|
-
|
|
21604
|
-
acrossTokenCacheTime = Date.now();
|
|
21605
|
-
return acrossTokenCache;
|
|
21479
|
+
const formatTokenAmount = (amount, decimals = 6, symbol = "") => {
|
|
21480
|
+
if (!amount) return symbol ? `0 ${symbol}` : "0";
|
|
21481
|
+
try {
|
|
21482
|
+
const raw = BigInt(amount);
|
|
21483
|
+
const divisor = 10n ** BigInt(decimals || 0);
|
|
21484
|
+
const whole = raw / divisor;
|
|
21485
|
+
const fraction = raw % divisor;
|
|
21486
|
+
const fractionText = fraction.toString().padStart(decimals || 0, "0").slice(0, 4).replace(/0+$/, "");
|
|
21487
|
+
return `${whole.toString()}${fractionText ? `.${fractionText}` : ""}${symbol ? ` ${symbol}` : ""}`;
|
|
21488
|
+
} catch {
|
|
21489
|
+
return symbol ? `${amount} ${symbol}` : String(amount);
|
|
21490
|
+
}
|
|
21606
21491
|
};
|
|
21607
|
-
const
|
|
21608
|
-
|
|
21609
|
-
|
|
21610
|
-
|
|
21611
|
-
|
|
21612
|
-
destTokenAddress,
|
|
21613
|
-
destTokenSymbol,
|
|
21614
|
-
amount,
|
|
21615
|
-
recipient,
|
|
21616
|
-
fromAddress,
|
|
21617
|
-
debugId,
|
|
21618
|
-
attemptId,
|
|
21619
|
-
attemptMeta,
|
|
21620
|
-
acrossApi
|
|
21621
|
-
}) => {
|
|
21622
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
21623
|
-
if (!isAcrossRouteCandidate({ originChainId, destChainId, originTokenSymbol, destTokenSymbol })) {
|
|
21624
|
-
throw new Error("Across route not eligible for this chain/token pair");
|
|
21625
|
-
}
|
|
21626
|
-
const tokens = await fetchAcrossTokens(acrossApi);
|
|
21627
|
-
const inputToken = pickAcrossToken(tokens, originChainId, originTokenSymbol, originTokenAddress);
|
|
21628
|
-
const outputToken = pickAcrossToken(tokens, destChainId, destTokenSymbol, destTokenAddress);
|
|
21629
|
-
if (!inputToken || !outputToken) {
|
|
21630
|
-
throw new Error("Across token not available for this route");
|
|
21631
|
-
}
|
|
21632
|
-
const toAmountRaw = BigInt(Math.ceil(parseFloat(amount) * Math.pow(10, outputToken.decimals || 6))).toString();
|
|
21633
|
-
const params = {
|
|
21634
|
-
tradeType: "exactOutput",
|
|
21635
|
-
amount: toAmountRaw,
|
|
21636
|
-
originChainId: String(originChainId),
|
|
21637
|
-
destinationChainId: String(destChainId),
|
|
21638
|
-
inputToken: inputToken.address,
|
|
21639
|
-
outputToken: outputToken.address,
|
|
21640
|
-
depositor: fromAddress,
|
|
21641
|
-
recipient,
|
|
21642
|
-
slippage: "0.005"
|
|
21643
|
-
};
|
|
21644
|
-
console.log("[Across] Requesting fallback quote:", {
|
|
21645
|
-
debugId,
|
|
21646
|
-
fromChain: originChainId,
|
|
21647
|
-
toChain: destChainId,
|
|
21648
|
-
fromToken: `${inputToken.symbol} (${inputToken.address.slice(0, 10)}...)`,
|
|
21649
|
-
toToken: `${outputToken.symbol} (${outputToken.address.slice(0, 10)}...)`,
|
|
21650
|
-
recipient,
|
|
21651
|
-
fromAddress,
|
|
21652
|
-
requestedOutputAmount: toAmountRaw
|
|
21653
|
-
});
|
|
21654
|
-
const quote = await acrossApi.getAcrossApproval(params);
|
|
21655
|
-
const bridgeStep = ((_a = quote.steps) == null ? void 0 : _a.bridge) || {};
|
|
21656
|
-
const feeAmountRaw = ((_b = bridgeStep.fees) == null ? void 0 : _b.amount) || ((_c = quote.fees) == null ? void 0 : _c.total) || "0";
|
|
21657
|
-
const feeDecimals = ((_e = (_d = bridgeStep.fees) == null ? void 0 : _d.token) == null ? void 0 : _e.decimals) || inputToken.decimals || 6;
|
|
21658
|
-
const feeUsd = Number(feeAmountRaw) / Math.pow(10, feeDecimals);
|
|
21659
|
-
const inputAmountRaw = bridgeStep.inputAmount || ((_g = (_f = quote.checks) == null ? void 0 : _f.balance) == null ? void 0 : _g.expected) || ((_i = (_h = quote.checks) == null ? void 0 : _h.allowance) == null ? void 0 : _i.expected);
|
|
21660
|
-
const outputAmountRaw = bridgeStep.outputAmount || toAmountRaw;
|
|
21661
|
-
const inputAmount = inputAmountRaw ? `${(Number(inputAmountRaw) / Math.pow(10, inputToken.decimals || 6)).toFixed(4)} ${inputToken.symbol}` : amount;
|
|
21662
|
-
const outputAmount = outputAmountRaw ? (Number(outputAmountRaw) / Math.pow(10, outputToken.decimals || 6)).toFixed(4) : amount;
|
|
21663
|
-
const parsedQuote = {
|
|
21664
|
-
debugId,
|
|
21665
|
-
provider: "across",
|
|
21666
|
-
raw: quote,
|
|
21667
|
-
originChainId,
|
|
21668
|
-
destChainId,
|
|
21669
|
-
originChainName: CHAIN_ID_TO_SHORT_NAME[originChainId] || `Chain ${originChainId}`,
|
|
21670
|
-
destChainName: CHAIN_ID_TO_SHORT_NAME[destChainId] || `Chain ${destChainId}`,
|
|
21671
|
-
originTokenSymbol: inputToken.symbol || originTokenSymbol,
|
|
21672
|
-
originTokenAddress: inputToken.address,
|
|
21673
|
-
inputAmount,
|
|
21674
|
-
destTokenSymbol: outputToken.symbol || destTokenSymbol,
|
|
21675
|
-
destTokenAddress: outputToken.address,
|
|
21676
|
-
outputAmount,
|
|
21677
|
-
bridgeFee: Number.isFinite(feeUsd) ? feeUsd.toFixed(4) : "0",
|
|
21678
|
-
bridgeFeeCurrency: "USD",
|
|
21679
|
-
estimatedTime: quote.expectedFillTime || quote.expectedFillTimeSec || 5,
|
|
21680
|
-
steps: [bridgeStep].filter(Boolean),
|
|
21681
|
-
tool: "across",
|
|
21682
|
-
toolDetails: { name: "Across" },
|
|
21683
|
-
isSwap: inputToken.symbol !== outputToken.symbol,
|
|
21684
|
-
isSameChain: Number(originChainId) === Number(destChainId),
|
|
21685
|
-
tradeType: "EXACT_OUTPUT",
|
|
21686
|
-
requestedRecipient: normalizeAddress(recipient),
|
|
21687
|
-
effectiveRecipient: normalizeAddress(recipient),
|
|
21688
|
-
transactionRequest: quote.swapTx,
|
|
21689
|
-
approvalTxns: quote.approvalTxns || [],
|
|
21690
|
-
approvalAddress: ((_k = (_j = quote.checks) == null ? void 0 : _j.allowance) == null ? void 0 : _k.spender) || ((_m = (_l = quote.approvalTxns) == null ? void 0 : _l[0]) == null ? void 0 : _m.to) || null,
|
|
21691
|
-
attemptId,
|
|
21692
|
-
selectionSnapshot: (attemptMeta == null ? void 0 : attemptMeta.selectionSnapshot) ?? null
|
|
21693
|
-
};
|
|
21694
|
-
console.log("[Across] Quote response:", {
|
|
21695
|
-
debugId,
|
|
21696
|
-
attemptId,
|
|
21697
|
-
inputToken: parsedQuote.originTokenSymbol,
|
|
21698
|
-
outputToken: parsedQuote.destTokenSymbol,
|
|
21699
|
-
inputAmount: parsedQuote.inputAmount,
|
|
21700
|
-
outputAmount: parsedQuote.outputAmount,
|
|
21701
|
-
estimatedTime: parsedQuote.estimatedTime,
|
|
21702
|
-
hasApproval: parsedQuote.approvalTxns.length > 0,
|
|
21703
|
-
hasSwapTx: !!parsedQuote.transactionRequest
|
|
21704
|
-
});
|
|
21705
|
-
return parsedQuote;
|
|
21492
|
+
const buildApprovalData = (spender, amount) => {
|
|
21493
|
+
const cleanSpender = normalizeAddress(spender);
|
|
21494
|
+
if (!cleanSpender) throw new Error("Invalid bridge approval spender");
|
|
21495
|
+
const rawAmount = BigInt(amount || 0).toString(16);
|
|
21496
|
+
return "0x095ea7b3" + cleanSpender.slice(2).padStart(64, "0") + rawAmount.padStart(64, "0");
|
|
21706
21497
|
};
|
|
21707
21498
|
const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
21708
21499
|
const [bridgeStatus, setBridgeStatus] = useState("idle");
|
|
21709
21500
|
const [bridgeQuote, setBridgeQuote] = useState(null);
|
|
21710
21501
|
const [bridgeError, setBridgeError] = useState(null);
|
|
21711
21502
|
const [bridgeChains, setBridgeChains] = useState([]);
|
|
21712
|
-
const
|
|
21713
|
-
|
|
21714
|
-
const headers = {
|
|
21715
|
-
"Content-Type": "application/json",
|
|
21716
|
-
...{ "x-lifi-api-key": LIFI_API_KEY }
|
|
21717
|
-
};
|
|
21503
|
+
const bridgeApiRef = useRef(null);
|
|
21504
|
+
bridgeApiRef.current = apiUrl && publicKeyOrApiKey ? new SimplePaymentAPI(apiUrl, publicKeyOrApiKey, apiSecret) : null;
|
|
21718
21505
|
const fetchBridgeChains = useCallback(async () => {
|
|
21719
|
-
|
|
21720
|
-
|
|
21721
|
-
|
|
21722
|
-
|
|
21723
|
-
|
|
21724
|
-
|
|
21725
|
-
|
|
21726
|
-
|
|
21727
|
-
|
|
21728
|
-
return chains;
|
|
21729
|
-
} catch (e) {
|
|
21730
|
-
console.warn("[LiFi] Failed to fetch chains:", e.message);
|
|
21731
|
-
return [];
|
|
21732
|
-
}
|
|
21506
|
+
const chains = Object.entries(CHAIN_ID_TO_SHORT_NAME).map(([id, shortName]) => ({
|
|
21507
|
+
id: Number(id),
|
|
21508
|
+
chainId: Number(id),
|
|
21509
|
+
name: shortName,
|
|
21510
|
+
displayName: shortName,
|
|
21511
|
+
chainType: "EVM"
|
|
21512
|
+
}));
|
|
21513
|
+
setBridgeChains(chains);
|
|
21514
|
+
return chains;
|
|
21733
21515
|
}, []);
|
|
21734
21516
|
const getBridgeQuote = useCallback(async (originChainId, destChainId, originTokenAddress, originTokenSymbol, originTokenDecimals, destTokenAddress, destTokenSymbol, amount, recipient, _originBridgeTokens, _destBridgeTokens, user, debugId = createDebugId(), attemptMeta = null) => {
|
|
21735
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
21517
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
21736
21518
|
const attemptId = (attemptMeta == null ? void 0 : attemptMeta.attemptId) ?? null;
|
|
21737
|
-
const providerMode = (attemptMeta == null ? void 0 : attemptMeta.providerMode) || "auto";
|
|
21738
21519
|
const isStillCurrent = () => {
|
|
21739
21520
|
if (!(attemptMeta == null ? void 0 : attemptMeta.isStillCurrent)) return true;
|
|
21740
21521
|
try {
|
|
@@ -21747,41 +21528,6 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
21747
21528
|
setBridgeError(null);
|
|
21748
21529
|
const resolvedOriginAddress = !originTokenAddress || originTokenAddress === "native" || originTokenAddress.length < 10 ? NATIVE_TOKEN_ADDRESS : originTokenAddress;
|
|
21749
21530
|
const resolvedDestAddress = !destTokenAddress || destTokenAddress.length < 10 ? NATIVE_TOKEN_ADDRESS : destTokenAddress;
|
|
21750
|
-
const fromAddressForFallback = user || recipient;
|
|
21751
|
-
const requestAcrossQuote = async () => getAcrossQuote({
|
|
21752
|
-
originChainId,
|
|
21753
|
-
destChainId,
|
|
21754
|
-
originTokenAddress: resolvedOriginAddress,
|
|
21755
|
-
originTokenSymbol,
|
|
21756
|
-
destTokenAddress: resolvedDestAddress,
|
|
21757
|
-
destTokenSymbol,
|
|
21758
|
-
amount,
|
|
21759
|
-
recipient,
|
|
21760
|
-
fromAddress: fromAddressForFallback,
|
|
21761
|
-
debugId,
|
|
21762
|
-
attemptId,
|
|
21763
|
-
attemptMeta,
|
|
21764
|
-
acrossApi: acrossApiRef.current
|
|
21765
|
-
});
|
|
21766
|
-
if (providerMode === "across-only") {
|
|
21767
|
-
try {
|
|
21768
|
-
const acrossQuote = await requestAcrossQuote();
|
|
21769
|
-
if (!isStillCurrent()) {
|
|
21770
|
-
console.log("[Across] Dropping stale fallback quote — attempt no longer current", { debugId, attemptId });
|
|
21771
|
-
return acrossQuote;
|
|
21772
|
-
}
|
|
21773
|
-
setBridgeQuote(acrossQuote);
|
|
21774
|
-
setBridgeStatus("idle");
|
|
21775
|
-
setBridgeError(null);
|
|
21776
|
-
return acrossQuote;
|
|
21777
|
-
} catch (acrossError) {
|
|
21778
|
-
console.warn("[Across] Fallback quote failed:", acrossError.message, { debugId, attemptId });
|
|
21779
|
-
setBridgeQuote(null);
|
|
21780
|
-
setBridgeError(acrossError.message);
|
|
21781
|
-
setBridgeStatus("error");
|
|
21782
|
-
return null;
|
|
21783
|
-
}
|
|
21784
|
-
}
|
|
21785
21531
|
try {
|
|
21786
21532
|
const normalizedOriginSymbol = (originTokenSymbol || "").toUpperCase();
|
|
21787
21533
|
const normalizedDestSymbol = (destTokenSymbol || "").toUpperCase();
|
|
@@ -21790,25 +21536,8 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
21790
21536
|
const isSwap = !isSameToken;
|
|
21791
21537
|
const destDecimals = 6;
|
|
21792
21538
|
const toAmountRaw = BigInt(Math.ceil(parseFloat(amount) * Math.pow(10, destDecimals))).toString();
|
|
21793
|
-
const fromAmountRaw = BigInt(Math.floor(parseFloat(amount) * Math.pow(10, originTokenDecimals || 18))).toString();
|
|
21794
|
-
const useExactOutputQuote = true;
|
|
21795
21539
|
const fromAddress = user || recipient;
|
|
21796
|
-
|
|
21797
|
-
fromChain: originChainId.toString(),
|
|
21798
|
-
toChain: destChainId.toString(),
|
|
21799
|
-
fromToken: resolvedOriginAddress,
|
|
21800
|
-
toToken: resolvedDestAddress,
|
|
21801
|
-
fromAddress,
|
|
21802
|
-
toAddress: recipient,
|
|
21803
|
-
integrator: LIFI_INTEGRATOR,
|
|
21804
|
-
fee: "0",
|
|
21805
|
-
slippage: "0.005",
|
|
21806
|
-
order: "CHEAPEST"
|
|
21807
|
-
});
|
|
21808
|
-
if (useExactOutputQuote) {
|
|
21809
|
-
params.set("toAmount", toAmountRaw);
|
|
21810
|
-
}
|
|
21811
|
-
console.log("[LiFi] Requesting quote:", {
|
|
21540
|
+
console.log("[Bridge] Requesting server route:", {
|
|
21812
21541
|
debugId,
|
|
21813
21542
|
fromChain: originChainId,
|
|
21814
21543
|
toChain: destChainId,
|
|
@@ -21816,77 +21545,92 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
21816
21545
|
toToken: `${destTokenSymbol} (${resolvedDestAddress.slice(0, 10)}...)`,
|
|
21817
21546
|
recipient,
|
|
21818
21547
|
fromAddress,
|
|
21819
|
-
requestedAmount:
|
|
21820
|
-
quoteMode:
|
|
21548
|
+
requestedAmount: toAmountRaw,
|
|
21549
|
+
quoteMode: "exactOutput",
|
|
21821
21550
|
isSwap,
|
|
21822
21551
|
isSameChain
|
|
21823
21552
|
});
|
|
21824
|
-
const
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
|
|
21553
|
+
const bridgeApi = bridgeApiRef.current;
|
|
21554
|
+
if (!(bridgeApi == null ? void 0 : bridgeApi.getBridgeRoute)) {
|
|
21555
|
+
throw new Error("Bridge routing service is not configured");
|
|
21556
|
+
}
|
|
21557
|
+
const route = await bridgeApi.getBridgeRoute({
|
|
21558
|
+
fromChainId: Number(originChainId),
|
|
21559
|
+
toChainId: Number(destChainId),
|
|
21560
|
+
fromToken: {
|
|
21561
|
+
address: resolvedOriginAddress,
|
|
21562
|
+
symbol: originTokenSymbol,
|
|
21563
|
+
decimals: Number(originTokenDecimals || 18)
|
|
21564
|
+
},
|
|
21565
|
+
toToken: {
|
|
21566
|
+
address: resolvedDestAddress,
|
|
21567
|
+
symbol: destTokenSymbol,
|
|
21568
|
+
decimals: destDecimals
|
|
21569
|
+
},
|
|
21570
|
+
amount: toAmountRaw,
|
|
21571
|
+
quoteMode: "exactOutput",
|
|
21572
|
+
fromAddress,
|
|
21573
|
+
recipient,
|
|
21574
|
+
slippage: "0.005"
|
|
21828
21575
|
});
|
|
21829
|
-
if (!
|
|
21830
|
-
|
|
21831
|
-
|
|
21832
|
-
}
|
|
21833
|
-
const quote = await response.json();
|
|
21834
|
-
const estimate = quote.estimate || {};
|
|
21835
|
-
const feeCosts = estimate.feeCosts || [];
|
|
21836
|
-
const gasCosts = estimate.gasCosts || [];
|
|
21837
|
-
const totalFee = feeCosts.reduce((sum, f2) => sum + parseFloat(f2.amountUSD || 0), 0) + gasCosts.reduce((sum, g) => sum + parseFloat(g.amountUSD || 0), 0);
|
|
21576
|
+
if (!(route == null ? void 0 : route.transactionRequest)) {
|
|
21577
|
+
throw new Error("Bridge route returned no executable transaction");
|
|
21578
|
+
}
|
|
21838
21579
|
const parsedQuote = {
|
|
21839
21580
|
debugId,
|
|
21840
|
-
provider: "
|
|
21841
|
-
raw:
|
|
21581
|
+
provider: route.provider || "bridge",
|
|
21582
|
+
raw: route.raw || route,
|
|
21842
21583
|
originChainId,
|
|
21843
21584
|
destChainId,
|
|
21844
21585
|
originChainName: CHAIN_ID_TO_SHORT_NAME[originChainId] || `Chain ${originChainId}`,
|
|
21845
21586
|
destChainName: CHAIN_ID_TO_SHORT_NAME[destChainId] || `Chain ${destChainId}`,
|
|
21846
|
-
originTokenSymbol: originTokenSymbol || ((_b = (_a =
|
|
21587
|
+
originTokenSymbol: originTokenSymbol || ((_c = (_b = (_a = route.raw) == null ? void 0 : _a.action) == null ? void 0 : _b.fromToken) == null ? void 0 : _c.symbol) || "Unknown",
|
|
21847
21588
|
originTokenAddress: resolvedOriginAddress,
|
|
21848
|
-
inputAmount:
|
|
21849
|
-
destTokenSymbol: destTokenSymbol || ((_f = (_e =
|
|
21589
|
+
inputAmount: formatTokenAmount(route.fromAmount, originTokenDecimals || 18, originTokenSymbol),
|
|
21590
|
+
destTokenSymbol: destTokenSymbol || ((_f = (_e = (_d = route.raw) == null ? void 0 : _d.action) == null ? void 0 : _e.toToken) == null ? void 0 : _f.symbol) || "USDC",
|
|
21850
21591
|
destTokenAddress: resolvedDestAddress,
|
|
21851
|
-
outputAmount:
|
|
21852
|
-
bridgeFee:
|
|
21592
|
+
outputAmount: formatTokenAmount(route.toAmount || route.toAmountMin, destDecimals, ""),
|
|
21593
|
+
bridgeFee: Number(route.totalFeeUsd || 0).toFixed(2),
|
|
21853
21594
|
bridgeFeeCurrency: "USD",
|
|
21854
|
-
estimatedTime:
|
|
21855
|
-
steps:
|
|
21856
|
-
tool:
|
|
21857
|
-
toolDetails:
|
|
21595
|
+
estimatedTime: route.estimatedTimeSec || 30,
|
|
21596
|
+
steps: ((_g = route.raw) == null ? void 0 : _g.includedSteps) || [],
|
|
21597
|
+
tool: route.provider,
|
|
21598
|
+
toolDetails: { name: route.provider },
|
|
21858
21599
|
isSwap,
|
|
21859
21600
|
isSameChain,
|
|
21860
|
-
tradeType:
|
|
21601
|
+
tradeType: "EXACT_OUTPUT",
|
|
21861
21602
|
requestedRecipient: normalizeAddress(recipient),
|
|
21862
|
-
effectiveRecipient: extractQuoteRecipient(
|
|
21863
|
-
|
|
21864
|
-
|
|
21865
|
-
approvalAddress:
|
|
21603
|
+
effectiveRecipient: normalizeAddress(route.effectiveRecipient) || extractQuoteRecipient(route.raw || {}),
|
|
21604
|
+
transactionRequest: route.transactionRequest,
|
|
21605
|
+
approvalTxns: route.approvalTxns || [],
|
|
21606
|
+
approvalAddress: route.approvalAddress,
|
|
21607
|
+
fromAmountRaw: route.fromAmount,
|
|
21608
|
+
toAmountRaw: route.toAmount,
|
|
21609
|
+
toAmountMinRaw: route.toAmountMin,
|
|
21866
21610
|
attemptId,
|
|
21867
21611
|
selectionSnapshot: (attemptMeta == null ? void 0 : attemptMeta.selectionSnapshot) ?? null
|
|
21868
21612
|
};
|
|
21869
|
-
console.log("[
|
|
21613
|
+
console.log("[Bridge] Server route response:", {
|
|
21870
21614
|
debugId,
|
|
21871
21615
|
attemptId,
|
|
21872
|
-
|
|
21616
|
+
provider: parsedQuote.provider,
|
|
21873
21617
|
requestedRecipient: parsedQuote.requestedRecipient,
|
|
21874
21618
|
effectiveRecipient: parsedQuote.effectiveRecipient,
|
|
21875
|
-
approvalAddress:
|
|
21876
|
-
|
|
21877
|
-
|
|
21878
|
-
|
|
21879
|
-
|
|
21880
|
-
|
|
21881
|
-
transactionRequest:
|
|
21882
|
-
to:
|
|
21883
|
-
chainId:
|
|
21884
|
-
hasData: !!
|
|
21885
|
-
hasValue:
|
|
21619
|
+
approvalAddress: parsedQuote.approvalAddress,
|
|
21620
|
+
approvalTxnCount: parsedQuote.approvalTxns.length,
|
|
21621
|
+
toAmount: route.toAmount,
|
|
21622
|
+
toAmountMin: route.toAmountMin,
|
|
21623
|
+
fromAmount: route.fromAmount,
|
|
21624
|
+
executionDuration: route.estimatedTimeSec,
|
|
21625
|
+
transactionRequest: route.transactionRequest ? {
|
|
21626
|
+
to: route.transactionRequest.to,
|
|
21627
|
+
chainId: route.transactionRequest.chainId,
|
|
21628
|
+
hasData: !!route.transactionRequest.data,
|
|
21629
|
+
hasValue: route.transactionRequest.value !== void 0
|
|
21886
21630
|
} : null
|
|
21887
21631
|
});
|
|
21888
21632
|
if (!isStillCurrent()) {
|
|
21889
|
-
console.log("[
|
|
21633
|
+
console.log("[Bridge] Dropping stale quote result — attempt no longer current", { debugId, attemptId });
|
|
21890
21634
|
return parsedQuote;
|
|
21891
21635
|
}
|
|
21892
21636
|
setBridgeQuote(parsedQuote);
|
|
@@ -21894,30 +21638,11 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
21894
21638
|
return parsedQuote;
|
|
21895
21639
|
} catch (error) {
|
|
21896
21640
|
const stillCurrent = isStillCurrent();
|
|
21897
|
-
console.warn("[
|
|
21641
|
+
console.warn("[Bridge] Route quote failed:", error.message, { debugId, attemptId, stillCurrent });
|
|
21898
21642
|
if (!stillCurrent) {
|
|
21899
|
-
console.log("[
|
|
21900
|
-
return null;
|
|
21901
|
-
}
|
|
21902
|
-
if (providerMode === "lifi-only") {
|
|
21903
|
-
setBridgeQuote(null);
|
|
21904
|
-
setBridgeError(error.message);
|
|
21905
|
-
setBridgeStatus("error");
|
|
21643
|
+
console.log("[Bridge] Ignoring stale quote error");
|
|
21906
21644
|
return null;
|
|
21907
21645
|
}
|
|
21908
|
-
try {
|
|
21909
|
-
const acrossQuote = await requestAcrossQuote();
|
|
21910
|
-
if (!isStillCurrent()) {
|
|
21911
|
-
console.log("[Across] Dropping stale fallback quote — attempt no longer current", { debugId, attemptId });
|
|
21912
|
-
return acrossQuote;
|
|
21913
|
-
}
|
|
21914
|
-
setBridgeQuote(acrossQuote);
|
|
21915
|
-
setBridgeStatus("idle");
|
|
21916
|
-
setBridgeError(null);
|
|
21917
|
-
return acrossQuote;
|
|
21918
|
-
} catch (acrossError) {
|
|
21919
|
-
console.warn("[Across] Fallback quote failed:", acrossError.message, { debugId, attemptId });
|
|
21920
|
-
}
|
|
21921
21646
|
setBridgeQuote(null);
|
|
21922
21647
|
setBridgeError(error.message);
|
|
21923
21648
|
setBridgeStatus("error");
|
|
@@ -21925,7 +21650,7 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
21925
21650
|
}
|
|
21926
21651
|
}, []);
|
|
21927
21652
|
const executeBridge = useCallback(async (quote, walletClient, onProgress) => {
|
|
21928
|
-
var _a, _b;
|
|
21653
|
+
var _a, _b, _c, _d;
|
|
21929
21654
|
setBridgeStatus("bridging");
|
|
21930
21655
|
setBridgeError(null);
|
|
21931
21656
|
try {
|
|
@@ -21934,80 +21659,46 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
21934
21659
|
if (!txRequest) {
|
|
21935
21660
|
throw new Error("Invalid quote: no transaction data");
|
|
21936
21661
|
}
|
|
21937
|
-
|
|
21938
|
-
|
|
21939
|
-
|
|
21940
|
-
|
|
21941
|
-
|
|
21942
|
-
console.log("[Across] Sending approval tx:", {
|
|
21943
|
-
debugId,
|
|
21944
|
-
chainId: quote.originChainId,
|
|
21945
|
-
to: approvalTxn.to
|
|
21946
|
-
});
|
|
21947
|
-
const approveTx = await walletClient.sendTransaction({
|
|
21948
|
-
to: approvalTxn.to,
|
|
21949
|
-
data: approvalTxn.data,
|
|
21950
|
-
value: approvalTxn.value ? BigInt(approvalTxn.value) : 0n,
|
|
21951
|
-
chainId: quote.originChainId
|
|
21952
|
-
});
|
|
21953
|
-
console.log("[Across] Approval tx submitted:", { debugId, approveTx });
|
|
21954
|
-
onProgress == null ? void 0 : onProgress("approving", "Waiting for approval confirmation...");
|
|
21955
|
-
await waitForTxReceipt(approveTx, quote.originChainId);
|
|
21956
|
-
}
|
|
21957
|
-
onProgress == null ? void 0 : onProgress("signing", "Sending bridge transaction...");
|
|
21958
|
-
console.log("[Across] Sending bridge tx:", {
|
|
21662
|
+
const approvalTxns = quote.approvalTxns || ((_b = quote.raw) == null ? void 0 : _b.approvalTxns) || [];
|
|
21663
|
+
for (const approvalTxn of approvalTxns) {
|
|
21664
|
+
if (!(approvalTxn == null ? void 0 : approvalTxn.to) || !(approvalTxn == null ? void 0 : approvalTxn.data)) continue;
|
|
21665
|
+
onProgress == null ? void 0 : onProgress("approving", "Approving token spend...");
|
|
21666
|
+
console.log("[Bridge] Sending provider approval tx:", {
|
|
21959
21667
|
debugId,
|
|
21960
|
-
chainId: quote.originChainId,
|
|
21961
|
-
|
|
21962
|
-
txChainId: txRequest.chainId,
|
|
21963
|
-
hasData: !!txRequest.data,
|
|
21964
|
-
value: txRequest.value || "0"
|
|
21668
|
+
chainId: approvalTxn.chainId || quote.originChainId,
|
|
21669
|
+
to: approvalTxn.to
|
|
21965
21670
|
});
|
|
21966
|
-
const
|
|
21967
|
-
to:
|
|
21968
|
-
data:
|
|
21969
|
-
value:
|
|
21970
|
-
chainId: quote.originChainId
|
|
21971
|
-
...txRequest.gas ? { gas: BigInt(txRequest.gas) } : {}
|
|
21671
|
+
const approveTx = await walletClient.sendTransaction({
|
|
21672
|
+
to: approvalTxn.to,
|
|
21673
|
+
data: approvalTxn.data,
|
|
21674
|
+
value: approvalTxn.value ? BigInt(approvalTxn.value) : 0n,
|
|
21675
|
+
chainId: approvalTxn.chainId || quote.originChainId
|
|
21972
21676
|
});
|
|
21973
|
-
console.log("[
|
|
21974
|
-
|
|
21975
|
-
txHash: txHash2,
|
|
21976
|
-
recipient: quote.requestedRecipient
|
|
21977
|
-
});
|
|
21978
|
-
onProgress == null ? void 0 : onProgress("submitted", `Transaction submitted: ${txHash2.slice(0, 10)}...`);
|
|
21979
|
-
onProgress == null ? void 0 : onProgress("confirming", "Waiting for bridge delivery...");
|
|
21980
|
-
await pollAcrossStatus(txHash2, quote.originChainId, debugId);
|
|
21981
|
-
setBridgeStatus("completed");
|
|
21982
|
-
onProgress == null ? void 0 : onProgress("completed", "bridge complete!");
|
|
21983
|
-
return { success: true, txHash: txHash2 };
|
|
21677
|
+
console.log("[Bridge] Approval tx submitted:", { debugId, approveTx });
|
|
21678
|
+
onProgress == null ? void 0 : onProgress("approving", "Approval submitted...");
|
|
21984
21679
|
}
|
|
21985
|
-
if (quote.approvalAddress && quote.originTokenAddress !== NATIVE_TOKEN_ADDRESS) {
|
|
21680
|
+
if (quote.approvalAddress && quote.originTokenAddress !== NATIVE_TOKEN_ADDRESS && approvalTxns.length === 0) {
|
|
21986
21681
|
onProgress == null ? void 0 : onProgress("approving", "Approving token spend...");
|
|
21987
|
-
|
|
21988
|
-
|
|
21989
|
-
|
|
21990
|
-
|
|
21991
|
-
|
|
21992
|
-
|
|
21993
|
-
|
|
21994
|
-
|
|
21995
|
-
|
|
21996
|
-
|
|
21997
|
-
|
|
21998
|
-
|
|
21999
|
-
|
|
22000
|
-
|
|
22001
|
-
onProgress == null ? void 0 : onProgress("approving", "Waiting for approval confirmation...");
|
|
22002
|
-
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
22003
|
-
} catch (e) {
|
|
22004
|
-
console.warn("[LiFi] Approval failed, proceeding:", e.message);
|
|
22005
|
-
}
|
|
21682
|
+
const approveData = buildApprovalData(quote.approvalAddress, quote.fromAmountRaw || ((_c = quote.raw) == null ? void 0 : _c.fromAmount));
|
|
21683
|
+
console.log("[Bridge] Sending spender approval tx:", {
|
|
21684
|
+
debugId,
|
|
21685
|
+
chainId: quote.originChainId,
|
|
21686
|
+
token: quote.originTokenAddress,
|
|
21687
|
+
approvalAddress: quote.approvalAddress
|
|
21688
|
+
});
|
|
21689
|
+
const approveTx = await walletClient.sendTransaction({
|
|
21690
|
+
to: quote.originTokenAddress,
|
|
21691
|
+
data: approveData,
|
|
21692
|
+
chainId: quote.originChainId
|
|
21693
|
+
});
|
|
21694
|
+
console.log("[Bridge] Approval tx submitted:", { debugId, approveTx });
|
|
21695
|
+
onProgress == null ? void 0 : onProgress("approving", "Approval submitted...");
|
|
22006
21696
|
}
|
|
22007
21697
|
const action = quote.isSwap ? "swap" : "bridge";
|
|
22008
21698
|
onProgress == null ? void 0 : onProgress("signing", `Sending ${action} transaction...`);
|
|
22009
|
-
console.log("[
|
|
21699
|
+
console.log("[Bridge] Sending main tx:", {
|
|
22010
21700
|
debugId,
|
|
21701
|
+
provider: quote.provider,
|
|
22011
21702
|
action,
|
|
22012
21703
|
chainId: quote.originChainId,
|
|
22013
21704
|
txTo: txRequest.to,
|
|
@@ -22019,30 +21710,43 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
22019
21710
|
to: txRequest.to,
|
|
22020
21711
|
data: txRequest.data,
|
|
22021
21712
|
value: txRequest.value ? BigInt(txRequest.value) : 0n,
|
|
22022
|
-
chainId: quote.originChainId,
|
|
22023
|
-
...txRequest.gasLimit ? { gas: BigInt(txRequest.gasLimit) } : {}
|
|
21713
|
+
chainId: txRequest.chainId || quote.originChainId,
|
|
21714
|
+
...txRequest.gasLimit || txRequest.gas ? { gas: BigInt(txRequest.gasLimit || txRequest.gas) } : {}
|
|
22024
21715
|
});
|
|
22025
|
-
console.log("[
|
|
21716
|
+
console.log("[Bridge] Main tx submitted:", {
|
|
22026
21717
|
debugId,
|
|
22027
21718
|
txHash,
|
|
22028
21719
|
quoteRequestedRecipient: quote == null ? void 0 : quote.requestedRecipient,
|
|
22029
|
-
quoteEffectiveRecipient: quote == null ? void 0 : quote.effectiveRecipient
|
|
22030
|
-
sourceExplorer: txHash ? `https://scan.li.fi/tx/${txHash}` : null
|
|
21720
|
+
quoteEffectiveRecipient: quote == null ? void 0 : quote.effectiveRecipient
|
|
22031
21721
|
});
|
|
22032
21722
|
onProgress == null ? void 0 : onProgress("submitted", `Transaction submitted: ${txHash.slice(0, 10)}...`);
|
|
22033
|
-
|
|
22034
|
-
|
|
22035
|
-
|
|
22036
|
-
|
|
22037
|
-
|
|
22038
|
-
|
|
21723
|
+
if (quote.paymentId && ((_d = bridgeApiRef.current) == null ? void 0 : _d.trackBridge)) {
|
|
21724
|
+
try {
|
|
21725
|
+
await bridgeApiRef.current.trackBridge({
|
|
21726
|
+
paymentId: quote.paymentId,
|
|
21727
|
+
provider: quote.provider,
|
|
21728
|
+
sourceChainId: quote.originChainId,
|
|
21729
|
+
sourceTxHash: txHash
|
|
21730
|
+
});
|
|
21731
|
+
console.log("[Bridge] Tracking registered:", {
|
|
21732
|
+
debugId,
|
|
21733
|
+
paymentId: quote.paymentId,
|
|
21734
|
+
provider: quote.provider,
|
|
21735
|
+
sourceChainId: quote.originChainId,
|
|
21736
|
+
sourceTxHash: txHash
|
|
21737
|
+
});
|
|
21738
|
+
} catch (trackError) {
|
|
21739
|
+
console.warn("[Bridge] Track request failed; deposit polling will continue:", {
|
|
21740
|
+
debugId,
|
|
21741
|
+
error: trackError.message
|
|
21742
|
+
});
|
|
22039
21743
|
}
|
|
22040
21744
|
}
|
|
22041
21745
|
setBridgeStatus("completed");
|
|
22042
|
-
onProgress == null ? void 0 : onProgress("completed", `${action}
|
|
21746
|
+
onProgress == null ? void 0 : onProgress("completed", `${action} submitted!`);
|
|
22043
21747
|
return { success: true, txHash };
|
|
22044
21748
|
} catch (error) {
|
|
22045
|
-
console.error("[
|
|
21749
|
+
console.error("[Bridge] Execution failed:", { debugId: quote == null ? void 0 : quote.debugId, error });
|
|
22046
21750
|
setBridgeError(error.message);
|
|
22047
21751
|
setBridgeStatus("error");
|
|
22048
21752
|
onProgress == null ? void 0 : onProgress("error", error.message);
|
|
@@ -22186,45 +21890,6 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
22186
21890
|
return { success: false, error: error.message };
|
|
22187
21891
|
}
|
|
22188
21892
|
}, []);
|
|
22189
|
-
const waitForTxReceipt = async (txHash, chainId) => {
|
|
22190
|
-
var _a, _b;
|
|
22191
|
-
const ALCHEMY_KEY = "YWG990wOlIikc1tU7-WWTepfU8d1f4dp";
|
|
22192
|
-
const slugs = {
|
|
22193
|
-
1: "eth-mainnet",
|
|
22194
|
-
8453: "base-mainnet",
|
|
22195
|
-
42161: "arb-mainnet",
|
|
22196
|
-
137: "polygon-mainnet",
|
|
22197
|
-
10: "opt-mainnet",
|
|
22198
|
-
56: "bnb-mainnet",
|
|
22199
|
-
43114: "avax-mainnet",
|
|
22200
|
-
42220: "celo-mainnet",
|
|
22201
|
-
59144: "linea-mainnet",
|
|
22202
|
-
81457: "blast-mainnet",
|
|
22203
|
-
534352: "scroll-mainnet",
|
|
22204
|
-
324: "zksync-mainnet",
|
|
22205
|
-
80094: "berachain-mainnet",
|
|
22206
|
-
2741: "abstract-mainnet",
|
|
22207
|
-
130: "unichain-mainnet"
|
|
22208
|
-
};
|
|
22209
|
-
const slug = slugs[chainId];
|
|
22210
|
-
if (!slug) return false;
|
|
22211
|
-
for (let i = 0; i < 30; i++) {
|
|
22212
|
-
try {
|
|
22213
|
-
const res = await fetch(`https://${slug}.g.alchemy.com/v2/${ALCHEMY_KEY}`, {
|
|
22214
|
-
method: "POST",
|
|
22215
|
-
headers: { "Content-Type": "application/json" },
|
|
22216
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_getTransactionReceipt", params: [txHash] }),
|
|
22217
|
-
signal: AbortSignal.timeout(5e3)
|
|
22218
|
-
}).then((r) => r.json());
|
|
22219
|
-
if (((_a = res.result) == null ? void 0 : _a.status) === "0x1") return true;
|
|
22220
|
-
if (((_b = res.result) == null ? void 0 : _b.status) === "0x0") throw new Error("Transaction reverted on-chain");
|
|
22221
|
-
} catch (e) {
|
|
22222
|
-
if (e.message.includes("reverted")) throw e;
|
|
22223
|
-
}
|
|
22224
|
-
await new Promise((r) => setTimeout(r, 2e3));
|
|
22225
|
-
}
|
|
22226
|
-
return false;
|
|
22227
|
-
};
|
|
22228
21893
|
const pollLiFiStatus = async (txHash, fromChain, toChain, debugId) => {
|
|
22229
21894
|
var _a, _b, _c, _d, _e;
|
|
22230
21895
|
let lastLoggedPhase = null;
|
|
@@ -22232,7 +21897,7 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
22232
21897
|
try {
|
|
22233
21898
|
const res = await fetch(
|
|
22234
21899
|
`${LIFI_API_URL}/status?txHash=${txHash}&fromChain=${fromChain}&toChain=${toChain}`,
|
|
22235
|
-
{ headers, signal: AbortSignal.timeout(1e4) }
|
|
21900
|
+
{ headers: { "Content-Type": "application/json" }, signal: AbortSignal.timeout(1e4) }
|
|
22236
21901
|
);
|
|
22237
21902
|
if (res.ok) {
|
|
22238
21903
|
const status = await res.json();
|
|
@@ -22280,45 +21945,6 @@ const useBridge = (apiUrl, publicKeyOrApiKey, apiSecret = null) => {
|
|
|
22280
21945
|
}
|
|
22281
21946
|
return false;
|
|
22282
21947
|
};
|
|
22283
|
-
const pollAcrossStatus = async (txHash, originChainId, debugId) => {
|
|
22284
|
-
var _a, _b, _c;
|
|
22285
|
-
let lastStatus = null;
|
|
22286
|
-
for (let i = 0; i < 60; i++) {
|
|
22287
|
-
try {
|
|
22288
|
-
const acrossApi = acrossApiRef.current;
|
|
22289
|
-
if (!(acrossApi == null ? void 0 : acrossApi.getAcrossStatus)) {
|
|
22290
|
-
throw new Error("Across server proxy is not configured");
|
|
22291
|
-
}
|
|
22292
|
-
const status = await acrossApi.getAcrossStatus({
|
|
22293
|
-
originChainId: String(originChainId),
|
|
22294
|
-
depositTxHash: txHash
|
|
22295
|
-
});
|
|
22296
|
-
const statusValue = status.status || status.fillStatus || ((_a = status.deposit) == null ? void 0 : _a.status) || "unknown";
|
|
22297
|
-
if (statusValue !== lastStatus || i === 0 || (i + 1) % 10 === 0) {
|
|
22298
|
-
console.log("[Across] Status checkpoint:", {
|
|
22299
|
-
debugId,
|
|
22300
|
-
attempt: i + 1,
|
|
22301
|
-
sourceTxHash: txHash,
|
|
22302
|
-
status: statusValue,
|
|
22303
|
-
fillTxHash: status.fillTxHash || ((_b = status.deposit) == null ? void 0 : _b.fillTxHash),
|
|
22304
|
-
destinationChainId: status.destinationChainId || ((_c = status.deposit) == null ? void 0 : _c.destinationChainId)
|
|
22305
|
-
});
|
|
22306
|
-
lastStatus = statusValue;
|
|
22307
|
-
}
|
|
22308
|
-
const normalized = String(statusValue).toLowerCase();
|
|
22309
|
-
if (normalized.includes("filled") || normalized.includes("complete") || normalized === "filled" || status.filled === true) {
|
|
22310
|
-
return true;
|
|
22311
|
-
}
|
|
22312
|
-
if (normalized.includes("failed") || normalized.includes("expired")) {
|
|
22313
|
-
throw new Error("Across bridge transaction failed");
|
|
22314
|
-
}
|
|
22315
|
-
} catch (e) {
|
|
22316
|
-
if (e.message.includes("failed")) throw e;
|
|
22317
|
-
}
|
|
22318
|
-
await new Promise((r) => setTimeout(r, 3e3));
|
|
22319
|
-
}
|
|
22320
|
-
return false;
|
|
22321
|
-
};
|
|
22322
21948
|
const resetBridge = useCallback(() => {
|
|
22323
21949
|
setBridgeStatus("idle");
|
|
22324
21950
|
setBridgeQuote(null);
|
|
@@ -22350,8 +21976,7 @@ const COINGECKO_CHAIN_SLUGS = {
|
|
|
22350
21976
|
42220: "celo"
|
|
22351
21977
|
};
|
|
22352
21978
|
const LIFI_HEADERS = {
|
|
22353
|
-
"Content-Type": "application/json"
|
|
22354
|
-
...{ "x-lifi-api-key": LIFI_API_KEY }
|
|
21979
|
+
"Content-Type": "application/json"
|
|
22355
21980
|
};
|
|
22356
21981
|
const TOKEN_LIST_TTL = 10 * 60 * 1e3;
|
|
22357
21982
|
const WALLET_TOKEN_CACHE_TTL_MS = 30 * 1e3;
|
|
@@ -23336,6 +22961,36 @@ const BROKEN_TOKENS_BY_CHAIN = {
|
|
|
23336
22961
|
"USDT"
|
|
23337
22962
|
]
|
|
23338
22963
|
};
|
|
22964
|
+
const ACROSS_SUPPORTED_USDC_SOURCE_CHAINS = /* @__PURE__ */ new Set([
|
|
22965
|
+
1,
|
|
22966
|
+
10,
|
|
22967
|
+
130,
|
|
22968
|
+
137,
|
|
22969
|
+
143,
|
|
22970
|
+
232,
|
|
22971
|
+
480,
|
|
22972
|
+
999,
|
|
22973
|
+
1868,
|
|
22974
|
+
42161,
|
|
22975
|
+
534352,
|
|
22976
|
+
57073,
|
|
22977
|
+
59144,
|
|
22978
|
+
324
|
|
22979
|
+
]);
|
|
22980
|
+
const ACROSS_SUPPORTED_USDT_SOURCE_CHAINS = /* @__PURE__ */ new Set([
|
|
22981
|
+
1,
|
|
22982
|
+
10,
|
|
22983
|
+
130,
|
|
22984
|
+
137,
|
|
22985
|
+
143,
|
|
22986
|
+
999,
|
|
22987
|
+
1868,
|
|
22988
|
+
42161,
|
|
22989
|
+
534352,
|
|
22990
|
+
59144,
|
|
22991
|
+
57073,
|
|
22992
|
+
324
|
|
22993
|
+
]);
|
|
23339
22994
|
const DIRECT_EVM_PAYMENT_CHAINS = /* @__PURE__ */ new Set([
|
|
23340
22995
|
"ethereum",
|
|
23341
22996
|
"bsc",
|
|
@@ -24452,7 +24107,8 @@ const CoinleyPaymentInternal = ({
|
|
|
24452
24107
|
const isSolanaNetwork2 = (selectedNetwork == null ? void 0 : selectedNetwork.shortName) === "solana" || (selectedNetwork == null ? void 0 : selectedNetwork.chainType) === "solana";
|
|
24453
24108
|
const useGenericMobileTokenList = isMobile && showMobileWalletPicker && !!selectedMobileWallet && !connectedWalletType;
|
|
24454
24109
|
useEffect(() => {
|
|
24455
|
-
|
|
24110
|
+
var _a2;
|
|
24111
|
+
if (!useGenericMobileTokenList || !(selectedNetwork == null ? void 0 : selectedNetwork.isExtraNetwork) || !((_a2 = paymentFlow.api) == null ? void 0 : _a2.getBridgeTokens)) {
|
|
24456
24112
|
setMobileCatalogTokens([]);
|
|
24457
24113
|
return;
|
|
24458
24114
|
}
|
|
@@ -24464,30 +24120,21 @@ const CoinleyPaymentInternal = ({
|
|
|
24464
24120
|
return;
|
|
24465
24121
|
}
|
|
24466
24122
|
let cancelled = false;
|
|
24467
|
-
const lifiHeaders = { "Content-Type": "application/json", ...{ "x-lifi-api-key": LIFI_API_KEY } };
|
|
24468
24123
|
const shortName = selectedNetwork.shortName;
|
|
24469
24124
|
const networkName = selectedNetwork.name;
|
|
24470
24125
|
const stableSymbols = /* @__PURE__ */ new Set(["USDC", "USDT", "DAI"]);
|
|
24471
24126
|
(async () => {
|
|
24472
|
-
var _a2, _b;
|
|
24473
24127
|
try {
|
|
24474
|
-
const
|
|
24475
|
-
const res = await fetch(`${LIFI_API_URL}/tokens?${params.toString()}`, {
|
|
24476
|
-
headers: lifiHeaders,
|
|
24477
|
-
signal: AbortSignal.timeout(15e3)
|
|
24478
|
-
});
|
|
24479
|
-
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
24480
|
-
const data = await res.json();
|
|
24481
|
-
const chainTokens = ((_a2 = data == null ? void 0 : data.tokens) == null ? void 0 : _a2[chainId]) || ((_b = data == null ? void 0 : data.tokens) == null ? void 0 : _b[String(chainId)]) || [];
|
|
24128
|
+
const chainTokens = await paymentFlow.api.getBridgeTokens(chainId);
|
|
24482
24129
|
const entries = chainTokens.map((t) => {
|
|
24483
24130
|
const isStable = stableSymbols.has((t.symbol || "").toUpperCase());
|
|
24484
|
-
const isNative = t.address === NATIVE_TOKEN_ADDRESS;
|
|
24131
|
+
const isNative = t.address === NATIVE_TOKEN_ADDRESS || t.address === "native";
|
|
24485
24132
|
return {
|
|
24486
|
-
id: `mobile-
|
|
24133
|
+
id: `mobile-bridge-${chainId}-${t.address}`,
|
|
24487
24134
|
symbol: t.symbol,
|
|
24488
|
-
name: t.name,
|
|
24135
|
+
name: t.name || t.symbol,
|
|
24489
24136
|
contractAddress: isNative ? "native" : t.address,
|
|
24490
|
-
decimals: t.decimals,
|
|
24137
|
+
decimals: t.decimals || 18,
|
|
24491
24138
|
isStablecoin: isStable,
|
|
24492
24139
|
isSwapToken: !isStable,
|
|
24493
24140
|
balance: null,
|
|
@@ -24502,13 +24149,13 @@ const CoinleyPaymentInternal = ({
|
|
|
24502
24149
|
setMobileCatalogTokens(entries);
|
|
24503
24150
|
}
|
|
24504
24151
|
} catch (err) {
|
|
24505
|
-
console.warn("[Mobile]
|
|
24152
|
+
console.warn("[Mobile] Bridge token catalog fetch failed:", err.message);
|
|
24506
24153
|
}
|
|
24507
24154
|
})();
|
|
24508
24155
|
return () => {
|
|
24509
24156
|
cancelled = true;
|
|
24510
24157
|
};
|
|
24511
|
-
}, [useGenericMobileTokenList, selectedNetwork == null ? void 0 : selectedNetwork.isExtraNetwork, selectedNetwork == null ? void 0 : selectedNetwork.chainId, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedNetwork == null ? void 0 : selectedNetwork.name]);
|
|
24158
|
+
}, [useGenericMobileTokenList, selectedNetwork == null ? void 0 : selectedNetwork.isExtraNetwork, selectedNetwork == null ? void 0 : selectedNetwork.chainId, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedNetwork == null ? void 0 : selectedNetwork.name, paymentFlow.api]);
|
|
24512
24159
|
const availableTokens = useMemo(() => {
|
|
24513
24160
|
if (!selectedNetwork) return [];
|
|
24514
24161
|
const networkTokens = [];
|
|
@@ -25822,7 +25469,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25822
25469
|
if (currentStep === PAYMENT_STEPS.SUCCESS) {
|
|
25823
25470
|
return /* @__PURE__ */ jsxs("div", { id: SDK_ROOT_ID, className: `${SDK_ROOT_CLASS} fixed inset-0 z-50`, style: { fontFamily: FONT_FAMILY }, children: [
|
|
25824
25471
|
/* @__PURE__ */ jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50" }),
|
|
25825
|
-
/* @__PURE__ */ jsx("div", { className: isMobile ? "fixed inset-0 flex items-end" : "fixed inset-0 flex items-center justify-center p-4", style: { zIndex: 51 }, children: /* @__PURE__ */ jsx("div", { className: isMobile ? "
|
|
25472
|
+
/* @__PURE__ */ jsx("div", { className: isMobile ? "fixed inset-0 flex items-end" : "fixed inset-0 flex items-center justify-center p-4", style: { zIndex: 51 }, children: /* @__PURE__ */ jsx("div", { className: isMobile ? "relative flex w-full max-h-[92vh] flex-col overflow-y-auto rounded-t-[28px] bg-white px-4 pb-5 pt-5 animate-slide-up-sheet" : "relative flex h-[553px] w-[450px] max-w-[calc(100vw-32px)] flex-col overflow-hidden rounded-[28px] bg-white px-4 pb-5 pt-5", children: /* @__PURE__ */ jsx(
|
|
25826
25473
|
PaymentStatus,
|
|
25827
25474
|
{
|
|
25828
25475
|
status: "success",
|
|
@@ -27002,4 +26649,4 @@ export {
|
|
|
27002
26649
|
isFeatureEnabled as i,
|
|
27003
26650
|
logo as l
|
|
27004
26651
|
};
|
|
27005
|
-
//# sourceMappingURL=CoinleyPayment-
|
|
26652
|
+
//# sourceMappingURL=CoinleyPayment-pbTQ15wF.js.map
|