coinley-pay 0.17.0 → 0.18.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-ArVDuAUY.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-DjkvRRWK.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";
@@ -3616,6 +3616,11 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3616
3616
  const { isLoading: isConfirming, isSuccess: isConfirmed } = useWaitForTransactionReceipt({
3617
3617
  hash: txHash
3618
3618
  });
3619
+ const finalizePaymentInBackground = (transactionHash, activePaymentData) => {
3620
+ processFinalPayment(transactionHash, activePaymentData, { background: true }).catch((error) => {
3621
+ console.error("[processFinalPayment] Background finalization failed:", error);
3622
+ });
3623
+ };
3619
3624
  const executePaymentTransaction = async (paymentOverride = null) => {
3620
3625
  var _a, _b;
3621
3626
  const activePaymentData = paymentOverride || paymentData;
@@ -3724,7 +3729,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3724
3729
  setTransactionStep("splitPayment");
3725
3730
  const splitPaymentHash2 = await executeSplitPayment();
3726
3731
  if (splitPaymentHash2) {
3727
- await processFinalPayment(splitPaymentHash2, activePaymentData);
3732
+ finalizePaymentInBackground(splitPaymentHash2, activePaymentData);
3728
3733
  }
3729
3734
  return splitPaymentHash2;
3730
3735
  }
@@ -3792,7 +3797,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3792
3797
  }
3793
3798
  const splitPaymentHash = await executeSplitPayment();
3794
3799
  if (splitPaymentHash) {
3795
- await processFinalPayment(splitPaymentHash, activePaymentData);
3800
+ finalizePaymentInBackground(splitPaymentHash, activePaymentData);
3796
3801
  }
3797
3802
  return splitPaymentHash;
3798
3803
  } catch (error) {
@@ -3898,11 +3903,14 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3898
3903
  throw error;
3899
3904
  }
3900
3905
  };
3901
- const processFinalPayment = async (transactionHash, paymentOverride = null) => {
3906
+ const processFinalPayment = async (transactionHash, paymentOverride = null, options = {}) => {
3902
3907
  var _a;
3903
3908
  const activePaymentData = paymentOverride || paymentData;
3909
+ const runInBackground = (options == null ? void 0 : options.background) === true;
3904
3910
  try {
3905
- setTransactionStep("processing");
3911
+ if (!runInBackground) {
3912
+ setTransactionStep("processing");
3913
+ }
3906
3914
  console.log("🔄 [processFinalPayment] Starting payment finalization...");
3907
3915
  if (approveTransactionHash && transactionHash === approveTransactionHash) {
3908
3916
  console.error("🛑 [processFinalPayment] BLOCKED: Attempted to send approve hash to backend!", {
@@ -3914,8 +3922,10 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3914
3922
  if (!api || !api.processPayment) {
3915
3923
  throw new Error("API instance not available or missing processPayment method");
3916
3924
  }
3917
- console.log("⏳ [processFinalPayment] Waiting 4s for blockchain indexers to sync...");
3918
- await new Promise((resolve) => setTimeout(resolve, 4e3));
3925
+ if (!runInBackground) {
3926
+ console.log("⏳ [processFinalPayment] Waiting 4s for blockchain indexers to sync...");
3927
+ await new Promise((resolve) => setTimeout(resolve, 4e3));
3928
+ }
3919
3929
  const maxProcessRetries = 3;
3920
3930
  let lastProcessError = null;
3921
3931
  for (let processAttempt = 0; processAttempt < maxProcessRetries; processAttempt++) {
@@ -3934,7 +3944,9 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3934
3944
  );
3935
3945
  if (processResult && processResult.success !== false) {
3936
3946
  console.log("✅ [processFinalPayment] API.processPayment succeeded:", processResult);
3937
- setTransactionStep("success");
3947
+ if (!runInBackground) {
3948
+ setTransactionStep("success");
3949
+ }
3938
3950
  sdkAnalytics.trackPaymentSuccess(
3939
3951
  activePaymentData.id,
3940
3952
  activePaymentData.amount,
@@ -3982,8 +3994,10 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3982
3994
  console.error("❌ [processFinalPayment] Formatted error log:", errorLog);
3983
3995
  const friendlyError = parseUserFriendlyError(error);
3984
3996
  console.error("❌ [processFinalPayment] User-friendly error:", friendlyError);
3985
- setTransactionError(friendlyError);
3986
- setTransactionStep("error");
3997
+ if (!runInBackground) {
3998
+ setTransactionError(friendlyError);
3999
+ setTransactionStep("error");
4000
+ }
3987
4001
  sdkAnalytics.trackPaymentFailed(
3988
4002
  activePaymentData == null ? void 0 : activePaymentData.id,
3989
4003
  activePaymentData == null ? void 0 : activePaymentData.amount,
@@ -21106,7 +21120,7 @@ const WalletSelector = ({
21106
21120
  try {
21107
21121
  setAppKitError(null);
21108
21122
  setWalletConnectAddress(solanaAccountState.address);
21109
- const { createWalletConnectAdapter } = await import("./appKitSolana-jtnvPa0Y.js");
21123
+ const { createWalletConnectAdapter } = await import("./appKitSolana-COVsc1hI.js");
21110
21124
  const adapter = createWalletConnectAdapter(solanaAccountState.address);
21111
21125
  await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
21112
21126
  console.log("✅ WalletConnect synced with SDK");
@@ -21211,7 +21225,7 @@ const WalletSelector = ({
21211
21225
  setAppKitLoading(true);
21212
21226
  setAppKitError(null);
21213
21227
  try {
21214
- const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-CH55u3Is.js");
21228
+ const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-7klvcQWP.js");
21215
21229
  await initializeAppKitEVM(wagmiConfig);
21216
21230
  await openAppKitModal();
21217
21231
  } catch (error) {
@@ -21231,7 +21245,7 @@ const WalletSelector = ({
21231
21245
  setAppKitError(null);
21232
21246
  try {
21233
21247
  console.log("📦 Loading AppKit Solana module...");
21234
- const { initializeAppKitSolana } = await import("./appKitSolana-jtnvPa0Y.js");
21248
+ const { initializeAppKitSolana } = await import("./appKitSolana-COVsc1hI.js");
21235
21249
  console.log("✅ Module loaded, initializing...");
21236
21250
  const modal = await initializeAppKitSolana(solanaWallet);
21237
21251
  console.log("✅ AppKit Solana initialized successfully");
@@ -26981,4 +26995,4 @@ export {
26981
26995
  isFeatureEnabled as i,
26982
26996
  logo as l
26983
26997
  };
26984
- //# sourceMappingURL=CoinleyPayment-DWGoIei3.js.map
26998
+ //# sourceMappingURL=CoinleyPayment-BRiKHFaK.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-DWGoIei3.js";
1
+ import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID, l as logo } from "./CoinleyPayment-BRiKHFaK.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-CH55u3Is.js.map
115
+ //# sourceMappingURL=appKitEVM-7klvcQWP.js.map
@@ -1,4 +1,4 @@
1
- import { F as FEATURES, l as logo, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-DWGoIei3.js";
1
+ import { F as FEATURES, l as logo, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BRiKHFaK.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-jtnvPa0Y.js.map
245
+ //# sourceMappingURL=appKitSolana-COVsc1hI.js.map