@offckb/cli 0.3.0-canary-47da86f.0 → 0.3.0-canary-e88a9d6.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/dist/cli.js +6 -4
- package/dist/cmd/list-hashes.d.ts +2 -2
- package/dist/cmd/list-hashes.js +6 -6
- package/dist/cmd/system-scripts.d.ts +14 -6
- package/dist/cmd/system-scripts.js +35 -23
- package/dist/scripts/gen.js +1 -1
- package/dist/scripts/private.js +1 -1
- package/package.json +1 -1
- package/templates/v3/offckb.config.example.ts +6 -1
package/dist/cli.js
CHANGED
|
@@ -95,7 +95,7 @@ program.command('accounts').description('Print account list info').action(accoun
|
|
|
95
95
|
program
|
|
96
96
|
.command('list-hashes [CKB-Version]')
|
|
97
97
|
.description('Use the CKB to list blockchain scripts hashes')
|
|
98
|
-
.action(list_hashes_1.
|
|
98
|
+
.action(list_hashes_1.printDevnetListHashes);
|
|
99
99
|
program.command('inject-config').description('Add offckb.config.ts to your frontend workspace').action(inject_config_1.injectConfig);
|
|
100
100
|
program.command('sync-scripts').description('Sync scripts json files in your frontend workspace').action(sync_scripts_1.syncScripts);
|
|
101
101
|
program
|
|
@@ -166,11 +166,13 @@ program
|
|
|
166
166
|
}));
|
|
167
167
|
program
|
|
168
168
|
.command('system-scripts')
|
|
169
|
-
.option('--export-style <exportStyle>', 'Specify the export format, possible values are lumos and ccc.')
|
|
170
|
-
.
|
|
169
|
+
.option('--export-style <exportStyle>', 'Specify the export format, possible values are system, lumos and ccc.')
|
|
170
|
+
.option('--network <network>', 'Specify the CKB blockchain network', 'devnet')
|
|
171
|
+
.description('Output system scripts of the CKB blockchain')
|
|
171
172
|
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
+
const network = option.network;
|
|
172
174
|
const exportStyle = option.exportStyle;
|
|
173
|
-
return (0, system_scripts_1.printSystemScripts)(exportStyle);
|
|
175
|
+
return (0, system_scripts_1.printSystemScripts)({ style: exportStyle, network });
|
|
174
176
|
}));
|
|
175
177
|
program
|
|
176
178
|
.command('mol')
|
|
@@ -21,5 +21,5 @@ export interface SpecHashes {
|
|
|
21
21
|
export interface ListHashes {
|
|
22
22
|
offckb: SpecHashes;
|
|
23
23
|
}
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
24
|
+
export declare function printDevnetListHashes(version?: string): Promise<void>;
|
|
25
|
+
export declare function getDevnetListHashes(version?: string): string | null;
|
package/dist/cmd/list-hashes.js
CHANGED
|
@@ -9,18 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.getDevnetListHashes = exports.printDevnetListHashes = void 0;
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
14
|
const setting_1 = require("../cfg/setting");
|
|
15
15
|
const encoding_1 = require("../util/encoding");
|
|
16
|
-
function
|
|
16
|
+
function printDevnetListHashes(version) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const output =
|
|
18
|
+
const output = getDevnetListHashes(version);
|
|
19
19
|
console.log(output);
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
exports.
|
|
23
|
-
function
|
|
22
|
+
exports.printDevnetListHashes = printDevnetListHashes;
|
|
23
|
+
function getDevnetListHashes(version) {
|
|
24
24
|
const settings = (0, setting_1.readSettings)();
|
|
25
25
|
const ckbVersion = version || settings.bins.defaultCKBVersion;
|
|
26
26
|
const ckbBinPath = (0, encoding_1.encodeBinPathForTerminal)((0, setting_1.getCKBBinaryPath)(ckbVersion));
|
|
@@ -37,4 +37,4 @@ function getListHashes(version) {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
exports.
|
|
40
|
+
exports.getDevnetListHashes = getDevnetListHashes;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { SystemCell } from './list-hashes';
|
|
2
2
|
import { CellDepInfoLike, Script } from '@ckb-ccc/core';
|
|
3
3
|
import { ScriptInfo, SystemScriptsRecord } from '../scripts/type';
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { Network, NetworkOption } from '../type/base';
|
|
5
|
+
export declare enum PrintStyle {
|
|
6
|
+
system = "system",
|
|
7
|
+
lumos = "lumos",
|
|
8
|
+
ccc = "ccc"
|
|
9
|
+
}
|
|
10
|
+
export interface PrintProps extends NetworkOption {
|
|
11
|
+
style?: PrintStyle;
|
|
12
|
+
}
|
|
13
|
+
export declare function printSystemScripts({ style, network }: PrintProps): Promise<void>;
|
|
14
|
+
export declare function printInSystemStyle(systemScripts: SystemScriptsRecord, network: Network): void;
|
|
15
|
+
export declare function printInLumosConfigStyle(scripts: SystemScriptsRecord, network: Network): void;
|
|
16
|
+
export declare function printInCCCStyle(scripts: SystemScriptsRecord, network: Network): void;
|
|
17
|
+
export declare function getDevnetSystemScriptsFromListHashes(): SystemScriptsRecord | null;
|
|
10
18
|
export declare function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }: {
|
|
11
19
|
cell: SystemCell;
|
|
12
20
|
depType: 'code' | 'depGroup';
|
|
@@ -12,30 +12,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.toCCCKnownScripts = exports.toLumosConfig = exports.systemCellToScriptInfo = exports.
|
|
15
|
+
exports.toCCCKnownScripts = exports.toLumosConfig = exports.systemCellToScriptInfo = exports.getDevnetSystemScriptsFromListHashes = exports.printInCCCStyle = exports.printInLumosConfigStyle = exports.printInSystemStyle = exports.printSystemScripts = exports.PrintStyle = void 0;
|
|
16
16
|
const setting_1 = require("../cfg/setting");
|
|
17
17
|
const list_hashes_1 = require("./list-hashes");
|
|
18
18
|
const toml_1 = __importDefault(require("@iarna/toml"));
|
|
19
19
|
const core_1 = require("@ckb-ccc/core");
|
|
20
|
-
|
|
20
|
+
const base_1 = require("../type/base");
|
|
21
|
+
const public_1 = require("../scripts/public");
|
|
22
|
+
var PrintStyle;
|
|
23
|
+
(function (PrintStyle) {
|
|
24
|
+
PrintStyle["system"] = "system";
|
|
25
|
+
PrintStyle["lumos"] = "lumos";
|
|
26
|
+
PrintStyle["ccc"] = "ccc";
|
|
27
|
+
})(PrintStyle || (exports.PrintStyle = PrintStyle = {}));
|
|
28
|
+
function printSystemScripts({ style = PrintStyle.system, network = base_1.Network.devnet }) {
|
|
21
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const systemScripts =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const systemScripts = network === base_1.Network.mainnet
|
|
31
|
+
? public_1.MAINNET_SYSTEM_SCRIPTS
|
|
32
|
+
: network === base_1.Network.testnet
|
|
33
|
+
? public_1.TESTNET_SYSTEM_SCRIPTS
|
|
34
|
+
: getDevnetSystemScriptsFromListHashes();
|
|
35
|
+
if (!systemScripts)
|
|
36
|
+
return console.log(`SystemScripts is null, ${network}`);
|
|
37
|
+
if (style === PrintStyle.system) {
|
|
38
|
+
return printInSystemStyle(systemScripts, network);
|
|
39
|
+
}
|
|
40
|
+
if (style === PrintStyle.lumos) {
|
|
41
|
+
return printInLumosConfigStyle(systemScripts, network);
|
|
42
|
+
}
|
|
43
|
+
if (style === PrintStyle.ccc) {
|
|
44
|
+
return printInCCCStyle(systemScripts, network);
|
|
33
45
|
}
|
|
34
46
|
});
|
|
35
47
|
}
|
|
36
48
|
exports.printSystemScripts = printSystemScripts;
|
|
37
|
-
function printInSystemStyle(systemScripts) {
|
|
38
|
-
console.log(
|
|
49
|
+
function printInSystemStyle(systemScripts, network) {
|
|
50
|
+
console.log(`*** CKB ${network.toUpperCase()} System Scripts ***\n`);
|
|
39
51
|
for (const [name, script] of Object.entries(systemScripts)) {
|
|
40
52
|
console.log(`- name: ${name}`);
|
|
41
53
|
if (script == null) {
|
|
@@ -48,22 +60,22 @@ function printInSystemStyle(systemScripts) {
|
|
|
48
60
|
}
|
|
49
61
|
}
|
|
50
62
|
exports.printInSystemStyle = printInSystemStyle;
|
|
51
|
-
function printInLumosConfigStyle(scripts) {
|
|
52
|
-
const config = toLumosConfig(scripts);
|
|
53
|
-
console.log(
|
|
63
|
+
function printInLumosConfigStyle(scripts, network) {
|
|
64
|
+
const config = toLumosConfig(scripts, network === base_1.Network.mainnet ? 'ckb' : 'ckt');
|
|
65
|
+
console.log(`*** CKB ${network.toUpperCase()} System Scripts As LumosConfig ***\n`);
|
|
54
66
|
console.log(JSON.stringify(config, null, 2));
|
|
55
67
|
}
|
|
56
68
|
exports.printInLumosConfigStyle = printInLumosConfigStyle;
|
|
57
|
-
function printInCCCStyle(scripts) {
|
|
69
|
+
function printInCCCStyle(scripts, network) {
|
|
58
70
|
const knownsScripts = toCCCKnownScripts(scripts);
|
|
59
|
-
console.log(
|
|
71
|
+
console.log(`*** CKB ${network.toUpperCase()} System Scripts As CCC KnownScripts ***\n`);
|
|
60
72
|
console.log(JSON.stringify(knownsScripts, null, 2));
|
|
61
73
|
}
|
|
62
74
|
exports.printInCCCStyle = printInCCCStyle;
|
|
63
|
-
function
|
|
75
|
+
function getDevnetSystemScriptsFromListHashes() {
|
|
64
76
|
var _a;
|
|
65
77
|
const settings = (0, setting_1.readSettings)();
|
|
66
|
-
const listHashesString = (0, list_hashes_1.
|
|
78
|
+
const listHashesString = (0, list_hashes_1.getDevnetListHashes)(settings.bins.defaultCKBVersion);
|
|
67
79
|
if (!listHashesString) {
|
|
68
80
|
console.log(`list-hashes not found!`);
|
|
69
81
|
return null;
|
|
@@ -104,7 +116,7 @@ function getSystemScriptsFromListHashes() {
|
|
|
104
116
|
(_a = systemScripts.omnilock) === null || _a === void 0 ? void 0 : _a.script.cellDeps.push(systemScripts.secp256k1_blake160_sighash_all.script.cellDeps[0]);
|
|
105
117
|
return systemScripts;
|
|
106
118
|
}
|
|
107
|
-
exports.
|
|
119
|
+
exports.getDevnetSystemScriptsFromListHashes = getDevnetSystemScriptsFromListHashes;
|
|
108
120
|
function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }) {
|
|
109
121
|
// todo: we left the type in cellDepsInfo since it requires async fetching and
|
|
110
122
|
// chain running to get the full type script of the type-id deps.
|
package/dist/scripts/gen.js
CHANGED
|
@@ -34,7 +34,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
34
34
|
const base_1 = require("../type/base");
|
|
35
35
|
const util_1 = require("./util");
|
|
36
36
|
function genSystemScripts() {
|
|
37
|
-
const devnetScripts = (0, system_scripts_1.
|
|
37
|
+
const devnetScripts = (0, system_scripts_1.getDevnetSystemScriptsFromListHashes)();
|
|
38
38
|
if (devnetScripts != null) {
|
|
39
39
|
const networkScripts = {
|
|
40
40
|
devnet: devnetScripts,
|
package/dist/scripts/private.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.buildCCCDevnetKnownScripts = void 0;
|
|
|
4
4
|
//todo: extract getSystemScriptsFromListHashes/toCCCKnownScripts from cmd folder
|
|
5
5
|
const system_scripts_1 = require("../cmd/system-scripts");
|
|
6
6
|
function buildCCCDevnetKnownScripts() {
|
|
7
|
-
const devnetSystemScripts = (0, system_scripts_1.
|
|
7
|
+
const devnetSystemScripts = (0, system_scripts_1.getDevnetSystemScriptsFromListHashes)();
|
|
8
8
|
if (devnetSystemScripts == null) {
|
|
9
9
|
throw new Error('can not getSystemScriptsFromListHashes in devnet');
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export enum SystemScriptName {
|
|
|
21
21
|
|
|
22
22
|
export interface ScriptInfo {
|
|
23
23
|
codeHash: `0x${string}`;
|
|
24
|
-
hashType: 'type' | 'data';
|
|
24
|
+
hashType: 'type' | 'data' | 'data1';
|
|
25
25
|
cellDeps: {
|
|
26
26
|
cellDep: {
|
|
27
27
|
outPoint: {
|
|
@@ -30,6 +30,11 @@ export interface ScriptInfo {
|
|
|
30
30
|
};
|
|
31
31
|
depType: 'code' | 'dep_group';
|
|
32
32
|
};
|
|
33
|
+
type?: {
|
|
34
|
+
codeHash: `0x${string}`;
|
|
35
|
+
hashType: 'type' | 'data' | 'data1';
|
|
36
|
+
args: `0x${string}`;
|
|
37
|
+
};
|
|
33
38
|
}[];
|
|
34
39
|
}
|
|
35
40
|
|