@offckb/cli 0.3.0-canary-4e24414.0 → 0.3.0-canary-47da86f.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.
@@ -1,40 +1,21 @@
1
1
  import { SystemCell } from './list-hashes';
2
2
  import { CellDepInfoLike, Script } from '@ckb-ccc/core';
3
- import { SystemScriptsRecord } from '../scripts/type';
3
+ import { ScriptInfo, SystemScriptsRecord } from '../scripts/type';
4
4
  export type PrintProps = 'lumos' | 'ccc';
5
5
  export declare function printSystemScripts(props?: PrintProps): Promise<void>;
6
6
  export declare function printInSystemStyle(systemScripts: SystemScriptsRecord): void;
7
7
  export declare function printInLumosConfigStyle(scripts: SystemScriptsRecord): void;
8
8
  export declare function printInCCCStyle(scripts: SystemScriptsRecord): void;
9
9
  export declare function getSystemScriptsFromListHashes(): SystemScriptsRecord | null;
10
- export declare function systemCellToScriptInfo(cell: SystemCell, depType: 'code' | 'depGroup', depGroup?: {
11
- txHash: string;
12
- index: number;
13
- }): {
14
- codeHash: string;
15
- hashType: string;
16
- cellDeps: {
17
- cellDep: {
18
- outPoint: {
19
- txHash: string;
20
- index: number;
21
- };
22
- depType: "code";
23
- };
24
- }[];
25
- } | {
26
- codeHash: string;
27
- hashType: string;
28
- cellDeps: {
29
- cellDep: {
30
- outPoint: {
31
- txHash: string;
32
- index: number;
33
- };
34
- depType: "depGroup";
35
- };
36
- }[];
37
- };
10
+ export declare function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }: {
11
+ cell: SystemCell;
12
+ depType: 'code' | 'depGroup';
13
+ depGroup?: {
14
+ txHash: string;
15
+ index: number;
16
+ };
17
+ extraCellDeps?: ScriptInfo['cellDeps'];
18
+ }): ScriptInfo;
38
19
  export declare function toLumosConfig(scripts: SystemScriptsRecord, addressPrefix?: 'ckb' | 'ckt'): {
39
20
  PREFIX: "ckb" | "ckt";
40
21
  SCRIPTS: {
@@ -61,73 +61,80 @@ function printInCCCStyle(scripts) {
61
61
  }
62
62
  exports.printInCCCStyle = printInCCCStyle;
63
63
  function getSystemScriptsFromListHashes() {
64
+ var _a;
64
65
  const settings = (0, setting_1.readSettings)();
65
66
  const listHashesString = (0, list_hashes_1.getListHashes)(settings.bins.defaultCKBVersion);
66
- if (listHashesString) {
67
- const listHashes = toml_1.default.parse(listHashesString);
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
73
- .map((cell) => {
74
- var _a;
75
- // Extract the file name
76
- const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
77
- const depGroupIndex = chainSpecHashes.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(`Bundled(specs/cells/${name})`));
78
- const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
79
- const depGroup = depGroupIndex === -1
80
- ? undefined
81
- : {
82
- txHash: chainSpecHashes.dep_groups[depGroupIndex].tx_hash,
83
- index: chainSpecHashes.dep_groups[depGroupIndex].index,
84
- };
85
- const scriptInfo = systemCellToScriptInfo(cell, depType, depGroup);
86
- return {
87
- name,
88
- file: cell.path,
89
- script: scriptInfo,
90
- };
91
- })
92
- .filter((s) => s.name != 'secp256k1_data');
93
- const systemScripts = systemScriptArray.reduce((acc, item) => {
94
- const key = item.name;
95
- acc[key] = item;
96
- return acc;
97
- }, {});
98
- return systemScripts;
99
- }
100
- else {
67
+ if (!listHashesString) {
101
68
  console.log(`list-hashes not found!`);
102
69
  return null;
103
70
  }
71
+ const listHashes = toml_1.default.parse(listHashesString);
72
+ const chainSpecHashes = Object.values(listHashes)[0];
73
+ if (chainSpecHashes == null) {
74
+ throw new Error(`invalid chain spec hashes file ${listHashesString}`);
75
+ }
76
+ const systemScriptArray = chainSpecHashes.system_cells
77
+ .map((cell) => {
78
+ var _a;
79
+ // Extract the file name
80
+ const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
81
+ const depGroupIndex = chainSpecHashes.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(`Bundled(specs/cells/${name})`));
82
+ const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
83
+ const depGroup = depGroupIndex === -1
84
+ ? undefined
85
+ : {
86
+ txHash: chainSpecHashes.dep_groups[depGroupIndex].tx_hash,
87
+ index: chainSpecHashes.dep_groups[depGroupIndex].index,
88
+ };
89
+ const scriptInfo = systemCellToScriptInfo({ cell, depType, depGroup });
90
+ return {
91
+ name,
92
+ file: cell.path,
93
+ script: scriptInfo,
94
+ };
95
+ })
96
+ .filter((s) => s.name != 'secp256k1_data');
97
+ const systemScripts = systemScriptArray.reduce((acc, item) => {
98
+ const key = item.name;
99
+ acc[key] = item;
100
+ return acc;
101
+ }, {});
102
+ // some special case fixes
103
+ // eg: omnilock also requires the deps of secp256k1-sigHashAll
104
+ (_a = systemScripts.omnilock) === null || _a === void 0 ? void 0 : _a.script.cellDeps.push(systemScripts.secp256k1_blake160_sighash_all.script.cellDeps[0]);
105
+ return systemScripts;
104
106
  }
105
107
  exports.getSystemScriptsFromListHashes = getSystemScriptsFromListHashes;
106
- function systemCellToScriptInfo(cell, depType, depGroup) {
107
- if (depType === 'depGroup' && !depGroup) {
108
- throw new Error('require depGroup info since the dep type is depGroup');
109
- }
108
+ function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }) {
109
+ // todo: we left the type in cellDepsInfo since it requires async fetching and
110
+ // chain running to get the full type script of the type-id deps.
111
+ // Also, in devnet there is no real need to auto upgrade the system scripts with type-id
110
112
  if (depType === 'code') {
111
- return {
112
- codeHash: cell.type_hash || cell.data_hash,
113
- hashType: cell.type_hash ? 'type' : 'data1',
114
- cellDeps: [
115
- {
116
- cellDep: {
117
- outPoint: {
118
- txHash: cell.tx_hash,
119
- index: cell.index,
120
- },
121
- depType,
113
+ let cellDeps = [
114
+ {
115
+ cellDep: {
116
+ outPoint: {
117
+ txHash: cell.tx_hash,
118
+ index: cell.index,
122
119
  },
120
+ depType,
123
121
  },
124
- ],
122
+ },
123
+ ];
124
+ if (extraCellDeps && extraCellDeps.length > 0) {
125
+ cellDeps = [...extraCellDeps, ...cellDeps];
126
+ }
127
+ return {
128
+ codeHash: (cell.type_hash || cell.data_hash),
129
+ hashType: cell.type_hash ? 'type' : 'data1',
130
+ cellDeps,
125
131
  };
126
132
  }
127
- return {
128
- codeHash: cell.type_hash || cell.data_hash,
129
- hashType: cell.type_hash ? 'type' : 'data1',
130
- cellDeps: [
133
+ if (depType === 'depGroup') {
134
+ if (!depGroup) {
135
+ throw new Error('require depGroup info since the dep type is depGroup');
136
+ }
137
+ let cellDeps = [
131
138
  {
132
139
  cellDep: {
133
140
  outPoint: {
@@ -137,8 +144,17 @@ function systemCellToScriptInfo(cell, depType, depGroup) {
137
144
  depType,
138
145
  },
139
146
  },
140
- ],
141
- };
147
+ ];
148
+ if (extraCellDeps && extraCellDeps.length > 0) {
149
+ cellDeps = [...extraCellDeps, ...cellDeps];
150
+ }
151
+ return {
152
+ codeHash: (cell.type_hash || cell.data_hash),
153
+ hashType: cell.type_hash ? 'type' : 'data1',
154
+ cellDeps,
155
+ };
156
+ }
157
+ throw new Error(`unknown DepType ${depType}`);
142
158
  }
143
159
  exports.systemCellToScriptInfo = systemCellToScriptInfo;
144
160
  function toLumosConfig(scripts, addressPrefix = 'ckt') {
@@ -1,62 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MAINNET_SYSTEM_SCRIPTS = exports.TESTNET_SYSTEM_SCRIPTS = void 0;
4
+ const advanced_1 = require("@ckb-ccc/core/advanced");
5
+ const advanced_2 = require("@ckb-ccc/core/advanced");
4
6
  // spore: https://github.com/sporeprotocol/spore-contract/blob/master/docs/VERSIONS.md
5
7
  exports.TESTNET_SYSTEM_SCRIPTS = {
6
8
  secp256k1_blake160_sighash_all: {
7
9
  name: 'secp256k1_blake160_sighash_all',
8
- script: {
9
- codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
10
- hashType: 'type',
11
- cellDeps: [
12
- {
13
- cellDep: {
14
- outPoint: {
15
- txHash: '0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37',
16
- index: 0,
17
- },
18
- depType: 'depGroup',
19
- },
20
- },
21
- ],
22
- },
10
+ script: advanced_1.TESTNET_SCRIPTS.Secp256k1Blake160,
23
11
  },
24
12
  dao: {
25
13
  name: 'dao',
26
- script: {
27
- codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
28
- hashType: 'type',
29
- cellDeps: [
30
- {
31
- cellDep: {
32
- outPoint: {
33
- txHash: '0x8f8c79eb6671709633fe6a46de93c0fedc9c1b8a6527a18d3983879542635c9f',
34
- index: 2,
35
- },
36
- depType: 'code',
37
- },
38
- },
39
- ],
40
- },
14
+ script: advanced_1.TESTNET_SCRIPTS.NervosDao,
41
15
  },
42
16
  secp256k1_blake160_multisig_all: {
43
17
  name: 'secp256k1_blake160_multisig_all',
44
- file: 'Bundled(specs/cells/secp256k1_blake160_multisig_all)',
45
- script: {
46
- codeHash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8',
47
- hashType: 'type',
48
- cellDeps: [
49
- {
50
- cellDep: {
51
- outPoint: {
52
- txHash: '0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37',
53
- index: 1,
54
- },
55
- depType: 'depGroup',
56
- },
57
- },
58
- ],
59
- },
18
+ script: advanced_1.TESTNET_SCRIPTS.Secp256k1Multisig,
60
19
  },
61
20
  sudt: {
62
21
  name: 'sudt',
@@ -78,57 +37,15 @@ exports.TESTNET_SYSTEM_SCRIPTS = {
78
37
  },
79
38
  xudt: {
80
39
  name: 'xudt',
81
- script: {
82
- codeHash: '0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb',
83
- hashType: 'type',
84
- cellDeps: [
85
- {
86
- cellDep: {
87
- outPoint: {
88
- txHash: '0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f',
89
- index: 0,
90
- },
91
- depType: 'code',
92
- },
93
- },
94
- ],
95
- },
40
+ script: advanced_1.TESTNET_SCRIPTS.XUdt,
96
41
  },
97
42
  omnilock: {
98
43
  name: 'omnilock',
99
- script: {
100
- codeHash: '0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb',
101
- hashType: 'type',
102
- cellDeps: [
103
- {
104
- cellDep: {
105
- outPoint: {
106
- txHash: '0xec18bf0d857c981c3d1f4e17999b9b90c484b303378e94de1a57b0872f5d4602',
107
- index: 0,
108
- },
109
- depType: 'code',
110
- },
111
- },
112
- ],
113
- },
44
+ script: advanced_1.TESTNET_SCRIPTS.OmniLock,
114
45
  },
115
46
  anyone_can_pay: {
116
47
  name: 'anyone_can_pay',
117
- script: {
118
- codeHash: '0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356',
119
- hashType: 'type',
120
- cellDeps: [
121
- {
122
- cellDep: {
123
- outPoint: {
124
- txHash: '0xec26b0f85ed839ece5f11c4c4e837ec359f5adc4420410f6453b1f6b60fb96a6',
125
- index: 0,
126
- },
127
- depType: 'depGroup',
128
- },
129
- },
130
- ],
131
- },
48
+ script: advanced_1.TESTNET_SCRIPTS.AnyoneCanPay,
132
49
  },
133
50
  always_success: undefined,
134
51
  spore: {
@@ -225,57 +142,15 @@ exports.TESTNET_SYSTEM_SCRIPTS = {
225
142
  exports.MAINNET_SYSTEM_SCRIPTS = {
226
143
  secp256k1_blake160_sighash_all: {
227
144
  name: 'secp256k1_blake160_sighash_all',
228
- script: {
229
- codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
230
- hashType: 'type',
231
- cellDeps: [
232
- {
233
- cellDep: {
234
- outPoint: {
235
- txHash: '0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c',
236
- index: 0,
237
- },
238
- depType: 'depGroup',
239
- },
240
- },
241
- ],
242
- },
145
+ script: advanced_2.MAINNET_SCRIPTS.Secp256k1Blake160,
243
146
  },
244
147
  dao: {
245
148
  name: 'dao',
246
- script: {
247
- codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
248
- hashType: 'type',
249
- cellDeps: [
250
- {
251
- cellDep: {
252
- outPoint: {
253
- txHash: '0xe2fb199810d49a4d8beec56718ba2593b665db9d52299a0f9e6e75416d73ff5c',
254
- index: 2,
255
- },
256
- depType: 'code',
257
- },
258
- },
259
- ],
260
- },
149
+ script: advanced_2.MAINNET_SCRIPTS.NervosDao,
261
150
  },
262
151
  secp256k1_blake160_multisig_all: {
263
152
  name: 'secp256k1_blake160_multisig_all',
264
- script: {
265
- codeHash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8',
266
- hashType: 'type',
267
- cellDeps: [
268
- {
269
- cellDep: {
270
- outPoint: {
271
- txHash: '0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c',
272
- index: 1,
273
- },
274
- depType: 'depGroup',
275
- },
276
- },
277
- ],
278
- },
153
+ script: advanced_2.MAINNET_SCRIPTS.Secp256k1Multisig,
279
154
  },
280
155
  sudt: {
281
156
  name: 'sudt',
@@ -297,57 +172,15 @@ exports.MAINNET_SYSTEM_SCRIPTS = {
297
172
  },
298
173
  xudt: {
299
174
  name: 'xudt',
300
- script: {
301
- codeHash: '0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95',
302
- hashType: 'data1',
303
- cellDeps: [
304
- {
305
- cellDep: {
306
- outPoint: {
307
- txHash: '0xc07844ce21b38e4b071dd0e1ee3b0e27afd8d7532491327f39b786343f558ab7',
308
- index: 0,
309
- },
310
- depType: 'code',
311
- },
312
- },
313
- ],
314
- },
175
+ script: advanced_2.MAINNET_SCRIPTS.XUdt,
315
176
  },
316
177
  omnilock: {
317
178
  name: 'omnilock',
318
- script: {
319
- codeHash: '0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26',
320
- hashType: 'type',
321
- cellDeps: [
322
- {
323
- cellDep: {
324
- outPoint: {
325
- txHash: '0xc76edf469816aa22f416503c38d0b533d2a018e253e379f134c3985b3472c842',
326
- index: 0,
327
- },
328
- depType: 'code',
329
- },
330
- },
331
- ],
332
- },
179
+ script: advanced_2.MAINNET_SCRIPTS.OmniLock,
333
180
  },
334
181
  anyone_can_pay: {
335
182
  name: 'anyone_can_pay',
336
- script: {
337
- codeHash: '0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354',
338
- hashType: 'type',
339
- cellDeps: [
340
- {
341
- cellDep: {
342
- outPoint: {
343
- txHash: '0x4153a2014952d7cac45f285ce9a7c5c0c0e1b21f2d378b82ac1433cb11c25c4d',
344
- index: 0,
345
- },
346
- depType: 'depGroup',
347
- },
348
- },
349
- ],
350
- },
183
+ script: advanced_2.MAINNET_SCRIPTS.AnyoneCanPay,
351
184
  },
352
185
  always_success: undefined,
353
186
  spore: {
@@ -25,6 +25,11 @@ export interface ScriptInfo {
25
25
  };
26
26
  depType: DepType;
27
27
  };
28
+ type?: {
29
+ codeHash: `0x${string}`;
30
+ hashType: HashType;
31
+ args: `0x${string}`;
32
+ };
28
33
  }[];
29
34
  }
30
35
  export interface SystemScript {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.3.0-canary-4e24414.0",
3
+ "version": "0.3.0-canary-47da86f.0",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "CKB EcoFund",
6
6
  "license": "MIT",