@chipi-stack/chipi-react 0.1.0 → 0.2.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/hooks.d.mts +29 -65
- package/dist/hooks.d.ts +29 -65
- package/dist/hooks.js +32 -51
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +33 -49
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +30 -471
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -466
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/components.d.mts +0 -60
- package/dist/components.d.ts +0 -60
- package/dist/components.js +0 -504
- package/dist/components.js.map +0 -1
- package/dist/components.mjs +0 -494
- package/dist/components.mjs.map +0 -1
package/dist/components.mjs
DELETED
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
import React2, { createContext, useState, useContext } from 'react';
|
|
2
|
-
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
3
|
-
import '@chipi-stack/backend';
|
|
4
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
|
-
import { formatAddress, formatCurrency } from '@chipi-stack/shared';
|
|
6
|
-
|
|
7
|
-
// src/components/WalletCreator.tsx
|
|
8
|
-
var ChipiContext = createContext(null);
|
|
9
|
-
function useChipiContext() {
|
|
10
|
-
const context = useContext(ChipiContext);
|
|
11
|
-
if (!context) {
|
|
12
|
-
throw new Error("useChipiContext must be used within a ChipiProvider");
|
|
13
|
-
}
|
|
14
|
-
return context;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// src/hooks/useCreateWallet.ts
|
|
18
|
-
function useCreateWallet() {
|
|
19
|
-
const { chipiSDK } = useChipiContext();
|
|
20
|
-
const mutation = useMutation({
|
|
21
|
-
mutationFn: (params) => chipiSDK.createWallet(params)
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
createWallet: mutation.mutate,
|
|
25
|
-
createWalletAsync: mutation.mutateAsync,
|
|
26
|
-
data: mutation.data,
|
|
27
|
-
isLoading: mutation.isPending,
|
|
28
|
-
isError: mutation.isError,
|
|
29
|
-
error: mutation.error,
|
|
30
|
-
isSuccess: mutation.isSuccess,
|
|
31
|
-
reset: mutation.reset
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function WalletCreator({ onWalletCreated, className, children }) {
|
|
35
|
-
const [encryptKey, setEncryptKey] = useState("");
|
|
36
|
-
const [bearerToken, setBearerToken] = useState("");
|
|
37
|
-
const { createWallet, isLoading, isError, error, data, isSuccess } = useCreateWallet();
|
|
38
|
-
const handleSubmit = (e) => {
|
|
39
|
-
e.preventDefault();
|
|
40
|
-
if (!encryptKey || !bearerToken) return;
|
|
41
|
-
createWallet({
|
|
42
|
-
encryptKey,
|
|
43
|
-
bearerToken
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
React2.useEffect(() => {
|
|
47
|
-
if (isSuccess && data && onWalletCreated) {
|
|
48
|
-
onWalletCreated(data);
|
|
49
|
-
}
|
|
50
|
-
}, [isSuccess, data, onWalletCreated]);
|
|
51
|
-
if (children) {
|
|
52
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
53
|
-
}
|
|
54
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
55
|
-
/* @__PURE__ */ jsx("h2", { children: "Create Wallet" }),
|
|
56
|
-
isError && error && /* @__PURE__ */ jsxs("div", { style: { color: "red", marginBottom: "1rem" }, children: [
|
|
57
|
-
"Error: ",
|
|
58
|
-
error.message
|
|
59
|
-
] }),
|
|
60
|
-
isSuccess && data && /* @__PURE__ */ jsxs("div", { style: { color: "green", marginBottom: "1rem" }, children: [
|
|
61
|
-
"Wallet created successfully! Address: ",
|
|
62
|
-
data.walletPublicKey
|
|
63
|
-
] }),
|
|
64
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
65
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
66
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "encryptKey", children: "Encrypt Key:" }),
|
|
67
|
-
/* @__PURE__ */ jsx(
|
|
68
|
-
"input",
|
|
69
|
-
{
|
|
70
|
-
id: "encryptKey",
|
|
71
|
-
type: "password",
|
|
72
|
-
value: encryptKey,
|
|
73
|
-
onChange: (e) => setEncryptKey(e.target.value),
|
|
74
|
-
required: true,
|
|
75
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
] }),
|
|
79
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
80
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "bearerToken", children: "Bearer Token:" }),
|
|
81
|
-
/* @__PURE__ */ jsx(
|
|
82
|
-
"input",
|
|
83
|
-
{
|
|
84
|
-
id: "bearerToken",
|
|
85
|
-
type: "text",
|
|
86
|
-
value: bearerToken,
|
|
87
|
-
onChange: (e) => setBearerToken(e.target.value),
|
|
88
|
-
required: true,
|
|
89
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
|
|
90
|
-
}
|
|
91
|
-
)
|
|
92
|
-
] }),
|
|
93
|
-
/* @__PURE__ */ jsx(
|
|
94
|
-
"button",
|
|
95
|
-
{
|
|
96
|
-
type: "submit",
|
|
97
|
-
disabled: isLoading || !encryptKey || !bearerToken,
|
|
98
|
-
style: {
|
|
99
|
-
padding: "0.75rem 1.5rem",
|
|
100
|
-
backgroundColor: isLoading ? "#ccc" : "#007bff",
|
|
101
|
-
color: "white",
|
|
102
|
-
border: "none",
|
|
103
|
-
borderRadius: "0.25rem",
|
|
104
|
-
cursor: isLoading ? "not-allowed" : "pointer"
|
|
105
|
-
},
|
|
106
|
-
children: isLoading ? "Creating..." : "Create Wallet"
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
] })
|
|
110
|
-
] });
|
|
111
|
-
}
|
|
112
|
-
function WalletBalance({
|
|
113
|
-
address,
|
|
114
|
-
balance,
|
|
115
|
-
currency = "USD",
|
|
116
|
-
isLoading = false,
|
|
117
|
-
className
|
|
118
|
-
}) {
|
|
119
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
120
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "0.5rem" }, children: [
|
|
121
|
-
/* @__PURE__ */ jsx("strong", { children: "Wallet:" }),
|
|
122
|
-
" ",
|
|
123
|
-
formatAddress(address)
|
|
124
|
-
] }),
|
|
125
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
126
|
-
/* @__PURE__ */ jsx("strong", { children: "Balance:" }),
|
|
127
|
-
" ",
|
|
128
|
-
isLoading ? /* @__PURE__ */ jsx("span", { children: "Loading..." }) : balance !== void 0 ? formatCurrency(balance, currency) : /* @__PURE__ */ jsx("span", { children: "--" })
|
|
129
|
-
] })
|
|
130
|
-
] });
|
|
131
|
-
}
|
|
132
|
-
function useTransfer() {
|
|
133
|
-
const { chipiSDK } = useChipiContext();
|
|
134
|
-
const mutation = useMutation({
|
|
135
|
-
mutationFn: (params) => chipiSDK.transfer(params)
|
|
136
|
-
});
|
|
137
|
-
return {
|
|
138
|
-
transfer: mutation.mutate,
|
|
139
|
-
transferAsync: mutation.mutateAsync,
|
|
140
|
-
data: mutation.data,
|
|
141
|
-
isLoading: mutation.isPending,
|
|
142
|
-
isError: mutation.isError,
|
|
143
|
-
error: mutation.error,
|
|
144
|
-
isSuccess: mutation.isSuccess,
|
|
145
|
-
reset: mutation.reset
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function TransactionForm({
|
|
149
|
-
wallet,
|
|
150
|
-
encryptKey,
|
|
151
|
-
bearerToken,
|
|
152
|
-
onTransactionComplete,
|
|
153
|
-
className
|
|
154
|
-
}) {
|
|
155
|
-
const [contractAddress, setContractAddress] = useState("");
|
|
156
|
-
const [recipient, setRecipient] = useState("");
|
|
157
|
-
const [amount, setAmount] = useState("");
|
|
158
|
-
const [decimals, setDecimals] = useState(18);
|
|
159
|
-
const { transfer, isLoading, isError, error, data, isSuccess } = useTransfer();
|
|
160
|
-
const handleSubmit = (e) => {
|
|
161
|
-
e.preventDefault();
|
|
162
|
-
if (!contractAddress || !recipient || !amount) return;
|
|
163
|
-
transfer({
|
|
164
|
-
encryptKey,
|
|
165
|
-
wallet,
|
|
166
|
-
contractAddress,
|
|
167
|
-
recipient,
|
|
168
|
-
amount: parseFloat(amount),
|
|
169
|
-
decimals,
|
|
170
|
-
bearerToken
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
React2.useEffect(() => {
|
|
174
|
-
if (isSuccess && data && onTransactionComplete) {
|
|
175
|
-
onTransactionComplete(data);
|
|
176
|
-
}
|
|
177
|
-
}, [isSuccess, data, onTransactionComplete]);
|
|
178
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
179
|
-
/* @__PURE__ */ jsx("h3", { children: "Transfer Tokens" }),
|
|
180
|
-
isError && error && /* @__PURE__ */ jsxs("div", { style: { color: "red", marginBottom: "1rem" }, children: [
|
|
181
|
-
"Error: ",
|
|
182
|
-
error.message
|
|
183
|
-
] }),
|
|
184
|
-
isSuccess && data && /* @__PURE__ */ jsxs("div", { style: { color: "green", marginBottom: "1rem" }, children: [
|
|
185
|
-
"Transaction successful! Hash: ",
|
|
186
|
-
data
|
|
187
|
-
] }),
|
|
188
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
189
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
190
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "contractAddress", children: "Token Contract:" }),
|
|
191
|
-
/* @__PURE__ */ jsx(
|
|
192
|
-
"input",
|
|
193
|
-
{
|
|
194
|
-
id: "contractAddress",
|
|
195
|
-
type: "text",
|
|
196
|
-
value: contractAddress,
|
|
197
|
-
onChange: (e) => setContractAddress(e.target.value),
|
|
198
|
-
placeholder: "0x...",
|
|
199
|
-
required: true,
|
|
200
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
|
|
201
|
-
}
|
|
202
|
-
)
|
|
203
|
-
] }),
|
|
204
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
205
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "recipient", children: "Recipient:" }),
|
|
206
|
-
/* @__PURE__ */ jsx(
|
|
207
|
-
"input",
|
|
208
|
-
{
|
|
209
|
-
id: "recipient",
|
|
210
|
-
type: "text",
|
|
211
|
-
value: recipient,
|
|
212
|
-
onChange: (e) => setRecipient(e.target.value),
|
|
213
|
-
placeholder: "0x...",
|
|
214
|
-
required: true,
|
|
215
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
|
|
216
|
-
}
|
|
217
|
-
)
|
|
218
|
-
] }),
|
|
219
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
220
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "amount", children: "Amount:" }),
|
|
221
|
-
/* @__PURE__ */ jsx(
|
|
222
|
-
"input",
|
|
223
|
-
{
|
|
224
|
-
id: "amount",
|
|
225
|
-
type: "number",
|
|
226
|
-
step: "any",
|
|
227
|
-
value: amount,
|
|
228
|
-
onChange: (e) => setAmount(e.target.value),
|
|
229
|
-
required: true,
|
|
230
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
|
|
231
|
-
}
|
|
232
|
-
)
|
|
233
|
-
] }),
|
|
234
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
235
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "decimals", children: "Decimals:" }),
|
|
236
|
-
/* @__PURE__ */ jsx(
|
|
237
|
-
"input",
|
|
238
|
-
{
|
|
239
|
-
id: "decimals",
|
|
240
|
-
type: "number",
|
|
241
|
-
value: decimals,
|
|
242
|
-
onChange: (e) => setDecimals(parseInt(e.target.value)),
|
|
243
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
|
|
244
|
-
}
|
|
245
|
-
)
|
|
246
|
-
] }),
|
|
247
|
-
/* @__PURE__ */ jsx(
|
|
248
|
-
"button",
|
|
249
|
-
{
|
|
250
|
-
type: "submit",
|
|
251
|
-
disabled: isLoading || !contractAddress || !recipient || !amount,
|
|
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 ? "Sending..." : "Send Transaction"
|
|
261
|
-
}
|
|
262
|
-
)
|
|
263
|
-
] })
|
|
264
|
-
] });
|
|
265
|
-
}
|
|
266
|
-
function useSkus(params = {}) {
|
|
267
|
-
const { chipiSDK } = useChipiContext();
|
|
268
|
-
const { enabled = true, ...queryParams } = params;
|
|
269
|
-
return useQuery({
|
|
270
|
-
queryKey: ["skus", queryParams],
|
|
271
|
-
queryFn: () => chipiSDK.skus.findSkus(queryParams),
|
|
272
|
-
enabled
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
function SkuList({ categories, onSkuSelect, className }) {
|
|
276
|
-
const { data: skus, isLoading, isError, error } = useSkus({ categories });
|
|
277
|
-
if (isLoading) {
|
|
278
|
-
return /* @__PURE__ */ jsx("div", { className, children: "Loading SKUs..." });
|
|
279
|
-
}
|
|
280
|
-
if (isError) {
|
|
281
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsxs("div", { style: { color: "red" }, children: [
|
|
282
|
-
"Error loading SKUs: ",
|
|
283
|
-
error?.message
|
|
284
|
-
] }) });
|
|
285
|
-
}
|
|
286
|
-
if (!skus || skus.length === 0) {
|
|
287
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx("div", { children: "No SKUs available." }) });
|
|
288
|
-
}
|
|
289
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
290
|
-
/* @__PURE__ */ jsx("h3", { children: "Available SKUs" }),
|
|
291
|
-
/* @__PURE__ */ jsx("div", { style: { display: "grid", gap: "1rem", gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))" }, children: skus.map((sku) => /* @__PURE__ */ jsxs(
|
|
292
|
-
"div",
|
|
293
|
-
{
|
|
294
|
-
style: {
|
|
295
|
-
border: "1px solid #ddd",
|
|
296
|
-
borderRadius: "0.5rem",
|
|
297
|
-
padding: "1rem",
|
|
298
|
-
backgroundColor: "white",
|
|
299
|
-
cursor: onSkuSelect ? "pointer" : "default"
|
|
300
|
-
},
|
|
301
|
-
onClick: () => onSkuSelect?.(sku),
|
|
302
|
-
children: [
|
|
303
|
-
/* @__PURE__ */ jsx("div", { style: { marginBottom: "0.5rem" }, children: /* @__PURE__ */ jsx("h4", { style: { margin: 0, fontSize: "1.1rem" }, children: sku.name }) }),
|
|
304
|
-
sku.description && /* @__PURE__ */ jsx("div", { style: { marginBottom: "0.5rem", color: "#666", fontSize: "0.9rem" }, children: sku.description }),
|
|
305
|
-
/* @__PURE__ */ jsx("div", { style: { marginBottom: "0.5rem" }, children: /* @__PURE__ */ jsx(
|
|
306
|
-
"span",
|
|
307
|
-
{
|
|
308
|
-
style: {
|
|
309
|
-
backgroundColor: "#f0f0f0",
|
|
310
|
-
padding: "0.25rem 0.5rem",
|
|
311
|
-
borderRadius: "0.25rem",
|
|
312
|
-
fontSize: "0.8rem",
|
|
313
|
-
color: "#666"
|
|
314
|
-
},
|
|
315
|
-
children: sku.category
|
|
316
|
-
}
|
|
317
|
-
) }),
|
|
318
|
-
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
319
|
-
/* @__PURE__ */ jsx("div", { style: { fontSize: "1.2rem", fontWeight: "bold" }, children: formatCurrency(sku.price, sku.currency) }),
|
|
320
|
-
/* @__PURE__ */ jsx(
|
|
321
|
-
"div",
|
|
322
|
-
{
|
|
323
|
-
style: {
|
|
324
|
-
color: sku.isActive ? "green" : "red",
|
|
325
|
-
fontSize: "0.9rem",
|
|
326
|
-
fontWeight: "bold"
|
|
327
|
-
},
|
|
328
|
-
children: sku.isActive ? "Available" : "Unavailable"
|
|
329
|
-
}
|
|
330
|
-
)
|
|
331
|
-
] })
|
|
332
|
-
]
|
|
333
|
-
},
|
|
334
|
-
sku.id
|
|
335
|
-
)) })
|
|
336
|
-
] });
|
|
337
|
-
}
|
|
338
|
-
function usePurchaseSku() {
|
|
339
|
-
const { chipiSDK } = useChipiContext();
|
|
340
|
-
const mutation = useMutation({
|
|
341
|
-
mutationFn: (params) => chipiSDK.skus.purchaseSku(params)
|
|
342
|
-
});
|
|
343
|
-
return {
|
|
344
|
-
purchaseSku: mutation.mutate,
|
|
345
|
-
purchaseSkuAsync: mutation.mutateAsync,
|
|
346
|
-
data: mutation.data,
|
|
347
|
-
isLoading: mutation.isPending,
|
|
348
|
-
isError: mutation.isError,
|
|
349
|
-
error: mutation.error,
|
|
350
|
-
isSuccess: mutation.isSuccess,
|
|
351
|
-
reset: mutation.reset
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
function SkuPurchaseForm({
|
|
355
|
-
sku,
|
|
356
|
-
walletAddress,
|
|
357
|
-
onPurchaseComplete,
|
|
358
|
-
className
|
|
359
|
-
}) {
|
|
360
|
-
const [chain, setChain] = useState("STARKNET_MAINNET");
|
|
361
|
-
const [chainToken, setChainToken] = useState("USDC");
|
|
362
|
-
const [reference, setReference] = useState("");
|
|
363
|
-
const [transactionHash, setTransactionHash] = useState("");
|
|
364
|
-
const { purchaseSku, isLoading, isError, error, data, isSuccess } = usePurchaseSku();
|
|
365
|
-
const handleSubmit = (e) => {
|
|
366
|
-
e.preventDefault();
|
|
367
|
-
if (!reference || !transactionHash) return;
|
|
368
|
-
purchaseSku({
|
|
369
|
-
skuId: sku.id,
|
|
370
|
-
walletAddress,
|
|
371
|
-
chain,
|
|
372
|
-
chainToken,
|
|
373
|
-
mxnAmount: sku.price,
|
|
374
|
-
reference,
|
|
375
|
-
transactionHash
|
|
376
|
-
});
|
|
377
|
-
};
|
|
378
|
-
React2.useEffect(() => {
|
|
379
|
-
if (isSuccess && data && onPurchaseComplete) {
|
|
380
|
-
onPurchaseComplete(data.transaction.transactionHash);
|
|
381
|
-
}
|
|
382
|
-
}, [isSuccess, data, onPurchaseComplete]);
|
|
383
|
-
if (!sku.isActive) {
|
|
384
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx("div", { style: { color: "red", textAlign: "center", padding: "2rem" }, children: "This SKU is currently unavailable for purchase." }) });
|
|
385
|
-
}
|
|
386
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
387
|
-
/* @__PURE__ */ jsx("h3", { children: "Purchase SKU" }),
|
|
388
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1.5rem", padding: "1rem", backgroundColor: "#f9f9f9", borderRadius: "0.5rem" }, children: [
|
|
389
|
-
/* @__PURE__ */ jsx("h4", { style: { margin: "0 0 0.5rem 0" }, children: sku.name }),
|
|
390
|
-
sku.description && /* @__PURE__ */ jsx("p", { style: { margin: "0 0 0.5rem 0", color: "#666" }, children: sku.description }),
|
|
391
|
-
/* @__PURE__ */ jsxs("div", { style: { fontSize: "1.2rem", fontWeight: "bold" }, children: [
|
|
392
|
-
"Price: ",
|
|
393
|
-
formatCurrency(sku.price, sku.currency)
|
|
394
|
-
] })
|
|
395
|
-
] }),
|
|
396
|
-
isError && error && /* @__PURE__ */ jsxs("div", { style: { color: "red", marginBottom: "1rem" }, children: [
|
|
397
|
-
"Error: ",
|
|
398
|
-
error.message
|
|
399
|
-
] }),
|
|
400
|
-
isSuccess && data && /* @__PURE__ */ jsxs("div", { style: { color: "green", marginBottom: "1rem" }, children: [
|
|
401
|
-
"Purchase successful! Transaction: ",
|
|
402
|
-
data.transaction.transactionHash
|
|
403
|
-
] }),
|
|
404
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
405
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
406
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "chain", children: "Chain:" }),
|
|
407
|
-
/* @__PURE__ */ jsxs(
|
|
408
|
-
"select",
|
|
409
|
-
{
|
|
410
|
-
id: "chain",
|
|
411
|
-
value: chain,
|
|
412
|
-
onChange: (e) => setChain(e.target.value),
|
|
413
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" },
|
|
414
|
-
children: [
|
|
415
|
-
/* @__PURE__ */ jsx("option", { value: "STARKNET_MAINNET", children: "Starknet Mainnet" }),
|
|
416
|
-
/* @__PURE__ */ jsx("option", { value: "STARKNET_SEPOLIA", children: "Starknet Sepolia" })
|
|
417
|
-
]
|
|
418
|
-
}
|
|
419
|
-
)
|
|
420
|
-
] }),
|
|
421
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
422
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "chainToken", children: "Token:" }),
|
|
423
|
-
/* @__PURE__ */ jsxs(
|
|
424
|
-
"select",
|
|
425
|
-
{
|
|
426
|
-
id: "chainToken",
|
|
427
|
-
value: chainToken,
|
|
428
|
-
onChange: (e) => setChainToken(e.target.value),
|
|
429
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" },
|
|
430
|
-
children: [
|
|
431
|
-
/* @__PURE__ */ jsx("option", { value: "USDC", children: "USDC" }),
|
|
432
|
-
/* @__PURE__ */ jsx("option", { value: "USDT", children: "USDT" }),
|
|
433
|
-
/* @__PURE__ */ jsx("option", { value: "ETH", children: "ETH" }),
|
|
434
|
-
/* @__PURE__ */ jsx("option", { value: "STRK", children: "STRK" }),
|
|
435
|
-
/* @__PURE__ */ jsx("option", { value: "DAI", children: "DAI" })
|
|
436
|
-
]
|
|
437
|
-
}
|
|
438
|
-
)
|
|
439
|
-
] }),
|
|
440
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
441
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "reference", children: "Reference:" }),
|
|
442
|
-
/* @__PURE__ */ jsx(
|
|
443
|
-
"input",
|
|
444
|
-
{
|
|
445
|
-
id: "reference",
|
|
446
|
-
type: "text",
|
|
447
|
-
value: reference,
|
|
448
|
-
onChange: (e) => setReference(e.target.value),
|
|
449
|
-
placeholder: "Transaction reference",
|
|
450
|
-
required: true,
|
|
451
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
|
|
452
|
-
}
|
|
453
|
-
)
|
|
454
|
-
] }),
|
|
455
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
456
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "transactionHash", children: "Transaction Hash:" }),
|
|
457
|
-
/* @__PURE__ */ jsx(
|
|
458
|
-
"input",
|
|
459
|
-
{
|
|
460
|
-
id: "transactionHash",
|
|
461
|
-
type: "text",
|
|
462
|
-
value: transactionHash,
|
|
463
|
-
onChange: (e) => setTransactionHash(e.target.value),
|
|
464
|
-
placeholder: "0x...",
|
|
465
|
-
required: true,
|
|
466
|
-
style: { width: "100%", padding: "0.5rem", marginTop: "0.25rem" }
|
|
467
|
-
}
|
|
468
|
-
)
|
|
469
|
-
] }),
|
|
470
|
-
/* @__PURE__ */ jsx(
|
|
471
|
-
"button",
|
|
472
|
-
{
|
|
473
|
-
type: "submit",
|
|
474
|
-
disabled: isLoading || !reference || !transactionHash,
|
|
475
|
-
style: {
|
|
476
|
-
width: "100%",
|
|
477
|
-
padding: "0.75rem",
|
|
478
|
-
backgroundColor: isLoading ? "#ccc" : "#28a745",
|
|
479
|
-
color: "white",
|
|
480
|
-
border: "none",
|
|
481
|
-
borderRadius: "0.25rem",
|
|
482
|
-
fontSize: "1rem",
|
|
483
|
-
cursor: isLoading ? "not-allowed" : "pointer"
|
|
484
|
-
},
|
|
485
|
-
children: isLoading ? "Processing..." : `Purchase for ${formatCurrency(sku.price, sku.currency)}`
|
|
486
|
-
}
|
|
487
|
-
)
|
|
488
|
-
] })
|
|
489
|
-
] });
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
export { SkuList, SkuPurchaseForm, TransactionForm, WalletBalance, WalletCreator };
|
|
493
|
-
//# sourceMappingURL=components.mjs.map
|
|
494
|
-
//# sourceMappingURL=components.mjs.map
|
package/dist/components.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context/ChipiProvider.tsx","../src/hooks/useCreateWallet.ts","../src/components/WalletCreator.tsx","../src/components/WalletBalance.tsx","../src/hooks/useTransfer.ts","../src/components/TransactionForm.tsx","../src/hooks/useSkus.ts","../src/components/SkuList.tsx","../src/hooks/usePurchaseSku.ts","../src/components/SkuPurchaseForm.tsx"],"names":["React","jsx","jsxs","useMutation","useState","formatCurrency"],"mappings":";;;;;;;AASA,IAAM,YAAA,GAAe,cAAwC,IAAI,CAAA;AA+B1D,SAAS,eAAA,GAAqC;AACnD,EAAA,MAAM,OAAA,GAAU,WAAW,YAAY,CAAA;AAEvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AAEA,EAAA,OAAO,OAAA;AACT;;;ACvCO,SAAS,eAAA,GASd;AACA,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,eAAA,EAAgB;AAErC,EAAA,MAAM,WAA8E,WAAA,CAAY;AAAA,IAC9F,UAAA,EAAY,CAAC,MAAA,KAA8B,QAAA,CAAS,aAAa,MAAM;AAAA,GACxE,CAAA;AAED,EAAA,OAAO;AAAA,IACL,cAAc,QAAA,CAAS,MAAA;AAAA,IACvB,mBAAmB,QAAA,CAAS,WA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YACP,UAAU,CAAC,CAAA,KAAM,kBAAA,CAAmB,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,YAClD,WAAA,EAAY,OAAA;AAAA,YACZ,QAAA,EAAQ,IAAA;AAAA,YACR,OAAO,EAAE,KAAA,EAAO,QAAQ,OAAA,EAAS,QAAA,EAAU,WAAW,SAAA;AAAU;AAAA;AAClE,OAAA,EACF,CAAA;AAAA,sBAEAA,GAAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,QAAA,EAAU,SAAA,IAAa,CAAC,SAAA,IAAa,CAAC,eAAA;AAAA,UACtC,KAAA,EAAO;AAAA,YACL,KAAA,EAAO,MAAA;AAAA,YACP,OAAA,EAAS,SAAA;AAAA,YACT,eAAA,EAAiB,YAAY,MAAA,GAAS,SAAA;AAAA,YACtC,KAAA,EAAO,OAAA;AAAA,YACP,MAAA,EAAQ,MAAA;AAAA,YACR,YAAA,EAAc,SAAA;AAAA,YACd,QAAA,EAAU,MAAA;AAAA,YACV,MAAA,EAAQ,YAAY,aAAA,GAAgB;AAAA,WACtC;AAAA,UAEC,QAAA,EAAA,SAAA,GAAY,kBAAkB,CAAA,aAAA,EAAgBI,cAAAA,CAAe,IAAI,KAAA,EAAO,GAAA,CAAI,QAAQ,CAAC,CAAA;AAAA;AAAA;AACxF,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"components.mjs","sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport { ChipiSDK } from '@chipi-stack/backend';\nimport type { ChipiSDKConfig } from '@chipi-stack/types';\n\ninterface ChipiContextValue {\n chipiSDK: ChipiSDK;\n config: ChipiSDKConfig;\n}\n\nconst ChipiContext = createContext<ChipiContextValue | null>(null);\n\ninterface ChipiProviderProps {\n children: ReactNode;\n config: ChipiSDKConfig;\n}\n\n/**\n * Provider component that wraps your app and provides Chipi SDK context\n */\nexport function ChipiProvider({ children, config }: ChipiProviderProps) {\n const chipiSDK = React.useMemo(() => new ChipiSDK(config), [config]);\n\n const value = React.useMemo(\n () => ({\n chipiSDK,\n config,\n }),\n [chipiSDK, config]\n );\n\n return (\n <ChipiContext.Provider value={value}>\n {children}\n </ChipiContext.Provider>\n );\n}\n\n/**\n * Hook to access Chipi SDK context\n */\nexport function useChipiContext(): ChipiContextValue {\n const context = useContext(ChipiContext);\n \n if (!context) {\n throw new Error('useChipiContext must be used within a ChipiProvider');\n }\n \n return context;\n}\n","import { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { useChipiContext } from '../context';\nimport type { CreateWalletParams, CreateWalletResponse } from '@chipi-stack/types';\n\ntype CreateWalletInput = Omit<CreateWalletParams, 'apiPublicKey' | 'nodeUrl'>;\n\n/**\n * Hook for creating a new wallet\n */\nexport function useCreateWallet(): {\n createWallet: (params: CreateWalletInput) => void;\n createWalletAsync: (params: CreateWalletInput) => Promise<CreateWalletResponse>;\n data: CreateWalletResponse | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<CreateWalletResponse, Error, CreateWalletInput> = useMutation({\n mutationFn: (params: CreateWalletInput) => chipiSDK.createWallet(params),\n });\n\n return {\n createWallet: mutation.mutate,\n createWalletAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import React, { useState } from 'react';\nimport { useCreateWallet } from '../hooks/useCreateWallet';\nimport type { CreateWalletResponse } from '@chipi-stack/types';\n\ninterface WalletCreatorProps {\n onWalletCreated?: (wallet: CreateWalletResponse) => void;\n className?: string;\n children?: React.ReactNode;\n}\n\n/**\n * Component for creating a new wallet\n */\nexport function WalletCreator({ onWalletCreated, className, children }: WalletCreatorProps) {\n const [encryptKey, setEncryptKey] = useState('');\n const [bearerToken, setBearerToken] = useState('');\n\n const { createWallet, isLoading, isError, error, data, isSuccess } = useCreateWallet();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n if (!encryptKey || !bearerToken) return;\n\n createWallet({\n encryptKey,\n bearerToken,\n });\n };\n\n React.useEffect(() => {\n if (isSuccess && data && onWalletCreated) {\n onWalletCreated(data);\n }\n }, [isSuccess, data, onWalletCreated]);\n\n if (children) {\n return (\n <>\n {children}\n </>\n );\n }\n\n return (\n <div className={className}>\n <h2>Create Wallet</h2>\n \n {isError && error && (\n <div style={{ color: 'red', marginBottom: '1rem' }}>\n Error: {error.message}\n </div>\n )}\n\n {isSuccess && data && (\n <div style={{ color: 'green', marginBottom: '1rem' }}>\n Wallet created successfully! Address: {data.walletPublicKey}\n </div>\n )}\n\n <form onSubmit={handleSubmit}>\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"encryptKey\">Encrypt Key:</label>\n <input\n id=\"encryptKey\"\n type=\"password\"\n value={encryptKey}\n onChange={(e) => setEncryptKey(e.target.value)}\n required\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n />\n </div>\n\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"bearerToken\">Bearer Token:</label>\n <input\n id=\"bearerToken\"\n type=\"text\"\n value={bearerToken}\n onChange={(e) => setBearerToken(e.target.value)}\n required\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n />\n </div>\n\n <button\n type=\"submit\"\n disabled={isLoading || !encryptKey || !bearerToken}\n style={{\n padding: '0.75rem 1.5rem',\n backgroundColor: isLoading ? '#ccc' : '#007bff',\n color: 'white',\n border: 'none',\n borderRadius: '0.25rem',\n cursor: isLoading ? 'not-allowed' : 'pointer',\n }}\n >\n {isLoading ? 'Creating...' : 'Create Wallet'}\n </button>\n </form>\n </div>\n );\n}\n","import React from 'react';\nimport { formatCurrency, formatAddress } from '@chipi-stack/shared';\n\ninterface WalletBalanceProps {\n address: string;\n balance?: number;\n currency?: string;\n isLoading?: boolean;\n className?: string;\n}\n\n/**\n * Component for displaying wallet balance\n */\nexport function WalletBalance({\n address,\n balance,\n currency = 'USD',\n isLoading = false,\n className,\n}: WalletBalanceProps) {\n return (\n <div className={className}>\n <div style={{ marginBottom: '0.5rem' }}>\n <strong>Wallet:</strong> {formatAddress(address)}\n </div>\n \n <div>\n <strong>Balance:</strong>{' '}\n {isLoading ? (\n <span>Loading...</span>\n ) : balance !== undefined ? (\n formatCurrency(balance, currency)\n ) : (\n <span>--</span>\n )}\n </div>\n </div>\n );\n}\n","import { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { useChipiContext } from '../context';\nimport type { TransferParams } from '@chipi-stack/types';\n\ntype TransferInput = Omit<TransferParams, 'apiPublicKey'>;\n\n/**\n * Hook for transferring tokens\n */\nexport function useTransfer(): {\n transfer: (params: TransferInput) => void;\n transferAsync: (params: TransferInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, TransferInput> = useMutation({\n mutationFn: (params: TransferInput) => chipiSDK.transfer(params),\n });\n\n return {\n transfer: mutation.mutate,\n transferAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import React, { useState } from 'react';\nimport { useTransfer } from '../hooks/useTransfer';\nimport type { WalletData } from '@chipi-stack/types';\n\ninterface TransactionFormProps {\n wallet: WalletData;\n encryptKey: string;\n bearerToken: string;\n onTransactionComplete?: (txHash: string) => void;\n className?: string;\n}\n\n/**\n * Component for creating token transfer transactions\n */\nexport function TransactionForm({\n wallet,\n encryptKey,\n bearerToken,\n onTransactionComplete,\n className,\n}: TransactionFormProps) {\n const [contractAddress, setContractAddress] = useState('');\n const [recipient, setRecipient] = useState('');\n const [amount, setAmount] = useState('');\n const [decimals, setDecimals] = useState(18);\n\n const { transfer, isLoading, isError, error, data, isSuccess } = useTransfer();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n if (!contractAddress || !recipient || !amount) return;\n\n transfer({\n encryptKey,\n wallet,\n contractAddress,\n recipient,\n amount: parseFloat(amount),\n decimals,\n bearerToken,\n });\n };\n\n React.useEffect(() => {\n if (isSuccess && data && onTransactionComplete) {\n onTransactionComplete(data);\n }\n }, [isSuccess, data, onTransactionComplete]);\n\n return (\n <div className={className}>\n <h3>Transfer Tokens</h3>\n \n {isError && error && (\n <div style={{ color: 'red', marginBottom: '1rem' }}>\n Error: {error.message}\n </div>\n )}\n\n {isSuccess && data && (\n <div style={{ color: 'green', marginBottom: '1rem' }}>\n Transaction successful! Hash: {data}\n </div>\n )}\n\n <form onSubmit={handleSubmit}>\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"contractAddress\">Token Contract:</label>\n <input\n id=\"contractAddress\"\n type=\"text\"\n value={contractAddress}\n onChange={(e) => setContractAddress(e.target.value)}\n placeholder=\"0x...\"\n required\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n />\n </div>\n\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"recipient\">Recipient:</label>\n <input\n id=\"recipient\"\n type=\"text\"\n value={recipient}\n onChange={(e) => setRecipient(e.target.value)}\n placeholder=\"0x...\"\n required\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n />\n </div>\n\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"amount\">Amount:</label>\n <input\n id=\"amount\"\n type=\"number\"\n step=\"any\"\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n required\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n />\n </div>\n\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"decimals\">Decimals:</label>\n <input\n id=\"decimals\"\n type=\"number\"\n value={decimals}\n onChange={(e) => setDecimals(parseInt(e.target.value))}\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n />\n </div>\n\n <button\n type=\"submit\"\n disabled={isLoading || !contractAddress || !recipient || !amount}\n style={{\n padding: '0.75rem 1.5rem',\n backgroundColor: isLoading ? '#ccc' : '#007bff',\n color: 'white',\n border: 'none',\n borderRadius: '0.25rem',\n cursor: isLoading ? 'not-allowed' : 'pointer',\n }}\n >\n {isLoading ? 'Sending...' : 'Send Transaction'}\n </button>\n </form>\n </div>\n );\n}","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useChipiContext } from '../context';\nimport type { FindSkusParams, Sku } from '@chipi-stack/types';\n\ninterface UseSkusParams extends FindSkusParams {\n enabled?: boolean;\n}\n\n/**\n * Hook for fetching available SKUs\n */\nexport function useSkus(params: UseSkusParams = {}): UseQueryResult<Sku[], Error> {\n const { chipiSDK } = useChipiContext();\n const { enabled = true, ...queryParams } = params;\n\n return useQuery({\n queryKey: ['skus', queryParams],\n queryFn: () => chipiSDK.skus.findSkus(queryParams),\n enabled,\n });\n}\n","import React from 'react';\nimport { useSkus } from '../hooks/useSkus';\nimport { formatCurrency } from '@chipi-stack/shared';\nimport type { Sku, SkuCategory } from '@chipi-stack/types';\n\ninterface SkuListProps {\n categories?: SkuCategory[];\n onSkuSelect?: (sku: Sku) => void;\n className?: string;\n}\n\n/**\n * Component for displaying available SKUs\n */\nexport function SkuList({ categories, onSkuSelect, className }: SkuListProps) {\n const { data: skus, isLoading, isError, error } = useSkus({ categories });\n\n if (isLoading) {\n return <div className={className}>Loading SKUs...</div>;\n }\n\n if (isError) {\n return (\n <div className={className}>\n <div style={{ color: 'red' }}>\n Error loading SKUs: {error?.message}\n </div>\n </div>\n );\n }\n\n if (!skus || skus.length === 0) {\n return (\n <div className={className}>\n <div>No SKUs available.</div>\n </div>\n );\n }\n\n return (\n <div className={className}>\n <h3>Available SKUs</h3>\n \n <div style={{ display: 'grid', gap: '1rem', gridTemplateColumns: 'repeat(auto-fill, minmax(300px, 1fr))' }}>\n {skus.map((sku) => (\n <div\n key={sku.id}\n style={{\n border: '1px solid #ddd',\n borderRadius: '0.5rem',\n padding: '1rem',\n backgroundColor: 'white',\n cursor: onSkuSelect ? 'pointer' : 'default',\n }}\n onClick={() => onSkuSelect?.(sku)}\n >\n <div style={{ marginBottom: '0.5rem' }}>\n <h4 style={{ margin: 0, fontSize: '1.1rem' }}>{sku.name}</h4>\n </div>\n \n {sku.description && (\n <div style={{ marginBottom: '0.5rem', color: '#666', fontSize: '0.9rem' }}>\n {sku.description}\n </div>\n )}\n \n <div style={{ marginBottom: '0.5rem' }}>\n <span\n style={{\n backgroundColor: '#f0f0f0',\n padding: '0.25rem 0.5rem',\n borderRadius: '0.25rem',\n fontSize: '0.8rem',\n color: '#666',\n }}\n >\n {sku.category}\n </span>\n </div>\n \n <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <div style={{ fontSize: '1.2rem', fontWeight: 'bold' }}>\n {formatCurrency(sku.price, sku.currency)}\n </div>\n \n <div\n style={{\n color: sku.isActive ? 'green' : 'red',\n fontSize: '0.9rem',\n fontWeight: 'bold',\n }}\n >\n {sku.isActive ? 'Available' : 'Unavailable'}\n </div>\n </div>\n </div>\n ))}\n </div>\n </div>\n );\n}","import { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { useChipiContext } from '../context';\nimport type { Sku, SkuTransaction, Chain, ChainToken } from '@chipi-stack/types';\n\ninterface PurchaseSkuParams {\n skuId: string;\n walletAddress: string;\n chain: Chain;\n chainToken: ChainToken;\n mxnAmount: number;\n reference: string;\n transactionHash: string;\n}\n\ninterface PurchaseSkuResult {\n sku: Sku;\n transaction: SkuTransaction;\n}\n\n/**\n * Hook for purchasing a SKU (convenience hook that combines SKU lookup and transaction creation)\n */\nexport function usePurchaseSku(): {\n purchaseSku: (params: PurchaseSkuParams) => void;\n purchaseSkuAsync: (params: PurchaseSkuParams) => Promise<PurchaseSkuResult>;\n data: PurchaseSkuResult | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<PurchaseSkuResult, Error, PurchaseSkuParams> = useMutation({\n mutationFn: (params: PurchaseSkuParams) => chipiSDK.skus.purchaseSku(params),\n });\n\n return {\n purchaseSku: mutation.mutate,\n purchaseSkuAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import React, { useState } from 'react';\nimport { usePurchaseSku } from '../hooks/usePurchaseSku';\nimport { formatCurrency } from '@chipi-stack/shared';\nimport type { Sku, Chain, ChainToken } from '@chipi-stack/types';\n\ninterface SkuPurchaseFormProps {\n sku: Sku;\n walletAddress: string;\n onPurchaseComplete?: (transactionHash: string) => void;\n className?: string;\n}\n\n/**\n * Component for purchasing a SKU\n */\nexport function SkuPurchaseForm({\n sku,\n walletAddress,\n onPurchaseComplete,\n className,\n}: SkuPurchaseFormProps) {\n const [chain, setChain] = useState<Chain>('STARKNET_MAINNET');\n const [chainToken, setChainToken] = useState<ChainToken>('USDC');\n const [reference, setReference] = useState('');\n const [transactionHash, setTransactionHash] = useState('');\n\n const { purchaseSku, isLoading, isError, error, data, isSuccess } = usePurchaseSku();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n if (!reference || !transactionHash) return;\n\n purchaseSku({\n skuId: sku.id,\n walletAddress,\n chain,\n chainToken,\n mxnAmount: sku.price,\n reference,\n transactionHash,\n });\n };\n\n React.useEffect(() => {\n if (isSuccess && data && onPurchaseComplete) {\n onPurchaseComplete(data.transaction.transactionHash);\n }\n }, [isSuccess, data, onPurchaseComplete]);\n\n if (!sku.isActive) {\n return (\n <div className={className}>\n <div style={{ color: 'red', textAlign: 'center', padding: '2rem' }}>\n This SKU is currently unavailable for purchase.\n </div>\n </div>\n );\n }\n\n return (\n <div className={className}>\n <h3>Purchase SKU</h3>\n \n <div style={{ marginBottom: '1.5rem', padding: '1rem', backgroundColor: '#f9f9f9', borderRadius: '0.5rem' }}>\n <h4 style={{ margin: '0 0 0.5rem 0' }}>{sku.name}</h4>\n {sku.description && (\n <p style={{ margin: '0 0 0.5rem 0', color: '#666' }}>{sku.description}</p>\n )}\n <div style={{ fontSize: '1.2rem', fontWeight: 'bold' }}>\n Price: {formatCurrency(sku.price, sku.currency)}\n </div>\n </div>\n\n {isError && error && (\n <div style={{ color: 'red', marginBottom: '1rem' }}>\n Error: {error.message}\n </div>\n )}\n\n {isSuccess && data && (\n <div style={{ color: 'green', marginBottom: '1rem' }}>\n Purchase successful! Transaction: {data.transaction.transactionHash}\n </div>\n )}\n\n <form onSubmit={handleSubmit}>\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"chain\">Chain:</label>\n <select\n id=\"chain\"\n value={chain}\n onChange={(e) => setChain(e.target.value as Chain)}\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n >\n <option value=\"STARKNET_MAINNET\">Starknet Mainnet</option>\n <option value=\"STARKNET_SEPOLIA\">Starknet Sepolia</option>\n </select>\n </div>\n\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"chainToken\">Token:</label>\n <select\n id=\"chainToken\"\n value={chainToken}\n onChange={(e) => setChainToken(e.target.value as ChainToken)}\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n >\n <option value=\"USDC\">USDC</option>\n <option value=\"USDT\">USDT</option>\n <option value=\"ETH\">ETH</option>\n <option value=\"STRK\">STRK</option>\n <option value=\"DAI\">DAI</option>\n </select>\n </div>\n\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"reference\">Reference:</label>\n <input\n id=\"reference\"\n type=\"text\"\n value={reference}\n onChange={(e) => setReference(e.target.value)}\n placeholder=\"Transaction reference\"\n required\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n />\n </div>\n\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor=\"transactionHash\">Transaction Hash:</label>\n <input\n id=\"transactionHash\"\n type=\"text\"\n value={transactionHash}\n onChange={(e) => setTransactionHash(e.target.value)}\n placeholder=\"0x...\"\n required\n style={{ width: '100%', padding: '0.5rem', marginTop: '0.25rem' }}\n />\n </div>\n\n <button\n type=\"submit\"\n disabled={isLoading || !reference || !transactionHash}\n style={{\n width: '100%',\n padding: '0.75rem',\n backgroundColor: isLoading ? '#ccc' : '#28a745',\n color: 'white',\n border: 'none',\n borderRadius: '0.25rem',\n fontSize: '1rem',\n cursor: isLoading ? 'not-allowed' : 'pointer',\n }}\n >\n {isLoading ? 'Processing...' : `Purchase for ${formatCurrency(sku.price, sku.currency)}`}\n </button>\n </form>\n </div>\n );\n}\n"]}
|