@ckb-ccc/spore 1.0.8 → 1.1.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/CHANGELOG.md +13 -0
- package/dist/advanced.d.ts +2 -4
- package/dist/advanced.d.ts.map +1 -1
- package/dist/advanced.js +2 -4
- package/dist/advancedBarrel.d.ts +5 -0
- package/dist/advancedBarrel.d.ts.map +1 -0
- package/dist/advancedBarrel.js +4 -0
- package/dist/barrel.d.ts +5 -0
- package/dist/barrel.d.ts.map +1 -0
- package/dist/barrel.js +4 -0
- package/dist/cluster/index.d.ts.map +1 -1
- package/dist/cluster/index.js +2 -4
- package/dist/helper/index.d.ts +0 -2
- package/dist/helper/index.d.ts.map +1 -1
- package/dist/helper/index.js +0 -19
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/spore/advanced.d.ts.map +1 -1
- package/dist/spore/advanced.js +2 -10
- package/dist/spore/index.d.ts.map +1 -1
- package/dist/spore/index.js +2 -4
- package/dist.commonjs/advanced.d.ts +2 -4
- package/dist.commonjs/advanced.d.ts.map +1 -1
- package/dist.commonjs/advanced.js +15 -4
- package/dist.commonjs/advancedBarrel.d.ts +5 -0
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -0
- package/dist.commonjs/advancedBarrel.js +20 -0
- package/dist.commonjs/barrel.d.ts +5 -0
- package/dist.commonjs/barrel.d.ts.map +1 -0
- package/dist.commonjs/barrel.js +33 -0
- package/dist.commonjs/cluster/index.d.ts.map +1 -1
- package/dist.commonjs/cluster/index.js +1 -3
- package/dist.commonjs/helper/index.d.ts +0 -2
- package/dist.commonjs/helper/index.d.ts.map +1 -1
- package/dist.commonjs/helper/index.js +0 -21
- package/dist.commonjs/index.d.ts +2 -4
- package/dist.commonjs/index.d.ts.map +1 -1
- package/dist.commonjs/index.js +3 -5
- package/dist.commonjs/spore/advanced.d.ts.map +1 -1
- package/dist.commonjs/spore/advanced.js +2 -10
- package/dist.commonjs/spore/index.d.ts.map +1 -1
- package/dist.commonjs/spore/index.js +1 -3
- package/package.json +12 -2
- package/src/advanced.ts +2 -4
- package/src/advancedBarrel.ts +4 -0
- package/src/barrel.ts +4 -0
- package/src/cluster/index.ts +2 -7
- package/src/helper/index.ts +0 -33
- package/src/index.ts +2 -4
- package/src/spore/advanced.ts +2 -12
- package/src/spore/index.ts +2 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ckb-ccc/spore
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#130](https://github.com/ckb-devrel/ccc/pull/130) [`8c97c85`](https://github.com/ckb-devrel/ccc/commit/8c97c851db4a2d940c7e59116ca7620cfd0afae1) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat: export backend packages in @ckb-ccc/shell
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#131](https://github.com/ckb-devrel/ccc/pull/131) [`4c76f9e`](https://github.com/ckb-devrel/ccc/commit/4c76f9e2a93a226fcfc4c32a5378bb531bfff08f) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Transaction.completeInputs(Add/AtLeast)One
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`4dbf4fd`](https://github.com/ckb-devrel/ccc/commit/4dbf4fd8021cf14d05282706a7667ea7d108fb09), [`4c76f9e`](https://github.com/ckb-devrel/ccc/commit/4c76f9e2a93a226fcfc4c32a5378bb531bfff08f), [`c2c4c26`](https://github.com/ckb-devrel/ccc/commit/c2c4c264e04461948e4b913b2f22054e6032ddc8), [`b6a73fa`](https://github.com/ckb-devrel/ccc/commit/b6a73fa9628ebdff51cb8f246309654cd53e36f2), [`8c97c85`](https://github.com/ckb-devrel/ccc/commit/8c97c851db4a2d940c7e59116ca7620cfd0afae1)]:
|
|
14
|
+
- @ckb-ccc/core@1.3.0
|
|
15
|
+
|
|
3
16
|
## 1.0.8
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./predefined/advanced.js";
|
|
4
|
-
export * from "./spore/advanced.js";
|
|
1
|
+
export * from "./advancedBarrel.js";
|
|
2
|
+
export * as sporeA from "./advancedBarrel.js";
|
|
5
3
|
//# sourceMappingURL=advanced.d.ts.map
|
package/dist/advanced.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC"}
|
package/dist/advanced.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
package/dist/barrel.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dist/barrel.js
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cluster/index.ts"],"names":[],"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B,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC;CACb,CAAC,CAwCD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC;IAChB,EAAE,EAAE,GAAG,CAAC,UAAU,CAAC;IACnB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC;IACzB,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CAC9B,GAAG,OAAO,CAAC;IACV,EAAE,EAAE,GAAG,CAAC,WAAW,CAAC;CACrB,CAAC,CAwCD;AAED;;;;;;GAMG;AACH,wBAAuB,yBAAyB,CAAC,MAAM,EAAE;IACvD,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACrC,GAAG,cAAc,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC;IAClB,WAAW,EAAE,eAAe,CAAC;CAC9B,CAAC,CAoCD"}
|
package/dist/cluster/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { assembleCreateClusterAction, assembleTransferClusterAction, prepareSporeTransaction, } from "../advanced.js";
|
|
3
3
|
import { ClusterData, ClusterDataV1, packRawClusterData, } from "../codec/index.js";
|
|
4
|
-
import { findSingletonCellByArgs
|
|
4
|
+
import { findSingletonCellByArgs } from "../helper/index.js";
|
|
5
5
|
import { getClusterScriptInfo, getClusterScriptInfos, } from "../predefined/index.js";
|
|
6
6
|
export async function findCluster(client, args, scripts) {
|
|
7
7
|
return findSingletonCellByArgs(client, args, scripts ?? Object.values(getClusterScriptInfos(client)));
|
|
@@ -31,9 +31,7 @@ export async function createSporeCluster(params) {
|
|
|
31
31
|
const scriptInfo = params.scriptInfo ?? getClusterScriptInfo(signer.client);
|
|
32
32
|
// prepare transaction
|
|
33
33
|
const tx = ccc.Transaction.from(params.tx ?? {});
|
|
34
|
-
|
|
35
|
-
await injectOneCapacityCell(signer, tx);
|
|
36
|
-
}
|
|
34
|
+
await tx.completeInputsAtLeastOne(signer);
|
|
37
35
|
// build cluster cell
|
|
38
36
|
const id = ccc.hashTypeId(tx.inputs[0], tx.outputs.length);
|
|
39
37
|
const packedClusterData = packRawClusterData(data);
|
package/dist/helper/index.d.ts
CHANGED
|
@@ -4,6 +4,4 @@ export declare function findSingletonCellByArgs(client: ccc.Client, args: ccc.He
|
|
|
4
4
|
cell: ccc.Cell;
|
|
5
5
|
scriptInfo: SporeScriptInfo;
|
|
6
6
|
} | undefined>;
|
|
7
|
-
export declare function searchOneCellBySigner(signer: ccc.Signer): Promise<ccc.Cell | undefined>;
|
|
8
|
-
export declare function injectOneCapacityCell(signer: ccc.Signer, tx: ccc.Transaction): Promise<void>;
|
|
9
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,EACjB,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,GAC3C,OAAO,CACN;IACE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD,SAAS,CACZ,CAqBA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,EACjB,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,GAC3C,OAAO,CACN;IACE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD,SAAS,CACZ,CAqBA"}
|
package/dist/helper/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
1
|
import { SporeScriptInfo } from "../predefined/index.js";
|
|
3
2
|
export async function findSingletonCellByArgs(client, args, scripts) {
|
|
4
3
|
for (const scriptInfo of scripts) {
|
|
@@ -17,21 +16,3 @@ export async function findSingletonCellByArgs(client, args, scripts) {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
export async function searchOneCellBySigner(signer) {
|
|
21
|
-
for await (const cell of signer.findCells({
|
|
22
|
-
scriptLenRange: [0, 1],
|
|
23
|
-
outputDataLenRange: [0, 1],
|
|
24
|
-
}, true, undefined, 1)) {
|
|
25
|
-
return cell;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export async function injectOneCapacityCell(signer, tx) {
|
|
29
|
-
const liveCell = await searchOneCellBySigner(signer);
|
|
30
|
-
if (!liveCell) {
|
|
31
|
-
throw new Error("No live cell found");
|
|
32
|
-
}
|
|
33
|
-
tx.inputs.push(ccc.CellInput.from({
|
|
34
|
-
previousOutput: liveCell.outPoint,
|
|
35
|
-
...liveCell,
|
|
36
|
-
}));
|
|
37
|
-
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/spore/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/spore/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE1D,wBAAsB,cAAc,CAClC,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,EAAE,EAAE,GAAG,CAAC,WAAW,EACnB,IAAI,EAAE,aAAa,EACnB,WAAW,CAAC,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM,EAClD,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,GAC3B,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,MAAM,CAAC,GAAG,SAAS,CAAC,CAiEvD"}
|
package/dist/spore/advanced.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { assembleTransferClusterAction } from "../advanced.js";
|
|
3
3
|
import { assertCluster } from "../cluster/index.js";
|
|
4
|
-
import { searchOneCellBySigner } from "../helper/index.js";
|
|
5
4
|
export async function prepareCluster(signer, tx, data, clusterMode, scriptInfoHash) {
|
|
6
5
|
// skip if the spore is not belong to a cluster
|
|
7
6
|
if (!data.clusterId || clusterMode === "skip") {
|
|
@@ -15,17 +14,10 @@ export async function prepareCluster(signer, tx, data, clusterMode, scriptInfoHa
|
|
|
15
14
|
switch (clusterMode) {
|
|
16
15
|
case "lockProxy": {
|
|
17
16
|
const lock = cluster.cellOutput.lock;
|
|
18
|
-
if (await tx.findInputIndexByLock(lock, signer.client) === undefined) {
|
|
17
|
+
if ((await tx.findInputIndexByLock(lock, signer.client)) === undefined) {
|
|
19
18
|
// note: We can only search proxy of signer, if any custom logic is in need, developer should get
|
|
20
19
|
// the proxy filled in transaction before invoking `createSpore`
|
|
21
|
-
|
|
22
|
-
if (!proxy) {
|
|
23
|
-
throw new Error("Cluster lock proxy cell not found");
|
|
24
|
-
}
|
|
25
|
-
tx.inputs.push(ccc.CellInput.from({
|
|
26
|
-
previousOutput: proxy.outPoint,
|
|
27
|
-
...proxy,
|
|
28
|
-
}));
|
|
20
|
+
await tx.completeInputsAddOne(signer);
|
|
29
21
|
}
|
|
30
22
|
if (tx.outputs.every((output) => output.lock !== lock)) {
|
|
31
23
|
tx.addOutput({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,OAAO,EAAa,aAAa,EAAoB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,OAAO,EAAa,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EACL,eAAe,EACf,mBAAmB,EAGpB,MAAM,wBAAwB,CAAC;AAGhC,wBAAsB,SAAS,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,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AAG,CAAC,WAAW,CAAC;CACrB,CAAC,CAmCD;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE;IACtC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC;IAChB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC;IACzB,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CAC9B,GAAG,OAAO,CAAC;IACV,EAAE,EAAE,GAAG,CAAC,WAAW,CAAC;CACrB,CAAC,CAuBD;AAED;;;;;;;;GAQG;AACH,wBAAuB,kBAAkB,CAAC,MAAM,EAAE;IAChD,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACrC,GAAG,cAAc,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;CAC1B,CAAC,CAqCD"}
|
package/dist/spore/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { assembleCreateSporeAction, assembleMeltSporeAction, assembleTransferSporeAction, prepareSporeTransaction, } from "../advanced.js";
|
|
3
3
|
import { SporeData, packRawSporeData } from "../codec/index.js";
|
|
4
|
-
import { findSingletonCellByArgs
|
|
4
|
+
import { findSingletonCellByArgs } from "../helper/index.js";
|
|
5
5
|
import { getSporeScriptInfo, getSporeScriptInfos, } from "../predefined/index.js";
|
|
6
6
|
import { prepareCluster } from "./advanced.js";
|
|
7
7
|
export async function findSpore(client, args, scripts) {
|
|
@@ -39,9 +39,7 @@ export async function createSpore(params) {
|
|
|
39
39
|
const actions = [];
|
|
40
40
|
const ids = [];
|
|
41
41
|
const tx = ccc.Transaction.from(params.tx ?? {});
|
|
42
|
-
|
|
43
|
-
await injectOneCapacityCell(signer, tx);
|
|
44
|
-
}
|
|
42
|
+
await tx.completeInputsAtLeastOne(signer);
|
|
45
43
|
const { script: lock } = await signer.getRecommendedAddressObj();
|
|
46
44
|
// build spore cell
|
|
47
45
|
const id = ccc.hashTypeId(tx.inputs[0], tx.outputs.length);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./predefined/advanced.js";
|
|
4
|
-
export * from "./spore/advanced.js";
|
|
1
|
+
export * from "./advancedBarrel.js";
|
|
2
|
+
export * as sporeA from "./advancedBarrel.js";
|
|
5
3
|
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC"}
|
|
@@ -10,11 +10,22 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
|
|
20
|
-
__exportStar(require("./spore/advanced.js"), exports);
|
|
29
|
+
exports.sporeA = void 0;
|
|
30
|
+
__exportStar(require("./advancedBarrel.js"), exports);
|
|
31
|
+
exports.sporeA = __importStar(require("./advancedBarrel.js"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cobuild/index.js"), exports);
|
|
18
|
+
__exportStar(require("./codec/index.js"), exports);
|
|
19
|
+
__exportStar(require("./predefined/advanced.js"), exports);
|
|
20
|
+
__exportStar(require("./spore/advanced.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.dob = void 0;
|
|
30
|
+
__exportStar(require("./cluster/index.js"), exports);
|
|
31
|
+
exports.dob = __importStar(require("./dob/index.js"));
|
|
32
|
+
__exportStar(require("./predefined/index.js"), exports);
|
|
33
|
+
__exportStar(require("./spore/index.js"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cluster/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMpC,OAAO,EAGL,eAAe,EAEhB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cluster/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMpC,OAAO,EAGL,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,mBAAmB,EAGpB,MAAM,wBAAwB,CAAC;AAEhC,wBAAsB,WAAW,CAC/B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,EACjB,OAAO,CAAC,EAAE,mBAAmB,EAAE,GAC9B,OAAO,CACN;IACE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD,SAAS,CACZ,CAMA;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,EACjB,OAAO,CAAC,EAAE,mBAAmB,EAAE,GAC9B,OAAO,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,9 +38,7 @@ async function createSporeCluster(params) {
|
|
|
38
38
|
const scriptInfo = params.scriptInfo ?? (0, index_js_3.getClusterScriptInfo)(signer.client);
|
|
39
39
|
// prepare transaction
|
|
40
40
|
const tx = core_1.ccc.Transaction.from(params.tx ?? {});
|
|
41
|
-
|
|
42
|
-
await (0, index_js_2.injectOneCapacityCell)(signer, tx);
|
|
43
|
-
}
|
|
41
|
+
await tx.completeInputsAtLeastOne(signer);
|
|
44
42
|
// build cluster cell
|
|
45
43
|
const id = core_1.ccc.hashTypeId(tx.inputs[0], tx.outputs.length);
|
|
46
44
|
const packedClusterData = (0, index_js_1.packRawClusterData)(data);
|
|
@@ -4,6 +4,4 @@ export declare function findSingletonCellByArgs(client: ccc.Client, args: ccc.He
|
|
|
4
4
|
cell: ccc.Cell;
|
|
5
5
|
scriptInfo: SporeScriptInfo;
|
|
6
6
|
} | undefined>;
|
|
7
|
-
export declare function searchOneCellBySigner(signer: ccc.Signer): Promise<ccc.Cell | undefined>;
|
|
8
|
-
export declare function injectOneCapacityCell(signer: ccc.Signer, tx: ccc.Transaction): Promise<void>;
|
|
9
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,EACjB,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,GAC3C,OAAO,CACN;IACE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD,SAAS,CACZ,CAqBA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,EACjB,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,GAC3C,OAAO,CACN;IACE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD,SAAS,CACZ,CAqBA"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findSingletonCellByArgs = findSingletonCellByArgs;
|
|
4
|
-
exports.searchOneCellBySigner = searchOneCellBySigner;
|
|
5
|
-
exports.injectOneCapacityCell = injectOneCapacityCell;
|
|
6
|
-
const core_1 = require("@ckb-ccc/core");
|
|
7
4
|
const index_js_1 = require("../predefined/index.js");
|
|
8
5
|
async function findSingletonCellByArgs(client, args, scripts) {
|
|
9
6
|
for (const scriptInfo of scripts) {
|
|
@@ -22,21 +19,3 @@ async function findSingletonCellByArgs(client, args, scripts) {
|
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
async function searchOneCellBySigner(signer) {
|
|
26
|
-
for await (const cell of signer.findCells({
|
|
27
|
-
scriptLenRange: [0, 1],
|
|
28
|
-
outputDataLenRange: [0, 1],
|
|
29
|
-
}, true, undefined, 1)) {
|
|
30
|
-
return cell;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function injectOneCapacityCell(signer, tx) {
|
|
34
|
-
const liveCell = await searchOneCellBySigner(signer);
|
|
35
|
-
if (!liveCell) {
|
|
36
|
-
throw new Error("No live cell found");
|
|
37
|
-
}
|
|
38
|
-
tx.inputs.push(core_1.ccc.CellInput.from({
|
|
39
|
-
previousOutput: liveCell.outPoint,
|
|
40
|
-
...liveCell,
|
|
41
|
-
}));
|
|
42
|
-
}
|
package/dist.commonjs/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC"}
|
package/dist.commonjs/index.js
CHANGED
|
@@ -26,8 +26,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
__exportStar(require("./
|
|
31
|
-
exports.
|
|
32
|
-
__exportStar(require("./predefined/index.js"), exports);
|
|
33
|
-
__exportStar(require("./spore/index.js"), exports);
|
|
29
|
+
exports.spore = void 0;
|
|
30
|
+
__exportStar(require("./barrel.js"), exports);
|
|
31
|
+
exports.spore = __importStar(require("./barrel.js"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/spore/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/spore/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE1D,wBAAsB,cAAc,CAClC,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,EAAE,EAAE,GAAG,CAAC,WAAW,EACnB,IAAI,EAAE,aAAa,EACnB,WAAW,CAAC,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM,EAClD,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,GAC3B,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,MAAM,CAAC,GAAG,SAAS,CAAC,CAiEvD"}
|
|
@@ -4,7 +4,6 @@ exports.prepareCluster = prepareCluster;
|
|
|
4
4
|
const core_1 = require("@ckb-ccc/core");
|
|
5
5
|
const advanced_js_1 = require("../advanced.js");
|
|
6
6
|
const index_js_1 = require("../cluster/index.js");
|
|
7
|
-
const index_js_2 = require("../helper/index.js");
|
|
8
7
|
async function prepareCluster(signer, tx, data, clusterMode, scriptInfoHash) {
|
|
9
8
|
// skip if the spore is not belong to a cluster
|
|
10
9
|
if (!data.clusterId || clusterMode === "skip") {
|
|
@@ -18,17 +17,10 @@ async function prepareCluster(signer, tx, data, clusterMode, scriptInfoHash) {
|
|
|
18
17
|
switch (clusterMode) {
|
|
19
18
|
case "lockProxy": {
|
|
20
19
|
const lock = cluster.cellOutput.lock;
|
|
21
|
-
if (await tx.findInputIndexByLock(lock, signer.client) === undefined) {
|
|
20
|
+
if ((await tx.findInputIndexByLock(lock, signer.client)) === undefined) {
|
|
22
21
|
// note: We can only search proxy of signer, if any custom logic is in need, developer should get
|
|
23
22
|
// the proxy filled in transaction before invoking `createSpore`
|
|
24
|
-
|
|
25
|
-
if (!proxy) {
|
|
26
|
-
throw new Error("Cluster lock proxy cell not found");
|
|
27
|
-
}
|
|
28
|
-
tx.inputs.push(core_1.ccc.CellInput.from({
|
|
29
|
-
previousOutput: proxy.outPoint,
|
|
30
|
-
...proxy,
|
|
31
|
-
}));
|
|
23
|
+
await tx.completeInputsAddOne(signer);
|
|
32
24
|
}
|
|
33
25
|
if (tx.outputs.every((output) => output.lock !== lock)) {
|
|
34
26
|
tx.addOutput({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,OAAO,EAAa,aAAa,EAAoB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,OAAO,EAAa,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EACL,eAAe,EACf,mBAAmB,EAGpB,MAAM,wBAAwB,CAAC;AAGhC,wBAAsB,SAAS,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,EACjB,OAAO,CAAC,EAAE,mBAAmB,EAAE,GAC9B,OAAO,CACN;IACE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD,SAAS,CACZ,CAMA;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,GAAG,CAAC,OAAO,EACjB,OAAO,CAAC,EAAE,mBAAmB,EAAE,GAC9B,OAAO,CAAC;IACT,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC,CAQD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE;IACxC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;IACpB,EAAE,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM,CAAC;IACnD,EAAE,C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C,IAAI,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;CAC1B,CAAC,CAqCD"}
|
|
@@ -47,9 +47,7 @@ async function createSpore(params) {
|
|
|
47
47
|
const actions = [];
|
|
48
48
|
const ids = [];
|
|
49
49
|
const tx = core_1.ccc.Transaction.from(params.tx ?? {});
|
|
50
|
-
|
|
51
|
-
await (0, index_js_2.injectOneCapacityCell)(signer, tx);
|
|
52
|
-
}
|
|
50
|
+
await tx.completeInputsAtLeastOne(signer);
|
|
53
51
|
const { script: lock } = await signer.getRecommendedAddressObj();
|
|
54
52
|
// build spore cell
|
|
55
53
|
const id = core_1.ccc.hashTypeId(tx.inputs[0], tx.outputs.length);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/spore",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CCC - CKBer's Codebase. Common Chains Connector's support for Spore protocol",
|
|
5
5
|
"author": "ashuralyk <ashuralyk@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,10 +19,20 @@
|
|
|
19
19
|
"require": "./dist.commonjs/index.js",
|
|
20
20
|
"default": "./dist.commonjs/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./barrel": {
|
|
23
|
+
"import": "./dist/barrel.js",
|
|
24
|
+
"require": "./dist.commonjs/barrel.js",
|
|
25
|
+
"default": "./dist.commonjs/barrel.js"
|
|
26
|
+
},
|
|
22
27
|
"./advanced": {
|
|
23
28
|
"import": "./dist/advanced.js",
|
|
24
29
|
"require": "./dist.commonjs/advanced.js",
|
|
25
30
|
"default": "./dist.commonjs/advanced.js"
|
|
31
|
+
},
|
|
32
|
+
"./advancedBarrel": {
|
|
33
|
+
"import": "./dist/advancedBarrel.js",
|
|
34
|
+
"require": "./dist.commonjs/advancedBarrel.js",
|
|
35
|
+
"default": "./dist.commonjs/advancedBarrel.js"
|
|
26
36
|
}
|
|
27
37
|
},
|
|
28
38
|
"devDependencies": {
|
|
@@ -44,7 +54,7 @@
|
|
|
44
54
|
},
|
|
45
55
|
"dependencies": {
|
|
46
56
|
"axios": "^1.7.7",
|
|
47
|
-
"@ckb-ccc/core": "1.
|
|
57
|
+
"@ckb-ccc/core": "1.3.0"
|
|
48
58
|
},
|
|
49
59
|
"scripts": {
|
|
50
60
|
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
|
package/src/advanced.ts
CHANGED
package/src/barrel.ts
ADDED
package/src/cluster/index.ts
CHANGED
|
@@ -10,10 +10,7 @@ import {
|
|
|
10
10
|
ClusterDataView,
|
|
11
11
|
packRawClusterData,
|
|
12
12
|
} from "../codec/index.js";
|
|
13
|
-
import {
|
|
14
|
-
findSingletonCellByArgs,
|
|
15
|
-
injectOneCapacityCell,
|
|
16
|
-
} from "../helper/index.js";
|
|
13
|
+
import { findSingletonCellByArgs } from "../helper/index.js";
|
|
17
14
|
import {
|
|
18
15
|
SporeScriptInfo,
|
|
19
16
|
SporeScriptInfoLike,
|
|
@@ -85,9 +82,7 @@ export async function createSporeCluster(params: {
|
|
|
85
82
|
|
|
86
83
|
// prepare transaction
|
|
87
84
|
const tx = ccc.Transaction.from(params.tx ?? {});
|
|
88
|
-
|
|
89
|
-
await injectOneCapacityCell(signer, tx);
|
|
90
|
-
}
|
|
85
|
+
await tx.completeInputsAtLeastOne(signer);
|
|
91
86
|
|
|
92
87
|
// build cluster cell
|
|
93
88
|
const id = ccc.hashTypeId(tx.inputs[0], tx.outputs.length);
|
package/src/helper/index.ts
CHANGED
|
@@ -33,36 +33,3 @@ export async function findSingletonCellByArgs(
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
export async function searchOneCellBySigner(
|
|
38
|
-
signer: ccc.Signer,
|
|
39
|
-
): Promise<ccc.Cell | undefined> {
|
|
40
|
-
for await (const cell of signer.findCells(
|
|
41
|
-
{
|
|
42
|
-
scriptLenRange: [0, 1],
|
|
43
|
-
outputDataLenRange: [0, 1],
|
|
44
|
-
},
|
|
45
|
-
true,
|
|
46
|
-
undefined,
|
|
47
|
-
1,
|
|
48
|
-
)) {
|
|
49
|
-
return cell;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function injectOneCapacityCell(
|
|
54
|
-
signer: ccc.Signer,
|
|
55
|
-
tx: ccc.Transaction,
|
|
56
|
-
): Promise<void> {
|
|
57
|
-
const liveCell = await searchOneCellBySigner(signer);
|
|
58
|
-
if (!liveCell) {
|
|
59
|
-
throw new Error("No live cell found");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
tx.inputs.push(
|
|
63
|
-
ccc.CellInput.from({
|
|
64
|
-
previousOutput: liveCell.outPoint,
|
|
65
|
-
...liveCell,
|
|
66
|
-
}),
|
|
67
|
-
);
|
|
68
|
-
}
|
package/src/index.ts
CHANGED
package/src/spore/advanced.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { ccc, mol } from "@ckb-ccc/core";
|
|
|
2
2
|
import { assembleTransferClusterAction } from "../advanced.js";
|
|
3
3
|
import { assertCluster } from "../cluster/index.js";
|
|
4
4
|
import { Action, SporeDataView } from "../codec/index.js";
|
|
5
|
-
import { searchOneCellBySigner } from "../helper/index.js";
|
|
6
5
|
|
|
7
6
|
export async function prepareCluster(
|
|
8
7
|
signer: ccc.Signer,
|
|
@@ -30,19 +29,10 @@ export async function prepareCluster(
|
|
|
30
29
|
case "lockProxy": {
|
|
31
30
|
const lock = cluster.cellOutput.lock;
|
|
32
31
|
|
|
33
|
-
if (await tx.findInputIndexByLock(lock, signer.client) === undefined) {
|
|
32
|
+
if ((await tx.findInputIndexByLock(lock, signer.client)) === undefined) {
|
|
34
33
|
// note: We can only search proxy of signer, if any custom logic is in need, developer should get
|
|
35
34
|
// the proxy filled in transaction before invoking `createSpore`
|
|
36
|
-
|
|
37
|
-
if (!proxy) {
|
|
38
|
-
throw new Error("Cluster lock proxy cell not found");
|
|
39
|
-
}
|
|
40
|
-
tx.inputs.push(
|
|
41
|
-
ccc.CellInput.from({
|
|
42
|
-
previousOutput: proxy.outPoint,
|
|
43
|
-
...proxy,
|
|
44
|
-
}),
|
|
45
|
-
);
|
|
35
|
+
await tx.completeInputsAddOne(signer);
|
|
46
36
|
}
|
|
47
37
|
if (tx.outputs.every((output) => output.lock !== lock)) {
|
|
48
38
|
tx.addOutput({
|
package/src/spore/index.ts
CHANGED
|
@@ -6,10 +6,7 @@ import {
|
|
|
6
6
|
prepareSporeTransaction,
|
|
7
7
|
} from "../advanced.js";
|
|
8
8
|
import { SporeData, SporeDataView, packRawSporeData } from "../codec/index.js";
|
|
9
|
-
import {
|
|
10
|
-
findSingletonCellByArgs,
|
|
11
|
-
injectOneCapacityCell,
|
|
12
|
-
} from "../helper/index.js";
|
|
9
|
+
import { findSingletonCellByArgs } from "../helper/index.js";
|
|
13
10
|
import {
|
|
14
11
|
SporeScriptInfo,
|
|
15
12
|
SporeScriptInfoLike,
|
|
@@ -90,9 +87,7 @@ export async function createSpore(params: {
|
|
|
90
87
|
const actions = [];
|
|
91
88
|
const ids: ccc.Hex[] = [];
|
|
92
89
|
const tx = ccc.Transaction.from(params.tx ?? {});
|
|
93
|
-
|
|
94
|
-
await injectOneCapacityCell(signer, tx);
|
|
95
|
-
}
|
|
90
|
+
await tx.completeInputsAtLeastOne(signer);
|
|
96
91
|
|
|
97
92
|
const { script: lock } = await signer.getRecommendedAddressObj();
|
|
98
93
|
|