@offckb/cli 0.4.6-canary-d2d2df6.0 → 0.4.7-canary-dfe1b5f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/index.js +41 -3
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -209,7 +209,7 @@ exports.defaultSettings = {
209
209
  proxy: undefined,
210
210
  bins: {
211
211
  rootFolder: path.resolve(exports.dataPath, 'bins'),
212
- defaultCKBVersion: '0.201.0',
212
+ defaultCKBVersion: '0.205.0',
213
213
  downloadPath: path.resolve(exports.cachePath, 'download'),
214
214
  },
215
215
  devnet: {
@@ -774,6 +774,9 @@ const prompts_1 = __nccwpck_require__(55259);
774
774
  const gen_1 = __nccwpck_require__(750);
775
775
  const ckb_debugger_1 = __nccwpck_require__(14815);
776
776
  const logger_1 = __nccwpck_require__(65370);
777
+ const install_1 = __nccwpck_require__(65611);
778
+ const init_chain_1 = __nccwpck_require__(1360);
779
+ const setting_1 = __nccwpck_require__(25546);
777
780
  function createScriptProject(name_1) {
778
781
  return __awaiter(this, arguments, void 0, function* (name, options = {}) {
779
782
  logger_1.logger.info(['🚀 Creating CKB JavaScript VM project...', '']);
@@ -836,6 +839,9 @@ function createScriptProject(name_1) {
836
839
  // Add project path to context
837
840
  const contextWithPath = Object.assign(Object.assign({}, projectInfo), { projectPath: fullProjectPath });
838
841
  yield processor.generateProject(fullProjectPath, contextWithPath);
842
+ const _settings = (0, setting_1.readSettings)();
843
+ yield (0, install_1.installCKBBinary)(_settings.bins.defaultCKBVersion);
844
+ yield (0, init_chain_1.initChainIfNeeded)();
839
845
  // Generate system-scripts.json
840
846
  logger_1.logger.info('🔧 Generating system scripts configuration...');
841
847
  try {
@@ -3866,7 +3872,8 @@ class CKB {
3866
3872
  }
3867
3873
  }
3868
3874
  buildSigner(privateKey) {
3869
- const signer = new core_1.ccc.SignerCkbPrivateKey(this.client, privateKey);
3875
+ const normalizedKey = (0, validator_1.normalizePrivKey)(privateKey);
3876
+ const signer = new core_1.ccc.SignerCkbPrivateKey(this.client, normalizedKey);
3870
3877
  return signer;
3871
3878
  }
3872
3879
  buildSecp256k1Address(privateKey) {
@@ -7890,6 +7897,7 @@ exports.validateExecDappEnvironment = validateExecDappEnvironment;
7890
7897
  exports.isValidNetworkString = isValidNetworkString;
7891
7898
  exports.validateNetworkOpt = validateNetworkOpt;
7892
7899
  exports.isValidVersion = isValidVersion;
7900
+ exports.normalizePrivKey = normalizePrivKey;
7893
7901
  const path_1 = __importDefault(__nccwpck_require__(16928));
7894
7902
  const fs_1 = __importDefault(__nccwpck_require__(79896));
7895
7903
  const base_1 = __nccwpck_require__(69951);
@@ -7948,6 +7956,36 @@ function isValidVersion(version) {
7948
7956
  // Test the version against the regex
7949
7957
  return versionRegex.test(version);
7950
7958
  }
7959
+ function normalizePrivKey(privKey) {
7960
+ // Trim surrounding whitespaces
7961
+ let key = privKey ? privKey.trim() : '';
7962
+ if (!key) {
7963
+ throw new Error('Private key is required.');
7964
+ }
7965
+ // Strip surrounding quotes
7966
+ if (key.startsWith('"') && key.endsWith('"')) {
7967
+ key = key.slice(1, -1);
7968
+ }
7969
+ if (key.startsWith("'") && key.endsWith("'")) {
7970
+ key = key.slice(1, -1);
7971
+ }
7972
+ // Trim again to normalize whitespace that was inside surrounding quotes
7973
+ key = key.trim();
7974
+ // Remove standard 0x/0X prefix if it exists manually for normalization
7975
+ if (/^0x/i.test(key)) {
7976
+ key = key.slice(2);
7977
+ }
7978
+ // Validate only hex characters are left
7979
+ if (!/^[0-9a-fA-F]+$/.test(key)) {
7980
+ throw new Error('Invalid private key: contains non-hexadecimal characters.');
7981
+ }
7982
+ // Enforce exactly 32 bytes length
7983
+ if (key.length !== 64) {
7984
+ throw new Error(`Invalid private key length: expected 32 bytes (64 hex characters), but got ${key.length} characters (excluding 0x prefix).`);
7985
+ }
7986
+ // Return the formally strictly padded ckb format `0x` string
7987
+ return '0x' + key;
7988
+ }
7951
7989
 
7952
7990
 
7953
7991
  /***/ }),
@@ -147411,7 +147449,7 @@ module.exports = {"version":"3.17.0"};
147411
147449
  /***/ ((module) => {
147412
147450
 
147413
147451
  "use strict";
147414
- module.exports = /*#__PURE__*/JSON.parse('{"rE":"0.4.6-canary-d2d2df6.0","h_":"ckb development network for your first try"}');
147452
+ module.exports = /*#__PURE__*/JSON.parse('{"rE":"0.4.7-canary-dfe1b5f.0","h_":"ckb development network for your first try"}');
147415
147453
 
147416
147454
  /***/ })
147417
147455
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.4.6-canary-d2d2df6.0",
3
+ "version": "0.4.7-canary-dfe1b5f.0",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "CKB EcoFund",
6
6
  "license": "MIT",