@chipi-stack/chipi-react 0.1.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.
@@ -0,0 +1,60 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import { CreateWalletResponse, WalletData, SkuCategory, Sku } from '@chipi-stack/types';
4
+
5
+ interface WalletCreatorProps {
6
+ onWalletCreated?: (wallet: CreateWalletResponse) => void;
7
+ className?: string;
8
+ children?: React.ReactNode;
9
+ }
10
+ /**
11
+ * Component for creating a new wallet
12
+ */
13
+ declare function WalletCreator({ onWalletCreated, className, children }: WalletCreatorProps): react_jsx_runtime.JSX.Element;
14
+
15
+ interface WalletBalanceProps {
16
+ address: string;
17
+ balance?: number;
18
+ currency?: string;
19
+ isLoading?: boolean;
20
+ className?: string;
21
+ }
22
+ /**
23
+ * Component for displaying wallet balance
24
+ */
25
+ declare function WalletBalance({ address, balance, currency, isLoading, className, }: WalletBalanceProps): react_jsx_runtime.JSX.Element;
26
+
27
+ interface TransactionFormProps {
28
+ wallet: WalletData;
29
+ encryptKey: string;
30
+ bearerToken: string;
31
+ onTransactionComplete?: (txHash: string) => void;
32
+ className?: string;
33
+ }
34
+ /**
35
+ * Component for creating token transfer transactions
36
+ */
37
+ declare function TransactionForm({ wallet, encryptKey, bearerToken, onTransactionComplete, className, }: TransactionFormProps): react_jsx_runtime.JSX.Element;
38
+
39
+ interface SkuListProps {
40
+ categories?: SkuCategory[];
41
+ onSkuSelect?: (sku: Sku) => void;
42
+ className?: string;
43
+ }
44
+ /**
45
+ * Component for displaying available SKUs
46
+ */
47
+ declare function SkuList({ categories, onSkuSelect, className }: SkuListProps): react_jsx_runtime.JSX.Element;
48
+
49
+ interface SkuPurchaseFormProps {
50
+ sku: Sku;
51
+ walletAddress: string;
52
+ onPurchaseComplete?: (transactionHash: string) => void;
53
+ className?: string;
54
+ }
55
+ /**
56
+ * Component for purchasing a SKU
57
+ */
58
+ declare function SkuPurchaseForm({ sku, walletAddress, onPurchaseComplete, className, }: SkuPurchaseFormProps): react_jsx_runtime.JSX.Element;
59
+
60
+ export { SkuList, SkuPurchaseForm, TransactionForm, WalletBalance, WalletCreator };
@@ -0,0 +1,60 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import { CreateWalletResponse, WalletData, SkuCategory, Sku } from '@chipi-stack/types';
4
+
5
+ interface WalletCreatorProps {
6
+ onWalletCreated?: (wallet: CreateWalletResponse) => void;
7
+ className?: string;
8
+ children?: React.ReactNode;
9
+ }
10
+ /**
11
+ * Component for creating a new wallet
12
+ */
13
+ declare function WalletCreator({ onWalletCreated, className, children }: WalletCreatorProps): react_jsx_runtime.JSX.Element;
14
+
15
+ interface WalletBalanceProps {
16
+ address: string;
17
+ balance?: number;
18
+ currency?: string;
19
+ isLoading?: boolean;
20
+ className?: string;
21
+ }
22
+ /**
23
+ * Component for displaying wallet balance
24
+ */
25
+ declare function WalletBalance({ address, balance, currency, isLoading, className, }: WalletBalanceProps): react_jsx_runtime.JSX.Element;
26
+
27
+ interface TransactionFormProps {
28
+ wallet: WalletData;
29
+ encryptKey: string;
30
+ bearerToken: string;
31
+ onTransactionComplete?: (txHash: string) => void;
32
+ className?: string;
33
+ }
34
+ /**
35
+ * Component for creating token transfer transactions
36
+ */
37
+ declare function TransactionForm({ wallet, encryptKey, bearerToken, onTransactionComplete, className, }: TransactionFormProps): react_jsx_runtime.JSX.Element;
38
+
39
+ interface SkuListProps {
40
+ categories?: SkuCategory[];
41
+ onSkuSelect?: (sku: Sku) => void;
42
+ className?: string;
43
+ }
44
+ /**
45
+ * Component for displaying available SKUs
46
+ */
47
+ declare function SkuList({ categories, onSkuSelect, className }: SkuListProps): react_jsx_runtime.JSX.Element;
48
+
49
+ interface SkuPurchaseFormProps {
50
+ sku: Sku;
51
+ walletAddress: string;
52
+ onPurchaseComplete?: (transactionHash: string) => void;
53
+ className?: string;
54
+ }
55
+ /**
56
+ * Component for purchasing a SKU
57
+ */
58
+ declare function SkuPurchaseForm({ sku, walletAddress, onPurchaseComplete, className, }: SkuPurchaseFormProps): react_jsx_runtime.JSX.Element;
59
+
60
+ export { SkuList, SkuPurchaseForm, TransactionForm, WalletBalance, WalletCreator };
@@ -0,0 +1,504 @@
1
+ 'use strict';
2
+
3
+ var React2 = require('react');
4
+ var reactQuery = require('@tanstack/react-query');
5
+ require('@chipi-stack/backend');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var shared = require('@chipi-stack/shared');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var React2__default = /*#__PURE__*/_interopDefault(React2);
12
+
13
+ // src/components/WalletCreator.tsx
14
+ var ChipiContext = React2.createContext(null);
15
+ function useChipiContext() {
16
+ const context = React2.useContext(ChipiContext);
17
+ if (!context) {
18
+ throw new Error("useChipiContext must be used within a ChipiProvider");
19
+ }
20
+ return context;
21
+ }
22
+
23
+ // src/hooks/useCreateWallet.ts
24
+ function useCreateWallet() {
25
+ const { chipiSDK } = useChipiContext();
26
+ const mutation = reactQuery.useMutation({
27
+ mutationFn: (params) => chipiSDK.createWallet(params)
28
+ });
29
+ return {
30
+ createWallet: mutation.mutate,
31
+ createWalletAsync: mutation.mutateAsync,
32
+ data: mutation.data,
33
+ isLoading: mutation.isPending,
34
+ isError: mutation.isError,
35
+ error: mutation.error,
36
+ isSuccess: mutation.isSuccess,
37
+ reset: mutation.reset
38
+ };
39
+ }
40
+ function WalletCreator({ onWalletCreated, className, children }) {
41
+ const [encryptKey, setEncryptKey] = React2.useState("");
42
+ const [bearerToken, setBearerToken] = React2.useState("");
43
+ const { createWallet, isLoading, isError, error, data, isSuccess } = useCreateWallet();
44
+ const handleSubmit = (e) => {
45
+ e.preventDefault();
46
+ if (!encryptKey || !bearerToken) return;
47
+ createWallet({
48
+ encryptKey,
49
+ bearerToken
50
+ });
51
+ };
52
+ React2__default.default.useEffect(() => {
53
+ if (isSuccess && data && onWalletCreated) {
54
+ onWalletCreated(data);
55
+ }
56
+ }, [isSuccess, data, onWalletCreated]);
57
+ if (children) {
58
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
59
+ }
60
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
61
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { children: "Create Wallet" }),
62
+ isError && error && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { color: "red", marginBottom: "1rem" }, children: [
63
+ "Error: ",
64
+ error.message
65
+ ] }),
66
+ isSuccess && data && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { color: "green", marginBottom: "1rem" }, children: [
67
+ "Wallet created successfully! Address: ",
68
+ data.walletPublicKey
69
+ ] }),
70
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
71
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
72
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "encryptKey", children: "Encrypt Key:" }),
73
+ /* @__PURE__ */ jsxRuntime.jsx(
74
+ "input",
75
+ {
76
+ id: "encryptKey",
77
+ type: "password",
78
+ value: encryptKey,
79
+ onChange: (e) => setEncryptKey(e.target.value),
80
+ required: true,
81
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
82
+ }
83
+ )
84
+ ] }),
85
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
86
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "bearerToken", children: "Bearer Token:" }),
87
+ /* @__PURE__ */ jsxRuntime.jsx(
88
+ "input",
89
+ {
90
+ id: "bearerToken",
91
+ type: "text",
92
+ value: bearerToken,
93
+ onChange: (e) => setBearerToken(e.target.value),
94
+ required: true,
95
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
96
+ }
97
+ )
98
+ ] }),
99
+ /* @__PURE__ */ jsxRuntime.jsx(
100
+ "button",
101
+ {
102
+ type: "submit",
103
+ disabled: isLoading || !encryptKey || !bearerToken,
104
+ style: {
105
+ padding: "0.75rem 1.5rem",
106
+ backgroundColor: isLoading ? "#ccc" : "#007bff",
107
+ color: "white",
108
+ border: "none",
109
+ borderRadius: "0.25rem",
110
+ cursor: isLoading ? "not-allowed" : "pointer"
111
+ },
112
+ children: isLoading ? "Creating..." : "Create Wallet"
113
+ }
114
+ )
115
+ ] })
116
+ ] });
117
+ }
118
+ function WalletBalance({
119
+ address,
120
+ balance,
121
+ currency = "USD",
122
+ isLoading = false,
123
+ className
124
+ }) {
125
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
126
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "0.5rem" }, children: [
127
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Wallet:" }),
128
+ " ",
129
+ shared.formatAddress(address)
130
+ ] }),
131
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
132
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Balance:" }),
133
+ " ",
134
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading..." }) : balance !== void 0 ? shared.formatCurrency(balance, currency) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: "--" })
135
+ ] })
136
+ ] });
137
+ }
138
+ function useTransfer() {
139
+ const { chipiSDK } = useChipiContext();
140
+ const mutation = reactQuery.useMutation({
141
+ mutationFn: (params) => chipiSDK.transfer(params)
142
+ });
143
+ return {
144
+ transfer: mutation.mutate,
145
+ transferAsync: mutation.mutateAsync,
146
+ data: mutation.data,
147
+ isLoading: mutation.isPending,
148
+ isError: mutation.isError,
149
+ error: mutation.error,
150
+ isSuccess: mutation.isSuccess,
151
+ reset: mutation.reset
152
+ };
153
+ }
154
+ function TransactionForm({
155
+ wallet,
156
+ encryptKey,
157
+ bearerToken,
158
+ onTransactionComplete,
159
+ className
160
+ }) {
161
+ const [contractAddress, setContractAddress] = React2.useState("");
162
+ const [recipient, setRecipient] = React2.useState("");
163
+ const [amount, setAmount] = React2.useState("");
164
+ const [decimals, setDecimals] = React2.useState(18);
165
+ const { transfer, isLoading, isError, error, data, isSuccess } = useTransfer();
166
+ const handleSubmit = (e) => {
167
+ e.preventDefault();
168
+ if (!contractAddress || !recipient || !amount) return;
169
+ transfer({
170
+ encryptKey,
171
+ wallet,
172
+ contractAddress,
173
+ recipient,
174
+ amount: parseFloat(amount),
175
+ decimals,
176
+ bearerToken
177
+ });
178
+ };
179
+ React2__default.default.useEffect(() => {
180
+ if (isSuccess && data && onTransactionComplete) {
181
+ onTransactionComplete(data);
182
+ }
183
+ }, [isSuccess, data, onTransactionComplete]);
184
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
185
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { children: "Transfer Tokens" }),
186
+ isError && error && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { color: "red", marginBottom: "1rem" }, children: [
187
+ "Error: ",
188
+ error.message
189
+ ] }),
190
+ isSuccess && data && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { color: "green", marginBottom: "1rem" }, children: [
191
+ "Transaction successful! Hash: ",
192
+ data
193
+ ] }),
194
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
195
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
196
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "contractAddress", children: "Token Contract:" }),
197
+ /* @__PURE__ */ jsxRuntime.jsx(
198
+ "input",
199
+ {
200
+ id: "contractAddress",
201
+ type: "text",
202
+ value: contractAddress,
203
+ onChange: (e) => setContractAddress(e.target.value),
204
+ placeholder: "0x...",
205
+ required: true,
206
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
207
+ }
208
+ )
209
+ ] }),
210
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
211
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "recipient", children: "Recipient:" }),
212
+ /* @__PURE__ */ jsxRuntime.jsx(
213
+ "input",
214
+ {
215
+ id: "recipient",
216
+ type: "text",
217
+ value: recipient,
218
+ onChange: (e) => setRecipient(e.target.value),
219
+ placeholder: "0x...",
220
+ required: true,
221
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
222
+ }
223
+ )
224
+ ] }),
225
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
226
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "amount", children: "Amount:" }),
227
+ /* @__PURE__ */ jsxRuntime.jsx(
228
+ "input",
229
+ {
230
+ id: "amount",
231
+ type: "number",
232
+ step: "any",
233
+ value: amount,
234
+ onChange: (e) => setAmount(e.target.value),
235
+ required: true,
236
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
237
+ }
238
+ )
239
+ ] }),
240
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
241
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "decimals", children: "Decimals:" }),
242
+ /* @__PURE__ */ jsxRuntime.jsx(
243
+ "input",
244
+ {
245
+ id: "decimals",
246
+ type: "number",
247
+ value: decimals,
248
+ onChange: (e) => setDecimals(parseInt(e.target.value)),
249
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
250
+ }
251
+ )
252
+ ] }),
253
+ /* @__PURE__ */ jsxRuntime.jsx(
254
+ "button",
255
+ {
256
+ type: "submit",
257
+ disabled: isLoading || !contractAddress || !recipient || !amount,
258
+ style: {
259
+ padding: "0.75rem 1.5rem",
260
+ backgroundColor: isLoading ? "#ccc" : "#007bff",
261
+ color: "white",
262
+ border: "none",
263
+ borderRadius: "0.25rem",
264
+ cursor: isLoading ? "not-allowed" : "pointer"
265
+ },
266
+ children: isLoading ? "Sending..." : "Send Transaction"
267
+ }
268
+ )
269
+ ] })
270
+ ] });
271
+ }
272
+ function useSkus(params = {}) {
273
+ const { chipiSDK } = useChipiContext();
274
+ const { enabled = true, ...queryParams } = params;
275
+ return reactQuery.useQuery({
276
+ queryKey: ["skus", queryParams],
277
+ queryFn: () => chipiSDK.skus.findSkus(queryParams),
278
+ enabled
279
+ });
280
+ }
281
+ function SkuList({ categories, onSkuSelect, className }) {
282
+ const { data: skus, isLoading, isError, error } = useSkus({ categories });
283
+ if (isLoading) {
284
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: "Loading SKUs..." });
285
+ }
286
+ if (isError) {
287
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { color: "red" }, children: [
288
+ "Error loading SKUs: ",
289
+ error?.message
290
+ ] }) });
291
+ }
292
+ if (!skus || skus.length === 0) {
293
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "No SKUs available." }) });
294
+ }
295
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
296
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { children: "Available SKUs" }),
297
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "grid", gap: "1rem", gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))" }, children: skus.map((sku) => /* @__PURE__ */ jsxRuntime.jsxs(
298
+ "div",
299
+ {
300
+ style: {
301
+ border: "1px solid #ddd",
302
+ borderRadius: "0.5rem",
303
+ padding: "1rem",
304
+ backgroundColor: "white",
305
+ cursor: onSkuSelect ? "pointer" : "default"
306
+ },
307
+ onClick: () => onSkuSelect?.(sku),
308
+ children: [
309
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginBottom: "0.5rem" }, children: /* @__PURE__ */ jsxRuntime.jsx("h4", { style: { margin: 0, fontSize: "1.1rem" }, children: sku.name }) }),
310
+ sku.description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginBottom: "0.5rem", color: "#666", fontSize: "0.9rem" }, children: sku.description }),
311
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginBottom: "0.5rem" }, children: /* @__PURE__ */ jsxRuntime.jsx(
312
+ "span",
313
+ {
314
+ style: {
315
+ backgroundColor: "#f0f0f0",
316
+ padding: "0.25rem 0.5rem",
317
+ borderRadius: "0.25rem",
318
+ fontSize: "0.8rem",
319
+ color: "#666"
320
+ },
321
+ children: sku.category
322
+ }
323
+ ) }),
324
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
325
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "1.2rem", fontWeight: "bold" }, children: shared.formatCurrency(sku.price, sku.currency) }),
326
+ /* @__PURE__ */ jsxRuntime.jsx(
327
+ "div",
328
+ {
329
+ style: {
330
+ color: sku.isActive ? "green" : "red",
331
+ fontSize: "0.9rem",
332
+ fontWeight: "bold"
333
+ },
334
+ children: sku.isActive ? "Available" : "Unavailable"
335
+ }
336
+ )
337
+ ] })
338
+ ]
339
+ },
340
+ sku.id
341
+ )) })
342
+ ] });
343
+ }
344
+ function usePurchaseSku() {
345
+ const { chipiSDK } = useChipiContext();
346
+ const mutation = reactQuery.useMutation({
347
+ mutationFn: (params) => chipiSDK.skus.purchaseSku(params)
348
+ });
349
+ return {
350
+ purchaseSku: mutation.mutate,
351
+ purchaseSkuAsync: mutation.mutateAsync,
352
+ data: mutation.data,
353
+ isLoading: mutation.isPending,
354
+ isError: mutation.isError,
355
+ error: mutation.error,
356
+ isSuccess: mutation.isSuccess,
357
+ reset: mutation.reset
358
+ };
359
+ }
360
+ function SkuPurchaseForm({
361
+ sku,
362
+ walletAddress,
363
+ onPurchaseComplete,
364
+ className
365
+ }) {
366
+ const [chain, setChain] = React2.useState("STARKNET_MAINNET");
367
+ const [chainToken, setChainToken] = React2.useState("USDC");
368
+ const [reference, setReference] = React2.useState("");
369
+ const [transactionHash, setTransactionHash] = React2.useState("");
370
+ const { purchaseSku, isLoading, isError, error, data, isSuccess } = usePurchaseSku();
371
+ const handleSubmit = (e) => {
372
+ e.preventDefault();
373
+ if (!reference || !transactionHash) return;
374
+ purchaseSku({
375
+ skuId: sku.id,
376
+ walletAddress,
377
+ chain,
378
+ chainToken,
379
+ mxnAmount: sku.price,
380
+ reference,
381
+ transactionHash
382
+ });
383
+ };
384
+ React2__default.default.useEffect(() => {
385
+ if (isSuccess && data && onPurchaseComplete) {
386
+ onPurchaseComplete(data.transaction.transactionHash);
387
+ }
388
+ }, [isSuccess, data, onPurchaseComplete]);
389
+ if (!sku.isActive) {
390
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "red", textAlign: "center", padding: "2rem" }, children: "This SKU is currently unavailable for purchase." }) });
391
+ }
392
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
393
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { children: "Purchase SKU" }),
394
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1.5rem", padding: "1rem", backgroundColor: "#f9f9f9", borderRadius: "0.5rem" }, children: [
395
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { style: { margin: "0 0 0.5rem 0" }, children: sku.name }),
396
+ sku.description && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0 0 0.5rem 0", color: "#666" }, children: sku.description }),
397
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: "1.2rem", fontWeight: "bold" }, children: [
398
+ "Price: ",
399
+ shared.formatCurrency(sku.price, sku.currency)
400
+ ] })
401
+ ] }),
402
+ isError && error && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { color: "red", marginBottom: "1rem" }, children: [
403
+ "Error: ",
404
+ error.message
405
+ ] }),
406
+ isSuccess && data && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { color: "green", marginBottom: "1rem" }, children: [
407
+ "Purchase successful! Transaction: ",
408
+ data.transaction.transactionHash
409
+ ] }),
410
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
411
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
412
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "chain", children: "Chain:" }),
413
+ /* @__PURE__ */ jsxRuntime.jsxs(
414
+ "select",
415
+ {
416
+ id: "chain",
417
+ value: chain,
418
+ onChange: (e) => setChain(e.target.value),
419
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" },
420
+ children: [
421
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "STARKNET_MAINNET", children: "Starknet Mainnet" }),
422
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "STARKNET_SEPOLIA", children: "Starknet Sepolia" })
423
+ ]
424
+ }
425
+ )
426
+ ] }),
427
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
428
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "chainToken", children: "Token:" }),
429
+ /* @__PURE__ */ jsxRuntime.jsxs(
430
+ "select",
431
+ {
432
+ id: "chainToken",
433
+ value: chainToken,
434
+ onChange: (e) => setChainToken(e.target.value),
435
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" },
436
+ children: [
437
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "USDC", children: "USDC" }),
438
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "USDT", children: "USDT" }),
439
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "ETH", children: "ETH" }),
440
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "STRK", children: "STRK" }),
441
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "DAI", children: "DAI" })
442
+ ]
443
+ }
444
+ )
445
+ ] }),
446
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
447
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "reference", children: "Reference:" }),
448
+ /* @__PURE__ */ jsxRuntime.jsx(
449
+ "input",
450
+ {
451
+ id: "reference",
452
+ type: "text",
453
+ value: reference,
454
+ onChange: (e) => setReference(e.target.value),
455
+ placeholder: "Transaction reference",
456
+ required: true,
457
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
458
+ }
459
+ )
460
+ ] }),
461
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
462
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "transactionHash", children: "Transaction Hash:" }),
463
+ /* @__PURE__ */ jsxRuntime.jsx(
464
+ "input",
465
+ {
466
+ id: "transactionHash",
467
+ type: "text",
468
+ value: transactionHash,
469
+ onChange: (e) => setTransactionHash(e.target.value),
470
+ placeholder: "0x...",
471
+ required: true,
472
+ style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
473
+ }
474
+ )
475
+ ] }),
476
+ /* @__PURE__ */ jsxRuntime.jsx(
477
+ "button",
478
+ {
479
+ type: "submit",
480
+ disabled: isLoading || !reference || !transactionHash,
481
+ style: {
482
+ width: "100%",
483
+ padding: "0.75rem",
484
+ backgroundColor: isLoading ? "#ccc" : "#28a745",
485
+ color: "white",
486
+ border: "none",
487
+ borderRadius: "0.25rem",
488
+ fontSize: "1rem",
489
+ cursor: isLoading ? "not-allowed" : "pointer"
490
+ },
491
+ children: isLoading ? "Processing..." : `Purchase for ${shared.formatCurrency(sku.price, sku.currency)}`
492
+ }
493
+ )
494
+ ] })
495
+ ] });
496
+ }
497
+
498
+ exports.SkuList = SkuList;
499
+ exports.SkuPurchaseForm = SkuPurchaseForm;
500
+ exports.TransactionForm = TransactionForm;
501
+ exports.WalletBalance = WalletBalance;
502
+ exports.WalletCreator = WalletCreator;
503
+ //# sourceMappingURL=components.js.map
504
+ //# sourceMappingURL=components.js.map