coinley-pay 0.52.0 → 0.54.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-Bw36JcVp.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-Bp7JOqpt.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";
@@ -21126,7 +21126,7 @@ const WalletSelector = ({
21126
21126
  try {
21127
21127
  setAppKitError(null);
21128
21128
  setWalletConnectAddress(solanaAccountState.address);
21129
- const { createWalletConnectAdapter } = await import("./appKitSolana-ZNLr1WJ6.js");
21129
+ const { createWalletConnectAdapter } = await import("./appKitSolana-FcW9To4k.js");
21130
21130
  const adapter = createWalletConnectAdapter(solanaAccountState.address);
21131
21131
  await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
21132
21132
  console.log("✅ WalletConnect synced with SDK");
@@ -21231,7 +21231,7 @@ const WalletSelector = ({
21231
21231
  setAppKitLoading(true);
21232
21232
  setAppKitError(null);
21233
21233
  try {
21234
- const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-R5T4FZOw.js");
21234
+ const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-B3xgIRTz.js");
21235
21235
  await initializeAppKitEVM(wagmiConfig);
21236
21236
  await openAppKitModal();
21237
21237
  } catch (error) {
@@ -21251,7 +21251,7 @@ const WalletSelector = ({
21251
21251
  setAppKitError(null);
21252
21252
  try {
21253
21253
  console.log("📦 Loading AppKit Solana module...");
21254
- const { initializeAppKitSolana } = await import("./appKitSolana-ZNLr1WJ6.js");
21254
+ const { initializeAppKitSolana } = await import("./appKitSolana-FcW9To4k.js");
21255
21255
  console.log("✅ Module loaded, initializing...");
21256
21256
  const modal = await initializeAppKitSolana(solanaWallet);
21257
21257
  console.log("✅ AppKit Solana initialized successfully");
@@ -23322,6 +23322,7 @@ const CoinleyPaymentInternal = ({
23322
23322
  const [ccError, setCcError] = useState(null);
23323
23323
  const [ccGenerating, setCcGenerating] = useState(false);
23324
23324
  const [ccManualCheckStatus, setCcManualCheckStatus] = useState("idle");
23325
+ const [ccRefundPendingInfo, setCcRefundPendingInfo] = useState(null);
23325
23326
  const ccSucceeded = useRef(false);
23326
23327
  const ccStatusPollInFlight = useRef(false);
23327
23328
  const ccSourcesRetryTimer = useRef(null);
@@ -23738,6 +23739,7 @@ const CoinleyPaymentInternal = ({
23738
23739
  setCcManualCheckStatus(null);
23739
23740
  setRecoveryLoadingAction(null);
23740
23741
  setRecoveryLoadingStatus(null);
23742
+ setCcRefundPendingInfo(null);
23741
23743
  clearUnderpaymentRecovery(paymentId || activeTransferPaymentId);
23742
23744
  }, [activeTransferPaymentId, clearUnderpaymentRecovery]);
23743
23745
  useEffect(() => {
@@ -23745,6 +23747,7 @@ const CoinleyPaymentInternal = ({
23745
23747
  setRefundSuccessDetails(null);
23746
23748
  setRecoveryLoadingAction(null);
23747
23749
  setRecoveryLoadingStatus(null);
23750
+ setCcRefundPendingInfo(null);
23748
23751
  }, [paymentData == null ? void 0 : paymentData.id]);
23749
23752
  const selectedNetworkIsSolana = (selectedNetwork == null ? void 0 : selectedNetwork.chainType) === "solana" || (selectedNetwork == null ? void 0 : selectedNetwork.shortName) === "solana";
23750
23753
  const sourceNeedsMerchantBridge = Boolean(
@@ -25310,6 +25313,19 @@ const CoinleyPaymentInternal = ({
25310
25313
  description: "We will process it automatically.",
25311
25314
  detail: `Refunding the received ${(underpaymentInfo == null ? void 0 : underpaymentInfo.tokenSymbol) || (selectedToken == null ? void 0 : selectedToken.symbol) || "tokens"} on ${(underpaymentInfo == null ? void 0 : underpaymentInfo.refundNetworkLabel) || (selectedNetwork == null ? void 0 : selectedNetwork.name) || (selectedNetwork == null ? void 0 : selectedNetwork.shortName) || "the selected network"}.`
25312
25315
  }), [selectedNetwork == null ? void 0 : selectedNetwork.name, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, underpaymentInfo == null ? void 0 : underpaymentInfo.refundNetworkLabel, underpaymentInfo == null ? void 0 : underpaymentInfo.tokenSymbol]);
25316
+ const getCrossChainRefundPendingStatus = useCallback((status = ccRefundPendingInfo) => {
25317
+ var _a2, _b, _c, _d;
25318
+ const details = (status == null ? void 0 : status.refundPendingDetails) || {};
25319
+ const tokenSymbol = ((_a2 = status == null ? void 0 : status.underpayment) == null ? void 0 : _a2.tokenSymbol) || ((_b = status == null ? void 0 : status.underpayment) == null ? void 0 : _b.currency) || (underpaymentInfo == null ? void 0 : underpaymentInfo.tokenSymbol) || (ccOriginToken == null ? void 0 : ccOriginToken.symbol) || (selectedToken == null ? void 0 : selectedToken.symbol) || "tokens";
25320
+ const networkLabel = ((_c = status == null ? void 0 : status.underpayment) == null ? void 0 : _c.refundNetworkLabel) || (underpaymentInfo == null ? void 0 : underpaymentInfo.refundNetworkLabel) || ccChainName(((_d = status == null ? void 0 : status.relay) == null ? void 0 : _d.originChainId) || (ccResult == null ? void 0 : ccResult.originChainId) || ccOriginChainId);
25321
+ const refundAddressLabel = (status == null ? void 0 : status.refundRecipient) || refundAddress.trim();
25322
+ const available = details.available && details.available !== "0.0" ? ` Relay has returned ${details.available} ${tokenSymbol}.` : "";
25323
+ return {
25324
+ title: "Waiting for Relay refund",
25325
+ description: "Relay is returning the underpaid funds before Coinley can send your refund.",
25326
+ detail: `We will keep checking automatically and refund ${tokenSymbol} on ${networkLabel}${refundAddressLabel ? ` to ${truncateAddress(refundAddressLabel)}` : ""}.${available}`
25327
+ };
25328
+ }, [ccOriginChainId, ccOriginToken == null ? void 0 : ccOriginToken.symbol, ccRefundPendingInfo, ccResult == null ? void 0 : ccResult.originChainId, refundAddress, selectedToken == null ? void 0 : selectedToken.symbol, underpaymentInfo == null ? void 0 : underpaymentInfo.refundNetworkLabel, underpaymentInfo == null ? void 0 : underpaymentInfo.tokenSymbol]);
25313
25329
  useEffect(() => () => {
25314
25330
  if (recoveryLoadingTimeout.current) {
25315
25331
  clearTimeout(recoveryLoadingTimeout.current);
@@ -25325,6 +25341,7 @@ const CoinleyPaymentInternal = ({
25325
25341
  setCcPhase(status.phase);
25326
25342
  if (status.refundStatus === "refunded") {
25327
25343
  finishRecoveryLoading(() => {
25344
+ setCcRefundPendingInfo(null);
25328
25345
  ccSucceeded.current = true;
25329
25346
  setRefundRequestStatus("refunded");
25330
25347
  setRefundRequestMessage("");
@@ -25332,6 +25349,14 @@ const CoinleyPaymentInternal = ({
25332
25349
  clearUnderpaymentRecovery(status.paymentId || ccResult.id);
25333
25350
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
25334
25351
  });
25352
+ } else if (status.refundStatus === "pending") {
25353
+ activateUnderpaymentFromCrossChainStatus(status);
25354
+ setCcRefundPendingInfo(status);
25355
+ setRefundRequestSubmitted(true);
25356
+ setRefundRequestStatus("pending");
25357
+ setRefundRequestMessage("");
25358
+ setCcManualCheckStatus(null);
25359
+ holdRecoveryLoading("refund", getCrossChainRefundPendingStatus(status));
25335
25360
  } else if (activateUnderpaymentFromCrossChainStatus(status)) {
25336
25361
  if (isOffsetRecovery) {
25337
25362
  setCcManualCheckStatus("not_found");
@@ -25391,17 +25416,29 @@ const CoinleyPaymentInternal = ({
25391
25416
  setCcPhase(s.phase);
25392
25417
  if (s.refundStatus === "refunded") {
25393
25418
  ccSucceeded.current = true;
25419
+ setCcRefundPendingInfo(null);
25394
25420
  setRefundRequestStatus("refunded");
25395
25421
  setRefundRequestMessage("");
25396
25422
  captureRefundSuccessDetails(s, s.refundTxHash, s.refundRecipient || refundAddress.trim());
25397
25423
  clearUnderpaymentRecovery(s.paymentId || ccResult.id);
25398
25424
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
25425
+ } else if (s.refundStatus === "pending") {
25426
+ activateUnderpaymentFromCrossChainStatus(s);
25427
+ setCcRefundPendingInfo(s);
25428
+ setRefundRequestSubmitted(true);
25429
+ setRefundRequestStatus("pending");
25430
+ setRefundRequestMessage("");
25431
+ setCcManualCheckStatus(null);
25432
+ holdRecoveryLoading("refund", getCrossChainRefundPendingStatus(s));
25399
25433
  } else if (activateUnderpaymentFromCrossChainStatus(s)) {
25434
+ setCcRefundPendingInfo(null);
25400
25435
  setCcManualCheckStatus(null);
25401
25436
  } else if (s.phase === "bridging") {
25437
+ setCcRefundPendingInfo(null);
25402
25438
  clearUnderpaymentUiState(s.paymentId || ccResult.id);
25403
25439
  } else if (s.phase === "settled" && !ccSucceeded.current) {
25404
25440
  ccSucceeded.current = true;
25441
+ setCcRefundPendingInfo(null);
25405
25442
  onSuccess == null ? void 0 : onSuccess(s);
25406
25443
  }
25407
25444
  } catch {
@@ -25415,7 +25452,7 @@ const CoinleyPaymentInternal = ({
25415
25452
  cancelled = true;
25416
25453
  clearInterval(t);
25417
25454
  };
25418
- }, [activateUnderpaymentFromCrossChainStatus, captureRefundSuccessDetails, ccResult == null ? void 0 : ccResult.id, clearUnderpaymentRecovery, clearUnderpaymentUiState, onSuccess, paymentFlow.api, refundAddress]);
25455
+ }, [activateUnderpaymentFromCrossChainStatus, captureRefundSuccessDetails, ccResult == null ? void 0 : ccResult.id, clearUnderpaymentRecovery, clearUnderpaymentUiState, getCrossChainRefundPendingStatus, holdRecoveryLoading, onSuccess, paymentFlow.api, refundAddress]);
25419
25456
  const handleGenerateTransferAddress = async () => {
25420
25457
  if (isConverting) {
25421
25458
  setError("Please wait for currency conversion to complete");
@@ -26293,7 +26330,20 @@ const CoinleyPaymentInternal = ({
26293
26330
  });
26294
26331
  } else {
26295
26332
  setRefundRequestMessage("");
26296
- holdRecoveryLoading("refund", getRefundPendingStatus());
26333
+ if (ccResult) {
26334
+ const pendingStatus = {
26335
+ refundStatus: "pending",
26336
+ refundRecipient: trimmedAddress,
26337
+ underpayment: underpaymentInfo,
26338
+ relay: {
26339
+ originChainId: ccResult.originChainId || ccOriginChainId
26340
+ }
26341
+ };
26342
+ setCcRefundPendingInfo(pendingStatus);
26343
+ holdRecoveryLoading("refund", getCrossChainRefundPendingStatus(pendingStatus));
26344
+ } else {
26345
+ holdRecoveryLoading("refund", getRefundPendingStatus());
26346
+ }
26297
26347
  }
26298
26348
  } catch (error2) {
26299
26349
  console.warn("[RefundRequest] Error:", error2.message);
@@ -26303,7 +26353,7 @@ const CoinleyPaymentInternal = ({
26303
26353
  setRefundRequestMessage(error2.message || "Failed to submit refund request. Please try again.");
26304
26354
  });
26305
26355
  }
26306
- }, [activeTransferPaymentId, captureRefundSuccessDetails, ccOriginChainId, ccOriginToken == null ? void 0 : ccOriginToken.symbol, clearUnderpaymentRecovery, config, finishRecoveryLoading, getRefundPendingStatus, holdRecoveryLoading, refundAddress, refundRequestStatus, paymentFlow.api, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, startRecoveryLoading, underpaymentInfo]);
26356
+ }, [activeTransferPaymentId, captureRefundSuccessDetails, ccOriginChainId, ccOriginToken == null ? void 0 : ccOriginToken.symbol, ccResult, clearUnderpaymentRecovery, config, finishRecoveryLoading, getCrossChainRefundPendingStatus, getRefundPendingStatus, holdRecoveryLoading, refundAddress, refundRequestStatus, paymentFlow.api, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, startRecoveryLoading, underpaymentInfo]);
26307
26357
  const handleDepositManualCheck = useCallback(async () => {
26308
26358
  if (manualCheckStatus === "checking" || !(paymentData == null ? void 0 : paymentData.id)) return;
26309
26359
  const isOffsetRecovery = Boolean(underpaymentInfo && underpaymentView === "offset");
@@ -27518,7 +27568,7 @@ const CoinleyPaymentInternal = ({
27518
27568
  const checkoutAction = renderCheckoutAction();
27519
27569
  return /* @__PURE__ */ jsxs("div", { className: `mt-auto shrink-0 ${isTightWalletView ? "pt-2 pb-0" : isCompactCheckoutView ? "pt-3 pb-0" : "pt-4 pb-1"} text-center`, children: [
27520
27570
  /* @__PURE__ */ jsx("div", { className: checkoutAction ? "mb-3 min-h-[44px]" : "mb-3 min-h-[44px]", children: checkoutAction }),
27521
- /* @__PURE__ */ jsxs("div", { className: `flex items-center justify-center gap-2 ${isTightWalletView ? "text-xs" : "text-sm"} text-[#1F2430]`, children: [
27571
+ /* @__PURE__ */ jsxs("div", { className: `flex items-center justify-center gap-1.5 ${isTightWalletView ? "text-xs" : "text-sm"} text-[#1F2430]`, children: [
27522
27572
  /* @__PURE__ */ jsxs("svg", { className: `${isTightWalletView ? "h-3.5 w-3.5" : "h-4 w-4"}`, fill: "none", stroke: "currentColor", strokeWidth: "1.8", viewBox: "0 0 24 24", children: [
27523
27573
  /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
27524
27574
  /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 7v5l3 2" })
@@ -28072,4 +28122,4 @@ export {
28072
28122
  chainTransports as c,
28073
28123
  isFeatureEnabled as i
28074
28124
  };
28075
- //# sourceMappingURL=CoinleyPayment-DkOwcvXS.js.map
28125
+ //# sourceMappingURL=CoinleyPayment-BD6rtaxd.js.map
@@ -1,4 +1,4 @@
1
- import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-DkOwcvXS.js";
1
+ import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BD6rtaxd.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-R5T4FZOw.js.map
116
+ //# sourceMappingURL=appKitEVM-B3xgIRTz.js.map
@@ -1,4 +1,4 @@
1
- import { F as FEATURES, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-DkOwcvXS.js";
1
+ import { F as FEATURES, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BD6rtaxd.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-ZNLr1WJ6.js.map
246
+ //# sourceMappingURL=appKitSolana-FcW9To4k.js.map