@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
@@ -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 (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.genMyScriptsJsonFile = exports.genMyScripts = exports.genSystemScriptsJsonFile = exports.genSystemScripts = void 0;
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;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildCCCDevnetKnownScripts = void 0;
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;
@@ -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 (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
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.readUserDeployedScriptsInfo = void 0;
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(txHash, timeout = 60000) {
67
- return __awaiter(this, void 0, void 0, function* () {
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({ privateKey, toAddress, amountInCKB }) {
108
- return __awaiter(this, void 0, void 0, function* () {
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({ privateKey, toAddress }) {
126
- return __awaiter(this, void 0, void 0, function* () {
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.");
@@ -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 __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -1,16 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadBareTemplateOpts = void 0;
3
+ exports.loadBareTemplateOpts = loadBareTemplateOpts;
4
4
  const templates = [
5
5
  {
6
- name: 'Remix-Vite Bare Templates',
6
+ name: 'JS Script with Next.js fullstack template',
7
+ value: 'js-script-next-js',
8
+ description: 'A full-stack template with Next-js and ckb-js-vm script',
9
+ tag: ['next.js', 'tailwindcss', 'ckb-js-vm', 'typescript'],
10
+ author: 'retric@cryptape.com',
11
+ },
12
+ {
13
+ name: 'Rust Script with Remix-Vite fullstack template',
7
14
  value: 'remix-vite-template',
8
15
  description: 'A full-stack template with Remix-vite and ckb-script-templates',
9
16
  tag: ['remix', 'vite', 'tailwindcss', 'ckb-script-templates', 'typescript', 'rust'],
10
17
  author: 'retric@cryptape.com',
11
18
  },
12
19
  {
13
- name: 'Next.js Bare Templates',
20
+ name: 'Rust Script with Next.js fullstack template',
14
21
  value: 'next-js-template',
15
22
  description: 'A full-stack template with Next.js framework and ckb-script-templates',
16
23
  tag: ['next.js', 'tailwindcss', 'ckb-script-templates', 'typescript', 'rust'],
@@ -20,4 +27,3 @@ const templates = [
20
27
  function loadBareTemplateOpts() {
21
28
  return templates;
22
29
  }
23
- exports.loadBareTemplateOpts = loadBareTemplateOpts;
@@ -8,5 +8,6 @@ export declare class CKBDebugger {
8
8
  static runRaw(options: string): void;
9
9
  static runTxCellScript({ fullTxJsonFilePath, cellIndex, cellType, scriptGroupType }: DebugOption): void;
10
10
  static isBinaryInstalled(): boolean;
11
+ static isBinaryVersionValid(): boolean;
11
12
  static installCKBDebugger(): void;
12
13
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CKBDebugger = void 0;
4
4
  const child_process_1 = require("child_process");
5
+ const setting_1 = require("../cfg/setting");
5
6
  class CKBDebugger {
6
7
  static runRaw(options) {
7
8
  const command = `ckb-debugger ${options}`;
@@ -15,6 +16,20 @@ class CKBDebugger {
15
16
  const result = (0, child_process_1.spawnSync)('ckb-debugger', ['--version'], { stdio: 'ignore' });
16
17
  return result.status === 0;
17
18
  }
19
+ static isBinaryVersionValid() {
20
+ const result = (0, child_process_1.spawnSync)('ckb-debugger', ['--version']);
21
+ if (result.status !== 0) {
22
+ console.error('ckb-debugger is not installed');
23
+ return false;
24
+ }
25
+ const version = result.stdout.toString().split(' ')[1];
26
+ const settings = (0, setting_1.readSettings)();
27
+ if (version < settings.tools.ckbDebugger.minVersion) {
28
+ console.error(`ckb-debugger version ${version} is less than ${settings.tools.ckbDebugger.minVersion}`);
29
+ return false;
30
+ }
31
+ return true;
32
+ }
18
33
  static installCKBDebugger() {
19
34
  const command = `cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger`;
20
35
  try {
@@ -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.dumpTransaction = void 0;
6
+ exports.dumpTransaction = dumpTransaction;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const child_process_1 = require("child_process");
9
9
  const setting_1 = require("../cfg/setting");
@@ -18,4 +18,3 @@ function dumpTransaction({ rpc, txJsonFilePath, outputFilePath }) {
18
18
  console.error('Command failed:', error.message);
19
19
  }
20
20
  }
21
- exports.dumpTransaction = dumpTransaction;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import http from 'http';
3
2
  import { Network } from '../type/base';
4
3
  export declare function createRPCProxy(network: Network, targetRpcUrl: string, port: number): {
@@ -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.createRPCProxy = void 0;
6
+ exports.createRPCProxy = createRPCProxy;
7
7
  const http_proxy_1 = __importDefault(require("http-proxy"));
8
8
  const http_1 = __importDefault(require("http"));
9
9
  const base_1 = require("../type/base");
@@ -88,4 +88,3 @@ function createRPCProxy(network, targetRpcUrl, port) {
88
88
  },
89
89
  };
90
90
  }
91
- exports.createRPCProxy = createRPCProxy;
@@ -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.encodeBinPathForTerminal = exports.setUTF8EncodingForWindows = void 0;
6
+ exports.setUTF8EncodingForWindows = setUTF8EncodingForWindows;
7
+ exports.encodeBinPathForTerminal = encodeBinPathForTerminal;
7
8
  const child_process_1 = require("child_process");
8
9
  const os_1 = __importDefault(require("os"));
9
10
  function setUTF8EncodingForWindows() {
@@ -16,10 +17,8 @@ function setUTF8EncodingForWindows() {
16
17
  }
17
18
  }
18
19
  }
19
- exports.setUTF8EncodingForWindows = setUTF8EncodingForWindows;
20
20
  function encodeBinPathForTerminal(path) {
21
21
  // some path contains space in the string
22
22
  // this fix the space in the terminal
23
23
  return `"${path}"`;
24
24
  }
25
- exports.encodeBinPathForTerminal = encodeBinPathForTerminal;
package/dist/util/fs.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare function readFileToUint8Array(filePath: string): Promise<Uint8Arr
7
7
  export declare function getBinaryFilesFromPath(fileOrFolderPath: string): string[];
8
8
  export declare function listBinaryFilesInFolder(folderPath: string): string[];
9
9
  export declare function isBinaryFile(filePath: string): boolean;
10
+ export declare function getBinaryFileSizeInBytes(filePath: string): number;
10
11
  export declare function isAbsolutePath(filePath: string): boolean;
11
12
  export declare function findFileInFolder(folderPath: string, fileName: string): string | null;
12
13
  export declare function getSubfolders(folderPath: string): string[];
package/dist/util/fs.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 (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) {
@@ -32,7 +42,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
42
  });
33
43
  };
34
44
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.getSubfolders = exports.findFileInFolder = exports.isAbsolutePath = exports.isBinaryFile = exports.listBinaryFilesInFolder = exports.getBinaryFilesFromPath = exports.readFileToUint8Array = exports.copyRecursive = exports.copyFilesWithExclusion = exports.copyFileSync = exports.copyFolderSync = exports.isFolderExists = void 0;
45
+ exports.isFolderExists = isFolderExists;
46
+ exports.copyFolderSync = copyFolderSync;
47
+ exports.copyFileSync = copyFileSync;
48
+ exports.copyFilesWithExclusion = copyFilesWithExclusion;
49
+ exports.copyRecursive = copyRecursive;
50
+ exports.readFileToUint8Array = readFileToUint8Array;
51
+ exports.getBinaryFilesFromPath = getBinaryFilesFromPath;
52
+ exports.listBinaryFilesInFolder = listBinaryFilesInFolder;
53
+ exports.isBinaryFile = isBinaryFile;
54
+ exports.getBinaryFileSizeInBytes = getBinaryFileSizeInBytes;
55
+ exports.isAbsolutePath = isAbsolutePath;
56
+ exports.findFileInFolder = findFileInFolder;
57
+ exports.getSubfolders = getSubfolders;
36
58
  const fs = __importStar(require("fs"));
37
59
  const path = __importStar(require("path"));
38
60
  function isFolderExists(folderPath) {
@@ -48,7 +70,6 @@ function isFolderExists(folderPath) {
48
70
  return false;
49
71
  }
50
72
  }
51
- exports.isFolderExists = isFolderExists;
52
73
  function copyFolderSync(source, destination) {
53
74
  if (!fs.existsSync(destination)) {
54
75
  fs.mkdirSync(destination, { recursive: true });
@@ -65,7 +86,6 @@ function copyFolderSync(source, destination) {
65
86
  }
66
87
  }
67
88
  }
68
- exports.copyFolderSync = copyFolderSync;
69
89
  function copyFileSync(source, target) {
70
90
  let targetFile = target;
71
91
  // If target is a directory, a new file with the same name will be created
@@ -76,7 +96,6 @@ function copyFileSync(source, target) {
76
96
  }
77
97
  fs.writeFileSync(targetFile, fs.readFileSync(source));
78
98
  }
79
- exports.copyFileSync = copyFileSync;
80
99
  function copyFilesWithExclusion(sourceDir, destinationDir, excludedFolders) {
81
100
  return __awaiter(this, void 0, void 0, function* () {
82
101
  try {
@@ -90,7 +109,6 @@ function copyFilesWithExclusion(sourceDir, destinationDir, excludedFolders) {
90
109
  }
91
110
  });
92
111
  }
93
- exports.copyFilesWithExclusion = copyFilesWithExclusion;
94
112
  // Function to recursively copy files and directories
95
113
  function copyRecursive(source, destination, excludedFolders) {
96
114
  return __awaiter(this, void 0, void 0, function* () {
@@ -120,7 +138,6 @@ function copyRecursive(source, destination, excludedFolders) {
120
138
  }
121
139
  });
122
140
  }
123
- exports.copyRecursive = copyRecursive;
124
141
  function readFileToUint8Array(filePath) {
125
142
  return __awaiter(this, void 0, void 0, function* () {
126
143
  return new Promise((resolve, reject) => {
@@ -134,7 +151,6 @@ function readFileToUint8Array(filePath) {
134
151
  });
135
152
  });
136
153
  }
137
- exports.readFileToUint8Array = readFileToUint8Array;
138
154
  function getBinaryFilesFromPath(fileOrFolderPath) {
139
155
  if (!fs.existsSync(fileOrFolderPath)) {
140
156
  throw new Error(`File or Folder not exits ${fileOrFolderPath}`);
@@ -148,7 +164,6 @@ function getBinaryFilesFromPath(fileOrFolderPath) {
148
164
  }
149
165
  throw new Error(`${fileOrFolderPath} is not a valid path to deploy scripts.`);
150
166
  }
151
- exports.getBinaryFilesFromPath = getBinaryFilesFromPath;
152
167
  function listBinaryFilesInFolder(folderPath) {
153
168
  // Check if the provided path is a directory
154
169
  if (!fs.existsSync(folderPath) || !fs.lstatSync(folderPath).isDirectory()) {
@@ -160,7 +175,6 @@ function listBinaryFilesInFolder(folderPath) {
160
175
  const binaryFiles = files.filter((file) => fs.statSync(file).isFile() && isBinaryFile(file));
161
176
  return binaryFiles;
162
177
  }
163
- exports.listBinaryFilesInFolder = listBinaryFilesInFolder;
164
178
  // Function to check if a file is binary
165
179
  function isBinaryFile(filePath) {
166
180
  const buffer = fs.readFileSync(filePath);
@@ -172,11 +186,13 @@ function isBinaryFile(filePath) {
172
186
  }
173
187
  return false;
174
188
  }
175
- exports.isBinaryFile = isBinaryFile;
189
+ function getBinaryFileSizeInBytes(filePath) {
190
+ const stats = fs.statSync(filePath);
191
+ return stats.size;
192
+ }
176
193
  function isAbsolutePath(filePath) {
177
194
  return path.isAbsolute(filePath);
178
195
  }
179
- exports.isAbsolutePath = isAbsolutePath;
180
196
  function findFileInFolder(folderPath, fileName) {
181
197
  const files = fs.readdirSync(folderPath);
182
198
  for (const file of files) {
@@ -194,11 +210,9 @@ function findFileInFolder(folderPath, fileName) {
194
210
  }
195
211
  return null;
196
212
  }
197
- exports.findFileInFolder = findFileInFolder;
198
213
  function getSubfolders(folderPath) {
199
214
  return fs.readdirSync(folderPath).filter((file) => {
200
215
  const fullPath = path.join(folderPath, file);
201
216
  return fs.statSync(fullPath).isDirectory();
202
217
  });
203
218
  }
204
- exports.getSubfolders = getSubfolders;
package/dist/util/git.js CHANGED
@@ -15,15 +15,26 @@ 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
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.gitCloneAndDownloadFolderSync = exports.isGitInstalled = void 0;
36
+ exports.isGitInstalled = isGitInstalled;
37
+ exports.gitCloneAndDownloadFolderSync = gitCloneAndDownloadFolderSync;
27
38
  const child_process_1 = require("child_process");
28
39
  const fs = __importStar(require("fs"));
29
40
  const path = __importStar(require("path"));
@@ -38,7 +49,6 @@ function isGitInstalled() {
38
49
  return false;
39
50
  }
40
51
  }
41
- exports.isGitInstalled = isGitInstalled;
42
52
  function gitCloneAndDownloadFolderSync(repoUrl, branch, subFolderName, targetPath) {
43
53
  console.log('start cloning the dapp template..');
44
54
  const settings = (0, setting_1.readSettings)();
@@ -94,4 +104,3 @@ function gitCloneAndDownloadFolderSync(repoUrl, branch, subFolderName, targetPat
94
104
  }
95
105
  console.log(`Folder ${subFolderName} downloaded successfully from ${repoUrl} and moved to ${targetPath}`);
96
106
  }
97
- exports.gitCloneAndDownloadFolderSync = gitCloneAndDownloadFolderSync;
package/dist/util/link.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildTestnetTxLink = void 0;
3
+ exports.buildTestnetTxLink = buildTestnetTxLink;
4
4
  function buildTestnetTxLink(txHash) {
5
5
  return `https://pudge.explorer.nervos.org/transaction/${txHash}`;
6
6
  }
7
- exports.buildTestnetTxLink = buildTestnetTxLink;
@@ -17,8 +17,8 @@ const setting_1 = require("../cfg/setting");
17
17
  const https_proxy_agent_1 = require("https-proxy-agent");
18
18
  const node_fetch_1 = __importDefault(require("node-fetch"));
19
19
  class Request {
20
- static send(url, options = {}) {
21
- return __awaiter(this, void 0, void 0, function* () {
20
+ static send(url_1) {
21
+ return __awaiter(this, arguments, void 0, function* (url, options = {}) {
22
22
  const agent = this.proxy ? new https_proxy_agent_1.HttpsProxyAgent(this.proxyConfigToUrl(this.proxy)) : undefined;
23
23
  const opt = Object.assign({ agent }, options);
24
24
  try {
@@ -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.isValidVersion = exports.validateNetworkOpt = exports.isValidNetworkString = exports.validateExecDappEnvironment = exports.validateTypescriptWorkspace = void 0;
6
+ exports.validateTypescriptWorkspace = validateTypescriptWorkspace;
7
+ exports.validateExecDappEnvironment = validateExecDappEnvironment;
8
+ exports.isValidNetworkString = isValidNetworkString;
9
+ exports.validateNetworkOpt = validateNetworkOpt;
10
+ exports.isValidVersion = isValidVersion;
7
11
  const path_1 = __importDefault(require("path"));
8
12
  const fs_1 = __importDefault(require("fs"));
9
13
  const base_1 = require("../type/base");
@@ -20,7 +24,6 @@ function validateTypescriptWorkspace() {
20
24
  throw new Error('tsconfig.json not found in the current directory');
21
25
  }
22
26
  }
23
- exports.validateTypescriptWorkspace = validateTypescriptWorkspace;
24
27
  function validateExecDappEnvironment() {
25
28
  const cwd = process.cwd();
26
29
  // Check if package.json and tsconfig.json exists
@@ -41,11 +44,9 @@ function validateExecDappEnvironment() {
41
44
  throw new Error('OffCKBConfig interface is not exported in offckb.config.ts');
42
45
  }
43
46
  }
44
- exports.validateExecDappEnvironment = validateExecDappEnvironment;
45
47
  function isValidNetworkString(network) {
46
48
  return ['devnet', 'testnet', 'mainnet'].includes(network);
47
49
  }
48
- exports.isValidNetworkString = isValidNetworkString;
49
50
  function validateNetworkOpt(network) {
50
51
  if (!isValidNetworkString(network)) {
51
52
  throw new Error('invalid network option, ' + network);
@@ -55,7 +56,6 @@ function validateNetworkOpt(network) {
55
56
  process.exit(1);
56
57
  }
57
58
  }
58
- exports.validateNetworkOpt = validateNetworkOpt;
59
59
  function isValidVersion(version) {
60
60
  if (typeof version !== 'string') {
61
61
  return false;
@@ -65,4 +65,3 @@ function isValidVersion(version) {
65
65
  // Test the version against the regex
66
66
  return versionRegex.test(version);
67
67
  }
68
- exports.isValidVersion = isValidVersion;