coinley-test 0.36.102 → 0.37.102

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/index.esm.js CHANGED
@@ -15,15 +15,6 @@ const ALCHEMY_API_KEY_PRIMARY = "YWG990wOlIikc1tU7-WWTepfU8d1f4dp";
15
15
  const ALCHEMY_API_KEY_SECONDARY = "qtIcCe_-8t4rIWktnWJm0";
16
16
  const WAGMI_CONFIG_VERSION = "2.7.0-dual-alchemy-keys";
17
17
  console.log("🔧 SDK wagmiConfig version:", WAGMI_CONFIG_VERSION);
18
- console.log("🌐 SDK RPC config:", "Dual Alchemy keys (primary + secondary failover) + Public fallbacks (3-4 endpoints per chain)");
19
- console.log("⚡ Alchemy networks: ALL 8 CHAINS (Ethereum, BSC, Polygon, Arbitrum, Optimism, Avalanche, Celo, Base)");
20
- console.log("🔐 Alchemy failover: 2 API keys for maximum reliability (auto-failover on rate limit/error)");
21
- console.log("✅ Ethereum simulation bypass: Working (proven by Etherscan 100% success rate)");
22
- console.log("🔍 Enhanced error extraction: Hex error data, panic detection, custom errors");
23
- console.log("🎯 UX improvement: Blockchain explorer links added to success screen");
24
- console.log("🔄 Balance check fallback: Wallet RPC → App fallback RPC (fixes Coinbase Wallet issues)");
25
- console.log("🔧 ChainId normalization: Unified normalizeChainId() util handles hex/decimal/number");
26
- console.log("⏳ Backend sync delay: 8s wait before API call (prevents RPC indexing lag errors)");
27
18
  const getConnectors = () => {
28
19
  const baseConnectors = [
29
20
  injected(),
@@ -151,7 +142,6 @@ let SimplePaymentAPI$1 = class SimplePaymentAPI {
151
142
  try {
152
143
  return await this.request("/api/networks");
153
144
  } catch (error) {
154
- console.error("Failed to fetch networks:", error);
155
145
  return {
156
146
  networks: [
157
147
  { id: "1", name: "Ethereum", shortName: "ethereum", chainId: "0x1", type: "ethereum" },
@@ -168,7 +158,6 @@ let SimplePaymentAPI$1 = class SimplePaymentAPI {
168
158
  try {
169
159
  return await this.request("/api/networks/stablecoins");
170
160
  } catch (error) {
171
- console.error("Failed to fetch tokens:", error);
172
161
  return {
173
162
  stablecoins: [
174
163
  // Ethereum Network
@@ -350,7 +339,6 @@ let SimplePaymentAPI$1 = class SimplePaymentAPI {
350
339
  }
351
340
  return response.contractInfo;
352
341
  } catch (error) {
353
- console.error("❌ Failed to get contract info:", error);
354
342
  throw new Error(error.message || "Failed to get contract information");
355
343
  }
356
344
  }
@@ -377,14 +365,8 @@ let SimplePaymentAPI$1 = class SimplePaymentAPI {
377
365
  timeout: 9e4
378
366
  // 90 seconds - blockchain verification can be slow
379
367
  });
380
- console.log("✅ [API] processPayment succeeded:", result);
381
368
  return result;
382
369
  } catch (error) {
383
- console.error("❌ [API] processPayment failed:", {
384
- error: error.message,
385
- name: error.name,
386
- stack: error.stack
387
- });
388
370
  throw error;
389
371
  }
390
372
  }
@@ -419,7 +401,6 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
419
401
  try {
420
402
  setLoading(true);
421
403
  setError("");
422
- console.log("🔄 Loading networks and tokens...");
423
404
  const [networksRes, tokensRes] = await Promise.all([
424
405
  api.current.getNetworks(),
425
406
  api.current.getTokens()
@@ -453,15 +434,7 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
453
434
  }, [])) || [];
454
435
  setNetworks(uniqueNetworks);
455
436
  setTokens(uniqueTokens);
456
- console.log("✅ Loaded unique networks:", uniqueNetworks.length);
457
- console.log("📋 Networks:", uniqueNetworks.map((n) => `${n.name} (${n.shortName}, chainId: ${n.chainId})`));
458
- console.log("✅ Loaded unique tokens:", uniqueTokens.length);
459
- console.log("📋 Tokens:", uniqueTokens.map((t) => {
460
- var _a2;
461
- return `${t.symbol} on ${((_a2 = t.Network) == null ? void 0 : _a2.name) || "Unknown"}`;
462
- }));
463
437
  } catch (err) {
464
- console.error("Failed to load data:", err);
465
438
  setError("Failed to load payment options. Using fallback data.");
466
439
  } finally {
467
440
  setLoading(false);
@@ -486,13 +459,10 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
486
459
  wagmiEnabled: true
487
460
  }
488
461
  };
489
- console.log("🔄 Creating payment:", paymentPayload);
490
462
  const payment = await api.current.createPayment(paymentPayload);
491
463
  setPaymentData(payment.payment);
492
- console.log("✅ Payment created:", payment.payment.id);
493
464
  setCurrentStep("confirm");
494
465
  } catch (err) {
495
- console.error("Payment creation failed:", err);
496
466
  setError(err.message);
497
467
  } finally {
498
468
  setLoading(false);
@@ -501,11 +471,8 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
501
471
  const failPayment = async (reason = "Payment cancelled by user") => {
502
472
  if (paymentData == null ? void 0 : paymentData.id) {
503
473
  try {
504
- console.log("🚫 Payment cancelled by user, notifying backend...", paymentData.id);
505
474
  await api.current.failPayment(paymentData.id, reason);
506
- console.log("✅ Backend notified of payment cancellation");
507
475
  } catch (error2) {
508
- console.error("❌ Failed to notify backend of payment cancellation:", error2);
509
476
  }
510
477
  }
511
478
  };
@@ -606,7 +573,6 @@ const useWalletConnection = () => {
606
573
  const handleWalletSelection = (walletType) => {
607
574
  setSelectedWalletType(walletType);
608
575
  setConnectionError("");
609
- console.log(`📱 Selected wallet type: ${walletType}`);
610
576
  };
611
577
  const connectWallet = async (connector, selectedNetwork = null) => {
612
578
  var _a, _b, _c;
@@ -616,27 +582,20 @@ const useWalletConnection = () => {
616
582
  }
617
583
  try {
618
584
  setConnectionError("");
619
- console.log(`🔗 Connecting to ${connector.name} wallet...`);
620
585
  await connect({ connector });
621
- console.log(`✅ ${connector.name} wallet connected successfully`);
622
586
  if (selectedNetwork) {
623
587
  const requiredChainId = getChainId(selectedNetwork.shortName);
624
588
  const walletName = ((_a = connector.name) == null ? void 0 : _a.toLowerCase()) || "";
625
589
  const needsLongerDelay = walletName.includes("zerion") || walletName.includes("trust") || walletName.includes("rabby");
626
590
  const delayMs = needsLongerDelay ? 5e3 : 500;
627
- console.log(`⏳ Waiting ${delayMs}ms for ${connector.name} to initialize...`);
628
591
  await new Promise((resolve) => setTimeout(resolve, delayMs));
629
592
  const currentAccount = getAccount(wagmiConfig);
630
593
  const currentChainId = currentAccount.chainId;
631
- console.log(`🔍 Network check: Current chain ${currentChainId}, Required chain ${requiredChainId} (${selectedNetwork.name})`);
632
594
  if (requiredChainId && currentChainId !== requiredChainId) {
633
- console.log(`🔄 Switching from chain ${currentChainId} to ${requiredChainId} (${selectedNetwork.name})`);
634
595
  try {
635
596
  await switchChain({ chainId: requiredChainId });
636
- console.log(`✅ Successfully switched to ${selectedNetwork.name}`);
637
597
  await new Promise((resolve) => setTimeout(resolve, 1e3));
638
598
  } catch (switchError) {
639
- console.error("❌ Network switch failed:", switchError);
640
599
  if (switchError.code === 4001 || ((_b = switchError.message) == null ? void 0 : _b.includes("User rejected"))) {
641
600
  setConnectionError("Network switch was cancelled by user");
642
601
  } else if ((_c = switchError.message) == null ? void 0 : _c.includes("Unrecognized chain ID")) {
@@ -650,7 +609,6 @@ const useWalletConnection = () => {
650
609
  }
651
610
  return true;
652
611
  } catch (err) {
653
- console.error(`${connector.name} wallet connection failed:`, err);
654
612
  if (err.code === 4001 || err.message.includes("User rejected") || err.message.includes("rejected")) {
655
613
  setConnectionError("User cancelled the connection request");
656
614
  } else {
@@ -670,23 +628,18 @@ const useWalletConnection = () => {
670
628
  const ensureCorrectNetwork = async (requiredNetwork) => {
671
629
  var _a, _b;
672
630
  if (!requiredNetwork) {
673
- console.warn("⚠️ No network specified for verification");
674
631
  return true;
675
632
  }
676
633
  try {
677
634
  const requiredChainId = getChainId(requiredNetwork.shortName);
678
635
  const currentAccount = getAccount(wagmiConfig);
679
636
  const currentChainId = currentAccount.chainId;
680
- console.log(`🔍 Network verification: Current=${currentChainId}, Required=${requiredChainId} (${requiredNetwork.name})`);
681
637
  if (requiredChainId && currentChainId !== requiredChainId) {
682
- console.log(`🔄 Wrong network detected! Switching from chain ${currentChainId} to ${requiredChainId}...`);
683
638
  try {
684
639
  await switchChain({ chainId: requiredChainId });
685
- console.log(`✅ Successfully switched to ${requiredNetwork.name}`);
686
640
  await new Promise((resolve) => setTimeout(resolve, 1e3));
687
641
  return true;
688
642
  } catch (switchError) {
689
- console.error("❌ Network switch failed:", switchError);
690
643
  if (switchError.code === 4001 || ((_a = switchError.message) == null ? void 0 : _a.includes("User rejected"))) {
691
644
  setConnectionError("Network switch was cancelled. Please switch to the correct network in your wallet.");
692
645
  } else if ((_b = switchError.message) == null ? void 0 : _b.includes("Unrecognized chain ID")) {
@@ -697,10 +650,8 @@ const useWalletConnection = () => {
697
650
  return false;
698
651
  }
699
652
  }
700
- console.log(`✅ Already on correct network: ${requiredNetwork.name}`);
701
653
  return true;
702
654
  } catch (error) {
703
- console.error("❌ Network verification failed:", error);
704
655
  setConnectionError("Failed to verify network. Please check your wallet connection.");
705
656
  return false;
706
657
  }
@@ -3416,9 +3367,6 @@ const parseUserFriendlyError = (error) => {
3416
3367
  var _a, _b;
3417
3368
  const errorMessage = ((_a = error == null ? void 0 : error.message) == null ? void 0 : _a.toLowerCase()) || ((_b = error == null ? void 0 : error.toString()) == null ? void 0 : _b.toLowerCase()) || "";
3418
3369
  const errorCode = (error == null ? void 0 : error.code) || (error == null ? void 0 : error.reason) || "";
3419
- console.log("🔍 Original error:", error);
3420
- console.log("🔍 Error message:", errorMessage);
3421
- console.log("🔍 Error code:", errorCode);
3422
3370
  if (errorMessage.includes("user rejected") || errorMessage.includes("user denied") || errorMessage.includes("user cancelled") || errorMessage.includes("rejected by user") || errorCode === 4001 || errorCode === "ACTION_REJECTED") {
3423
3371
  return {
3424
3372
  type: "user_rejected",
@@ -3581,27 +3529,7 @@ const formatErrorForLogging = (error, context = "") => {
3581
3529
  }
3582
3530
  };
3583
3531
  };
3584
- const TRANSACTION_HANDLER_VERSION = "2.6.0-base-network";
3585
- const FIX_DATE = "2025-10-24";
3586
- const FIXES_APPLIED = [
3587
- "✅ 3s RPC propagation delay after approval (Coinbase Wallet fix)",
3588
- "✅ Allowance verification loop (3 attempts, 2s intervals)",
3589
- "✅ Avalanche simulation bypass (JSON-RPC error workaround)",
3590
- "✅ Ethereum simulation bypass (stale RPC state workaround)",
3591
- "✅ 120s transaction timeout (was 60s)",
3592
- "✅ 20% gas price buffer (FIXED: proper estimateFeesPerGas import)",
3593
- "✅ Balance check fallback RPC (Alchemy primary, 3+ public fallbacks)",
3594
- "✅ USDT reset handling",
3595
- "⚡ Alchemy RPCs: ALL 8 CHAINS (ETH, BSC, MATIC, ARB, OP, AVAX, CELO, BASE) - 99.9% uptime",
3596
- '✅ 8s backend sync delay (prevents "payment not found" RPC indexing lag)',
3597
- "🆕 Base network support (Chain ID 8453, Contract: 0x6D827e60d0dC279cAa09f026d1641ECDb5704753)"
3598
- ];
3599
- console.log(`%c🔖 Transaction Handler Version: ${TRANSACTION_HANDLER_VERSION}`, "color: #00ff00; font-weight: bold; font-size: 14px;");
3600
- console.log(`%c📅 Build Date: ${FIX_DATE}`, "color: #00aaff; font-weight: bold;");
3601
- console.log(`%c🛠️ Fixes Applied:`, "color: #ffaa00; font-weight: bold;");
3602
- FIXES_APPLIED.forEach((fix) => console.log(`%c ${fix}`, "color: #aaaaaa;"));
3603
3532
  const getGasFeesWithBuffer = async (wagmiConfig2, chainId) => {
3604
- var _a, _b, _c, _d;
3605
3533
  try {
3606
3534
  const gasPrice = await estimateFeesPerGas(wagmiConfig2, { chainId });
3607
3535
  const GAS_BUFFER_MULTIPLIER = 120n;
@@ -3610,19 +3538,8 @@ const getGasFeesWithBuffer = async (wagmiConfig2, chainId) => {
3610
3538
  maxFeePerGas: gasPrice.maxFeePerGas ? gasPrice.maxFeePerGas * GAS_BUFFER_MULTIPLIER / MULTIPLIER_BASE : void 0,
3611
3539
  maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas ? gasPrice.maxPriorityFeePerGas * GAS_BUFFER_MULTIPLIER / MULTIPLIER_BASE : void 0
3612
3540
  };
3613
- console.log("⛽ Gas price with 20% buffer:", {
3614
- original: {
3615
- maxFeePerGas: (_a = gasPrice.maxFeePerGas) == null ? void 0 : _a.toString(),
3616
- maxPriorityFeePerGas: (_b = gasPrice.maxPriorityFeePerGas) == null ? void 0 : _b.toString()
3617
- },
3618
- buffered: {
3619
- maxFeePerGas: (_c = bufferedFees.maxFeePerGas) == null ? void 0 : _c.toString(),
3620
- maxPriorityFeePerGas: (_d = bufferedFees.maxPriorityFeePerGas) == null ? void 0 : _d.toString()
3621
- }
3622
- });
3623
3541
  return bufferedFees;
3624
3542
  } catch (error) {
3625
- console.warn("⚠️ Could not estimate gas with buffer, using default:", error.message);
3626
3543
  return {};
3627
3544
  }
3628
3545
  };
@@ -3704,7 +3621,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3704
3621
  hash: txHash
3705
3622
  });
3706
3623
  const executePaymentTransaction = async () => {
3707
- var _a, _b, _c, _d;
3624
+ var _a, _b;
3708
3625
  if (!address || !(paymentData == null ? void 0 : paymentData.contractCall)) {
3709
3626
  throw new Error("Missing wallet connection or payment data");
3710
3627
  }
@@ -3712,36 +3629,19 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3712
3629
  if (!contractCall.contractAddress) {
3713
3630
  throw new Error("PaymentSplitter contract data missing from payment response");
3714
3631
  }
3715
- console.log("🔍 PaymentSplitter Details:", {
3716
- contractAddress: contractCall.contractAddress,
3717
- tokenAddress: contractCall.tokenAddress,
3718
- params: contractCall.params
3719
- });
3720
3632
  if ((walletConnection == null ? void 0 : walletConnection.ensureCorrectNetwork) && selectedNetwork) {
3721
- console.log("🔍 Verifying network before transaction...");
3722
3633
  const networkOk = await walletConnection.ensureCorrectNetwork(selectedNetwork);
3723
3634
  if (!networkOk) {
3724
- console.error("❌ Network verification failed - transaction aborted");
3725
3635
  throw new Error("Network verification failed. Please ensure you are on the correct network.");
3726
3636
  }
3727
- console.log("✅ Network verified - proceeding with transaction");
3728
3637
  }
3729
3638
  if (selectedToken.contractAddress) {
3730
- console.log("📝 Starting PaymentSplitter flow for ERC-20 token...");
3731
3639
  const decimals = selectedToken.decimals || 6;
3732
3640
  const amount = contractCall.approvalAmount || Math.floor(paymentData.totalAmount * Math.pow(10, decimals));
3733
- console.log("🔍 Amount calculation debug:", {
3734
- rawAmount: amount,
3735
- amountType: typeof amount,
3736
- decimals,
3737
- totalAmount: paymentData.totalAmount,
3738
- approvalAmount: contractCall.approvalAmount
3739
- });
3740
3641
  try {
3741
3642
  let userBalance;
3742
3643
  let balanceCheckMethod = "unknown";
3743
3644
  try {
3744
- console.log("💰 Checking balance via wallet RPC...");
3745
3645
  userBalance = await readContract(wagmiConfig, {
3746
3646
  address: contractCall.tokenAddress,
3747
3647
  abi: ERC20_BALANCE_ABI,
@@ -3749,17 +3649,10 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3749
3649
  args: [address]
3750
3650
  });
3751
3651
  balanceCheckMethod = "wallet-rpc";
3752
- console.log("✅ Balance check via wallet RPC succeeded");
3753
3652
  } catch (walletRpcError) {
3754
- console.warn("⚠️ Balance check via wallet RPC failed:", {
3755
- error: walletRpcError.message,
3756
- isEmptyData: ((_a = walletRpcError.message) == null ? void 0 : _a.includes("returned no data")) || ((_b = walletRpcError.message) == null ? void 0 : _b.includes("0x")),
3757
- wallet: "Using wallet-controlled RPC"
3758
- });
3759
3653
  const chainId = (selectedNetwork == null ? void 0 : selectedNetwork.chainId) || (selectedNetwork == null ? void 0 : selectedNetwork.id);
3760
3654
  if (chainId) {
3761
3655
  const chainIdNumber = normalizeChainId(chainId);
3762
- console.log(`🔄 Attempting balance check via fallback RPC (chain ${chainId} → ${chainIdNumber})...`);
3763
3656
  const fallbackClient = getFallbackRpcClient(chainIdNumber);
3764
3657
  if (fallbackClient) {
3765
3658
  try {
@@ -3770,47 +3663,27 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3770
3663
  args: [address]
3771
3664
  });
3772
3665
  balanceCheckMethod = "fallback-rpc";
3773
- console.log("✅ Balance check via fallback RPC succeeded");
3774
3666
  } catch (fallbackRpcError) {
3775
- console.error("❌ Balance check via fallback RPC also failed:", fallbackRpcError.message);
3776
3667
  throw walletRpcError;
3777
3668
  }
3778
3669
  } else {
3779
- console.error("❌ No fallback RPC client available for chain", chainIdNumber);
3780
3670
  throw walletRpcError;
3781
3671
  }
3782
3672
  } else {
3783
- console.error("❌ No chainId available for fallback RPC");
3784
3673
  throw walletRpcError;
3785
3674
  }
3786
3675
  }
3787
3676
  const requiredAmount = BigInt(amount);
3788
- console.log("💰 User token balance check result:", {
3789
- balance: userBalance.toString(),
3790
- required: requiredAmount.toString(),
3791
- hasEnough: userBalance >= requiredAmount,
3792
- formatted: `${(Number(userBalance) / Math.pow(10, decimals)).toFixed(6)} ${selectedToken.symbol}`,
3793
- method: balanceCheckMethod,
3794
- wallet: balanceCheckMethod === "wallet-rpc" ? "Wallet RPC (Coinbase/MetaMask infrastructure)" : "App Fallback RPC (Multi-endpoint)"
3795
- });
3796
3677
  if (userBalance < requiredAmount) {
3797
3678
  const errorMsg = `Insufficient ${selectedToken.symbol} balance. You have ${(Number(userBalance) / Math.pow(10, decimals)).toFixed(6)} ${selectedToken.symbol} but need ${(Number(requiredAmount) / Math.pow(10, decimals)).toFixed(6)} ${selectedToken.symbol}`;
3798
3679
  throw new Error(errorMsg);
3799
3680
  }
3800
3681
  } catch (balanceError) {
3801
- console.error("Balance check failed:", balanceError);
3802
3682
  if (balanceError.message.includes("Insufficient")) {
3803
3683
  throw balanceError;
3804
3684
  }
3805
- console.warn("⚠️ Continuing despite balance check failure - transaction will be validated by wallet");
3806
3685
  }
3807
3686
  setTransactionStep("approve");
3808
- console.log(`PaymentSplitter Step 1 - Approve Transaction:`, {
3809
- token: selectedToken.symbol,
3810
- spender: contractCall.contractAddress,
3811
- amount,
3812
- to: contractCall.tokenAddress
3813
- });
3814
3687
  window.coinleyPendingSplitPayment = {
3815
3688
  contractCall,
3816
3689
  selectedToken,
@@ -3826,18 +3699,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3826
3699
  let requiredAmount;
3827
3700
  try {
3828
3701
  requiredAmount = BigInt(amount);
3829
- console.log("🔍 Converted amount to BigInt:", {
3830
- originalAmount: amount,
3831
- originalType: typeof amount,
3832
- bigIntAmount: requiredAmount.toString(),
3833
- isBigInt: typeof requiredAmount === "bigint"
3834
- });
3835
3702
  } catch (conversionError) {
3836
- console.error("❌ Failed to convert amount to BigInt:", {
3837
- amount,
3838
- amountType: typeof amount,
3839
- error: conversionError.message
3840
- });
3841
3703
  throw new Error(`Invalid amount value: ${amount}`);
3842
3704
  }
3843
3705
  let currentAllowance = 0n;
@@ -3851,38 +3713,25 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3851
3713
  functionName: "allowance",
3852
3714
  args: [address, contractCall.contractAddress]
3853
3715
  });
3854
- console.log("🔍 Current allowance check:", {
3855
- token: selectedToken.symbol,
3856
- currentAllowance: currentAllowance.toString(),
3857
- requiredAmount: requiredAmount.toString(),
3858
- hasSufficient: currentAllowance >= requiredAmount,
3859
- attempt: allowanceCheckAttempts + 1
3860
- });
3861
3716
  break;
3862
3717
  } catch (allowanceError) {
3863
3718
  allowanceCheckAttempts++;
3864
3719
  if (allowanceCheckAttempts < maxAllowanceCheckAttempts) {
3865
- console.warn(`⚠️ Allowance check attempt ${allowanceCheckAttempts} failed, retrying in 2s...`, allowanceError.message);
3866
3720
  await new Promise((resolve) => setTimeout(resolve, 2e3));
3867
3721
  } else {
3868
- console.warn("⚠️ Could not check allowance after 3 attempts, assuming 0 allowance:", allowanceError.message);
3869
3722
  currentAllowance = 0n;
3870
3723
  }
3871
3724
  }
3872
3725
  }
3873
3726
  if (currentAllowance >= requiredAmount) {
3874
- console.log("✅ Sufficient allowance already exists, skipping approval step");
3875
3727
  setTransactionStep("splitPayment");
3876
3728
  const splitPaymentHash2 = await executeSplitPayment();
3877
3729
  if (splitPaymentHash2) {
3878
- console.log("🔄 Notifying backend with transaction hash:", splitPaymentHash2);
3879
3730
  await processFinalPayment(splitPaymentHash2);
3880
3731
  }
3881
3732
  return splitPaymentHash2;
3882
3733
  }
3883
3734
  if (isUSDT && currentAllowance > 0n) {
3884
- console.log("⚠️ USDT: Changing allowance from", currentAllowance.toString(), "to", requiredAmount.toString());
3885
- console.log("⚠️ USDT requires reset to 0 before changing allowance...");
3886
3735
  const gasFees2 = await getGasFeesWithBuffer(wagmiConfig, selectedNetwork.chainId);
3887
3736
  const resetHash = await writeContract(wagmiConfig, {
3888
3737
  address: contractCall.tokenAddress,
@@ -3892,26 +3741,14 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3892
3741
  ...gasFees2
3893
3742
  // ✅ FIX #2: Add 20% gas price buffer
3894
3743
  });
3895
- console.log("🔄 USDT reset to 0 transaction sent:", resetHash);
3896
- console.log("⏳ Waiting for USDT reset confirmation (max 120s)...");
3897
3744
  await waitForTransactionReceipt(wagmiConfig, {
3898
3745
  hash: resetHash,
3899
3746
  confirmations: 1,
3900
3747
  timeout: 12e4
3901
3748
  // 120 seconds (same as approve transaction)
3902
3749
  });
3903
- console.log("✅ USDT allowance reset to 0 confirmed");
3904
3750
  }
3905
3751
  const gasFees = await getGasFeesWithBuffer(wagmiConfig, selectedNetwork.chainId);
3906
- console.log("📤 Sending approve transaction:", {
3907
- tokenAddress: contractCall.tokenAddress,
3908
- spenderAddress: contractCall.contractAddress,
3909
- amount: requiredAmount.toString(),
3910
- amountType: typeof requiredAmount,
3911
- network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
3912
- wallet: address,
3913
- gasBuffer: "20%"
3914
- });
3915
3752
  const approveHash = await writeContract(wagmiConfig, {
3916
3753
  address: contractCall.tokenAddress,
3917
3754
  abi: erc20Abi,
@@ -3920,20 +3757,13 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3920
3757
  ...gasFees
3921
3758
  // ✅ FIX #2: Add 20% gas price buffer to prevent "max fee < base fee" errors
3922
3759
  });
3923
- console.log("✅ ERC20 Approve transaction sent:", approveHash);
3924
3760
  setCurrentTransactionHash(approveHash);
3925
- console.log("⏳ Waiting for approval confirmation on-chain (max 120s)...");
3926
3761
  const receipt = await waitForTransactionReceipt(wagmiConfig, {
3927
3762
  hash: approveHash,
3928
3763
  confirmations: 1,
3929
3764
  timeout: 12e4
3930
3765
  // 120 seconds (2 minutes)
3931
3766
  });
3932
- console.log("✅ Approval confirmed on-chain!", {
3933
- blockNumber: receipt.blockNumber,
3934
- status: receipt.status
3935
- });
3936
- console.log("⏳ Waiting 3 seconds for RPC state propagation...");
3937
3767
  await new Promise((resolve) => setTimeout(resolve, 3e3));
3938
3768
  let verificationAttempts = 0;
3939
3769
  const maxVerificationAttempts = 3;
@@ -3946,22 +3776,14 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3946
3776
  functionName: "allowance",
3947
3777
  args: [address, contractCall.contractAddress]
3948
3778
  });
3949
- console.log(`🔍 Allowance verification attempt ${verificationAttempts + 1}:`, {
3950
- currentAllowance: updatedAllowance.toString(),
3951
- requiredAmount: requiredAmount.toString(),
3952
- verified: updatedAllowance >= requiredAmount
3953
- });
3954
3779
  if (updatedAllowance >= requiredAmount) {
3955
- console.log("✅ Allowance verified! Ready to proceed with splitPayment");
3956
3780
  allowanceVerified = true;
3957
3781
  break;
3958
3782
  }
3959
3783
  if (verificationAttempts < maxVerificationAttempts - 1) {
3960
- console.log("⚠️ Allowance not yet propagated, waiting 2 more seconds...");
3961
3784
  await new Promise((resolve) => setTimeout(resolve, 2e3));
3962
3785
  }
3963
3786
  } catch (verifyError) {
3964
- console.warn(`⚠️ Allowance verification attempt ${verificationAttempts + 1} failed:`, verifyError.message);
3965
3787
  if (verificationAttempts < maxVerificationAttempts - 1) {
3966
3788
  await new Promise((resolve) => setTimeout(resolve, 2e3));
3967
3789
  }
@@ -3969,23 +3791,18 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3969
3791
  verificationAttempts++;
3970
3792
  }
3971
3793
  if (!allowanceVerified) {
3972
- console.warn("⚠️ Could not verify allowance after 3 attempts, proceeding anyway");
3973
- console.warn("⚠️ Transaction will fail if allowance has not propagated");
3974
3794
  }
3975
3795
  const splitPaymentHash = await executeSplitPayment();
3976
3796
  if (splitPaymentHash) {
3977
- console.log("🔄 Notifying backend with transaction hash:", splitPaymentHash);
3978
3797
  await processFinalPayment(splitPaymentHash);
3979
3798
  }
3980
3799
  return splitPaymentHash;
3981
3800
  } catch (error) {
3982
- console.error("❌ ERC20 Approve failed:", error);
3983
- const errorLog = formatErrorForLogging(error, "approve_transaction");
3984
- console.error("🔍 Detailed error log:", errorLog);
3801
+ formatErrorForLogging(error, "approve_transaction");
3985
3802
  const friendlyError = parseUserFriendlyError(error);
3986
3803
  setTransactionError(friendlyError);
3987
3804
  setTransactionStep("idle");
3988
- if (((_c = error.message) == null ? void 0 : _c.includes("User rejected")) || ((_d = error.message) == null ? void 0 : _d.includes("User denied")) || error.code === 4001) {
3805
+ if (((_a = error.message) == null ? void 0 : _a.includes("User rejected")) || ((_b = error.message) == null ? void 0 : _b.includes("User denied")) || error.code === 4001) {
3989
3806
  throw new Error("Transaction was cancelled by user");
3990
3807
  }
3991
3808
  throw new Error(`Approve failed: ${error.message}`);
@@ -3997,41 +3814,20 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
3997
3814
  const executeSplitPayment = async () => {
3998
3815
  var _a, _b, _c, _d, _e, _f, _g;
3999
3816
  try {
4000
- console.log("🔄 Step 2: Executing PaymentSplitter.splitPayment()...");
4001
3817
  setTransactionStep("splitPayment");
4002
3818
  const pendingSplitPayment = window.coinleyPendingSplitPayment;
4003
3819
  if (!pendingSplitPayment) {
4004
3820
  throw new Error("Missing split payment data");
4005
3821
  }
4006
3822
  const { contractCall, selectedToken: selectedToken2, paymentData: paymentData2, selectedNetwork: selectedNetwork2 } = pendingSplitPayment;
4007
- console.log("🔍 [DEBUG] selectedNetwork object:", {
4008
- fullObject: selectedNetwork2,
4009
- chainId: selectedNetwork2 == null ? void 0 : selectedNetwork2.chainId,
4010
- shortName: selectedNetwork2 == null ? void 0 : selectedNetwork2.shortName,
4011
- name: selectedNetwork2 == null ? void 0 : selectedNetwork2.name
4012
- });
4013
3823
  const chainId = selectedNetwork2.chainId || 10;
4014
- console.log("🔍 [DEBUG] Resolved chainId:", chainId);
4015
- console.log("🔍 Fetching contract ABI for chain:", chainId);
4016
3824
  const contractInfo = await api.getContractInfo(chainId);
4017
3825
  const { abi } = contractInfo;
4018
- console.log("✅ Contract ABI fetched successfully");
4019
3826
  const splitPaymentParams = createSplitPaymentParams(contractCall.params);
4020
- console.log("🔍 Structured parameters for tuple:", splitPaymentParams);
4021
- console.log("🔍 Simulating transaction to check for errors...");
4022
3827
  const chainIdNormalized = normalizeChainId(chainId);
4023
3828
  const isEthereum = chainIdNormalized === 1;
4024
3829
  const isAvalanche = chainIdNormalized === 43114;
4025
3830
  const shouldBypassSimulationErrors = isEthereum || isAvalanche;
4026
- console.log("🔍 Chain detection:", {
4027
- chainId,
4028
- chainIdType: typeof chainId,
4029
- chainIdNormalized,
4030
- isEthereum,
4031
- isAvalanche,
4032
- networkName: selectedNetwork2 == null ? void 0 : selectedNetwork2.shortName,
4033
- willBypassSimulation: shouldBypassSimulationErrors ? "YES - Known RPC simulation issues (warnings only)" : "NO - Will throw on simulation error"
4034
- });
4035
3831
  try {
4036
3832
  const { request } = await simulateContract(wagmiConfig, {
4037
3833
  address: contractCall.contractAddress,
@@ -4039,53 +3835,23 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
4039
3835
  functionName: "splitPayment",
4040
3836
  args: [splitPaymentParams]
4041
3837
  });
4042
- console.log("✅ Transaction simulation successful");
4043
3838
  } catch (simulationError) {
4044
- console.error("❌ Transaction simulation failed:", simulationError);
4045
- console.error("🔍 Simulation Error Details:", {
4046
- message: simulationError.message,
4047
- cause: simulationError.cause,
4048
- data: simulationError.data,
4049
- reason: simulationError.reason,
4050
- code: simulationError.code,
4051
- details: simulationError.details,
4052
- shortMessage: simulationError.shortMessage,
4053
- metaMessages: simulationError.metaMessages,
4054
- name: simulationError.name
4055
- });
4056
3839
  const errorData = simulationError.data || ((_a = simulationError.cause) == null ? void 0 : _a.data);
4057
3840
  if (errorData) {
4058
- console.error("🔍 Raw Error Data (hex):", errorData);
4059
3841
  if (typeof errorData === "string" && errorData.startsWith("0x08c379a0")) {
4060
- console.error("🔍 Error type: Error(string) - contract has custom revert message");
4061
3842
  } else if (typeof errorData === "string" && errorData.startsWith("0x4e487b71")) {
4062
- console.error("🔍 Error type: Panic - likely assert() failure or array bounds");
4063
3843
  } else if (errorData) {
4064
- console.error("🔍 Error type: Custom error or unknown revert");
4065
3844
  }
4066
3845
  }
4067
3846
  const revertReason = simulationError.reason || ((_b = simulationError.cause) == null ? void 0 : _b.reason) || ((_c = simulationError.cause) == null ? void 0 : _c.shortMessage) || ((_d = simulationError.data) == null ? void 0 : _d.message) || "Unknown revert reason (contract may use require() without message)";
4068
- console.error("🔍 Contract Revert Reason:", revertReason);
4069
- console.error("🔍 Failed Contract Call:", {
4070
- contract: contractCall.contractAddress,
4071
- function: "splitPayment",
4072
- paymentId: splitPaymentParams.paymentId,
4073
- amount: splitPaymentParams.amount.toString(),
4074
- token: splitPaymentParams.token
4075
- });
4076
3847
  if (shouldBypassSimulationErrors) {
4077
3848
  const networkName = isEthereum ? "ETHEREUM" : "AVALANCHE";
4078
3849
  const reason = isEthereum ? "Stale RPC state, gas estimation quirks, contract has 100% Etherscan success rate" : "JSON-RPC errors during simulation (common with Avalanche RPCs), but transactions succeed on-chain";
4079
- console.warn(`⚠️ [${networkName}] Simulation failed but proceeding anyway`);
4080
- console.warn(`⚠️ [${networkName}] The wallet will catch any actual errors`);
4081
- console.warn(`⚠️ [${networkName}] Reason: ${reason}`);
4082
- console.warn("📤 Sending transaction to wallet for real validation...");
4083
3850
  } else {
4084
3851
  const { userFriendlyMessage } = categorizeSimulationError(simulationError);
4085
3852
  throw new Error(userFriendlyMessage);
4086
3853
  }
4087
3854
  }
4088
- console.log("📤 Sending PaymentSplitter.splitPayment transaction...");
4089
3855
  const gasFees = await getGasFeesWithBuffer(wagmiConfig, chainId);
4090
3856
  const isArbitrum = selectedNetwork2.shortName === "arbitrum";
4091
3857
  const maxRetries = isArbitrum ? 2 : 0;
@@ -4094,7 +3860,6 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
4094
3860
  try {
4095
3861
  if (attempt > 0) {
4096
3862
  const waitTime = 2e3 * attempt;
4097
- console.log(`⏳ Retrying splitPayment on Arbitrum (attempt ${attempt + 1}) after ${waitTime}ms...`);
4098
3863
  await new Promise((resolve) => setTimeout(resolve, waitTime));
4099
3864
  }
4100
3865
  splitPaymentHash = await writeContract(wagmiConfig, {
@@ -4107,22 +3872,18 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
4107
3872
  });
4108
3873
  break;
4109
3874
  } catch (writeError) {
4110
- console.log(`❌ WriteContract attempt ${attempt + 1} failed:`, writeError.message);
4111
3875
  const isKnownArbitrumError = ((_e = writeError.message) == null ? void 0 : _e.includes("Internal JSON-RPC error")) || ((_f = writeError.message) == null ? void 0 : _f.includes("-32603")) || ((_g = writeError.message) == null ? void 0 : _g.includes("nonce"));
4112
3876
  if (attempt === maxRetries || !isKnownArbitrumError && !isArbitrum) {
4113
3877
  throw writeError;
4114
3878
  }
4115
3879
  }
4116
3880
  }
4117
- console.log("✅ PaymentSplitter.splitPayment transaction sent:", splitPaymentHash);
4118
3881
  setCurrentTransactionHash(splitPaymentHash);
4119
3882
  setTransactionStep("processing");
4120
3883
  window.coinleyPendingSplitPayment = null;
4121
3884
  return splitPaymentHash;
4122
3885
  } catch (error) {
4123
- console.error("❌ Step 2 (SplitPayment) failed:", error);
4124
- const errorLog = formatErrorForLogging(error, "split_payment_transaction");
4125
- console.error("🔍 Detailed error log:", errorLog);
3886
+ formatErrorForLogging(error, "split_payment_transaction");
4126
3887
  const friendlyError = parseUserFriendlyError(error);
4127
3888
  setTransactionError(friendlyError);
4128
3889
  setTransactionStep("error");
@@ -4132,34 +3893,20 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
4132
3893
  const processFinalPayment = async (transactionHash) => {
4133
3894
  try {
4134
3895
  setTransactionStep("processing");
4135
- console.log("🔄 Processing final payment with hash:", transactionHash);
4136
- console.log("🔍 API instance check:", {
4137
- hasApi: !!api,
4138
- apiType: typeof api,
4139
- hasProcessPaymentMethod: !!(api == null ? void 0 : api.processPayment),
4140
- paymentId: paymentData == null ? void 0 : paymentData.id,
4141
- network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
4142
- address
4143
- });
4144
3896
  if (!api || !api.processPayment) {
4145
3897
  throw new Error("API instance not available or missing processPayment method");
4146
3898
  }
4147
- console.log("⏳ Waiting 8 seconds for blockchain indexers to sync transaction...");
4148
3899
  await new Promise((resolve) => setTimeout(resolve, 8e3));
4149
- console.log("📤 Calling API.processPayment...");
4150
3900
  const processResult = await api.processPayment(
4151
3901
  paymentData.id,
4152
3902
  transactionHash,
4153
3903
  selectedNetwork.shortName,
4154
3904
  address
4155
3905
  );
4156
- console.log("✅ Payment processing completed:", processResult);
4157
3906
  setTransactionStep("success");
4158
3907
  return processResult;
4159
3908
  } catch (error) {
4160
- console.error("❌ Final payment processing failed:", error);
4161
- const errorLog = formatErrorForLogging(error, "final_payment_processing");
4162
- console.error("🔍 Detailed error log:", errorLog);
3909
+ formatErrorForLogging(error, "final_payment_processing");
4163
3910
  const friendlyError = parseUserFriendlyError(error);
4164
3911
  setTransactionError(friendlyError);
4165
3912
  setTransactionStep("error");
@@ -4518,7 +4265,6 @@ const PaymentStatus = ({
4518
4265
  setCopiedHash(true);
4519
4266
  setTimeout(() => setCopiedHash(false), 2e3);
4520
4267
  } catch (err) {
4521
- console.error("Failed to copy transaction hash:", err);
4522
4268
  }
4523
4269
  }
4524
4270
  };
@@ -4637,14 +4383,6 @@ const PaymentStatus = ({
4637
4383
  (() => {
4638
4384
  const explorerUrl = getExplorerUrl(transactionHash, selectedNetwork);
4639
4385
  const explorerName = getExplorerName(selectedNetwork);
4640
- console.log("🔍 Explorer link debug:", {
4641
- hasSelectedNetwork: !!selectedNetwork,
4642
- selectedNetwork,
4643
- transactionHash,
4644
- explorerUrl,
4645
- explorerName,
4646
- willShow: !!(selectedNetwork && explorerUrl)
4647
- });
4648
4386
  return selectedNetwork && explorerUrl && /* @__PURE__ */ jsxs(
4649
4387
  "a",
4650
4388
  {
@@ -4877,98 +4615,71 @@ const getCustomMobileWallets = () => {
4877
4615
  ];
4878
4616
  };
4879
4617
  const getAvailableWallets = (connectors, selectedNetwork) => {
4880
- console.log("🔍 getAvailableWallets called with:", {
4881
- connectorCount: connectors == null ? void 0 : connectors.length,
4882
- connectorNames: connectors == null ? void 0 : connectors.map((c) => c.name),
4883
- selectedNetwork: selectedNetwork == null ? void 0 : selectedNetwork.shortName
4884
- });
4885
4618
  if (!selectedNetwork) {
4886
- console.warn("⚠️ No network selected");
4887
4619
  return [];
4888
4620
  }
4889
4621
  const evmNetworks = ["ethereum", "bsc", "polygon", "arbitrum", "optimism", "avalanche", "celo", "base"];
4890
4622
  if (!evmNetworks.includes(selectedNetwork.shortName)) {
4891
- console.warn("⚠️ Network not in EVM list:", selectedNetwork.shortName);
4892
4623
  return [];
4893
4624
  }
4894
4625
  const wagmiWallets = (connectors || []).map(
4895
4626
  (connector) => createWalletFromConnector(connector)
4896
4627
  );
4897
- console.log("✅ Wagmi wallets created:", wagmiWallets.map((w) => w.name));
4898
4628
  const isMobile = detectMobile();
4899
4629
  const customMobileWallets = isMobile ? getCustomMobileWallets() : [];
4900
4630
  const allWallets = [...wagmiWallets, ...customMobileWallets];
4901
- console.log("📋 Total available wallets:", allWallets.length);
4902
4631
  return allWallets;
4903
4632
  };
4904
4633
  const getCoinIdForChain = (chainId) => {
4905
4634
  const normalizedChainId = typeof chainId === "string" && chainId.startsWith("0x") ? parseInt(chainId, 16) : parseInt(chainId);
4906
4635
  const evmChains = [1, 56, 137, 42161, 10, 43114, 42220, 8453];
4907
4636
  if (evmChains.includes(normalizedChainId)) {
4908
- console.log(`🔍 EVM Chain ${chainId} (normalized: ${normalizedChainId}) -> coin_id: 60 (Trust Wallet DApp browser uses Ethereum mode for all EVM chains)`);
4909
4637
  return 60;
4910
4638
  }
4911
4639
  const chainToCoinId = {
4912
4640
  // Non-EVM chains would go here
4913
4641
  };
4914
4642
  const coinId = chainToCoinId[normalizedChainId] || 60;
4915
- console.log(`🔍 Chain ${chainId} (normalized: ${normalizedChainId}) -> coin_id: ${coinId}`);
4916
4643
  return coinId;
4917
4644
  };
4918
4645
  const generateQRPaymentURI = (paymentData, selectedToken, selectedNetwork, config, preferredWallet = "metamask", apiConfig = null) => {
4919
4646
  if (!paymentData) return null;
4920
4647
  try {
4921
4648
  const baseUrl = "https://paymentscreen.vercel.app";
4922
- console.log("🔍 SIMPLE Payment data for QR generation:", {
4923
- paymentData,
4924
- selectedToken,
4925
- selectedNetwork,
4926
- config,
4927
- preferredWallet
4928
- });
4929
4649
  const params = new URLSearchParams();
4930
4650
  const paymentId = (paymentData == null ? void 0 : paymentData.id) || (paymentData == null ? void 0 : paymentData.splitterPaymentId);
4931
4651
  if (!paymentId) {
4932
- console.error("❌ Cannot generate QR: No payment ID");
4933
4652
  return null;
4934
4653
  }
4935
4654
  params.set("paymentId", paymentId);
4936
4655
  params.set("preferredWallet", preferredWallet);
4937
4656
  params.set("isMobile", "true");
4938
4657
  const paymentScreenUrl = `${baseUrl}?${params.toString()}`;
4939
- console.log("🔗 SIMPLE Generated payment URL:", paymentScreenUrl);
4940
- console.log("🔍 SIMPLE URL Parameters:", Object.fromEntries(params.entries()));
4941
4658
  let deepLinkUrl;
4942
4659
  switch (preferredWallet) {
4943
4660
  case "metamask":
4944
4661
  const metaMaskUrl = paymentScreenUrl.replace("https://", "");
4945
4662
  deepLinkUrl = `https://metamask.app.link/dapp/${metaMaskUrl}`;
4946
- console.log("🦊 Generated MetaMask deep link for QR");
4947
4663
  break;
4948
4664
  case "trust":
4949
4665
  const chainIdForCoin = (selectedNetwork == null ? void 0 : selectedNetwork.chainId) || 1;
4950
4666
  const coinId = getCoinIdForChain(chainIdForCoin);
4951
4667
  deepLinkUrl = `https://link.trustwallet.com/open_url?coin_id=${coinId}&url=${encodeURIComponent(paymentScreenUrl)}`;
4952
- console.log("🛡️ Generated Trust Wallet deep link for QR with coin_id:", coinId);
4953
4668
  break;
4954
4669
  case "coinbase":
4955
4670
  deepLinkUrl = `https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(paymentScreenUrl)}`;
4956
- console.log("💙 Generated Coinbase Wallet deep link for QR");
4957
4671
  break;
4958
4672
  default:
4959
4673
  deepLinkUrl = paymentScreenUrl;
4960
- console.log("🔗 Using direct payment screen URL");
4961
4674
  }
4962
4675
  return deepLinkUrl;
4963
4676
  } catch (error) {
4964
- console.error("❌ Error generating QR payment URI:", error);
4965
4677
  return null;
4966
4678
  }
4967
4679
  };
4968
4680
  const generateMobilePaymentDeepLink = (walletType, paymentUri) => {
4969
4681
  if (!paymentUri) return null;
4970
4682
  try {
4971
- console.log(`🔗 Generating ${walletType} deep link for: ${paymentUri}`);
4972
4683
  switch (walletType) {
4973
4684
  case "metamask":
4974
4685
  const metaMaskUrl = paymentUri.includes("metamask.app.link") ? paymentUri : `https://metamask.app.link/dapp/${paymentUri.replace("https://", "")}`;
@@ -4983,7 +4694,6 @@ const generateMobilePaymentDeepLink = (walletType, paymentUri) => {
4983
4694
  return paymentUri;
4984
4695
  }
4985
4696
  } catch (error) {
4986
- console.error(`❌ Error generating ${walletType} deep link:`, error);
4987
4697
  return paymentUri;
4988
4698
  }
4989
4699
  };
@@ -5016,18 +4726,15 @@ const QRCodeDisplay = ({
5016
4726
  useEffect(() => {
5017
4727
  const generateQRCode = async () => {
5018
4728
  if (!(paymentData == null ? void 0 : paymentData.id)) {
5019
- console.warn("⚠️ No payment data provided for QR code");
5020
4729
  setIsGenerating(false);
5021
4730
  return;
5022
4731
  }
5023
4732
  setIsGenerating(true);
5024
4733
  try {
5025
4734
  if (!selectedToken || !selectedToken.contractAddress) {
5026
- console.error("❌ QR Code Error: selectedToken missing or incomplete:", selectedToken);
5027
4735
  throw new Error("Cannot generate QR code: Token contract address required");
5028
4736
  }
5029
4737
  if (!selectedNetwork || !selectedNetwork.chainId) {
5030
- console.error("❌ QR Code Error: selectedNetwork missing or incomplete:", selectedNetwork);
5031
4738
  throw new Error("Cannot generate QR code: Network chain ID required");
5032
4739
  }
5033
4740
  const paymentUri = generateQRPaymentURI(
@@ -5041,24 +4748,10 @@ const QRCodeDisplay = ({
5041
4748
  preferredWallet
5042
4749
  // Pass the preferred wallet for deep link generation
5043
4750
  );
5044
- console.log("🔍 QR Code Regenerating with:");
5045
- console.log(" - Payment ID:", paymentData.id);
5046
- console.log(" - Network:", network, "Currency:", currency, "Amount:", amount);
5047
- console.log(" - Preferred Wallet:", preferredWallet);
5048
- console.log("🔍 COMPLETE QR PAYMENT DATA CHECK:");
5049
- console.log(" - paymentData object:", JSON.stringify(paymentData, null, 2));
5050
- console.log(" - selectedToken object:", JSON.stringify(selectedToken, null, 2));
5051
- console.log(" - selectedNetwork object:", JSON.stringify(selectedNetwork, null, 2));
5052
- console.log(" - config object:", JSON.stringify(config, null, 2));
5053
- console.log("🔗 Generated Coinley deep link URL:", paymentUri);
5054
4751
  if (paymentUri.includes("metamask.app.link")) {
5055
- console.log("✅ QR contains MetaMask deep link");
5056
4752
  } else if (paymentUri.includes("link.trustwallet.com")) {
5057
- console.log("✅ QR contains Trust Wallet deep link");
5058
4753
  } else if (paymentUri.includes("go.cb-w.com")) {
5059
- console.log("✅ QR contains Coinbase Wallet deep link");
5060
4754
  } else {
5061
- console.log("⚠️ QR contains generic deep link (no wallet-specific wrapper)");
5062
4755
  }
5063
4756
  if (!paymentUri) {
5064
4757
  throw new Error("Failed to generate Coinley payment URL");
@@ -5079,9 +4772,7 @@ const QRCodeDisplay = ({
5079
4772
  });
5080
4773
  setQrCodeImage(qrImage);
5081
4774
  setIsGenerating(false);
5082
- console.log("✅ QR Code regenerated with", preferredWallet, "deep link");
5083
4775
  } catch (error) {
5084
- console.error("❌ Failed to generate QR code:", error);
5085
4776
  setIsGenerating(false);
5086
4777
  }
5087
4778
  };
@@ -5146,7 +4837,6 @@ const WalletSelector = ({
5146
4837
  const { connectors } = useConnect();
5147
4838
  const { isConnected, address } = useAccount();
5148
4839
  const availableWallets = getAvailableWallets(connectors, selectedNetwork);
5149
- console.log("🔍 WAGMI: Available connectors:", availableWallets.map((w) => w.name));
5150
4840
  const handleWalletSelection = async (walletType) => {
5151
4841
  setSelectedWalletType(walletType);
5152
4842
  const wallet = availableWallets.find((w) => w.type === walletType);
@@ -5170,7 +4860,6 @@ const WalletSelector = ({
5170
4860
  return;
5171
4861
  }
5172
4862
  try {
5173
- console.log(`🚀 Opening mobile wallet: ${wallet.name}`);
5174
4863
  const { generateQRPaymentURI: generateQRPaymentURI2, generateMobilePaymentDeepLink: generateMobilePaymentDeepLink2 } = await Promise.resolve().then(() => deepLinkUtils);
5175
4864
  const paymentUri = generateQRPaymentURI2(
5176
4865
  paymentData,
@@ -5186,10 +4875,8 @@ const WalletSelector = ({
5186
4875
  if (!mobileDeepLink) {
5187
4876
  throw new Error(`Failed to generate ${wallet.name} deep link`);
5188
4877
  }
5189
- console.log(`🔗 Opening ${wallet.name} with:`, mobileDeepLink);
5190
4878
  window.location.href = mobileDeepLink;
5191
4879
  } catch (error) {
5192
- console.error(`❌ Mobile wallet connection failed:`, error);
5193
4880
  alert(`Failed to open ${wallet.name}: ${error.message}`);
5194
4881
  }
5195
4882
  };
@@ -5286,9 +4973,6 @@ const isDebugEnabled = () => {
5286
4973
  };
5287
4974
  const DEBUG_MODE = isDevelopment() || isDebugEnabled();
5288
4975
  const debugLog = (...args) => {
5289
- if (DEBUG_MODE) {
5290
- console.log(...args);
5291
- }
5292
4976
  };
5293
4977
  const MobileWalletDropdown = ({
5294
4978
  paymentData,
@@ -5735,7 +5419,6 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
5735
5419
  useEffect(() => {
5736
5420
  if (transactionStep === "processing" || transactionStep === "approve" || transactionStep === "splitPayment") {
5737
5421
  const timeout = setTimeout(() => {
5738
- console.warn("⚠️ Transaction timeout - resetting state");
5739
5422
  setError("Transaction timed out. Please try again.");
5740
5423
  setCurrentStep(PAYMENT_STEPS.CONFIRM);
5741
5424
  transactionHandling.resetTransaction();
@@ -5748,10 +5431,7 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
5748
5431
  onClose();
5749
5432
  };
5750
5433
  const handleConnect = async (connector) => {
5751
- const success = await connectWallet(connector, selectedNetwork);
5752
- if (success && onSuccess) {
5753
- console.log("✅ Wallet connected successfully");
5754
- }
5434
+ await connectWallet(connector, selectedNetwork);
5755
5435
  };
5756
5436
  const renderNetworkOption = (network) => {
5757
5437
  var _a, _b;
@@ -5948,17 +5628,13 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
5948
5628
  selectedNetwork,
5949
5629
  config,
5950
5630
  onPaymentStarted: (details) => {
5951
- console.log("🚀 Mobile payment started:", details);
5952
5631
  setMobilePaymentStarted(true);
5953
5632
  if (typeof window !== "undefined" && window.sessionStorage) {
5954
5633
  sessionStorage.setItem("coinley_mobile_payment_started", "true");
5955
5634
  }
5956
- if (details.walletName) {
5957
- console.log(`Opening ${details.walletName} with payment...`);
5958
- }
5635
+ if (details.walletName) ;
5959
5636
  },
5960
5637
  onError: (error2) => {
5961
- console.error("❌ Mobile payment error:", error2);
5962
5638
  setError(error2);
5963
5639
  }
5964
5640
  }
@@ -6057,10 +5733,8 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6057
5733
  setVerifyingPayment(true);
6058
5734
  setCurrentStep(PAYMENT_STEPS.PROCESSING);
6059
5735
  setError("");
6060
- console.log("🔍 Verifying mobile payment:", paymentData.id);
6061
5736
  const statusResult = await paymentFlow.api.checkPaymentStatus(paymentData.id);
6062
5737
  if (((_a = statusResult.payment) == null ? void 0 : _a.status) === "completed") {
6063
- console.log("✅ Payment already completed:", statusResult.payment);
6064
5738
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
6065
5739
  if (onSuccess) {
6066
5740
  onSuccess({
@@ -6070,10 +5744,8 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6070
5744
  });
6071
5745
  }
6072
5746
  } else if (((_b = statusResult.payment) == null ? void 0 : _b.status) === "pending") {
6073
- console.log("⏳ Payment pending, verifying on blockchain...");
6074
5747
  const verificationResult = await paymentFlow.api.verifyQRPayment(paymentData.id);
6075
5748
  if (verificationResult.success && verificationResult.verified) {
6076
- console.log("✅ Payment verified on blockchain:", verificationResult.onChainData);
6077
5749
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
6078
5750
  if (onSuccess) {
6079
5751
  onSuccess({
@@ -6095,7 +5767,6 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6095
5767
  setCurrentStep(PAYMENT_STEPS.CONFIRM);
6096
5768
  }
6097
5769
  } catch (error2) {
6098
- console.error("❌ Mobile payment verification failed:", error2);
6099
5770
  setError(`Verification failed: ${error2.message}. Please ensure payment was completed and try again.`);
6100
5771
  setCurrentStep(PAYMENT_STEPS.CONFIRM);
6101
5772
  } finally {
@@ -6111,10 +5782,8 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6111
5782
  try {
6112
5783
  setCurrentStep(PAYMENT_STEPS.PROCESSING);
6113
5784
  setError("");
6114
- console.log("🔍 Checking payment status:", paymentData.id);
6115
5785
  const statusResult = await paymentFlow.api.checkPaymentStatus(paymentData.id);
6116
5786
  if (((_e = statusResult.payment) == null ? void 0 : _e.status) === "completed") {
6117
- console.log("✅ Payment already completed:", statusResult.payment);
6118
5787
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
6119
5788
  if (onSuccess) {
6120
5789
  onSuccess({
@@ -6124,10 +5793,8 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6124
5793
  });
6125
5794
  }
6126
5795
  } else if (((_f = statusResult.payment) == null ? void 0 : _f.status) === "pending") {
6127
- console.log("⏳ Payment pending, verifying on blockchain...");
6128
5796
  const verificationResult = await paymentFlow.api.verifyQRPayment(paymentData.id);
6129
5797
  if (verificationResult.success && verificationResult.verified) {
6130
- console.log("✅ Payment verified on blockchain:", verificationResult.onChainData);
6131
5798
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
6132
5799
  if (onSuccess) {
6133
5800
  onSuccess({
@@ -6149,7 +5816,6 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6149
5816
  setCurrentStep(PAYMENT_STEPS.CONFIRM);
6150
5817
  }
6151
5818
  } catch (error2) {
6152
- console.error("❌ QR payment verification failed:", error2);
6153
5819
  setError(`Verification failed: ${error2.message}. Please ensure payment was completed and try again.`);
6154
5820
  setCurrentStep(PAYMENT_STEPS.CONFIRM);
6155
5821
  }
@@ -6163,12 +5829,6 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6163
5829
  setError("");
6164
5830
  transactionHandling.setTransactionError("");
6165
5831
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
6166
- console.log("✅ Payment SUCCESS - calling onSuccess callback", {
6167
- paymentId: paymentData.id,
6168
- transactionHash: txHash,
6169
- isRetry: !!error
6170
- // Log if this was a retry after error
6171
- });
6172
5832
  if (onSuccess) {
6173
5833
  onSuccess({
6174
5834
  paymentId: paymentData.id,
@@ -6178,7 +5838,6 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6178
5838
  }
6179
5839
  }
6180
5840
  } catch (error2) {
6181
- console.error("Transaction failed:", error2);
6182
5841
  setCurrentStep(PAYMENT_STEPS.CONFIRM);
6183
5842
  if (((_i = error2.message) == null ? void 0 : _i.includes("User rejected")) || ((_j = error2.message) == null ? void 0 : _j.includes("User denied")) || error2.code === 4001 || error2.code === "ACTION_REJECTED") {
6184
5843
  setError("Transaction was cancelled by user. Please try again.");
@@ -6186,7 +5845,6 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
6186
5845
  setError(error2.message || "Transaction failed. Please try again.");
6187
5846
  }
6188
5847
  transactionHandling.resetTransaction();
6189
- console.log("⚠️ Transaction failed, user can retry");
6190
5848
  }
6191
5849
  }
6192
5850
  },
@@ -6330,7 +5988,6 @@ const CoinleyCheckout = forwardRef(({
6330
5988
  const open = (config) => {
6331
5989
  try {
6332
5990
  if (debug) {
6333
- console.log("Opening Coinley checkout with config:", config);
6334
5991
  }
6335
5992
  if (!config.amount || config.amount <= 0) {
6336
5993
  throw new Error("Amount must be greater than 0");
@@ -6355,7 +6012,6 @@ const CoinleyCheckout = forwardRef(({
6355
6012
  };
6356
6013
  openPayment(finalConfig, checkoutCallbacks);
6357
6014
  } catch (error) {
6358
- console.error("Failed to open Coinley checkout:", error);
6359
6015
  if (onError) {
6360
6016
  onError(error);
6361
6017
  }
@@ -6409,7 +6065,6 @@ class PaymentAPI {
6409
6065
  });
6410
6066
  this.api.interceptors.request.use(
6411
6067
  (config) => {
6412
- var _a;
6413
6068
  if (this.publicKey) {
6414
6069
  config.headers["x-public-key"] = this.publicKey;
6415
6070
  } else {
@@ -6420,39 +6075,23 @@ class PaymentAPI {
6420
6075
  config.headers["Authorization"] = `Bearer ${token}`;
6421
6076
  }
6422
6077
  }
6423
- console.log("API Request:", {
6424
- method: (_a = config.method) == null ? void 0 : _a.toUpperCase(),
6425
- url: config.url,
6426
- data: config.data
6427
- });
6428
6078
  return config;
6429
6079
  },
6430
6080
  (error) => {
6431
- console.error("Request interceptor error:", error);
6432
6081
  return Promise.reject(error);
6433
6082
  }
6434
6083
  );
6435
6084
  this.api.interceptors.response.use(
6436
6085
  (response) => {
6437
- console.log("API Response:", {
6438
- status: response.status,
6439
- url: response.config.url,
6440
- data: response.data
6441
- });
6442
6086
  return response;
6443
6087
  },
6444
6088
  (error) => {
6445
- var _a, _b, _c, _d, _e;
6446
- console.error("API Error:", {
6447
- status: (_a = error.response) == null ? void 0 : _a.status,
6448
- data: (_b = error.response) == null ? void 0 : _b.data,
6449
- message: error.message
6450
- });
6451
- if (((_c = error.response) == null ? void 0 : _c.status) === 401) {
6089
+ var _a, _b, _c;
6090
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
6452
6091
  throw new Error("Authentication failed. Please check your API credentials.");
6453
- } else if (((_d = error.response) == null ? void 0 : _d.status) === 404) {
6092
+ } else if (((_b = error.response) == null ? void 0 : _b.status) === 404) {
6454
6093
  throw new Error("API endpoint not found. Please check your API URL.");
6455
- } else if (((_e = error.response) == null ? void 0 : _e.status) >= 500) {
6094
+ } else if (((_c = error.response) == null ? void 0 : _c.status) >= 500) {
6456
6095
  throw new Error("Server error. Please try again later.");
6457
6096
  }
6458
6097
  throw error;
@@ -6464,7 +6103,6 @@ class PaymentAPI {
6464
6103
  const credentials = `${this.apiKey}:${this.apiSecret}`;
6465
6104
  return btoa(credentials);
6466
6105
  } catch (error) {
6467
- console.error("Failed to generate token:", error);
6468
6106
  return null;
6469
6107
  }
6470
6108
  }
@@ -6515,7 +6153,6 @@ class PaymentAPI {
6515
6153
  const response = await this.api.get("/api/networks");
6516
6154
  return response.data;
6517
6155
  } catch (error) {
6518
- console.error("Get networks failed:", error);
6519
6156
  return {
6520
6157
  networks: [
6521
6158
  {
@@ -6557,7 +6194,6 @@ class PaymentAPI {
6557
6194
  const response = await this.api.get("/api/networks/stablecoins");
6558
6195
  return response.data;
6559
6196
  } catch (error) {
6560
- console.error("Get stablecoins failed:", error);
6561
6197
  return {
6562
6198
  stablecoins: [
6563
6199
  {
@@ -6612,22 +6248,14 @@ class PaymentAPI {
6612
6248
  async processPayment(paymentId, transactionHash, network, senderAddress) {
6613
6249
  var _a;
6614
6250
  try {
6615
- console.log("🔄 PaymentAPI: Processing PaymentSplitter transaction:", {
6616
- paymentId,
6617
- transactionHash,
6618
- network,
6619
- senderAddress
6620
- });
6621
6251
  const response = await this.api.post("/api/payments/process", {
6622
6252
  paymentId,
6623
6253
  transactionHash,
6624
6254
  network,
6625
6255
  senderAddress
6626
6256
  });
6627
- console.log("✅ PaymentAPI: PaymentSplitter transaction processed:", response.data);
6628
6257
  return response.data;
6629
6258
  } catch (error) {
6630
- console.error("❌ PaymentAPI: PaymentSplitter transaction failed:", error);
6631
6259
  if ((_a = error.response) == null ? void 0 : _a.data) {
6632
6260
  const errorData = error.response.data;
6633
6261
  const errorMessage = errorData.error || errorData.message || "Payment processing failed";
@@ -6645,12 +6273,9 @@ class PaymentAPI {
6645
6273
  async getContractInfo(chainId) {
6646
6274
  var _a, _b;
6647
6275
  try {
6648
- console.log("🔍 PaymentAPI: Getting contract info for chain:", chainId);
6649
6276
  const response = await this.api.get(`/api/payments/contract/${chainId}`);
6650
- console.log("✅ PaymentAPI: Contract info retrieved:", response.data.contractInfo);
6651
6277
  return response.data.contractInfo;
6652
6278
  } catch (error) {
6653
- console.error("❌ PaymentAPI: Failed to get contract info:", error);
6654
6279
  if ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error) {
6655
6280
  throw new Error(error.response.data.error);
6656
6281
  }
@@ -6661,12 +6286,9 @@ class PaymentAPI {
6661
6286
  async getPaymentSplitterStatus(paymentId) {
6662
6287
  var _a, _b;
6663
6288
  try {
6664
- console.log("🔍 PaymentAPI: Getting PaymentSplitter status for:", paymentId);
6665
6289
  const response = await this.api.get(`/api/payments/splitter-status/${paymentId}`);
6666
- console.log("✅ PaymentAPI: PaymentSplitter status:", response.data.paymentSplitterStatus);
6667
6290
  return response.data.paymentSplitterStatus;
6668
6291
  } catch (error) {
6669
- console.error("❌ PaymentAPI: Failed to get PaymentSplitter status:", error);
6670
6292
  if ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error) {
6671
6293
  throw new Error(error.response.data.error);
6672
6294
  }
@@ -6679,7 +6301,6 @@ class PaymentAPI {
6679
6301
  const response = await this.api.get("/api/payments/health");
6680
6302
  return response.data.paymentSplitterHealth;
6681
6303
  } catch (error) {
6682
- console.error("PaymentSplitter health check failed:", error);
6683
6304
  return { error: error.message };
6684
6305
  }
6685
6306
  }
@@ -6688,7 +6309,6 @@ class PaymentAPI {
6688
6309
  const response = await this.api.get("/api/health");
6689
6310
  return response.status === 200;
6690
6311
  } catch (error) {
6691
- console.error("Health check failed:", error);
6692
6312
  return false;
6693
6313
  }
6694
6314
  }
@@ -6746,13 +6366,11 @@ class BalanceChecker {
6746
6366
  // Check native token balance (ETH, BNB, MATIC, etc.)
6747
6367
  async checkNativeBalance(walletAddress, networkShortName) {
6748
6368
  try {
6749
- console.log(`🔍 Checking native balance for ${walletAddress} on ${networkShortName}`);
6750
6369
  const client = this.getClient(networkShortName);
6751
6370
  const balanceWei = await client.getBalance({
6752
6371
  address: walletAddress
6753
6372
  });
6754
6373
  const balanceEther = formatUnits$1(balanceWei, 18);
6755
- console.log(`💰 Native balance: ${balanceEther} ${this.getNativeTokenSymbol(networkShortName)}`);
6756
6374
  return {
6757
6375
  balance: parseFloat(balanceEther),
6758
6376
  balanceWei: balanceWei.toString(),
@@ -6760,15 +6378,12 @@ class BalanceChecker {
6760
6378
  decimals: 18
6761
6379
  };
6762
6380
  } catch (error) {
6763
- console.error(`❌ Failed to check native balance:`, error);
6764
6381
  throw new Error(`Failed to check native balance: ${error.message}`);
6765
6382
  }
6766
6383
  }
6767
6384
  // Check ERC-20 token balance
6768
6385
  async checkTokenBalance(walletAddress, tokenAddress, networkShortName) {
6769
6386
  try {
6770
- console.log(`🔍 Checking token balance for ${walletAddress} on ${networkShortName}`);
6771
- console.log(`🪙 Token contract: ${tokenAddress}`);
6772
6387
  const client = this.getClient(networkShortName);
6773
6388
  const contract = getContract({
6774
6389
  address: tokenAddress,
@@ -6782,7 +6397,6 @@ class BalanceChecker {
6782
6397
  contract.read.symbol().catch(() => "TOKEN")
6783
6398
  ]);
6784
6399
  const balance = parseFloat(formatUnits$1(balanceWei, decimals));
6785
- console.log(`💰 Token balance: ${balance} ${symbol}`);
6786
6400
  return {
6787
6401
  balance,
6788
6402
  balanceWei: balanceWei.toString(),
@@ -6791,17 +6405,12 @@ class BalanceChecker {
6791
6405
  tokenAddress
6792
6406
  };
6793
6407
  } catch (error) {
6794
- console.error(`❌ Failed to check token balance:`, error);
6795
6408
  throw new Error(`Failed to check token balance: ${error.message}`);
6796
6409
  }
6797
6410
  }
6798
6411
  // Check if user has sufficient balance for transaction
6799
6412
  async validateBalance(walletAddress, token, requiredAmount, networkShortName, includeGasFee = true) {
6800
6413
  try {
6801
- console.log(`🔍 Validating balance for payment:`);
6802
- console.log(` Required: ${requiredAmount} ${token.symbol}`);
6803
- console.log(` Network: ${networkShortName}`);
6804
- console.log(` Include gas fee check: ${includeGasFee}`);
6805
6414
  let tokenBalance;
6806
6415
  let nativeBalance = null;
6807
6416
  if (token.contractAddress) {
@@ -6857,10 +6466,8 @@ class BalanceChecker {
6857
6466
  );
6858
6467
  }
6859
6468
  }
6860
- console.log(`✅ Balance validation complete:`, validationResult);
6861
6469
  return validationResult;
6862
6470
  } catch (error) {
6863
- console.error(`❌ Balance validation failed:`, error);
6864
6471
  return {
6865
6472
  isValid: false,
6866
6473
  errors: [`Failed to check balance: ${error.message}`],
@@ -6932,7 +6539,6 @@ class BalanceChecker {
6932
6539
  const results = await Promise.all(balancePromises);
6933
6540
  return results;
6934
6541
  } catch (error) {
6935
- console.error("❌ Failed to check multiple balances:", error);
6936
6542
  throw error;
6937
6543
  }
6938
6544
  }
@@ -6966,7 +6572,6 @@ class SimplePaymentAPI2 {
6966
6572
  try {
6967
6573
  return await this.request("/api/networks");
6968
6574
  } catch (error) {
6969
- console.error("Failed to fetch networks:", error);
6970
6575
  return {
6971
6576
  networks: [
6972
6577
  { id: "1", name: "Ethereum", shortName: "ethereum", chainId: "0x1", type: "ethereum" },
@@ -6985,7 +6590,6 @@ class SimplePaymentAPI2 {
6985
6590
  try {
6986
6591
  return await this.request("/api/networks/stablecoins");
6987
6592
  } catch (error) {
6988
- console.error("Failed to fetch tokens:", error);
6989
6593
  return {
6990
6594
  stablecoins: [
6991
6595
  {
@@ -7225,7 +6829,6 @@ const QRCodePayment = ({
7225
6829
  setNetworks(networksRes.networks || []);
7226
6830
  setTokens(tokensRes.stablecoins || []);
7227
6831
  } catch (err) {
7228
- console.error("Failed to load data:", err);
7229
6832
  setError("Failed to load payment options.");
7230
6833
  } finally {
7231
6834
  setLoading(false);
@@ -7280,10 +6883,7 @@ const QRCodePayment = ({
7280
6883
  });
7281
6884
  setQrCodeImage(qrImage);
7282
6885
  setCurrentStep("scan");
7283
- console.log("🔗 Split Payment QR Code generated with backend record:", splitPaymentUri);
7284
- console.log("📋 Payment ID:", payment.payment.id);
7285
6886
  } catch (error2) {
7286
- console.error("❌ Failed to generate split payment QR code:", error2);
7287
6887
  setError(error2.message || "Failed to generate split payment QR code");
7288
6888
  } finally {
7289
6889
  setLoading(false);
@@ -7299,7 +6899,6 @@ const QRCodePayment = ({
7299
6899
  await checkWalletBalance(mockWalletAddress);
7300
6900
  setCurrentStep("confirm");
7301
6901
  } catch (error2) {
7302
- console.error("❌ Wallet simulation failed:", error2);
7303
6902
  setError("Failed to simulate wallet connection");
7304
6903
  } finally {
7305
6904
  setLoading(false);
@@ -7310,7 +6909,6 @@ const QRCodePayment = ({
7310
6909
  return false;
7311
6910
  }
7312
6911
  try {
7313
- console.log("🔍 Checking QR wallet balance...");
7314
6912
  const validation = await balanceChecker.validateBalance(
7315
6913
  address,
7316
6914
  selectedToken,
@@ -7323,10 +6921,8 @@ const QRCodePayment = ({
7323
6921
  setError(`Insufficient balance: ${validation.errors.join(", ")}`);
7324
6922
  return false;
7325
6923
  }
7326
- console.log("✅ QR balance validation passed");
7327
6924
  return true;
7328
6925
  } catch (error2) {
7329
- console.error("❌ QR balance check failed:", error2);
7330
6926
  setError(`Failed to check balance: ${error2.message}`);
7331
6927
  return false;
7332
6928
  }
@@ -7337,7 +6933,6 @@ const QRCodePayment = ({
7337
6933
  setError("");
7338
6934
  const mockTxHash = `0x${Math.random().toString(16).substring(2, 66)}`;
7339
6935
  await new Promise((resolve) => setTimeout(resolve, 3e3));
7340
- console.log("✅ QR payment transaction confirmed:", mockTxHash);
7341
6936
  setCurrentStep("success");
7342
6937
  onSuccess == null ? void 0 : onSuccess(paymentData.id, mockTxHash, {
7343
6938
  network: selectedNetwork.name,
@@ -7347,7 +6942,6 @@ const QRCodePayment = ({
7347
6942
  walletAddress
7348
6943
  });
7349
6944
  } catch (error2) {
7350
- console.error("❌ QR transaction failed:", error2);
7351
6945
  setError("Transaction confirmation failed");
7352
6946
  } finally {
7353
6947
  setCheckingPayment(false);
@@ -7574,25 +7168,27 @@ class CoinleyVanilla {
7574
7168
  /**
7575
7169
  * Initialize Coinley payment SDK
7576
7170
  * @param {Object} config - SDK configuration
7577
- * @param {string} config.apiKey - Merchant API key (required)
7578
- * @param {string} config.apiSecret - Merchant API secret (required)
7171
+ * @param {string} [config.publicKey] - Merchant public key (recommended - starts with 'pk_')
7172
+ * @param {string} [config.apiKey] - Merchant API key (legacy, used with apiSecret)
7173
+ * @param {string} [config.apiSecret] - Merchant API secret (legacy, used with apiKey)
7579
7174
  * @param {string} config.apiUrl - API base URL (required)
7580
7175
  * @param {string} [config.theme='light'] - UI theme ('light' or 'dark')
7581
7176
  * @param {boolean} [config.debug=false] - Enable debug logging
7582
7177
  */
7583
7178
  constructor(config = {}) {
7584
- if (!config.apiKey) {
7585
- throw new Error("CoinleyVanilla: apiKey is required");
7179
+ if (!config.publicKey && !config.apiKey) {
7180
+ throw new Error("CoinleyVanilla: publicKey or apiKey is required");
7586
7181
  }
7587
- if (!config.apiSecret) {
7588
- throw new Error("CoinleyVanilla: apiSecret is required");
7182
+ if (!config.publicKey && !config.apiSecret) {
7183
+ throw new Error("CoinleyVanilla: apiSecret is required when using apiKey");
7589
7184
  }
7590
7185
  if (!config.apiUrl) {
7591
7186
  throw new Error("CoinleyVanilla: apiUrl is required");
7592
7187
  }
7593
7188
  this.config = {
7594
- apiKey: config.apiKey,
7595
- apiSecret: config.apiSecret,
7189
+ publicKey: config.publicKey || null,
7190
+ apiKey: config.apiKey || null,
7191
+ apiSecret: config.apiSecret || null,
7596
7192
  apiUrl: config.apiUrl.replace(/\/$/, ""),
7597
7193
  // Remove trailing slash
7598
7194
  theme: config.theme || "light",
@@ -7604,13 +7200,7 @@ class CoinleyVanilla {
7604
7200
  this.container = null;
7605
7201
  this.callbacks = {};
7606
7202
  this.currentPayment = null;
7607
- if (this.config.debug) {
7608
- console.log("✅ CoinleyVanilla SDK initialized", {
7609
- apiUrl: this.config.apiUrl,
7610
- theme: this.config.theme,
7611
- version: "2.0.0"
7612
- });
7613
- }
7203
+ if (this.config.debug) ;
7614
7204
  }
7615
7205
  /**
7616
7206
  * Open payment modal
@@ -7630,7 +7220,6 @@ class CoinleyVanilla {
7630
7220
  */
7631
7221
  open(paymentConfig, callbacks = {}) {
7632
7222
  if (this.isOpen) {
7633
- console.warn("⚠️ CoinleyVanilla: Payment modal is already open");
7634
7223
  return;
7635
7224
  }
7636
7225
  try {
@@ -7642,6 +7231,7 @@ class CoinleyVanilla {
7642
7231
  this.isOpen = true;
7643
7232
  this.root.render(
7644
7233
  React.createElement(EnhancedSimpleCoinleyPayment, {
7234
+ publicKey: this.config.publicKey,
7645
7235
  apiKey: this.config.apiKey,
7646
7236
  apiSecret: this.config.apiSecret,
7647
7237
  apiUrl: this.config.apiUrl,
@@ -7668,14 +7258,8 @@ class CoinleyVanilla {
7668
7258
  })
7669
7259
  );
7670
7260
  if (this.config.debug) {
7671
- console.log("🚀 CoinleyVanilla: Payment modal opened", {
7672
- amount: paymentConfig.amount,
7673
- customerEmail: paymentConfig.customerEmail,
7674
- networks: Object.keys(paymentConfig.merchantWalletAddresses || {})
7675
- });
7676
7261
  }
7677
7262
  } catch (error) {
7678
- console.error("❌ CoinleyVanilla: Failed to open payment modal", error);
7679
7263
  if (callbacks.onError) {
7680
7264
  callbacks.onError(error.message || "Failed to open payment modal");
7681
7265
  }
@@ -7689,9 +7273,7 @@ class CoinleyVanilla {
7689
7273
  return;
7690
7274
  }
7691
7275
  this._cleanup();
7692
- if (this.config.debug) {
7693
- console.log("🔒 CoinleyVanilla: Payment modal closed");
7694
- }
7276
+ if (this.config.debug) ;
7695
7277
  }
7696
7278
  /**
7697
7279
  * Check if payment modal is currently open
@@ -7706,9 +7288,7 @@ class CoinleyVanilla {
7706
7288
  */
7707
7289
  updateConfig(newConfig) {
7708
7290
  this.config = { ...this.config, ...newConfig };
7709
- if (this.config.debug) {
7710
- console.log("🔧 CoinleyVanilla: Configuration updated", this.config);
7711
- }
7291
+ if (this.config.debug) ;
7712
7292
  }
7713
7293
  /**
7714
7294
  * Get current configuration (read-only)
@@ -7747,10 +7327,7 @@ class CoinleyVanilla {
7747
7327
  if (typeof config.merchantWalletAddresses !== "object") {
7748
7328
  throw new Error("merchantWalletAddresses must be an object");
7749
7329
  }
7750
- const walletCount = Object.keys(config.merchantWalletAddresses).length;
7751
- if (walletCount === 0) {
7752
- console.warn("⚠️ CoinleyVanilla: No merchant wallet addresses provided. Networks will be fetched from backend.");
7753
- }
7330
+ Object.keys(config.merchantWalletAddresses).length;
7754
7331
  }
7755
7332
  }
7756
7333
  /**
@@ -7788,13 +7365,7 @@ class CoinleyVanilla {
7788
7365
  * @private
7789
7366
  */
7790
7367
  _handleSuccess(paymentId, transactionHash, paymentDetails) {
7791
- if (this.config.debug) {
7792
- console.log("✅ CoinleyVanilla: Payment successful", {
7793
- paymentId,
7794
- transactionHash,
7795
- details: paymentDetails
7796
- });
7797
- }
7368
+ if (this.config.debug) ;
7798
7369
  if (this.callbacks.onSuccess) {
7799
7370
  this.callbacks.onSuccess(paymentId, transactionHash, paymentDetails);
7800
7371
  }
@@ -7804,9 +7375,7 @@ class CoinleyVanilla {
7804
7375
  * @private
7805
7376
  */
7806
7377
  _handleError(error) {
7807
- if (this.config.debug) {
7808
- console.error("❌ CoinleyVanilla: Payment error", error);
7809
- }
7378
+ if (this.config.debug) ;
7810
7379
  if (this.callbacks.onError) {
7811
7380
  this.callbacks.onError(error);
7812
7381
  }
@@ -7831,7 +7400,6 @@ class CoinleyVanilla {
7831
7400
  try {
7832
7401
  this.root.unmount();
7833
7402
  } catch (error) {
7834
- console.error("Error unmounting React root:", error);
7835
7403
  }
7836
7404
  this.root = null;
7837
7405
  }
@@ -7853,23 +7421,23 @@ if (typeof window !== "undefined") {
7853
7421
  function autoInitialize() {
7854
7422
  const scripts = document.querySelectorAll('script[src*="coinley-vanilla"]');
7855
7423
  scripts.forEach((script) => {
7424
+ const publicKey = script.getAttribute("data-public-key");
7856
7425
  const apiKey = script.getAttribute("data-api-key");
7857
7426
  const apiSecret = script.getAttribute("data-api-secret");
7858
7427
  const apiUrl = script.getAttribute("data-api-url");
7859
7428
  const theme = script.getAttribute("data-theme") || "light";
7860
7429
  const debug = script.hasAttribute("data-debug");
7861
- if (apiKey && apiSecret && apiUrl) {
7430
+ if ((publicKey || apiKey && apiSecret) && apiUrl) {
7862
7431
  try {
7863
7432
  window.coinley = new CoinleyVanilla({
7433
+ publicKey,
7864
7434
  apiKey,
7865
7435
  apiSecret,
7866
7436
  apiUrl,
7867
7437
  theme,
7868
7438
  debug
7869
7439
  });
7870
- console.log("✅ Coinley SDK auto-initialized from script tag");
7871
7440
  } catch (error) {
7872
- console.error("❌ Failed to auto-initialize Coinley SDK:", error);
7873
7441
  }
7874
7442
  }
7875
7443
  });