coinley-pay 0.27.0 → 0.28.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-CCOXI1rx.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-B6XL-PMy.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";
@@ -2896,6 +2896,7 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
2896
2896
  __coinleySelectionSnapshot: (attemptMeta == null ? void 0 : attemptMeta.selectionSnapshot) ?? null
2897
2897
  };
2898
2898
  setPaymentData(enrichedPayment);
2899
+ setPaymentType("deposit");
2899
2900
  sdkAnalytics.trackPaymentCreated(
2900
2901
  (_g = response.payment) == null ? void 0 : _g.id,
2901
2902
  config.amount,
@@ -21120,7 +21121,7 @@ const WalletSelector = ({
21120
21121
  try {
21121
21122
  setAppKitError(null);
21122
21123
  setWalletConnectAddress(solanaAccountState.address);
21123
- const { createWalletConnectAdapter } = await import("./appKitSolana-CnR-9LnG.js");
21124
+ const { createWalletConnectAdapter } = await import("./appKitSolana-BWdEszCH.js");
21124
21125
  const adapter = createWalletConnectAdapter(solanaAccountState.address);
21125
21126
  await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
21126
21127
  console.log("✅ WalletConnect synced with SDK");
@@ -21225,7 +21226,7 @@ const WalletSelector = ({
21225
21226
  setAppKitLoading(true);
21226
21227
  setAppKitError(null);
21227
21228
  try {
21228
- const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-BWbPyL29.js");
21229
+ const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-BcM7Ftoe.js");
21229
21230
  await initializeAppKitEVM(wagmiConfig);
21230
21231
  await openAppKitModal();
21231
21232
  } catch (error) {
@@ -21245,7 +21246,7 @@ const WalletSelector = ({
21245
21246
  setAppKitError(null);
21246
21247
  try {
21247
21248
  console.log("📦 Loading AppKit Solana module...");
21248
- const { initializeAppKitSolana } = await import("./appKitSolana-CnR-9LnG.js");
21249
+ const { initializeAppKitSolana } = await import("./appKitSolana-BWdEszCH.js");
21249
21250
  console.log("✅ Module loaded, initializing...");
21250
21251
  const modal = await initializeAppKitSolana(solanaWallet);
21251
21252
  console.log("✅ AppKit Solana initialized successfully");
@@ -23466,6 +23467,22 @@ const CoinleyPaymentInternal = ({
23466
23467
  setRefundRequestSubmitted(false);
23467
23468
  return true;
23468
23469
  }, [normalizeUnderpaymentInfo]);
23470
+ const activateUnderpaymentFromDepositBalance = useCallback((balanceResult) => {
23471
+ const received = Number((balanceResult == null ? void 0 : balanceResult.balance) ?? (balanceResult == null ? void 0 : balanceResult.balanceFormatted) ?? 0);
23472
+ const expected = Number((balanceResult == null ? void 0 : balanceResult.expectedAmount) ?? paymentAmount ?? 0);
23473
+ if (!received || !expected || received <= 0 || received >= expected) {
23474
+ return false;
23475
+ }
23476
+ return activateUnderpaymentFlow({
23477
+ status: "underpaid",
23478
+ paymentState: "underpaid",
23479
+ amount: expected,
23480
+ amountReceived: received,
23481
+ amountRemaining: Math.max(expected - received, 0),
23482
+ currency: (balanceResult == null ? void 0 : balanceResult.token) || (selectedToken == null ? void 0 : selectedToken.symbol),
23483
+ refundNetworkLabel: (selectedNetwork == null ? void 0 : selectedNetwork.displayName) || (selectedNetwork == null ? void 0 : selectedNetwork.name) || (selectedNetwork == null ? void 0 : selectedNetwork.shortName)
23484
+ });
23485
+ }, [activateUnderpaymentFlow, paymentAmount, selectedNetwork, selectedToken]);
23469
23486
  const selectedNetworkIsSolana = (selectedNetwork == null ? void 0 : selectedNetwork.chainType) === "solana" || (selectedNetwork == null ? void 0 : selectedNetwork.shortName) === "solana";
23470
23487
  const sourceNeedsMerchantBridge = Boolean(
23471
23488
  selectedNetwork && !selectedNetworkIsSolana && !isMerchantReceiveNetwork(selectedNetwork)
@@ -23981,7 +23998,7 @@ const CoinleyPaymentInternal = ({
23981
23998
  return () => clearInterval(pollInterval);
23982
23999
  }, [currentStep, paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.depositAddress, selectedNetwork, selectedToken, onSuccess, activateUnderpaymentFlow]);
23983
24000
  useEffect(() => {
23984
- const shouldPoll = (paymentData == null ? void 0 : paymentData.id) && (activeTab === PAYMENT_TABS.QR || activeTab === PAYMENT_TABS.TRANSFER) && currentStep === PAYMENT_STEPS.CONFIRM && !verifyingPayment && paymentType !== PAYMENT_TYPES.DEPOSIT;
24001
+ const shouldPoll = (paymentData == null ? void 0 : paymentData.id) && (activeTab === PAYMENT_TABS.QR || activeTab === PAYMENT_TABS.TRANSFER) && currentStep === PAYMENT_STEPS.CONFIRM && !verifyingPayment && paymentType !== PAYMENT_TYPES.DEPOSIT && !(paymentData == null ? void 0 : paymentData.isDepositPayment) && !(paymentData == null ? void 0 : paymentData.depositAddress);
23985
24002
  if (!shouldPoll) {
23986
24003
  return;
23987
24004
  }
@@ -24061,7 +24078,7 @@ const CoinleyPaymentInternal = ({
24061
24078
  console.log("🛑 Stopping auto-detection polling");
24062
24079
  clearInterval(pollInterval);
24063
24080
  };
24064
- }, [paymentData == null ? void 0 : paymentData.id, activeTab, currentStep, verifyingPayment, paymentType, selectedNetwork, selectedToken, onSuccess, paymentFlow.api]);
24081
+ }, [paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.isDepositPayment, paymentData == null ? void 0 : paymentData.depositAddress, activeTab, currentStep, verifyingPayment, paymentType, selectedNetwork, selectedToken, onSuccess, paymentFlow.api]);
24065
24082
  const resetAllTransactionState = async () => {
24066
24083
  var _a2;
24067
24084
  invalidateCurrentAttempt("reset-all-transaction-state");
@@ -25617,6 +25634,12 @@ const CoinleyPaymentInternal = ({
25617
25634
  return;
25618
25635
  }
25619
25636
  }
25637
+ if (paymentData == null ? void 0 : paymentData.depositAddress) {
25638
+ const balanceResult = await paymentFlow.api.getDepositBalance(paymentData.id);
25639
+ if ((balanceResult == null ? void 0 : balanceResult.success) && activateUnderpaymentFromDepositBalance(balanceResult)) {
25640
+ return;
25641
+ }
25642
+ }
25620
25643
  setManualCheckStatus("not_found");
25621
25644
  manualCheckTimeout.current = setTimeout(() => {
25622
25645
  setManualCheckStatus(null);
@@ -25628,7 +25651,7 @@ const CoinleyPaymentInternal = ({
25628
25651
  setManualCheckStatus(null);
25629
25652
  }, 1e4);
25630
25653
  }
25631
- }, [manualCheckStatus, paymentData == null ? void 0 : paymentData.id, paymentFlow.api, config == null ? void 0 : config.amount, selectedNetwork, selectedToken, onSuccess, activateUnderpaymentFlow]);
25654
+ }, [manualCheckStatus, paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.depositAddress, paymentFlow.api, config == null ? void 0 : config.amount, selectedNetwork, selectedToken, onSuccess, activateUnderpaymentFlow, activateUnderpaymentFromDepositBalance]);
25632
25655
  if (!isOpen) return null;
25633
25656
  if (currentStep === PAYMENT_STEPS.PROCESSING) {
25634
25657
  return /* @__PURE__ */ jsxs("div", { id: SDK_ROOT_ID, className: `${SDK_ROOT_CLASS} fixed inset-0 z-50`, style: { fontFamily: FONT_FAMILY }, children: [
@@ -26993,4 +27016,4 @@ export {
26993
27016
  isFeatureEnabled as i,
26994
27017
  logo as l
26995
27018
  };
26996
- //# sourceMappingURL=CoinleyPayment-Dy4VNYcm.js.map
27019
+ //# sourceMappingURL=CoinleyPayment-Bql8B8cV.js.map
@@ -1,4 +1,4 @@
1
- import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID, l as logo } from "./CoinleyPayment-Dy4VNYcm.js";
1
+ import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID, l as logo } from "./CoinleyPayment-Bql8B8cV.js";
2
2
  let appKitInstance = null;
3
3
  let isInitializing = false;
4
4
  let initializationPromise = null;
@@ -112,4 +112,4 @@ export {
112
112
  initializeAppKitEVM,
113
113
  openAppKitModal
114
114
  };
115
- //# sourceMappingURL=appKitEVM-BWbPyL29.js.map
115
+ //# sourceMappingURL=appKitEVM-BcM7Ftoe.js.map
@@ -1,4 +1,4 @@
1
- import { F as FEATURES, l as logo, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-Dy4VNYcm.js";
1
+ import { F as FEATURES, l as logo, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-Bql8B8cV.js";
2
2
  let appKitInstance = null;
3
3
  let isInitializing = false;
4
4
  let initializationPromise = null;
@@ -242,4 +242,4 @@ export {
242
242
  disconnectWalletConnect,
243
243
  initializeAppKitSolana
244
244
  };
245
- //# sourceMappingURL=appKitSolana-CnR-9LnG.js.map
245
+ //# sourceMappingURL=appKitSolana-BWdEszCH.js.map