@ckb-ccc/lumos-patches 0.0.12-alpha.1 → 0.0.12-alpha.2
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/default.d.ts +1 -1
- package/dist/default.d.ts.map +1 -1
- package/dist/default.js +16 -2
- package/dist.commonjs/default.d.ts +1 -1
- package/dist.commonjs/default.d.ts.map +1 -1
- package/dist.commonjs/default.js +17 -3
- package/package.json +3 -2
- package/src/default.ts +32 -4
package/dist/default.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LockScriptInfo } from "@ckb-lumos/common-scripts";
|
|
2
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { LockScriptInfo } from "@ckb-lumos/common-scripts";
|
|
3
3
|
/**
|
|
4
4
|
* Generates custom lock script information.
|
|
5
5
|
* @param {string} codeHash - The code hash of the custom script.
|
package/dist/default.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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,CAwEhB;AAWD;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,cAAc,EAAE,CAc7D"}
|
package/dist/default.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { cccA } from "@ckb-ccc/core/advanced";
|
|
3
3
|
import { bytes } from "@ckb-lumos/codec";
|
|
4
|
-
import { parseFromInfo } from "@ckb-lumos/common-scripts";
|
|
5
|
-
import { addCellDep } from "@ckb-lumos/common-scripts/lib/helper";
|
|
4
|
+
import { parseFromInfo, } from "@ckb-lumos/common-scripts";
|
|
6
5
|
import { getConfig } from "@ckb-lumos/config-manager";
|
|
7
6
|
import { asserts } from "./utils.js";
|
|
7
|
+
function addCellDep(txSkeleton, newCellDep) {
|
|
8
|
+
const cellDep = txSkeleton.get("cellDeps").find((cellDep) => {
|
|
9
|
+
return (cellDep.depType === newCellDep.depType &&
|
|
10
|
+
ccc.OutPoint.from(cellDep.outPoint).eq(ccc.OutPoint.from(newCellDep.outPoint)));
|
|
11
|
+
});
|
|
12
|
+
if (!cellDep) {
|
|
13
|
+
txSkeleton = txSkeleton.update("cellDeps", (cellDeps) => {
|
|
14
|
+
return cellDeps.push({
|
|
15
|
+
outPoint: newCellDep.outPoint,
|
|
16
|
+
depType: newCellDep.depType,
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return txSkeleton;
|
|
21
|
+
}
|
|
8
22
|
/**
|
|
9
23
|
* Generates a class for collecting custom script cells.
|
|
10
24
|
* @param {string} codeHash - The code hash of the custom script.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LockScriptInfo } from "@ckb-lumos/common-scripts";
|
|
2
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { LockScriptInfo } from "@ckb-lumos/common-scripts";
|
|
3
3
|
/**
|
|
4
4
|
* Generates custom lock script information.
|
|
5
5
|
* @param {string} codeHash - The code hash of the custom script.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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,CAwEhB;AAWD;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,cAAc,EAAE,CAc7D"}
|
package/dist.commonjs/default.js
CHANGED
|
@@ -5,9 +5,23 @@ const core_1 = require("@ckb-ccc/core");
|
|
|
5
5
|
const advanced_1 = require("@ckb-ccc/core/advanced");
|
|
6
6
|
const codec_1 = require("@ckb-lumos/codec");
|
|
7
7
|
const common_scripts_1 = require("@ckb-lumos/common-scripts");
|
|
8
|
-
const helper_1 = require("@ckb-lumos/common-scripts/lib/helper");
|
|
9
8
|
const config_manager_1 = require("@ckb-lumos/config-manager");
|
|
10
9
|
const utils_js_1 = require("./utils.js");
|
|
10
|
+
function addCellDep(txSkeleton, newCellDep) {
|
|
11
|
+
const cellDep = txSkeleton.get("cellDeps").find((cellDep) => {
|
|
12
|
+
return (cellDep.depType === newCellDep.depType &&
|
|
13
|
+
core_1.ccc.OutPoint.from(cellDep.outPoint).eq(core_1.ccc.OutPoint.from(newCellDep.outPoint)));
|
|
14
|
+
});
|
|
15
|
+
if (!cellDep) {
|
|
16
|
+
txSkeleton = txSkeleton.update("cellDeps", (cellDeps) => {
|
|
17
|
+
return cellDeps.push({
|
|
18
|
+
outPoint: newCellDep.outPoint,
|
|
19
|
+
depType: newCellDep.depType,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return txSkeleton;
|
|
24
|
+
}
|
|
11
25
|
/**
|
|
12
26
|
* Generates a class for collecting custom script cells.
|
|
13
27
|
* @param {string} codeHash - The code hash of the custom script.
|
|
@@ -105,14 +119,14 @@ function generateScriptInfo(codeHash, cellDeps) {
|
|
|
105
119
|
type: item.type,
|
|
106
120
|
})
|
|
107
121
|
.collect()) {
|
|
108
|
-
txSkeleton =
|
|
122
|
+
txSkeleton = addCellDep(txSkeleton, {
|
|
109
123
|
depType: "code",
|
|
110
124
|
outPoint: cell.outPoint,
|
|
111
125
|
});
|
|
112
126
|
}
|
|
113
127
|
}
|
|
114
128
|
else {
|
|
115
|
-
txSkeleton =
|
|
129
|
+
txSkeleton = addCellDep(txSkeleton, {
|
|
116
130
|
...item.cellDep,
|
|
117
131
|
outPoint: {
|
|
118
132
|
txHash: item.cellDep.outPoint.txHash,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/lumos-patches",
|
|
3
|
-
"version": "0.0.12-alpha.
|
|
3
|
+
"version": "0.0.12-alpha.2",
|
|
4
4
|
"description": "Patches for using Lumos with CCC",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"@ckb-lumos/codec": "^0.24.0-next.1",
|
|
45
45
|
"@ckb-lumos/common-scripts": "^0.24.0-next.1",
|
|
46
46
|
"@ckb-lumos/config-manager": "^0.24.0-next.1",
|
|
47
|
+
"@ckb-lumos/helpers": "^0.24.0-next.1",
|
|
47
48
|
"@joyid/ckb": "^1.0.1"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "376a1a965e35c550a425ade00926e5fd6a9127cb"
|
|
50
51
|
}
|
package/src/default.ts
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
|
-
import { LockScriptInfo } from "@ckb-lumos/common-scripts";
|
|
2
|
-
|
|
3
1
|
import { ccc } from "@ckb-ccc/core";
|
|
4
2
|
import { cccA } from "@ckb-ccc/core/advanced";
|
|
5
3
|
import {
|
|
6
4
|
Cell,
|
|
7
5
|
CellCollector,
|
|
6
|
+
CellDep,
|
|
8
7
|
CellProvider,
|
|
9
8
|
QueryOptions,
|
|
10
9
|
Script,
|
|
11
10
|
} from "@ckb-lumos/base";
|
|
12
11
|
import { bytes } from "@ckb-lumos/codec";
|
|
13
|
-
import {
|
|
14
|
-
|
|
12
|
+
import {
|
|
13
|
+
FromInfo,
|
|
14
|
+
LockScriptInfo,
|
|
15
|
+
parseFromInfo,
|
|
16
|
+
} from "@ckb-lumos/common-scripts";
|
|
15
17
|
import { Config, getConfig } from "@ckb-lumos/config-manager";
|
|
18
|
+
import { TransactionSkeletonType } from "@ckb-lumos/helpers";
|
|
16
19
|
import { asserts } from "./utils.js";
|
|
17
20
|
|
|
21
|
+
function addCellDep(
|
|
22
|
+
txSkeleton: TransactionSkeletonType,
|
|
23
|
+
newCellDep: CellDep,
|
|
24
|
+
): TransactionSkeletonType {
|
|
25
|
+
const cellDep = txSkeleton.get("cellDeps").find((cellDep) => {
|
|
26
|
+
return (
|
|
27
|
+
cellDep.depType === newCellDep.depType &&
|
|
28
|
+
ccc.OutPoint.from(cellDep.outPoint).eq(
|
|
29
|
+
ccc.OutPoint.from(newCellDep.outPoint),
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (!cellDep) {
|
|
35
|
+
txSkeleton = txSkeleton.update("cellDeps", (cellDeps) => {
|
|
36
|
+
return cellDeps.push({
|
|
37
|
+
outPoint: newCellDep.outPoint,
|
|
38
|
+
depType: newCellDep.depType,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return txSkeleton;
|
|
44
|
+
}
|
|
45
|
+
|
|
18
46
|
/**
|
|
19
47
|
* Generates a class for collecting custom script cells.
|
|
20
48
|
* @param {string} codeHash - The code hash of the custom script.
|