@offckb/cli 0.4.0-canary-d31cb59.0 → 0.4.0-canary-81f2a49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -1355,27 +1355,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
1355
1355
  step((generator = generator.apply(thisArg, _arguments || [])).next());
1356
1356
  });
1357
1357
  };
1358
- var __importDefault = (this && this.__importDefault) || function (mod) {
1359
- return (mod && mod.__esModule) ? mod : { "default": mod };
1360
- };
1361
1358
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1362
1359
  exports.PrintStyle = void 0;
1363
1360
  exports.printSystemScripts = printSystemScripts;
1364
1361
  exports.printInSystemStyle = printInSystemStyle;
1365
1362
  exports.printInLumosConfigStyle = printInLumosConfigStyle;
1366
1363
  exports.printInCCCStyle = printInCCCStyle;
1367
- exports.getDevnetSystemScriptsFromListHashes = getDevnetSystemScriptsFromListHashes;
1368
1364
  exports.systemCellToScriptInfo = systemCellToScriptInfo;
1369
1365
  exports.toLumosConfig = toLumosConfig;
1370
- exports.toCCCKnownScripts = toCCCKnownScripts;
1371
- const setting_1 = __nccwpck_require__(25546);
1372
- const list_hashes_1 = __nccwpck_require__(31603);
1373
- const toml_1 = __importDefault(__nccwpck_require__(2811));
1374
- const core_1 = __nccwpck_require__(58906);
1375
1366
  const base_1 = __nccwpck_require__(69951);
1376
1367
  const public_1 = __nccwpck_require__(84535);
1377
1368
  const logger_1 = __nccwpck_require__(65370);
1378
- const const_1 = __nccwpck_require__(75587);
1369
+ const private_1 = __nccwpck_require__(5835);
1379
1370
  var PrintStyle;
1380
1371
  (function (PrintStyle) {
1381
1372
  PrintStyle["system"] = "system";
@@ -1388,7 +1379,7 @@ function printSystemScripts(_a) {
1388
1379
  ? public_1.MAINNET_SYSTEM_SCRIPTS
1389
1380
  : network === base_1.Network.testnet
1390
1381
  ? public_1.TESTNET_SYSTEM_SCRIPTS
1391
- : getDevnetSystemScriptsFromListHashes();
1382
+ : (0, private_1.getDevnetSystemScriptsFromListHashes)();
1392
1383
  if (!systemScripts)
1393
1384
  return logger_1.logger.info(`SystemScripts is null, ${network}`);
1394
1385
  if (style === PrintStyle.system) {
@@ -1421,56 +1412,10 @@ function printInLumosConfigStyle(scripts, network) {
1421
1412
  logger_1.logger.info(JSON.stringify(config, null, 2));
1422
1413
  }
1423
1414
  function printInCCCStyle(scripts, network) {
1424
- const knownsScripts = toCCCKnownScripts(scripts);
1415
+ const knownsScripts = (0, private_1.toCCCKnownScripts)(scripts);
1425
1416
  logger_1.logger.info(`*** CKB ${network.toUpperCase()} System Scripts As CCC KnownScripts ***\n`);
1426
1417
  logger_1.logger.info(JSON.stringify(knownsScripts, null, 2));
1427
1418
  }
1428
- function getDevnetSystemScriptsFromListHashes() {
1429
- var _a;
1430
- const settings = (0, setting_1.readSettings)();
1431
- const listHashesString = (0, list_hashes_1.getDevnetListHashes)(settings.bins.defaultCKBVersion);
1432
- if (!listHashesString) {
1433
- logger_1.logger.info(`list-hashes not found!`);
1434
- return null;
1435
- }
1436
- const listHashes = toml_1.default.parse(listHashesString);
1437
- const chainSpecHashes = Object.values(listHashes)[0];
1438
- if (chainSpecHashes == null) {
1439
- throw new Error(`invalid chain spec hashes file ${listHashesString}`);
1440
- }
1441
- const systemScriptArray = chainSpecHashes.system_cells
1442
- .map((cell) => {
1443
- var _a;
1444
- // Extract the file name
1445
- const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
1446
- const depGroupIndex = chainSpecHashes.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(`Bundled(specs/cells/${name})`));
1447
- const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
1448
- const depGroup = depGroupIndex === -1
1449
- ? undefined
1450
- : {
1451
- txHash: chainSpecHashes.dep_groups[depGroupIndex].tx_hash,
1452
- index: chainSpecHashes.dep_groups[depGroupIndex].index,
1453
- };
1454
- const scriptInfo = systemCellToScriptInfo({ cell, depType, depGroup });
1455
- return {
1456
- name,
1457
- file: cell.path,
1458
- script: scriptInfo,
1459
- };
1460
- })
1461
- .filter((s) => s.name != 'secp256k1_data');
1462
- const systemScripts = systemScriptArray.reduce((acc, item) => {
1463
- const key = item.name;
1464
- acc[key] = item;
1465
- return acc;
1466
- }, {});
1467
- // some special case fixes
1468
- // eg: omnilock also requires the deps of secp256k1-sigHashAll
1469
- (_a = systemScripts.omnilock) === null || _a === void 0 ? void 0 : _a.script.cellDeps.push(systemScripts.secp256k1_blake160_sighash_all.script.cellDeps[0]);
1470
- // add built-in type_id script
1471
- systemScripts.type_id = const_1.TYPE_ID_SCRIPT;
1472
- return systemScripts;
1473
- }
1474
1419
  function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }) {
1475
1420
  // todo: we left the type in cellDepsInfo since it requires async fetching and
1476
1421
  // chain running to get the full type script of the type-id deps.
@@ -1635,21 +1580,6 @@ function toLumosConfig(scripts, addressPrefix = 'ckt') {
1635
1580
  }
1636
1581
  return config;
1637
1582
  }
1638
- function toCCCKnownScripts(scripts) {
1639
- const DEVNET_SCRIPTS = {
1640
- [core_1.KnownScript.Secp256k1Blake160]: scripts.secp256k1_blake160_sighash_all.script,
1641
- [core_1.KnownScript.Secp256k1Multisig]: scripts.secp256k1_blake160_multisig_all.script,
1642
- [core_1.KnownScript.AnyoneCanPay]: scripts.anyone_can_pay.script,
1643
- [core_1.KnownScript.OmniLock]: scripts.omnilock.script,
1644
- [core_1.KnownScript.XUdt]: scripts.xudt.script,
1645
- [core_1.KnownScript.TypeId]: {
1646
- codeHash: '0x00000000000000000000000000000000000000000000000000545950455f4944',
1647
- hashType: 'type',
1648
- cellDeps: [],
1649
- },
1650
- };
1651
- return DEVNET_SCRIPTS;
1652
- }
1653
1583
 
1654
1584
 
1655
1585
  /***/ }),
@@ -2567,13 +2497,13 @@ exports.genMyScripts = genMyScripts;
2567
2497
  exports.genMyScriptsJsonFile = genMyScriptsJsonFile;
2568
2498
  const fs = __importStar(__nccwpck_require__(79896));
2569
2499
  const public_1 = __importDefault(__nccwpck_require__(84535));
2570
- const system_scripts_1 = __nccwpck_require__(86198);
2571
2500
  const path_1 = __importDefault(__nccwpck_require__(16928));
2572
2501
  const base_1 = __nccwpck_require__(69951);
2573
2502
  const util_1 = __nccwpck_require__(58642);
2574
2503
  const fs_1 = __nccwpck_require__(37293);
2504
+ const private_1 = __nccwpck_require__(5835);
2575
2505
  function genSystemScripts() {
2576
- const devnetScripts = (0, system_scripts_1.getDevnetSystemScriptsFromListHashes)();
2506
+ const devnetScripts = (0, private_1.getDevnetSystemScriptsFromListHashes)();
2577
2507
  if (devnetScripts != null) {
2578
2508
  const networkScripts = {
2579
2509
  devnet: devnetScripts,
@@ -2611,20 +2541,91 @@ function genMyScriptsJsonFile(filePath) {
2611
2541
  /***/ }),
2612
2542
 
2613
2543
  /***/ 5835:
2614
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2544
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
2615
2545
 
2616
2546
  "use strict";
2617
2547
 
2548
+ var __importDefault = (this && this.__importDefault) || function (mod) {
2549
+ return (mod && mod.__esModule) ? mod : { "default": mod };
2550
+ };
2618
2551
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2552
+ exports.getDevnetSystemScriptsFromListHashes = getDevnetSystemScriptsFromListHashes;
2553
+ exports.toCCCKnownScripts = toCCCKnownScripts;
2619
2554
  exports.buildCCCDevnetKnownScripts = buildCCCDevnetKnownScripts;
2620
- //todo: extract getSystemScriptsFromListHashes/toCCCKnownScripts from cmd folder
2555
+ const core_1 = __nccwpck_require__(58906);
2556
+ const setting_1 = __nccwpck_require__(25546);
2621
2557
  const system_scripts_1 = __nccwpck_require__(86198);
2558
+ const list_hashes_1 = __nccwpck_require__(31603);
2559
+ const logger_1 = __nccwpck_require__(65370);
2560
+ const const_1 = __nccwpck_require__(75587);
2561
+ const toml_1 = __importDefault(__nccwpck_require__(2811));
2562
+ function getDevnetSystemScriptsFromListHashes() {
2563
+ var _a;
2564
+ const settings = (0, setting_1.readSettings)();
2565
+ const listHashesString = (0, list_hashes_1.getDevnetListHashes)(settings.bins.defaultCKBVersion);
2566
+ if (!listHashesString) {
2567
+ logger_1.logger.info(`list-hashes not found!`);
2568
+ return null;
2569
+ }
2570
+ const listHashes = toml_1.default.parse(listHashesString);
2571
+ const chainSpecHashes = Object.values(listHashes)[0];
2572
+ if (chainSpecHashes == null) {
2573
+ throw new Error(`invalid chain spec hashes file ${listHashesString}`);
2574
+ }
2575
+ const systemScriptArray = chainSpecHashes.system_cells
2576
+ .map((cell) => {
2577
+ var _a;
2578
+ // Extract the file name
2579
+ const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
2580
+ const depGroupIndex = chainSpecHashes.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(cell.path));
2581
+ const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
2582
+ const depGroup = depGroupIndex === -1
2583
+ ? undefined
2584
+ : {
2585
+ txHash: chainSpecHashes.dep_groups[depGroupIndex].tx_hash,
2586
+ index: chainSpecHashes.dep_groups[depGroupIndex].index,
2587
+ };
2588
+ const scriptInfo = (0, system_scripts_1.systemCellToScriptInfo)({ cell, depType, depGroup });
2589
+ return {
2590
+ name,
2591
+ file: cell.path,
2592
+ script: scriptInfo,
2593
+ };
2594
+ })
2595
+ .filter((s) => s.name != 'secp256k1_data');
2596
+ const systemScripts = systemScriptArray.reduce((acc, item) => {
2597
+ const key = item.name;
2598
+ acc[key] = item;
2599
+ return acc;
2600
+ }, {});
2601
+ // some special case fixes
2602
+ // eg: omnilock also requires the deps of secp256k1-sigHashAll
2603
+ (_a = systemScripts.omnilock) === null || _a === void 0 ? void 0 : _a.script.cellDeps.push(systemScripts.secp256k1_blake160_sighash_all.script.cellDeps[0]);
2604
+ // add built-in type_id script
2605
+ systemScripts.type_id = const_1.TYPE_ID_SCRIPT;
2606
+ return systemScripts;
2607
+ }
2608
+ function toCCCKnownScripts(scripts) {
2609
+ const DEVNET_SCRIPTS = {
2610
+ [core_1.KnownScript.Secp256k1Blake160]: scripts.secp256k1_blake160_sighash_all.script,
2611
+ [core_1.KnownScript.Secp256k1Multisig]: scripts.secp256k1_blake160_multisig_all.script,
2612
+ [core_1.KnownScript.AnyoneCanPay]: scripts.anyone_can_pay.script,
2613
+ [core_1.KnownScript.OmniLock]: scripts.omnilock.script,
2614
+ [core_1.KnownScript.XUdt]: scripts.xudt.script,
2615
+ [core_1.KnownScript.TypeId]: {
2616
+ codeHash: '0x00000000000000000000000000000000000000000000000000545950455f4944',
2617
+ hashType: 'type',
2618
+ cellDeps: [],
2619
+ },
2620
+ };
2621
+ return DEVNET_SCRIPTS;
2622
+ }
2622
2623
  function buildCCCDevnetKnownScripts() {
2623
- const devnetSystemScripts = (0, system_scripts_1.getDevnetSystemScriptsFromListHashes)();
2624
+ const devnetSystemScripts = getDevnetSystemScriptsFromListHashes();
2624
2625
  if (devnetSystemScripts == null) {
2625
2626
  throw new Error('can not getSystemScriptsFromListHashes in devnet');
2626
2627
  }
2627
- const devnetKnownScripts = (0, system_scripts_1.toCCCKnownScripts)(devnetSystemScripts);
2628
+ const devnetKnownScripts = toCCCKnownScripts(devnetSystemScripts);
2628
2629
  return devnetKnownScripts;
2629
2630
  }
2630
2631
 
@@ -2813,6 +2814,26 @@ exports.TESTNET_SYSTEM_SCRIPTS = {
2813
2814
  },
2814
2815
  },
2815
2816
  type_id: const_1.TYPE_ID_SCRIPT,
2817
+ secp256k1_keccak256_sighash_all: undefined,
2818
+ secp256k1_keccak256_sighash_all_acpl: undefined,
2819
+ secp256k1_blake160_multisig_all_v2: {
2820
+ name: 'secp256k1_blake160_multisig_all_v2',
2821
+ script: {
2822
+ codeHash: '0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29',
2823
+ hashType: 'data1',
2824
+ cellDeps: [
2825
+ {
2826
+ cellDep: {
2827
+ outPoint: {
2828
+ txHash: '0x2eefdeb21f3a3edf697c28a52601b4419806ed60bb427420455cc29a090b26d5',
2829
+ index: 0,
2830
+ },
2831
+ depType: 'depGroup',
2832
+ },
2833
+ },
2834
+ ],
2835
+ },
2836
+ },
2816
2837
  };
2817
2838
  exports.MAINNET_SYSTEM_SCRIPTS = {
2818
2839
  secp256k1_blake160_sighash_all: {
@@ -2917,6 +2938,26 @@ exports.MAINNET_SYSTEM_SCRIPTS = {
2917
2938
  },
2918
2939
  },
2919
2940
  type_id: const_1.TYPE_ID_SCRIPT,
2941
+ secp256k1_keccak256_sighash_all: undefined,
2942
+ secp256k1_keccak256_sighash_all_acpl: undefined,
2943
+ secp256k1_blake160_multisig_all_v2: {
2944
+ name: 'secp256k1_blake160_multisig_all_v2',
2945
+ script: {
2946
+ codeHash: '0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29',
2947
+ hashType: 'data1',
2948
+ cellDeps: [
2949
+ {
2950
+ cellDep: {
2951
+ outPoint: {
2952
+ txHash: '0x6888aa39ab30c570c2c30d9d5684d3769bf77265a7973211a3c087fe8efbf738',
2953
+ index: 0,
2954
+ },
2955
+ depType: 'depGroup',
2956
+ },
2957
+ },
2958
+ ],
2959
+ },
2960
+ },
2920
2961
  };
2921
2962
  exports["default"] = {
2922
2963
  testnet: exports.TESTNET_SYSTEM_SCRIPTS,
@@ -4603,11 +4644,13 @@ function createRPCProxy(network, targetRpcUrl, port) {
4603
4644
  reqData += chunk;
4604
4645
  });
4605
4646
  req.on('end', () => {
4647
+ if (reqData.length === 0)
4648
+ return;
4606
4649
  try {
4607
4650
  const jsonRpcContent = JSON.parse(reqData);
4608
4651
  const method = jsonRpcContent.method;
4609
4652
  const params = jsonRpcContent.params;
4610
- logger_1.logger.debug('RPC Req: ', method);
4653
+ logger_1.logger.info('RPC Req: ', method);
4611
4654
  if (method === 'send_transaction') {
4612
4655
  const tx = params[0];
4613
4656
  // todo: record tx
@@ -4625,7 +4668,7 @@ function createRPCProxy(network, targetRpcUrl, port) {
4625
4668
  }
4626
4669
  }
4627
4670
  catch (err) {
4628
- logger_1.logger.error('Error parsing JSON-RPC content:', err);
4671
+ logger_1.logger.error('Error parsing JSON-RPC req content:', err.message);
4629
4672
  }
4630
4673
  });
4631
4674
  });
@@ -4636,6 +4679,8 @@ function createRPCProxy(network, targetRpcUrl, port) {
4636
4679
  });
4637
4680
  proxyRes.on('end', function () {
4638
4681
  const res = Buffer.concat(body).toString();
4682
+ if (res.length === 0)
4683
+ return;
4639
4684
  try {
4640
4685
  const jsonRpcResponse = JSON.parse(res);
4641
4686
  const error = jsonRpcResponse.error;
@@ -4644,7 +4689,7 @@ function createRPCProxy(network, targetRpcUrl, port) {
4644
4689
  }
4645
4690
  }
4646
4691
  catch (err) {
4647
- logger_1.logger.error('Error parsing JSON-RPC content:', err);
4692
+ logger_1.logger.error('Error parsing JSON-RPC res content:', err.message);
4648
4693
  }
4649
4694
  });
4650
4695
  });
@@ -70,6 +70,15 @@ create_type_id = true
70
70
  [[genesis.system_cells]]
71
71
  file = { file = "nostr_lock" }
72
72
  create_type_id = false
73
+ [[genesis.system_cells]]
74
+ file = { file = "pw-lock/secp256k1_keccak256_sighash_all" }
75
+ create_type_id = false
76
+ [[genesis.system_cells]]
77
+ file = { file = "pw-lock/secp256k1_keccak256_sighash_all_acpl" }
78
+ create_type_id = false
79
+ [[genesis.system_cells]]
80
+ file = { file = "secp256k1_blake160_multisig_all_v2" }
81
+ create_type_id = false
73
82
 
74
83
  [genesis.system_cells_lock]
75
84
  code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
@@ -89,6 +98,24 @@ files = [
89
98
  { bundled = "specs/cells/secp256k1_data" },
90
99
  { bundled = "specs/cells/secp256k1_blake160_multisig_all" },
91
100
  ]
101
+ [[genesis.dep_groups]]
102
+ name = "secp256k1_blake160_multisig_all_v2"
103
+ files = [
104
+ { bundled = "specs/cells/secp256k1_data" },
105
+ { file = "secp256k1_blake160_multisig_all_v2"},
106
+ ]
107
+ [[genesis.dep_groups]]
108
+ name = "secp256k1_keccak256_sighash_all"
109
+ files = [
110
+ { bundled = "specs/cells/secp256k1_data" },
111
+ { file = "pw-lock/secp256k1_keccak256_sighash_all"},
112
+ ]
113
+ [[genesis.dep_groups]]
114
+ name = "secp256k1_keccak256_sighash_all_acpl"
115
+ files = [
116
+ { bundled = "specs/cells/secp256k1_data" },
117
+ { file = "pw-lock/secp256k1_keccak256_sighash_all_acpl"},
118
+ ]
92
119
 
93
120
  # For first 11 block
94
121
  [genesis.bootstrap_lock]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.4.0-canary-d31cb59.0",
3
+ "version": "0.4.0-canary-81f2a49.0",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "CKB EcoFund",
6
6
  "license": "MIT",