@cfxdevkit/core 0.1.0 → 1.0.5
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/CHANGELOG.md +1 -1
- package/README.md +22 -22
- package/package.json +20 -19
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@ Provides chain clients, contract utilities, wallet derivation, swap services, an
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
pnpm add @cfxdevkit/
|
|
16
|
+
pnpm add @cfxdevkit/core
|
|
17
17
|
# or
|
|
18
|
-
npm install @cfxdevkit/
|
|
18
|
+
npm install @cfxdevkit/core
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Peer dependencies (install if using React hooks):
|
|
@@ -30,15 +30,15 @@ pnpm add react react-dom
|
|
|
30
30
|
|
|
31
31
|
| Subpath | Contents |
|
|
32
32
|
|---------|----------|
|
|
33
|
-
| `@cfxdevkit/
|
|
34
|
-
| `@cfxdevkit/
|
|
35
|
-
| `@cfxdevkit/
|
|
36
|
-
| `@cfxdevkit/
|
|
37
|
-
| `@cfxdevkit/
|
|
38
|
-
| `@cfxdevkit/
|
|
39
|
-
| `@cfxdevkit/
|
|
40
|
-
| `@cfxdevkit/
|
|
41
|
-
| `@cfxdevkit/
|
|
33
|
+
| `@cfxdevkit/core` | Full barrel – everything |
|
|
34
|
+
| `@cfxdevkit/core/clients` | `ClientManager`, `CoreClient`, `EspaceClient` |
|
|
35
|
+
| `@cfxdevkit/core/config` | Chain definitions for Core + eSpace |
|
|
36
|
+
| `@cfxdevkit/core/types` | Shared TypeScript types |
|
|
37
|
+
| `@cfxdevkit/core/utils` | Logger |
|
|
38
|
+
| `@cfxdevkit/core/wallet` | HD derivation, session keys, batching, embedded wallets |
|
|
39
|
+
| `@cfxdevkit/core/contracts` | `ContractDeployer`, `ContractReader`, `ContractWriter`, ERC ABIs |
|
|
40
|
+
| `@cfxdevkit/core/services` | `SwapService` (Swappi DEX), `KeystoreService`, `EncryptionService` |
|
|
41
|
+
| `@cfxdevkit/core/automation` | `SafetyGuard`, `RetryQueue`, `PriceChecker`, `AUTOMATION_MANAGER_ABI`, types |
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
@@ -47,7 +47,7 @@ pnpm add react react-dom
|
|
|
47
47
|
### Connect to Conflux eSpace
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
|
-
import { ClientManager, EVM_MAINNET } from '@cfxdevkit/
|
|
50
|
+
import { ClientManager, EVM_MAINNET } from '@cfxdevkit/core';
|
|
51
51
|
|
|
52
52
|
const manager = new ClientManager({
|
|
53
53
|
evm: { chain: EVM_MAINNET },
|
|
@@ -61,7 +61,7 @@ console.log('Current block:', block);
|
|
|
61
61
|
### Connect to Conflux Core Space
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
|
-
import { ClientManager, CORE_MAINNET } from '@cfxdevkit/
|
|
64
|
+
import { ClientManager, CORE_MAINNET } from '@cfxdevkit/core';
|
|
65
65
|
|
|
66
66
|
const manager = new ClientManager({
|
|
67
67
|
core: { chain: CORE_MAINNET },
|
|
@@ -75,7 +75,7 @@ console.log('Current epoch:', epochNumber);
|
|
|
75
75
|
### HD Wallet Derivation
|
|
76
76
|
|
|
77
77
|
```typescript
|
|
78
|
-
import { generateMnemonic, deriveAccounts } from '@cfxdevkit/
|
|
78
|
+
import { generateMnemonic, deriveAccounts } from '@cfxdevkit/core/wallet';
|
|
79
79
|
|
|
80
80
|
// Generate new wallet
|
|
81
81
|
const mnemonic = generateMnemonic();
|
|
@@ -92,9 +92,9 @@ for (const account of accounts) {
|
|
|
92
92
|
### Read an ERC-20 token
|
|
93
93
|
|
|
94
94
|
```typescript
|
|
95
|
-
import { ClientManager, EVM_MAINNET } from '@cfxdevkit/
|
|
96
|
-
import { ContractReader } from '@cfxdevkit/
|
|
97
|
-
import { ERC20_ABI } from '@cfxdevkit/
|
|
95
|
+
import { ClientManager, EVM_MAINNET } from '@cfxdevkit/core';
|
|
96
|
+
import { ContractReader } from '@cfxdevkit/core/contracts';
|
|
97
|
+
import { ERC20_ABI } from '@cfxdevkit/core/contracts';
|
|
98
98
|
|
|
99
99
|
const manager = new ClientManager({ evm: { chain: EVM_MAINNET } });
|
|
100
100
|
await manager.connect();
|
|
@@ -113,8 +113,8 @@ console.log('Balance:', balance);
|
|
|
113
113
|
### Query a DEX swap quote (Swappi)
|
|
114
114
|
|
|
115
115
|
```typescript
|
|
116
|
-
import { ClientManager, EVM_MAINNET } from '@cfxdevkit/
|
|
117
|
-
import { SwapService } from '@cfxdevkit/
|
|
116
|
+
import { ClientManager, EVM_MAINNET } from '@cfxdevkit/core';
|
|
117
|
+
import { SwapService } from '@cfxdevkit/services';
|
|
118
118
|
|
|
119
119
|
const manager = new ClientManager({ evm: { chain: EVM_MAINNET } });
|
|
120
120
|
await manager.connect();
|
|
@@ -132,7 +132,7 @@ console.log('Expected out:', quote.amountOut);
|
|
|
132
132
|
### Encrypted Keystore
|
|
133
133
|
|
|
134
134
|
```typescript
|
|
135
|
-
import { KeystoreService } from '@cfxdevkit/
|
|
135
|
+
import { KeystoreService } from '@cfxdevkit/services';
|
|
136
136
|
|
|
137
137
|
const keystore = new KeystoreService('/path/to/.keystore.json');
|
|
138
138
|
await keystore.setup({ password: 'my-password' });
|
|
@@ -150,7 +150,7 @@ const accounts = await keystore.deriveAccountsFromMnemonic(
|
|
|
150
150
|
```typescript
|
|
151
151
|
import {
|
|
152
152
|
SafetyGuard, RetryQueue, PriceChecker, AUTOMATION_MANAGER_ABI,
|
|
153
|
-
} from '@cfxdevkit/
|
|
153
|
+
} from '@cfxdevkit/core/automation';
|
|
154
154
|
|
|
155
155
|
// Injectable logger — pass pino/winston/console or omit for silence
|
|
156
156
|
const guard = new SafetyGuard({ maxSwapUsd: 5_000 }, myLogger);
|
|
@@ -172,7 +172,7 @@ const { conditionMet, swapUsd } = await checker.checkLimitOrder(job);
|
|
|
172
172
|
## Architecture
|
|
173
173
|
|
|
174
174
|
```
|
|
175
|
-
@cfxdevkit/
|
|
175
|
+
@cfxdevkit/core
|
|
176
176
|
│
|
|
177
177
|
├── clients/ ← cive (Core) + viem (eSpace) thin wrappers + ClientManager
|
|
178
178
|
├── config/ ← Chain definitions: local / testnet / mainnet for both spaces
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfxdevkit/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Core Conflux SDK – blockchain client abstractions, wallet tools, and core utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,6 +48,21 @@
|
|
|
48
48
|
},
|
|
49
49
|
"./package.json": "./package.json"
|
|
50
50
|
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsup",
|
|
53
|
+
"build:watch": "tsup --watch",
|
|
54
|
+
"type-check": "tsc --noEmit",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:watch": "vitest",
|
|
57
|
+
"test:coverage": "vitest run --coverage --pass-with-no-tests",
|
|
58
|
+
"clean": "rm -rf dist",
|
|
59
|
+
"lint": "biome lint src/",
|
|
60
|
+
"lint:fix": "biome lint --write src/",
|
|
61
|
+
"format": "biome format src/",
|
|
62
|
+
"format:fix": "biome format --write src/",
|
|
63
|
+
"check": "biome check src/",
|
|
64
|
+
"check:fix": "biome check --write src/"
|
|
65
|
+
},
|
|
51
66
|
"keywords": [
|
|
52
67
|
"conflux",
|
|
53
68
|
"blockchain",
|
|
@@ -65,11 +80,11 @@
|
|
|
65
80
|
"license": "Apache-2.0",
|
|
66
81
|
"repository": {
|
|
67
82
|
"type": "git",
|
|
68
|
-
"url": "git+https://github.com/cfxdevkit/
|
|
83
|
+
"url": "git+https://github.com/cfxdevkit/devkit.git"
|
|
69
84
|
},
|
|
70
85
|
"homepage": "https://github.com/cfxdevkit/conflux-sdk#readme",
|
|
71
86
|
"bugs": {
|
|
72
|
-
"url": "https://github.com/cfxdevkit/
|
|
87
|
+
"url": "https://github.com/cfxdevkit/devkit/issues"
|
|
73
88
|
},
|
|
74
89
|
"dependencies": {
|
|
75
90
|
"@scure/bip32": "^2.0.1",
|
|
@@ -101,19 +116,5 @@
|
|
|
101
116
|
"engines": {
|
|
102
117
|
"node": ">=18.0.0"
|
|
103
118
|
},
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
"build:watch": "tsup --watch",
|
|
107
|
-
"type-check": "tsc --noEmit",
|
|
108
|
-
"test": "vitest run",
|
|
109
|
-
"test:watch": "vitest",
|
|
110
|
-
"test:coverage": "vitest run --coverage",
|
|
111
|
-
"clean": "rm -rf dist",
|
|
112
|
-
"lint": "biome lint src/",
|
|
113
|
-
"lint:fix": "biome lint --write src/",
|
|
114
|
-
"format": "biome format src/",
|
|
115
|
-
"format:fix": "biome format --write src/",
|
|
116
|
-
"check": "biome check src/",
|
|
117
|
-
"check:fix": "biome check --write src/"
|
|
118
|
-
}
|
|
119
|
-
}
|
|
119
|
+
"packageManager": "pnpm@10.11.0"
|
|
120
|
+
}
|