@offckb/cli 0.3.0-rc1 → 0.3.0-rc3
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 +40 -6
- package/ckb/devnet/specs/dev.toml +1 -1
- package/dist/cmd/system-scripts.js +10 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ There are BREAKING CHANGES between v0.2.x and v0.3.x, make sure to read the [mig
|
|
|
27
27
|
- [Get started](#get-started)
|
|
28
28
|
- [Running CKB](#running-ckb)
|
|
29
29
|
- [List scripts info](#list-scripts-info)
|
|
30
|
+
- [Tweak Devnet Config](#tweak-devnet-config)
|
|
30
31
|
- [Create a full-stack Project](#create-a-full-stack-project)
|
|
31
32
|
- [Create a script-only Project](#create-a-script-only-project)
|
|
32
33
|
- [Build and Deploy a script](#build-and-deploy-a-script)
|
|
@@ -49,7 +50,7 @@ There are BREAKING CHANGES between v0.2.x and v0.3.x, make sure to read the [mig
|
|
|
49
50
|
npm install -g @offckb/cli
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
_We recommand using [LTS](https://nodejs.org/en/download/package-manager) version of Node to run `offckb`_
|
|
53
54
|
|
|
54
55
|
## Usage
|
|
55
56
|
|
|
@@ -83,7 +84,7 @@ Commands:
|
|
|
83
84
|
help [command] display help for command
|
|
84
85
|
```
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
_Use `offckb [command] -h` to learn more about a specific command._
|
|
87
88
|
|
|
88
89
|
## Get started
|
|
89
90
|
|
|
@@ -98,7 +99,7 @@ offckb node
|
|
|
98
99
|
Or specify a CKB version:
|
|
99
100
|
|
|
100
101
|
```sh
|
|
101
|
-
offckb node 0.117.0
|
|
102
|
+
offckb node 0.117.0
|
|
102
103
|
```
|
|
103
104
|
|
|
104
105
|
Or set the default CKB version:
|
|
@@ -142,6 +143,39 @@ Or print the scripts info in a CCC style:
|
|
|
142
143
|
offckb system-scripts --export-style ccc
|
|
143
144
|
```
|
|
144
145
|
|
|
146
|
+
### Tweak Devnet Config
|
|
147
|
+
|
|
148
|
+
By default, offckb use a fixed devnet config for the local blockchain. You can tweak the config to customize the devnet:
|
|
149
|
+
|
|
150
|
+
First, start a default CKB devnet and locate your devnet folder
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
offckb node
|
|
154
|
+
# after starting, press ctrl-c to kill the node
|
|
155
|
+
# then get the config
|
|
156
|
+
offckb config list
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Result:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"devnet": {
|
|
164
|
+
"rpcUrl": "http://localhost:8114",
|
|
165
|
+
"configPath": "~/Library/Application Support/offckb-nodejs/devnet",
|
|
166
|
+
"dataPath": "~/Library/Application Support/offckb-nodejs/devnet/data"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Pay attention to the `devnet.configPath` and `devnet.dataPath`. They are the ones we need.
|
|
172
|
+
|
|
173
|
+
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.
|
|
174
|
+
2. After modifications, remove everything in the `devnet.dataPath` folder. This will clean the chain data.
|
|
175
|
+
3. Restart local blockchain by running `offckb node`
|
|
176
|
+
|
|
177
|
+
Done.
|
|
178
|
+
|
|
145
179
|
### Create a full-stack Project
|
|
146
180
|
|
|
147
181
|
Create a new project from predefined boilerplates.
|
|
@@ -160,13 +194,13 @@ You can create a new script project without a frontend. This is useful when you
|
|
|
160
194
|
offckb create <your-project-name> --script
|
|
161
195
|
```
|
|
162
196
|
|
|
163
|
-
Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your environment to use this command. offckb doesn't do anything really, it just call [ckb-script-template](https://github.com/cryptape/ckb-script-
|
|
197
|
+
Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your environment to use this command. offckb doesn't do anything really, it just call [ckb-script-template](https://github.com/cryptape/ckb-script-templates) to do all the magic.
|
|
164
198
|
|
|
165
199
|
### Build and Deploy a script
|
|
166
200
|
|
|
167
201
|
The fullstack boilerplate project is a monorepo, which contains a script project and a frontend project.
|
|
168
202
|
|
|
169
|
-
To build the script, in the root of the project, run:
|
|
203
|
+
To build the script, in the root of the project, run:
|
|
170
204
|
|
|
171
205
|
```sh
|
|
172
206
|
make build
|
|
@@ -249,7 +283,7 @@ Or you can replace the script with a binary file in your single cell script debu
|
|
|
249
283
|
offckb debug <transaction-hash> --single-script <single-cell-script-option> --bin <path/to/binary/file>
|
|
250
284
|
```
|
|
251
285
|
|
|
252
|
-
All the debug utils are borrowed from [ckb-debugger](https://github.com/nervosnetwork/ckb-debugger).
|
|
286
|
+
All the debug utils are borrowed from [ckb-debugger](https://github.com/nervosnetwork/ckb-standalone-debugger/tree/develop/ckb-debugger).
|
|
253
287
|
|
|
254
288
|
### Generate Moleculec bindings
|
|
255
289
|
|
|
@@ -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 {
|
|
@@ -106,7 +110,7 @@ function systemCellToScriptInfo(cell, depType, depGroup) {
|
|
|
106
110
|
if (depType === 'code') {
|
|
107
111
|
return {
|
|
108
112
|
codeHash: cell.type_hash || cell.data_hash,
|
|
109
|
-
hashType: cell.type_hash ? 'type' : '
|
|
113
|
+
hashType: cell.type_hash ? 'type' : 'data1',
|
|
110
114
|
cellDeps: [
|
|
111
115
|
{
|
|
112
116
|
cellDep: {
|
|
@@ -122,7 +126,7 @@ function systemCellToScriptInfo(cell, depType, depGroup) {
|
|
|
122
126
|
}
|
|
123
127
|
return {
|
|
124
128
|
codeHash: cell.type_hash || cell.data_hash,
|
|
125
|
-
hashType: cell.type_hash ? 'type' : '
|
|
129
|
+
hashType: cell.type_hash ? 'type' : 'data1',
|
|
126
130
|
cellDeps: [
|
|
127
131
|
{
|
|
128
132
|
cellDep: {
|