@ckb-ccc/lumos-patches 0.0.12-alpha.4 → 0.0.12

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/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # @ckb-ccc/lumos-patches
2
+
3
+ ## 0.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @ckb-ccc/core@0.0.12
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="https://ckbccc-demo.vercel.app/">
2
+ <a href="https://app.ckbccc.com/">
3
3
  <img alt="Logo" src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/logo.svg" width="20%" />
4
4
  </a>
5
5
  </p>
@@ -15,7 +15,7 @@
15
15
  <img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/ckb-ecofund/ccc" />
16
16
  <img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ckb-ecofund/ccc/master" />
17
17
  <img alt="GitHub deployments" src="https://img.shields.io/github/deployments/ckb-ecofund/ccc/production" />
18
- <a href="https://ckbccc-demo.vercel.app/"><img
18
+ <a href="https://app.ckbccc.com/"><img
19
19
  alt="Demo" src="https://img.shields.io/website?url=https%3A%2F%2Fckbccc-demo.vercel.app%2F&label=Demo"
20
20
  /></a>
21
21
  </p>
@@ -33,13 +33,13 @@
33
33
  ## Preview
34
34
 
35
35
  <p align="center">
36
- <a href="https://ckbccc-demo.vercel.app/">
36
+ <a href="https://app.ckbccc.com/">
37
37
  <img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/preview.png" width="30%" />
38
38
  </a>
39
39
  </p>
40
40
 
41
- This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://ckbccc-demo.vercel.app/). It showcases how to use CCC for some basic scenarios in CKB.
41
+ This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://app.ckbccc.com/). It showcases how to use CCC for some basic scenarios in CKB.
42
42
 
43
43
  <h3 align="center">
44
- Read more about CCC on its <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
44
+ Read more about CCC on <a href="https://docs.ckbccc.com">our website</a> or <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
45
45
  </h3>
package/dist/default.d.ts CHANGED
@@ -2,14 +2,16 @@ import { ccc } from "@ckb-ccc/core";
2
2
  import { LockScriptInfo } from "@ckb-lumos/common-scripts";
3
3
  /**
4
4
  * Generates custom lock script information.
5
- * @param {string} codeHash - The code hash of the custom script.
6
- * @param {CellDep[]} cellDeps - The cell dependencies for the custom script.
7
- * @returns {LockScriptInfo} The lock script information.
5
+ * @public
6
+ *
7
+ * @param codeHash - The code hash of the custom script.
8
+ * @param cellDeps - The cell dependencies for the custom script.
9
+ * @returns The lock script information.
8
10
  */
9
- export declare function generateScriptInfo(codeHash: string, cellDeps: ccc.CellDepInfoLike[]): LockScriptInfo;
11
+ export declare function generateScriptInfo(codeHash: string, cellDeps: ccc.CellDepInfoLike[], dummyLockLength: number): LockScriptInfo;
10
12
  /**
11
13
  * Generates default script information for CCC.
12
- * @returns {LockScriptInfo[]} An array of lock script information.
14
+ * @returns An array of lock script information.
13
15
  */
14
16
  export declare function generateDefaultScriptInfos(): LockScriptInfo[];
15
17
  //# sourceMappingURL=default.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAWpC,OAAO,EAEL,cAAc,EAEf,MAAM,2BAA2B,CAAC;AAqGnC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,CAAC,eAAe,EAAE,GAC9B,cAAc,CAyFhB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,cAAc,EAAE,CAc7D"}
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAWpC,OAAO,EAEL,cAAc,EAEf,MAAM,2BAA2B,CAAC;AAoGnC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,CAAC,eAAe,EAAE,EAC/B,eAAe,EAAE,MAAM,GACtB,cAAc,CAmGhB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,cAAc,EAAE,CAwB7D"}
package/dist/default.js CHANGED
@@ -21,22 +21,21 @@ function addCellDep(txSkeleton, newCellDep) {
21
21
  }
22
22
  /**
23
23
  * Generates a class for collecting custom script cells.
24
- * @param {string} codeHash - The code hash of the custom script.
25
- * @returns {typeof JoyIDCellCollector} The CustomCellCollector class.
24
+ * @param codeHash - The code hash of the custom script.
25
+ * @returns The CustomCellCollector class.
26
26
  */
27
27
  function generateCollectorClass(codeHash) {
28
28
  /**
29
29
  * Class representing a collector for custom script cells.
30
- * @class
31
30
  */
32
31
  return class CustomCellCollector {
33
32
  /**
34
33
  * Creates an instance of CustomCollector.
35
- * @param {FromInfo} fromInfo - The information about the address to collect cells from.
36
- * @param {CellProvider} cellProvider - The provider to collect cells from.
37
- * @param {Object} options - The options for the collector.
38
- * @param {QueryOptions} [options.queryOptions={}] - The query options for collecting cells.
39
- * @param {Config} [options.config=getConfig()] - The Lumos configuration.
34
+ * @param fromInfo - The information about the address to collect cells from.
35
+ * @param cellProvider - The provider to collect cells from.
36
+ * @param options - The options for the collector.
37
+ * @param] - The query options for collecting cells.
38
+ * @param [options.config=getConfig()] - The Lumos configuration.
40
39
  * @throws {Error} If cellProvider is not provided or fromInfo is not a string.
41
40
  */
42
41
  constructor(fromInfo, cellProvider, { queryOptions = {}, config = getConfig(), }) {
@@ -75,11 +74,13 @@ function generateCollectorClass(codeHash) {
75
74
  }
76
75
  /**
77
76
  * Generates custom lock script information.
78
- * @param {string} codeHash - The code hash of the custom script.
79
- * @param {CellDep[]} cellDeps - The cell dependencies for the custom script.
80
- * @returns {LockScriptInfo} The lock script information.
77
+ * @public
78
+ *
79
+ * @param codeHash - The code hash of the custom script.
80
+ * @param cellDeps - The cell dependencies for the custom script.
81
+ * @returns The lock script information.
81
82
  */
82
- export function generateScriptInfo(codeHash, cellDeps) {
83
+ export function generateScriptInfo(codeHash, cellDeps, dummyLockLength) {
83
84
  return {
84
85
  codeHash: codeHash,
85
86
  hashType: "type",
@@ -137,9 +138,11 @@ export function generateScriptInfo(codeHash, cellDeps) {
137
138
  .findIndex((input) => ccc.Script.from(input.cellOutput.lock).eq(ccc.Script.from(fromScript)));
138
139
  txSkeleton = txSkeleton.update("witnesses", (witnesses) => {
139
140
  if (witnesses.get(firstIndex)) {
140
- return witnesses;
141
+ witnesses = witnesses.merge(Array.from(new Array(firstIndex + 1 - witnesses.size), () => "0x"));
141
142
  }
142
- return witnesses.merge(Array.from(new Array(firstIndex + 1 - witnesses.size), () => "0x"));
143
+ return witnesses.set(firstIndex, ccc.hexFrom(ccc.WitnessArgs.from({
144
+ lock: Array.from(new Array(dummyLockLength), () => 0),
145
+ }).toBytes()));
143
146
  });
144
147
  return txSkeleton;
145
148
  },
@@ -148,19 +151,19 @@ export function generateScriptInfo(codeHash, cellDeps) {
148
151
  }
149
152
  /**
150
153
  * Generates default script information for CCC.
151
- * @returns {LockScriptInfo[]} An array of lock script information.
154
+ * @returns An array of lock script information.
152
155
  */
153
156
  export function generateDefaultScriptInfos() {
154
157
  const mainnet = cccA.MAINNET_SCRIPTS;
155
158
  const testnet = cccA.TESTNET_SCRIPTS;
156
159
  return [
157
- ccc.KnownScript.JoyId,
158
- ccc.KnownScript.NostrLock,
159
- ccc.KnownScript.PWLock,
160
+ [ccc.KnownScript.JoyId, 1000],
161
+ [ccc.KnownScript.NostrLock, 572],
162
+ [ccc.KnownScript.PWLock, 65],
160
163
  ]
161
- .map((script) => [
162
- generateScriptInfo(testnet[script].codeHash, testnet[script].cellDeps),
163
- generateScriptInfo(mainnet[script].codeHash, mainnet[script].cellDeps),
164
+ .map(([script, dummyLockLength]) => [
165
+ generateScriptInfo(testnet[script].codeHash, testnet[script].cellDeps, dummyLockLength),
166
+ generateScriptInfo(mainnet[script].codeHash, mainnet[script].cellDeps, dummyLockLength),
164
167
  ])
165
168
  .flat();
166
169
  }
package/dist/utils.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Asserts that a condition is true, throwing an error if it is not.
3
- * @param {unknown} condition - The condition to assert.
4
- * @param {string} [message="Assert failed"] - The error message to throw if the condition is false.
3
+ * @public
4
+ *
5
+ * @param condition - The condition to assert.
6
+ * @param [message="Assert failed"] - The error message to throw if the condition is false.
5
7
  * @throws {Error} If the condition is false.
6
8
  */
7
9
  export declare function asserts(condition: unknown, message?: string): asserts condition;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,OAAO,EAClB,OAAO,SAAkB,GACxB,OAAO,CAAC,SAAS,CAInB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,OAAO,EAClB,OAAO,SAAkB,GACxB,OAAO,CAAC,SAAS,CAInB"}
package/dist/utils.js CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Asserts that a condition is true, throwing an error if it is not.
3
- * @param {unknown} condition - The condition to assert.
4
- * @param {string} [message="Assert failed"] - The error message to throw if the condition is false.
3
+ * @public
4
+ *
5
+ * @param condition - The condition to assert.
6
+ * @param [message="Assert failed"] - The error message to throw if the condition is false.
5
7
  * @throws {Error} If the condition is false.
6
8
  */
7
9
  export function asserts(condition, message = "Assert failed") {
@@ -2,14 +2,16 @@ import { ccc } from "@ckb-ccc/core";
2
2
  import { LockScriptInfo } from "@ckb-lumos/common-scripts";
3
3
  /**
4
4
  * Generates custom lock script information.
5
- * @param {string} codeHash - The code hash of the custom script.
6
- * @param {CellDep[]} cellDeps - The cell dependencies for the custom script.
7
- * @returns {LockScriptInfo} The lock script information.
5
+ * @public
6
+ *
7
+ * @param codeHash - The code hash of the custom script.
8
+ * @param cellDeps - The cell dependencies for the custom script.
9
+ * @returns The lock script information.
8
10
  */
9
- export declare function generateScriptInfo(codeHash: string, cellDeps: ccc.CellDepInfoLike[]): LockScriptInfo;
11
+ export declare function generateScriptInfo(codeHash: string, cellDeps: ccc.CellDepInfoLike[], dummyLockLength: number): LockScriptInfo;
10
12
  /**
11
13
  * Generates default script information for CCC.
12
- * @returns {LockScriptInfo[]} An array of lock script information.
14
+ * @returns An array of lock script information.
13
15
  */
14
16
  export declare function generateDefaultScriptInfos(): LockScriptInfo[];
15
17
  //# sourceMappingURL=default.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAWpC,OAAO,EAEL,cAAc,EAEf,MAAM,2BAA2B,CAAC;AAqGnC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,CAAC,eAAe,EAAE,GAC9B,cAAc,CAyFhB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,cAAc,EAAE,CAc7D"}
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAWpC,OAAO,EAEL,cAAc,EAEf,MAAM,2BAA2B,CAAC;AAoGnC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,CAAC,eAAe,EAAE,EAC/B,eAAe,EAAE,MAAM,GACtB,cAAc,CAmGhB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,cAAc,EAAE,CAwB7D"}
@@ -24,22 +24,21 @@ function addCellDep(txSkeleton, newCellDep) {
24
24
  }
25
25
  /**
26
26
  * Generates a class for collecting custom script cells.
27
- * @param {string} codeHash - The code hash of the custom script.
28
- * @returns {typeof JoyIDCellCollector} The CustomCellCollector class.
27
+ * @param codeHash - The code hash of the custom script.
28
+ * @returns The CustomCellCollector class.
29
29
  */
30
30
  function generateCollectorClass(codeHash) {
31
31
  /**
32
32
  * Class representing a collector for custom script cells.
33
- * @class
34
33
  */
35
34
  return class CustomCellCollector {
36
35
  /**
37
36
  * Creates an instance of CustomCollector.
38
- * @param {FromInfo} fromInfo - The information about the address to collect cells from.
39
- * @param {CellProvider} cellProvider - The provider to collect cells from.
40
- * @param {Object} options - The options for the collector.
41
- * @param {QueryOptions} [options.queryOptions={}] - The query options for collecting cells.
42
- * @param {Config} [options.config=getConfig()] - The Lumos configuration.
37
+ * @param fromInfo - The information about the address to collect cells from.
38
+ * @param cellProvider - The provider to collect cells from.
39
+ * @param options - The options for the collector.
40
+ * @param] - The query options for collecting cells.
41
+ * @param [options.config=getConfig()] - The Lumos configuration.
43
42
  * @throws {Error} If cellProvider is not provided or fromInfo is not a string.
44
43
  */
45
44
  constructor(fromInfo, cellProvider, { queryOptions = {}, config = (0, config_manager_1.getConfig)(), }) {
@@ -78,11 +77,13 @@ function generateCollectorClass(codeHash) {
78
77
  }
79
78
  /**
80
79
  * Generates custom lock script information.
81
- * @param {string} codeHash - The code hash of the custom script.
82
- * @param {CellDep[]} cellDeps - The cell dependencies for the custom script.
83
- * @returns {LockScriptInfo} The lock script information.
80
+ * @public
81
+ *
82
+ * @param codeHash - The code hash of the custom script.
83
+ * @param cellDeps - The cell dependencies for the custom script.
84
+ * @returns The lock script information.
84
85
  */
85
- function generateScriptInfo(codeHash, cellDeps) {
86
+ function generateScriptInfo(codeHash, cellDeps, dummyLockLength) {
86
87
  return {
87
88
  codeHash: codeHash,
88
89
  hashType: "type",
@@ -140,9 +141,11 @@ function generateScriptInfo(codeHash, cellDeps) {
140
141
  .findIndex((input) => core_1.ccc.Script.from(input.cellOutput.lock).eq(core_1.ccc.Script.from(fromScript)));
141
142
  txSkeleton = txSkeleton.update("witnesses", (witnesses) => {
142
143
  if (witnesses.get(firstIndex)) {
143
- return witnesses;
144
+ witnesses = witnesses.merge(Array.from(new Array(firstIndex + 1 - witnesses.size), () => "0x"));
144
145
  }
145
- return witnesses.merge(Array.from(new Array(firstIndex + 1 - witnesses.size), () => "0x"));
146
+ return witnesses.set(firstIndex, core_1.ccc.hexFrom(core_1.ccc.WitnessArgs.from({
147
+ lock: Array.from(new Array(dummyLockLength), () => 0),
148
+ }).toBytes()));
146
149
  });
147
150
  return txSkeleton;
148
151
  },
@@ -152,19 +155,19 @@ function generateScriptInfo(codeHash, cellDeps) {
152
155
  exports.generateScriptInfo = generateScriptInfo;
153
156
  /**
154
157
  * Generates default script information for CCC.
155
- * @returns {LockScriptInfo[]} An array of lock script information.
158
+ * @returns An array of lock script information.
156
159
  */
157
160
  function generateDefaultScriptInfos() {
158
161
  const mainnet = advanced_1.cccA.MAINNET_SCRIPTS;
159
162
  const testnet = advanced_1.cccA.TESTNET_SCRIPTS;
160
163
  return [
161
- core_1.ccc.KnownScript.JoyId,
162
- core_1.ccc.KnownScript.NostrLock,
163
- core_1.ccc.KnownScript.PWLock,
164
+ [core_1.ccc.KnownScript.JoyId, 1000],
165
+ [core_1.ccc.KnownScript.NostrLock, 572],
166
+ [core_1.ccc.KnownScript.PWLock, 65],
164
167
  ]
165
- .map((script) => [
166
- generateScriptInfo(testnet[script].codeHash, testnet[script].cellDeps),
167
- generateScriptInfo(mainnet[script].codeHash, mainnet[script].cellDeps),
168
+ .map(([script, dummyLockLength]) => [
169
+ generateScriptInfo(testnet[script].codeHash, testnet[script].cellDeps, dummyLockLength),
170
+ generateScriptInfo(mainnet[script].codeHash, mainnet[script].cellDeps, dummyLockLength),
168
171
  ])
169
172
  .flat();
170
173
  }
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Asserts that a condition is true, throwing an error if it is not.
3
- * @param {unknown} condition - The condition to assert.
4
- * @param {string} [message="Assert failed"] - The error message to throw if the condition is false.
3
+ * @public
4
+ *
5
+ * @param condition - The condition to assert.
6
+ * @param [message="Assert failed"] - The error message to throw if the condition is false.
5
7
  * @throws {Error} If the condition is false.
6
8
  */
7
9
  export declare function asserts(condition: unknown, message?: string): asserts condition;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,OAAO,EAClB,OAAO,SAAkB,GACxB,OAAO,CAAC,SAAS,CAInB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,OAAO,EAClB,OAAO,SAAkB,GACxB,OAAO,CAAC,SAAS,CAInB"}
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.asserts = void 0;
4
4
  /**
5
5
  * Asserts that a condition is true, throwing an error if it is not.
6
- * @param {unknown} condition - The condition to assert.
7
- * @param {string} [message="Assert failed"] - The error message to throw if the condition is false.
6
+ * @public
7
+ *
8
+ * @param condition - The condition to assert.
9
+ * @param [message="Assert failed"] - The error message to throw if the condition is false.
8
10
  * @throws {Error} If the condition is false.
9
11
  */
10
12
  function asserts(condition, message = "Assert failed") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/lumos-patches",
3
- "version": "0.0.12-alpha.4",
3
+ "version": "0.0.12",
4
4
  "description": "Patches for using Lumos with CCC",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
@@ -18,11 +18,6 @@
18
18
  "default": "./dist.commonjs/index.js"
19
19
  }
20
20
  },
21
- "scripts": {
22
- "build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
23
- "lint": "eslint",
24
- "format": "prettier --write . && eslint --fix"
25
- },
26
21
  "devDependencies": {
27
22
  "@eslint/js": "^9.1.1",
28
23
  "copyfiles": "^2.4.1",
@@ -39,13 +34,17 @@
39
34
  "access": "public"
40
35
  },
41
36
  "dependencies": {
42
- "@ckb-ccc/core": "0.0.12-alpha.1",
43
37
  "@ckb-lumos/base": "^0.24.0-next.1",
44
38
  "@ckb-lumos/codec": "^0.24.0-next.1",
45
39
  "@ckb-lumos/common-scripts": "^0.24.0-next.1",
46
40
  "@ckb-lumos/config-manager": "^0.24.0-next.1",
47
41
  "@ckb-lumos/helpers": "^0.24.0-next.1",
48
- "@joyid/ckb": "^1.0.1"
42
+ "@joyid/ckb": "^1.0.1",
43
+ "@ckb-ccc/core": "0.0.12"
49
44
  },
50
- "gitHead": "e40082930923fe770bdb570ae4815edfc70c49a8"
51
- }
45
+ "scripts": {
46
+ "build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
47
+ "lint": "eslint",
48
+ "format": "prettier --write . && eslint --fix"
49
+ }
50
+ }
package/src/default.ts CHANGED
@@ -45,13 +45,12 @@ function addCellDep(
45
45
 
46
46
  /**
47
47
  * Generates a class for collecting custom script cells.
48
- * @param {string} codeHash - The code hash of the custom script.
49
- * @returns {typeof JoyIDCellCollector} The CustomCellCollector class.
48
+ * @param codeHash - The code hash of the custom script.
49
+ * @returns The CustomCellCollector class.
50
50
  */
51
51
  function generateCollectorClass(codeHash: string) {
52
52
  /**
53
53
  * Class representing a collector for custom script cells.
54
- * @class
55
54
  */
56
55
  return class CustomCellCollector {
57
56
  readonly fromScript: Script;
@@ -59,11 +58,11 @@ function generateCollectorClass(codeHash: string) {
59
58
 
60
59
  /**
61
60
  * Creates an instance of CustomCollector.
62
- * @param {FromInfo} fromInfo - The information about the address to collect cells from.
63
- * @param {CellProvider} cellProvider - The provider to collect cells from.
64
- * @param {Object} options - The options for the collector.
65
- * @param {QueryOptions} [options.queryOptions={}] - The query options for collecting cells.
66
- * @param {Config} [options.config=getConfig()] - The Lumos configuration.
61
+ * @param fromInfo - The information about the address to collect cells from.
62
+ * @param cellProvider - The provider to collect cells from.
63
+ * @param options - The options for the collector.
64
+ * @param] - The query options for collecting cells.
65
+ * @param [options.config=getConfig()] - The Lumos configuration.
67
66
  * @throws {Error} If cellProvider is not provided or fromInfo is not a string.
68
67
  */
69
68
  constructor(
@@ -116,13 +115,16 @@ function generateCollectorClass(codeHash: string) {
116
115
 
117
116
  /**
118
117
  * Generates custom lock script information.
119
- * @param {string} codeHash - The code hash of the custom script.
120
- * @param {CellDep[]} cellDeps - The cell dependencies for the custom script.
121
- * @returns {LockScriptInfo} The lock script information.
118
+ * @public
119
+ *
120
+ * @param codeHash - The code hash of the custom script.
121
+ * @param cellDeps - The cell dependencies for the custom script.
122
+ * @returns The lock script information.
122
123
  */
123
124
  export function generateScriptInfo(
124
125
  codeHash: string,
125
126
  cellDeps: ccc.CellDepInfoLike[],
127
+ dummyLockLength: number,
126
128
  ): LockScriptInfo {
127
129
  return {
128
130
  codeHash: codeHash,
@@ -200,11 +202,21 @@ export function generateScriptInfo(
200
202
  );
201
203
  txSkeleton = txSkeleton.update("witnesses", (witnesses) => {
202
204
  if (witnesses.get(firstIndex)) {
203
- return witnesses;
205
+ witnesses = witnesses.merge(
206
+ Array.from(
207
+ new Array(firstIndex + 1 - witnesses.size),
208
+ () => "0x",
209
+ ),
210
+ );
204
211
  }
205
212
 
206
- return witnesses.merge(
207
- Array.from(new Array(firstIndex + 1 - witnesses.size), () => "0x"),
213
+ return witnesses.set(
214
+ firstIndex,
215
+ ccc.hexFrom(
216
+ ccc.WitnessArgs.from({
217
+ lock: Array.from(new Array(dummyLockLength), () => 0),
218
+ }).toBytes(),
219
+ ),
208
220
  );
209
221
  });
210
222
 
@@ -216,20 +228,30 @@ export function generateScriptInfo(
216
228
 
217
229
  /**
218
230
  * Generates default script information for CCC.
219
- * @returns {LockScriptInfo[]} An array of lock script information.
231
+ * @returns An array of lock script information.
220
232
  */
221
233
  export function generateDefaultScriptInfos(): LockScriptInfo[] {
222
234
  const mainnet = cccA.MAINNET_SCRIPTS;
223
235
  const testnet = cccA.TESTNET_SCRIPTS;
224
236
 
225
- return [
226
- ccc.KnownScript.JoyId,
227
- ccc.KnownScript.NostrLock,
228
- ccc.KnownScript.PWLock,
229
- ]
230
- .map((script) => [
231
- generateScriptInfo(testnet[script]!.codeHash, testnet[script]!.cellDeps),
232
- generateScriptInfo(mainnet[script]!.codeHash, mainnet[script]!.cellDeps),
237
+ return (
238
+ [
239
+ [ccc.KnownScript.JoyId, 1000],
240
+ [ccc.KnownScript.NostrLock, 572],
241
+ [ccc.KnownScript.PWLock, 65],
242
+ ] as [ccc.KnownScript, number][]
243
+ )
244
+ .map(([script, dummyLockLength]) => [
245
+ generateScriptInfo(
246
+ testnet[script]!.codeHash,
247
+ testnet[script]!.cellDeps,
248
+ dummyLockLength,
249
+ ),
250
+ generateScriptInfo(
251
+ mainnet[script]!.codeHash,
252
+ mainnet[script]!.cellDeps,
253
+ dummyLockLength,
254
+ ),
233
255
  ])
234
256
  .flat();
235
257
  }
package/src/utils.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Asserts that a condition is true, throwing an error if it is not.
3
- * @param {unknown} condition - The condition to assert.
4
- * @param {string} [message="Assert failed"] - The error message to throw if the condition is false.
3
+ * @public
4
+ *
5
+ * @param condition - The condition to assert.
6
+ * @param [message="Assert failed"] - The error message to throw if the condition is false.
5
7
  * @throws {Error} If the condition is false.
6
8
  */
7
9
  export function asserts(
package/typedoc.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "entryPoints": ["./src/index.ts"],
4
+ "extends": ["../../typedoc.base.json"],
5
+ "name": "@ckb-ccc lumos-patches"
6
+ }