coinley-pay 0.16.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.
- package/dist/{CoinleyPayment-cKZE6vTC.js → CoinleyPayment-BRiKHFaK.js} +112 -73
- package/dist/{appKitEVM-Cczsrh75.js → appKitEVM-7klvcQWP.js} +2 -2
- package/dist/{appKitSolana-B5sLQhdT.js → appKitSolana-COVsc1hI.js} +2 -2
- package/dist/coinley-vanilla.min.js +2 -2
- package/dist/{index-DH6hsG4C.js → index-CJRf3v5i.js} +3 -3
- package/dist/{index-JtPtlS_B.js → index-DjkvRRWK.js} +3 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -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-
|
|
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";
|
|
@@ -2764,11 +2764,12 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
|
|
|
2764
2764
|
stale.code = "STALE_ATTEMPT";
|
|
2765
2765
|
throw stale;
|
|
2766
2766
|
}
|
|
2767
|
-
|
|
2767
|
+
const enrichedPayment = {
|
|
2768
2768
|
...payment.payment,
|
|
2769
2769
|
__coinleyAttemptId: (attemptMeta == null ? void 0 : attemptMeta.attemptId) ?? null,
|
|
2770
2770
|
__coinleySelectionSnapshot: (attemptMeta == null ? void 0 : attemptMeta.selectionSnapshot) ?? null
|
|
2771
|
-
}
|
|
2771
|
+
};
|
|
2772
|
+
setPaymentData(enrichedPayment);
|
|
2772
2773
|
sdkAnalytics.trackPaymentCreated(
|
|
2773
2774
|
(_l = payment.payment) == null ? void 0 : _l.id,
|
|
2774
2775
|
config.amount,
|
|
@@ -2782,6 +2783,7 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
|
|
|
2782
2783
|
selectedToken.symbol
|
|
2783
2784
|
);
|
|
2784
2785
|
setCurrentStep("confirm");
|
|
2786
|
+
return enrichedPayment;
|
|
2785
2787
|
} catch (err) {
|
|
2786
2788
|
if ((err == null ? void 0 : err.code) === "STALE_ATTEMPT") {
|
|
2787
2789
|
console.log("[PaymentFlow] createPayment aborted — stale attempt");
|
|
@@ -2893,12 +2895,13 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
|
|
|
2893
2895
|
stale.code = "STALE_ATTEMPT";
|
|
2894
2896
|
throw stale;
|
|
2895
2897
|
}
|
|
2896
|
-
|
|
2898
|
+
const enrichedPayment = {
|
|
2897
2899
|
...response.payment,
|
|
2898
2900
|
isDepositPayment: true,
|
|
2899
2901
|
__coinleyAttemptId: (attemptMeta == null ? void 0 : attemptMeta.attemptId) ?? null,
|
|
2900
2902
|
__coinleySelectionSnapshot: (attemptMeta == null ? void 0 : attemptMeta.selectionSnapshot) ?? null
|
|
2901
|
-
}
|
|
2903
|
+
};
|
|
2904
|
+
setPaymentData(enrichedPayment);
|
|
2902
2905
|
sdkAnalytics.trackPaymentCreated(
|
|
2903
2906
|
(_g = response.payment) == null ? void 0 : _g.id,
|
|
2904
2907
|
config.amount,
|
|
@@ -2912,7 +2915,7 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
|
|
|
2912
2915
|
selectedToken.symbol
|
|
2913
2916
|
);
|
|
2914
2917
|
setCurrentStep("confirm");
|
|
2915
|
-
return
|
|
2918
|
+
return enrichedPayment;
|
|
2916
2919
|
} catch (err) {
|
|
2917
2920
|
if ((err == null ? void 0 : err.code) === "STALE_ATTEMPT") {
|
|
2918
2921
|
console.log("[PaymentFlow] createDepositPayment aborted — stale attempt");
|
|
@@ -3613,12 +3616,18 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3613
3616
|
const { isLoading: isConfirming, isSuccess: isConfirmed } = useWaitForTransactionReceipt({
|
|
3614
3617
|
hash: txHash
|
|
3615
3618
|
});
|
|
3616
|
-
const
|
|
3619
|
+
const finalizePaymentInBackground = (transactionHash, activePaymentData) => {
|
|
3620
|
+
processFinalPayment(transactionHash, activePaymentData, { background: true }).catch((error) => {
|
|
3621
|
+
console.error("[processFinalPayment] Background finalization failed:", error);
|
|
3622
|
+
});
|
|
3623
|
+
};
|
|
3624
|
+
const executePaymentTransaction = async (paymentOverride = null) => {
|
|
3617
3625
|
var _a, _b;
|
|
3618
|
-
|
|
3626
|
+
const activePaymentData = paymentOverride || paymentData;
|
|
3627
|
+
if (!address || !(activePaymentData == null ? void 0 : activePaymentData.contractCall)) {
|
|
3619
3628
|
throw new Error("Missing wallet connection or payment data");
|
|
3620
3629
|
}
|
|
3621
|
-
const contractCall =
|
|
3630
|
+
const contractCall = activePaymentData.contractCall;
|
|
3622
3631
|
if (!contractCall.contractAddress) {
|
|
3623
3632
|
throw new Error("PaymentSplitter contract data missing from payment response");
|
|
3624
3633
|
}
|
|
@@ -3630,7 +3639,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3630
3639
|
}
|
|
3631
3640
|
if (selectedToken.contractAddress) {
|
|
3632
3641
|
const decimals = selectedToken.decimals || 6;
|
|
3633
|
-
const amount = contractCall.approvalAmount || Math.floor(
|
|
3642
|
+
const amount = contractCall.approvalAmount || Math.floor(activePaymentData.totalAmount * Math.pow(10, decimals));
|
|
3634
3643
|
try {
|
|
3635
3644
|
let userBalance;
|
|
3636
3645
|
let balanceCheckMethod = "unknown";
|
|
@@ -3680,7 +3689,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3680
3689
|
window.coinleyPendingSplitPayment = {
|
|
3681
3690
|
contractCall,
|
|
3682
3691
|
selectedToken,
|
|
3683
|
-
paymentData,
|
|
3692
|
+
paymentData: activePaymentData,
|
|
3684
3693
|
selectedNetwork
|
|
3685
3694
|
};
|
|
3686
3695
|
try {
|
|
@@ -3720,7 +3729,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3720
3729
|
setTransactionStep("splitPayment");
|
|
3721
3730
|
const splitPaymentHash2 = await executeSplitPayment();
|
|
3722
3731
|
if (splitPaymentHash2) {
|
|
3723
|
-
|
|
3732
|
+
finalizePaymentInBackground(splitPaymentHash2, activePaymentData);
|
|
3724
3733
|
}
|
|
3725
3734
|
return splitPaymentHash2;
|
|
3726
3735
|
}
|
|
@@ -3788,7 +3797,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3788
3797
|
}
|
|
3789
3798
|
const splitPaymentHash = await executeSplitPayment();
|
|
3790
3799
|
if (splitPaymentHash) {
|
|
3791
|
-
|
|
3800
|
+
finalizePaymentInBackground(splitPaymentHash, activePaymentData);
|
|
3792
3801
|
}
|
|
3793
3802
|
return splitPaymentHash;
|
|
3794
3803
|
} catch (error) {
|
|
@@ -3894,10 +3903,14 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3894
3903
|
throw error;
|
|
3895
3904
|
}
|
|
3896
3905
|
};
|
|
3897
|
-
const processFinalPayment = async (transactionHash) => {
|
|
3906
|
+
const processFinalPayment = async (transactionHash, paymentOverride = null, options = {}) => {
|
|
3898
3907
|
var _a;
|
|
3908
|
+
const activePaymentData = paymentOverride || paymentData;
|
|
3909
|
+
const runInBackground = (options == null ? void 0 : options.background) === true;
|
|
3899
3910
|
try {
|
|
3900
|
-
|
|
3911
|
+
if (!runInBackground) {
|
|
3912
|
+
setTransactionStep("processing");
|
|
3913
|
+
}
|
|
3901
3914
|
console.log("🔄 [processFinalPayment] Starting payment finalization...");
|
|
3902
3915
|
if (approveTransactionHash && transactionHash === approveTransactionHash) {
|
|
3903
3916
|
console.error("🛑 [processFinalPayment] BLOCKED: Attempted to send approve hash to backend!", {
|
|
@@ -3909,37 +3922,41 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3909
3922
|
if (!api || !api.processPayment) {
|
|
3910
3923
|
throw new Error("API instance not available or missing processPayment method");
|
|
3911
3924
|
}
|
|
3912
|
-
|
|
3913
|
-
|
|
3925
|
+
if (!runInBackground) {
|
|
3926
|
+
console.log("⏳ [processFinalPayment] Waiting 4s for blockchain indexers to sync...");
|
|
3927
|
+
await new Promise((resolve) => setTimeout(resolve, 4e3));
|
|
3928
|
+
}
|
|
3914
3929
|
const maxProcessRetries = 3;
|
|
3915
3930
|
let lastProcessError = null;
|
|
3916
3931
|
for (let processAttempt = 0; processAttempt < maxProcessRetries; processAttempt++) {
|
|
3917
3932
|
try {
|
|
3918
3933
|
if (processAttempt > 0) {
|
|
3919
|
-
const retryDelay = 5e3 *
|
|
3934
|
+
const retryDelay = 5e3 * processAttempt;
|
|
3920
3935
|
console.log(`🔄 [processFinalPayment] Retry ${processAttempt}/${maxProcessRetries}, waiting ${retryDelay / 1e3}s...`);
|
|
3921
3936
|
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
3922
3937
|
}
|
|
3923
3938
|
console.log(`📤 [processFinalPayment] Calling API.processPayment (attempt ${processAttempt + 1})...`);
|
|
3924
3939
|
const processResult = await api.processPayment(
|
|
3925
|
-
|
|
3940
|
+
activePaymentData.id,
|
|
3926
3941
|
transactionHash,
|
|
3927
3942
|
selectedNetwork.shortName,
|
|
3928
3943
|
address
|
|
3929
3944
|
);
|
|
3930
3945
|
if (processResult && processResult.success !== false) {
|
|
3931
3946
|
console.log("✅ [processFinalPayment] API.processPayment succeeded:", processResult);
|
|
3932
|
-
|
|
3947
|
+
if (!runInBackground) {
|
|
3948
|
+
setTransactionStep("success");
|
|
3949
|
+
}
|
|
3933
3950
|
sdkAnalytics.trackPaymentSuccess(
|
|
3934
|
-
|
|
3935
|
-
|
|
3951
|
+
activePaymentData.id,
|
|
3952
|
+
activePaymentData.amount,
|
|
3936
3953
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
3937
3954
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
3938
3955
|
transactionHash
|
|
3939
3956
|
);
|
|
3940
3957
|
clarityAnalytics.trackPaymentSuccess(
|
|
3941
|
-
|
|
3942
|
-
|
|
3958
|
+
activePaymentData.id,
|
|
3959
|
+
activePaymentData.amount,
|
|
3943
3960
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
3944
3961
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
3945
3962
|
transactionHash
|
|
@@ -3977,18 +3994,20 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3977
3994
|
console.error("❌ [processFinalPayment] Formatted error log:", errorLog);
|
|
3978
3995
|
const friendlyError = parseUserFriendlyError(error);
|
|
3979
3996
|
console.error("❌ [processFinalPayment] User-friendly error:", friendlyError);
|
|
3980
|
-
|
|
3981
|
-
|
|
3997
|
+
if (!runInBackground) {
|
|
3998
|
+
setTransactionError(friendlyError);
|
|
3999
|
+
setTransactionStep("error");
|
|
4000
|
+
}
|
|
3982
4001
|
sdkAnalytics.trackPaymentFailed(
|
|
3983
|
-
|
|
3984
|
-
|
|
4002
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
4003
|
+
activePaymentData == null ? void 0 : activePaymentData.amount,
|
|
3985
4004
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
3986
4005
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
3987
4006
|
friendlyError
|
|
3988
4007
|
);
|
|
3989
4008
|
clarityAnalytics.trackPaymentFailed(
|
|
3990
|
-
|
|
3991
|
-
|
|
4009
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
4010
|
+
activePaymentData == null ? void 0 : activePaymentData.amount,
|
|
3992
4011
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
3993
4012
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
3994
4013
|
friendlyError
|
|
@@ -21101,7 +21120,7 @@ const WalletSelector = ({
|
|
|
21101
21120
|
try {
|
|
21102
21121
|
setAppKitError(null);
|
|
21103
21122
|
setWalletConnectAddress(solanaAccountState.address);
|
|
21104
|
-
const { createWalletConnectAdapter } = await import("./appKitSolana-
|
|
21123
|
+
const { createWalletConnectAdapter } = await import("./appKitSolana-COVsc1hI.js");
|
|
21105
21124
|
const adapter = createWalletConnectAdapter(solanaAccountState.address);
|
|
21106
21125
|
await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
|
|
21107
21126
|
console.log("✅ WalletConnect synced with SDK");
|
|
@@ -21206,7 +21225,7 @@ const WalletSelector = ({
|
|
|
21206
21225
|
setAppKitLoading(true);
|
|
21207
21226
|
setAppKitError(null);
|
|
21208
21227
|
try {
|
|
21209
|
-
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-
|
|
21228
|
+
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-7klvcQWP.js");
|
|
21210
21229
|
await initializeAppKitEVM(wagmiConfig);
|
|
21211
21230
|
await openAppKitModal();
|
|
21212
21231
|
} catch (error) {
|
|
@@ -21226,7 +21245,7 @@ const WalletSelector = ({
|
|
|
21226
21245
|
setAppKitError(null);
|
|
21227
21246
|
try {
|
|
21228
21247
|
console.log("📦 Loading AppKit Solana module...");
|
|
21229
|
-
const { initializeAppKitSolana } = await import("./appKitSolana-
|
|
21248
|
+
const { initializeAppKitSolana } = await import("./appKitSolana-COVsc1hI.js");
|
|
21230
21249
|
console.log("✅ Module loaded, initializing...");
|
|
21231
21250
|
const modal = await initializeAppKitSolana(solanaWallet);
|
|
21232
21251
|
console.log("✅ AppKit Solana initialized successfully");
|
|
@@ -24983,14 +25002,24 @@ const CoinleyPaymentInternal = ({
|
|
|
24983
25002
|
setError("Invalid payment amount. Please refresh and try again.");
|
|
24984
25003
|
return;
|
|
24985
25004
|
}
|
|
25005
|
+
const currentSelectionSnapshot = buildSelectionSnapshot();
|
|
24986
25006
|
let attempt = activeAttemptRef.current;
|
|
24987
|
-
if (!attempt || !snapshotsMatch(attempt.snapshot,
|
|
25007
|
+
if (!attempt || !snapshotsMatch(attempt.snapshot, currentSelectionSnapshot)) {
|
|
24988
25008
|
attempt = createNewAttempt("connect-wallet", {
|
|
24989
|
-
snapshot:
|
|
25009
|
+
snapshot: currentSelectionSnapshot
|
|
24990
25010
|
});
|
|
24991
25011
|
}
|
|
24992
25012
|
const attemptMeta = buildAttemptMeta(attempt);
|
|
24993
25013
|
let effectivePaymentData = paymentData;
|
|
25014
|
+
const existingPaymentSnapshot = effectivePaymentData == null ? void 0 : effectivePaymentData.__coinleySelectionSnapshot;
|
|
25015
|
+
if (effectivePaymentData && (!existingPaymentSnapshot || !snapshotsMatch(existingPaymentSnapshot, currentSelectionSnapshot))) {
|
|
25016
|
+
console.log("[Attempt] discarding paymentData with missing or mismatched selection snapshot", {
|
|
25017
|
+
paymentId: effectivePaymentData.id,
|
|
25018
|
+
hasSnapshot: !!existingPaymentSnapshot
|
|
25019
|
+
});
|
|
25020
|
+
setPaymentData(null);
|
|
25021
|
+
effectivePaymentData = null;
|
|
25022
|
+
}
|
|
24994
25023
|
if ((effectivePaymentData == null ? void 0 : effectivePaymentData.__coinleyAttemptId) && effectivePaymentData.__coinleyAttemptId !== attempt.id) {
|
|
24995
25024
|
const existingSnapshot = effectivePaymentData.__coinleySelectionSnapshot;
|
|
24996
25025
|
if (existingSnapshot && snapshotsMatch(existingSnapshot, attempt.snapshot)) {
|
|
@@ -25038,7 +25067,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25038
25067
|
if (connectedWalletType === "solana" && merchantHasSolanaWallet && !(selectedToken == null ? void 0 : selectedToken.isSwapToken)) {
|
|
25039
25068
|
console.log("[Payment] Solana direct: merchant has Solana wallet");
|
|
25040
25069
|
try {
|
|
25041
|
-
await createPayment(configWithConvertedAmount);
|
|
25070
|
+
effectivePaymentData = await createPayment(configWithConvertedAmount);
|
|
25042
25071
|
} catch (e) {
|
|
25043
25072
|
if ((e == null ? void 0 : e.code) === "STALE_ATTEMPT") {
|
|
25044
25073
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
@@ -25064,7 +25093,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25064
25093
|
}
|
|
25065
25094
|
};
|
|
25066
25095
|
try {
|
|
25067
|
-
await createDepositPayment(depositConfig);
|
|
25096
|
+
effectivePaymentData = await createDepositPayment(depositConfig);
|
|
25068
25097
|
} catch (e) {
|
|
25069
25098
|
if ((e == null ? void 0 : e.code) === "STALE_ATTEMPT") {
|
|
25070
25099
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
@@ -25102,7 +25131,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25102
25131
|
expiresIn: BRIDGE_DEPOSIT_EXPIRY_SECONDS
|
|
25103
25132
|
};
|
|
25104
25133
|
try {
|
|
25105
|
-
await createDepositPayment(depositConfig);
|
|
25134
|
+
effectivePaymentData = await createDepositPayment(depositConfig);
|
|
25106
25135
|
} catch (e) {
|
|
25107
25136
|
if ((e == null ? void 0 : e.code) === "STALE_ATTEMPT") {
|
|
25108
25137
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
@@ -25112,7 +25141,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25112
25141
|
}
|
|
25113
25142
|
} else {
|
|
25114
25143
|
try {
|
|
25115
|
-
await createPayment(configWithConvertedAmount);
|
|
25144
|
+
effectivePaymentData = await createPayment(configWithConvertedAmount);
|
|
25116
25145
|
} catch (e) {
|
|
25117
25146
|
if ((e == null ? void 0 : e.code) === "STALE_ATTEMPT") {
|
|
25118
25147
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
@@ -25122,10 +25151,20 @@ const CoinleyPaymentInternal = ({
|
|
|
25122
25151
|
}
|
|
25123
25152
|
}
|
|
25124
25153
|
}
|
|
25125
|
-
|
|
25154
|
+
if (!effectivePaymentData) {
|
|
25155
|
+
setError("Payment could not be prepared. Please try again.");
|
|
25156
|
+
return;
|
|
25157
|
+
}
|
|
25158
|
+
setShowWalletConfirm(false);
|
|
25159
|
+
await executePayment(effectivePaymentData);
|
|
25126
25160
|
};
|
|
25127
|
-
const executePayment = async () => {
|
|
25161
|
+
const executePayment = async (paymentOverride = null) => {
|
|
25128
25162
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
25163
|
+
const activePaymentData = paymentOverride || paymentData;
|
|
25164
|
+
if (!(activePaymentData == null ? void 0 : activePaymentData.id)) {
|
|
25165
|
+
setError("Payment could not be prepared. Please try again.");
|
|
25166
|
+
return;
|
|
25167
|
+
}
|
|
25129
25168
|
if (isSwapOrBridgeFlow && relayBridge.bridgeStatus === "quoting") {
|
|
25130
25169
|
setError("Payment quote is being refreshed. Please wait a moment and try again.");
|
|
25131
25170
|
return;
|
|
@@ -25156,9 +25195,9 @@ const CoinleyPaymentInternal = ({
|
|
|
25156
25195
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
25157
25196
|
return;
|
|
25158
25197
|
}
|
|
25159
|
-
if (
|
|
25198
|
+
if (activePaymentData && activePaymentData.__coinleyAttemptId && activePaymentData.__coinleyAttemptId !== activeAttempt.id) {
|
|
25160
25199
|
console.warn("[Attempt] executePayment blocked — paymentData attempt mismatch", {
|
|
25161
|
-
paymentAttemptId:
|
|
25200
|
+
paymentAttemptId: activePaymentData.__coinleyAttemptId,
|
|
25162
25201
|
activeAttemptId: activeAttempt.id
|
|
25163
25202
|
});
|
|
25164
25203
|
setPaymentData(null);
|
|
@@ -25177,7 +25216,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25177
25216
|
}
|
|
25178
25217
|
console.log("[Attempt] executePayment proceeding", {
|
|
25179
25218
|
attemptId: activeAttempt.id,
|
|
25180
|
-
hasPaymentData: !!
|
|
25219
|
+
hasPaymentData: !!activePaymentData,
|
|
25181
25220
|
hasQuote: !!relayBridge.bridgeQuote
|
|
25182
25221
|
});
|
|
25183
25222
|
}
|
|
@@ -25188,7 +25227,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25188
25227
|
}
|
|
25189
25228
|
try {
|
|
25190
25229
|
setCurrentStep(PAYMENT_STEPS.PROCESSING);
|
|
25191
|
-
if ((
|
|
25230
|
+
if ((activePaymentData == null ? void 0 : activePaymentData.isDepositPayment) && (activePaymentData == null ? void 0 : activePaymentData.depositAddress)) {
|
|
25192
25231
|
console.log("[Solana] Bridged payment — executing Relay Solana→EVM bridge");
|
|
25193
25232
|
const bestDest = getBestDestinationChain(networks);
|
|
25194
25233
|
const destChainId = bestDest ? parseInt(bestDest.chainId) : 8453;
|
|
@@ -25218,7 +25257,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25218
25257
|
destStablecoinAddress,
|
|
25219
25258
|
"USDC",
|
|
25220
25259
|
amount.toString(),
|
|
25221
|
-
|
|
25260
|
+
activePaymentData.depositAddress,
|
|
25222
25261
|
null,
|
|
25223
25262
|
null,
|
|
25224
25263
|
solanaWallet.publicKey
|
|
@@ -25237,7 +25276,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25237
25276
|
destStablecoinAddress,
|
|
25238
25277
|
"USDC",
|
|
25239
25278
|
amount.toString(),
|
|
25240
|
-
|
|
25279
|
+
activePaymentData.depositAddress,
|
|
25241
25280
|
null,
|
|
25242
25281
|
null,
|
|
25243
25282
|
solanaWallet.publicKey
|
|
@@ -25286,7 +25325,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25286
25325
|
let detected = false;
|
|
25287
25326
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
25288
25327
|
try {
|
|
25289
|
-
const status = await paymentFlow.api.getDepositStatus(
|
|
25328
|
+
const status = await paymentFlow.api.getDepositStatus(activePaymentData.id);
|
|
25290
25329
|
console.log(`[Solana Bridge] Deposit check ${attempt + 1}/${maxAttempts}:`, (_g = status == null ? void 0 : status.payment) == null ? void 0 : _g.status);
|
|
25291
25330
|
if (((_h = status == null ? void 0 : status.payment) == null ? void 0 : _h.detectedAt) || ((_i = status == null ? void 0 : status.payment) == null ? void 0 : _i.status) === "completed" || ((_j = status == null ? void 0 : status.payment) == null ? void 0 : _j.status) === "swept") {
|
|
25292
25331
|
detected = true;
|
|
@@ -25299,7 +25338,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25299
25338
|
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
25300
25339
|
}
|
|
25301
25340
|
const successData = {
|
|
25302
|
-
paymentId:
|
|
25341
|
+
paymentId: activePaymentData.id,
|
|
25303
25342
|
transactionHash: primaryTxHash,
|
|
25304
25343
|
senderAddress: solanaWallet.publicKey,
|
|
25305
25344
|
network: "solana",
|
|
@@ -25318,22 +25357,22 @@ const CoinleyPaymentInternal = ({
|
|
|
25318
25357
|
}
|
|
25319
25358
|
return;
|
|
25320
25359
|
}
|
|
25321
|
-
const totalAmount = parseFloat(
|
|
25322
|
-
const merchantPercentage = (
|
|
25323
|
-
const coinleyPercentage = (
|
|
25360
|
+
const totalAmount = parseFloat(activePaymentData.amount);
|
|
25361
|
+
const merchantPercentage = (activePaymentData.merchantPercentage || 9825) / 1e4;
|
|
25362
|
+
const coinleyPercentage = (activePaymentData.coinleyPercentage || 175) / 1e4;
|
|
25324
25363
|
const merchantAmount = totalAmount * merchantPercentage;
|
|
25325
25364
|
const coinleyAmount = totalAmount * coinleyPercentage;
|
|
25326
25365
|
const result = await solanaTransaction.sendSplitPayment({
|
|
25327
25366
|
tokenMintAddress: selectedToken.contractAddress,
|
|
25328
|
-
merchantAddress:
|
|
25329
|
-
coinleyAddress:
|
|
25367
|
+
merchantAddress: activePaymentData.merchantWallet,
|
|
25368
|
+
coinleyAddress: activePaymentData.coinleyWallet,
|
|
25330
25369
|
merchantAmount,
|
|
25331
25370
|
coinleyAmount,
|
|
25332
25371
|
decimals: selectedToken.decimals || 6
|
|
25333
25372
|
});
|
|
25334
25373
|
if (result.success) {
|
|
25335
25374
|
const finalResult = await paymentFlow.api.processPayment(
|
|
25336
|
-
|
|
25375
|
+
activePaymentData.id,
|
|
25337
25376
|
result.signature,
|
|
25338
25377
|
selectedNetwork.shortName,
|
|
25339
25378
|
solanaWallet.publicKey
|
|
@@ -25341,14 +25380,14 @@ const CoinleyPaymentInternal = ({
|
|
|
25341
25380
|
if (finalResult.success) {
|
|
25342
25381
|
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
25343
25382
|
sdkAnalytics.trackPaymentSuccess(
|
|
25344
|
-
|
|
25383
|
+
activePaymentData.id,
|
|
25345
25384
|
config == null ? void 0 : config.amount,
|
|
25346
25385
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25347
25386
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
25348
25387
|
result.signature
|
|
25349
25388
|
);
|
|
25350
25389
|
clarityAnalytics.trackPaymentSuccess(
|
|
25351
|
-
|
|
25390
|
+
activePaymentData.id,
|
|
25352
25391
|
config == null ? void 0 : config.amount,
|
|
25353
25392
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25354
25393
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
@@ -25356,7 +25395,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25356
25395
|
);
|
|
25357
25396
|
if (onSuccess) {
|
|
25358
25397
|
onSuccess({
|
|
25359
|
-
paymentId:
|
|
25398
|
+
paymentId: activePaymentData.id,
|
|
25360
25399
|
transactionHash: result.signature,
|
|
25361
25400
|
senderAddress: solanaWallet.publicKey,
|
|
25362
25401
|
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
@@ -25371,14 +25410,14 @@ const CoinleyPaymentInternal = ({
|
|
|
25371
25410
|
}
|
|
25372
25411
|
} catch (err) {
|
|
25373
25412
|
sdkAnalytics.trackPaymentFailed(
|
|
25374
|
-
|
|
25413
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25375
25414
|
config == null ? void 0 : config.amount,
|
|
25376
25415
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25377
25416
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
25378
25417
|
err.message || "Transaction failed"
|
|
25379
25418
|
);
|
|
25380
25419
|
clarityAnalytics.trackPaymentFailed(
|
|
25381
|
-
|
|
25420
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25382
25421
|
config == null ? void 0 : config.amount,
|
|
25383
25422
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25384
25423
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
@@ -25400,7 +25439,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25400
25439
|
try {
|
|
25401
25440
|
setCurrentStep(PAYMENT_STEPS.PROCESSING);
|
|
25402
25441
|
setProcessingStatusMessage("");
|
|
25403
|
-
if ((walletConnection == null ? void 0 : walletConnection.ensureCorrectNetwork) && selectedNetwork) {
|
|
25442
|
+
if (isSwapOrBridgeFlow && (walletConnection == null ? void 0 : walletConnection.ensureCorrectNetwork) && selectedNetwork) {
|
|
25404
25443
|
const networkOk = await walletConnection.ensureCorrectNetwork(selectedNetwork);
|
|
25405
25444
|
if (!networkOk) {
|
|
25406
25445
|
throw new Error(`Please switch your wallet to ${selectedNetwork.name} and try again.`);
|
|
@@ -25408,7 +25447,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25408
25447
|
}
|
|
25409
25448
|
let txHash;
|
|
25410
25449
|
if (isSwapOrBridgeFlow) {
|
|
25411
|
-
if (!(
|
|
25450
|
+
if (!(activePaymentData == null ? void 0 : activePaymentData.depositAddress)) {
|
|
25412
25451
|
throw new Error("Payment is missing a deposit address. Please refresh and try again.");
|
|
25413
25452
|
}
|
|
25414
25453
|
if (!relayBridge.bridgeQuote) {
|
|
@@ -25420,7 +25459,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25420
25459
|
console.log(`🔄 Executing ${action} → deposit address flow`);
|
|
25421
25460
|
const { getWalletClient: getWalletClient2 } = await import("@wagmi/core");
|
|
25422
25461
|
const targetChainId = parseInt(selectedNetwork.chainId);
|
|
25423
|
-
const expectedDepositAddress = normalizeEvmAddress(
|
|
25462
|
+
const expectedDepositAddress = normalizeEvmAddress(activePaymentData.depositAddress);
|
|
25424
25463
|
const quoteRequestedRecipient = normalizeEvmAddress((_k = relayBridge.bridgeQuote) == null ? void 0 : _k.requestedRecipient);
|
|
25425
25464
|
const quoteEffectiveRecipient = normalizeEvmAddress((_l = relayBridge.bridgeQuote) == null ? void 0 : _l.effectiveRecipient);
|
|
25426
25465
|
console.log(`[${action}] validating deposit recipient`, {
|
|
@@ -25472,7 +25511,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25472
25511
|
(step, message) => {
|
|
25473
25512
|
console.log(`[${action}] ${step}: ${message}`);
|
|
25474
25513
|
},
|
|
25475
|
-
|
|
25514
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25476
25515
|
paymentFlow.api
|
|
25477
25516
|
);
|
|
25478
25517
|
if (result == null ? void 0 : result.success) {
|
|
@@ -25485,19 +25524,19 @@ const CoinleyPaymentInternal = ({
|
|
|
25485
25524
|
return;
|
|
25486
25525
|
}
|
|
25487
25526
|
} else {
|
|
25488
|
-
txHash = await executePaymentTransaction();
|
|
25527
|
+
txHash = await executePaymentTransaction(activePaymentData);
|
|
25489
25528
|
}
|
|
25490
25529
|
if (txHash) {
|
|
25491
25530
|
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
25492
25531
|
sdkAnalytics.trackPaymentSuccess(
|
|
25493
|
-
|
|
25532
|
+
activePaymentData.id,
|
|
25494
25533
|
config == null ? void 0 : config.amount,
|
|
25495
25534
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25496
25535
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
25497
25536
|
txHash
|
|
25498
25537
|
);
|
|
25499
25538
|
clarityAnalytics.trackPaymentSuccess(
|
|
25500
|
-
|
|
25539
|
+
activePaymentData.id,
|
|
25501
25540
|
config == null ? void 0 : config.amount,
|
|
25502
25541
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25503
25542
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
@@ -25505,7 +25544,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25505
25544
|
);
|
|
25506
25545
|
if (onSuccess) {
|
|
25507
25546
|
onSuccess({
|
|
25508
|
-
paymentId:
|
|
25547
|
+
paymentId: activePaymentData.id,
|
|
25509
25548
|
transactionHash: txHash,
|
|
25510
25549
|
senderAddress: address,
|
|
25511
25550
|
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
@@ -25522,14 +25561,14 @@ const CoinleyPaymentInternal = ({
|
|
|
25522
25561
|
return;
|
|
25523
25562
|
}
|
|
25524
25563
|
sdkAnalytics.trackPaymentFailed(
|
|
25525
|
-
|
|
25564
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25526
25565
|
config == null ? void 0 : config.amount,
|
|
25527
25566
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25528
25567
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
25529
25568
|
err.message || "Transaction failed"
|
|
25530
25569
|
);
|
|
25531
25570
|
clarityAnalytics.trackPaymentFailed(
|
|
25532
|
-
|
|
25571
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25533
25572
|
config == null ? void 0 : config.amount,
|
|
25534
25573
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25535
25574
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
@@ -26003,7 +26042,7 @@ const CoinleyPaymentInternal = ({
|
|
|
26003
26042
|
{
|
|
26004
26043
|
onClick: handleGenerateTransferAddress,
|
|
26005
26044
|
disabled: !selectedNetwork || !selectedToken || loading || isConverting,
|
|
26006
|
-
className:
|
|
26045
|
+
className: `mt-1 h-11 w-full rounded-full text-sm font-semibold text-white transition-colors ${selectedNetwork && selectedToken && !loading && !isConverting ? "bg-[#7042D2] hover:bg-[#5B34B1]" : "cursor-not-allowed bg-[#B89CE9] opacity-60"}`,
|
|
26007
26046
|
children: isConverting ? "Converting currency..." : loading ? "Generating Address..." : `Pay ${paymentAmountLabel}`
|
|
26008
26047
|
}
|
|
26009
26048
|
)
|
|
@@ -26062,7 +26101,7 @@ const CoinleyPaymentInternal = ({
|
|
|
26062
26101
|
if (!search) return true;
|
|
26063
26102
|
return getNetworkDisplayName(network).toLowerCase().includes(search) || ((_b = (_a2 = network == null ? void 0 : network.shortName) == null ? void 0 : _a2.toLowerCase) == null ? void 0 : _b.call(_a2).includes(search));
|
|
26064
26103
|
});
|
|
26065
|
-
const visibleWalletNetworkOptions =
|
|
26104
|
+
const visibleWalletNetworkOptions = filteredWalletNetworkOptions;
|
|
26066
26105
|
const renderWalletNetworkPickerPanel = () => /* @__PURE__ */ jsxs("div", { className: "pt-1", children: [
|
|
26067
26106
|
/* @__PURE__ */ jsx("p", { className: "mb-2 text-xs font-medium text-[#1F2430]", children: "Select a preferred network" }),
|
|
26068
26107
|
/* @__PURE__ */ jsx("div", { className: "relative mb-2", children: /* @__PURE__ */ jsx(
|
|
@@ -26956,4 +26995,4 @@ export {
|
|
|
26956
26995
|
isFeatureEnabled as i,
|
|
26957
26996
|
logo as l
|
|
26958
26997
|
};
|
|
26959
|
-
//# sourceMappingURL=CoinleyPayment-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
245
|
+
//# sourceMappingURL=appKitSolana-COVsc1hI.js.map
|