coinley-pay 0.50.0 → 0.52.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.
@@ -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-DgL8JZEZ.js";
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-Bw36JcVp.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";
@@ -2475,8 +2475,12 @@ class SimplePaymentAPI {
2475
2475
  // customer sends to a Relay-generated source-chain address that bridges to the
2476
2476
  // merchant's settlement chain. Backend resolves the destination.
2477
2477
  async getCrossChainSources() {
2478
+ var _a;
2478
2479
  const result = await this.request("/api/payments/cross-chain/sources");
2479
- return (result == null ? void 0 : result.sources) || [];
2480
+ if (Array.isArray(result)) return result;
2481
+ if (Array.isArray(result == null ? void 0 : result.sources)) return result.sources;
2482
+ if (Array.isArray((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.sources)) return result.data.sources;
2483
+ return [];
2480
2484
  }
2481
2485
  async createCrossChainPayment(data) {
2482
2486
  return await this.request("/api/payments/cross-chain/create", {
@@ -21122,7 +21126,7 @@ const WalletSelector = ({
21122
21126
  try {
21123
21127
  setAppKitError(null);
21124
21128
  setWalletConnectAddress(solanaAccountState.address);
21125
- const { createWalletConnectAdapter } = await import("./appKitSolana-Bmo8nV6E.js");
21129
+ const { createWalletConnectAdapter } = await import("./appKitSolana-ZNLr1WJ6.js");
21126
21130
  const adapter = createWalletConnectAdapter(solanaAccountState.address);
21127
21131
  await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
21128
21132
  console.log("✅ WalletConnect synced with SDK");
@@ -21227,7 +21231,7 @@ const WalletSelector = ({
21227
21231
  setAppKitLoading(true);
21228
21232
  setAppKitError(null);
21229
21233
  try {
21230
- const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-DjCR_sZH.js");
21234
+ const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-R5T4FZOw.js");
21231
21235
  await initializeAppKitEVM(wagmiConfig);
21232
21236
  await openAppKitModal();
21233
21237
  } catch (error) {
@@ -21247,7 +21251,7 @@ const WalletSelector = ({
21247
21251
  setAppKitError(null);
21248
21252
  try {
21249
21253
  console.log("📦 Loading AppKit Solana module...");
21250
- const { initializeAppKitSolana } = await import("./appKitSolana-Bmo8nV6E.js");
21254
+ const { initializeAppKitSolana } = await import("./appKitSolana-ZNLr1WJ6.js");
21251
21255
  console.log("✅ Module loaded, initializing...");
21252
21256
  const modal = await initializeAppKitSolana(solanaWallet);
21253
21257
  console.log("✅ AppKit Solana initialized successfully");
@@ -23320,6 +23324,7 @@ const CoinleyPaymentInternal = ({
23320
23324
  const [ccManualCheckStatus, setCcManualCheckStatus] = useState("idle");
23321
23325
  const ccSucceeded = useRef(false);
23322
23326
  const ccStatusPollInFlight = useRef(false);
23327
+ const ccSourcesRetryTimer = useRef(null);
23323
23328
  const [networkSearch, setNetworkSearch] = useState("");
23324
23329
  const [walletNetworkSearch, setWalletNetworkSearch] = useState("");
23325
23330
  const [openCheckoutDropdown, setOpenCheckoutDropdown] = useState(null);
@@ -25178,21 +25183,42 @@ const CoinleyPaymentInternal = ({
25178
25183
  clarityAnalytics.trackTokenSelected(token == null ? void 0 : token.symbol, selectedNetwork == null ? void 0 : selectedNetwork.name, config == null ? void 0 : config.merchantName);
25179
25184
  };
25180
25185
  useEffect(() => {
25181
- if (ccSources.length) return;
25186
+ var _a2;
25187
+ if (ccSources.length || !((_a2 = paymentFlow.api) == null ? void 0 : _a2.getCrossChainSources)) return;
25182
25188
  let cancelled = false;
25183
- paymentFlow.api.getCrossChainSources().then((s) => {
25184
- if (cancelled) return;
25185
- setCcSources(Array.isArray(s) ? s : []);
25186
- setCcError(null);
25187
- }).catch((e) => {
25188
- if (cancelled) return;
25189
- console.warn("[CrossChainSources] Failed to load source networks:", (e == null ? void 0 : e.message) || e);
25190
- setCcError(null);
25191
- });
25189
+ const clearRetry = () => {
25190
+ if (ccSourcesRetryTimer.current) {
25191
+ clearTimeout(ccSourcesRetryTimer.current);
25192
+ ccSourcesRetryTimer.current = null;
25193
+ }
25194
+ };
25195
+ const fetchSources = async (allowRetry = false) => {
25196
+ try {
25197
+ const s = await paymentFlow.api.getCrossChainSources();
25198
+ if (cancelled) return;
25199
+ const sources = Array.isArray(s) ? s : [];
25200
+ setCcSources(sources);
25201
+ setCcError(null);
25202
+ if (sources.length === 0 && allowRetry) {
25203
+ clearRetry();
25204
+ ccSourcesRetryTimer.current = setTimeout(() => fetchSources(false), 1200);
25205
+ }
25206
+ } catch (e) {
25207
+ if (cancelled) return;
25208
+ console.warn("[CrossChainSources] Failed to load source networks:", (e == null ? void 0 : e.message) || e);
25209
+ setCcError(null);
25210
+ if (allowRetry) {
25211
+ clearRetry();
25212
+ ccSourcesRetryTimer.current = setTimeout(() => fetchSources(false), 1200);
25213
+ }
25214
+ }
25215
+ };
25216
+ fetchSources(activeTab === PAYMENT_TABS.TRANSFER);
25192
25217
  return () => {
25193
25218
  cancelled = true;
25219
+ clearRetry();
25194
25220
  };
25195
- }, [ccSources.length, paymentFlow.api]);
25221
+ }, [activeTab, ccSources.length, paymentFlow.api]);
25196
25222
  const ccOriginTokens = useMemo(() => {
25197
25223
  const c = ccSources.find((s) => Number(s.chainId) === Number(ccOriginChainId));
25198
25224
  return c ? c.tokens : [];
@@ -28046,4 +28072,4 @@ export {
28046
28072
  chainTransports as c,
28047
28073
  isFeatureEnabled as i
28048
28074
  };
28049
- //# sourceMappingURL=CoinleyPayment-BGguZgUq.js.map
28075
+ //# sourceMappingURL=CoinleyPayment-DkOwcvXS.js.map
@@ -1,4 +1,4 @@
1
- import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BGguZgUq.js";
1
+ import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-DkOwcvXS.js";
2
2
  const logo = "https://coinley.io/logo.png";
3
3
  let appKitInstance = null;
4
4
  let isInitializing = false;
@@ -113,4 +113,4 @@ export {
113
113
  initializeAppKitEVM,
114
114
  openAppKitModal
115
115
  };
116
- //# sourceMappingURL=appKitEVM-DjCR_sZH.js.map
116
+ //# sourceMappingURL=appKitEVM-R5T4FZOw.js.map
@@ -1,4 +1,4 @@
1
- import { F as FEATURES, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BGguZgUq.js";
1
+ import { F as FEATURES, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-DkOwcvXS.js";
2
2
  const logo = "https://coinley.io/logo.png";
3
3
  let appKitInstance = null;
4
4
  let isInitializing = false;
@@ -243,4 +243,4 @@ export {
243
243
  disconnectWalletConnect,
244
244
  initializeAppKitSolana
245
245
  };
246
- //# sourceMappingURL=appKitSolana-Bmo8nV6E.js.map
246
+ //# sourceMappingURL=appKitSolana-ZNLr1WJ6.js.map