Commit 3a6f325
committed
feat(conflux-devkit): setup wizard + fix API/routes + default port 7748
- AppShell gates the entire UI on keystore initialization status —
first-time visitors see the setup wizard full-screen, not a broken dashboard
- Extract SetupWizard to src/components/SetupWizard.tsx; wallet/page imports it
- Add NEXT_PUBLIC_API_URL + NEXT_PUBLIC_WS_URL support in api.ts / socket.ts;
.env.development.local points to http://localhost:7748 for use
- Backend: fix node-manager DEFAULT_CONFIG chainId 1→2029, evmChainId 71→2030
- Backend: fix keystore status response (initialized/encryptionEnabled vs stale names)
- Backend: fix wallets/accounts endpoints to return flat arrays (no wrapper object)
- Backend: replace non-implemented fundAccount() with fundEvmAccount/fundCoreAccount
- Backend: add try/catch to all async route handlers (devnode, accounts)
- CLI: change default port 4200 → 7748 (aligns with README)
fix: node startup, WS ports, mining UI sync, contracts page
- Fix miningAuthor sentinel value 'auto' being passed to native binary
instead of the derived Core address, causing 'Node startup communication
failed' on every POST /api/node/start
- Add EVM WebSocket port (evmWsPort, default 8546) alongside existing Core
WS port; wire jsonrpcWsEthPort into @xcfx/node createServer(); expose
coreWs and evmWs fields from getRpcUrls() and /api/network/rpc-urls
- Fix mining page showing 'Off' when node is actively mining: frontend
MiningStatus type had {enabled,blockTime,latestEpoch} but backend returns
{isRunning,interval,blocksMined}; align types and field usage
- Fix contracts page crash: templates endpoint was returning {templates:[]}
wrapper that .map() iterated wrong; fix to return plain array including
source field for editor preview; fix compile response shape to match
CompileResult type (was nested under {ok,result}); fix deploy to wait for
receipt and return contractAddress; mine a block post-deploy when
auto-mining is inactive so the tx gets confirmed
UX overhaul: dashboard consolidation, live balances, contract deploy error handling
- Dashboard (page.tsx): merged Accounts + Mining + Network into single vertical
scroll page; wallet selector before start; network config preview (editable
when stopped, read-only when running); status label reflects Starting.../
Stopping... immediately on button press; accounts table shows first 5 rows
with expand to show all 10; live Core+EVM balances; faucet card; fund modal;
full auto-mine toggle + interval + manual mine controls; all 4 RPC endpoints
- Accounts route (accounts.ts): fetch live Core balance via cfx_getBalance
JSON-RPC and EVM balance via viem on every GET /api/accounts call; balances
now populate correctly in the table
- Contracts deploy route (contracts.ts): wrap requireManager() + entire EVM
deploy pipeline in try/catch blocks; add timeout: 10_000 to viem HTTP
transports; always respond with a JSON error instead of hanging the connection
- Sidebar.tsx: remove Accounts/Mining/Network links; keep Dashboard/Contracts/Wallet
- Types: fix NodeStatusEvent (socket.ts) and NodeStatus (api.ts) to match actual
backend shape — rpcUrls now includes coreWs/evmWs fields
UX polish: mining toggle, RPC on top, faucet Core-only, contracts crash fix
Dashboard (page.tsx):
- Mining: collapse three cards into one. Header shows blocks-mined count +
auto-mine toggle switch (pill). When ON: interval (ms) input; Update button
appears only when value differs from current interval (stop+restart). When
OFF: manual mine (blocks input + Mine button).
- RPC Endpoints: moved above Accounts, immediately after the status card.
Added Core Chain ID + EVM Chain ID rows with copy buttons at the bottom of
that card. Removed the read-only grid from inside the status card; network
config (editable) still appears in the status card when the node is stopped.
- Faucet: removed EVM address/balance column. Now shows Core address + Core
balance on the left; Keys + Fund buttons moved into the faucet card header
(right side). Accounts section header is now just the section label.
Contracts (page.tsx):
- Added nodeApi.status query (refetchInterval: 3s).
- Yellow warning banner when node is not running (AlertTriangle icon).
- Deploy button disabled + title tooltip when node is down.
- loadTemplate: wrapped in try/catch; errors surface in local loadError state
instead of causing an unhandled promise rejection that could crash the app.
- deployMutation.onError: uses e instanceof Error ? e.message : String(e) to
handle TypeError ('Failed to fetch') and other non-Error objects safely.
Wallet-scoped data dirs, wipe-restart, mining order, Save Config safety
Backend (node-manager.ts):
- Data directory is now per-wallet: ~/.conflux-devkit/wallets/<wallet-id>/data
instead of the shared ~/.conflux-devkit/data. Switching wallets always
starts the node with a fresh, isolated chain state directory.
- Removed dataDir from DEFAULT_CONFIG; it is computed at start() time from
the active wallet's ID via walletDataDir(id).
- Added restartWipe(): stop → rm -rf wallet data dir → start fresh.
- Updated config type to Omit<ServerConfig, 'dataDir'> throughout.
Backend (routes/devnode.ts):
- Added POST /api/node/restart-wipe route that calls nodeManager.restartWipe().
Frontend (lib/api.ts):
- Added nodeApi.restartWipe() → POST /node/restart-wipe.
Frontend (app/globals.css):
- Added .btn-warning (amber) style used by the new Wipe & Restart button.
Frontend (app/page.tsx):
- Save Config button is now disabled when isBusy (node starting/stopping),
preventing config writes during transient states.
- Mining card is now rendered above RPC Endpoints when the node is running.
- Added restartWipeMutation and 'Wipe & Restart' amber button (Trash2 icon)
next to the Restart button; shows a confirm() dialog before proceeding.
- restartWipeMutation.isPending contributes to isBusy and statusLabel.
- Error display now includes restartWipeMutation.error.
Contracts: fix EVM deploy, add Core deploy, persist deployed contracts
Backend:
- contract-storage.ts: new ContractStorageService singleton persisting
deployed contract records to <walletDataDir>/contracts.json per wallet.
Wired into NodeManager.start() (setDataDir) and restartWipe() (wipeFile).
- contracts.ts: complete rewrite
- EVM deploy: encodeDeployData + sendTransaction with gas: 5_000_000n
bypasses eth_estimateGas which Conflux eSpace falsely rejects
- Use nodeManager.getConfig() for chain IDs (avoids undefined->71 fallback)
- Core Space deploy: cive library with privateKeyToAccount(key, {networkId})
and toCiveChain(); receipt.contractCreated for contract address
- All deploys persist to contractStorage after success
- New routes: GET/DELETE /deployed, GET/DELETE /deployed/:id
- package.json: added cive ^0.8.1
Frontend:
- api.ts: del() helper, StoredContract interface, id in DeployResult,
contractName in deploy opts, contractsApi.deployed() and deleteDeployed()
- contracts/page.tsx: full rewrite with 3 tabs (Templates/Custom/Deployed)
- Deployed tab: lists persisted contracts with address copy, chain badge,
ABI entry count, tx hash copy, delete button
- deployMutation: passes contractName, invalidates deployed query on success
Contracts: fix TS error - add chain: coreChain to Core deployContract call
fix: deploy — _packMining lock prevents xcfx concurrent-mine crash; follow xcfx-node reference pattern
- Switch auto-miner from mine({numTxs:1}) every 500ms to mine({blocks:1}) every 2000ms
(mine({blocks}) is fast; mine({numTxs}) takes >10s on slow machines causing timeout cascade)
- Add _packMining flag: auto-miner skips its tick while packMine() is running
(concurrent test_generateEmptyBlocks + test_generateOneBlock crashes xcfx)
- Add packMine() method with 120s timeout client and _packMining lock
- devPackTxImmediately: false — matches xcfx-node reference test
- Deploy routes: packMine() once then poll loop [getTransactionReceipt + mine({blocks:1}) + sleep(200)]
- EVM: mine({numTxs:1}) is required to pack eSpace txs (mine({blocks}) never packs them)
- Core: same pattern for consistency
feat: contract interact panel — ABI viewer, read/write functions, account picker
Backend:
- POST /api/contracts/:id/call — server-side read and write for deployed contracts
- Reads (view/pure): readContract via viem/cive, returns serialized result as JSON
- Writes: writeContract + packMine() + poll loop (same pattern as deploy)
- Correct status mapping: cive outcomeStatus is 'success'|'failed'|'skipped' (not 0/1)
- serializeValue() helper: recursively converts BigInt to string for JSON serialization
- Address casts: use CiveAddress (type import from cive) instead of 'as any'
- contractsApi.call() added to API client
UI (contracts/page.tsx):
- FunctionCallForm component: per-function form with typed inputs (one field per param)
- ContractInteractPanel: Read/Write sections, auto-packed write with loading state
- Deployed card: expandable 'Interact' toggle — inline, no modal needed
- Account picker dropdown for write functions (all 10 funded accounts)
- Replace broken ExternalLink RPC button with copy-RPC-URL button
- Fix ExternalLink icon: opening a JSON-RPC port in browser always returns POST error
feat: wipe data without restart + collapse RPC into status card
Backend:
- Extract wipeData() from restartWipe() — stop if running, wipe data dir + contracts.json, do not restart
- restartWipe() now calls wipeData() then start()
- POST /api/node/wipe — wipes active wallet data dir regardless of node state
UI:
- Dashboard: 'Wipe Data' button accessible when node is stopped (was previously only 'Wipe & Restart' when running)
Both wipe actions ask for confirm() before proceeding
- Status label shows 'Wiping...' during wipe mutation
- RPC Endpoints section moved inside the top status card, collapsed by default
Toggled by 'RPC Endpoints' label with chevron — stays hidden until user needs it
Removes a permanent card from the dashboard reducing vertical noise
feat: per-param ctor args, account selector, fund auto-detect
fix(fund): use Core→eSpace bridge; compact mining; security middleware; bundle workspace deps
fund:
- fundEvmAccount now routes through the Conflux cross-chain internal contract
(0x0888...0006 transferEVM) from the Core-space faucet wallet instead of
trying to send from an EVM wallet that has no balance; fixes 'total cost
exceeds balance' error when funding eSpace addresses
mining card:
- Collapse all mining controls onto a single compact flex row: title, blocks
count badge, interval/blocks input, mine button, and auto toggle all inline
with a divider before the toggle
security:
- In-memory rate limiter (200 req/min/IP, no extra deps)
- Bearer token auth middleware activated by --api-key CLI flag; loopback IPs
are always trusted; all /api routes protected when key is set
- --host flag to set bind address (default 127.0.0.1); warns when binding
to a public interface without an API key
- --cors-origin flag for explicit CORS origin restriction
- GET /api/settings returns active security config (key value never exposed)
- SecurityPanel component in the dashboard showing bind address, auth status,
CORS, rate-limit settings and a public-host hardening checklist
build:
- tsup noExternal: [/^@cfxdevkit\//] bundles all workspace packages into the
single CLI output so the published npm package runs standalone
fix(build): CJS format, graceful shutdown, root scripts
- Switch tsup to CJS format: solc/memorystream/require() now work correctly
- Remove "type": "module" from devkit package.json
- Replace ESM __dirname workaround with native CJS __dirname global
- Add stop() to AppInstance: closes io, nodeManager, httpServer
- Register SIGINT/SIGTERM in cli.ts for proper Ctrl+C handling
- Add devkit:build, devkit:start, devkit:dev to root package.json
fix(deps): add @xcfx/node as direct dep of devtools/devkit
@xcfx/node is a NAPI-RS native module — it cannot be bundled by tsup.
It was only declared in packages/devnode but not in devtools/devkit,
so when the bundled dist/cli.js tried to require('@xcfx/node') at
runtime the module resolver could not find it, causing the worker
process to exit with code 1 immediately on every node-start attempt.
Adding it as a direct dep causes pnpm to create the required symlink
under devtools/devkit/node_modules/@xcfx/node so the built CLI can
resolve it correctly.
feat(contracts): add 6 practical/didactical Solidity templates
New templates (all pure Solidity, no OpenZeppelin deps):
- Counter: ownable step counter with increment/decrement/reset
- BasicNFT: ERC-721 from scratch — ownership, approvals, transfers
- Voting: ballot with weighted vote delegation — structs, governance
- Escrow: three-party escrow — payable, state machines, CFX transfers
- MultiSigWallet: M-of-N multisig — collective governance, low-level call
- Registry: on-chain name service — keccak256 keys, string storage
UI Templates tab overhaul:
- Difficulty badge (beginner / intermediate / advanced)
- Concept tags per template (ERC-20, NFT, governance, etc.)
- Constructor args hint
- Description instead of raw source preview
chore: biome cleanup, CI, docs
- Fix all biome lint errors: remove unused imports (Shield, ServerSettings,
NetworkConfig, RpcUrls), remove unused CopyBtn in wallet page, remove
useless fragment, replace non-null assertions with null coalescing,
fix array-index keys with stable composite keys, prefix unused params
with underscore
- Add biome.json overrides: suppress noUnknownAtRules for CSS files
(Tailwind directives), suppress noLabelWithoutControl for devkit-ui
(developer tooling, not public-facing app)
- Exclude globals.css from biome (Tailwind directives cause parse errors)
- Create .github/workflows/ci.yml: lint, typecheck, build, test jobs
using pnpm 10.11.0 + Node 22, Turbo cache, coverage artifact upload
- Update README.md: remove duplicate sections, add conflux-devkit features
section with template inventory and devkit/README.md reference
- Create devtools/devkit/README.md: full CLI documentation with options,
dashboard feature table, template catalogue, RPC endpoints, security
guidance, WebSocket events, build-from-source instructions1 parent 9b76e05 commit 3a6f325
File tree
43 files changed
+4643
-822
lines changed- .github/workflows
- devtools
- devkit-ui/src
- app
- accounts
- contracts
- mining
- network
- wallet
- components
- lib
- devkit
- src
- server
- routes
- packages
- compiler/src
- templates
- contracts
- devnode/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
43 files changed
+4643
-822
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
73 | | - | |
| 72 | + | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | 180 | | |
190 | 181 | | |
191 | 182 | | |
| |||
243 | 234 | | |
244 | 235 | | |
245 | 236 | | |
246 | | - | |
| 237 | + | |
247 | 238 | | |
248 | 239 | | |
249 | 240 | | |
| |||
257 | 248 | | |
258 | 249 | | |
259 | 250 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | 251 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
0 commit comments