@offckb/cli 0.3.2 → 0.3.4
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 +6 -0
- package/dist/cfg/env-path.js +1 -1
- package/dist/cfg/setting.js +22 -12
- package/dist/cli.js +17 -7
- package/dist/cmd/accounts.js +1 -2
- package/dist/cmd/balance.js +3 -4
- package/dist/cmd/clean.js +1 -2
- package/dist/cmd/config.js +2 -2
- package/dist/cmd/create.js +3 -4
- package/dist/cmd/debug.d.ts +1 -1
- package/dist/cmd/debug.js +10 -10
- package/dist/cmd/deploy.js +24 -7
- package/dist/cmd/deposit.js +3 -4
- package/dist/cmd/inject-config.js +18 -9
- package/dist/cmd/list-hashes.js +2 -3
- package/dist/cmd/mol.js +2 -3
- package/dist/cmd/my-scripts.js +1 -2
- package/dist/cmd/node.js +9 -10
- package/dist/cmd/proxy-rpc.js +1 -2
- package/dist/cmd/repl.js +5 -6
- package/dist/cmd/sync-scripts.js +1 -2
- package/dist/cmd/system-scripts.js +11 -11
- package/dist/cmd/transfer-all.js +3 -4
- package/dist/cmd/transfer.js +3 -4
- package/dist/deploy/index.js +6 -6
- package/dist/deploy/migration.js +25 -15
- package/dist/deploy/toml.js +2 -3
- package/dist/deploy/util.js +1 -2
- package/dist/molecule/mol.js +20 -10
- package/dist/node/init-chain.js +1 -2
- package/dist/node/install.js +27 -18
- package/dist/scripts/gen.js +21 -12
- package/dist/scripts/private.js +1 -2
- package/dist/scripts/util.js +18 -9
- package/dist/sdk/ckb.js +7 -7
- package/dist/template/offckb-config.js +17 -7
- package/dist/template/option.js +1 -2
- package/dist/tools/ckb-tx-dumper.js +1 -2
- package/dist/tools/rpc-proxy.d.ts +0 -1
- package/dist/tools/rpc-proxy.js +1 -2
- package/dist/util/encoding.js +2 -3
- package/dist/util/fs.d.ts +1 -0
- package/dist/util/fs.js +34 -20
- package/dist/util/git.js +19 -10
- package/dist/util/link.js +1 -2
- package/dist/util/request.js +2 -2
- package/dist/util/validator.js +5 -6
- package/npm-shrinkwrap.json +4514 -0
- package/package.json +6 -4
|
@@ -12,7 +12,15 @@ 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.
|
|
15
|
+
exports.PrintStyle = void 0;
|
|
16
|
+
exports.printSystemScripts = printSystemScripts;
|
|
17
|
+
exports.printInSystemStyle = printInSystemStyle;
|
|
18
|
+
exports.printInLumosConfigStyle = printInLumosConfigStyle;
|
|
19
|
+
exports.printInCCCStyle = printInCCCStyle;
|
|
20
|
+
exports.getDevnetSystemScriptsFromListHashes = getDevnetSystemScriptsFromListHashes;
|
|
21
|
+
exports.systemCellToScriptInfo = systemCellToScriptInfo;
|
|
22
|
+
exports.toLumosConfig = toLumosConfig;
|
|
23
|
+
exports.toCCCKnownScripts = toCCCKnownScripts;
|
|
16
24
|
const setting_1 = require("../cfg/setting");
|
|
17
25
|
const list_hashes_1 = require("./list-hashes");
|
|
18
26
|
const toml_1 = __importDefault(require("@iarna/toml"));
|
|
@@ -25,8 +33,8 @@ var PrintStyle;
|
|
|
25
33
|
PrintStyle["lumos"] = "lumos";
|
|
26
34
|
PrintStyle["ccc"] = "ccc";
|
|
27
35
|
})(PrintStyle || (exports.PrintStyle = PrintStyle = {}));
|
|
28
|
-
function printSystemScripts(
|
|
29
|
-
return __awaiter(this,
|
|
36
|
+
function printSystemScripts(_a) {
|
|
37
|
+
return __awaiter(this, arguments, void 0, function* ({ style = PrintStyle.system, network = base_1.Network.devnet }) {
|
|
30
38
|
const systemScripts = network === base_1.Network.mainnet
|
|
31
39
|
? public_1.MAINNET_SYSTEM_SCRIPTS
|
|
32
40
|
: network === base_1.Network.testnet
|
|
@@ -45,7 +53,6 @@ function printSystemScripts({ style = PrintStyle.system, network = base_1.Networ
|
|
|
45
53
|
}
|
|
46
54
|
});
|
|
47
55
|
}
|
|
48
|
-
exports.printSystemScripts = printSystemScripts;
|
|
49
56
|
function printInSystemStyle(systemScripts, network) {
|
|
50
57
|
console.log(`*** CKB ${network.toUpperCase()} System Scripts ***\n`);
|
|
51
58
|
for (const [name, script] of Object.entries(systemScripts)) {
|
|
@@ -59,19 +66,16 @@ function printInSystemStyle(systemScripts, network) {
|
|
|
59
66
|
console.log(` cellDeps: ${JSON.stringify(script.script.cellDeps, null, 2)}\n`);
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
|
-
exports.printInSystemStyle = printInSystemStyle;
|
|
63
69
|
function printInLumosConfigStyle(scripts, network) {
|
|
64
70
|
const config = toLumosConfig(scripts, network === base_1.Network.mainnet ? 'ckb' : 'ckt');
|
|
65
71
|
console.log(`*** CKB ${network.toUpperCase()} System Scripts As LumosConfig ***\n`);
|
|
66
72
|
console.log(JSON.stringify(config, null, 2));
|
|
67
73
|
}
|
|
68
|
-
exports.printInLumosConfigStyle = printInLumosConfigStyle;
|
|
69
74
|
function printInCCCStyle(scripts, network) {
|
|
70
75
|
const knownsScripts = toCCCKnownScripts(scripts);
|
|
71
76
|
console.log(`*** CKB ${network.toUpperCase()} System Scripts As CCC KnownScripts ***\n`);
|
|
72
77
|
console.log(JSON.stringify(knownsScripts, null, 2));
|
|
73
78
|
}
|
|
74
|
-
exports.printInCCCStyle = printInCCCStyle;
|
|
75
79
|
function getDevnetSystemScriptsFromListHashes() {
|
|
76
80
|
var _a;
|
|
77
81
|
const settings = (0, setting_1.readSettings)();
|
|
@@ -116,7 +120,6 @@ function getDevnetSystemScriptsFromListHashes() {
|
|
|
116
120
|
(_a = systemScripts.omnilock) === null || _a === void 0 ? void 0 : _a.script.cellDeps.push(systemScripts.secp256k1_blake160_sighash_all.script.cellDeps[0]);
|
|
117
121
|
return systemScripts;
|
|
118
122
|
}
|
|
119
|
-
exports.getDevnetSystemScriptsFromListHashes = getDevnetSystemScriptsFromListHashes;
|
|
120
123
|
function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }) {
|
|
121
124
|
// todo: we left the type in cellDepsInfo since it requires async fetching and
|
|
122
125
|
// chain running to get the full type script of the type-id deps.
|
|
@@ -168,7 +171,6 @@ function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }) {
|
|
|
168
171
|
}
|
|
169
172
|
throw new Error(`unknown DepType ${depType}`);
|
|
170
173
|
}
|
|
171
|
-
exports.systemCellToScriptInfo = systemCellToScriptInfo;
|
|
172
174
|
function toLumosConfig(scripts, addressPrefix = 'ckt') {
|
|
173
175
|
const config = {
|
|
174
176
|
PREFIX: addressPrefix,
|
|
@@ -282,7 +284,6 @@ function toLumosConfig(scripts, addressPrefix = 'ckt') {
|
|
|
282
284
|
}
|
|
283
285
|
return config;
|
|
284
286
|
}
|
|
285
|
-
exports.toLumosConfig = toLumosConfig;
|
|
286
287
|
function toCCCKnownScripts(scripts) {
|
|
287
288
|
const DEVNET_SCRIPTS = {
|
|
288
289
|
[core_1.KnownScript.Secp256k1Blake160]: scripts.secp256k1_blake160_sighash_all.script,
|
|
@@ -298,4 +299,3 @@ function toCCCKnownScripts(scripts) {
|
|
|
298
299
|
};
|
|
299
300
|
return DEVNET_SCRIPTS;
|
|
300
301
|
}
|
|
301
|
-
exports.toCCCKnownScripts = toCCCKnownScripts;
|
package/dist/cmd/transfer-all.js
CHANGED
|
@@ -9,13 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.transferAll =
|
|
12
|
+
exports.transferAll = transferAll;
|
|
13
13
|
const ckb_1 = require("../sdk/ckb");
|
|
14
14
|
const base_1 = require("../type/base");
|
|
15
15
|
const link_1 = require("../util/link");
|
|
16
16
|
const validator_1 = require("../util/validator");
|
|
17
|
-
function transferAll(
|
|
18
|
-
return __awaiter(this,
|
|
17
|
+
function transferAll(toAddress_1) {
|
|
18
|
+
return __awaiter(this, arguments, void 0, function* (toAddress, opt = { network: base_1.Network.devnet, proxyRpc: false }) {
|
|
19
19
|
const network = opt.network;
|
|
20
20
|
(0, validator_1.validateNetworkOpt)(network);
|
|
21
21
|
if (opt.privkey == null) {
|
|
@@ -35,4 +35,3 @@ function transferAll(toAddress, opt = { network: base_1.Network.devnet, proxyRpc
|
|
|
35
35
|
console.log('Successfully transfer, txHash:', txHash);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
exports.transferAll = transferAll;
|
package/dist/cmd/transfer.js
CHANGED
|
@@ -9,13 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.transfer =
|
|
12
|
+
exports.transfer = transfer;
|
|
13
13
|
const ckb_1 = require("../sdk/ckb");
|
|
14
14
|
const base_1 = require("../type/base");
|
|
15
15
|
const link_1 = require("../util/link");
|
|
16
16
|
const validator_1 = require("../util/validator");
|
|
17
|
-
function transfer(
|
|
18
|
-
return __awaiter(this,
|
|
17
|
+
function transfer(toAddress_1, amountInCKB_1) {
|
|
18
|
+
return __awaiter(this, arguments, void 0, function* (toAddress, amountInCKB, opt = { network: base_1.Network.devnet, proxyRpc: false }) {
|
|
19
19
|
const network = opt.network;
|
|
20
20
|
(0, validator_1.validateNetworkOpt)(network);
|
|
21
21
|
if (opt.privkey == null) {
|
|
@@ -36,4 +36,3 @@ function transfer(toAddress, amountInCKB, opt = { network: base_1.Network.devnet
|
|
|
36
36
|
console.log('Successfully transfer, txHash:', txHash);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
exports.transfer = transfer;
|
package/dist/deploy/index.js
CHANGED
|
@@ -12,7 +12,10 @@ 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.
|
|
15
|
+
exports.getToDeployBinsPath = getToDeployBinsPath;
|
|
16
|
+
exports.recordDeployResult = recordDeployResult;
|
|
17
|
+
exports.deployBinaries = deployBinaries;
|
|
18
|
+
exports.deployBinary = deployBinary;
|
|
16
19
|
const toml_1 = require("../deploy/toml");
|
|
17
20
|
const migration_1 = require("../deploy/migration");
|
|
18
21
|
const gen_1 = require("../scripts/gen");
|
|
@@ -26,9 +29,10 @@ function getToDeployBinsPath(userOffCKBConfigPath) {
|
|
|
26
29
|
const match = fileContent.match(/contractBinFolder:\s*['"]([^'"]+)['"]/);
|
|
27
30
|
if (match && match[1]) {
|
|
28
31
|
const contractBinFolderValue = match[1];
|
|
32
|
+
const folderPath = path_1.default.dirname(userOffCKBConfigPath);
|
|
29
33
|
const binFileOrFolderPath = (0, fs_1.isAbsolutePath)(contractBinFolderValue)
|
|
30
34
|
? contractBinFolderValue
|
|
31
|
-
: path_1.default.resolve(
|
|
35
|
+
: path_1.default.resolve(folderPath, contractBinFolderValue);
|
|
32
36
|
const bins = (0, fs_1.getBinaryFilesFromPath)(binFileOrFolderPath);
|
|
33
37
|
return bins;
|
|
34
38
|
}
|
|
@@ -37,7 +41,6 @@ function getToDeployBinsPath(userOffCKBConfigPath) {
|
|
|
37
41
|
return [];
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
|
-
exports.getToDeployBinsPath = getToDeployBinsPath;
|
|
41
44
|
function recordDeployResult(results, network, userOffCKBConfigPath) {
|
|
42
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
46
|
if (results.length === 0) {
|
|
@@ -61,7 +64,6 @@ function recordDeployResult(results, network, userOffCKBConfigPath) {
|
|
|
61
64
|
console.log('done.');
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
|
-
exports.recordDeployResult = recordDeployResult;
|
|
65
67
|
function deployBinaries(binPaths, privateKey, enableTypeId, ckb) {
|
|
66
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
69
|
if (binPaths.length === 0) {
|
|
@@ -75,7 +77,6 @@ function deployBinaries(binPaths, privateKey, enableTypeId, ckb) {
|
|
|
75
77
|
return results;
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
|
-
exports.deployBinaries = deployBinaries;
|
|
79
80
|
function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
80
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
82
|
const bin = yield (0, fs_1.readFileToUint8Array)(binPath);
|
|
@@ -124,4 +125,3 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
124
125
|
};
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
|
-
exports.deployBinary = deployBinary;
|
package/dist/deploy/migration.js
CHANGED
|
@@ -15,18 +15,35 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.Migration = void 0;
|
|
40
|
+
exports.generateDeploymentMigrationFile = generateDeploymentMigrationFile;
|
|
41
|
+
exports.readDeploymentMigrationFile = readDeploymentMigrationFile;
|
|
42
|
+
exports.getFormattedMigrationDate = getFormattedMigrationDate;
|
|
43
|
+
exports.getMigrationFolderPath = getMigrationFolderPath;
|
|
44
|
+
exports.getNewestMigrationFile = getNewestMigrationFile;
|
|
45
|
+
exports.deploymentRecipeToJson = deploymentRecipeToJson;
|
|
46
|
+
exports.deploymentRecipeFromJson = deploymentRecipeFromJson;
|
|
30
47
|
const base_1 = require("../type/base");
|
|
31
48
|
const path_1 = __importStar(require("path"));
|
|
32
49
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -70,13 +87,11 @@ function generateDeploymentMigrationFile(name, deploymentRecipe, network = base_
|
|
|
70
87
|
console.log(`${name} migration json file ${outputFilePath} generated successfully.`);
|
|
71
88
|
}
|
|
72
89
|
}
|
|
73
|
-
exports.generateDeploymentMigrationFile = generateDeploymentMigrationFile;
|
|
74
90
|
function readDeploymentMigrationFile(filePath) {
|
|
75
91
|
const jsonString = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
76
92
|
const data = JSON.parse(jsonString);
|
|
77
93
|
return deploymentRecipeFromJson(data);
|
|
78
94
|
}
|
|
79
|
-
exports.readDeploymentMigrationFile = readDeploymentMigrationFile;
|
|
80
95
|
function getFormattedMigrationDate() {
|
|
81
96
|
const now = new Date();
|
|
82
97
|
const year = now.getFullYear();
|
|
@@ -87,12 +102,10 @@ function getFormattedMigrationDate() {
|
|
|
87
102
|
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
88
103
|
return `${year}-${month}-${day}-${hours}${minutes}${seconds}`;
|
|
89
104
|
}
|
|
90
|
-
exports.getFormattedMigrationDate = getFormattedMigrationDate;
|
|
91
105
|
function getMigrationFolderPath(scriptName, network) {
|
|
92
106
|
const contractsPath = (0, util_1.getContractsPath)(network);
|
|
93
107
|
return path_1.default.resolve(contractsPath, `${scriptName}/migrations`);
|
|
94
108
|
}
|
|
95
|
-
exports.getMigrationFolderPath = getMigrationFolderPath;
|
|
96
109
|
function getNewestMigrationFile(folderPath) {
|
|
97
110
|
if (!fs_1.default.existsSync(folderPath) || !fs_1.default.lstatSync(folderPath).isDirectory()) {
|
|
98
111
|
return null;
|
|
@@ -109,7 +122,6 @@ function getNewestMigrationFile(folderPath) {
|
|
|
109
122
|
// Return the full path of the newest file (last in sorted array) or undefined if no files
|
|
110
123
|
return files.length > 0 ? path_1.default.join(folderPath, files[files.length - 1]) : null;
|
|
111
124
|
}
|
|
112
|
-
exports.getNewestMigrationFile = getNewestMigrationFile;
|
|
113
125
|
function deploymentRecipeToJson(recipe) {
|
|
114
126
|
return {
|
|
115
127
|
cell_recipes: recipe.cellRecipes.map((val) => {
|
|
@@ -141,7 +153,6 @@ function deploymentRecipeToJson(recipe) {
|
|
|
141
153
|
}),
|
|
142
154
|
};
|
|
143
155
|
}
|
|
144
|
-
exports.deploymentRecipeToJson = deploymentRecipeToJson;
|
|
145
156
|
function deploymentRecipeFromJson(json) {
|
|
146
157
|
return {
|
|
147
158
|
cellRecipes: json.cell_recipes.map((val) => {
|
|
@@ -165,4 +176,3 @@ function deploymentRecipeFromJson(json) {
|
|
|
165
176
|
}),
|
|
166
177
|
};
|
|
167
178
|
}
|
|
168
|
-
exports.deploymentRecipeFromJson = deploymentRecipeFromJson;
|
package/dist/deploy/toml.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.generateDeploymentToml = generateDeploymentToml;
|
|
7
|
+
exports.readDeploymentToml = readDeploymentToml;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const toml_1 = __importDefault(require("@iarna/toml"));
|
|
9
10
|
const path_1 = require("path");
|
|
@@ -35,7 +36,6 @@ function generateDeploymentToml(options, network) {
|
|
|
35
36
|
console.log(`${options.name} deployment.toml file ${outputFilePath} generated successfully.`);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
exports.generateDeploymentToml = generateDeploymentToml;
|
|
39
39
|
function readDeploymentToml(scriptName, network) {
|
|
40
40
|
const filePath = `${(0, util_1.getContractsPath)(network)}/${scriptName}/deployment.toml`;
|
|
41
41
|
const file = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
@@ -57,4 +57,3 @@ function readDeploymentToml(scriptName, network) {
|
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
exports.readDeploymentToml = readDeploymentToml;
|
package/dist/deploy/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getContractsPath =
|
|
3
|
+
exports.getContractsPath = getContractsPath;
|
|
4
4
|
const setting_1 = require("../cfg/setting");
|
|
5
5
|
const base_1 = require("../type/base");
|
|
6
6
|
function getContractsPath(network) {
|
|
@@ -16,4 +16,3 @@ function getContractsPath(network) {
|
|
|
16
16
|
}
|
|
17
17
|
throw new Error(`invalid network ${network}`);
|
|
18
18
|
}
|
|
19
|
-
exports.getContractsPath = getContractsPath;
|
package/dist/molecule/mol.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,7 +45,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
48
|
+
exports.BindingLanguage = void 0;
|
|
49
|
+
exports.generateMolBindings = generateMolBindings;
|
|
50
|
+
exports.installMolToolsIfNeeded = installMolToolsIfNeeded;
|
|
39
51
|
const child_process_1 = require("child_process");
|
|
40
52
|
const moleculec_es_1 = require("../tools/moleculec-es");
|
|
41
53
|
const moleculec_rust_1 = require("../tools/moleculec-rust");
|
|
@@ -121,7 +133,6 @@ function generateMolBindings(schemeFilePath, outputFilePath, bindingLanguage) {
|
|
|
121
133
|
throw new Error(`Unsupported binding language: ${bindingLanguage}`);
|
|
122
134
|
});
|
|
123
135
|
}
|
|
124
|
-
exports.generateMolBindings = generateMolBindings;
|
|
125
136
|
function installMolToolsIfNeeded() {
|
|
126
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
138
|
if (!moleculec_es_1.MoleculecES.isBinaryInstalled()) {
|
|
@@ -136,4 +147,3 @@ function installMolToolsIfNeeded() {
|
|
|
136
147
|
}
|
|
137
148
|
});
|
|
138
149
|
}
|
|
139
|
-
exports.installMolToolsIfNeeded = installMolToolsIfNeeded;
|
package/dist/node/init-chain.js
CHANGED
|
@@ -12,7 +12,7 @@ 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.initChainIfNeeded =
|
|
15
|
+
exports.initChainIfNeeded = initChainIfNeeded;
|
|
16
16
|
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const fs_2 = require("../util/fs");
|
|
@@ -38,4 +38,3 @@ function initChainIfNeeded() {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
exports.initChainIfNeeded = initChainIfNeeded;
|
package/dist/node/install.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,7 +45,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
48
|
+
exports.installCKBBinary = installCKBBinary;
|
|
49
|
+
exports.downloadCKBBinaryAndUnzip = downloadCKBBinaryAndUnzip;
|
|
50
|
+
exports.downloadAndSaveCKBBinary = downloadAndSaveCKBBinary;
|
|
51
|
+
exports.unZipFile = unZipFile;
|
|
52
|
+
exports.decompressTarGzAsync = decompressTarGzAsync;
|
|
53
|
+
exports.getVersionFromBinary = getVersionFromBinary;
|
|
54
|
+
exports.buildDownloadUrl = buildDownloadUrl;
|
|
39
55
|
const child_process_1 = require("child_process");
|
|
40
56
|
const fs = __importStar(require("fs"));
|
|
41
57
|
const path = __importStar(require("path"));
|
|
@@ -65,7 +81,6 @@ function installCKBBinary(version) {
|
|
|
65
81
|
yield downloadCKBBinaryAndUnzip(version);
|
|
66
82
|
});
|
|
67
83
|
}
|
|
68
|
-
exports.installCKBBinary = installCKBBinary;
|
|
69
84
|
function downloadCKBBinaryAndUnzip(version) {
|
|
70
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
86
|
const ckbPackageName = buildCKBGithubReleasePackageName(version);
|
|
@@ -92,7 +107,6 @@ function downloadCKBBinaryAndUnzip(version) {
|
|
|
92
107
|
}
|
|
93
108
|
});
|
|
94
109
|
}
|
|
95
|
-
exports.downloadCKBBinaryAndUnzip = downloadCKBBinaryAndUnzip;
|
|
96
110
|
function downloadAndSaveCKBBinary(version, tempFilePath) {
|
|
97
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
112
|
const downloadURL = buildDownloadUrl(version);
|
|
@@ -102,9 +116,8 @@ function downloadAndSaveCKBBinary(version, tempFilePath) {
|
|
|
102
116
|
fs.writeFileSync(tempFilePath, Buffer.from(arrayBuffer));
|
|
103
117
|
});
|
|
104
118
|
}
|
|
105
|
-
|
|
106
|
-
function
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
function unZipFile(filePath_1, extractDir_1) {
|
|
120
|
+
return __awaiter(this, arguments, void 0, function* (filePath, extractDir, useTar = false) {
|
|
108
121
|
// Ensure the destination directory exists, if not create it
|
|
109
122
|
if (!fs.existsSync(extractDir)) {
|
|
110
123
|
fs.mkdirSync(extractDir, { recursive: true });
|
|
@@ -116,7 +129,6 @@ function unZipFile(filePath, extractDir, useTar = false) {
|
|
|
116
129
|
zip.extractAllTo(extractDir, true);
|
|
117
130
|
});
|
|
118
131
|
}
|
|
119
|
-
exports.unZipFile = unZipFile;
|
|
120
132
|
function decompressTarGzAsync(tarballPath, destinationDir) {
|
|
121
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
134
|
return new Promise((resolve, reject) => {
|
|
@@ -138,13 +150,12 @@ function decompressTarGzAsync(tarballPath, destinationDir) {
|
|
|
138
150
|
});
|
|
139
151
|
});
|
|
140
152
|
}
|
|
141
|
-
exports.decompressTarGzAsync = decompressTarGzAsync;
|
|
142
153
|
function getVersionFromBinary(binPath) {
|
|
143
154
|
try {
|
|
144
155
|
const versionOutput = (0, child_process_1.execSync)(`${(0, encoding_1.encodeBinPathForTerminal)(binPath)} --version`, {
|
|
145
156
|
encoding: 'utf-8',
|
|
146
157
|
});
|
|
147
|
-
const versionMatch = versionOutput.match(/(\d+\.\d+\.\d+)/);
|
|
158
|
+
const versionMatch = versionOutput.match(/(\d+\.\d+\.\d+(-rc\d+)?)/);
|
|
148
159
|
if (versionMatch) {
|
|
149
160
|
return versionMatch[0];
|
|
150
161
|
}
|
|
@@ -154,7 +165,6 @@ function getVersionFromBinary(binPath) {
|
|
|
154
165
|
return null;
|
|
155
166
|
}
|
|
156
167
|
}
|
|
157
|
-
exports.getVersionFromBinary = getVersionFromBinary;
|
|
158
168
|
function getOS() {
|
|
159
169
|
const platform = os_1.default.platform();
|
|
160
170
|
if (platform === 'darwin') {
|
|
@@ -223,4 +233,3 @@ function buildDownloadUrl(version, opt = {}) {
|
|
|
223
233
|
const fullPackageName = buildCKBGithubReleasePackageNameWithExtension(version, opt);
|
|
224
234
|
return `https://github.com/nervosnetwork/ckb/releases/download/v${version}/${fullPackageName}`;
|
|
225
235
|
}
|
|
226
|
-
exports.buildDownloadUrl = buildDownloadUrl;
|
package/dist/scripts/gen.js
CHANGED
|
@@ -15,18 +15,31 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.genSystemScripts = genSystemScripts;
|
|
40
|
+
exports.genSystemScriptsJsonFile = genSystemScriptsJsonFile;
|
|
41
|
+
exports.genMyScripts = genMyScripts;
|
|
42
|
+
exports.genMyScriptsJsonFile = genMyScriptsJsonFile;
|
|
30
43
|
const fs = __importStar(require("fs"));
|
|
31
44
|
const public_1 = __importDefault(require("./public"));
|
|
32
45
|
const system_scripts_1 = require("../cmd/system-scripts");
|
|
@@ -45,13 +58,11 @@ function genSystemScripts() {
|
|
|
45
58
|
}
|
|
46
59
|
return null;
|
|
47
60
|
}
|
|
48
|
-
exports.genSystemScripts = genSystemScripts;
|
|
49
61
|
function genSystemScriptsJsonFile(filePath) {
|
|
50
62
|
const scripts = genSystemScripts();
|
|
51
63
|
fs.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
|
|
52
64
|
fs.writeFileSync(filePath, JSON.stringify(scripts, null, 2));
|
|
53
65
|
}
|
|
54
|
-
exports.genSystemScriptsJsonFile = genSystemScriptsJsonFile;
|
|
55
66
|
function genMyScripts() {
|
|
56
67
|
const networkMyScripts = {
|
|
57
68
|
devnet: (0, util_1.readUserDeployedScriptsInfo)(base_1.Network.devnet),
|
|
@@ -60,10 +71,8 @@ function genMyScripts() {
|
|
|
60
71
|
};
|
|
61
72
|
return networkMyScripts;
|
|
62
73
|
}
|
|
63
|
-
exports.genMyScripts = genMyScripts;
|
|
64
74
|
function genMyScriptsJsonFile(filePath) {
|
|
65
75
|
const scripts = genMyScripts();
|
|
66
76
|
fs.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
|
|
67
77
|
fs.writeFileSync(filePath, JSON.stringify(scripts, null, 2));
|
|
68
78
|
}
|
|
69
|
-
exports.genMyScriptsJsonFile = genMyScriptsJsonFile;
|
package/dist/scripts/private.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildCCCDevnetKnownScripts =
|
|
3
|
+
exports.buildCCCDevnetKnownScripts = buildCCCDevnetKnownScripts;
|
|
4
4
|
//todo: extract getSystemScriptsFromListHashes/toCCCKnownScripts from cmd folder
|
|
5
5
|
const system_scripts_1 = require("../cmd/system-scripts");
|
|
6
6
|
function buildCCCDevnetKnownScripts() {
|
|
@@ -11,4 +11,3 @@ function buildCCCDevnetKnownScripts() {
|
|
|
11
11
|
const devnetKnownScripts = (0, system_scripts_1.toCCCKnownScripts)(devnetSystemScripts);
|
|
12
12
|
return devnetKnownScripts;
|
|
13
13
|
}
|
|
14
|
-
exports.buildCCCDevnetKnownScripts = buildCCCDevnetKnownScripts;
|
package/dist/scripts/util.js
CHANGED
|
@@ -15,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.readUserDeployedScriptsInfo =
|
|
36
|
+
exports.readUserDeployedScriptsInfo = readUserDeployedScriptsInfo;
|
|
27
37
|
const fs = __importStar(require("fs"));
|
|
28
38
|
const util_1 = require("../deploy/util");
|
|
29
39
|
const migration_1 = require("../deploy/migration");
|
|
@@ -81,4 +91,3 @@ function readUserDeployedScriptsInfo(network) {
|
|
|
81
91
|
}
|
|
82
92
|
return deployedScriptsInfo;
|
|
83
93
|
}
|
|
84
|
-
exports.readUserDeployedScriptsInfo = readUserDeployedScriptsInfo;
|
package/dist/sdk/ckb.js
CHANGED
|
@@ -63,8 +63,8 @@ class CKB {
|
|
|
63
63
|
return address.toString();
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
waitForTxConfirm(
|
|
67
|
-
return __awaiter(this,
|
|
66
|
+
waitForTxConfirm(txHash_1) {
|
|
67
|
+
return __awaiter(this, arguments, void 0, function* (txHash, timeout = 60000) {
|
|
68
68
|
const query = () => __awaiter(this, void 0, void 0, function* () {
|
|
69
69
|
const res = yield this.client.getTransactionNoCache(txHash);
|
|
70
70
|
if (res && res.status === 'committed') {
|
|
@@ -104,8 +104,8 @@ class CKB {
|
|
|
104
104
|
return balanceInCKB;
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
transfer(
|
|
108
|
-
return __awaiter(this,
|
|
107
|
+
transfer(_a) {
|
|
108
|
+
return __awaiter(this, arguments, void 0, function* ({ privateKey, toAddress, amountInCKB }) {
|
|
109
109
|
const signer = this.buildSigner(privateKey);
|
|
110
110
|
const to = yield core_1.ccc.Address.fromString(toAddress, this.client);
|
|
111
111
|
const tx = core_1.ccc.Transaction.from({
|
|
@@ -122,8 +122,8 @@ class CKB {
|
|
|
122
122
|
return txHash;
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
transferAll(
|
|
126
|
-
return __awaiter(this,
|
|
125
|
+
transferAll(_a) {
|
|
126
|
+
return __awaiter(this, arguments, void 0, function* ({ privateKey, toAddress }) {
|
|
127
127
|
const signer = this.buildSigner(privateKey);
|
|
128
128
|
const to = yield core_1.ccc.Address.fromString(toAddress, this.client);
|
|
129
129
|
const balanceInCKB = yield this.balance((yield signer.getRecommendedAddressObj()).toString());
|
|
@@ -184,8 +184,8 @@ class CKB {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
upgradeTypeIdScript(scriptName, newScriptBinBytes, privateKey) {
|
|
187
|
-
var _a;
|
|
188
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
var _a;
|
|
189
189
|
const deploymentReceipt = migration_1.Migration.find(scriptName, this.network);
|
|
190
190
|
if (deploymentReceipt == null)
|
|
191
191
|
throw new Error("no migration file, can't be updated.");
|