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