coinley-pay 0.23.0 → 0.24.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-Cl3PzsxC.js → CoinleyPayment-BNHoVBKU.js} +85 -21
- package/dist/{appKitEVM-BDZw0_fy.js → appKitEVM-BeGg9nUC.js} +2 -2
- package/dist/{appKitSolana-CKJ3gWw5.js → appKitSolana-C2Tow7WJ.js} +2 -2
- package/dist/coinley-vanilla.min.js +576 -576
- package/dist/{index-BElt06nj.js → index-B7tIc4VN.js} +3 -3
- package/dist/{index-OSKXr_YB.js → index-BuM1IGbr.js} +3 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +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-BuM1IGbr.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";
|
|
@@ -21120,7 +21120,7 @@ const WalletSelector = ({
|
|
|
21120
21120
|
try {
|
|
21121
21121
|
setAppKitError(null);
|
|
21122
21122
|
setWalletConnectAddress(solanaAccountState.address);
|
|
21123
|
-
const { createWalletConnectAdapter } = await import("./appKitSolana-
|
|
21123
|
+
const { createWalletConnectAdapter } = await import("./appKitSolana-C2Tow7WJ.js");
|
|
21124
21124
|
const adapter = createWalletConnectAdapter(solanaAccountState.address);
|
|
21125
21125
|
await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
|
|
21126
21126
|
console.log("✅ WalletConnect synced with SDK");
|
|
@@ -21225,7 +21225,7 @@ const WalletSelector = ({
|
|
|
21225
21225
|
setAppKitLoading(true);
|
|
21226
21226
|
setAppKitError(null);
|
|
21227
21227
|
try {
|
|
21228
|
-
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-
|
|
21228
|
+
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-BeGg9nUC.js");
|
|
21229
21229
|
await initializeAppKitEVM(wagmiConfig);
|
|
21230
21230
|
await openAppKitModal();
|
|
21231
21231
|
} catch (error) {
|
|
@@ -21245,7 +21245,7 @@ const WalletSelector = ({
|
|
|
21245
21245
|
setAppKitError(null);
|
|
21246
21246
|
try {
|
|
21247
21247
|
console.log("📦 Loading AppKit Solana module...");
|
|
21248
|
-
const { initializeAppKitSolana } = await import("./appKitSolana-
|
|
21248
|
+
const { initializeAppKitSolana } = await import("./appKitSolana-C2Tow7WJ.js");
|
|
21249
21249
|
console.log("✅ Module loaded, initializing...");
|
|
21250
21250
|
const modal = await initializeAppKitSolana(solanaWallet);
|
|
21251
21251
|
console.log("✅ AppKit Solana initialized successfully");
|
|
@@ -24608,6 +24608,56 @@ const CoinleyPaymentInternal = ({
|
|
|
24608
24608
|
}
|
|
24609
24609
|
})();
|
|
24610
24610
|
}, [paymentData == null ? void 0 : paymentData.depositAddress]);
|
|
24611
|
+
const getBridgeQuoteForDepositExecution = async (activePaymentData) => {
|
|
24612
|
+
if (!isSwapOrBridgeFlow || !(activePaymentData == null ? void 0 : activePaymentData.depositAddress)) {
|
|
24613
|
+
return relayBridge.bridgeQuote;
|
|
24614
|
+
}
|
|
24615
|
+
const currentQuote = relayBridge.bridgeQuote;
|
|
24616
|
+
if (!currentQuote) {
|
|
24617
|
+
throw new Error("Bridge route unavailable. Please try again.");
|
|
24618
|
+
}
|
|
24619
|
+
const expectedDepositAddress = normalizeEvmAddress(activePaymentData.depositAddress);
|
|
24620
|
+
const quoteRecipient = normalizeEvmAddress(currentQuote.requestedRecipient);
|
|
24621
|
+
const quoteEffectiveRecipient = normalizeEvmAddress(currentQuote.effectiveRecipient);
|
|
24622
|
+
if (expectedDepositAddress && quoteRecipient === expectedDepositAddress && (!quoteEffectiveRecipient || quoteEffectiveRecipient === expectedDepositAddress)) {
|
|
24623
|
+
return currentQuote;
|
|
24624
|
+
}
|
|
24625
|
+
const activeAttempt = activeAttemptRef.current;
|
|
24626
|
+
if (!activeAttempt) {
|
|
24627
|
+
throw new Error(STALE_ATTEMPT_MESSAGE);
|
|
24628
|
+
}
|
|
24629
|
+
const amount = paymentAmount || parseFloat(config == null ? void 0 : config.amount) || 0;
|
|
24630
|
+
if (amount <= 0) {
|
|
24631
|
+
throw new Error("Invalid payment amount. Please refresh and try again.");
|
|
24632
|
+
}
|
|
24633
|
+
console.log("[Swap] Awaiting deposit-recipient quote before execution:", {
|
|
24634
|
+
paymentId: activePaymentData.id,
|
|
24635
|
+
depositAddress: activePaymentData.depositAddress,
|
|
24636
|
+
currentRecipient: currentQuote.requestedRecipient,
|
|
24637
|
+
attemptId: activeAttempt.id
|
|
24638
|
+
});
|
|
24639
|
+
const reQuoteUser = currentQuote.originChainId === RELAY_SOLANA_CHAIN_ID ? solanaWallet == null ? void 0 : solanaWallet.publicKey : void 0;
|
|
24640
|
+
const quote = await relayBridge.getBridgeQuote(
|
|
24641
|
+
currentQuote.originChainId,
|
|
24642
|
+
currentQuote.destChainId,
|
|
24643
|
+
currentQuote.originTokenAddress,
|
|
24644
|
+
currentQuote.originTokenSymbol,
|
|
24645
|
+
selectedToken.decimals || 18,
|
|
24646
|
+
currentQuote.destTokenAddress,
|
|
24647
|
+
currentQuote.destTokenSymbol,
|
|
24648
|
+
amount.toString(),
|
|
24649
|
+
activePaymentData.depositAddress,
|
|
24650
|
+
null,
|
|
24651
|
+
null,
|
|
24652
|
+
reQuoteUser,
|
|
24653
|
+
void 0,
|
|
24654
|
+
buildAttemptMeta(activeAttempt)
|
|
24655
|
+
);
|
|
24656
|
+
if (!quote) {
|
|
24657
|
+
throw new Error("Bridge route unavailable for this deposit address. Please try another network or token.");
|
|
24658
|
+
}
|
|
24659
|
+
return quote;
|
|
24660
|
+
};
|
|
24611
24661
|
useEffect(() => {
|
|
24612
24662
|
const amount = paymentAmount || parseFloat(config == null ? void 0 : config.amount) || 0;
|
|
24613
24663
|
if (connectedWalletType === "solana" && (solanaWallet == null ? void 0 : solanaWallet.publicKey) && (selectedNetwork == null ? void 0 : selectedNetwork.shortName) === "solana") {
|
|
@@ -24857,12 +24907,26 @@ const CoinleyPaymentInternal = ({
|
|
|
24857
24907
|
setError("Payment could not be prepared. Please try again.");
|
|
24858
24908
|
return;
|
|
24859
24909
|
}
|
|
24910
|
+
let bridgeQuoteForExecution = null;
|
|
24911
|
+
if (isSwapOrBridgeFlow && (effectivePaymentData == null ? void 0 : effectivePaymentData.depositAddress)) {
|
|
24912
|
+
try {
|
|
24913
|
+
bridgeQuoteForExecution = await getBridgeQuoteForDepositExecution(effectivePaymentData);
|
|
24914
|
+
} catch (e) {
|
|
24915
|
+
if ((e == null ? void 0 : e.message) === STALE_ATTEMPT_MESSAGE) {
|
|
24916
|
+
setError(STALE_ATTEMPT_MESSAGE);
|
|
24917
|
+
} else {
|
|
24918
|
+
setError((e == null ? void 0 : e.message) || "Payment quote is not ready. Please try again.");
|
|
24919
|
+
}
|
|
24920
|
+
return;
|
|
24921
|
+
}
|
|
24922
|
+
}
|
|
24860
24923
|
setShowWalletConfirm(false);
|
|
24861
|
-
await executePayment(effectivePaymentData);
|
|
24924
|
+
await executePayment(effectivePaymentData, bridgeQuoteForExecution);
|
|
24862
24925
|
};
|
|
24863
|
-
const executePayment = async (paymentOverride = null) => {
|
|
24864
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
24926
|
+
const executePayment = async (paymentOverride = null, bridgeQuoteOverride = null) => {
|
|
24927
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
24865
24928
|
const activePaymentData = paymentOverride || paymentData;
|
|
24929
|
+
const activeBridgeQuote = bridgeQuoteOverride || relayBridge.bridgeQuote;
|
|
24866
24930
|
if (!(activePaymentData == null ? void 0 : activePaymentData.id)) {
|
|
24867
24931
|
setError("Payment could not be prepared. Please try again.");
|
|
24868
24932
|
return;
|
|
@@ -24906,7 +24970,7 @@ const CoinleyPaymentInternal = ({
|
|
|
24906
24970
|
setError(STALE_ATTEMPT_MESSAGE);
|
|
24907
24971
|
return;
|
|
24908
24972
|
}
|
|
24909
|
-
const quoteAttemptId = (
|
|
24973
|
+
const quoteAttemptId = (activeBridgeQuote == null ? void 0 : activeBridgeQuote.attemptId) ?? null;
|
|
24910
24974
|
if (quoteAttemptId && quoteAttemptId !== activeAttempt.id) {
|
|
24911
24975
|
console.warn("[Attempt] executePayment blocked — bridgeQuote attempt mismatch", {
|
|
24912
24976
|
quoteAttemptId,
|
|
@@ -24919,7 +24983,7 @@ const CoinleyPaymentInternal = ({
|
|
|
24919
24983
|
console.log("[Attempt] executePayment proceeding", {
|
|
24920
24984
|
attemptId: activeAttempt.id,
|
|
24921
24985
|
hasPaymentData: !!activePaymentData,
|
|
24922
|
-
hasQuote: !!
|
|
24986
|
+
hasQuote: !!activeBridgeQuote
|
|
24923
24987
|
});
|
|
24924
24988
|
}
|
|
24925
24989
|
if (isSolana) {
|
|
@@ -24945,11 +25009,11 @@ const CoinleyPaymentInternal = ({
|
|
|
24945
25009
|
const amount = paymentAmount || parseFloat(config == null ? void 0 : config.amount) || 0;
|
|
24946
25010
|
const SOL_MINT = "So11111111111111111111111111111111111111112";
|
|
24947
25011
|
const tokenMint = selectedToken == null ? void 0 : selectedToken.contractAddress;
|
|
24948
|
-
const isNativeSOL = tokenMint === "native" || ((
|
|
25012
|
+
const isNativeSOL = tokenMint === "native" || ((_a2 = selectedToken == null ? void 0 : selectedToken.symbol) == null ? void 0 : _a2.toUpperCase()) === "SOL";
|
|
24949
25013
|
let quote = relayBridge.bridgeQuote;
|
|
24950
25014
|
if (!quote) {
|
|
24951
25015
|
console.log("[Solana Bridge] No quote cached — fetching fresh quote...");
|
|
24952
|
-
const originTokenAddress = isNativeSOL ? SOLANA_TOKEN_ADDRESSES.SOL : SOLANA_TOKEN_ADDRESSES[(
|
|
25016
|
+
const originTokenAddress = isNativeSOL ? SOLANA_TOKEN_ADDRESSES.SOL : SOLANA_TOKEN_ADDRESSES[(_b = selectedToken == null ? void 0 : selectedToken.symbol) == null ? void 0 : _b.toUpperCase()] || tokenMint;
|
|
24953
25017
|
quote = await relayBridge.getBridgeQuote(
|
|
24954
25018
|
RELAY_SOLANA_CHAIN_ID,
|
|
24955
25019
|
destChainId,
|
|
@@ -24986,7 +25050,7 @@ const CoinleyPaymentInternal = ({
|
|
|
24986
25050
|
if (!solQuote) {
|
|
24987
25051
|
throw new Error("Unable to find a bridge route. Try paying with SOL, USDC, or USDT.");
|
|
24988
25052
|
}
|
|
24989
|
-
const solNeededLamports = BigInt(((
|
|
25053
|
+
const solNeededLamports = BigInt(((_e = (_d = (_c = solQuote.raw) == null ? void 0 : _c.details) == null ? void 0 : _d.currencyIn) == null ? void 0 : _e.amount) || "0");
|
|
24990
25054
|
const solWithBuffer = solNeededLamports * 105n / 100n;
|
|
24991
25055
|
const solAmount = Number(solWithBuffer) / 1e9;
|
|
24992
25056
|
console.log(`[Solana Bridge] Need ~${solAmount.toFixed(6)} SOL for bridge`);
|
|
@@ -25028,8 +25092,8 @@ const CoinleyPaymentInternal = ({
|
|
|
25028
25092
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
25029
25093
|
try {
|
|
25030
25094
|
const status = await paymentFlow.api.getDepositStatus(activePaymentData.id);
|
|
25031
|
-
console.log(`[Solana Bridge] Deposit check ${attempt + 1}/${maxAttempts}:`, (
|
|
25032
|
-
if (((
|
|
25095
|
+
console.log(`[Solana Bridge] Deposit check ${attempt + 1}/${maxAttempts}:`, (_f = status == null ? void 0 : status.payment) == null ? void 0 : _f.status);
|
|
25096
|
+
if (((_g = status == null ? void 0 : status.payment) == null ? void 0 : _g.detectedAt) || ((_h = status == null ? void 0 : status.payment) == null ? void 0 : _h.status) === "completed" || ((_i = status == null ? void 0 : status.payment) == null ? void 0 : _i.status) === "swept") {
|
|
25033
25097
|
detected = true;
|
|
25034
25098
|
console.log("[Solana Bridge] Deposit detected on destination chain!");
|
|
25035
25099
|
break;
|
|
@@ -25152,7 +25216,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25152
25216
|
if (!(activePaymentData == null ? void 0 : activePaymentData.depositAddress)) {
|
|
25153
25217
|
throw new Error("Payment is missing a deposit address. Please refresh and try again.");
|
|
25154
25218
|
}
|
|
25155
|
-
if (!
|
|
25219
|
+
if (!activeBridgeQuote) {
|
|
25156
25220
|
throw new Error(
|
|
25157
25221
|
`Bridge route unavailable for ${selectedToken.symbol} on ${selectedNetwork.name}. Please try a different token or network.`
|
|
25158
25222
|
);
|
|
@@ -25162,8 +25226,8 @@ const CoinleyPaymentInternal = ({
|
|
|
25162
25226
|
const { getWalletClient: getWalletClient2 } = await import("@wagmi/core");
|
|
25163
25227
|
const targetChainId = parseInt(selectedNetwork.chainId);
|
|
25164
25228
|
const expectedDepositAddress = normalizeEvmAddress(activePaymentData.depositAddress);
|
|
25165
|
-
const quoteRequestedRecipient = normalizeEvmAddress(
|
|
25166
|
-
const quoteEffectiveRecipient = normalizeEvmAddress(
|
|
25229
|
+
const quoteRequestedRecipient = normalizeEvmAddress(activeBridgeQuote == null ? void 0 : activeBridgeQuote.requestedRecipient);
|
|
25230
|
+
const quoteEffectiveRecipient = normalizeEvmAddress(activeBridgeQuote == null ? void 0 : activeBridgeQuote.effectiveRecipient);
|
|
25167
25231
|
console.log(`[${action}] validating deposit recipient`, {
|
|
25168
25232
|
expectedDepositAddress,
|
|
25169
25233
|
quoteRequestedRecipient,
|
|
@@ -25188,10 +25252,10 @@ const CoinleyPaymentInternal = ({
|
|
|
25188
25252
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
25189
25253
|
try {
|
|
25190
25254
|
walletClient = await getWalletClient2(wagmiConfig, { chainId: targetChainId });
|
|
25191
|
-
console.log(`[${action}] connector confirmed: chain=${(
|
|
25255
|
+
console.log(`[${action}] connector confirmed: chain=${(_j = walletClient.chain) == null ? void 0 : _j.id} | attempts=${attempt + 1}`);
|
|
25192
25256
|
break;
|
|
25193
25257
|
} catch (e) {
|
|
25194
|
-
if (((
|
|
25258
|
+
if (((_k = e.message) == null ? void 0 : _k.includes("does not match")) && attempt < maxAttempts - 1) {
|
|
25195
25259
|
console.log(`[${action}] connector still settling, attempt ${attempt + 1}: ${e.message}`);
|
|
25196
25260
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
25197
25261
|
continue;
|
|
@@ -25208,7 +25272,7 @@ const CoinleyPaymentInternal = ({
|
|
|
25208
25272
|
}
|
|
25209
25273
|
const result = await executeSwapToDeposit(
|
|
25210
25274
|
relayBridge,
|
|
25211
|
-
|
|
25275
|
+
activeBridgeQuote,
|
|
25212
25276
|
walletClient,
|
|
25213
25277
|
(step, message) => {
|
|
25214
25278
|
console.log(`[${action}] ${step}: ${message}`);
|
|
@@ -26704,4 +26768,4 @@ export {
|
|
|
26704
26768
|
isFeatureEnabled as i,
|
|
26705
26769
|
logo as l
|
|
26706
26770
|
};
|
|
26707
|
-
//# sourceMappingURL=CoinleyPayment-
|
|
26771
|
+
//# sourceMappingURL=CoinleyPayment-BNHoVBKU.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-BNHoVBKU.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-BeGg9nUC.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-BNHoVBKU.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-C2Tow7WJ.js.map
|