@offckb/cli 0.3.0-canary-3e662fd.0 → 0.3.0-canary-95ee88f.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 +38 -4
- package/ckb/devnet/specs/dev.toml +1 -1
- package/dist/cmd/system-scripts.js +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Start building on CKB blockchain, right now, right away!
|
|
|
25
25
|
- [Get started](#get-started)
|
|
26
26
|
- [Running CKB](#running-ckb)
|
|
27
27
|
- [List scripts info](#list-scripts-info)
|
|
28
|
+
- [Tweak Devnet Config](#tweak-devnet-config)
|
|
28
29
|
- [Create a full-stack Project](#create-a-full-stack-project)
|
|
29
30
|
- [Create a script-only Project](#create-a-script-only-project)
|
|
30
31
|
- [Build and Deploy a script](#build-and-deploy-a-script)
|
|
@@ -47,7 +48,7 @@ Start building on CKB blockchain, right now, right away!
|
|
|
47
48
|
npm install -g @offckb/cli
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
_We recommand using [LTS](https://nodejs.org/en/download/package-manager) version of Node to run `offckb`_
|
|
51
52
|
|
|
52
53
|
## Usage
|
|
53
54
|
|
|
@@ -81,7 +82,7 @@ Commands:
|
|
|
81
82
|
help [command] display help for command
|
|
82
83
|
```
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
_Use `offckb [command] -h` to learn more about a specific command._
|
|
85
86
|
|
|
86
87
|
## Get started
|
|
87
88
|
|
|
@@ -96,7 +97,7 @@ offckb node
|
|
|
96
97
|
Or specify a CKB version:
|
|
97
98
|
|
|
98
99
|
```sh
|
|
99
|
-
offckb node 0.117.0
|
|
100
|
+
offckb node 0.117.0
|
|
100
101
|
```
|
|
101
102
|
|
|
102
103
|
Or set the default CKB version:
|
|
@@ -140,6 +141,39 @@ Or print the scripts info in a CCC style:
|
|
|
140
141
|
offckb system-scripts --export-style ccc
|
|
141
142
|
```
|
|
142
143
|
|
|
144
|
+
### Tweak Devnet Config
|
|
145
|
+
|
|
146
|
+
By default, offckb use a fixed devnet config for the local blockchain. You can tweak the config to customize the devnet:
|
|
147
|
+
|
|
148
|
+
First, start a default CKB devnet and locate your devnet folder
|
|
149
|
+
|
|
150
|
+
```sh
|
|
151
|
+
offckb node
|
|
152
|
+
# after starting, press ctrl-c to kill the node
|
|
153
|
+
# then get the config
|
|
154
|
+
offckb config list
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Result:
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"devnet": {
|
|
162
|
+
"rpcUrl": "http://localhost:8114",
|
|
163
|
+
"configPath": "~/Library/Application Support/offckb-nodejs/devnet",
|
|
164
|
+
"dataPath": "~/Library/Application Support/offckb-nodejs/devnet/data"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Pay attention to the `devnet.configPath` and `devnet.dataPath`. They are the ones we need.
|
|
170
|
+
|
|
171
|
+
1. `cd` into the `devnet.configPath`, this is the config folder for the local blockchain. Modify the config in the folder to better customize the devnet. For customization, see [Custom Devnet Setup](https://docs.nervos.org/docs/node/run-devnet-node#custom-devnet-setup) and [Configure CKB](https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md) for better explanation of the config files.
|
|
172
|
+
2. After modifications, remove everything in the `devnet.dataPath` folder. This will clean the chain data.
|
|
173
|
+
3. Restart local blockchain by running `offckb node`
|
|
174
|
+
|
|
175
|
+
Done.
|
|
176
|
+
|
|
143
177
|
### Create a full-stack Project
|
|
144
178
|
|
|
145
179
|
Create a new project from predefined boilerplates.
|
|
@@ -164,7 +198,7 @@ Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your env
|
|
|
164
198
|
|
|
165
199
|
The fullstack boilerplate project is a monorepo, which contains a script project and a frontend project.
|
|
166
200
|
|
|
167
|
-
To build the script, in the root of the project, run:
|
|
201
|
+
To build the script, in the root of the project, run:
|
|
168
202
|
|
|
169
203
|
```sh
|
|
170
204
|
make build
|
|
@@ -65,18 +65,22 @@ function getSystemScriptsFromListHashes() {
|
|
|
65
65
|
const listHashesString = (0, list_hashes_1.getListHashes)(settings.bins.defaultCKBVersion);
|
|
66
66
|
if (listHashesString) {
|
|
67
67
|
const listHashes = toml_1.default.parse(listHashesString);
|
|
68
|
-
const
|
|
68
|
+
const chainSpecHashes = Object.values(listHashes)[0];
|
|
69
|
+
if (chainSpecHashes == null) {
|
|
70
|
+
throw new Error(`invalid chain spec hashes file ${listHashesString}`);
|
|
71
|
+
}
|
|
72
|
+
const systemScriptArray = chainSpecHashes.system_cells
|
|
69
73
|
.map((cell) => {
|
|
70
74
|
var _a;
|
|
71
75
|
// Extract the file name
|
|
72
76
|
const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
|
|
73
|
-
const depGroupIndex =
|
|
77
|
+
const depGroupIndex = chainSpecHashes.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(`Bundled(specs/cells/${name})`));
|
|
74
78
|
const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
|
|
75
79
|
const depGroup = depGroupIndex === -1
|
|
76
80
|
? undefined
|
|
77
81
|
: {
|
|
78
|
-
txHash:
|
|
79
|
-
index:
|
|
82
|
+
txHash: chainSpecHashes.dep_groups[depGroupIndex].tx_hash,
|
|
83
|
+
index: chainSpecHashes.dep_groups[depGroupIndex].index,
|
|
80
84
|
};
|
|
81
85
|
const scriptInfo = systemCellToScriptInfo(cell, depType, depGroup);
|
|
82
86
|
return {
|