@cedros/pay-react 1.1.15 → 1.1.17
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/AISettingsSection--jn-BNmd.mjs +539 -0
- package/dist/AISettingsSection-BrXUD4l_.js +51 -0
- package/dist/AutosaveIndicator-B3T328jH.mjs +35 -0
- package/dist/AutosaveIndicator-BQkm3cn8.js +1 -0
- package/dist/{CedrosContext-D7nh5-Zh.mjs → CedrosContext-BnJ2Cf7R.mjs} +1179 -642
- package/dist/CedrosContext-C26DlvLF.js +6 -0
- package/dist/CryptoButton-B4-oJ8lF.js +1 -0
- package/dist/CryptoButton-Dhxnk9d7.mjs +542 -0
- package/dist/FAQSection-BB1wJRsR.mjs +366 -0
- package/dist/FAQSection-aoAz35MV.js +1 -0
- package/dist/MessagingSection-BG9O62ko.mjs +347 -0
- package/dist/MessagingSection-DId-WJdU.js +1 -0
- package/dist/PaymentSettingsSection-D92IO4xJ.js +1 -0
- package/dist/PaymentSettingsSection-c13RAUxn.mjs +94 -0
- package/dist/SettingsSection-DUxjXl2G.js +1 -0
- package/dist/SettingsSection-htem-WL3.mjs +57 -0
- package/dist/SingleCategorySettings-BIEs6s6Z.mjs +1421 -0
- package/dist/SingleCategorySettings-CQ-osdzb.js +3 -0
- package/dist/StorefrontSection-CKTQt255.mjs +765 -0
- package/dist/StorefrontSection-DcSoDx-k.js +1 -0
- package/dist/SubscriptionsSection-C0hYf7Hr.js +1 -0
- package/dist/SubscriptionsSection-CONwHhT4.mjs +616 -0
- package/dist/Toggle-CsPSF8Dr.js +1 -0
- package/dist/Toggle-DAxIdpY4.mjs +48 -0
- package/dist/WalletManager-D6BYTwXn.js +1 -0
- package/dist/{WalletManager-oEjZhaFk.mjs → WalletManager-HXXyARQ7.mjs} +36 -32
- package/dist/components/CedrosPay.d.ts.map +1 -1
- package/dist/components/CryptoSubscribeButton.d.ts.map +1 -1
- package/dist/components/PaymentModal.d.ts.map +1 -1
- package/dist/components/SubscriptionManagementPanel.d.ts.map +1 -1
- package/dist/components/admin/AISettingsSection.d.ts.map +1 -1
- package/dist/components/admin/AdminAuthManager.d.ts +2 -1
- package/dist/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/components/admin/AutosaveIndicator.d.ts +7 -0
- package/dist/components/admin/AutosaveIndicator.d.ts.map +1 -0
- package/dist/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/components/admin/ConfigEditor.d.ts +0 -2
- package/dist/components/admin/ConfigEditor.d.ts.map +1 -1
- package/dist/components/admin/MessagingSection.d.ts.map +1 -1
- package/dist/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/components/admin/SecretArrayEditor.d.ts +16 -0
- package/dist/components/admin/SecretArrayEditor.d.ts.map +1 -0
- package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -1
- package/dist/components/admin/StorefrontSection.d.ts.map +1 -1
- package/dist/components/admin/Toggle.d.ts +14 -0
- package/dist/components/admin/Toggle.d.ts.map +1 -0
- package/dist/components/admin/TokenMintSelector.d.ts +27 -0
- package/dist/components/admin/TokenMintSelector.d.ts.map +1 -0
- package/dist/components/admin/configApi.d.ts +5 -3
- package/dist/components/admin/configApi.d.ts.map +1 -1
- package/dist/components/admin/index.d.ts +8 -9
- package/dist/components/admin/index.d.ts.map +1 -1
- package/dist/components/admin/sections-more.d.ts +2 -9
- package/dist/components/admin/sections-more.d.ts.map +1 -1
- package/dist/context/CedrosContext.d.ts +1 -1
- package/dist/context/CedrosContext.d.ts.map +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +391 -380
- package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/storage.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/storage.test.d.ts.map +1 -0
- package/dist/ecommerce/adapters/CommerceAdapter.d.ts +5 -0
- package/dist/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts +2 -0
- package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/ProductCard.d.ts.map +1 -1
- package/dist/ecommerce/components/catalog/QuickViewDialog.d.ts.map +1 -1
- package/dist/ecommerce/components/chat/ShopChatPanel.d.ts +4 -0
- package/dist/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
- package/dist/ecommerce/components/checkout/PaymentStep.d.ts.map +1 -1
- package/dist/ecommerce/components/faq/FAQItem.d.ts.map +1 -1
- package/dist/ecommerce/config/context.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useAIRelatedProducts.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useHoldExpiry.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useInventoryVerification.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useProducts.d.ts.map +1 -1
- package/dist/ecommerce/index.d.ts +2 -0
- package/dist/ecommerce/index.d.ts.map +1 -1
- package/dist/ecommerce/integrations/cedros-pay/useCedrosPayCheckoutAdapter.d.ts.map +1 -1
- package/dist/ecommerce/state/cart/CartProvider.d.ts.map +1 -1
- package/dist/ecommerce/state/checkout/checkoutSchema.d.ts +1 -1
- package/dist/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/ecommerce/templates/ProductTemplate.d.ts.map +1 -1
- package/dist/ecommerce/utils/storage.d.ts +1 -1
- package/dist/ecommerce/utils/storage.d.ts.map +1 -1
- package/dist/hooks/useCreditsPayment.d.ts.map +1 -1
- package/dist/hooks/useCreditsSubscription.d.ts.map +1 -1
- package/dist/hooks/useCryptoSubscription.d.ts.map +1 -1
- package/dist/hooks/useRefundVerification.d.ts.map +1 -1
- package/dist/hooks/useStripeCheckout.d.ts +1 -1
- package/dist/hooks/useStripeCheckout.d.ts.map +1 -1
- package/dist/hooks/useSubscription.d.ts.map +1 -1
- package/dist/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/hooks/useX402Payment.d.ts.map +1 -1
- package/dist/index-2N_CMVAv.js +84 -0
- package/dist/index-C1hbnxn0.mjs +22915 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +67 -72
- package/dist/managers/CreditsManager.d.ts +6 -0
- package/dist/managers/CreditsManager.d.ts.map +1 -1
- package/dist/managers/ManagerCache.d.ts.map +1 -1
- package/dist/managers/RouteDiscoveryManager.d.ts +3 -0
- package/dist/managers/RouteDiscoveryManager.d.ts.map +1 -1
- package/dist/managers/StripeManager.d.ts +15 -0
- package/dist/managers/StripeManager.d.ts.map +1 -1
- package/dist/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/managers/SubscriptionManager.d.ts +7 -14
- package/dist/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/managers/WalletManager.d.ts +2 -1
- package/dist/managers/WalletManager.d.ts.map +1 -1
- package/dist/managers/X402Manager.d.ts.map +1 -1
- package/dist/{sections-DG4Ws13b.js → sections-D2GMJuKq.js} +1 -1
- package/dist/{sections-Dl8qjlql.mjs → sections-DICaHGhz.mjs} +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +67 -72
- package/dist/telemetry.js +1 -1
- package/dist/telemetry.mjs +23 -25
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/types/index.d.ts +13 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/useAutosave-B2p6iwh8.js +1 -0
- package/dist/useAutosave-YwMqRzqy.mjs +44 -0
- package/dist/utils/circuitBreaker.d.ts +3 -1
- package/dist/utils/circuitBreaker.d.ts.map +1 -1
- package/dist/utils/cspHelper.d.ts +6 -0
- package/dist/utils/cspHelper.d.ts.map +1 -1
- package/dist/utils/csvHelpers.d.ts +0 -41
- package/dist/utils/csvHelpers.d.ts.map +1 -1
- package/dist/utils/errorHandling.d.ts.map +1 -1
- package/dist/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/utils/requestDeduplication.d.ts.map +1 -1
- package/dist/utils/telemetry.d.ts.map +1 -1
- package/dist/utils/validateConfig.d.ts +1 -1
- package/dist/utils/validateConfig.d.ts.map +1 -1
- package/dist/walletDetection-JZR3UCOa.mjs +27 -0
- package/dist/walletDetection-bNmV5ItZ.js +1 -0
- package/dist/{walletPool-BR6etEiq.mjs → walletPool-BV_z1lEA.mjs} +1 -1
- package/dist/{walletPool-BZyAG4YS.js → walletPool-DjA7J3a9.js} +1 -1
- package/package.json +8 -7
- package/dist/CedrosContext-C2v_s8cc.js +0 -6
- package/dist/WalletManager-B5KLZK2D.js +0 -1
- package/dist/index-BjxGupjw.mjs +0 -27893
- package/dist/index-DW6XWuRP.js +0 -136
package/dist/crypto-only.mjs
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { x as Ue, w as Ve, C as Ye, a as He, b as Je, h as Xe,
|
|
1
|
+
import { T as Te, E as ve, F as fe, A as Be, D as me, y as Ie, z as ye, B as Y, a5 as We, a6 as qe } from "./index-C1hbnxn0.mjs";
|
|
2
|
+
import { x as Ue, w as Ve, C as Ye, a as He, b as Je, h as Xe, f as Ze, d as et, e as tt, P as rt, R as nt, K as at, S as st, g as ot, i as it, q as ct, c as lt, O as ut, L as dt, V as pt, v as ft, o as mt, r as yt, t as gt, N as bt, Q as wt, H as St, G as ht, M as Ct, J as xt, p as Pt, s as Et, j as Rt, m as kt, U as Tt, k as vt, u as Bt, l as It, n as Wt, I as qt } from "./index-C1hbnxn0.mjs";
|
|
3
|
+
import { u as H, m as K, a as _e, i as y } from "./CedrosContext-BnJ2Cf7R.mjs";
|
|
4
|
+
import { f as Mt, C as Lt, e as At, d as Nt, E as Dt, K as zt, L as Kt, h as Ot, R as Qt, g as $t, b as Ft, j as Gt, c as jt, r as Ut, v as Vt, n as Yt } from "./CedrosContext-BnJ2Cf7R.mjs";
|
|
5
|
+
import { C as Jt, u as Xt } from "./CryptoButton-Dhxnk9d7.mjs";
|
|
3
6
|
import { jsxs as O, jsx as x } from "react/jsx-runtime";
|
|
4
|
-
import { useState as B,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "@solana/
|
|
8
|
-
import "./
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { WalletIcon as qe } from "@solana/wallet-adapter-react-ui";
|
|
12
|
-
import { WalletPool as Zt, createWalletPool as er } from "./walletPool-BR6etEiq.mjs";
|
|
13
|
-
function _e() {
|
|
14
|
-
const { subscriptionManager: r, x402Manager: c, walletManager: m } = Y(), { publicKey: o, signTransaction: k } = H(), [g, d] = B({
|
|
7
|
+
import { useState as B, useRef as z, useCallback as h, useMemo as G, useEffect as Q } from "react";
|
|
8
|
+
import { useWallet as J } from "@solana/wallet-adapter-react";
|
|
9
|
+
import { WalletReadyState as ge } from "@solana/wallet-adapter-base";
|
|
10
|
+
import { WalletIcon as Me } from "@solana/wallet-adapter-react-ui";
|
|
11
|
+
import { WalletPool as er, createWalletPool as tr } from "./walletPool-BV_z1lEA.mjs";
|
|
12
|
+
function Le() {
|
|
13
|
+
const { subscriptionManager: r, x402Manager: c, walletManager: f } = H(), { publicKey: i, signTransaction: R } = J(), [w, p] = B({
|
|
15
14
|
status: "idle",
|
|
16
15
|
error: null,
|
|
17
16
|
sessionId: null,
|
|
18
17
|
subscriptionStatus: null,
|
|
19
18
|
expiresAt: null
|
|
20
|
-
}), [
|
|
21
|
-
if (!
|
|
19
|
+
}), [k, P] = B(null), E = z(!1), C = h(() => {
|
|
20
|
+
if (!i) {
|
|
22
21
|
const s = "Wallet not connected";
|
|
23
|
-
return
|
|
22
|
+
return p((t) => ({ ...t, status: "error", error: s })), { valid: !1, error: s };
|
|
24
23
|
}
|
|
25
|
-
if (!
|
|
24
|
+
if (!R) {
|
|
26
25
|
const s = "Wallet does not support signing";
|
|
27
|
-
return
|
|
26
|
+
return p((t) => ({ ...t, status: "error", error: s })), { valid: !1, error: s };
|
|
28
27
|
}
|
|
29
28
|
return { valid: !0 };
|
|
30
|
-
}, [
|
|
29
|
+
}, [i, R]), T = h(
|
|
31
30
|
async (s) => {
|
|
32
|
-
if (!
|
|
33
|
-
return
|
|
31
|
+
if (!i)
|
|
32
|
+
return p((t) => ({
|
|
34
33
|
...t,
|
|
35
34
|
status: "error",
|
|
36
35
|
error: "Wallet not connected"
|
|
37
36
|
})), null;
|
|
38
|
-
|
|
37
|
+
p((t) => ({
|
|
39
38
|
...t,
|
|
40
39
|
status: "checking",
|
|
41
40
|
error: null
|
|
@@ -43,333 +42,335 @@ function _e() {
|
|
|
43
42
|
try {
|
|
44
43
|
const t = await r.checkSubscriptionStatus({
|
|
45
44
|
resource: s,
|
|
46
|
-
userId:
|
|
45
|
+
userId: i.toString()
|
|
47
46
|
});
|
|
48
|
-
return
|
|
49
|
-
...
|
|
47
|
+
return p((n) => ({
|
|
48
|
+
...n,
|
|
50
49
|
status: t.active ? "success" : "idle",
|
|
51
50
|
subscriptionStatus: t.status,
|
|
52
51
|
expiresAt: t.expiresAt || t.currentPeriodEnd || null
|
|
53
52
|
})), t;
|
|
54
53
|
} catch (t) {
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
...
|
|
54
|
+
const n = K(t, "Failed to check subscription status");
|
|
55
|
+
return p((l) => ({
|
|
56
|
+
...l,
|
|
58
57
|
status: "error",
|
|
59
|
-
error:
|
|
58
|
+
error: n
|
|
60
59
|
})), null;
|
|
61
60
|
}
|
|
62
61
|
},
|
|
63
|
-
[
|
|
64
|
-
),
|
|
65
|
-
async (s, t,
|
|
66
|
-
|
|
67
|
-
...
|
|
62
|
+
[i, r]
|
|
63
|
+
), q = h(
|
|
64
|
+
async (s, t, n) => {
|
|
65
|
+
p((l) => ({
|
|
66
|
+
...l,
|
|
68
67
|
status: "loading",
|
|
69
68
|
error: null
|
|
70
69
|
}));
|
|
71
70
|
try {
|
|
72
|
-
const
|
|
71
|
+
const l = await r.requestSubscriptionQuote(
|
|
73
72
|
s,
|
|
74
73
|
t,
|
|
75
|
-
|
|
74
|
+
n
|
|
76
75
|
);
|
|
77
|
-
return
|
|
78
|
-
...
|
|
76
|
+
return P(l), p((a) => ({
|
|
77
|
+
...a,
|
|
79
78
|
status: "idle"
|
|
80
|
-
})),
|
|
81
|
-
} catch (
|
|
82
|
-
const
|
|
83
|
-
return
|
|
84
|
-
...
|
|
79
|
+
})), l;
|
|
80
|
+
} catch (l) {
|
|
81
|
+
const a = K(l, "Failed to get subscription quote");
|
|
82
|
+
return p((o) => ({
|
|
83
|
+
...o,
|
|
85
84
|
status: "error",
|
|
86
|
-
error:
|
|
85
|
+
error: a
|
|
87
86
|
})), null;
|
|
88
87
|
}
|
|
89
88
|
},
|
|
90
89
|
[r]
|
|
91
|
-
),
|
|
92
|
-
async (s, t,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
), g = h(
|
|
91
|
+
async (s, t, n) => {
|
|
92
|
+
if (E.current)
|
|
93
|
+
return { success: !1, error: "Payment already in progress" };
|
|
94
|
+
const l = C();
|
|
95
|
+
if (!l.valid)
|
|
96
|
+
return { success: !1, error: l.error };
|
|
97
|
+
E.current = !0, p((a) => ({
|
|
98
|
+
...a,
|
|
98
99
|
status: "loading",
|
|
99
100
|
error: null
|
|
100
101
|
}));
|
|
101
102
|
try {
|
|
102
|
-
const
|
|
103
|
+
const a = await r.requestSubscriptionQuote(
|
|
103
104
|
s,
|
|
104
105
|
t,
|
|
105
|
-
|
|
106
|
+
n
|
|
106
107
|
);
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
if (!c.validateRequirement(
|
|
108
|
+
P(a);
|
|
109
|
+
const o = a.requirement;
|
|
110
|
+
if (!c.validateRequirement(o))
|
|
110
111
|
throw new Error("Invalid subscription quote received from server");
|
|
111
|
-
const
|
|
112
|
-
let
|
|
113
|
-
if (
|
|
114
|
-
const { transaction:
|
|
112
|
+
const b = !!o.extra?.feePayer;
|
|
113
|
+
let m;
|
|
114
|
+
if (b) {
|
|
115
|
+
const { transaction: S, blockhash: _ } = await c.buildGaslessTransaction({
|
|
115
116
|
resourceId: s,
|
|
116
|
-
userWallet:
|
|
117
|
-
feePayer:
|
|
118
|
-
couponCode:
|
|
119
|
-
}),
|
|
120
|
-
transaction:
|
|
121
|
-
signTransaction:
|
|
122
|
-
blockhash:
|
|
117
|
+
userWallet: i.toString(),
|
|
118
|
+
feePayer: o.extra.feePayer,
|
|
119
|
+
couponCode: n?.couponCode
|
|
120
|
+
}), M = f.deserializeTransaction(S), L = await f.partiallySignTransaction({
|
|
121
|
+
transaction: M,
|
|
122
|
+
signTransaction: R,
|
|
123
|
+
blockhash: _
|
|
123
124
|
});
|
|
124
|
-
|
|
125
|
+
m = await c.submitGaslessTransaction({
|
|
125
126
|
resource: s,
|
|
126
|
-
partialTx:
|
|
127
|
-
couponCode:
|
|
127
|
+
partialTx: L,
|
|
128
|
+
couponCode: n?.couponCode,
|
|
128
129
|
resourceType: "regular",
|
|
129
|
-
requirement:
|
|
130
|
+
requirement: o
|
|
130
131
|
});
|
|
131
132
|
} else {
|
|
132
|
-
const
|
|
133
|
-
requirement:
|
|
134
|
-
payerPublicKey:
|
|
135
|
-
}),
|
|
136
|
-
transaction:
|
|
137
|
-
signTransaction:
|
|
138
|
-
}),
|
|
139
|
-
requirement:
|
|
140
|
-
signedTx:
|
|
141
|
-
payerPublicKey:
|
|
133
|
+
const S = await f.buildTransaction({
|
|
134
|
+
requirement: o,
|
|
135
|
+
payerPublicKey: i
|
|
136
|
+
}), _ = await f.signTransaction({
|
|
137
|
+
transaction: S,
|
|
138
|
+
signTransaction: R
|
|
139
|
+
}), M = f.buildPaymentPayload({
|
|
140
|
+
requirement: o,
|
|
141
|
+
signedTx: _,
|
|
142
|
+
payerPublicKey: i
|
|
142
143
|
});
|
|
143
|
-
|
|
144
|
+
m = await c.submitPayment({
|
|
144
145
|
resource: s,
|
|
145
|
-
payload:
|
|
146
|
-
couponCode:
|
|
146
|
+
payload: M,
|
|
147
|
+
couponCode: n?.couponCode,
|
|
147
148
|
resourceType: "regular"
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
|
-
if (
|
|
151
|
-
const
|
|
151
|
+
if (m.success) {
|
|
152
|
+
const S = await r.checkSubscriptionStatus({
|
|
152
153
|
resource: s,
|
|
153
|
-
userId:
|
|
154
|
+
userId: i.toString()
|
|
154
155
|
});
|
|
155
|
-
|
|
156
|
+
p({
|
|
156
157
|
status: "success",
|
|
157
158
|
error: null,
|
|
158
|
-
sessionId:
|
|
159
|
-
subscriptionStatus:
|
|
160
|
-
expiresAt:
|
|
159
|
+
sessionId: m.transactionId || null,
|
|
160
|
+
subscriptionStatus: S.status,
|
|
161
|
+
expiresAt: S.expiresAt || S.currentPeriodEnd || null
|
|
161
162
|
});
|
|
162
163
|
} else
|
|
163
|
-
|
|
164
|
-
...
|
|
164
|
+
p((S) => ({
|
|
165
|
+
...S,
|
|
165
166
|
status: "error",
|
|
166
|
-
error:
|
|
167
|
+
error: m.error || "Subscription payment failed"
|
|
167
168
|
}));
|
|
168
|
-
return
|
|
169
|
-
} catch (
|
|
170
|
-
const
|
|
171
|
-
return
|
|
172
|
-
...
|
|
169
|
+
return m;
|
|
170
|
+
} catch (a) {
|
|
171
|
+
const o = K(a, "Subscription payment failed");
|
|
172
|
+
return p((b) => ({
|
|
173
|
+
...b,
|
|
173
174
|
status: "error",
|
|
174
|
-
error:
|
|
175
|
-
})), { success: !1, error:
|
|
175
|
+
error: o
|
|
176
|
+
})), { success: !1, error: o };
|
|
177
|
+
} finally {
|
|
178
|
+
E.current = !1;
|
|
176
179
|
}
|
|
177
180
|
},
|
|
178
181
|
[
|
|
179
|
-
|
|
182
|
+
C,
|
|
180
183
|
r,
|
|
181
184
|
c,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
f,
|
|
186
|
+
i,
|
|
187
|
+
R
|
|
185
188
|
]
|
|
186
|
-
),
|
|
187
|
-
|
|
189
|
+
), I = h(() => {
|
|
190
|
+
p({
|
|
188
191
|
status: "idle",
|
|
189
192
|
error: null,
|
|
190
193
|
sessionId: null,
|
|
191
194
|
subscriptionStatus: null,
|
|
192
195
|
expiresAt: null
|
|
193
|
-
}),
|
|
196
|
+
}), P(null);
|
|
194
197
|
}, []);
|
|
195
198
|
return {
|
|
196
|
-
...
|
|
197
|
-
quote:
|
|
198
|
-
checkStatus:
|
|
199
|
-
requestQuote:
|
|
200
|
-
processPayment:
|
|
201
|
-
reset:
|
|
199
|
+
...w,
|
|
200
|
+
quote: k,
|
|
201
|
+
checkStatus: T,
|
|
202
|
+
requestQuote: q,
|
|
203
|
+
processPayment: g,
|
|
204
|
+
reset: I
|
|
202
205
|
};
|
|
203
206
|
}
|
|
204
207
|
function $e({
|
|
205
208
|
resource: r,
|
|
206
209
|
interval: c,
|
|
207
|
-
intervalDays:
|
|
208
|
-
couponCode:
|
|
209
|
-
label:
|
|
210
|
-
disabled:
|
|
211
|
-
onAttempt:
|
|
212
|
-
onSuccess:
|
|
213
|
-
onError:
|
|
210
|
+
intervalDays: f,
|
|
211
|
+
couponCode: i,
|
|
212
|
+
label: R,
|
|
213
|
+
disabled: w = !1,
|
|
214
|
+
onAttempt: p,
|
|
215
|
+
onSuccess: k,
|
|
216
|
+
onError: P,
|
|
214
217
|
className: E = "",
|
|
215
|
-
testPageUrl:
|
|
218
|
+
testPageUrl: C,
|
|
216
219
|
hideMessages: T = !1,
|
|
217
220
|
autoCheckStatus: q = !0
|
|
218
221
|
}) {
|
|
219
222
|
const {
|
|
220
|
-
connected:
|
|
221
|
-
connecting:
|
|
222
|
-
connect:
|
|
223
|
-
disconnect:
|
|
224
|
-
select:
|
|
225
|
-
wallets:
|
|
226
|
-
wallet:
|
|
227
|
-
publicKey:
|
|
228
|
-
} =
|
|
229
|
-
status:
|
|
230
|
-
error:
|
|
231
|
-
subscriptionStatus:
|
|
223
|
+
connected: g,
|
|
224
|
+
connecting: I,
|
|
225
|
+
connect: s,
|
|
226
|
+
disconnect: t,
|
|
227
|
+
select: n,
|
|
228
|
+
wallets: l,
|
|
229
|
+
wallet: a,
|
|
230
|
+
publicKey: o
|
|
231
|
+
} = J(), {
|
|
232
|
+
status: b,
|
|
233
|
+
error: m,
|
|
234
|
+
subscriptionStatus: S,
|
|
232
235
|
expiresAt: _,
|
|
233
|
-
checkStatus:
|
|
234
|
-
processPayment:
|
|
235
|
-
} =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
() => f.filter(
|
|
248
|
-
({ readyState: e }) => e === fe.Installed || e === fe.Loadable
|
|
236
|
+
checkStatus: M,
|
|
237
|
+
processPayment: L
|
|
238
|
+
} = Le(), u = _e(), { solanaError: W } = H(), { t: v, translations: X } = Te(), be = R || v("ui.subscribe_with_crypto"), Z = z(k), ee = z(P), te = z(L), re = z(M);
|
|
239
|
+
Z.current = k, ee.current = P, te.current = L, re.current = M;
|
|
240
|
+
const we = m && typeof m != "string" ? m?.code ?? null : null, Se = W && typeof W != "string" ? W?.code ?? null : null, ne = (e) => {
|
|
241
|
+
if (!e || !X) return "";
|
|
242
|
+
const d = X.errors[e];
|
|
243
|
+
return d ? d.action ? `${d.message} ${d.action}` : d.message : "";
|
|
244
|
+
}, ae = m ? typeof m == "string" ? m : ne(we) : null, se = W ? typeof W == "string" ? W : ne(Se) : null, he = G(
|
|
245
|
+
() => l.map((e) => `${e.adapter.name}-${e.readyState}`).join(","),
|
|
246
|
+
[l]
|
|
247
|
+
), j = G(
|
|
248
|
+
() => l.filter(
|
|
249
|
+
({ readyState: e }) => e === ge.Installed || e === ge.Loadable
|
|
249
250
|
),
|
|
250
251
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
251
|
-
[
|
|
252
|
+
[he]
|
|
252
253
|
);
|
|
253
|
-
|
|
254
|
-
q &&
|
|
255
|
-
}, [q,
|
|
256
|
-
|
|
257
|
-
}, [
|
|
258
|
-
|
|
259
|
-
}, [
|
|
260
|
-
const
|
|
261
|
-
|
|
254
|
+
Q(() => {
|
|
255
|
+
q && g && o && (y().debug("[CryptoSubscribeButton] Auto-checking subscription status"), re.current(r));
|
|
256
|
+
}, [q, g, o, r]), Q(() => {
|
|
257
|
+
b === "success" && S === "active" && (ve("crypto", "subscription-active", r), Z.current?.("subscription-active"));
|
|
258
|
+
}, [b, S, r]), Q(() => {
|
|
259
|
+
b === "error" && m && (fe("crypto", m, r), ee.current?.(m));
|
|
260
|
+
}, [b, m, r]);
|
|
261
|
+
const oe = typeof window < "u" && window.top !== window.self, [ie, A] = B(!1), [ce, U] = B(!1), [le, N] = B(!1), D = W;
|
|
262
|
+
Q(() => {
|
|
262
263
|
let e = !1;
|
|
263
264
|
return e || (async () => {
|
|
264
|
-
if (
|
|
265
|
+
if (ce && a && !g && !I) {
|
|
265
266
|
y().debug(
|
|
266
267
|
"[CryptoSubscribeButton] Wallet detected, attempting auto-connect:",
|
|
267
|
-
|
|
268
|
-
),
|
|
268
|
+
a.adapter.name
|
|
269
|
+
), U(!1), ye(a.adapter.name);
|
|
269
270
|
try {
|
|
270
|
-
await
|
|
271
|
-
} catch (
|
|
271
|
+
await s(), e || y().debug("[CryptoSubscribeButton] Auto-connect successful");
|
|
272
|
+
} catch (V) {
|
|
272
273
|
if (!e) {
|
|
273
|
-
y().error("[CryptoSubscribeButton] Auto-connect failed:",
|
|
274
|
-
const
|
|
275
|
-
|
|
274
|
+
y().error("[CryptoSubscribeButton] Auto-connect failed:", V);
|
|
275
|
+
const ke = V instanceof Error ? V.message : "Failed to connect wallet";
|
|
276
|
+
Y(ke, a.adapter.name), N(!1);
|
|
276
277
|
}
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
280
|
})(), () => {
|
|
280
281
|
e = !0;
|
|
281
282
|
};
|
|
282
|
-
}, [
|
|
283
|
-
|
|
284
|
-
}, [
|
|
285
|
-
const
|
|
283
|
+
}, [a, ce, g, I, s]), Q(() => {
|
|
284
|
+
g && le && o && a && (Be(a.adapter.name, o.toString()), y().debug("[CryptoSubscribeButton] Processing pending subscription payment"), N(!1), A(!1), me("crypto", r), te.current(r, c, { couponCode: i, intervalDays: f }));
|
|
285
|
+
}, [g, le, o, a, r, c, i, f]);
|
|
286
|
+
const ue = h(async () => {
|
|
286
287
|
if (y().debug("[CryptoSubscribeButton] executeSubscriptionFlow called", {
|
|
287
|
-
connected:
|
|
288
|
-
wallet:
|
|
288
|
+
connected: g,
|
|
289
|
+
wallet: a?.adapter.name,
|
|
289
290
|
resource: r,
|
|
290
291
|
interval: c
|
|
291
|
-
}),
|
|
292
|
-
y().error("[CryptoSubscribeButton] Solana dependencies missing:",
|
|
292
|
+
}), Ie("crypto", r), p && p("crypto"), D) {
|
|
293
|
+
y().error("[CryptoSubscribeButton] Solana dependencies missing:", D), fe("crypto", D, r), P && P(D);
|
|
293
294
|
return;
|
|
294
295
|
}
|
|
295
|
-
if (
|
|
296
|
-
const e =
|
|
296
|
+
if (oe) {
|
|
297
|
+
const e = C || window.location.href;
|
|
297
298
|
try {
|
|
298
299
|
if (new URL(e, window.location.origin).origin !== window.location.origin)
|
|
299
300
|
throw y().error("[CryptoSubscribeButton] Blocked attempt to open external URL:", e), new Error("Cannot open external URLs from embedded context");
|
|
300
301
|
window.open(e, "_blank", "noopener,noreferrer");
|
|
301
|
-
} catch (
|
|
302
|
-
throw y().error("[CryptoSubscribeButton] URL validation failed:",
|
|
302
|
+
} catch (d) {
|
|
303
|
+
throw y().error("[CryptoSubscribeButton] URL validation failed:", d), d;
|
|
303
304
|
}
|
|
304
305
|
return;
|
|
305
306
|
}
|
|
306
|
-
if (
|
|
307
|
-
|
|
307
|
+
if (g)
|
|
308
|
+
me("crypto", r), await L(r, c, { couponCode: i, intervalDays: f });
|
|
308
309
|
else {
|
|
309
|
-
|
|
310
|
+
N(!0);
|
|
310
311
|
try {
|
|
311
|
-
if (
|
|
312
|
+
if (a)
|
|
312
313
|
y().debug(
|
|
313
314
|
"[CryptoSubscribeButton] Wallet already selected, connecting:",
|
|
314
|
-
|
|
315
|
-
),
|
|
315
|
+
a.adapter.name
|
|
316
|
+
), ye(a.adapter.name), await s();
|
|
316
317
|
else {
|
|
317
|
-
if (y().debug("[CryptoSubscribeButton] No wallet selected, showing selector"),
|
|
318
|
-
|
|
318
|
+
if (y().debug("[CryptoSubscribeButton] No wallet selected, showing selector"), j.length === 0) {
|
|
319
|
+
N(!1);
|
|
319
320
|
const e = "No wallets available";
|
|
320
|
-
throw
|
|
321
|
+
throw Y(e), new Error(e);
|
|
321
322
|
}
|
|
322
|
-
|
|
323
|
+
A(!0);
|
|
323
324
|
}
|
|
324
325
|
} catch (e) {
|
|
325
|
-
|
|
326
|
-
const
|
|
327
|
-
y().error("[CryptoSubscribeButton] Connection error:",
|
|
326
|
+
N(!1);
|
|
327
|
+
const d = e instanceof Error ? e.message : "Failed to connect wallet";
|
|
328
|
+
y().error("[CryptoSubscribeButton] Connection error:", d), Y(d, a?.adapter.name);
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
331
|
}, [
|
|
331
|
-
|
|
332
|
-
|
|
332
|
+
g,
|
|
333
|
+
a,
|
|
333
334
|
r,
|
|
334
335
|
c,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
]),
|
|
346
|
-
() =>
|
|
336
|
+
i,
|
|
337
|
+
f,
|
|
338
|
+
oe,
|
|
339
|
+
C,
|
|
340
|
+
j,
|
|
341
|
+
s,
|
|
342
|
+
L,
|
|
343
|
+
D,
|
|
344
|
+
p,
|
|
345
|
+
P
|
|
346
|
+
]), de = G(() => `crypto-subscribe-${r}-${c}`, [r, c]), Ce = G(
|
|
347
|
+
() => We(de, ue, {
|
|
347
348
|
cooldownMs: 200,
|
|
348
349
|
deduplicationWindowMs: 0
|
|
349
350
|
}),
|
|
350
|
-
[
|
|
351
|
-
),
|
|
352
|
-
let
|
|
353
|
-
if (
|
|
354
|
-
|
|
355
|
-
else if (
|
|
351
|
+
[de, ue]
|
|
352
|
+
), pe = b === "loading" || b === "checking", $ = S === "active" || S === "trialing", xe = w || pe || I || !!D || $;
|
|
353
|
+
let F = be;
|
|
354
|
+
if (pe)
|
|
355
|
+
F = v("ui.processing");
|
|
356
|
+
else if ($ && _) {
|
|
356
357
|
const e = new Date(_).toLocaleDateString();
|
|
357
|
-
|
|
358
|
-
} else
|
|
359
|
-
const
|
|
358
|
+
F = `${v("ui.subscribed_until")} ${e}`;
|
|
359
|
+
} else $ && (F = v("ui.subscribed"));
|
|
360
|
+
const Pe = h(async () => {
|
|
360
361
|
try {
|
|
361
|
-
|
|
362
|
+
U(!1), g && await t(), n(null), A(!0);
|
|
362
363
|
} catch (e) {
|
|
363
364
|
y().error("Failed to change wallet:", e);
|
|
364
365
|
}
|
|
365
|
-
}, [
|
|
366
|
+
}, [g, t, n]), Ee = h(
|
|
366
367
|
(e) => {
|
|
367
|
-
y().debug("[CryptoSubscribeButton] Wallet clicked:", e),
|
|
368
|
+
y().debug("[CryptoSubscribeButton] Wallet clicked:", e), A(!1), n(e), U(!0);
|
|
368
369
|
},
|
|
369
|
-
[
|
|
370
|
-
),
|
|
370
|
+
[n]
|
|
371
|
+
), Re = h(async () => {
|
|
371
372
|
try {
|
|
372
|
-
if (await
|
|
373
|
+
if (await t(), N(!1), typeof window < "u" && window.localStorage)
|
|
373
374
|
try {
|
|
374
375
|
window.localStorage.removeItem("walletName");
|
|
375
376
|
} catch (e) {
|
|
@@ -378,24 +379,24 @@ function $e({
|
|
|
378
379
|
} catch (e) {
|
|
379
380
|
y().error("Failed to disconnect wallet:", e);
|
|
380
381
|
}
|
|
381
|
-
}, [
|
|
382
|
+
}, [t]);
|
|
382
383
|
return /* @__PURE__ */ O(
|
|
383
384
|
"div",
|
|
384
385
|
{
|
|
385
|
-
className:
|
|
386
|
-
style:
|
|
386
|
+
className: u.unstyled ? E : `${u.className} cedros-theme__crypto-button ${E || ""}`,
|
|
387
|
+
style: u.unstyled ? {} : u.style,
|
|
387
388
|
children: [
|
|
388
389
|
/* @__PURE__ */ x(
|
|
389
390
|
"button",
|
|
390
391
|
{
|
|
391
|
-
onClick:
|
|
392
|
-
disabled:
|
|
393
|
-
className:
|
|
392
|
+
onClick: Ce,
|
|
393
|
+
disabled: xe,
|
|
394
|
+
className: u.unstyled ? E : "cedros-theme__button cedros-theme__crypto",
|
|
394
395
|
type: "button",
|
|
395
|
-
children:
|
|
396
|
+
children: F
|
|
396
397
|
}
|
|
397
398
|
),
|
|
398
|
-
|
|
399
|
+
ie && !T && /* @__PURE__ */ x(
|
|
399
400
|
"div",
|
|
400
401
|
{
|
|
401
402
|
className: "cedros-modal-overlay",
|
|
@@ -405,26 +406,26 @@ function $e({
|
|
|
405
406
|
left: 0,
|
|
406
407
|
right: 0,
|
|
407
408
|
bottom: 0,
|
|
408
|
-
backgroundColor:
|
|
409
|
+
backgroundColor: u.tokens.modalOverlay,
|
|
409
410
|
display: "flex",
|
|
410
411
|
alignItems: "center",
|
|
411
412
|
justifyContent: "center",
|
|
412
413
|
zIndex: 9999,
|
|
413
414
|
padding: "1rem"
|
|
414
415
|
},
|
|
415
|
-
onClick: () =>
|
|
416
|
+
onClick: () => A(!1),
|
|
416
417
|
children: /* @__PURE__ */ O(
|
|
417
418
|
"div",
|
|
418
419
|
{
|
|
419
420
|
className: "cedros-modal-content",
|
|
420
421
|
style: {
|
|
421
|
-
backgroundColor:
|
|
422
|
+
backgroundColor: u.tokens.modalBackground,
|
|
422
423
|
borderRadius: "12px",
|
|
423
424
|
padding: "2rem",
|
|
424
425
|
maxWidth: "400px",
|
|
425
426
|
width: "100%",
|
|
426
427
|
boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
427
|
-
border: `1px solid ${
|
|
428
|
+
border: `1px solid ${u.tokens.modalBorder}`
|
|
428
429
|
},
|
|
429
430
|
onClick: (e) => e.stopPropagation(),
|
|
430
431
|
children: [
|
|
@@ -445,7 +446,7 @@ function $e({
|
|
|
445
446
|
margin: 0,
|
|
446
447
|
fontSize: "1.25rem",
|
|
447
448
|
fontWeight: 600,
|
|
448
|
-
color:
|
|
449
|
+
color: u.tokens.surfaceText
|
|
449
450
|
},
|
|
450
451
|
children: v("wallet.select_wallet")
|
|
451
452
|
}
|
|
@@ -453,8 +454,8 @@ function $e({
|
|
|
453
454
|
/* @__PURE__ */ x(
|
|
454
455
|
"button",
|
|
455
456
|
{
|
|
456
|
-
onClick: () =>
|
|
457
|
-
style:
|
|
457
|
+
onClick: () => A(!1),
|
|
458
|
+
style: qe(u.tokens.surfaceText),
|
|
458
459
|
"aria-label": "Close modal",
|
|
459
460
|
type: "button",
|
|
460
461
|
children: "×"
|
|
@@ -463,34 +464,34 @@ function $e({
|
|
|
463
464
|
]
|
|
464
465
|
}
|
|
465
466
|
),
|
|
466
|
-
/* @__PURE__ */ x("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children:
|
|
467
|
+
/* @__PURE__ */ x("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: j.map((e) => /* @__PURE__ */ O(
|
|
467
468
|
"button",
|
|
468
469
|
{
|
|
469
|
-
onClick: () =>
|
|
470
|
+
onClick: () => Ee(e.adapter.name),
|
|
470
471
|
style: {
|
|
471
472
|
width: "100%",
|
|
472
473
|
padding: "1rem",
|
|
473
|
-
backgroundColor:
|
|
474
|
-
border: `1px solid ${
|
|
474
|
+
backgroundColor: u.tokens.surfaceBackground,
|
|
475
|
+
border: `1px solid ${u.tokens.surfaceBorder}`,
|
|
475
476
|
borderRadius: "0.5rem",
|
|
476
477
|
cursor: "pointer",
|
|
477
478
|
fontSize: "1rem",
|
|
478
479
|
textAlign: "left",
|
|
479
|
-
color:
|
|
480
|
+
color: u.tokens.surfaceText,
|
|
480
481
|
display: "flex",
|
|
481
482
|
alignItems: "center",
|
|
482
483
|
gap: "1rem",
|
|
483
484
|
transition: "all 0.2s ease"
|
|
484
485
|
},
|
|
485
|
-
onMouseEnter: (
|
|
486
|
-
|
|
486
|
+
onMouseEnter: (d) => {
|
|
487
|
+
d.currentTarget.style.backgroundColor = u.tokens.modalBackground, d.currentTarget.style.borderColor = u.tokens.surfaceText, d.currentTarget.style.transform = "translateY(-2px)";
|
|
487
488
|
},
|
|
488
|
-
onMouseLeave: (
|
|
489
|
-
|
|
489
|
+
onMouseLeave: (d) => {
|
|
490
|
+
d.currentTarget.style.backgroundColor = u.tokens.surfaceBackground, d.currentTarget.style.borderColor = u.tokens.surfaceBorder, d.currentTarget.style.transform = "translateY(0)";
|
|
490
491
|
},
|
|
491
492
|
type: "button",
|
|
492
493
|
children: [
|
|
493
|
-
/* @__PURE__ */ x(
|
|
494
|
+
/* @__PURE__ */ x(Me, { wallet: e, style: { width: "24px", height: "24px" } }),
|
|
494
495
|
/* @__PURE__ */ x("span", { style: { fontWeight: 500 }, children: e.adapter.name })
|
|
495
496
|
]
|
|
496
497
|
},
|
|
@@ -501,7 +502,7 @@ function $e({
|
|
|
501
502
|
)
|
|
502
503
|
}
|
|
503
504
|
),
|
|
504
|
-
|
|
505
|
+
g && !T && !ie && /* @__PURE__ */ O(
|
|
505
506
|
"div",
|
|
506
507
|
{
|
|
507
508
|
style: {
|
|
@@ -509,14 +510,14 @@ function $e({
|
|
|
509
510
|
justifyContent: "space-between",
|
|
510
511
|
marginTop: "0.5rem",
|
|
511
512
|
fontSize: "0.75rem",
|
|
512
|
-
color:
|
|
513
|
+
color: u.tokens.surfaceText,
|
|
513
514
|
opacity: 0.7
|
|
514
515
|
},
|
|
515
516
|
children: [
|
|
516
517
|
/* @__PURE__ */ x(
|
|
517
518
|
"button",
|
|
518
519
|
{
|
|
519
|
-
onClick:
|
|
520
|
+
onClick: Pe,
|
|
520
521
|
style: {
|
|
521
522
|
background: "none",
|
|
522
523
|
border: "none",
|
|
@@ -533,7 +534,7 @@ function $e({
|
|
|
533
534
|
/* @__PURE__ */ x(
|
|
534
535
|
"button",
|
|
535
536
|
{
|
|
536
|
-
onClick:
|
|
537
|
+
onClick: Re,
|
|
537
538
|
style: {
|
|
538
539
|
background: "none",
|
|
539
540
|
border: "none",
|
|
@@ -550,89 +551,97 @@ function $e({
|
|
|
550
551
|
]
|
|
551
552
|
}
|
|
552
553
|
),
|
|
553
|
-
!T &&
|
|
554
|
-
!T &&
|
|
555
|
-
!T &&
|
|
554
|
+
!T && se && /* @__PURE__ */ x("div", { className: u.unstyled ? "" : "cedros-theme__error", children: se }),
|
|
555
|
+
!T && ae && /* @__PURE__ */ x("div", { className: u.unstyled ? "" : "cedros-theme__error", children: ae }),
|
|
556
|
+
!T && $ && /* @__PURE__ */ x("div", { className: u.unstyled ? "" : "cedros-theme__success", children: v("ui.subscription_active") })
|
|
556
557
|
]
|
|
557
558
|
}
|
|
558
559
|
);
|
|
559
560
|
}
|
|
560
561
|
function Fe() {
|
|
561
|
-
const { x402Manager: r, walletManager: c } =
|
|
562
|
+
const { x402Manager: r, walletManager: c } = H(), { publicKey: f, signTransaction: i } = J(), [R, w] = B({
|
|
562
563
|
status: "idle",
|
|
563
564
|
error: null,
|
|
564
565
|
transactionId: null
|
|
565
|
-
}), [
|
|
566
|
+
}), [p, k] = B(null), [P, E] = B(null), C = z(!1), T = h(
|
|
566
567
|
async (s) => {
|
|
567
568
|
try {
|
|
568
|
-
|
|
569
|
+
w((n) => ({ ...n, status: "loading" }));
|
|
569
570
|
const t = await r.requestQuote({ resource: s });
|
|
570
571
|
if (!r.validateRequirement(t))
|
|
571
572
|
throw new Error("Invalid refund requirement received from server");
|
|
572
|
-
return
|
|
573
|
+
return k(t), w((n) => ({ ...n, status: "idle" })), t;
|
|
573
574
|
} catch (t) {
|
|
574
|
-
const
|
|
575
|
-
throw
|
|
575
|
+
const n = K(t, "Failed to fetch refund requirement");
|
|
576
|
+
throw w({
|
|
576
577
|
status: "error",
|
|
577
|
-
error:
|
|
578
|
+
error: n,
|
|
578
579
|
transactionId: null
|
|
579
580
|
}), t;
|
|
580
581
|
}
|
|
581
582
|
},
|
|
582
583
|
[r]
|
|
583
|
-
),
|
|
584
|
+
), q = h(
|
|
584
585
|
async (s, t) => {
|
|
585
|
-
if (
|
|
586
|
+
if (C.current)
|
|
587
|
+
throw new Error("Refund already in progress");
|
|
588
|
+
if (!f || !i)
|
|
586
589
|
throw new Error("Wallet not connected");
|
|
590
|
+
C.current = !0;
|
|
587
591
|
try {
|
|
588
|
-
|
|
592
|
+
w({
|
|
589
593
|
status: "loading",
|
|
590
594
|
error: null,
|
|
591
595
|
transactionId: null
|
|
592
596
|
});
|
|
593
|
-
const
|
|
594
|
-
if (!r.validateRequirement(
|
|
597
|
+
const n = await r.requestQuote({ resource: s, couponCode: t });
|
|
598
|
+
if (!r.validateRequirement(n))
|
|
595
599
|
throw new Error("Invalid refund requirement received");
|
|
596
|
-
|
|
597
|
-
const
|
|
598
|
-
requirement:
|
|
599
|
-
payerPublicKey:
|
|
600
|
-
}),
|
|
601
|
-
transaction:
|
|
602
|
-
signTransaction:
|
|
603
|
-
}),
|
|
604
|
-
requirement:
|
|
605
|
-
signedTx:
|
|
606
|
-
payerPublicKey:
|
|
607
|
-
}),
|
|
600
|
+
k(n);
|
|
601
|
+
const l = await c.buildTransaction({
|
|
602
|
+
requirement: n,
|
|
603
|
+
payerPublicKey: f
|
|
604
|
+
}), a = await c.signTransaction({
|
|
605
|
+
transaction: l,
|
|
606
|
+
signTransaction: i
|
|
607
|
+
}), o = c.buildPaymentPayload({
|
|
608
|
+
requirement: n,
|
|
609
|
+
signedTx: a,
|
|
610
|
+
payerPublicKey: f
|
|
611
|
+
}), b = await r.submitPayment({
|
|
608
612
|
resource: s,
|
|
609
|
-
payload:
|
|
613
|
+
payload: o,
|
|
610
614
|
couponCode: t,
|
|
611
615
|
metadata: void 0,
|
|
612
616
|
// no metadata for refunds
|
|
613
617
|
resourceType: "refund"
|
|
614
618
|
});
|
|
615
|
-
return
|
|
619
|
+
return b.settlement && E(b.settlement), w({
|
|
616
620
|
status: "success",
|
|
617
621
|
error: null,
|
|
618
|
-
transactionId:
|
|
619
|
-
}),
|
|
620
|
-
} catch (
|
|
621
|
-
const
|
|
622
|
-
throw
|
|
622
|
+
transactionId: b.transactionId || a.signature
|
|
623
|
+
}), b;
|
|
624
|
+
} catch (n) {
|
|
625
|
+
const l = K(n, "Refund payment failed");
|
|
626
|
+
throw w({
|
|
623
627
|
status: "error",
|
|
624
|
-
error:
|
|
628
|
+
error: l,
|
|
625
629
|
transactionId: null
|
|
626
|
-
}),
|
|
630
|
+
}), n;
|
|
631
|
+
} finally {
|
|
632
|
+
C.current = !1;
|
|
627
633
|
}
|
|
628
634
|
},
|
|
629
|
-
[
|
|
630
|
-
),
|
|
635
|
+
[f, i, r, c]
|
|
636
|
+
), g = h(
|
|
631
637
|
async (s) => {
|
|
632
|
-
if (
|
|
638
|
+
if (C.current)
|
|
639
|
+
throw new Error("Refund already in progress");
|
|
640
|
+
if (!f || !i)
|
|
633
641
|
throw new Error("Wallet not connected");
|
|
642
|
+
C.current = !0;
|
|
634
643
|
try {
|
|
635
|
-
|
|
644
|
+
w({
|
|
636
645
|
status: "loading",
|
|
637
646
|
error: null,
|
|
638
647
|
transactionId: null
|
|
@@ -640,17 +649,17 @@ function Fe() {
|
|
|
640
649
|
const t = await r.requestQuote({ resource: s });
|
|
641
650
|
if (!r.validateRequirement(t))
|
|
642
651
|
throw new Error("Invalid refund requirement received");
|
|
643
|
-
|
|
644
|
-
const { transaction:
|
|
652
|
+
k(t);
|
|
653
|
+
const { transaction: n } = await r.buildGaslessTransaction({
|
|
645
654
|
resourceId: s,
|
|
646
|
-
userWallet:
|
|
655
|
+
userWallet: f.toString(),
|
|
647
656
|
feePayer: t.extra.feePayer
|
|
648
|
-
}),
|
|
649
|
-
transaction:
|
|
650
|
-
signTransaction:
|
|
651
|
-
}),
|
|
657
|
+
}), l = c.deserializeTransaction(n), a = await c.partiallySignTransaction({
|
|
658
|
+
transaction: l,
|
|
659
|
+
signTransaction: i
|
|
660
|
+
}), o = await r.submitGaslessTransaction({
|
|
652
661
|
resource: s,
|
|
653
|
-
partialTx:
|
|
662
|
+
partialTx: a,
|
|
654
663
|
couponCode: void 0,
|
|
655
664
|
// no couponCode
|
|
656
665
|
metadata: void 0,
|
|
@@ -658,111 +667,113 @@ function Fe() {
|
|
|
658
667
|
resourceType: "refund",
|
|
659
668
|
requirement: t
|
|
660
669
|
});
|
|
661
|
-
return
|
|
670
|
+
return o.settlement && E(o.settlement), w({
|
|
662
671
|
status: "success",
|
|
663
672
|
error: null,
|
|
664
|
-
transactionId:
|
|
665
|
-
}),
|
|
673
|
+
transactionId: o.transactionId || "gasless-refund-tx"
|
|
674
|
+
}), o;
|
|
666
675
|
} catch (t) {
|
|
667
|
-
const
|
|
668
|
-
throw
|
|
676
|
+
const n = K(t, "Gasless refund payment failed");
|
|
677
|
+
throw w({
|
|
669
678
|
status: "error",
|
|
670
|
-
error:
|
|
679
|
+
error: n,
|
|
671
680
|
transactionId: null
|
|
672
681
|
}), t;
|
|
682
|
+
} finally {
|
|
683
|
+
C.current = !1;
|
|
673
684
|
}
|
|
674
685
|
},
|
|
675
|
-
[
|
|
676
|
-
),
|
|
677
|
-
|
|
686
|
+
[f, i, r, c]
|
|
687
|
+
), I = h(() => {
|
|
688
|
+
w({
|
|
678
689
|
status: "idle",
|
|
679
690
|
error: null,
|
|
680
691
|
transactionId: null
|
|
681
|
-
}),
|
|
692
|
+
}), k(null), E(null);
|
|
682
693
|
}, []);
|
|
683
694
|
return {
|
|
684
|
-
state:
|
|
685
|
-
requirement:
|
|
686
|
-
settlement:
|
|
687
|
-
fetchRefundQuote:
|
|
688
|
-
processRefund:
|
|
689
|
-
processGaslessRefund:
|
|
690
|
-
reset:
|
|
695
|
+
state: R,
|
|
696
|
+
requirement: p,
|
|
697
|
+
settlement: P,
|
|
698
|
+
fetchRefundQuote: T,
|
|
699
|
+
processRefund: q,
|
|
700
|
+
processGaslessRefund: g,
|
|
701
|
+
reset: I
|
|
691
702
|
};
|
|
692
703
|
}
|
|
693
704
|
export {
|
|
694
705
|
Ue as CEDROS_EVENTS,
|
|
695
|
-
|
|
706
|
+
Mt as CIRCUIT_BREAKER_PRESETS,
|
|
696
707
|
Ve as CSP_PRESETS,
|
|
697
708
|
Ye as CedrosPay,
|
|
698
709
|
He as CedrosPayAdminDashboard,
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
710
|
+
Lt as CedrosProvider,
|
|
711
|
+
At as CircuitBreakerOpenError,
|
|
712
|
+
Nt as CircuitState,
|
|
702
713
|
Je as CreditsButton,
|
|
703
714
|
Xe as CreditsSubscribeButton,
|
|
704
|
-
|
|
715
|
+
Jt as CryptoButton,
|
|
705
716
|
$e as CryptoSubscribeButton,
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
717
|
+
Dt as ERROR_CATEGORIES,
|
|
718
|
+
zt as KNOWN_STABLECOINS,
|
|
719
|
+
Kt as LogLevel,
|
|
720
|
+
Ot as Logger,
|
|
721
|
+
Ze as PaymentMethodBadge,
|
|
722
|
+
et as PaymentModal,
|
|
723
|
+
tt as ProductPrice,
|
|
724
|
+
rt as PurchaseButton,
|
|
725
|
+
Qt as RATE_LIMITER_PRESETS,
|
|
726
|
+
$t as RETRY_PRESETS,
|
|
727
|
+
nt as RPC_PROVIDERS,
|
|
728
|
+
at as SECURITY_RECOMMENDATIONS,
|
|
729
|
+
st as StripeButton,
|
|
730
|
+
ot as SubscribeButton,
|
|
731
|
+
it as SubscriptionManagementPanel,
|
|
732
|
+
er as WalletPool,
|
|
733
|
+
ct as calculateDiscountPercentage,
|
|
734
|
+
lt as cedrosPayPlugin,
|
|
735
|
+
Ft as createCircuitBreaker,
|
|
736
|
+
Gt as createLogger,
|
|
737
|
+
jt as createRateLimiter,
|
|
738
|
+
ut as createTranslator,
|
|
739
|
+
tr as createWalletPool,
|
|
740
|
+
dt as detectLocale,
|
|
741
|
+
pt as ecommerce,
|
|
742
|
+
fe as emitPaymentError,
|
|
743
|
+
me as emitPaymentProcessing,
|
|
744
|
+
Ie as emitPaymentStart,
|
|
745
|
+
ve as emitPaymentSuccess,
|
|
746
|
+
ye as emitWalletConnect,
|
|
747
|
+
Be as emitWalletConnected,
|
|
748
|
+
Y as emitWalletError,
|
|
749
|
+
ft as formatCSP,
|
|
750
|
+
mt as formatCouponCodes,
|
|
751
|
+
yt as generateCSP,
|
|
752
|
+
gt as generateCSPDirectives,
|
|
753
|
+
bt as getAvailableLocales,
|
|
754
|
+
wt as getLocalizedError,
|
|
744
755
|
y as getLogger,
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
756
|
+
St as getUserErrorMessage,
|
|
757
|
+
ht as isRetryableError,
|
|
758
|
+
Ct as loadLocale,
|
|
759
|
+
xt as logSecurityReport,
|
|
760
|
+
Pt as parseCouponCodes,
|
|
761
|
+
Ut as retryWithBackoff,
|
|
762
|
+
Et as stackCheckoutCoupons,
|
|
763
|
+
H as useCedrosContext,
|
|
764
|
+
_e as useCedrosTheme,
|
|
754
765
|
Rt as useCreditsPayment,
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
766
|
+
kt as useCreditsSubscription,
|
|
767
|
+
Le as useCryptoSubscription,
|
|
768
|
+
Tt as useLocalizedError,
|
|
769
|
+
vt as usePaymentMode,
|
|
759
770
|
Fe as useRefundVerification,
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
771
|
+
Bt as useStripeCheckout,
|
|
772
|
+
It as useSubscription,
|
|
773
|
+
Wt as useSubscriptionManagement,
|
|
774
|
+
Te as useTranslation,
|
|
775
|
+
Xt as useX402Payment,
|
|
776
|
+
Vt as validateConfig,
|
|
777
|
+
qt as validateSecurity,
|
|
778
|
+
Yt as validateTokenMint
|
|
768
779
|
};
|