coinley-pay 0.16.0 → 0.17.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-DWGoIei3.js} +94 -69
- package/dist/{appKitEVM-Cczsrh75.js → appKitEVM-CH55u3Is.js} +2 -2
- package/dist/{appKitSolana-B5sLQhdT.js → appKitSolana-jtnvPa0Y.js} +2 -2
- package/dist/coinley-vanilla.min.js +2 -2
- package/dist/{index-JtPtlS_B.js → index-ArVDuAUY.js} +3 -3
- package/dist/{index-DH6hsG4C.js → index-knR8SxKc.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-ArVDuAUY.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,13 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3613
3616
|
const { isLoading: isConfirming, isSuccess: isConfirmed } = useWaitForTransactionReceipt({
|
|
3614
3617
|
hash: txHash
|
|
3615
3618
|
});
|
|
3616
|
-
const executePaymentTransaction = async () => {
|
|
3619
|
+
const executePaymentTransaction = async (paymentOverride = null) => {
|
|
3617
3620
|
var _a, _b;
|
|
3618
|
-
|
|
3621
|
+
const activePaymentData = paymentOverride || paymentData;
|
|
3622
|
+
if (!address || !(activePaymentData == null ? void 0 : activePaymentData.contractCall)) {
|
|
3619
3623
|
throw new Error("Missing wallet connection or payment data");
|
|
3620
3624
|
}
|
|
3621
|
-
const contractCall =
|
|
3625
|
+
const contractCall = activePaymentData.contractCall;
|
|
3622
3626
|
if (!contractCall.contractAddress) {
|
|
3623
3627
|
throw new Error("PaymentSplitter contract data missing from payment response");
|
|
3624
3628
|
}
|
|
@@ -3630,7 +3634,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3630
3634
|
}
|
|
3631
3635
|
if (selectedToken.contractAddress) {
|
|
3632
3636
|
const decimals = selectedToken.decimals || 6;
|
|
3633
|
-
const amount = contractCall.approvalAmount || Math.floor(
|
|
3637
|
+
const amount = contractCall.approvalAmount || Math.floor(activePaymentData.totalAmount * Math.pow(10, decimals));
|
|
3634
3638
|
try {
|
|
3635
3639
|
let userBalance;
|
|
3636
3640
|
let balanceCheckMethod = "unknown";
|
|
@@ -3680,7 +3684,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3680
3684
|
window.coinleyPendingSplitPayment = {
|
|
3681
3685
|
contractCall,
|
|
3682
3686
|
selectedToken,
|
|
3683
|
-
paymentData,
|
|
3687
|
+
paymentData: activePaymentData,
|
|
3684
3688
|
selectedNetwork
|
|
3685
3689
|
};
|
|
3686
3690
|
try {
|
|
@@ -3720,7 +3724,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3720
3724
|
setTransactionStep("splitPayment");
|
|
3721
3725
|
const splitPaymentHash2 = await executeSplitPayment();
|
|
3722
3726
|
if (splitPaymentHash2) {
|
|
3723
|
-
await processFinalPayment(splitPaymentHash2);
|
|
3727
|
+
await processFinalPayment(splitPaymentHash2, activePaymentData);
|
|
3724
3728
|
}
|
|
3725
3729
|
return splitPaymentHash2;
|
|
3726
3730
|
}
|
|
@@ -3788,7 +3792,7 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3788
3792
|
}
|
|
3789
3793
|
const splitPaymentHash = await executeSplitPayment();
|
|
3790
3794
|
if (splitPaymentHash) {
|
|
3791
|
-
await processFinalPayment(splitPaymentHash);
|
|
3795
|
+
await processFinalPayment(splitPaymentHash, activePaymentData);
|
|
3792
3796
|
}
|
|
3793
3797
|
return splitPaymentHash;
|
|
3794
3798
|
} catch (error) {
|
|
@@ -3894,8 +3898,9 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3894
3898
|
throw error;
|
|
3895
3899
|
}
|
|
3896
3900
|
};
|
|
3897
|
-
const processFinalPayment = async (transactionHash) => {
|
|
3901
|
+
const processFinalPayment = async (transactionHash, paymentOverride = null) => {
|
|
3898
3902
|
var _a;
|
|
3903
|
+
const activePaymentData = paymentOverride || paymentData;
|
|
3899
3904
|
try {
|
|
3900
3905
|
setTransactionStep("processing");
|
|
3901
3906
|
console.log("🔄 [processFinalPayment] Starting payment finalization...");
|
|
@@ -3909,20 +3914,20 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3909
3914
|
if (!api || !api.processPayment) {
|
|
3910
3915
|
throw new Error("API instance not available or missing processPayment method");
|
|
3911
3916
|
}
|
|
3912
|
-
console.log("⏳ [processFinalPayment] Waiting
|
|
3913
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3917
|
+
console.log("⏳ [processFinalPayment] Waiting 4s for blockchain indexers to sync...");
|
|
3918
|
+
await new Promise((resolve) => setTimeout(resolve, 4e3));
|
|
3914
3919
|
const maxProcessRetries = 3;
|
|
3915
3920
|
let lastProcessError = null;
|
|
3916
3921
|
for (let processAttempt = 0; processAttempt < maxProcessRetries; processAttempt++) {
|
|
3917
3922
|
try {
|
|
3918
3923
|
if (processAttempt > 0) {
|
|
3919
|
-
const retryDelay = 5e3 *
|
|
3924
|
+
const retryDelay = 5e3 * processAttempt;
|
|
3920
3925
|
console.log(`🔄 [processFinalPayment] Retry ${processAttempt}/${maxProcessRetries}, waiting ${retryDelay / 1e3}s...`);
|
|
3921
3926
|
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
3922
3927
|
}
|
|
3923
3928
|
console.log(`📤 [processFinalPayment] Calling API.processPayment (attempt ${processAttempt + 1})...`);
|
|
3924
3929
|
const processResult = await api.processPayment(
|
|
3925
|
-
|
|
3930
|
+
activePaymentData.id,
|
|
3926
3931
|
transactionHash,
|
|
3927
3932
|
selectedNetwork.shortName,
|
|
3928
3933
|
address
|
|
@@ -3931,15 +3936,15 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3931
3936
|
console.log("✅ [processFinalPayment] API.processPayment succeeded:", processResult);
|
|
3932
3937
|
setTransactionStep("success");
|
|
3933
3938
|
sdkAnalytics.trackPaymentSuccess(
|
|
3934
|
-
|
|
3935
|
-
|
|
3939
|
+
activePaymentData.id,
|
|
3940
|
+
activePaymentData.amount,
|
|
3936
3941
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
3937
3942
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
3938
3943
|
transactionHash
|
|
3939
3944
|
);
|
|
3940
3945
|
clarityAnalytics.trackPaymentSuccess(
|
|
3941
|
-
|
|
3942
|
-
|
|
3946
|
+
activePaymentData.id,
|
|
3947
|
+
activePaymentData.amount,
|
|
3943
3948
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
3944
3949
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
3945
3950
|
transactionHash
|
|
@@ -3980,15 +3985,15 @@ const useTransactionHandling = (paymentData, selectedToken, selectedNetwork, add
|
|
|
3980
3985
|
setTransactionError(friendlyError);
|
|
3981
3986
|
setTransactionStep("error");
|
|
3982
3987
|
sdkAnalytics.trackPaymentFailed(
|
|
3983
|
-
|
|
3984
|
-
|
|
3988
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
3989
|
+
activePaymentData == null ? void 0 : activePaymentData.amount,
|
|
3985
3990
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
3986
3991
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
3987
3992
|
friendlyError
|
|
3988
3993
|
);
|
|
3989
3994
|
clarityAnalytics.trackPaymentFailed(
|
|
3990
|
-
|
|
3991
|
-
|
|
3995
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
3996
|
+
activePaymentData == null ? void 0 : activePaymentData.amount,
|
|
3992
3997
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
3993
3998
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
3994
3999
|
friendlyError
|
|
@@ -21101,7 +21106,7 @@ const WalletSelector = ({
|
|
|
21101
21106
|
try {
|
|
21102
21107
|
setAppKitError(null);
|
|
21103
21108
|
setWalletConnectAddress(solanaAccountState.address);
|
|
21104
|
-
const { createWalletConnectAdapter } = await import("./appKitSolana-
|
|
21109
|
+
const { createWalletConnectAdapter } = await import("./appKitSolana-jtnvPa0Y.js");
|
|
21105
21110
|
const adapter = createWalletConnectAdapter(solanaAccountState.address);
|
|
21106
21111
|
await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
|
|
21107
21112
|
console.log("✅ WalletConnect synced with SDK");
|
|
@@ -21206,7 +21211,7 @@ const WalletSelector = ({
|
|
|
21206
21211
|
setAppKitLoading(true);
|
|
21207
21212
|
setAppKitError(null);
|
|
21208
21213
|
try {
|
|
21209
|
-
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-
|
|
21214
|
+
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-CH55u3Is.js");
|
|
21210
21215
|
await initializeAppKitEVM(wagmiConfig);
|
|
21211
21216
|
await openAppKitModal();
|
|
21212
21217
|
} catch (error) {
|
|
@@ -21226,7 +21231,7 @@ const WalletSelector = ({
|
|
|
21226
21231
|
setAppKitError(null);
|
|
21227
21232
|
try {
|
|
21228
21233
|
console.log("📦 Loading AppKit Solana module...");
|
|
21229
|
-
const { initializeAppKitSolana } = await import("./appKitSolana-
|
|
21234
|
+
const { initializeAppKitSolana } = await import("./appKitSolana-jtnvPa0Y.js");
|
|
21230
21235
|
console.log("✅ Module loaded, initializing...");
|
|
21231
21236
|
const modal = await initializeAppKitSolana(solanaWallet);
|
|
21232
21237
|
console.log("✅ AppKit Solana initialized successfully");
|
|
@@ -24983,14 +24988,24 @@ const CoinleyPaymentInternal = ({
|
|
|
24983
24988
|
setError("Invalid payment amount. Please refresh and try again.");
|
|
24984
24989
|
return;
|
|
24985
24990
|
}
|
|
24991
|
+
const currentSelectionSnapshot = buildSelectionSnapshot();
|
|
24986
24992
|
let attempt = activeAttemptRef.current;
|
|
24987
|
-
if (!attempt || !snapshotsMatch(attempt.snapshot,
|
|
24993
|
+
if (!attempt || !snapshotsMatch(attempt.snapshot, currentSelectionSnapshot)) {
|
|
24988
24994
|
attempt = createNewAttempt("connect-wallet", {
|
|
24989
|
-
snapshot:
|
|
24995
|
+
snapshot: currentSelectionSnapshot
|
|
24990
24996
|
});
|
|
24991
24997
|
}
|
|
24992
24998
|
const attemptMeta = buildAttemptMeta(attempt);
|
|
24993
24999
|
let effectivePaymentData = paymentData;
|
|
25000
|
+
const existingPaymentSnapshot = effectivePaymentData == null ? void 0 : effectivePaymentData.__coinleySelectionSnapshot;
|
|
25001
|
+
if (effectivePaymentData && (!existingPaymentSnapshot || !snapshotsMatch(existingPaymentSnapshot, currentSelectionSnapshot))) {
|
|
25002
|
+
console.log("[Attempt] discarding paymentData with missing or mismatched selection snapshot", {
|
|
25003
|
+
paymentId: effectivePaymentData.id,
|
|
25004
|
+
hasSnapshot: !!existingPaymentSnapshot
|
|
25005
|
+
});
|
|
25006
|
+
setPaymentData(null);
|
|
25007
|
+
effectivePaymentData = null;
|
|
25008
|
+
}
|
|
24994
25009
|
if ((effectivePaymentData == null ? void 0 : effectivePaymentData.__coinleyAttemptId) && effectivePaymentData.__coinleyAttemptId !== attempt.id) {
|
|
24995
25010
|
const existingSnapshot = effectivePaymentData.__coinleySelectionSnapshot;
|
|
24996
25011
|
if (existingSnapshot && snapshotsMatch(existingSnapshot, attempt.snapshot)) {
|
|
@@ -25038,7 +25053,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25038
25053
|
if (connectedWalletType === "solana" && merchantHasSolanaWallet && !(selectedToken == null ? void 0 : selectedToken.isSwapToken)) {
|
|
25039
25054
|
console.log("[Payment] Solana direct: merchant has Solana wallet");
|
|
25040
25055
|
try {
|
|
25041
|
-
await createPayment(configWithConvertedAmount);
|
|
25056
|
+
effectivePaymentData = await createPayment(configWithConvertedAmount);
|
|
25042
25057
|
} catch (e) {
|
|
25043
25058
|
if ((e == null ? void 0 : e.code) === "STALE_ATTEMPT") {
|
|
25044
25059
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
@@ -25064,7 +25079,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25064
25079
|
}
|
|
25065
25080
|
};
|
|
25066
25081
|
try {
|
|
25067
|
-
await createDepositPayment(depositConfig);
|
|
25082
|
+
effectivePaymentData = await createDepositPayment(depositConfig);
|
|
25068
25083
|
} catch (e) {
|
|
25069
25084
|
if ((e == null ? void 0 : e.code) === "STALE_ATTEMPT") {
|
|
25070
25085
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
@@ -25102,7 +25117,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25102
25117
|
expiresIn: BRIDGE_DEPOSIT_EXPIRY_SECONDS
|
|
25103
25118
|
};
|
|
25104
25119
|
try {
|
|
25105
|
-
await createDepositPayment(depositConfig);
|
|
25120
|
+
effectivePaymentData = await createDepositPayment(depositConfig);
|
|
25106
25121
|
} catch (e) {
|
|
25107
25122
|
if ((e == null ? void 0 : e.code) === "STALE_ATTEMPT") {
|
|
25108
25123
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
@@ -25112,7 +25127,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25112
25127
|
}
|
|
25113
25128
|
} else {
|
|
25114
25129
|
try {
|
|
25115
|
-
await createPayment(configWithConvertedAmount);
|
|
25130
|
+
effectivePaymentData = await createPayment(configWithConvertedAmount);
|
|
25116
25131
|
} catch (e) {
|
|
25117
25132
|
if ((e == null ? void 0 : e.code) === "STALE_ATTEMPT") {
|
|
25118
25133
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
@@ -25122,10 +25137,20 @@ const CoinleyPaymentInternal = ({
|
|
|
25122
25137
|
}
|
|
25123
25138
|
}
|
|
25124
25139
|
}
|
|
25125
|
-
|
|
25140
|
+
if (!effectivePaymentData) {
|
|
25141
|
+
setError("Payment could not be prepared. Please try again.");
|
|
25142
|
+
return;
|
|
25143
|
+
}
|
|
25144
|
+
setShowWalletConfirm(false);
|
|
25145
|
+
await executePayment(effectivePaymentData);
|
|
25126
25146
|
};
|
|
25127
|
-
const executePayment = async () => {
|
|
25147
|
+
const executePayment = async (paymentOverride = null) => {
|
|
25128
25148
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
25149
|
+
const activePaymentData = paymentOverride || paymentData;
|
|
25150
|
+
if (!(activePaymentData == null ? void 0 : activePaymentData.id)) {
|
|
25151
|
+
setError("Payment could not be prepared. Please try again.");
|
|
25152
|
+
return;
|
|
25153
|
+
}
|
|
25129
25154
|
if (isSwapOrBridgeFlow && relayBridge.bridgeStatus === "quoting") {
|
|
25130
25155
|
setError("Payment quote is being refreshed. Please wait a moment and try again.");
|
|
25131
25156
|
return;
|
|
@@ -25156,9 +25181,9 @@ const CoinleyPaymentInternal = ({
|
|
|
25156
25181
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
25157
25182
|
return;
|
|
25158
25183
|
}
|
|
25159
|
-
if (
|
|
25184
|
+
if (activePaymentData && activePaymentData.__coinleyAttemptId && activePaymentData.__coinleyAttemptId !== activeAttempt.id) {
|
|
25160
25185
|
console.warn("[Attempt] executePayment blocked — paymentData attempt mismatch", {
|
|
25161
|
-
paymentAttemptId:
|
|
25186
|
+
paymentAttemptId: activePaymentData.__coinleyAttemptId,
|
|
25162
25187
|
activeAttemptId: activeAttempt.id
|
|
25163
25188
|
});
|
|
25164
25189
|
setPaymentData(null);
|
|
@@ -25177,7 +25202,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25177
25202
|
}
|
|
25178
25203
|
console.log("[Attempt] executePayment proceeding", {
|
|
25179
25204
|
attemptId: activeAttempt.id,
|
|
25180
|
-
hasPaymentData: !!
|
|
25205
|
+
hasPaymentData: !!activePaymentData,
|
|
25181
25206
|
hasQuote: !!relayBridge.bridgeQuote
|
|
25182
25207
|
});
|
|
25183
25208
|
}
|
|
@@ -25188,7 +25213,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25188
25213
|
}
|
|
25189
25214
|
try {
|
|
25190
25215
|
setCurrentStep(PAYMENT_STEPS.PROCESSING);
|
|
25191
|
-
if ((
|
|
25216
|
+
if ((activePaymentData == null ? void 0 : activePaymentData.isDepositPayment) && (activePaymentData == null ? void 0 : activePaymentData.depositAddress)) {
|
|
25192
25217
|
console.log("[Solana] Bridged payment — executing Relay Solana→EVM bridge");
|
|
25193
25218
|
const bestDest = getBestDestinationChain(networks);
|
|
25194
25219
|
const destChainId = bestDest ? parseInt(bestDest.chainId) : 8453;
|
|
@@ -25218,7 +25243,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25218
25243
|
destStablecoinAddress,
|
|
25219
25244
|
"USDC",
|
|
25220
25245
|
amount.toString(),
|
|
25221
|
-
|
|
25246
|
+
activePaymentData.depositAddress,
|
|
25222
25247
|
null,
|
|
25223
25248
|
null,
|
|
25224
25249
|
solanaWallet.publicKey
|
|
@@ -25237,7 +25262,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25237
25262
|
destStablecoinAddress,
|
|
25238
25263
|
"USDC",
|
|
25239
25264
|
amount.toString(),
|
|
25240
|
-
|
|
25265
|
+
activePaymentData.depositAddress,
|
|
25241
25266
|
null,
|
|
25242
25267
|
null,
|
|
25243
25268
|
solanaWallet.publicKey
|
|
@@ -25286,7 +25311,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25286
25311
|
let detected = false;
|
|
25287
25312
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
25288
25313
|
try {
|
|
25289
|
-
const status = await paymentFlow.api.getDepositStatus(
|
|
25314
|
+
const status = await paymentFlow.api.getDepositStatus(activePaymentData.id);
|
|
25290
25315
|
console.log(`[Solana Bridge] Deposit check ${attempt + 1}/${maxAttempts}:`, (_g = status == null ? void 0 : status.payment) == null ? void 0 : _g.status);
|
|
25291
25316
|
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
25317
|
detected = true;
|
|
@@ -25299,7 +25324,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25299
25324
|
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
25300
25325
|
}
|
|
25301
25326
|
const successData = {
|
|
25302
|
-
paymentId:
|
|
25327
|
+
paymentId: activePaymentData.id,
|
|
25303
25328
|
transactionHash: primaryTxHash,
|
|
25304
25329
|
senderAddress: solanaWallet.publicKey,
|
|
25305
25330
|
network: "solana",
|
|
@@ -25318,22 +25343,22 @@ const CoinleyPaymentInternal = ({
|
|
|
25318
25343
|
}
|
|
25319
25344
|
return;
|
|
25320
25345
|
}
|
|
25321
|
-
const totalAmount = parseFloat(
|
|
25322
|
-
const merchantPercentage = (
|
|
25323
|
-
const coinleyPercentage = (
|
|
25346
|
+
const totalAmount = parseFloat(activePaymentData.amount);
|
|
25347
|
+
const merchantPercentage = (activePaymentData.merchantPercentage || 9825) / 1e4;
|
|
25348
|
+
const coinleyPercentage = (activePaymentData.coinleyPercentage || 175) / 1e4;
|
|
25324
25349
|
const merchantAmount = totalAmount * merchantPercentage;
|
|
25325
25350
|
const coinleyAmount = totalAmount * coinleyPercentage;
|
|
25326
25351
|
const result = await solanaTransaction.sendSplitPayment({
|
|
25327
25352
|
tokenMintAddress: selectedToken.contractAddress,
|
|
25328
|
-
merchantAddress:
|
|
25329
|
-
coinleyAddress:
|
|
25353
|
+
merchantAddress: activePaymentData.merchantWallet,
|
|
25354
|
+
coinleyAddress: activePaymentData.coinleyWallet,
|
|
25330
25355
|
merchantAmount,
|
|
25331
25356
|
coinleyAmount,
|
|
25332
25357
|
decimals: selectedToken.decimals || 6
|
|
25333
25358
|
});
|
|
25334
25359
|
if (result.success) {
|
|
25335
25360
|
const finalResult = await paymentFlow.api.processPayment(
|
|
25336
|
-
|
|
25361
|
+
activePaymentData.id,
|
|
25337
25362
|
result.signature,
|
|
25338
25363
|
selectedNetwork.shortName,
|
|
25339
25364
|
solanaWallet.publicKey
|
|
@@ -25341,14 +25366,14 @@ const CoinleyPaymentInternal = ({
|
|
|
25341
25366
|
if (finalResult.success) {
|
|
25342
25367
|
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
25343
25368
|
sdkAnalytics.trackPaymentSuccess(
|
|
25344
|
-
|
|
25369
|
+
activePaymentData.id,
|
|
25345
25370
|
config == null ? void 0 : config.amount,
|
|
25346
25371
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25347
25372
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
25348
25373
|
result.signature
|
|
25349
25374
|
);
|
|
25350
25375
|
clarityAnalytics.trackPaymentSuccess(
|
|
25351
|
-
|
|
25376
|
+
activePaymentData.id,
|
|
25352
25377
|
config == null ? void 0 : config.amount,
|
|
25353
25378
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25354
25379
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
@@ -25356,7 +25381,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25356
25381
|
);
|
|
25357
25382
|
if (onSuccess) {
|
|
25358
25383
|
onSuccess({
|
|
25359
|
-
paymentId:
|
|
25384
|
+
paymentId: activePaymentData.id,
|
|
25360
25385
|
transactionHash: result.signature,
|
|
25361
25386
|
senderAddress: solanaWallet.publicKey,
|
|
25362
25387
|
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
@@ -25371,14 +25396,14 @@ const CoinleyPaymentInternal = ({
|
|
|
25371
25396
|
}
|
|
25372
25397
|
} catch (err) {
|
|
25373
25398
|
sdkAnalytics.trackPaymentFailed(
|
|
25374
|
-
|
|
25399
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25375
25400
|
config == null ? void 0 : config.amount,
|
|
25376
25401
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25377
25402
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
25378
25403
|
err.message || "Transaction failed"
|
|
25379
25404
|
);
|
|
25380
25405
|
clarityAnalytics.trackPaymentFailed(
|
|
25381
|
-
|
|
25406
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25382
25407
|
config == null ? void 0 : config.amount,
|
|
25383
25408
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25384
25409
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
@@ -25400,7 +25425,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25400
25425
|
try {
|
|
25401
25426
|
setCurrentStep(PAYMENT_STEPS.PROCESSING);
|
|
25402
25427
|
setProcessingStatusMessage("");
|
|
25403
|
-
if ((walletConnection == null ? void 0 : walletConnection.ensureCorrectNetwork) && selectedNetwork) {
|
|
25428
|
+
if (isSwapOrBridgeFlow && (walletConnection == null ? void 0 : walletConnection.ensureCorrectNetwork) && selectedNetwork) {
|
|
25404
25429
|
const networkOk = await walletConnection.ensureCorrectNetwork(selectedNetwork);
|
|
25405
25430
|
if (!networkOk) {
|
|
25406
25431
|
throw new Error(`Please switch your wallet to ${selectedNetwork.name} and try again.`);
|
|
@@ -25408,7 +25433,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25408
25433
|
}
|
|
25409
25434
|
let txHash;
|
|
25410
25435
|
if (isSwapOrBridgeFlow) {
|
|
25411
|
-
if (!(
|
|
25436
|
+
if (!(activePaymentData == null ? void 0 : activePaymentData.depositAddress)) {
|
|
25412
25437
|
throw new Error("Payment is missing a deposit address. Please refresh and try again.");
|
|
25413
25438
|
}
|
|
25414
25439
|
if (!relayBridge.bridgeQuote) {
|
|
@@ -25420,7 +25445,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25420
25445
|
console.log(`🔄 Executing ${action} → deposit address flow`);
|
|
25421
25446
|
const { getWalletClient: getWalletClient2 } = await import("@wagmi/core");
|
|
25422
25447
|
const targetChainId = parseInt(selectedNetwork.chainId);
|
|
25423
|
-
const expectedDepositAddress = normalizeEvmAddress(
|
|
25448
|
+
const expectedDepositAddress = normalizeEvmAddress(activePaymentData.depositAddress);
|
|
25424
25449
|
const quoteRequestedRecipient = normalizeEvmAddress((_k = relayBridge.bridgeQuote) == null ? void 0 : _k.requestedRecipient);
|
|
25425
25450
|
const quoteEffectiveRecipient = normalizeEvmAddress((_l = relayBridge.bridgeQuote) == null ? void 0 : _l.effectiveRecipient);
|
|
25426
25451
|
console.log(`[${action}] validating deposit recipient`, {
|
|
@@ -25472,7 +25497,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25472
25497
|
(step, message) => {
|
|
25473
25498
|
console.log(`[${action}] ${step}: ${message}`);
|
|
25474
25499
|
},
|
|
25475
|
-
|
|
25500
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25476
25501
|
paymentFlow.api
|
|
25477
25502
|
);
|
|
25478
25503
|
if (result == null ? void 0 : result.success) {
|
|
@@ -25485,19 +25510,19 @@ const CoinleyPaymentInternal = ({
|
|
|
25485
25510
|
return;
|
|
25486
25511
|
}
|
|
25487
25512
|
} else {
|
|
25488
|
-
txHash = await executePaymentTransaction();
|
|
25513
|
+
txHash = await executePaymentTransaction(activePaymentData);
|
|
25489
25514
|
}
|
|
25490
25515
|
if (txHash) {
|
|
25491
25516
|
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
25492
25517
|
sdkAnalytics.trackPaymentSuccess(
|
|
25493
|
-
|
|
25518
|
+
activePaymentData.id,
|
|
25494
25519
|
config == null ? void 0 : config.amount,
|
|
25495
25520
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25496
25521
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
25497
25522
|
txHash
|
|
25498
25523
|
);
|
|
25499
25524
|
clarityAnalytics.trackPaymentSuccess(
|
|
25500
|
-
|
|
25525
|
+
activePaymentData.id,
|
|
25501
25526
|
config == null ? void 0 : config.amount,
|
|
25502
25527
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25503
25528
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
@@ -25505,7 +25530,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25505
25530
|
);
|
|
25506
25531
|
if (onSuccess) {
|
|
25507
25532
|
onSuccess({
|
|
25508
|
-
paymentId:
|
|
25533
|
+
paymentId: activePaymentData.id,
|
|
25509
25534
|
transactionHash: txHash,
|
|
25510
25535
|
senderAddress: address,
|
|
25511
25536
|
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
@@ -25522,14 +25547,14 @@ const CoinleyPaymentInternal = ({
|
|
|
25522
25547
|
return;
|
|
25523
25548
|
}
|
|
25524
25549
|
sdkAnalytics.trackPaymentFailed(
|
|
25525
|
-
|
|
25550
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25526
25551
|
config == null ? void 0 : config.amount,
|
|
25527
25552
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25528
25553
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
25529
25554
|
err.message || "Transaction failed"
|
|
25530
25555
|
);
|
|
25531
25556
|
clarityAnalytics.trackPaymentFailed(
|
|
25532
|
-
|
|
25557
|
+
activePaymentData == null ? void 0 : activePaymentData.id,
|
|
25533
25558
|
config == null ? void 0 : config.amount,
|
|
25534
25559
|
selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
25535
25560
|
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
@@ -26003,7 +26028,7 @@ const CoinleyPaymentInternal = ({
|
|
|
26003
26028
|
{
|
|
26004
26029
|
onClick: handleGenerateTransferAddress,
|
|
26005
26030
|
disabled: !selectedNetwork || !selectedToken || loading || isConverting,
|
|
26006
|
-
className:
|
|
26031
|
+
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
26032
|
children: isConverting ? "Converting currency..." : loading ? "Generating Address..." : `Pay ${paymentAmountLabel}`
|
|
26008
26033
|
}
|
|
26009
26034
|
)
|
|
@@ -26062,7 +26087,7 @@ const CoinleyPaymentInternal = ({
|
|
|
26062
26087
|
if (!search) return true;
|
|
26063
26088
|
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
26089
|
});
|
|
26065
|
-
const visibleWalletNetworkOptions =
|
|
26090
|
+
const visibleWalletNetworkOptions = filteredWalletNetworkOptions;
|
|
26066
26091
|
const renderWalletNetworkPickerPanel = () => /* @__PURE__ */ jsxs("div", { className: "pt-1", children: [
|
|
26067
26092
|
/* @__PURE__ */ jsx("p", { className: "mb-2 text-xs font-medium text-[#1F2430]", children: "Select a preferred network" }),
|
|
26068
26093
|
/* @__PURE__ */ jsx("div", { className: "relative mb-2", children: /* @__PURE__ */ jsx(
|
|
@@ -26956,4 +26981,4 @@ export {
|
|
|
26956
26981
|
isFeatureEnabled as i,
|
|
26957
26982
|
logo as l
|
|
26958
26983
|
};
|
|
26959
|
-
//# sourceMappingURL=CoinleyPayment-
|
|
26984
|
+
//# sourceMappingURL=CoinleyPayment-DWGoIei3.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-DWGoIei3.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-CH55u3Is.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-DWGoIei3.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-jtnvPa0Y.js.map
|