@cfxdevkit/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE +72 -0
  3. package/README.md +257 -0
  4. package/dist/clients/index.cjs +2053 -0
  5. package/dist/clients/index.cjs.map +1 -0
  6. package/dist/clients/index.d.cts +7 -0
  7. package/dist/clients/index.d.ts +7 -0
  8. package/dist/clients/index.js +2043 -0
  9. package/dist/clients/index.js.map +1 -0
  10. package/dist/config/index.cjs +423 -0
  11. package/dist/config/index.cjs.map +1 -0
  12. package/dist/config/index.d.cts +99 -0
  13. package/dist/config/index.d.ts +99 -0
  14. package/dist/config/index.js +380 -0
  15. package/dist/config/index.js.map +1 -0
  16. package/dist/config-BMtaWM0X.d.cts +165 -0
  17. package/dist/config-BMtaWM0X.d.ts +165 -0
  18. package/dist/core-C5qe16RS.d.ts +352 -0
  19. package/dist/core-RZA4aKwj.d.cts +352 -0
  20. package/dist/index-BhCpy6Fz.d.cts +165 -0
  21. package/dist/index-Qz84U9Oq.d.ts +165 -0
  22. package/dist/index.cjs +3773 -0
  23. package/dist/index.cjs.map +1 -0
  24. package/dist/index.d.cts +945 -0
  25. package/dist/index.d.ts +945 -0
  26. package/dist/index.js +3730 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/types/index.cjs +44 -0
  29. package/dist/types/index.cjs.map +1 -0
  30. package/dist/types/index.d.cts +5 -0
  31. package/dist/types/index.d.ts +5 -0
  32. package/dist/types/index.js +17 -0
  33. package/dist/types/index.js.map +1 -0
  34. package/dist/utils/index.cjs +83 -0
  35. package/dist/utils/index.cjs.map +1 -0
  36. package/dist/utils/index.d.cts +11 -0
  37. package/dist/utils/index.d.ts +11 -0
  38. package/dist/utils/index.js +56 -0
  39. package/dist/utils/index.js.map +1 -0
  40. package/dist/wallet/index.cjs +852 -0
  41. package/dist/wallet/index.cjs.map +1 -0
  42. package/dist/wallet/index.d.cts +726 -0
  43. package/dist/wallet/index.d.ts +726 -0
  44. package/dist/wallet/index.js +815 -0
  45. package/dist/wallet/index.js.map +1 -0
  46. package/package.json +119 -0
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/types/index.ts
21
+ var types_exports = {};
22
+ __export(types_exports, {
23
+ NodeError: () => NodeError
24
+ });
25
+ module.exports = __toCommonJS(types_exports);
26
+
27
+ // src/types/config.ts
28
+ var NodeError = class extends Error {
29
+ code;
30
+ chain;
31
+ context;
32
+ constructor(message, code, chain, context) {
33
+ super(message);
34
+ this.name = "NodeError";
35
+ this.code = code;
36
+ this.chain = chain;
37
+ this.context = context;
38
+ }
39
+ };
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ NodeError
43
+ });
44
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/index.ts","../../src/types/config.ts"],"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\n// Types Index - Export all type definitions\n\n// Re-export chain types from config\nexport type { SupportedChainId } from '../config/chains.js';\nexport * from './clients.js';\nexport * from './config.js';\n\n// Health status enum\nexport type HealthStatus = 'healthy' | 'unhealthy' | 'disconnected' | 'unknown';\n\n// Import client types\nimport type {\n CoreClient,\n CoreTestClient,\n CoreWalletClient,\n} from '../clients/core.js';\nimport type {\n EspaceClient,\n EspaceTestClient,\n EspaceWalletClient,\n} from '../clients/evm.js';\n\n// Combined client instance types\nexport interface CoreClientInstance {\n publicClient: CoreClient;\n walletClient?: CoreWalletClient;\n testClient?: CoreTestClient;\n}\n\nexport interface EspaceClientInstance {\n publicClient: EspaceClient;\n walletClient?: EspaceWalletClient;\n testClient?: EspaceTestClient;\n}\n\n// DevKit API Types\nexport interface StartOptions {\n mining?: boolean;\n waitForBlocks?: number;\n fundingAmount?: string;\n}\n\nexport interface DeployOptions {\n abi: unknown[];\n bytecode: string;\n args?: unknown[];\n account: number;\n chain?: 'core' | 'evm';\n chains?: ('core' | 'evm')[];\n value?: bigint;\n}\n\nexport interface ReadOptions {\n address: string;\n abi: unknown[];\n functionName: string;\n args?: unknown[];\n chain: 'core' | 'evm';\n}\n\nexport interface WriteOptions {\n address: string;\n abi: unknown[];\n functionName: string;\n args?: unknown[];\n account: number;\n chain: 'core' | 'evm';\n value?: bigint;\n waitForConfirmation?: boolean;\n}\n\nexport interface ContractResult {\n core?: string;\n evm?: string;\n}\n\nexport interface ChainStatus {\n core: { connected: boolean; status: string };\n evm: { connected: boolean; status: string };\n}\n\nexport interface FaucetBalances {\n coreBalance: string;\n evmBalance: string;\n}\n\nexport interface MiningStatus {\n isRunning: boolean;\n interval: number;\n blocksMined: number;\n startTime?: Date;\n}\n\nexport interface ChainBalances {\n core: string;\n evm: string;\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// Core Configuration Types\n// Based on proven patterns from DevKit CLI and @xcfx/node\n\nexport interface NodeConfig {\n // Chain Configuration\n readonly chainId?: number; // Core space chain ID (default: 2029)\n readonly evmChainId?: number; // EVM space chain ID (default: 2030)\n\n // Network Ports\n readonly jsonrpcHttpPort?: number; // Core HTTP RPC port (default: 12537)\n readonly jsonrpcHttpEthPort?: number; // EVM HTTP RPC port (default: 8545)\n readonly jsonrpcWsPort?: number; // Core WebSocket port (default: 12538)\n readonly jsonrpcWsEthPort?: number; // EVM WebSocket port (default: 8546)\n\n // // Development Settings\n // readonly devBlockIntervalMs?: number; // Block generation interval (default: 1000)\n // readonly devPackTxImmediately?: boolean; // Pack transactions immediately\n\n // Data & Logging\n readonly confluxDataDir?: string; // Data directory path\n readonly log?: boolean; // Enable console logging\n readonly logConf?: string; // Custom log configuration file\n\n // Genesis Configuration\n readonly genesisSecrets?: readonly string[]; // Core space genesis private keys\n readonly genesisEvmSecrets?: readonly string[]; // EVM space genesis private keys\n readonly miningAuthor?: string; // Mining rewards recipient\n\n // Node Type\n readonly nodeType?: 'full' | 'archive' | 'light';\n readonly blockDbType?: 'rocksdb' | 'sqlite';\n}\n\nexport interface ExtendedNodeConfig extends NodeConfig {\n // DevKit Extensions\n readonly accountCount?: number; // Number of accounts to generate per chain\n readonly silent?: boolean; // Suppress all logging\n readonly fundAccounts?: boolean; // Auto-fund generated accounts\n readonly enabledChains?: readonly ('core' | 'evm')[]; // Active chains\n\n // Derivation paths for account generation\n readonly derivationPaths?: {\n readonly core: string; // Core derivation path template\n readonly evm: string; // EVM derivation path template\n };\n}\n\n// Address and Hash Types\nexport type Address = string;\nexport type CoreAddress = string; // cfx:... format\nexport type EvmAddress = string; // 0x... format\nexport type Hash = string;\nexport type ChainType = 'core' | 'evm';\n\n// Account Types\nexport interface UnifiedAccount {\n readonly id: string; // Unique identifier\n readonly name: string; // Human-readable name\n readonly index: number; // Derivation index\n readonly privateKey: string; // Private key (hex format)\n readonly derivationPath: string; // BIP32 derivation path\n\n // Chain-specific addresses (same private key, different formats)\n readonly coreAddress: CoreAddress; // cfx:... format\n readonly evmAddress: EvmAddress; // 0x... format\n\n // Chain-specific state\n readonly coreBalance: bigint;\n readonly evmBalance: bigint;\n readonly coreNonce: number;\n readonly evmNonce: number;\n\n // Metadata\n readonly isActive: boolean;\n readonly createdAt: Date;\n readonly updatedAt: Date;\n}\n\n// Client Status Types\nexport interface ChainStatus {\n readonly isRunning: boolean;\n readonly chainId: number;\n readonly blockNumber: bigint;\n readonly gasPrice: bigint;\n readonly peerCount: number;\n readonly syncStatus: 'syncing' | 'synced';\n readonly latestBlockHash: string;\n readonly mining: boolean;\n readonly pendingTransactions: number;\n readonly rpcEndpoint: string;\n readonly wsEndpoint?: string;\n}\n\nexport interface NodeStatus {\n readonly isRunning: boolean;\n readonly uptime: number;\n readonly startTime: Date | null;\n readonly core: ChainStatus;\n readonly evm: ChainStatus;\n readonly dataDir: string;\n readonly config: NodeConfig;\n readonly mining: MiningStatus;\n}\n\nexport interface MiningStatus {\n readonly isRunning: boolean;\n readonly interval: number;\n readonly blocksMined: number;\n readonly startTime: Date | null;\n readonly lastBlockTime: Date | null;\n}\n\n// Transaction Types\nexport interface BaseTransaction {\n readonly to?: string;\n readonly value?: bigint;\n readonly data?: string;\n readonly gasLimit?: bigint;\n readonly gasPrice?: bigint;\n readonly nonce?: number;\n}\n\nexport interface TransactionReceipt {\n readonly hash: string;\n readonly blockNumber: bigint;\n readonly blockHash: string;\n readonly transactionIndex: number;\n readonly status: 'success' | 'reverted';\n readonly gasUsed: bigint;\n readonly contractAddress?: string;\n readonly logs: readonly Log[];\n}\n\nexport interface Log {\n readonly address: string;\n readonly topics: readonly string[];\n readonly data: string;\n readonly blockNumber: bigint;\n readonly transactionHash: string;\n readonly logIndex: number;\n}\n\n// Error Types\nexport interface ConfluxNodeError extends Error {\n readonly code: string;\n readonly chain?: ChainType;\n readonly context?: Record<string, unknown>;\n}\n\nexport class NodeError extends Error implements ConfluxNodeError {\n public readonly code: string;\n public readonly chain?: ChainType;\n public readonly context?: Record<string, unknown>;\n\n constructor(\n message: string,\n code: string,\n chain?: ChainType,\n context?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'NodeError';\n this.code = code;\n this.chain = chain;\n this.context = context;\n }\n}\n\n// Event Types\nexport interface BlockEvent {\n readonly chainType: ChainType;\n readonly blockNumber: bigint;\n readonly blockHash: string;\n readonly timestamp: number;\n readonly transactionCount: number;\n}\n\nexport interface TransactionEvent {\n readonly chainType: ChainType;\n readonly hash: string;\n readonly from: string;\n readonly to?: string;\n readonly value: bigint;\n readonly blockNumber: bigint;\n}\n\n// Utility Types\nexport type EventCallback<T> = (event: T) => void;\nexport type UnwatchFunction = () => void;\n\n// Server Management Types\nexport type ServerStatus =\n | 'stopped'\n | 'starting'\n | 'running'\n | 'stopping'\n | 'error';\n\nexport interface ServerConfig {\n readonly coreRpcPort?: number;\n readonly evmRpcPort?: number;\n readonly wsPort?: number;\n readonly chainId?: number;\n readonly evmChainId?: number;\n readonly accounts?: number;\n readonly balance?: string;\n readonly mnemonic?: string;\n readonly logging?: boolean;\n readonly detached?: boolean;\n readonly mining?: MiningConfig;\n readonly devBlockIntervalMs?: number; // Auto block generation interval in ms (undefined = disabled)\n readonly devPackTxImmediately?: boolean; // Pack transactions immediately for responsiveness\n readonly dataDir?: string; // Data directory for Conflux node (default: /workspace/.conflux-dev)\n}\n\nexport interface MiningConfig {\n readonly enabled: boolean;\n readonly interval: number; // milliseconds between blocks\n readonly autoStart: boolean; // start mining when server starts\n}\n\nexport interface AccountInfo {\n readonly index: number;\n readonly privateKey: string;\n readonly coreAddress: string;\n readonly evmAddress: string;\n readonly mnemonic: string;\n readonly path: string;\n readonly evmPrivateKey?: string; // Ethereum-derived private key for EVM operations\n readonly evmPath?: string; // Ethereum derivation path (m/44'/60'/0'/0/i)\n}\n\n// Additional types will be migrated from devkit-node as needed\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqKO,IAAM,YAAN,cAAwB,MAAkC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,YACE,SACA,MACA,OACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EACjB;AACF;","names":[]}
@@ -0,0 +1,5 @@
1
+ export { SupportedChainId } from '../config/index.cjs';
2
+ export { h as ChainBalances, i as ChainClient, j as ChainStatus, e as ClientConfig, k as ClientFactory, l as ClientManager, m as ContractResult, f as CoreClientInstance, D as DeployOptions, g as EspaceClientInstance, F as FaucetBalances, H as HealthStatus, M as MiningStatus, R as ReadOptions, S as StartOptions, T as TestClient, n as TestConfig, W as WalletClient, o as WalletConfig, p as WriteOptions } from '../core-RZA4aKwj.cjs';
3
+ export { c as AccountInfo, A as Address, B as BaseTransaction, a as BlockEvent, C as ChainType, d as ConfluxNodeError, e as CoreAddress, E as EventCallback, f as EvmAddress, g as ExtendedNodeConfig, H as Hash, L as Log, M as MiningConfig, N as NodeConfig, h as NodeError, i as NodeStatus, S as ServerConfig, j as ServerStatus, b as TransactionEvent, T as TransactionReceipt, k as UnifiedAccount, U as UnwatchFunction } from '../config-BMtaWM0X.cjs';
4
+ import 'cive';
5
+ import 'viem';
@@ -0,0 +1,5 @@
1
+ export { SupportedChainId } from '../config/index.js';
2
+ export { h as ChainBalances, i as ChainClient, j as ChainStatus, e as ClientConfig, k as ClientFactory, l as ClientManager, m as ContractResult, f as CoreClientInstance, D as DeployOptions, g as EspaceClientInstance, F as FaucetBalances, H as HealthStatus, M as MiningStatus, R as ReadOptions, S as StartOptions, T as TestClient, n as TestConfig, W as WalletClient, o as WalletConfig, p as WriteOptions } from '../core-C5qe16RS.js';
3
+ export { c as AccountInfo, A as Address, B as BaseTransaction, a as BlockEvent, C as ChainType, d as ConfluxNodeError, e as CoreAddress, E as EventCallback, f as EvmAddress, g as ExtendedNodeConfig, H as Hash, L as Log, M as MiningConfig, N as NodeConfig, h as NodeError, i as NodeStatus, S as ServerConfig, j as ServerStatus, b as TransactionEvent, T as TransactionReceipt, k as UnifiedAccount, U as UnwatchFunction } from '../config-BMtaWM0X.js';
4
+ import 'cive';
5
+ import 'viem';
@@ -0,0 +1,17 @@
1
+ // src/types/config.ts
2
+ var NodeError = class extends Error {
3
+ code;
4
+ chain;
5
+ context;
6
+ constructor(message, code, chain, context) {
7
+ super(message);
8
+ this.name = "NodeError";
9
+ this.code = code;
10
+ this.chain = chain;
11
+ this.context = context;
12
+ }
13
+ };
14
+ export {
15
+ NodeError
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/config.ts"],"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\n// Core Configuration Types\n// Based on proven patterns from DevKit CLI and @xcfx/node\n\nexport interface NodeConfig {\n // Chain Configuration\n readonly chainId?: number; // Core space chain ID (default: 2029)\n readonly evmChainId?: number; // EVM space chain ID (default: 2030)\n\n // Network Ports\n readonly jsonrpcHttpPort?: number; // Core HTTP RPC port (default: 12537)\n readonly jsonrpcHttpEthPort?: number; // EVM HTTP RPC port (default: 8545)\n readonly jsonrpcWsPort?: number; // Core WebSocket port (default: 12538)\n readonly jsonrpcWsEthPort?: number; // EVM WebSocket port (default: 8546)\n\n // // Development Settings\n // readonly devBlockIntervalMs?: number; // Block generation interval (default: 1000)\n // readonly devPackTxImmediately?: boolean; // Pack transactions immediately\n\n // Data & Logging\n readonly confluxDataDir?: string; // Data directory path\n readonly log?: boolean; // Enable console logging\n readonly logConf?: string; // Custom log configuration file\n\n // Genesis Configuration\n readonly genesisSecrets?: readonly string[]; // Core space genesis private keys\n readonly genesisEvmSecrets?: readonly string[]; // EVM space genesis private keys\n readonly miningAuthor?: string; // Mining rewards recipient\n\n // Node Type\n readonly nodeType?: 'full' | 'archive' | 'light';\n readonly blockDbType?: 'rocksdb' | 'sqlite';\n}\n\nexport interface ExtendedNodeConfig extends NodeConfig {\n // DevKit Extensions\n readonly accountCount?: number; // Number of accounts to generate per chain\n readonly silent?: boolean; // Suppress all logging\n readonly fundAccounts?: boolean; // Auto-fund generated accounts\n readonly enabledChains?: readonly ('core' | 'evm')[]; // Active chains\n\n // Derivation paths for account generation\n readonly derivationPaths?: {\n readonly core: string; // Core derivation path template\n readonly evm: string; // EVM derivation path template\n };\n}\n\n// Address and Hash Types\nexport type Address = string;\nexport type CoreAddress = string; // cfx:... format\nexport type EvmAddress = string; // 0x... format\nexport type Hash = string;\nexport type ChainType = 'core' | 'evm';\n\n// Account Types\nexport interface UnifiedAccount {\n readonly id: string; // Unique identifier\n readonly name: string; // Human-readable name\n readonly index: number; // Derivation index\n readonly privateKey: string; // Private key (hex format)\n readonly derivationPath: string; // BIP32 derivation path\n\n // Chain-specific addresses (same private key, different formats)\n readonly coreAddress: CoreAddress; // cfx:... format\n readonly evmAddress: EvmAddress; // 0x... format\n\n // Chain-specific state\n readonly coreBalance: bigint;\n readonly evmBalance: bigint;\n readonly coreNonce: number;\n readonly evmNonce: number;\n\n // Metadata\n readonly isActive: boolean;\n readonly createdAt: Date;\n readonly updatedAt: Date;\n}\n\n// Client Status Types\nexport interface ChainStatus {\n readonly isRunning: boolean;\n readonly chainId: number;\n readonly blockNumber: bigint;\n readonly gasPrice: bigint;\n readonly peerCount: number;\n readonly syncStatus: 'syncing' | 'synced';\n readonly latestBlockHash: string;\n readonly mining: boolean;\n readonly pendingTransactions: number;\n readonly rpcEndpoint: string;\n readonly wsEndpoint?: string;\n}\n\nexport interface NodeStatus {\n readonly isRunning: boolean;\n readonly uptime: number;\n readonly startTime: Date | null;\n readonly core: ChainStatus;\n readonly evm: ChainStatus;\n readonly dataDir: string;\n readonly config: NodeConfig;\n readonly mining: MiningStatus;\n}\n\nexport interface MiningStatus {\n readonly isRunning: boolean;\n readonly interval: number;\n readonly blocksMined: number;\n readonly startTime: Date | null;\n readonly lastBlockTime: Date | null;\n}\n\n// Transaction Types\nexport interface BaseTransaction {\n readonly to?: string;\n readonly value?: bigint;\n readonly data?: string;\n readonly gasLimit?: bigint;\n readonly gasPrice?: bigint;\n readonly nonce?: number;\n}\n\nexport interface TransactionReceipt {\n readonly hash: string;\n readonly blockNumber: bigint;\n readonly blockHash: string;\n readonly transactionIndex: number;\n readonly status: 'success' | 'reverted';\n readonly gasUsed: bigint;\n readonly contractAddress?: string;\n readonly logs: readonly Log[];\n}\n\nexport interface Log {\n readonly address: string;\n readonly topics: readonly string[];\n readonly data: string;\n readonly blockNumber: bigint;\n readonly transactionHash: string;\n readonly logIndex: number;\n}\n\n// Error Types\nexport interface ConfluxNodeError extends Error {\n readonly code: string;\n readonly chain?: ChainType;\n readonly context?: Record<string, unknown>;\n}\n\nexport class NodeError extends Error implements ConfluxNodeError {\n public readonly code: string;\n public readonly chain?: ChainType;\n public readonly context?: Record<string, unknown>;\n\n constructor(\n message: string,\n code: string,\n chain?: ChainType,\n context?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'NodeError';\n this.code = code;\n this.chain = chain;\n this.context = context;\n }\n}\n\n// Event Types\nexport interface BlockEvent {\n readonly chainType: ChainType;\n readonly blockNumber: bigint;\n readonly blockHash: string;\n readonly timestamp: number;\n readonly transactionCount: number;\n}\n\nexport interface TransactionEvent {\n readonly chainType: ChainType;\n readonly hash: string;\n readonly from: string;\n readonly to?: string;\n readonly value: bigint;\n readonly blockNumber: bigint;\n}\n\n// Utility Types\nexport type EventCallback<T> = (event: T) => void;\nexport type UnwatchFunction = () => void;\n\n// Server Management Types\nexport type ServerStatus =\n | 'stopped'\n | 'starting'\n | 'running'\n | 'stopping'\n | 'error';\n\nexport interface ServerConfig {\n readonly coreRpcPort?: number;\n readonly evmRpcPort?: number;\n readonly wsPort?: number;\n readonly chainId?: number;\n readonly evmChainId?: number;\n readonly accounts?: number;\n readonly balance?: string;\n readonly mnemonic?: string;\n readonly logging?: boolean;\n readonly detached?: boolean;\n readonly mining?: MiningConfig;\n readonly devBlockIntervalMs?: number; // Auto block generation interval in ms (undefined = disabled)\n readonly devPackTxImmediately?: boolean; // Pack transactions immediately for responsiveness\n readonly dataDir?: string; // Data directory for Conflux node (default: /workspace/.conflux-dev)\n}\n\nexport interface MiningConfig {\n readonly enabled: boolean;\n readonly interval: number; // milliseconds between blocks\n readonly autoStart: boolean; // start mining when server starts\n}\n\nexport interface AccountInfo {\n readonly index: number;\n readonly privateKey: string;\n readonly coreAddress: string;\n readonly evmAddress: string;\n readonly mnemonic: string;\n readonly path: string;\n readonly evmPrivateKey?: string; // Ethereum-derived private key for EVM operations\n readonly evmPath?: string; // Ethereum derivation path (m/44'/60'/0'/0/i)\n}\n\n// Additional types will be migrated from devkit-node as needed\n"],"mappings":";AAqKO,IAAM,YAAN,cAAwB,MAAkC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,YACE,SACA,MACA,OACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EACjB;AACF;","names":[]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/index.ts
21
+ var utils_exports = {};
22
+ __export(utils_exports, {
23
+ logger: () => logger
24
+ });
25
+ module.exports = __toCommonJS(utils_exports);
26
+
27
+ // src/utils/logger.ts
28
+ var colors = {
29
+ info: "\x1B[36m",
30
+ // Cyan
31
+ warn: "\x1B[33m",
32
+ // Yellow
33
+ error: "\x1B[31m",
34
+ // Red
35
+ success: "\x1B[32m",
36
+ // Green
37
+ debug: "\x1B[90m",
38
+ // Gray
39
+ reset: "\x1B[0m"
40
+ // Reset
41
+ };
42
+ function formatMessage(level, message, ...args) {
43
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
44
+ const formattedArgs = args.length > 0 ? ` ${args.map(
45
+ (arg) => arg !== null && typeof arg === "object" ? JSON.stringify(
46
+ arg,
47
+ (_key, value) => typeof value === "bigint" ? value.toString() : value,
48
+ 2
49
+ ) : String(arg)
50
+ ).join(" ")}` : "";
51
+ return `[${timestamp}] ${level.toUpperCase()}: ${message}${formattedArgs}`;
52
+ }
53
+ function handleLog(level, color, fn, messageOrObj, maybeMsg, ...args) {
54
+ let msg = typeof messageOrObj === "string" ? messageOrObj : String(messageOrObj);
55
+ let objs = maybeMsg !== void 0 ? [maybeMsg, ...args] : args;
56
+ if (typeof messageOrObj === "object" && typeof maybeMsg === "string") {
57
+ msg = maybeMsg;
58
+ objs = [messageOrObj, ...args];
59
+ }
60
+ fn(color + formatMessage(level, msg, ...objs) + colors.reset);
61
+ }
62
+ var logger = {
63
+ info(m, m2, ...args) {
64
+ handleLog("info", colors.info, console.log, m, m2, ...args);
65
+ },
66
+ warn(m, m2, ...args) {
67
+ handleLog("warn", colors.warn, console.warn, m, m2, ...args);
68
+ },
69
+ error(m, m2, ...args) {
70
+ handleLog("error", colors.error, console.error, m, m2, ...args);
71
+ },
72
+ success(m, m2, ...args) {
73
+ handleLog("success", colors.success, console.log, m, m2, ...args);
74
+ },
75
+ debug(m, m2, ...args) {
76
+ handleLog("debug", colors.debug, console.log, m, m2, ...args);
77
+ }
78
+ };
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ logger
82
+ });
83
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/index.ts","../../src/utils/logger.ts"],"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\n// @cfxdevkit/core - Utils module\n// Shared utilities: logger, formatting helpers\n\nexport { logger } from './logger.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 * Simple logger utility\n */\n\nconst colors = {\n info: '\\x1b[36m', // Cyan\n warn: '\\x1b[33m', // Yellow\n error: '\\x1b[31m', // Red\n success: '\\x1b[32m', // Green\n debug: '\\x1b[90m', // Gray\n reset: '\\x1b[0m', // Reset\n};\n\n/** A structured log object or plain message string — mirrors the pino/winston dual-form API. */\ntype LogMessage = string | Record<string, unknown>;\n\nfunction formatMessage(\n level: string,\n message: string,\n ...args: unknown[]\n): string {\n const timestamp = new Date().toISOString();\n const formattedArgs =\n args.length > 0\n ? ` ${args\n .map((arg) =>\n arg !== null && typeof arg === 'object'\n ? JSON.stringify(\n arg,\n (_key, value) =>\n typeof value === 'bigint' ? value.toString() : value,\n 2\n )\n : String(arg)\n )\n .join(' ')}`\n : '';\n\n return `[${timestamp}] ${level.toUpperCase()}: ${message}${formattedArgs}`;\n}\n\nfunction handleLog(\n level: string,\n color: string,\n fn: (message: string) => void,\n messageOrObj: LogMessage,\n maybeMsg?: unknown,\n ...args: unknown[]\n): void {\n let msg =\n typeof messageOrObj === 'string' ? messageOrObj : String(messageOrObj);\n let objs: unknown[] = maybeMsg !== undefined ? [maybeMsg, ...args] : args;\n\n if (typeof messageOrObj === 'object' && typeof maybeMsg === 'string') {\n msg = maybeMsg;\n objs = [messageOrObj, ...args];\n }\n\n fn(color + formatMessage(level, msg, ...objs) + colors.reset);\n}\n\nexport const logger = {\n info(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('info', colors.info, console.log, m, m2, ...args);\n },\n warn(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('warn', colors.warn, console.warn, m, m2, ...args);\n },\n error(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('error', colors.error, console.error, m, m2, ...args);\n },\n success(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('success', colors.success, console.log, m, m2, ...args);\n },\n debug(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('debug', colors.debug, console.log, m, m2, ...args);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoBA,IAAM,SAAS;AAAA,EACb,MAAM;AAAA;AAAA,EACN,MAAM;AAAA;AAAA,EACN,OAAO;AAAA;AAAA,EACP,SAAS;AAAA;AAAA,EACT,OAAO;AAAA;AAAA,EACP,OAAO;AAAA;AACT;AAKA,SAAS,cACP,OACA,YACG,MACK;AACR,QAAM,aAAY,oBAAI,KAAK,GAAE,YAAY;AACzC,QAAM,gBACJ,KAAK,SAAS,IACV,IAAI,KACD;AAAA,IAAI,CAAC,QACJ,QAAQ,QAAQ,OAAO,QAAQ,WAC3B,KAAK;AAAA,MACH;AAAA,MACA,CAAC,MAAM,UACL,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,MACjD;AAAA,IACF,IACA,OAAO,GAAG;AAAA,EAChB,EACC,KAAK,GAAG,CAAC,KACZ;AAEN,SAAO,IAAI,SAAS,KAAK,MAAM,YAAY,CAAC,KAAK,OAAO,GAAG,aAAa;AAC1E;AAEA,SAAS,UACP,OACA,OACA,IACA,cACA,aACG,MACG;AACN,MAAI,MACF,OAAO,iBAAiB,WAAW,eAAe,OAAO,YAAY;AACvE,MAAI,OAAkB,aAAa,SAAY,CAAC,UAAU,GAAG,IAAI,IAAI;AAErE,MAAI,OAAO,iBAAiB,YAAY,OAAO,aAAa,UAAU;AACpE,UAAM;AACN,WAAO,CAAC,cAAc,GAAG,IAAI;AAAA,EAC/B;AAEA,KAAG,QAAQ,cAAc,OAAO,KAAK,GAAG,IAAI,IAAI,OAAO,KAAK;AAC9D;AAEO,IAAM,SAAS;AAAA,EACpB,KAAK,GAAe,OAAiB,MAAuB;AAC1D,cAAU,QAAQ,OAAO,MAAM,QAAQ,KAAK,GAAG,IAAI,GAAG,IAAI;AAAA,EAC5D;AAAA,EACA,KAAK,GAAe,OAAiB,MAAuB;AAC1D,cAAU,QAAQ,OAAO,MAAM,QAAQ,MAAM,GAAG,IAAI,GAAG,IAAI;AAAA,EAC7D;AAAA,EACA,MAAM,GAAe,OAAiB,MAAuB;AAC3D,cAAU,SAAS,OAAO,OAAO,QAAQ,OAAO,GAAG,IAAI,GAAG,IAAI;AAAA,EAChE;AAAA,EACA,QAAQ,GAAe,OAAiB,MAAuB;AAC7D,cAAU,WAAW,OAAO,SAAS,QAAQ,KAAK,GAAG,IAAI,GAAG,IAAI;AAAA,EAClE;AAAA,EACA,MAAM,GAAe,OAAiB,MAAuB;AAC3D,cAAU,SAAS,OAAO,OAAO,QAAQ,KAAK,GAAG,IAAI,GAAG,IAAI;AAAA,EAC9D;AACF;","names":[]}
@@ -0,0 +1,11 @@
1
+ /** A structured log object or plain message string — mirrors the pino/winston dual-form API. */
2
+ type LogMessage = string | Record<string, unknown>;
3
+ declare const logger: {
4
+ info(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
5
+ warn(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
6
+ error(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
7
+ success(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
8
+ debug(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
9
+ };
10
+
11
+ export { logger };
@@ -0,0 +1,11 @@
1
+ /** A structured log object or plain message string — mirrors the pino/winston dual-form API. */
2
+ type LogMessage = string | Record<string, unknown>;
3
+ declare const logger: {
4
+ info(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
5
+ warn(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
6
+ error(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
7
+ success(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
8
+ debug(m: LogMessage, m2?: unknown, ...args: unknown[]): void;
9
+ };
10
+
11
+ export { logger };
@@ -0,0 +1,56 @@
1
+ // src/utils/logger.ts
2
+ var colors = {
3
+ info: "\x1B[36m",
4
+ // Cyan
5
+ warn: "\x1B[33m",
6
+ // Yellow
7
+ error: "\x1B[31m",
8
+ // Red
9
+ success: "\x1B[32m",
10
+ // Green
11
+ debug: "\x1B[90m",
12
+ // Gray
13
+ reset: "\x1B[0m"
14
+ // Reset
15
+ };
16
+ function formatMessage(level, message, ...args) {
17
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
18
+ const formattedArgs = args.length > 0 ? ` ${args.map(
19
+ (arg) => arg !== null && typeof arg === "object" ? JSON.stringify(
20
+ arg,
21
+ (_key, value) => typeof value === "bigint" ? value.toString() : value,
22
+ 2
23
+ ) : String(arg)
24
+ ).join(" ")}` : "";
25
+ return `[${timestamp}] ${level.toUpperCase()}: ${message}${formattedArgs}`;
26
+ }
27
+ function handleLog(level, color, fn, messageOrObj, maybeMsg, ...args) {
28
+ let msg = typeof messageOrObj === "string" ? messageOrObj : String(messageOrObj);
29
+ let objs = maybeMsg !== void 0 ? [maybeMsg, ...args] : args;
30
+ if (typeof messageOrObj === "object" && typeof maybeMsg === "string") {
31
+ msg = maybeMsg;
32
+ objs = [messageOrObj, ...args];
33
+ }
34
+ fn(color + formatMessage(level, msg, ...objs) + colors.reset);
35
+ }
36
+ var logger = {
37
+ info(m, m2, ...args) {
38
+ handleLog("info", colors.info, console.log, m, m2, ...args);
39
+ },
40
+ warn(m, m2, ...args) {
41
+ handleLog("warn", colors.warn, console.warn, m, m2, ...args);
42
+ },
43
+ error(m, m2, ...args) {
44
+ handleLog("error", colors.error, console.error, m, m2, ...args);
45
+ },
46
+ success(m, m2, ...args) {
47
+ handleLog("success", colors.success, console.log, m, m2, ...args);
48
+ },
49
+ debug(m, m2, ...args) {
50
+ handleLog("debug", colors.debug, console.log, m, m2, ...args);
51
+ }
52
+ };
53
+ export {
54
+ logger
55
+ };
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/logger.ts"],"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\n/**\n * Simple logger utility\n */\n\nconst colors = {\n info: '\\x1b[36m', // Cyan\n warn: '\\x1b[33m', // Yellow\n error: '\\x1b[31m', // Red\n success: '\\x1b[32m', // Green\n debug: '\\x1b[90m', // Gray\n reset: '\\x1b[0m', // Reset\n};\n\n/** A structured log object or plain message string — mirrors the pino/winston dual-form API. */\ntype LogMessage = string | Record<string, unknown>;\n\nfunction formatMessage(\n level: string,\n message: string,\n ...args: unknown[]\n): string {\n const timestamp = new Date().toISOString();\n const formattedArgs =\n args.length > 0\n ? ` ${args\n .map((arg) =>\n arg !== null && typeof arg === 'object'\n ? JSON.stringify(\n arg,\n (_key, value) =>\n typeof value === 'bigint' ? value.toString() : value,\n 2\n )\n : String(arg)\n )\n .join(' ')}`\n : '';\n\n return `[${timestamp}] ${level.toUpperCase()}: ${message}${formattedArgs}`;\n}\n\nfunction handleLog(\n level: string,\n color: string,\n fn: (message: string) => void,\n messageOrObj: LogMessage,\n maybeMsg?: unknown,\n ...args: unknown[]\n): void {\n let msg =\n typeof messageOrObj === 'string' ? messageOrObj : String(messageOrObj);\n let objs: unknown[] = maybeMsg !== undefined ? [maybeMsg, ...args] : args;\n\n if (typeof messageOrObj === 'object' && typeof maybeMsg === 'string') {\n msg = maybeMsg;\n objs = [messageOrObj, ...args];\n }\n\n fn(color + formatMessage(level, msg, ...objs) + colors.reset);\n}\n\nexport const logger = {\n info(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('info', colors.info, console.log, m, m2, ...args);\n },\n warn(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('warn', colors.warn, console.warn, m, m2, ...args);\n },\n error(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('error', colors.error, console.error, m, m2, ...args);\n },\n success(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('success', colors.success, console.log, m, m2, ...args);\n },\n debug(m: LogMessage, m2?: unknown, ...args: unknown[]): void {\n handleLog('debug', colors.debug, console.log, m, m2, ...args);\n },\n};\n"],"mappings":";AAoBA,IAAM,SAAS;AAAA,EACb,MAAM;AAAA;AAAA,EACN,MAAM;AAAA;AAAA,EACN,OAAO;AAAA;AAAA,EACP,SAAS;AAAA;AAAA,EACT,OAAO;AAAA;AAAA,EACP,OAAO;AAAA;AACT;AAKA,SAAS,cACP,OACA,YACG,MACK;AACR,QAAM,aAAY,oBAAI,KAAK,GAAE,YAAY;AACzC,QAAM,gBACJ,KAAK,SAAS,IACV,IAAI,KACD;AAAA,IAAI,CAAC,QACJ,QAAQ,QAAQ,OAAO,QAAQ,WAC3B,KAAK;AAAA,MACH;AAAA,MACA,CAAC,MAAM,UACL,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,MACjD;AAAA,IACF,IACA,OAAO,GAAG;AAAA,EAChB,EACC,KAAK,GAAG,CAAC,KACZ;AAEN,SAAO,IAAI,SAAS,KAAK,MAAM,YAAY,CAAC,KAAK,OAAO,GAAG,aAAa;AAC1E;AAEA,SAAS,UACP,OACA,OACA,IACA,cACA,aACG,MACG;AACN,MAAI,MACF,OAAO,iBAAiB,WAAW,eAAe,OAAO,YAAY;AACvE,MAAI,OAAkB,aAAa,SAAY,CAAC,UAAU,GAAG,IAAI,IAAI;AAErE,MAAI,OAAO,iBAAiB,YAAY,OAAO,aAAa,UAAU;AACpE,UAAM;AACN,WAAO,CAAC,cAAc,GAAG,IAAI;AAAA,EAC/B;AAEA,KAAG,QAAQ,cAAc,OAAO,KAAK,GAAG,IAAI,IAAI,OAAO,KAAK;AAC9D;AAEO,IAAM,SAAS;AAAA,EACpB,KAAK,GAAe,OAAiB,MAAuB;AAC1D,cAAU,QAAQ,OAAO,MAAM,QAAQ,KAAK,GAAG,IAAI,GAAG,IAAI;AAAA,EAC5D;AAAA,EACA,KAAK,GAAe,OAAiB,MAAuB;AAC1D,cAAU,QAAQ,OAAO,MAAM,QAAQ,MAAM,GAAG,IAAI,GAAG,IAAI;AAAA,EAC7D;AAAA,EACA,MAAM,GAAe,OAAiB,MAAuB;AAC3D,cAAU,SAAS,OAAO,OAAO,QAAQ,OAAO,GAAG,IAAI,GAAG,IAAI;AAAA,EAChE;AAAA,EACA,QAAQ,GAAe,OAAiB,MAAuB;AAC7D,cAAU,WAAW,OAAO,SAAS,QAAQ,KAAK,GAAG,IAAI,GAAG,IAAI;AAAA,EAClE;AAAA,EACA,MAAM,GAAe,OAAiB,MAAuB;AAC3D,cAAU,SAAS,OAAO,OAAO,QAAQ,KAAK,GAAG,IAAI,GAAG,IAAI;AAAA,EAC9D;AACF;","names":[]}