@cfxdevkit/react 1.0.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/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @cfxdevkit/react
2
+
3
+ A set of unstyled React hooks, providers, and utilities tailored to building Conflux experiences with your own design system.
4
+
5
+ Features:
6
+ - `DevKitProvider` establishes RPC endpoints for Core/eSpace chains and exposes the current wallet context.
7
+ - React hooks such as `useBalance`, `useContract`, and `useTransaction` that wrap the shared Conflux clients.
8
+ - Fully tree-shakeable exports so you only ship what you need.
9
+
10
+ ## Getting started
11
+
12
+ ```tsx
13
+ import { DevKitProvider, useBalance } from '@conflux-devkit/ui-headless';
14
+
15
+ const App = () => (
16
+ <DevKitProvider apiUrl="http://localhost:3001" network="testnet">
17
+ <YourComponent />
18
+ </DevKitProvider>
19
+ );
20
+ ```
21
+
22
+ ## Development
23
+
24
+ ```bash
25
+ pnpm --filter @conflux-devkit/ui-headless install
26
+ pnpm --filter @conflux-devkit/ui-headless build
27
+ pnpm --filter @conflux-devkit/ui-headless test
28
+ ```
29
+
30
+ ## Testing and linting
31
+
32
+ - Tests run with `vitest`.
33
+ - Formatting and linting use Biome.
@@ -0,0 +1,506 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/index.ts
31
+ var components_exports = {};
32
+ __export(components_exports, {
33
+ AccountCard: () => AccountCard,
34
+ ConnectButton: () => ConnectButton,
35
+ ContractReader: () => ContractReader,
36
+ ContractWriter: () => ContractWriter,
37
+ SwapWidget: () => SwapWidget
38
+ });
39
+ module.exports = __toCommonJS(components_exports);
40
+
41
+ // src/hooks/useBalance.ts
42
+ var import_react2 = require("react");
43
+
44
+ // src/providers/DevKitProvider.tsx
45
+ var import_react = require("react");
46
+ var import_jsx_runtime = require("react/jsx-runtime");
47
+ var DevKitContext = (0, import_react.createContext)(void 0);
48
+ function useDevKitContext() {
49
+ const context = (0, import_react.useContext)(DevKitContext);
50
+ if (!context) {
51
+ throw new Error("useDevKitContext must be used within DevKitProvider");
52
+ }
53
+ return context;
54
+ }
55
+
56
+ // src/hooks/useBalance.ts
57
+ function useBalance(options) {
58
+ const { address, enabled = true, refreshInterval } = options;
59
+ useDevKitContext();
60
+ const [balance, setBalance] = (0, import_react2.useState)();
61
+ const [isLoading, setIsLoading] = (0, import_react2.useState)(false);
62
+ const [error, setError] = (0, import_react2.useState)();
63
+ const fetchBalance = (0, import_react2.useCallback)(async () => {
64
+ if (!address || !enabled) return;
65
+ setIsLoading(true);
66
+ setError(void 0);
67
+ try {
68
+ const mockBalance = "1000000000000000000";
69
+ setBalance(mockBalance);
70
+ } catch (err) {
71
+ setError(
72
+ err instanceof Error ? err : new Error("Failed to fetch balance")
73
+ );
74
+ } finally {
75
+ setIsLoading(false);
76
+ }
77
+ }, [address, enabled]);
78
+ (0, import_react2.useEffect)(() => {
79
+ void fetchBalance();
80
+ if (refreshInterval) {
81
+ const interval = setInterval(() => {
82
+ void fetchBalance();
83
+ }, refreshInterval);
84
+ return () => clearInterval(interval);
85
+ }
86
+ }, [fetchBalance, refreshInterval]);
87
+ return {
88
+ balance,
89
+ isLoading,
90
+ error,
91
+ refetch: fetchBalance
92
+ };
93
+ }
94
+
95
+ // src/providers/WalletProvider.tsx
96
+ var import_react3 = require("react");
97
+ var import_jsx_runtime2 = require("react/jsx-runtime");
98
+ var WalletContext = (0, import_react3.createContext)(void 0);
99
+ function useWalletContext() {
100
+ const context = (0, import_react3.useContext)(WalletContext);
101
+ if (!context) {
102
+ throw new Error("useWalletContext must be used within WalletProvider");
103
+ }
104
+ return context;
105
+ }
106
+
107
+ // src/components/account-display/AccountCard.tsx
108
+ var import_jsx_runtime3 = require("react/jsx-runtime");
109
+ function AccountCard({
110
+ showBalance = true,
111
+ children,
112
+ className
113
+ }) {
114
+ const { isConnected, coreAddress, evmAddress } = useWalletContext();
115
+ const { balance: coreBalance, isLoading: isLoadingCore } = useBalance({
116
+ address: coreAddress,
117
+ chain: "core",
118
+ enabled: showBalance && isConnected
119
+ });
120
+ const { balance: evmBalance, isLoading: isLoadingEvm } = useBalance({
121
+ address: evmAddress,
122
+ chain: "evm",
123
+ enabled: showBalance && isConnected
124
+ });
125
+ const renderProps = {
126
+ isConnected,
127
+ coreAddress,
128
+ evmAddress,
129
+ coreBalance,
130
+ evmBalance,
131
+ isLoadingBalance: isLoadingCore || isLoadingEvm
132
+ };
133
+ if (typeof children === "function") {
134
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: children(renderProps) });
135
+ }
136
+ if (!isConnected) {
137
+ return children ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className, children }) : null;
138
+ }
139
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: className || "p-4 bg-gray-100 rounded-lg space-y-2", children: [
140
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
141
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "font-semibold", children: "Core Space:" }),
142
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ml-2 font-mono text-sm", children: coreAddress }),
143
+ showBalance && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ml-2 text-gray-600", children: isLoadingCore ? "Loading..." : `${coreBalance} CFX` })
144
+ ] }),
145
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
146
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "font-semibold", children: "eSpace:" }),
147
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ml-2 font-mono text-sm", children: evmAddress }),
148
+ showBalance && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ml-2 text-gray-600", children: isLoadingEvm ? "Loading..." : `${evmBalance} CFX` })
149
+ ] })
150
+ ] });
151
+ }
152
+
153
+ // src/components/connect-wallet/ConnectButton.tsx
154
+ var import_react4 = __toESM(require("react"), 1);
155
+ var import_jsx_runtime4 = require("react/jsx-runtime");
156
+ function ConnectButton({
157
+ accountIndex = 0,
158
+ onConnect,
159
+ onDisconnect,
160
+ children,
161
+ className
162
+ }) {
163
+ const {
164
+ isConnected,
165
+ address,
166
+ connect: contextConnect,
167
+ disconnect: contextDisconnect
168
+ } = useWalletContext();
169
+ const [isLoading, setIsLoading] = import_react4.default.useState(false);
170
+ const connect = async () => {
171
+ setIsLoading(true);
172
+ try {
173
+ await contextConnect(accountIndex);
174
+ onConnect?.();
175
+ } catch (error) {
176
+ console.error("Connection failed:", error);
177
+ } finally {
178
+ setIsLoading(false);
179
+ }
180
+ };
181
+ const disconnect = () => {
182
+ contextDisconnect();
183
+ onDisconnect?.();
184
+ };
185
+ const renderProps = {
186
+ isConnected,
187
+ address,
188
+ connect,
189
+ disconnect,
190
+ isLoading
191
+ };
192
+ if (typeof children === "function") {
193
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: children(renderProps) });
194
+ }
195
+ if (children) {
196
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
197
+ "button",
198
+ {
199
+ onClick: isConnected ? disconnect : connect,
200
+ disabled: isLoading,
201
+ className,
202
+ type: "button",
203
+ children
204
+ }
205
+ );
206
+ }
207
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
208
+ "button",
209
+ {
210
+ onClick: isConnected ? disconnect : connect,
211
+ disabled: isLoading,
212
+ className: className || "px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",
213
+ type: "button",
214
+ children: isLoading ? "Connecting..." : isConnected ? `Connected: ${address?.slice(0, 6)}...${address?.slice(-4)}` : "Connect Wallet"
215
+ }
216
+ );
217
+ }
218
+
219
+ // src/components/contract/ContractReader.tsx
220
+ var import_react6 = require("react");
221
+
222
+ // src/hooks/useContract.ts
223
+ var import_react5 = require("react");
224
+ function useContract() {
225
+ useDevKitContext();
226
+ const { accountIndex } = useWalletContext();
227
+ const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
228
+ const [error, setError] = (0, import_react5.useState)();
229
+ const read = async (_options) => {
230
+ setIsLoading(true);
231
+ setError(void 0);
232
+ try {
233
+ return {};
234
+ } catch (err) {
235
+ const errorObj = err instanceof Error ? err : new Error("Contract read failed");
236
+ setError(errorObj);
237
+ throw errorObj;
238
+ } finally {
239
+ setIsLoading(false);
240
+ }
241
+ };
242
+ const write = async (_options) => {
243
+ if (accountIndex === void 0) {
244
+ throw new Error("Wallet not connected");
245
+ }
246
+ setIsLoading(true);
247
+ setError(void 0);
248
+ try {
249
+ const hash = `0x${Array.from(
250
+ { length: 64 },
251
+ () => Math.floor(Math.random() * 16).toString(16)
252
+ ).join("")}`;
253
+ return hash;
254
+ } catch (err) {
255
+ const errorObj = err instanceof Error ? err : new Error("Contract write failed");
256
+ setError(errorObj);
257
+ throw errorObj;
258
+ } finally {
259
+ setIsLoading(false);
260
+ }
261
+ };
262
+ return {
263
+ read,
264
+ write,
265
+ isLoading,
266
+ error
267
+ };
268
+ }
269
+
270
+ // src/components/contract/ContractReader.tsx
271
+ var import_jsx_runtime5 = require("react/jsx-runtime");
272
+ function ContractReader({
273
+ address,
274
+ abi,
275
+ functionName,
276
+ chain,
277
+ children,
278
+ className
279
+ }) {
280
+ const { read: readContract, isLoading, error } = useContract();
281
+ const [result, setResult] = (0, import_react6.useState)();
282
+ const read = async (args) => {
283
+ const data = await readContract({
284
+ address,
285
+ abi,
286
+ functionName,
287
+ args,
288
+ chain
289
+ });
290
+ setResult(data);
291
+ };
292
+ const renderProps = {
293
+ read,
294
+ result,
295
+ isLoading,
296
+ error
297
+ };
298
+ if (typeof children === "function") {
299
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: children(renderProps) });
300
+ }
301
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: className || "p-4 border rounded", children: [
302
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("h3", { className: "font-semibold mb-2", children: [
303
+ "Read: ",
304
+ functionName
305
+ ] }),
306
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
307
+ "button",
308
+ {
309
+ onClick: () => read(),
310
+ disabled: isLoading,
311
+ className: "px-3 py-1 bg-blue-500 text-white rounded disabled:opacity-50",
312
+ type: "button",
313
+ children: isLoading ? "Reading..." : "Read"
314
+ }
315
+ ),
316
+ result && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pre", { className: "bg-gray-100 p-2 rounded text-sm", children: JSON.stringify(result, null, 2) }) }),
317
+ error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mt-2 text-red-500", children: error.message }),
318
+ children
319
+ ] });
320
+ }
321
+
322
+ // src/components/contract/ContractWriter.tsx
323
+ var import_react7 = require("react");
324
+ var import_jsx_runtime6 = require("react/jsx-runtime");
325
+ function ContractWriter({
326
+ address,
327
+ abi,
328
+ functionName,
329
+ chain,
330
+ onSuccess,
331
+ children,
332
+ className
333
+ }) {
334
+ const { write: writeContract, isLoading, error } = useContract();
335
+ const [hash, setHash] = (0, import_react7.useState)();
336
+ const write = async (args, value) => {
337
+ const txHash = await writeContract({
338
+ address,
339
+ abi,
340
+ functionName,
341
+ args,
342
+ chain,
343
+ value
344
+ });
345
+ setHash(txHash);
346
+ onSuccess?.(txHash);
347
+ };
348
+ const reset = () => {
349
+ setHash(void 0);
350
+ };
351
+ const renderProps = {
352
+ write,
353
+ hash,
354
+ isLoading,
355
+ error,
356
+ reset
357
+ };
358
+ if (typeof children === "function") {
359
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: children(renderProps) });
360
+ }
361
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: className || "p-4 border rounded", children: [
362
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("h3", { className: "font-semibold mb-2", children: [
363
+ "Write: ",
364
+ functionName
365
+ ] }),
366
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
367
+ "button",
368
+ {
369
+ onClick: () => write(),
370
+ disabled: isLoading,
371
+ className: "px-3 py-1 bg-green-500 text-white rounded disabled:opacity-50",
372
+ type: "button",
373
+ children: isLoading ? "Sending..." : "Execute"
374
+ }
375
+ ),
376
+ hash && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mt-2", children: [
377
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-sm text-gray-600", children: "Transaction Hash:" }),
378
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "font-mono text-xs break-all", children: hash }),
379
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
380
+ "button",
381
+ {
382
+ onClick: reset,
383
+ className: "mt-1 text-sm text-blue-500 hover:underline",
384
+ type: "button",
385
+ children: "Reset"
386
+ }
387
+ )
388
+ ] }),
389
+ error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mt-2 text-red-500", children: error.message }),
390
+ children
391
+ ] });
392
+ }
393
+
394
+ // src/components/swap/SwapWidget.tsx
395
+ var import_react8 = require("react");
396
+ var import_jsx_runtime7 = require("react/jsx-runtime");
397
+ function SwapWidget({
398
+ defaultSlippage = 0.5,
399
+ onSuccess,
400
+ children,
401
+ className
402
+ }) {
403
+ useDevKitContext();
404
+ const { isConnected, accountIndex } = useWalletContext();
405
+ const [quote, setQuote] = (0, import_react8.useState)();
406
+ const [isLoadingQuote, setIsLoadingQuote] = (0, import_react8.useState)(false);
407
+ const [isExecutingSwap, setIsExecutingSwap] = (0, import_react8.useState)(false);
408
+ const [error, setError] = (0, import_react8.useState)();
409
+ const [hash, setHash] = (0, import_react8.useState)();
410
+ const [currentQuoteParams, setCurrentQuoteParams] = (0, import_react8.useState)();
411
+ const getQuote = async (tokenIn, tokenOut, amountIn) => {
412
+ if (!isConnected) {
413
+ setError(new Error("Wallet not connected"));
414
+ return;
415
+ }
416
+ setIsLoadingQuote(true);
417
+ setError(void 0);
418
+ try {
419
+ const mockQuote = {
420
+ amountIn,
421
+ amountOut: (parseFloat(amountIn) * 0.997).toString(),
422
+ // 0.3% fee
423
+ amountOutMin: (parseFloat(amountIn) * 0.997 * 0.995).toString(),
424
+ // With slippage
425
+ priceImpact: "0.3",
426
+ slippage: defaultSlippage
427
+ };
428
+ setQuote(mockQuote);
429
+ setCurrentQuoteParams({ tokenIn, tokenOut, amountIn });
430
+ } catch (err) {
431
+ setError(err instanceof Error ? err : new Error("Failed to get quote"));
432
+ } finally {
433
+ setIsLoadingQuote(false);
434
+ }
435
+ };
436
+ const executeSwap = async () => {
437
+ if (!quote || !currentQuoteParams || !isConnected || accountIndex === void 0) {
438
+ setError(new Error("Missing required data for swap"));
439
+ return;
440
+ }
441
+ setIsExecutingSwap(true);
442
+ setError(void 0);
443
+ try {
444
+ const mockHash = `0x${Array.from(
445
+ { length: 64 },
446
+ () => Math.floor(Math.random() * 16).toString(16)
447
+ ).join("")}`;
448
+ setHash(mockHash);
449
+ onSuccess?.(mockHash);
450
+ } catch (err) {
451
+ setError(err instanceof Error ? err : new Error("Swap failed"));
452
+ } finally {
453
+ setIsExecutingSwap(false);
454
+ }
455
+ };
456
+ const renderProps = {
457
+ getQuote,
458
+ executeSwap,
459
+ quote,
460
+ isLoadingQuote,
461
+ isExecutingSwap,
462
+ error,
463
+ hash
464
+ };
465
+ if (typeof children === "function") {
466
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: children(renderProps) });
467
+ }
468
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: className || "p-4 border rounded-lg", children: [
469
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: "text-xl font-bold mb-4", children: "Swap (Swappi)" }),
470
+ !isConnected && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-gray-600", children: "Connect wallet to start swapping" }),
471
+ quote && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mt-4 p-3 bg-gray-100 rounded", children: [
472
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { children: [
473
+ "Amount In: ",
474
+ quote.amountIn
475
+ ] }),
476
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { children: [
477
+ "Amount Out: ",
478
+ quote.amountOut
479
+ ] }),
480
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { children: [
481
+ "Min Amount: ",
482
+ quote.amountOutMin
483
+ ] }),
484
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { children: [
485
+ "Slippage: ",
486
+ quote.slippage,
487
+ "%"
488
+ ] })
489
+ ] }),
490
+ hash && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mt-4 p-3 bg-green-100 rounded", children: [
491
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-sm font-semibold", children: "Swap Successful!" }),
492
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-xs font-mono break-all", children: hash })
493
+ ] }),
494
+ error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-4 p-3 bg-red-100 rounded", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-red-700", children: error.message }) }),
495
+ children
496
+ ] });
497
+ }
498
+ // Annotate the CommonJS export names for ESM import in node:
499
+ 0 && (module.exports = {
500
+ AccountCard,
501
+ ConnectButton,
502
+ ContractReader,
503
+ ContractWriter,
504
+ SwapWidget
505
+ });
506
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/index.ts","../../src/hooks/useBalance.ts","../../src/providers/DevKitProvider.tsx","../../src/providers/WalletProvider.tsx","../../src/components/account-display/AccountCard.tsx","../../src/components/connect-wallet/ConnectButton.tsx","../../src/components/contract/ContractReader.tsx","../../src/hooks/useContract.ts","../../src/components/contract/ContractWriter.tsx","../../src/components/swap/SwapWidget.tsx"],"sourcesContent":["/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type {\n AccountCardProps,\n AccountCardRenderProps,\n} from './account-display/AccountCard.js';\n// Account Display\nexport { AccountCard } from './account-display/AccountCard.js';\nexport type {\n ConnectButtonProps,\n ConnectButtonRenderProps,\n} from './connect-wallet/ConnectButton.js';\n// Connect Wallet\nexport { ConnectButton } from './connect-wallet/ConnectButton.js';\nexport type {\n ContractReaderProps,\n ContractReaderRenderProps,\n} from './contract/ContractReader.js';\n// Contract Interaction\nexport { ContractReader } from './contract/ContractReader.js';\nexport type {\n ContractWriterProps,\n ContractWriterRenderProps,\n} from './contract/ContractWriter.js';\nexport { ContractWriter } from './contract/ContractWriter.js';\nexport type {\n SwapQuote,\n SwapWidgetProps,\n SwapWidgetRenderProps,\n} from './swap/SwapWidget.js';\n// Swap\nexport { SwapWidget } from './swap/SwapWidget.js';\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * useBalance Hook\n *\n * Fetches and tracks balance for an address\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useDevKitContext } from '../providers/DevKitProvider.js';\n\nexport interface UseBalanceOptions {\n address?: string;\n chain: ChainType;\n enabled?: boolean;\n refreshInterval?: number;\n}\n\nexport interface UseBalanceReturn {\n balance?: string;\n isLoading: boolean;\n error?: Error;\n refetch: () => Promise<void>;\n}\n\n/**\n * Hook to fetch and track address balance\n *\n * @example\n * ```tsx\n * const { balance, isLoading } = useBalance({\n * address: '0x...',\n * chain: 'evm'\n * });\n * ```\n */\nexport function useBalance(options: UseBalanceOptions): UseBalanceReturn {\n const { address, enabled = true, refreshInterval } = options;\n useDevKitContext(); // ensure provider is present; apiUrl and chain used in production impl\n\n const [balance, setBalance] = useState<string>();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error>();\n\n const fetchBalance = useCallback(async () => {\n if (!address || !enabled) return;\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n // In production, call backend API with `chain` to select Core vs eSpace\n // For now, simulate balance fetch\n const mockBalance = '1000000000000000000'; // 1 token\n setBalance(mockBalance);\n } catch (err) {\n setError(\n err instanceof Error ? err : new Error('Failed to fetch balance')\n );\n } finally {\n setIsLoading(false);\n }\n }, [address, enabled]);\n\n useEffect(() => {\n void fetchBalance();\n\n // Set up refresh interval if provided\n if (refreshInterval) {\n const interval = setInterval(() => {\n void fetchBalance();\n }, refreshInterval);\n return () => clearInterval(interval);\n }\n }, [fetchBalance, refreshInterval]);\n\n return {\n balance,\n isLoading,\n error,\n refetch: fetchBalance,\n };\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * DevKit Provider\n *\n * Provides DevKit instance and configuration to all child components\n */\n\nimport { createContext, type ReactNode, useContext } from 'react';\n\nexport interface DevKitContextValue {\n /** Backend API URL */\n apiUrl: string;\n /** WebSocket URL */\n wsUrl?: string;\n /** Current network */\n network: 'local' | 'testnet' | 'mainnet';\n /** Enable debug mode */\n debug?: boolean;\n}\n\nconst DevKitContext = createContext<DevKitContextValue | undefined>(undefined);\n\nexport interface DevKitProviderProps {\n apiUrl: string;\n wsUrl?: string;\n network?: 'local' | 'testnet' | 'mainnet';\n debug?: boolean;\n children: ReactNode;\n}\n\n/**\n * DevKit Provider Component\n *\n * Wrap your app with this provider to enable DevKit functionality\n *\n * @example\n * ```tsx\n * <DevKitProvider apiUrl=\"http://localhost:3000\" network=\"local\">\n * <App />\n * </DevKitProvider>\n * ```\n */\nexport function DevKitProvider({\n apiUrl,\n wsUrl,\n network = 'local',\n debug = false,\n children,\n}: DevKitProviderProps) {\n const value: DevKitContextValue = {\n apiUrl,\n wsUrl,\n network,\n debug,\n };\n\n return (\n <DevKitContext.Provider value={value}>{children}</DevKitContext.Provider>\n );\n}\n\n/**\n * Hook to access DevKit context\n *\n * @throws Error if used outside DevKitProvider\n */\nexport function useDevKitContext() {\n const context = useContext(DevKitContext);\n if (!context) {\n throw new Error('useDevKitContext must be used within DevKitProvider');\n }\n return context;\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Wallet Provider\n *\n * Manages wallet connection state and provides wallet-related functionality\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport { createContext, type ReactNode, useContext, useState } from 'react';\n\nexport interface WalletContextValue {\n isConnected: boolean;\n address?: string;\n coreAddress?: string;\n evmAddress?: string;\n chain?: ChainType;\n accountIndex?: number;\n connect: (accountIndex: number) => Promise<void>;\n disconnect: () => void;\n switchChain: (chain: ChainType) => void;\n}\n\nconst WalletContext = createContext<WalletContextValue | undefined>(undefined);\n\nexport interface WalletProviderProps {\n children: ReactNode;\n}\n\n/**\n * Wallet Provider Component\n *\n * Manages wallet connection state\n *\n * @example\n * ```tsx\n * <WalletProvider>\n * <ConnectButton />\n * <AccountCard />\n * </WalletProvider>\n * ```\n */\nexport function WalletProvider({ children }: WalletProviderProps) {\n const [isConnected, setIsConnected] = useState(false);\n const [coreAddress, setCoreAddress] = useState<string>();\n const [evmAddress, setEvmAddress] = useState<string>();\n const [chain, setChain] = useState<ChainType>('evm');\n const [accountIndex, setAccountIndex] = useState<number>();\n\n const connect = async (index: number) => {\n // In production, this would fetch account info from backend\n // For now, simulate connection\n setAccountIndex(index);\n setCoreAddress(`cfx:account${index}`);\n setEvmAddress(`0xaccount${index}`);\n setIsConnected(true);\n };\n\n const disconnect = () => {\n setIsConnected(false);\n setCoreAddress(undefined);\n setEvmAddress(undefined);\n setAccountIndex(undefined);\n };\n\n const switchChain = (newChain: ChainType) => {\n setChain(newChain);\n };\n\n const value: WalletContextValue = {\n isConnected,\n address: chain === 'core' ? coreAddress : evmAddress,\n coreAddress,\n evmAddress,\n chain,\n accountIndex,\n connect,\n disconnect,\n switchChain,\n };\n\n return (\n <WalletContext.Provider value={value}>{children}</WalletContext.Provider>\n );\n}\n\n/**\n * Hook to access Wallet context\n *\n * @throws Error if used outside WalletProvider\n */\nexport function useWalletContext() {\n const context = useContext(WalletContext);\n if (!context) {\n throw new Error('useWalletContext must be used within WalletProvider');\n }\n return context;\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * AccountCard - Headless Account Display Component\n *\n * Displays account information with customizable rendering\n */\n\nimport type React from 'react';\nimport { useBalance } from '../../hooks/useBalance.js';\nimport { useWalletContext } from '../../providers/WalletProvider.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface AccountCardRenderProps {\n isConnected: boolean;\n coreAddress?: string;\n evmAddress?: string;\n coreBalance?: string;\n evmBalance?: string;\n isLoadingBalance: boolean;\n}\n\nexport interface AccountCardProps extends BaseComponentProps {\n showBalance?: boolean;\n children?: RenderPropChild<AccountCardRenderProps> | React.ReactNode;\n}\n\n/**\n * AccountCard Component\n *\n * Headless account information display. Use render prop pattern for custom UI.\n *\n * @example\n * ```tsx\n * // With render prop\n * <AccountCard showBalance>\n * {({ coreAddress, evmAddress, coreBalance, evmBalance }) => (\n * <div>\n * <p>Core: {coreAddress}</p>\n * <p>EVM: {evmAddress}</p>\n * <p>Balance: {coreBalance}</p>\n * </div>\n * )}\n * </AccountCard>\n *\n * // With default styling\n * <AccountCard showBalance className=\"p-4 bg-gray-100 rounded\" />\n * ```\n */\nexport function AccountCard({\n showBalance = true,\n children,\n className,\n}: AccountCardProps) {\n const { isConnected, coreAddress, evmAddress } = useWalletContext();\n\n const { balance: coreBalance, isLoading: isLoadingCore } = useBalance({\n address: coreAddress,\n chain: 'core',\n enabled: showBalance && isConnected,\n });\n\n const { balance: evmBalance, isLoading: isLoadingEvm } = useBalance({\n address: evmAddress,\n chain: 'evm',\n enabled: showBalance && isConnected,\n });\n\n const renderProps: AccountCardRenderProps = {\n isConnected,\n coreAddress,\n evmAddress,\n coreBalance,\n evmBalance,\n isLoadingBalance: isLoadingCore || isLoadingEvm,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // If not connected, show nothing or custom children\n if (!isConnected) {\n return children ? <div className={className}>{children}</div> : null;\n }\n\n // Default rendering\n return (\n <div className={className || 'p-4 bg-gray-100 rounded-lg space-y-2'}>\n <div>\n <span className=\"font-semibold\">Core Space:</span>\n <span className=\"ml-2 font-mono text-sm\">{coreAddress}</span>\n {showBalance && (\n <span className=\"ml-2 text-gray-600\">\n {isLoadingCore ? 'Loading...' : `${coreBalance} CFX`}\n </span>\n )}\n </div>\n <div>\n <span className=\"font-semibold\">eSpace:</span>\n <span className=\"ml-2 font-mono text-sm\">{evmAddress}</span>\n {showBalance && (\n <span className=\"ml-2 text-gray-600\">\n {isLoadingEvm ? 'Loading...' : `${evmBalance} CFX`}\n </span>\n )}\n </div>\n </div>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ConnectButton - Headless Wallet Connection Component\n *\n * Provides wallet connection functionality with customizable rendering\n */\n\nimport React from 'react';\nimport { useWalletContext } from '../../providers/WalletProvider.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface ConnectButtonRenderProps {\n isConnected: boolean;\n address?: string;\n connect: () => Promise<void>;\n disconnect: () => void;\n isLoading: boolean;\n}\n\nexport interface ConnectButtonProps extends BaseComponentProps {\n accountIndex?: number;\n onConnect?: () => void;\n onDisconnect?: () => void;\n children?: RenderPropChild<ConnectButtonRenderProps> | React.ReactNode;\n}\n\n/**\n * ConnectButton Component\n *\n * Headless wallet connection button. Use render prop pattern for custom UI.\n *\n * @example\n * ```tsx\n * // With render prop (full control)\n * <ConnectButton>\n * {({ isConnected, address, connect, disconnect }) => (\n * <button onClick={isConnected ? disconnect : connect}>\n * {isConnected ? `Connected: ${address}` : 'Connect Wallet'}\n * </button>\n * )}\n * </ConnectButton>\n *\n * // With default styling\n * <ConnectButton className=\"px-4 py-2 bg-blue-500 text-white rounded\" />\n * ```\n */\nexport function ConnectButton({\n accountIndex = 0,\n onConnect,\n onDisconnect,\n children,\n className,\n}: ConnectButtonProps) {\n const {\n isConnected,\n address,\n connect: contextConnect,\n disconnect: contextDisconnect,\n } = useWalletContext();\n const [isLoading, setIsLoading] = React.useState(false);\n\n const connect = async () => {\n setIsLoading(true);\n try {\n await contextConnect(accountIndex);\n onConnect?.();\n } catch (error) {\n console.error('Connection failed:', error);\n } finally {\n setIsLoading(false);\n }\n };\n\n const disconnect = () => {\n contextDisconnect();\n onDisconnect?.();\n };\n\n const renderProps: ConnectButtonRenderProps = {\n isConnected,\n address,\n connect,\n disconnect,\n isLoading,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // If children provided, wrap in default button\n if (children) {\n return (\n <button\n onClick={isConnected ? disconnect : connect}\n disabled={isLoading}\n className={className}\n type=\"button\"\n >\n {children}\n </button>\n );\n }\n\n // Default rendering with Tailwind classes\n return (\n <button\n onClick={isConnected ? disconnect : connect}\n disabled={isLoading}\n className={\n className ||\n 'px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50'\n }\n type=\"button\"\n >\n {isLoading\n ? 'Connecting...'\n : isConnected\n ? `Connected: ${address?.slice(0, 6)}...${address?.slice(-4)}`\n : 'Connect Wallet'}\n </button>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ContractReader - Headless Contract Read Component\n *\n * Reads data from smart contracts with customizable rendering\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport type React from 'react';\nimport { useState } from 'react';\nimport { useContract } from '../../hooks/useContract.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface ContractReaderRenderProps<T = unknown> {\n read: (args?: unknown[]) => Promise<void>;\n result?: T;\n isLoading: boolean;\n error?: Error;\n}\n\nexport interface ContractReaderProps<T = unknown> extends BaseComponentProps {\n address: string;\n abi: unknown[];\n functionName: string;\n chain: ChainType;\n children?: RenderPropChild<ContractReaderRenderProps<T>> | React.ReactNode;\n}\n\n/**\n * ContractReader Component\n *\n * Headless contract read component. Use render prop for custom UI.\n *\n * @example\n * ```tsx\n * <ContractReader\n * address=\"0x...\"\n * abi={ERC20_ABI}\n * functionName=\"balanceOf\"\n * chain=\"evm\"\n * >\n * {({ read, result, isLoading }) => (\n * <div>\n * <button onClick={() => read(['0x...'])}>Get Balance</button>\n * {isLoading && <p>Loading...</p>}\n * {result && <p>Balance: {result}</p>}\n * </div>\n * )}\n * </ContractReader>\n * ```\n */\nexport function ContractReader<T = unknown>({\n address,\n abi,\n functionName,\n chain,\n children,\n className,\n}: ContractReaderProps<T>) {\n const { read: readContract, isLoading, error } = useContract();\n const [result, setResult] = useState<T>();\n\n const read = async (args?: unknown[]) => {\n const data = await readContract<T>({\n address,\n abi,\n functionName,\n args,\n chain,\n });\n setResult(data);\n };\n\n const renderProps: ContractReaderRenderProps<T> = {\n read,\n result,\n isLoading,\n error,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // Default rendering\n return (\n <div className={className || 'p-4 border rounded'}>\n <h3 className=\"font-semibold mb-2\">Read: {functionName}</h3>\n <button\n onClick={() => read()}\n disabled={isLoading}\n className=\"px-3 py-1 bg-blue-500 text-white rounded disabled:opacity-50\"\n type=\"button\"\n >\n {isLoading ? 'Reading...' : 'Read'}\n </button>\n {result && (\n <div className=\"mt-2\">\n <pre className=\"bg-gray-100 p-2 rounded text-sm\">\n {JSON.stringify(result, null, 2)}\n </pre>\n </div>\n )}\n {error && <p className=\"mt-2 text-red-500\">{error.message}</p>}\n {children}\n </div>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * useContract Hook\n *\n * Interact with smart contracts (read and write)\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport { useState } from 'react';\nimport { useDevKitContext } from '../providers/DevKitProvider.js';\nimport { useWalletContext } from '../providers/WalletProvider.js';\n\nexport interface ReadContractOptions {\n address: string;\n abi: unknown[];\n functionName: string;\n args?: unknown[];\n chain: ChainType;\n}\n\nexport interface WriteContractOptions extends ReadContractOptions {\n value?: string;\n}\n\nexport interface UseContractReturn {\n read: <T = unknown>(options: ReadContractOptions) => Promise<T>;\n write: (options: WriteContractOptions) => Promise<string>;\n isLoading: boolean;\n error?: Error;\n}\n\n/**\n * Hook to interact with smart contracts\n *\n * @example\n * ```tsx\n * const { read, write, isLoading } = useContract();\n *\n * // Read contract\n * const balance = await read({\n * address: '0x...',\n * abi: ERC20_ABI,\n * functionName: 'balanceOf',\n * args: ['0x...'],\n * chain: 'evm'\n * });\n *\n * // Write contract\n * const hash = await write({\n * address: '0x...',\n * abi: ERC20_ABI,\n * functionName: 'transfer',\n * args: ['0x...', '1000000000000000000'],\n * chain: 'evm'\n * });\n * ```\n */\nexport function useContract(): UseContractReturn {\n useDevKitContext(); // ensure provider is present; apiUrl used in production impl\n const { accountIndex } = useWalletContext();\n\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error>();\n\n const read = async <T = unknown>(\n _options: ReadContractOptions\n ): Promise<T> => {\n setIsLoading(true);\n setError(undefined);\n\n try {\n // In production, call backend API\n // For now, return mock data\n return {} as T;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error('Contract read failed');\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n };\n\n const write = async (_options: WriteContractOptions): Promise<string> => {\n if (accountIndex === undefined) {\n throw new Error('Wallet not connected');\n }\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n // In production, call backend API\n // For now, return mock hash\n const hash = `0x${Array.from({ length: 64 }, () =>\n Math.floor(Math.random() * 16).toString(16)\n ).join('')}`;\n\n return hash;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error('Contract write failed');\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n };\n\n return {\n read,\n write,\n isLoading,\n error,\n };\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ContractWriter - Headless Contract Write Component\n *\n * Writes to smart contracts with customizable rendering\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport type React from 'react';\nimport { useState } from 'react';\nimport { useContract } from '../../hooks/useContract.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface ContractWriterRenderProps {\n write: (args?: unknown[], value?: string) => Promise<void>;\n hash?: string;\n isLoading: boolean;\n error?: Error;\n reset: () => void;\n}\n\nexport interface ContractWriterProps extends BaseComponentProps {\n address: string;\n abi: unknown[];\n functionName: string;\n chain: ChainType;\n onSuccess?: (hash: string) => void;\n children?: RenderPropChild<ContractWriterRenderProps> | React.ReactNode;\n}\n\n/**\n * ContractWriter Component\n *\n * Headless contract write component. Use render prop for custom UI.\n *\n * @example\n * ```tsx\n * <ContractWriter\n * address=\"0x...\"\n * abi={ERC20_ABI}\n * functionName=\"transfer\"\n * chain=\"evm\"\n * onSuccess={(hash) => console.log('Success:', hash)}\n * >\n * {({ write, hash, isLoading }) => (\n * <div>\n * <button onClick={() => write(['0x...', '1000000000000000000'])}>\n * Transfer\n * </button>\n * {isLoading && <p>Sending...</p>}\n * {hash && <p>TX: {hash}</p>}\n * </div>\n * )}\n * </ContractWriter>\n * ```\n */\nexport function ContractWriter({\n address,\n abi,\n functionName,\n chain,\n onSuccess,\n children,\n className,\n}: ContractWriterProps) {\n const { write: writeContract, isLoading, error } = useContract();\n const [hash, setHash] = useState<string>();\n\n const write = async (args?: unknown[], value?: string) => {\n const txHash = await writeContract({\n address,\n abi,\n functionName,\n args,\n chain,\n value,\n });\n setHash(txHash);\n onSuccess?.(txHash);\n };\n\n const reset = () => {\n setHash(undefined);\n };\n\n const renderProps: ContractWriterRenderProps = {\n write,\n hash,\n isLoading,\n error,\n reset,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // Default rendering\n return (\n <div className={className || 'p-4 border rounded'}>\n <h3 className=\"font-semibold mb-2\">Write: {functionName}</h3>\n <button\n onClick={() => write()}\n disabled={isLoading}\n className=\"px-3 py-1 bg-green-500 text-white rounded disabled:opacity-50\"\n type=\"button\"\n >\n {isLoading ? 'Sending...' : 'Execute'}\n </button>\n {hash && (\n <div className=\"mt-2\">\n <p className=\"text-sm text-gray-600\">Transaction Hash:</p>\n <p className=\"font-mono text-xs break-all\">{hash}</p>\n <button\n onClick={reset}\n className=\"mt-1 text-sm text-blue-500 hover:underline\"\n type=\"button\"\n >\n Reset\n </button>\n </div>\n )}\n {error && <p className=\"mt-2 text-red-500\">{error.message}</p>}\n {children}\n </div>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * SwapWidget - Headless Swap Component (Swappi)\n *\n * Token swap interface with customizable rendering\n */\n\nimport type React from 'react';\nimport { useState } from 'react';\nimport { useDevKitContext } from '../../providers/DevKitProvider.js';\nimport { useWalletContext } from '../../providers/WalletProvider.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface SwapQuote {\n amountIn: string;\n amountOut: string;\n amountOutMin: string;\n priceImpact: string;\n slippage: number;\n}\n\nexport interface SwapWidgetRenderProps {\n getQuote: (\n tokenIn: string,\n tokenOut: string,\n amountIn: string\n ) => Promise<void>;\n executeSwap: () => Promise<void>;\n quote?: SwapQuote;\n isLoadingQuote: boolean;\n isExecutingSwap: boolean;\n error?: Error;\n hash?: string;\n}\n\nexport interface SwapWidgetProps extends BaseComponentProps {\n defaultSlippage?: number;\n onSuccess?: (hash: string) => void;\n children?: RenderPropChild<SwapWidgetRenderProps> | React.ReactNode;\n}\n\n/**\n * SwapWidget Component\n *\n * Headless swap interface for Swappi DEX. Use render prop for custom UI.\n *\n * @example\n * ```tsx\n * <SwapWidget defaultSlippage={0.5}>\n * {({ getQuote, executeSwap, quote, isLoadingQuote }) => (\n * <div>\n * <button onClick={() => getQuote('WCFX', 'USDT', '1.0')}>\n * Get Quote\n * </button>\n * {quote && <p>You get: {quote.amountOut}</p>}\n * <button onClick={executeSwap} disabled={!quote}>\n * Swap\n * </button>\n * </div>\n * )}\n * </SwapWidget>\n * ```\n */\nexport function SwapWidget({\n defaultSlippage = 0.5,\n onSuccess,\n children,\n className,\n}: SwapWidgetProps) {\n useDevKitContext(); // ensure provider is present; apiUrl used in production impl\n const { isConnected, accountIndex } = useWalletContext();\n\n const [quote, setQuote] = useState<SwapQuote>();\n const [isLoadingQuote, setIsLoadingQuote] = useState(false);\n const [isExecutingSwap, setIsExecutingSwap] = useState(false);\n const [error, setError] = useState<Error>();\n const [hash, setHash] = useState<string>();\n\n const [currentQuoteParams, setCurrentQuoteParams] = useState<{\n tokenIn: string;\n tokenOut: string;\n amountIn: string;\n }>();\n\n const getQuote = async (\n tokenIn: string,\n tokenOut: string,\n amountIn: string\n ) => {\n if (!isConnected) {\n setError(new Error('Wallet not connected'));\n return;\n }\n\n setIsLoadingQuote(true);\n setError(undefined);\n\n try {\n // In production, call backend API to get quote from Swappi\n // For now, simulate quote\n const mockQuote: SwapQuote = {\n amountIn,\n amountOut: (parseFloat(amountIn) * 0.997).toString(), // 0.3% fee\n amountOutMin: (parseFloat(amountIn) * 0.997 * 0.995).toString(), // With slippage\n priceImpact: '0.3',\n slippage: defaultSlippage,\n };\n\n setQuote(mockQuote);\n setCurrentQuoteParams({ tokenIn, tokenOut, amountIn });\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to get quote'));\n } finally {\n setIsLoadingQuote(false);\n }\n };\n\n const executeSwap = async () => {\n if (\n !quote ||\n !currentQuoteParams ||\n !isConnected ||\n accountIndex === undefined\n ) {\n setError(new Error('Missing required data for swap'));\n return;\n }\n\n setIsExecutingSwap(true);\n setError(undefined);\n\n try {\n // In production, call backend API to execute swap on Swappi\n // For now, simulate swap\n const mockHash = `0x${Array.from({ length: 64 }, () =>\n Math.floor(Math.random() * 16).toString(16)\n ).join('')}`;\n\n setHash(mockHash);\n onSuccess?.(mockHash);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Swap failed'));\n } finally {\n setIsExecutingSwap(false);\n }\n };\n\n const renderProps: SwapWidgetRenderProps = {\n getQuote,\n executeSwap,\n quote,\n isLoadingQuote,\n isExecutingSwap,\n error,\n hash,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // Default rendering\n return (\n <div className={className || 'p-4 border rounded-lg'}>\n <h2 className=\"text-xl font-bold mb-4\">Swap (Swappi)</h2>\n\n {!isConnected && (\n <p className=\"text-gray-600\">Connect wallet to start swapping</p>\n )}\n\n {quote && (\n <div className=\"mt-4 p-3 bg-gray-100 rounded\">\n <p>Amount In: {quote.amountIn}</p>\n <p>Amount Out: {quote.amountOut}</p>\n <p>Min Amount: {quote.amountOutMin}</p>\n <p>Slippage: {quote.slippage}%</p>\n </div>\n )}\n\n {hash && (\n <div className=\"mt-4 p-3 bg-green-100 rounded\">\n <p className=\"text-sm font-semibold\">Swap Successful!</p>\n <p className=\"text-xs font-mono break-all\">{hash}</p>\n </div>\n )}\n\n {error && (\n <div className=\"mt-4 p-3 bg-red-100 rounded\">\n <p className=\"text-red-700\">{error.message}</p>\n </div>\n )}\n\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuBA,IAAAA,gBAAiD;;;ACDjD,mBAA0D;AAkDtD;AArCJ,IAAM,oBAAgB,4BAA8C,MAAS;AA8CtE,SAAS,mBAAmB;AACjC,QAAM,cAAU,yBAAW,aAAa;AACxC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;;;ADpCO,SAAS,WAAW,SAA8C;AACvE,QAAM,EAAE,SAAS,UAAU,MAAM,gBAAgB,IAAI;AACrD,mBAAiB;AAEjB,QAAM,CAAC,SAAS,UAAU,QAAI,wBAAiB;AAC/C,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAgB;AAE1C,QAAM,mBAAe,2BAAY,YAAY;AAC3C,QAAI,CAAC,WAAW,CAAC,QAAS;AAE1B,iBAAa,IAAI;AACjB,aAAS,MAAS;AAElB,QAAI;AAGF,YAAM,cAAc;AACpB,iBAAW,WAAW;AAAA,IACxB,SAAS,KAAK;AACZ;AAAA,QACE,eAAe,QAAQ,MAAM,IAAI,MAAM,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E,WAAU,+BAA+B,gBAAK;AAAA,OACnD;AAAA,IAGD,SACC,6CAAC,SAAI,WAAU,+BACb,uDAAC,OAAE,WAAU,gBAAgB,gBAAM,SAAQ,GAC7C;AAAA,IAGD;AAAA,KACH;AAEJ;","names":["import_react","import_react","import_jsx_runtime","import_jsx_runtime","import_react","import_jsx_runtime","React","import_react","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime"]}
@@ -0,0 +1,4 @@
1
+ export { A as AccountCard, a as AccountCardProps, b as AccountCardRenderProps, C as ConnectButton, c as ConnectButtonProps, d as ConnectButtonRenderProps, f as ContractReader, g as ContractReaderProps, h as ContractReaderRenderProps, i as ContractWriter, j as ContractWriterProps, k as ContractWriterRenderProps, S as SwapQuote, l as SwapWidget, m as SwapWidgetProps, n as SwapWidgetRenderProps } from '../index-CU9Acwhq.cjs';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
4
+ import '@cfxdevkit/core';
@@ -0,0 +1,4 @@
1
+ export { A as AccountCard, a as AccountCardProps, b as AccountCardRenderProps, C as ConnectButton, c as ConnectButtonProps, d as ConnectButtonRenderProps, f as ContractReader, g as ContractReaderProps, h as ContractReaderRenderProps, i as ContractWriter, j as ContractWriterProps, k as ContractWriterRenderProps, S as SwapQuote, l as SwapWidget, m as SwapWidgetProps, n as SwapWidgetRenderProps } from '../index-CU9Acwhq.js';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
4
+ import '@cfxdevkit/core';