@offckb/cli 0.3.3 → 0.3.5

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.
Files changed (53) hide show
  1. package/README.md +15 -0
  2. package/dist/cfg/env-path.js +1 -1
  3. package/dist/cfg/setting.d.ts +3 -0
  4. package/dist/cfg/setting.js +26 -13
  5. package/dist/cli.js +21 -7
  6. package/dist/cmd/accounts.js +1 -2
  7. package/dist/cmd/balance.js +3 -4
  8. package/dist/cmd/clean.js +1 -2
  9. package/dist/cmd/config.js +2 -2
  10. package/dist/cmd/create.d.ts +11 -3
  11. package/dist/cmd/create.js +30 -4
  12. package/dist/cmd/debug.d.ts +1 -1
  13. package/dist/cmd/debug.js +9 -10
  14. package/dist/cmd/deploy.js +24 -7
  15. package/dist/cmd/deposit.js +3 -4
  16. package/dist/cmd/inject-config.js +20 -10
  17. package/dist/cmd/list-hashes.js +2 -3
  18. package/dist/cmd/mol.js +2 -3
  19. package/dist/cmd/my-scripts.js +1 -2
  20. package/dist/cmd/node.js +9 -10
  21. package/dist/cmd/proxy-rpc.js +1 -2
  22. package/dist/cmd/repl.js +5 -6
  23. package/dist/cmd/sync-scripts.js +1 -2
  24. package/dist/cmd/system-scripts.js +11 -11
  25. package/dist/cmd/transfer-all.js +3 -4
  26. package/dist/cmd/transfer.js +3 -4
  27. package/dist/deploy/index.js +6 -6
  28. package/dist/deploy/migration.js +25 -15
  29. package/dist/deploy/toml.js +2 -3
  30. package/dist/deploy/util.js +1 -2
  31. package/dist/molecule/mol.js +20 -10
  32. package/dist/node/init-chain.js +1 -2
  33. package/dist/node/install.js +26 -17
  34. package/dist/scripts/gen.js +21 -12
  35. package/dist/scripts/private.js +1 -2
  36. package/dist/scripts/util.js +18 -9
  37. package/dist/sdk/ckb.js +7 -7
  38. package/dist/template/offckb-config.js +17 -7
  39. package/dist/template/option.js +10 -4
  40. package/dist/tools/ckb-debugger.d.ts +1 -0
  41. package/dist/tools/ckb-debugger.js +15 -0
  42. package/dist/tools/ckb-tx-dumper.js +1 -2
  43. package/dist/tools/rpc-proxy.d.ts +0 -1
  44. package/dist/tools/rpc-proxy.js +1 -2
  45. package/dist/util/encoding.js +2 -3
  46. package/dist/util/fs.d.ts +1 -0
  47. package/dist/util/fs.js +34 -20
  48. package/dist/util/git.js +19 -10
  49. package/dist/util/link.js +1 -2
  50. package/dist/util/request.js +2 -2
  51. package/dist/util/validator.js +5 -6
  52. package/npm-shrinkwrap.json +4514 -0
  53. package/package.json +6 -4
package/dist/cmd/node.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.node = void 0;
12
+ exports.node = node;
13
13
  const child_process_1 = require("child_process");
14
14
  const init_chain_1 = require("../node/init-chain");
15
15
  const install_1 = require("../node/install");
@@ -17,9 +17,9 @@ const setting_1 = require("../cfg/setting");
17
17
  const encoding_1 = require("../util/encoding");
18
18
  const rpc_proxy_1 = require("../tools/rpc-proxy");
19
19
  const base_1 = require("../type/base");
20
- function node({ version, noProxyServer }) {
21
- var _a, _b;
22
- return __awaiter(this, void 0, void 0, function* () {
20
+ function node(_a) {
21
+ return __awaiter(this, arguments, void 0, function* ({ version, noProxyServer }) {
22
+ var _b, _c;
23
23
  const settings = (0, setting_1.readSettings)();
24
24
  const ckbVersion = version || settings.bins.defaultCKBVersion;
25
25
  yield (0, install_1.installCKBBinary)(ckbVersion);
@@ -32,22 +32,22 @@ function node({ version, noProxyServer }) {
32
32
  // Run first command
33
33
  const ckbProcess = (0, child_process_1.exec)(ckbCmd);
34
34
  // Log first command's output
35
- (_a = ckbProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
35
+ (_b = ckbProcess.stdout) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
36
36
  console.log('CKB:', data.toString());
37
37
  });
38
- (_b = ckbProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
38
+ (_c = ckbProcess.stderr) === null || _c === void 0 ? void 0 : _c.on('data', (data) => {
39
39
  console.error('CKB error:', data.toString());
40
40
  });
41
41
  // Start the second command after 3 seconds
42
42
  setTimeout(() => __awaiter(this, void 0, void 0, function* () {
43
- var _c, _d;
43
+ var _a, _b;
44
44
  try {
45
45
  // Run second command
46
46
  const minerProcess = (0, child_process_1.exec)(minerCmd);
47
- (_c = minerProcess.stdout) === null || _c === void 0 ? void 0 : _c.on('data', (data) => {
47
+ (_a = minerProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
48
48
  console.log('CKB-Miner:', data.toString());
49
49
  });
50
- (_d = minerProcess.stderr) === null || _d === void 0 ? void 0 : _d.on('data', (data) => {
50
+ (_b = minerProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
51
51
  console.error('CKB-Miner error:', data.toString());
52
52
  });
53
53
  console.log('noProxyServer: ', noProxyServer);
@@ -68,4 +68,3 @@ function node({ version, noProxyServer }) {
68
68
  }
69
69
  });
70
70
  }
71
- exports.node = node;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.proxyRpc = void 0;
3
+ exports.proxyRpc = proxyRpc;
4
4
  const setting_1 = require("../cfg/setting");
5
5
  const rpc_proxy_1 = require("../tools/rpc-proxy");
6
6
  const base_1 = require("../type/base");
@@ -20,4 +20,3 @@ function proxyRpc(options) {
20
20
  const proxy = (0, rpc_proxy_1.createRPCProxy)(network, ckbRpc, port);
21
21
  proxy.start();
22
22
  }
23
- exports.proxyRpc = proxyRpc;
package/dist/cmd/repl.js CHANGED
@@ -3,7 +3,11 @@ 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.buildMyScripts = exports.buildSystemScripts = exports.printHelpText = exports.initGlobalClientBuilder = exports.repl = void 0;
6
+ exports.repl = repl;
7
+ exports.initGlobalClientBuilder = initGlobalClientBuilder;
8
+ exports.printHelpText = printHelpText;
9
+ exports.buildSystemScripts = buildSystemScripts;
10
+ exports.buildMyScripts = buildMyScripts;
7
11
  const repl_1 = require("repl");
8
12
  const core_1 = require("@ckb-ccc/core");
9
13
  const advanced_1 = require("@ckb-ccc/core/advanced");
@@ -34,7 +38,6 @@ function repl({ network = base_1.Network.devnet, proxyRpc = false }) {
34
38
  context.systemScripts = buildSystemScripts().new(network);
35
39
  context.help = printHelpText;
36
40
  }
37
- exports.repl = repl;
38
41
  function initGlobalClientBuilder(proxyRpc) {
39
42
  return {
40
43
  new: (network) => {
@@ -69,7 +72,6 @@ function initGlobalClientBuilder(proxyRpc) {
69
72
  },
70
73
  };
71
74
  }
72
- exports.initGlobalClientBuilder = initGlobalClientBuilder;
73
75
  function printHelpText() {
74
76
  return console.log(`
75
77
  OffCKB Repl, a Nodejs REPL with CKB bundles.
@@ -88,7 +90,6 @@ Global Variables to use:
88
90
  - help, print this help message
89
91
  `);
90
92
  }
91
- exports.printHelpText = printHelpText;
92
93
  function buildSystemScripts() {
93
94
  return {
94
95
  new: (network) => {
@@ -101,7 +102,6 @@ function buildSystemScripts() {
101
102
  },
102
103
  };
103
104
  }
104
- exports.buildSystemScripts = buildSystemScripts;
105
105
  function buildMyScripts() {
106
106
  return {
107
107
  new: (network) => {
@@ -109,4 +109,3 @@ function buildMyScripts() {
109
109
  },
110
110
  };
111
111
  }
112
- exports.buildMyScripts = buildMyScripts;
@@ -3,7 +3,7 @@ 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.syncScripts = void 0;
6
+ exports.syncScripts = syncScripts;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const gen_1 = require("../scripts/gen");
9
9
  const offckb_config_1 = require("../template/offckb-config");
@@ -28,4 +28,3 @@ function syncScripts({ configPath }) {
28
28
  (0, gen_1.genMyScriptsJsonFile)(myScriptsJsonFilePath);
29
29
  console.log('scripts json config updated.');
30
30
  }
31
- exports.syncScripts = syncScripts;
@@ -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.toCCCKnownScripts = exports.toLumosConfig = exports.systemCellToScriptInfo = exports.getDevnetSystemScriptsFromListHashes = exports.printInCCCStyle = exports.printInLumosConfigStyle = exports.printInSystemStyle = exports.printSystemScripts = exports.PrintStyle = void 0;
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({ style = PrintStyle.system, network = base_1.Network.devnet }) {
29
- return __awaiter(this, void 0, void 0, function* () {
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;
@@ -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 = void 0;
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(toAddress, opt = { network: base_1.Network.devnet, proxyRpc: false }) {
18
- return __awaiter(this, void 0, void 0, function* () {
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;
@@ -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 = void 0;
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(toAddress, amountInCKB, opt = { network: base_1.Network.devnet, proxyRpc: false }) {
18
- return __awaiter(this, void 0, void 0, function* () {
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;
@@ -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.deployBinary = exports.deployBinaries = exports.recordDeployResult = exports.getToDeployBinsPath = void 0;
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(userOffCKBConfigPath, contractBinFolderValue);
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;
@@ -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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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.deploymentRecipeFromJson = exports.deploymentRecipeToJson = exports.getNewestMigrationFile = exports.getMigrationFolderPath = exports.getFormattedMigrationDate = exports.readDeploymentMigrationFile = exports.generateDeploymentMigrationFile = exports.Migration = void 0;
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;
@@ -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.readDeploymentToml = exports.generateDeploymentToml = void 0;
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;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContractsPath = void 0;
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;
@@ -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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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.installMolToolsIfNeeded = exports.generateMolBindings = exports.BindingLanguage = void 0;
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;
@@ -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 = void 0;
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;
@@ -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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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.buildDownloadUrl = exports.getVersionFromBinary = exports.decompressTarGzAsync = exports.unZipFile = exports.downloadAndSaveCKBBinary = exports.downloadCKBBinaryAndUnzip = exports.installCKBBinary = void 0;
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
- exports.downloadAndSaveCKBBinary = downloadAndSaveCKBBinary;
106
- function unZipFile(filePath, extractDir, useTar = false) {
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,7 +150,6 @@ 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`, {
@@ -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;