@ckb-ccc/lumos-patches 0.0.8-alpha.3 → 0.0.10-alpha.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.
- package/dist.commonjs/default.d.ts +3 -7
- package/dist.commonjs/default.js +106 -125
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +14 -30
- package/dist.commonjs/utils.d.ts +2 -5
- package/dist.commonjs/utils.js +3 -3
- package/package.json +7 -7
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { CellDep, Script } from "@ckb-lumos/base";
|
|
2
1
|
import { LockScriptInfo } from "@ckb-lumos/common-scripts";
|
|
2
|
+
import { CellDep, Script } from "@ckb-lumos/base";
|
|
3
3
|
/**
|
|
4
4
|
* Generates custom lock script information.
|
|
5
5
|
* @param {string} codeHash - The code hash of the custom script.
|
|
6
6
|
* @param {CellDep[]} cellDeps - The cell dependencies for the custom script.
|
|
7
7
|
* @returns {LockScriptInfo} The lock script information.
|
|
8
8
|
*/
|
|
9
|
-
export declare function generateScriptInfo(
|
|
10
|
-
codeHash: string,
|
|
11
|
-
cellDeps: CellDep[],
|
|
12
|
-
cellDepTypes?: Script[],
|
|
13
|
-
): LockScriptInfo;
|
|
9
|
+
export declare function generateScriptInfo(codeHash: string, cellDeps: CellDep[], cellDepTypes?: Script[]): LockScriptInfo;
|
|
14
10
|
/**
|
|
15
11
|
* Generates default script information for CCC.
|
|
16
12
|
* @returns {LockScriptInfo[]} An array of lock script information.
|
|
17
13
|
*/
|
|
18
14
|
export declare function generateDefaultScriptInfos(): LockScriptInfo[];
|
|
19
|
-
//# sourceMappingURL=default.d.ts.map
|
|
15
|
+
//# sourceMappingURL=default.d.ts.map
|
package/dist.commonjs/default.js
CHANGED
|
@@ -13,59 +13,53 @@ const utils_1 = require("./utils");
|
|
|
13
13
|
* @returns {typeof JoyIDCellCollector} The CustomCellCollector class.
|
|
14
14
|
*/
|
|
15
15
|
function generateCollectorClass(codeHash) {
|
|
16
|
-
/**
|
|
17
|
-
* Class representing a collector for custom script cells.
|
|
18
|
-
* @class
|
|
19
|
-
*/
|
|
20
|
-
return class CustomCellCollector {
|
|
21
16
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
24
|
-
* @param {CellProvider} cellProvider - The provider to collect cells from.
|
|
25
|
-
* @param {Object} options - The options for the collector.
|
|
26
|
-
* @param {QueryOptions} [options.queryOptions={}] - The query options for collecting cells.
|
|
27
|
-
* @param {Config} [options.config=getConfig()] - The Lumos configuration.
|
|
28
|
-
* @throws {Error} If cellProvider is not provided or fromInfo is not a string.
|
|
17
|
+
* Class representing a collector for custom script cells.
|
|
18
|
+
* @class
|
|
29
19
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
20
|
+
return class CustomCellCollector {
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of CustomCollector.
|
|
23
|
+
* @param {FromInfo} fromInfo - The information about the address to collect cells from.
|
|
24
|
+
* @param {CellProvider} cellProvider - The provider to collect cells from.
|
|
25
|
+
* @param {Object} options - The options for the collector.
|
|
26
|
+
* @param {QueryOptions} [options.queryOptions={}] - The query options for collecting cells.
|
|
27
|
+
* @param {Config} [options.config=getConfig()] - The Lumos configuration.
|
|
28
|
+
* @throws {Error} If cellProvider is not provided or fromInfo is not a string.
|
|
29
|
+
*/
|
|
30
|
+
constructor(fromInfo, cellProvider, { queryOptions = {}, config = (0, config_manager_1.getConfig)(), }) {
|
|
31
|
+
if (!cellProvider) {
|
|
32
|
+
throw new Error(`cellProvider is required when collecting cells`);
|
|
33
|
+
}
|
|
34
|
+
const { fromScript } = (0, common_scripts_1.parseFromInfo)(fromInfo, { config });
|
|
35
|
+
this.fromScript = fromScript;
|
|
36
|
+
if (!codec_1.bytes.equal(fromScript.codeHash, codeHash)) {
|
|
37
|
+
this.cellCollector = undefined;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
queryOptions = {
|
|
41
|
+
...queryOptions,
|
|
42
|
+
lock: this.fromScript,
|
|
43
|
+
type: queryOptions.type || "empty",
|
|
44
|
+
data: queryOptions.data || "0x",
|
|
45
|
+
};
|
|
46
|
+
this.cellCollector = cellProvider.collector(queryOptions);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Collects custom cells.
|
|
50
|
+
* @async
|
|
51
|
+
* @generator
|
|
52
|
+
* @yields {Cell} The collected cell.
|
|
53
|
+
*/
|
|
54
|
+
async *collect() {
|
|
55
|
+
if (!this.cellCollector) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for await (const inputCell of this.cellCollector.collect()) {
|
|
59
|
+
yield inputCell;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
69
63
|
}
|
|
70
64
|
/**
|
|
71
65
|
* Generates custom lock script information.
|
|
@@ -74,89 +68,76 @@ function generateCollectorClass(codeHash) {
|
|
|
74
68
|
* @returns {LockScriptInfo} The lock script information.
|
|
75
69
|
*/
|
|
76
70
|
function generateScriptInfo(codeHash, cellDeps, cellDepTypes = []) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
108
|
-
const since = options.since;
|
|
109
|
-
if (since) {
|
|
110
|
-
txSkeleton = txSkeleton.update("inputSinces", (inputSinces) => {
|
|
111
|
-
return inputSinces.set(txSkeleton.get("inputs").size - 1, since);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
cellDeps.forEach((item) => {
|
|
115
|
-
txSkeleton = (0, helper_1.addCellDep)(txSkeleton, item);
|
|
116
|
-
});
|
|
117
|
-
if (txSkeleton.cellProvider != null) {
|
|
118
|
-
await Promise.all(
|
|
119
|
-
cellDepTypes.map(async (type) => {
|
|
120
|
-
for await (const cell of txSkeleton.cellProvider
|
|
121
|
-
.collector({
|
|
122
|
-
type,
|
|
123
|
-
})
|
|
124
|
-
.collect()) {
|
|
125
|
-
txSkeleton = (0, helper_1.addCellDep)(txSkeleton, {
|
|
126
|
-
depType: "code",
|
|
127
|
-
outPoint: cell.outPoint,
|
|
71
|
+
return {
|
|
72
|
+
codeHash: codeHash,
|
|
73
|
+
hashType: "type",
|
|
74
|
+
lockScriptInfo: {
|
|
75
|
+
CellCollector: generateCollectorClass(codeHash),
|
|
76
|
+
prepareSigningEntries: () => {
|
|
77
|
+
throw new Error("Custom scripts doesn't support prepareSigningEntries.");
|
|
78
|
+
},
|
|
79
|
+
async setupInputCell(txSkeleton, inputCell, _, options = {}) {
|
|
80
|
+
const fromScript = inputCell.cellOutput.lock;
|
|
81
|
+
(0, utils_1.asserts)(codec_1.bytes.equal(fromScript.codeHash, codeHash), `The input script is not specified script`);
|
|
82
|
+
// add inputCell to txSkeleton
|
|
83
|
+
txSkeleton = txSkeleton.update("inputs", (inputs) => inputs.push(inputCell));
|
|
84
|
+
const output = {
|
|
85
|
+
cellOutput: {
|
|
86
|
+
capacity: inputCell.cellOutput.capacity,
|
|
87
|
+
lock: inputCell.cellOutput.lock,
|
|
88
|
+
type: inputCell.cellOutput.type,
|
|
89
|
+
},
|
|
90
|
+
data: inputCell.data,
|
|
91
|
+
};
|
|
92
|
+
txSkeleton = txSkeleton.update("outputs", (outputs) => outputs.push(output));
|
|
93
|
+
const since = options.since;
|
|
94
|
+
if (since) {
|
|
95
|
+
txSkeleton = txSkeleton.update("inputSinces", (inputSinces) => {
|
|
96
|
+
return inputSinces.set(txSkeleton.get("inputs").size - 1, since);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
cellDeps.forEach((item) => {
|
|
100
|
+
txSkeleton = (0, helper_1.addCellDep)(txSkeleton, item);
|
|
128
101
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
102
|
+
if (txSkeleton.cellProvider != null) {
|
|
103
|
+
await Promise.all(cellDepTypes.map(async (type) => {
|
|
104
|
+
for await (const cell of txSkeleton
|
|
105
|
+
.cellProvider.collector({
|
|
106
|
+
type,
|
|
107
|
+
})
|
|
108
|
+
.collect()) {
|
|
109
|
+
txSkeleton = (0, helper_1.addCellDep)(txSkeleton, {
|
|
110
|
+
depType: "code",
|
|
111
|
+
outPoint: cell.outPoint,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
return txSkeleton;
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
137
120
|
}
|
|
138
121
|
exports.generateScriptInfo = generateScriptInfo;
|
|
139
|
-
const NOSTR_TESTNET_TYPE_HASH =
|
|
140
|
-
"0x6ae5ee0cb887b2df5a9a18137315b9bdc55be8d52637b2de0624092d5f0c91d5";
|
|
122
|
+
const NOSTR_TESTNET_TYPE_HASH = "0x6ae5ee0cb887b2df5a9a18137315b9bdc55be8d52637b2de0624092d5f0c91d5";
|
|
141
123
|
const NOSTR_TESTNET_TYPE = {
|
|
142
|
-
|
|
143
|
-
"
|
|
144
|
-
|
|
145
|
-
args: "0x8dc56c6f35f0c535e23ded1629b1f20535477a1b43e59f14617d11e32c50e0aa",
|
|
124
|
+
codeHash: "0x00000000000000000000000000000000000000000000000000545950455f4944",
|
|
125
|
+
hashType: "type",
|
|
126
|
+
args: "0x8dc56c6f35f0c535e23ded1629b1f20535477a1b43e59f14617d11e32c50e0aa",
|
|
146
127
|
};
|
|
147
128
|
/**
|
|
148
129
|
* Generates default script information for CCC.
|
|
149
130
|
* @returns {LockScriptInfo[]} An array of lock script information.
|
|
150
131
|
*/
|
|
151
132
|
function generateDefaultScriptInfos() {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
133
|
+
return [
|
|
134
|
+
generateScriptInfo((0, ckb_1.getJoyIDLockScript)(false).codeHash, [
|
|
135
|
+
(0, ckb_1.getJoyIDCellDep)(false),
|
|
136
|
+
]),
|
|
137
|
+
generateScriptInfo((0, ckb_1.getJoyIDLockScript)(true).codeHash, [
|
|
138
|
+
(0, ckb_1.getJoyIDCellDep)(true),
|
|
139
|
+
]),
|
|
140
|
+
generateScriptInfo(NOSTR_TESTNET_TYPE_HASH, [], [NOSTR_TESTNET_TYPE]),
|
|
141
|
+
];
|
|
161
142
|
}
|
|
162
143
|
exports.generateDefaultScriptInfos = generateDefaultScriptInfos;
|
package/dist.commonjs/index.d.ts
CHANGED
package/dist.commonjs/index.js
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __exportStar =
|
|
26
|
-
(this && this.__exportStar) ||
|
|
27
|
-
function (m, exports) {
|
|
28
|
-
for (var p in m)
|
|
29
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
-
__createBinding(exports, m, p);
|
|
31
|
-
};
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
17
|
__exportStar(require("./default"), exports);
|
|
34
18
|
__exportStar(require("./utils"), exports);
|
package/dist.commonjs/utils.d.ts
CHANGED
|
@@ -4,8 +4,5 @@
|
|
|
4
4
|
* @param {string} [message="Assert failed"] - The error message to throw if the condition is false.
|
|
5
5
|
* @throws {Error} If the condition is false.
|
|
6
6
|
*/
|
|
7
|
-
export declare function asserts(
|
|
8
|
-
|
|
9
|
-
message?: string,
|
|
10
|
-
): asserts condition;
|
|
11
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
7
|
+
export declare function asserts(condition: unknown, message?: string): asserts condition;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/dist.commonjs/utils.js
CHANGED
|
@@ -8,8 +8,8 @@ exports.asserts = void 0;
|
|
|
8
8
|
* @throws {Error} If the condition is false.
|
|
9
9
|
*/
|
|
10
10
|
function asserts(condition, message = "Assert failed") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (!condition) {
|
|
12
|
+
throw new Error(message);
|
|
13
|
+
}
|
|
14
14
|
}
|
|
15
15
|
exports.asserts = asserts;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/lumos-patches",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10-alpha.5",
|
|
4
4
|
"description": "Patches for using Lumos with CCC",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@ckb-lumos/base": "^0.
|
|
42
|
-
"@ckb-lumos/codec": "^0.
|
|
43
|
-
"@ckb-lumos/common-scripts": "^0.
|
|
44
|
-
"@ckb-lumos/config-manager": "^0.
|
|
45
|
-
"@joyid/ckb": "^
|
|
41
|
+
"@ckb-lumos/base": "^0.24.0-next.1",
|
|
42
|
+
"@ckb-lumos/codec": "^0.24.0-next.1",
|
|
43
|
+
"@ckb-lumos/common-scripts": "^0.24.0-next.1",
|
|
44
|
+
"@ckb-lumos/config-manager": "^0.24.0-next.1",
|
|
45
|
+
"@joyid/ckb": "^1.0.1"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "40a3d50aa3697a98c7ac711cd526ef322ccad760"
|
|
48
48
|
}
|