@offckb/cli 0.2.6 → 0.3.0-canary-cfe9b48.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 +59 -17
- package/ckb/devnet/specs/dev.toml +7 -7
- package/dist/cfg/env-path.d.ts +9 -0
- package/dist/cfg/env-path.js +63 -0
- package/dist/cfg/setting.d.ts +45 -0
- package/dist/cfg/setting.js +124 -0
- package/dist/cli.js +54 -30
- package/dist/cmd/clean.js +7 -5
- package/dist/cmd/config.d.ts +11 -0
- package/dist/cmd/config.js +102 -0
- package/dist/cmd/create.d.ts +1 -1
- package/dist/cmd/create.js +19 -8
- package/dist/cmd/debug.d.ts +13 -0
- package/dist/cmd/debug.js +100 -0
- package/dist/cmd/deploy.js +45 -25
- package/dist/cmd/deposit.js +11 -7
- package/dist/cmd/inject-config.d.ts +0 -3
- package/dist/cmd/inject-config.js +20 -80
- package/dist/cmd/list-hashes.d.ts +25 -1
- package/dist/cmd/list-hashes.js +24 -16
- package/dist/cmd/{deployed-scripts.d.ts → my-scripts.d.ts} +1 -1
- package/dist/cmd/my-scripts.js +25 -0
- package/dist/cmd/node.d.ts +5 -1
- package/dist/cmd/node.js +22 -8
- package/dist/cmd/proxy-rpc.d.ts +7 -0
- package/dist/cmd/proxy-rpc.js +23 -0
- package/dist/cmd/sync-config.js +16 -11
- package/dist/cmd/system-scripts.d.ts +42 -0
- package/dist/cmd/system-scripts.js +265 -0
- package/dist/deploy/migration.d.ts +45 -0
- package/dist/deploy/migration.js +131 -0
- package/dist/deploy/toml.d.ts +38 -0
- package/dist/deploy/toml.js +60 -0
- package/dist/deploy/util.d.ts +2 -0
- package/dist/deploy/util.js +19 -0
- package/dist/node/init-chain.js +41 -0
- package/dist/{cmd/develop → node}/install.d.ts +4 -5
- package/dist/{cmd/develop → node}/install.js +32 -32
- package/dist/scripts/gen.d.ts +5 -0
- package/dist/scripts/gen.js +69 -0
- package/dist/scripts/public.d.ts +8 -0
- package/dist/scripts/public.js +396 -0
- package/dist/scripts/type.d.ts +46 -0
- package/dist/scripts/type.js +19 -0
- package/dist/scripts/util.d.ts +3 -0
- package/dist/scripts/util.js +84 -0
- package/dist/template/config.d.ts +4 -0
- package/dist/template/config.js +60 -0
- package/dist/template/offckb.config.d.ts +69 -0
- package/dist/template/offckb.config.js +81 -0
- package/dist/{util/template.d.ts → template/option.d.ts} +1 -1
- package/dist/template/option.js +11 -0
- package/dist/template/option.json +16 -0
- package/dist/tools/ckb-debugger.d.ts +12 -0
- package/dist/tools/ckb-debugger.js +31 -0
- package/dist/tools/ckb-tx-dumper.d.ts +6 -0
- package/dist/tools/ckb-tx-dumper.js +21 -0
- package/dist/tools/rpc-proxy.d.ts +9 -0
- package/dist/tools/rpc-proxy.js +84 -0
- package/dist/util/ckb.d.ts +64 -0
- package/dist/util/ckb.js +16 -3
- package/dist/util/encoding.d.ts +1 -0
- package/dist/util/encoding.js +7 -1
- package/dist/util/fs.d.ts +1 -2
- package/dist/util/fs.js +8 -32
- package/dist/util/git.js +19 -7
- package/dist/util/request.d.ts +8 -0
- package/dist/util/request.js +57 -0
- package/dist/util/type.d.ts +1 -0
- package/dist/util/validator.d.ts +1 -0
- package/dist/util/validator.js +13 -4
- package/package.json +9 -4
- package/templates/offckb.config.ts +3 -3
- package/templates/template.json +16 -0
- package/dist/cfg/const.d.ts +0 -21
- package/dist/cfg/const.js +0 -51
- package/dist/cmd/deployed-scripts.js +0 -14
- package/dist/cmd/develop/build-account.d.ts +0 -1
- package/dist/cmd/develop/build-account.js +0 -9
- package/dist/cmd/develop/genkey.d.ts +0 -14
- package/dist/cmd/develop/genkey.js +0 -143
- package/dist/cmd/develop/init-chain.js +0 -76
- package/dist/cmd/develop/lumos-config.d.ts +0 -4
- package/dist/cmd/develop/lumos-config.js +0 -153
- package/dist/util/config.d.ts +0 -9
- package/dist/util/config.js +0 -136
- package/dist/util/template.js +0 -30
- package/templates/config.json +0 -98
- /package/ckb/devnet/specs/{omni_lock → omnilock} +0 -0
- /package/ckb/devnet/specs/{spore-scripts → spore}/spore +0 -0
- /package/ckb/devnet/specs/{spore-scripts/cluster → spore/spore_cluster} +0 -0
- /package/ckb/devnet/specs/{spore-scripts/cluster_agent → spore/spore_cluster_agent} +0 -0
- /package/ckb/devnet/specs/{spore-scripts/cluster_proxy → spore/spore_cluster_proxy} +0 -0
- /package/ckb/devnet/specs/{spore-scripts → spore}/spore_extension_lua +0 -0
- /package/ckb/devnet/specs/{xudt_rce → xudt} +0 -0
- /package/dist/{cmd/develop → node}/init-chain.d.ts +0 -0
package/dist/cmd/list-hashes.js
CHANGED
|
@@ -9,24 +9,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.listHashes = void 0;
|
|
12
|
+
exports.getListHashes = exports.listHashes = void 0;
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
function listHashes() {
|
|
14
|
+
const setting_1 = require("../cfg/setting");
|
|
15
|
+
const encoding_1 = require("../util/encoding");
|
|
16
|
+
function listHashes(version) {
|
|
18
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const cmd = `${const_1.ckbBinPath} list-hashes -C ${const_1.devnetPath}`;
|
|
22
|
-
try {
|
|
23
|
-
(0, child_process_1.execSync)(cmd, {
|
|
24
|
-
stdio: 'inherit',
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.error('Error running dependency binary:', error);
|
|
29
|
-
}
|
|
18
|
+
const output = getListHashes(version);
|
|
19
|
+
console.log(output);
|
|
30
20
|
});
|
|
31
21
|
}
|
|
32
22
|
exports.listHashes = listHashes;
|
|
23
|
+
function getListHashes(version) {
|
|
24
|
+
const settings = (0, setting_1.readSettings)();
|
|
25
|
+
const ckbVersion = version || settings.bins.defaultCKBVersion;
|
|
26
|
+
const ckbBinPath = (0, encoding_1.encodeBinPathForTerminal)((0, setting_1.getCKBBinaryPath)(ckbVersion));
|
|
27
|
+
const devnetPath = (0, encoding_1.encodeBinPathForTerminal)(settings.devnet.configPath);
|
|
28
|
+
const cmd = `${ckbBinPath} list-hashes -C ${devnetPath}`;
|
|
29
|
+
try {
|
|
30
|
+
const output = (0, child_process_1.execSync)(cmd, {
|
|
31
|
+
encoding: 'utf-8',
|
|
32
|
+
});
|
|
33
|
+
return output;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error running dependency binary:', error);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.getListHashes = getListHashes;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { NetworkOption } from '../util/type';
|
|
2
2
|
export interface DeployedScriptOption extends NetworkOption {
|
|
3
3
|
}
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function printMyScripts(option?: DeployedScriptOption): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printMyScripts = void 0;
|
|
4
|
+
const toml_1 = require("../deploy/toml");
|
|
5
|
+
const util_1 = require("../deploy/util");
|
|
6
|
+
const util_2 = require("../scripts/util");
|
|
7
|
+
const type_1 = require("../util/type");
|
|
8
|
+
const validator_1 = require("../util/validator");
|
|
9
|
+
function printMyScripts(option = { network: type_1.Network.devnet }) {
|
|
10
|
+
const network = option.network;
|
|
11
|
+
(0, validator_1.validateNetworkOpt)(network);
|
|
12
|
+
const scriptsInfo = (0, util_2.readUserDeployedScriptsInfo)(network);
|
|
13
|
+
console.log(`*** User-deployed Scripts on ${network.toUpperCase()} ***`);
|
|
14
|
+
const scriptNames = Object.keys(scriptsInfo);
|
|
15
|
+
scriptNames.forEach((scriptName) => {
|
|
16
|
+
const deployToml = (0, toml_1.readDeploymentToml)(scriptName, network);
|
|
17
|
+
console.log(`- ${scriptName}`);
|
|
18
|
+
console.log(`Path: ${(0, util_1.getContractsPath)(network)}/${scriptName}`);
|
|
19
|
+
console.log(`Binary File: ${deployToml.cells[0].location.file}`);
|
|
20
|
+
console.log(`Enable Type Id: ${deployToml.cells[0].enableTypeId}`);
|
|
21
|
+
console.log(`Script Info: ${JSON.stringify(scriptsInfo[scriptName], null, 2)}`);
|
|
22
|
+
console.log(`\n`);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.printMyScripts = printMyScripts;
|
package/dist/cmd/node.d.ts
CHANGED
package/dist/cmd/node.js
CHANGED
|
@@ -11,22 +11,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.node = void 0;
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
14
|
+
const init_chain_1 = require("../node/init-chain");
|
|
15
|
+
const install_1 = require("../node/install");
|
|
16
|
+
const setting_1 = require("../cfg/setting");
|
|
17
|
+
const encoding_1 = require("../util/encoding");
|
|
18
|
+
const rpc_proxy_1 = require("../tools/rpc-proxy");
|
|
19
|
+
const type_1 = require("../util/type");
|
|
20
|
+
function node({ version, noProxyServer }) {
|
|
18
21
|
var _a, _b;
|
|
19
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
23
|
+
const settings = (0, setting_1.readSettings)();
|
|
24
|
+
const ckbVersion = version || settings.bins.defaultCKBVersion;
|
|
25
|
+
yield (0, install_1.installCKBBinary)(ckbVersion);
|
|
21
26
|
yield (0, init_chain_1.initChainIfNeeded)();
|
|
22
|
-
const
|
|
23
|
-
const
|
|
27
|
+
const ckbBinPath = (0, encoding_1.encodeBinPathForTerminal)((0, setting_1.getCKBBinaryPath)(ckbVersion));
|
|
28
|
+
const devnetConfigPath = (0, encoding_1.encodeBinPathForTerminal)(settings.devnet.configPath);
|
|
29
|
+
const ckbCmd = `${ckbBinPath} run -C ${devnetConfigPath}`;
|
|
30
|
+
const minerCmd = `${ckbBinPath} miner -C ${devnetConfigPath}`;
|
|
24
31
|
try {
|
|
25
32
|
// Run first command
|
|
26
33
|
const ckbProcess = (0, child_process_1.exec)(ckbCmd);
|
|
27
34
|
// Log first command's output
|
|
28
35
|
(_a = ckbProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
29
|
-
console.log('CKB
|
|
36
|
+
console.log('CKB:', data.toString());
|
|
30
37
|
});
|
|
31
38
|
(_b = ckbProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
|
|
32
39
|
console.error('CKB error:', data.toString());
|
|
@@ -43,6 +50,13 @@ function node() {
|
|
|
43
50
|
(_d = minerProcess.stderr) === null || _d === void 0 ? void 0 : _d.on('data', (data) => {
|
|
44
51
|
console.error('CKB-Miner error:', data.toString());
|
|
45
52
|
});
|
|
53
|
+
console.log('noProxyServer: ', noProxyServer);
|
|
54
|
+
if (!noProxyServer) {
|
|
55
|
+
const ckbRpc = settings.devnet.rpcUrl;
|
|
56
|
+
const port = settings.rpc.proxyPort;
|
|
57
|
+
const proxy = (0, rpc_proxy_1.createRPCProxy)(type_1.Network.devnet, ckbRpc, port);
|
|
58
|
+
proxy.start();
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
61
|
catch (error) {
|
|
48
62
|
console.error('Error running CKB-Miner:', error);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.proxyRpc = void 0;
|
|
4
|
+
const setting_1 = require("../cfg/setting");
|
|
5
|
+
const rpc_proxy_1 = require("../tools/rpc-proxy");
|
|
6
|
+
const type_1 = require("../util/type");
|
|
7
|
+
function proxyRpc(options) {
|
|
8
|
+
const settings = (0, setting_1.readSettings)();
|
|
9
|
+
const network = options.network || type_1.Network.devnet;
|
|
10
|
+
let ckbRpc = options.ckbRpc;
|
|
11
|
+
if (!ckbRpc) {
|
|
12
|
+
ckbRpc =
|
|
13
|
+
network === type_1.Network.devnet
|
|
14
|
+
? settings.devnet.rpcUrl
|
|
15
|
+
: network === type_1.Network.testnet
|
|
16
|
+
? settings.testnet.rpcUrl
|
|
17
|
+
: settings.mainnet.rpcUrl;
|
|
18
|
+
}
|
|
19
|
+
const port = options.port || settings.rpc.proxyPort;
|
|
20
|
+
const proxy = (0, rpc_proxy_1.createRPCProxy)(network, ckbRpc, port);
|
|
21
|
+
proxy.start();
|
|
22
|
+
}
|
|
23
|
+
exports.proxyRpc = proxyRpc;
|
package/dist/cmd/sync-config.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.syncConfig = void 0;
|
|
4
|
-
const
|
|
5
|
-
const config_1 = require("../util/config");
|
|
6
|
-
const type_1 = require("../util/type");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
7
8
|
const validator_1 = require("../util/validator");
|
|
9
|
+
const gen_1 = require("../scripts/gen");
|
|
10
|
+
const config_1 = require("../template/config");
|
|
8
11
|
function syncConfig() {
|
|
9
12
|
(0, validator_1.validateExecDappEnvironment)();
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(0,
|
|
17
|
-
|
|
13
|
+
const userOffCKBConfigPath = path_1.default.resolve(process.cwd(), 'offckb.config.ts');
|
|
14
|
+
const contractInfoFolder = config_1.OffCKBConfigFile.readContractInfoFolder(userOffCKBConfigPath);
|
|
15
|
+
if (!contractInfoFolder) {
|
|
16
|
+
throw new Error('No contract info folder found in offckb.config.ts!');
|
|
17
|
+
}
|
|
18
|
+
const systemJsonFilePath = path_1.default.resolve(contractInfoFolder, 'system-scripts.json');
|
|
19
|
+
(0, gen_1.genSystemScriptsJsonFile)(systemJsonFilePath);
|
|
20
|
+
const myScriptsJsonFilePath = path_1.default.resolve(contractInfoFolder, 'my-scripts.json');
|
|
21
|
+
(0, gen_1.genMyScriptsJsonFile)(myScriptsJsonFilePath);
|
|
22
|
+
console.log('scripts json config updated.');
|
|
18
23
|
}
|
|
19
24
|
exports.syncConfig = syncConfig;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { config } from '@ckb-lumos/lumos';
|
|
2
|
+
import { SystemCell } from './list-hashes';
|
|
3
|
+
import { CellDepInfoLike, Script } from '@ckb-ccc/core';
|
|
4
|
+
import { SystemScriptsRecord } from '../scripts/type';
|
|
5
|
+
export type PrintProps = 'lumos' | 'ccc';
|
|
6
|
+
export declare function printSystemScripts(props?: PrintProps): Promise<void>;
|
|
7
|
+
export declare function printInSystemStyle(systemScripts: SystemScriptsRecord): void;
|
|
8
|
+
export declare function printInLumosConfigStyle(scripts: SystemScriptsRecord): void;
|
|
9
|
+
export declare function printInCCCStyle(scripts: SystemScriptsRecord): void;
|
|
10
|
+
export declare function getSystemScriptsFromListHashes(): SystemScriptsRecord | null;
|
|
11
|
+
export declare function systemCellToScriptInfo(cell: SystemCell, depType: 'code' | 'depGroup', depGroup?: {
|
|
12
|
+
txHash: string;
|
|
13
|
+
index: number;
|
|
14
|
+
}): {
|
|
15
|
+
codeHash: string;
|
|
16
|
+
hashType: string;
|
|
17
|
+
cellDeps: {
|
|
18
|
+
cellDep: {
|
|
19
|
+
outPoint: {
|
|
20
|
+
txHash: string;
|
|
21
|
+
index: number;
|
|
22
|
+
};
|
|
23
|
+
depType: "code";
|
|
24
|
+
};
|
|
25
|
+
}[];
|
|
26
|
+
} | {
|
|
27
|
+
codeHash: string;
|
|
28
|
+
hashType: string;
|
|
29
|
+
cellDeps: {
|
|
30
|
+
cellDep: {
|
|
31
|
+
outPoint: {
|
|
32
|
+
txHash: string;
|
|
33
|
+
index: number;
|
|
34
|
+
};
|
|
35
|
+
depType: "depGroup";
|
|
36
|
+
};
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
export declare function toLumosConfig(scripts: SystemScriptsRecord, addressPrefix?: 'ckb' | 'ckt'): config.Config;
|
|
40
|
+
export declare function toCCCKnownScripts(scripts: SystemScriptsRecord): Record<string, Pick<Script, "codeHash" | "hashType"> & {
|
|
41
|
+
cellDeps: CellDepInfoLike[];
|
|
42
|
+
}>;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.toCCCKnownScripts = exports.toLumosConfig = exports.systemCellToScriptInfo = exports.getSystemScriptsFromListHashes = exports.printInCCCStyle = exports.printInLumosConfigStyle = exports.printInSystemStyle = exports.printSystemScripts = void 0;
|
|
16
|
+
const setting_1 = require("../cfg/setting");
|
|
17
|
+
const list_hashes_1 = require("./list-hashes");
|
|
18
|
+
const toml_1 = __importDefault(require("@iarna/toml"));
|
|
19
|
+
const core_1 = require("@ckb-ccc/core");
|
|
20
|
+
function printSystemScripts(props) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const systemScripts = getSystemScriptsFromListHashes();
|
|
23
|
+
if (systemScripts) {
|
|
24
|
+
if (!props) {
|
|
25
|
+
return printInSystemStyle(systemScripts);
|
|
26
|
+
}
|
|
27
|
+
if (props === 'lumos') {
|
|
28
|
+
return printInLumosConfigStyle(systemScripts);
|
|
29
|
+
}
|
|
30
|
+
if (props === 'ccc') {
|
|
31
|
+
return printInCCCStyle(systemScripts);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.printSystemScripts = printSystemScripts;
|
|
37
|
+
function printInSystemStyle(systemScripts) {
|
|
38
|
+
console.log('*** OffCKB Devnet System Scripts ***\n');
|
|
39
|
+
for (const [name, script] of Object.entries(systemScripts)) {
|
|
40
|
+
console.log(`- name: ${name}`);
|
|
41
|
+
if (script == null) {
|
|
42
|
+
return console.log(` undefined\n`);
|
|
43
|
+
}
|
|
44
|
+
console.log(` file: ${script.file}`);
|
|
45
|
+
console.log(` code_hash: ${script.script.codeHash}`);
|
|
46
|
+
console.log(` hash_type: ${script.script.hashType}`);
|
|
47
|
+
console.log(` cellDeps: ${JSON.stringify(script.script.cellDeps, null, 2)}\n`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.printInSystemStyle = printInSystemStyle;
|
|
51
|
+
function printInLumosConfigStyle(scripts) {
|
|
52
|
+
const config = toLumosConfig(scripts);
|
|
53
|
+
console.log('*** OffCKB Devnet System Scripts As LumosConfig ***\n');
|
|
54
|
+
console.log(JSON.stringify(config, null, 2));
|
|
55
|
+
}
|
|
56
|
+
exports.printInLumosConfigStyle = printInLumosConfigStyle;
|
|
57
|
+
function printInCCCStyle(scripts) {
|
|
58
|
+
const knownsScripts = toCCCKnownScripts(scripts);
|
|
59
|
+
console.log('*** OffCKB Devnet System Scripts As CCC KnownScripts ***\n');
|
|
60
|
+
console.log(JSON.stringify(knownsScripts, null, 2));
|
|
61
|
+
}
|
|
62
|
+
exports.printInCCCStyle = printInCCCStyle;
|
|
63
|
+
function getSystemScriptsFromListHashes() {
|
|
64
|
+
const settings = (0, setting_1.readSettings)();
|
|
65
|
+
const listHashesString = (0, list_hashes_1.getListHashes)(settings.bins.defaultCKBVersion);
|
|
66
|
+
if (listHashesString) {
|
|
67
|
+
const listHashes = toml_1.default.parse(listHashesString);
|
|
68
|
+
const systemScriptArray = listHashes.offckb.system_cells
|
|
69
|
+
.map((cell) => {
|
|
70
|
+
var _a;
|
|
71
|
+
// Extract the file name
|
|
72
|
+
const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
|
|
73
|
+
const depGroupIndex = listHashes.offckb.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(`Bundled(specs/cells/${name})`));
|
|
74
|
+
const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
|
|
75
|
+
const depGroup = depGroupIndex === -1
|
|
76
|
+
? undefined
|
|
77
|
+
: {
|
|
78
|
+
txHash: listHashes.offckb.dep_groups[depGroupIndex].tx_hash,
|
|
79
|
+
index: listHashes.offckb.dep_groups[depGroupIndex].index,
|
|
80
|
+
};
|
|
81
|
+
const scriptInfo = systemCellToScriptInfo(cell, depType, depGroup);
|
|
82
|
+
return {
|
|
83
|
+
name,
|
|
84
|
+
file: cell.path,
|
|
85
|
+
script: scriptInfo,
|
|
86
|
+
};
|
|
87
|
+
})
|
|
88
|
+
.filter((s) => s.name != 'secp256k1_data');
|
|
89
|
+
const systemScripts = systemScriptArray.reduce((acc, item) => {
|
|
90
|
+
const key = item.name;
|
|
91
|
+
acc[key] = item;
|
|
92
|
+
return acc;
|
|
93
|
+
}, {});
|
|
94
|
+
return systemScripts;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
console.log(`list-hashes not found!`);
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.getSystemScriptsFromListHashes = getSystemScriptsFromListHashes;
|
|
102
|
+
function systemCellToScriptInfo(cell, depType, depGroup) {
|
|
103
|
+
if (depType === 'depGroup' && !depGroup) {
|
|
104
|
+
throw new Error('require depGroup info since the dep type is depGroup');
|
|
105
|
+
}
|
|
106
|
+
if (depType === 'code') {
|
|
107
|
+
return {
|
|
108
|
+
codeHash: cell.type_hash || cell.data_hash,
|
|
109
|
+
hashType: cell.type_hash ? 'type' : 'data',
|
|
110
|
+
cellDeps: [
|
|
111
|
+
{
|
|
112
|
+
cellDep: {
|
|
113
|
+
outPoint: {
|
|
114
|
+
txHash: cell.tx_hash,
|
|
115
|
+
index: cell.index,
|
|
116
|
+
},
|
|
117
|
+
depType,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
codeHash: cell.type_hash || cell.data_hash,
|
|
125
|
+
hashType: cell.type_hash ? 'type' : 'data',
|
|
126
|
+
cellDeps: [
|
|
127
|
+
{
|
|
128
|
+
cellDep: {
|
|
129
|
+
outPoint: {
|
|
130
|
+
txHash: depGroup.txHash,
|
|
131
|
+
index: depGroup.index,
|
|
132
|
+
},
|
|
133
|
+
depType,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
exports.systemCellToScriptInfo = systemCellToScriptInfo;
|
|
140
|
+
function toLumosConfig(scripts, addressPrefix = 'ckt') {
|
|
141
|
+
const config = {
|
|
142
|
+
PREFIX: addressPrefix,
|
|
143
|
+
SCRIPTS: {
|
|
144
|
+
SECP256K1_BLAKE160: {
|
|
145
|
+
CODE_HASH: scripts.secp256k1_blake160_sighash_all.script.codeHash,
|
|
146
|
+
HASH_TYPE: scripts.secp256k1_blake160_sighash_all.script.hashType,
|
|
147
|
+
TX_HASH: scripts.secp256k1_blake160_sighash_all.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
148
|
+
INDEX: '0x' + scripts.secp256k1_blake160_sighash_all.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
149
|
+
DEP_TYPE: scripts.secp256k1_blake160_sighash_all.script.cellDeps[0].cellDep.depType,
|
|
150
|
+
SHORT_ID: 1,
|
|
151
|
+
},
|
|
152
|
+
SECP256K1_BLAKE160_MULTISIG: {
|
|
153
|
+
CODE_HASH: scripts.secp256k1_blake160_multisig_all.script.codeHash,
|
|
154
|
+
HASH_TYPE: scripts.secp256k1_blake160_multisig_all.script.hashType,
|
|
155
|
+
TX_HASH: scripts.secp256k1_blake160_multisig_all.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
156
|
+
INDEX: '0x' + scripts.secp256k1_blake160_multisig_all.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
157
|
+
DEP_TYPE: scripts.secp256k1_blake160_multisig_all.script.cellDeps[0].cellDep.depType,
|
|
158
|
+
},
|
|
159
|
+
DAO: {
|
|
160
|
+
CODE_HASH: scripts.dao.script.codeHash,
|
|
161
|
+
HASH_TYPE: scripts.dao.script.hashType,
|
|
162
|
+
TX_HASH: scripts.dao.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
163
|
+
INDEX: '0x' + scripts.dao.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
164
|
+
DEP_TYPE: scripts.dao.script.cellDeps[0].cellDep.depType,
|
|
165
|
+
SHORT_ID: 2,
|
|
166
|
+
},
|
|
167
|
+
SUDT: {
|
|
168
|
+
CODE_HASH: scripts.sudt.script.codeHash,
|
|
169
|
+
HASH_TYPE: scripts.sudt.script.hashType,
|
|
170
|
+
TX_HASH: scripts.sudt.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
171
|
+
INDEX: '0x' + scripts.sudt.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
172
|
+
DEP_TYPE: scripts.sudt.script.cellDeps[0].cellDep.depType,
|
|
173
|
+
},
|
|
174
|
+
XUDT: {
|
|
175
|
+
CODE_HASH: scripts.xudt.script.codeHash,
|
|
176
|
+
HASH_TYPE: scripts.xudt.script.hashType,
|
|
177
|
+
TX_HASH: scripts.xudt.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
178
|
+
INDEX: '0x' + scripts.xudt.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
179
|
+
DEP_TYPE: scripts.xudt.script.cellDeps[0].cellDep.depType,
|
|
180
|
+
},
|
|
181
|
+
OMNILOCK: {
|
|
182
|
+
CODE_HASH: scripts.omnilock.script.codeHash,
|
|
183
|
+
HASH_TYPE: scripts.omnilock.script.hashType,
|
|
184
|
+
TX_HASH: scripts.omnilock.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
185
|
+
INDEX: '0x' + scripts.omnilock.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
186
|
+
DEP_TYPE: scripts.omnilock.script.cellDeps[0].cellDep.depType,
|
|
187
|
+
},
|
|
188
|
+
ANYONE_CAN_PAY: {
|
|
189
|
+
CODE_HASH: scripts.anyone_can_pay.script.codeHash,
|
|
190
|
+
HASH_TYPE: scripts.anyone_can_pay.script.hashType,
|
|
191
|
+
TX_HASH: scripts.anyone_can_pay.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
192
|
+
INDEX: '0x' + scripts.anyone_can_pay.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
193
|
+
DEP_TYPE: scripts.anyone_can_pay.script.cellDeps[0].cellDep.depType,
|
|
194
|
+
},
|
|
195
|
+
SPORE: {
|
|
196
|
+
CODE_HASH: scripts.spore.script.codeHash,
|
|
197
|
+
HASH_TYPE: scripts.spore.script.hashType,
|
|
198
|
+
TX_HASH: scripts.spore.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
199
|
+
INDEX: '0x' + scripts.spore.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
200
|
+
DEP_TYPE: scripts.spore.script.cellDeps[0].cellDep.depType,
|
|
201
|
+
},
|
|
202
|
+
SPORE_CLUSTER: {
|
|
203
|
+
CODE_HASH: scripts.spore_cluster.script.codeHash,
|
|
204
|
+
HASH_TYPE: scripts.spore_cluster.script.hashType,
|
|
205
|
+
TX_HASH: scripts.spore_cluster.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
206
|
+
INDEX: '0x' + scripts.spore_cluster.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
207
|
+
DEP_TYPE: scripts.spore_cluster.script.cellDeps[0].cellDep.depType,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
if (scripts.always_success) {
|
|
212
|
+
config.SCRIPTS['ALWAYS_SUCCESS'] = {
|
|
213
|
+
CODE_HASH: scripts.always_success.script.codeHash,
|
|
214
|
+
HASH_TYPE: scripts.always_success.script.hashType,
|
|
215
|
+
TX_HASH: scripts.always_success.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
216
|
+
INDEX: '0x' + scripts.always_success.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
217
|
+
DEP_TYPE: scripts.always_success.script.cellDeps[0].cellDep.depType,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
if (scripts.spore_cluster_agent) {
|
|
221
|
+
config.SCRIPTS['SPORE_CLUSTER_AGENT'] = {
|
|
222
|
+
CODE_HASH: scripts.spore_cluster_agent.script.codeHash,
|
|
223
|
+
HASH_TYPE: scripts.spore_cluster_agent.script.hashType,
|
|
224
|
+
TX_HASH: scripts.spore_cluster_agent.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
225
|
+
INDEX: '0x' + scripts.spore_cluster_agent.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
226
|
+
DEP_TYPE: scripts.spore_cluster_agent.script.cellDeps[0].cellDep.depType,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (scripts.spore_cluster_proxy) {
|
|
230
|
+
config.SCRIPTS['SPORE_CLUSTER_PROXY'] = {
|
|
231
|
+
CODE_HASH: scripts.spore_cluster_proxy.script.codeHash,
|
|
232
|
+
HASH_TYPE: scripts.spore_cluster_proxy.script.hashType,
|
|
233
|
+
TX_HASH: scripts.spore_cluster_proxy.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
234
|
+
INDEX: '0x' + scripts.spore_cluster_proxy.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
235
|
+
DEP_TYPE: scripts.spore_cluster_proxy.script.cellDeps[0].cellDep.depType,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (scripts.spore_extension_lua) {
|
|
239
|
+
config.SCRIPTS['SPORE_LUA'] = {
|
|
240
|
+
CODE_HASH: scripts.spore_extension_lua.script.codeHash,
|
|
241
|
+
HASH_TYPE: scripts.spore_extension_lua.script.hashType,
|
|
242
|
+
TX_HASH: scripts.spore_extension_lua.script.cellDeps[0].cellDep.outPoint.txHash,
|
|
243
|
+
INDEX: '0x' + scripts.spore_extension_lua.script.cellDeps[0].cellDep.outPoint.index.toString(16),
|
|
244
|
+
DEP_TYPE: scripts.spore_extension_lua.script.cellDeps[0].cellDep.depType,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
return config;
|
|
248
|
+
}
|
|
249
|
+
exports.toLumosConfig = toLumosConfig;
|
|
250
|
+
function toCCCKnownScripts(scripts) {
|
|
251
|
+
const DEVNET_SCRIPTS = {
|
|
252
|
+
[core_1.KnownScript.Secp256k1Blake160]: scripts.secp256k1_blake160_sighash_all.script,
|
|
253
|
+
[core_1.KnownScript.Secp256k1Multisig]: scripts.secp256k1_blake160_multisig_all.script,
|
|
254
|
+
[core_1.KnownScript.AnyoneCanPay]: scripts.anyone_can_pay.script,
|
|
255
|
+
[core_1.KnownScript.OmniLock]: scripts.omnilock.script,
|
|
256
|
+
[core_1.KnownScript.XUdt]: scripts.xudt.script,
|
|
257
|
+
[core_1.KnownScript.TypeId]: {
|
|
258
|
+
codeHash: '0x00000000000000000000000000000000000000000000000000545950455f4944',
|
|
259
|
+
hashType: 'type',
|
|
260
|
+
cellDeps: [],
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
return DEVNET_SCRIPTS;
|
|
264
|
+
}
|
|
265
|
+
exports.toCCCKnownScripts = toCCCKnownScripts;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { HexNumber } from '@ckb-lumos/lumos';
|
|
2
|
+
import { Network } from '../util/type';
|
|
3
|
+
export interface CellRecipe {
|
|
4
|
+
name: string;
|
|
5
|
+
txHash: string;
|
|
6
|
+
index: HexNumber;
|
|
7
|
+
occupiedCapacity: HexNumber;
|
|
8
|
+
dataHash: string;
|
|
9
|
+
typeId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DepGroupRecipe {
|
|
12
|
+
name: string;
|
|
13
|
+
txHash: string;
|
|
14
|
+
index: HexNumber;
|
|
15
|
+
dataHash: string;
|
|
16
|
+
occupiedCapacity: HexNumber;
|
|
17
|
+
}
|
|
18
|
+
export interface DeploymentRecipe {
|
|
19
|
+
cellRecipes: CellRecipe[];
|
|
20
|
+
depGroupRecipes: DepGroupRecipe[];
|
|
21
|
+
}
|
|
22
|
+
export interface DeploymentRecipeJson {
|
|
23
|
+
cell_recipes: {
|
|
24
|
+
name: string;
|
|
25
|
+
tx_hash: string;
|
|
26
|
+
index: HexNumber;
|
|
27
|
+
occupied_capacity: HexNumber;
|
|
28
|
+
data_hash: string;
|
|
29
|
+
type_id?: string;
|
|
30
|
+
}[];
|
|
31
|
+
dep_group_recipes: {
|
|
32
|
+
name: string;
|
|
33
|
+
tx_hash: string;
|
|
34
|
+
index: HexNumber;
|
|
35
|
+
data_hash: string;
|
|
36
|
+
occupied_capacity: HexNumber;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
export declare function generateDeploymentRecipeJsonFile(name: string, deploymentRecipe: DeploymentRecipe, network?: Network): void;
|
|
40
|
+
export declare function readDeploymentRecipeJsonFile(filePath: string): DeploymentRecipe;
|
|
41
|
+
export declare function getFormattedMigrationDate(): string;
|
|
42
|
+
export declare function getMigrationFolderPath(scriptName: string, network: Network): string;
|
|
43
|
+
export declare function getNewestMigrationFile(folderPath: string): string | undefined;
|
|
44
|
+
export declare function deploymentRecipeToJson(recipe: DeploymentRecipe): DeploymentRecipeJson;
|
|
45
|
+
export declare function deploymentRecipeFromJson(json: DeploymentRecipeJson): DeploymentRecipe;
|