@ckb-ccc/spore 1.2.4 → 1.3.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 +8 -14
- package/dist/cluster/index.d.ts +34 -15
- package/dist/cluster/index.d.ts.map +1 -1
- package/dist/cluster/index.js +57 -23
- package/dist/cobuild/index.js +1 -2
- package/dist/spore/advanced.d.ts.map +1 -1
- package/dist/spore/advanced.js +1 -5
- package/dist/spore/index.d.ts +47 -21
- package/dist/spore/index.d.ts.map +1 -1
- package/dist/spore/index.js +78 -37
- package/dist.commonjs/advanced.js +17 -7
- package/dist.commonjs/barrel.js +17 -7
- package/dist.commonjs/cluster/index.d.ts +34 -15
- package/dist.commonjs/cluster/index.d.ts.map +1 -1
- package/dist.commonjs/cluster/index.js +58 -23
- package/dist.commonjs/cobuild/index.js +1 -2
- package/dist.commonjs/index.js +17 -7
- package/dist.commonjs/spore/advanced.d.ts.map +1 -1
- package/dist.commonjs/spore/advanced.js +1 -5
- package/dist.commonjs/spore/index.d.ts +47 -21
- package/dist.commonjs/spore/index.d.ts.map +1 -1
- package/dist.commonjs/spore/index.js +79 -37
- package/package.json +2 -2
- package/src/cluster/index.ts +79 -30
- package/src/cobuild/index.ts +2 -2
- package/src/spore/advanced.ts +1 -6
- package/src/spore/index.ts +105 -45
package/CHANGELOG.md
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
# @ckb-ccc/spore
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.3.0
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [[`2d80b5d`](https://github.com/ckb-devrel/ccc/commit/2d80b5da31bb542f0305a6f0da86f35e56681f50)]:
|
|
8
|
-
- @ckb-ccc/core@1.5.3
|
|
5
|
+
### Minor Changes
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
- [#173](https://github.com/ckb-devrel/ccc/pull/173) [`9eaa0ad`](https://github.com/ckb-devrel/ccc/commit/9eaa0ad3214d21bb00bec98d89c76b4bde2c0515) Thanks [@ashuralyk](https://github.com/ashuralyk)! - support search spore/cluster under customized lock script
|
|
11
8
|
|
|
12
9
|
### Patch Changes
|
|
13
10
|
|
|
14
|
-
-
|
|
15
|
-
- @ckb-ccc/core@1.5.2
|
|
11
|
+
- [#179](https://github.com/ckb-devrel/ccc/pull/179) [`732ad59`](https://github.com/ckb-devrel/ccc/commit/732ad59f13ea2cd47003033e30b310b8ff26f058) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix: add inputs after cobuild witness injected
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
13
|
+
- [#175](https://github.com/ckb-devrel/ccc/pull/175) [`5fa86e7`](https://github.com/ckb-devrel/ccc/commit/5fa86e7656d34d47662669d91e273f994640f707) Thanks [@ashuralyk](https://github.com/ashuralyk)! - bug: add scriptInfo parameter in transfer/melt spore method
|
|
20
14
|
|
|
21
|
-
- [`
|
|
15
|
+
- [#158](https://github.com/ckb-devrel/ccc/pull/158) [`6f10589`](https://github.com/ckb-devrel/ccc/commit/6f1058977e7aa113808fa74793f1ad5d672626d2) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Transaction utils
|
|
22
16
|
|
|
23
|
-
- Updated dependencies [[`
|
|
24
|
-
- @ckb-ccc/core@1.
|
|
17
|
+
- Updated dependencies [[`80e605d`](https://github.com/ckb-devrel/ccc/commit/80e605d0645e87b4e8b5be85c63322f7a3926e38), [`8c7e000`](https://github.com/ckb-devrel/ccc/commit/8c7e00069a276ac58afa4737623e95656d4852c5), [`732ad59`](https://github.com/ckb-devrel/ccc/commit/732ad59f13ea2cd47003033e30b310b8ff26f058), [`90b6e9f`](https://github.com/ckb-devrel/ccc/commit/90b6e9fee543b6ee16b96e27d6f86ff33fc57029), [`815fb4d`](https://github.com/ckb-devrel/ccc/commit/815fb4da3432b889b848eb70943d725988fe611d), [`def62a0`](https://github.com/ckb-devrel/ccc/commit/def62a08bf908c6a21fe91c8db2c60848a2ada52), [`d584059`](https://github.com/ckb-devrel/ccc/commit/d584059644e8bcd3a0ea8b0314fdcbb68ee66013), [`f58d398`](https://github.com/ckb-devrel/ccc/commit/f58d3980f08da1f3fa19cee45aa50c8b293294ea), [`1e88ad8`](https://github.com/ckb-devrel/ccc/commit/1e88ad8743428b46b28fe790bd559b96df8a6ce4), [`6f10589`](https://github.com/ckb-devrel/ccc/commit/6f1058977e7aa113808fa74793f1ad5d672626d2), [`601a729`](https://github.com/ckb-devrel/ccc/commit/601a7291e877b39c4032c95fab421ed3d41404c2), [`074b4cd`](https://github.com/ckb-devrel/ccc/commit/074b4cd3b0cdc925dc9ef99e8146564a60646f1e), [`d7728d9`](https://github.com/ckb-devrel/ccc/commit/d7728d9edb46c9c5a2bfeb342fc68a8b1c0fec5d), [`ab195a0`](https://github.com/ckb-devrel/ccc/commit/ab195a024aeee5e21ed19d89c2cf1bf8d52bb380), [`29a2e22`](https://github.com/ckb-devrel/ccc/commit/29a2e223b902ed23523e4948ab3fca793f9e5b01)]:
|
|
18
|
+
- @ckb-ccc/core@1.6.0
|
|
25
19
|
|
|
26
20
|
## 1.2.1
|
|
27
21
|
|
package/dist/cluster/index.d.ts
CHANGED
|
@@ -14,12 +14,12 @@ export declare function assertCluster(client: ccc.Client, args: ccc.HexLike, scr
|
|
|
14
14
|
/**
|
|
15
15
|
* Create a new Cluster cell
|
|
16
16
|
*
|
|
17
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
18
|
-
* @param data specific format of data required by Cluster protocol
|
|
19
|
-
* @param to the owner of the Cluster cell, which will be replaced with signer if not provided
|
|
20
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
21
|
-
* @param scriptInfo the script info of new cluster, default spore version if undefined
|
|
22
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
17
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
18
|
+
* @param params.data specific format of data required by Cluster protocol
|
|
19
|
+
* @param params.to the owner of the Cluster cell, which will be replaced with signer if not provided
|
|
20
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
21
|
+
* @param params.scriptInfo the script info of new cluster, default spore version if undefined
|
|
22
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
23
23
|
* @returns
|
|
24
24
|
* - **tx**: a new transaction that contains created Cluster cell
|
|
25
25
|
* - **id**: the id of the created Cluster cell
|
|
@@ -38,11 +38,11 @@ export declare function createSporeCluster(params: {
|
|
|
38
38
|
/**
|
|
39
39
|
* Transfer a Cluster cell
|
|
40
40
|
*
|
|
41
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
42
|
-
* @param id the id of the Cluster cell to be transferred
|
|
43
|
-
* @param to the new owner of the Cluster cell
|
|
44
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
45
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
41
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
42
|
+
* @param params.id the id of the Cluster cell to be transferred
|
|
43
|
+
* @param params.to the new owner of the Cluster cell
|
|
44
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
45
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
46
46
|
* @returns
|
|
47
47
|
* - **tx**: a new transaction that contains transferred Cluster cell
|
|
48
48
|
*/
|
|
@@ -51,6 +51,7 @@ export declare function transferSporeCluster(params: {
|
|
|
51
51
|
id: ccc.HexLike;
|
|
52
52
|
to: ccc.ScriptLike;
|
|
53
53
|
tx?: ccc.TransactionLike;
|
|
54
|
+
scripts?: SporeScriptInfoLike[];
|
|
54
55
|
scriptInfoHash?: ccc.HexLike;
|
|
55
56
|
}): Promise<{
|
|
56
57
|
tx: ccc.Transaction;
|
|
@@ -58,11 +59,11 @@ export declare function transferSporeCluster(params: {
|
|
|
58
59
|
/**
|
|
59
60
|
* Search on-chain clusters under the signer's control
|
|
60
61
|
*
|
|
61
|
-
* @param signer the owner of clusters
|
|
62
|
-
* @param order the order in creation time of clusters
|
|
63
|
-
* @param scriptInfos the deployed script infos of clusters
|
|
62
|
+
* @param params.signer the owner of clusters
|
|
63
|
+
* @param params.order the order in creation time of clusters
|
|
64
|
+
* @param params.scriptInfos the deployed script infos of clusters
|
|
64
65
|
*/
|
|
65
|
-
export declare function findSporeClustersBySigner(
|
|
66
|
+
export declare function findSporeClustersBySigner(params: {
|
|
66
67
|
signer: ccc.Signer;
|
|
67
68
|
order?: "asc" | "desc";
|
|
68
69
|
limit?: number;
|
|
@@ -73,4 +74,22 @@ export declare function findSporeClustersBySigner({ signer, order, limit, script
|
|
|
73
74
|
clusterData: ClusterDataView;
|
|
74
75
|
scriptInfo: SporeScriptInfo;
|
|
75
76
|
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Search on-chain clusters under the specified lock or not
|
|
79
|
+
*
|
|
80
|
+
* @param params.client the client to search clusters
|
|
81
|
+
* @param params.lock the lock of clusters
|
|
82
|
+
*/
|
|
83
|
+
export declare function findSporeClusters(params: {
|
|
84
|
+
client: ccc.Client;
|
|
85
|
+
lock?: ccc.ScriptLike;
|
|
86
|
+
order?: "asc" | "desc";
|
|
87
|
+
limit?: number;
|
|
88
|
+
scriptInfos?: SporeScriptInfoLike[];
|
|
89
|
+
}): AsyncGenerator<{
|
|
90
|
+
cell: ccc.Cell;
|
|
91
|
+
cluster: ccc.Cell;
|
|
92
|
+
clusterData: ClusterDataView;
|
|
93
|
+
scriptInfo: SporeScriptInfo;
|
|
94
|
+
}>;
|
|
76
95
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,EACL,eAAe,EAGhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,eAAe,EACf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K,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACrC,GAAG,cAAc,CAAC;IACjB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC;IAClB,WAAW,EAAE,eAAe,CAAC;IAC7B,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC,CAkCD"}
|
package/dist/cluster/index.js
CHANGED
|
@@ -25,12 +25,12 @@ export async function assertCluster(client, args, scripts) {
|
|
|
25
25
|
/**
|
|
26
26
|
* Create a new Cluster cell
|
|
27
27
|
*
|
|
28
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
29
|
-
* @param data specific format of data required by Cluster protocol
|
|
30
|
-
* @param to the owner of the Cluster cell, which will be replaced with signer if not provided
|
|
31
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
32
|
-
* @param scriptInfo the script info of new cluster, default spore version if undefined
|
|
33
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
28
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
29
|
+
* @param params.data specific format of data required by Cluster protocol
|
|
30
|
+
* @param params.to the owner of the Cluster cell, which will be replaced with signer if not provided
|
|
31
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
32
|
+
* @param params.scriptInfo the script info of new cluster, default spore version if undefined
|
|
33
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
34
34
|
* @returns
|
|
35
35
|
* - **tx**: a new transaction that contains created Cluster cell
|
|
36
36
|
* - **id**: the id of the created Cluster cell
|
|
@@ -67,32 +67,29 @@ export async function createSporeCluster(params) {
|
|
|
67
67
|
/**
|
|
68
68
|
* Transfer a Cluster cell
|
|
69
69
|
*
|
|
70
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
71
|
-
* @param id the id of the Cluster cell to be transferred
|
|
72
|
-
* @param to the new owner of the Cluster cell
|
|
73
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
74
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
70
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
71
|
+
* @param params.id the id of the Cluster cell to be transferred
|
|
72
|
+
* @param params.to the new owner of the Cluster cell
|
|
73
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
74
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
75
75
|
* @returns
|
|
76
76
|
* - **tx**: a new transaction that contains transferred Cluster cell
|
|
77
77
|
*/
|
|
78
78
|
export async function transferSporeCluster(params) {
|
|
79
|
-
const { signer, id, to, scriptInfoHash } = params;
|
|
79
|
+
const { signer, id, to, scripts, scriptInfoHash } = params;
|
|
80
80
|
// prepare transaction
|
|
81
81
|
const tx = ccc.Transaction.from(params.tx ?? {});
|
|
82
82
|
// build cluster cell
|
|
83
|
-
const { cell: cluster, scriptInfo } = await assertCluster(signer.client, id);
|
|
84
|
-
tx.
|
|
85
|
-
previousOutput: cluster.outPoint,
|
|
86
|
-
...cluster,
|
|
87
|
-
}));
|
|
83
|
+
const { cell: cluster, scriptInfo: clusterScriptInfo } = await assertCluster(signer.client, id, scripts);
|
|
84
|
+
tx.addInput(cluster);
|
|
88
85
|
tx.addOutput({
|
|
89
86
|
lock: to,
|
|
90
87
|
type: cluster.cellOutput.type,
|
|
91
88
|
}, cluster.outputData);
|
|
92
89
|
// complete cellDeps
|
|
93
|
-
await tx.addCellDepInfos(signer.client,
|
|
90
|
+
await tx.addCellDepInfos(signer.client, clusterScriptInfo.cellDeps);
|
|
94
91
|
// generate cobuild action
|
|
95
|
-
const actions =
|
|
92
|
+
const actions = clusterScriptInfo.cobuild
|
|
96
93
|
? [
|
|
97
94
|
assembleTransferClusterAction(cluster.cellOutput, tx.outputs[tx.outputs.length - 1], scriptInfoHash),
|
|
98
95
|
]
|
|
@@ -104,11 +101,12 @@ export async function transferSporeCluster(params) {
|
|
|
104
101
|
/**
|
|
105
102
|
* Search on-chain clusters under the signer's control
|
|
106
103
|
*
|
|
107
|
-
* @param signer the owner of clusters
|
|
108
|
-
* @param order the order in creation time of clusters
|
|
109
|
-
* @param scriptInfos the deployed script infos of clusters
|
|
104
|
+
* @param params.signer the owner of clusters
|
|
105
|
+
* @param params.order the order in creation time of clusters
|
|
106
|
+
* @param params.scriptInfos the deployed script infos of clusters
|
|
110
107
|
*/
|
|
111
|
-
export async function* findSporeClustersBySigner(
|
|
108
|
+
export async function* findSporeClustersBySigner(params) {
|
|
109
|
+
const { signer, order, limit, scriptInfos } = params;
|
|
112
110
|
for (const scriptInfo of scriptInfos ??
|
|
113
111
|
Object.values(getClusterScriptInfos(signer.client))) {
|
|
114
112
|
if (!scriptInfo) {
|
|
@@ -129,3 +127,39 @@ export async function* findSporeClustersBySigner({ signer, order, limit, scriptI
|
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Search on-chain clusters under the specified lock or not
|
|
132
|
+
*
|
|
133
|
+
* @param params.client the client to search clusters
|
|
134
|
+
* @param params.lock the lock of clusters
|
|
135
|
+
*/
|
|
136
|
+
export async function* findSporeClusters(params) {
|
|
137
|
+
const { client, lock, order, limit, scriptInfos } = params;
|
|
138
|
+
for (const scriptInfo of scriptInfos ??
|
|
139
|
+
Object.values(getClusterScriptInfos(client))) {
|
|
140
|
+
if (!scriptInfo) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
for await (const cluster of client.findCells({
|
|
144
|
+
script: {
|
|
145
|
+
...scriptInfo,
|
|
146
|
+
args: "",
|
|
147
|
+
},
|
|
148
|
+
scriptType: "type",
|
|
149
|
+
scriptSearchMode: "prefix",
|
|
150
|
+
withData: true,
|
|
151
|
+
filter: lock
|
|
152
|
+
? {
|
|
153
|
+
script: lock,
|
|
154
|
+
}
|
|
155
|
+
: undefined,
|
|
156
|
+
}, order, limit)) {
|
|
157
|
+
yield {
|
|
158
|
+
cell: cluster,
|
|
159
|
+
cluster,
|
|
160
|
+
clusterData: unpackToRawClusterData(cluster.outputData),
|
|
161
|
+
scriptInfo: SporeScriptInfo.from(scriptInfo),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
package/dist/cobuild/index.js
CHANGED
|
@@ -155,7 +155,7 @@ export function extractCobuildActionsFromTx(tx) {
|
|
|
155
155
|
return witnessLayout.value.message.actions;
|
|
156
156
|
}
|
|
157
157
|
export function injectCobuild(tx, actions) {
|
|
158
|
-
|
|
158
|
+
tx.setWitnessAt(Math.max(tx.witnesses.length, tx.inputs.length), WitnessLayout.encode({
|
|
159
159
|
type: "SighashAll",
|
|
160
160
|
value: {
|
|
161
161
|
seal: "0x",
|
|
@@ -164,5 +164,4 @@ export function injectCobuild(tx, actions) {
|
|
|
164
164
|
},
|
|
165
165
|
},
|
|
166
166
|
}));
|
|
167
|
-
tx.witnesses.push(ccc.hexFrom(witnessLayout));
|
|
168
167
|
}
|
|
@@ -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;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,
|
|
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,CA4DvD"}
|
package/dist/spore/advanced.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
1
|
import { assembleTransferClusterAction } from "../advanced.js";
|
|
3
2
|
import { assertCluster } from "../cluster/index.js";
|
|
4
3
|
export async function prepareCluster(signer, tx, data, clusterMode, scriptInfoHash) {
|
|
@@ -34,10 +33,7 @@ export async function prepareCluster(signer, tx, data, clusterMode, scriptInfoHa
|
|
|
34
33
|
if (tx.inputs.some((i) => i.previousOutput.eq(cluster.outPoint))) {
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
|
-
tx.
|
|
38
|
-
previousOutput: cluster.outPoint,
|
|
39
|
-
...cluster,
|
|
40
|
-
}));
|
|
36
|
+
tx.addInput(cluster);
|
|
41
37
|
tx.addOutput(cluster.cellOutput, cluster.outputData);
|
|
42
38
|
await tx.addCellDepInfos(signer.client, scriptInfo.cellDeps);
|
|
43
39
|
// note: add cluster as cellDep, which will be used in Spore contract
|
package/dist/spore/index.d.ts
CHANGED
|
@@ -14,17 +14,17 @@ export declare function assertSpore(client: ccc.Client, args: ccc.HexLike, scrip
|
|
|
14
14
|
/**
|
|
15
15
|
* Create one Spore cell with the specified Spore data.
|
|
16
16
|
*
|
|
17
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
18
|
-
* @param data specific format of data required by Spore protocol
|
|
19
|
-
* @param to owner of new spore cell, signer if no provided
|
|
20
|
-
* @param clusterMode how to process cluster cell **(if clusterId is not provided in SporeData, this parameter will be ignored)**
|
|
17
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
18
|
+
* @param params.data specific format of data required by Spore protocol
|
|
19
|
+
* @param params.to owner of new spore cell, signer if no provided
|
|
20
|
+
* @param params.clusterMode how to process cluster cell **(if clusterId is not provided in SporeData, this parameter will be ignored)**
|
|
21
21
|
* - undefined: error if the spore has a cluster but the clusterMode is not set
|
|
22
22
|
* - lockProxy: put a cell that uses the same lock from Cluster cell in both Inputs and Outputs
|
|
23
23
|
* - clusterCell: directly put Cluster cell in Inputs and Outputs
|
|
24
24
|
* - skip: don't handle the cluster logic
|
|
25
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
26
|
-
* @param scriptInfo the script info of Spore cell, if not provided, the default script info will be used
|
|
27
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
25
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
26
|
+
* @param params.scriptInfo the script info of Spore cell, if not provided, the default script info will be used
|
|
27
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
28
28
|
* @returns
|
|
29
29
|
* - **tx**: a new transaction that contains created Spore cells
|
|
30
30
|
* - **id**: the sporeId of created Spore cell
|
|
@@ -44,11 +44,11 @@ export declare function createSpore(params: {
|
|
|
44
44
|
/**
|
|
45
45
|
* Transfer one Spore cell
|
|
46
46
|
*
|
|
47
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
48
|
-
* @param id sporeId
|
|
49
|
-
* @param to Spore's new owner
|
|
50
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
51
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
47
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
48
|
+
* @param params.id sporeId
|
|
49
|
+
* @param params.to Spore's new owner
|
|
50
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
51
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
52
52
|
* @returns
|
|
53
53
|
* - **tx**: a new transaction that contains transferred Spore cells
|
|
54
54
|
*/
|
|
@@ -57,6 +57,7 @@ export declare function transferSpore(params: {
|
|
|
57
57
|
id: ccc.HexLike;
|
|
58
58
|
to: ccc.ScriptLike;
|
|
59
59
|
tx?: ccc.TransactionLike;
|
|
60
|
+
scripts?: SporeScriptInfoLike[];
|
|
60
61
|
scriptInfoHash?: ccc.HexLike;
|
|
61
62
|
}): Promise<{
|
|
62
63
|
tx: ccc.Transaction;
|
|
@@ -64,10 +65,10 @@ export declare function transferSpore(params: {
|
|
|
64
65
|
/**
|
|
65
66
|
* Melt one Spore cell
|
|
66
67
|
*
|
|
67
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
68
|
-
* @param id sporeId to be melted
|
|
69
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
70
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
68
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
69
|
+
* @param params.id sporeId to be melted
|
|
70
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
71
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
71
72
|
* @returns
|
|
72
73
|
* - **tx**: a new transaction that contains melted Spore cell
|
|
73
74
|
*/
|
|
@@ -75,6 +76,7 @@ export declare function meltSpore(params: {
|
|
|
75
76
|
signer: ccc.Signer;
|
|
76
77
|
id: ccc.HexLike;
|
|
77
78
|
tx?: ccc.TransactionLike;
|
|
79
|
+
scripts?: SporeScriptInfoLike[];
|
|
78
80
|
scriptInfoHash?: ccc.HexLike;
|
|
79
81
|
}): Promise<{
|
|
80
82
|
tx: ccc.Transaction;
|
|
@@ -82,13 +84,13 @@ export declare function meltSpore(params: {
|
|
|
82
84
|
/**
|
|
83
85
|
* Search on-chain spores under the signer's control, if cluster provided, filter spores belonging to this cluster
|
|
84
86
|
*
|
|
85
|
-
* @param signer the owner of spores
|
|
86
|
-
* @param order the order in creation time of spores
|
|
87
|
-
* @param clusterId the cluster that spores belong to. "" to find public spores
|
|
88
|
-
* @param scriptInfos the deployed script infos of spores
|
|
87
|
+
* @param params.signer the owner of spores
|
|
88
|
+
* @param params.order the order in creation time of spores
|
|
89
|
+
* @param params.clusterId the cluster that spores belong to. "" to find public spores
|
|
90
|
+
* @param params.scriptInfos the deployed script infos of spores
|
|
89
91
|
* @returns specified spore cells
|
|
90
92
|
*/
|
|
91
|
-
export declare function findSporesBySigner(
|
|
93
|
+
export declare function findSporesBySigner(params: {
|
|
92
94
|
signer: ccc.Signer;
|
|
93
95
|
order?: "asc" | "desc";
|
|
94
96
|
limit?: number;
|
|
@@ -100,4 +102,28 @@ export declare function findSporesBySigner({ signer, clusterId, scriptInfos, lim
|
|
|
100
102
|
sporeData: SporeDataView;
|
|
101
103
|
scriptInfo: SporeScriptInfo;
|
|
102
104
|
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Search on-chain spores under the specified lock or not, if cluster provided, filter spores belonging to this cluster
|
|
107
|
+
*
|
|
108
|
+
* @param params.client the client to search spores
|
|
109
|
+
* @param params.lock the lock of spores
|
|
110
|
+
* @param params.clusterId the cluster that spores belong to. "" to find public spores
|
|
111
|
+
* @param params.scriptInfos the deployed script infos of spores
|
|
112
|
+
* @param params.limit the limit of spores to search
|
|
113
|
+
* @param params.order the order in creation time of spores
|
|
114
|
+
* @returns specified spore cells
|
|
115
|
+
*/
|
|
116
|
+
export declare function findSpores(params: {
|
|
117
|
+
client: ccc.Client;
|
|
118
|
+
lock?: ccc.ScriptLike;
|
|
119
|
+
clusterId?: ccc.HexLike;
|
|
120
|
+
scriptInfos?: SporeScriptInfoLike[];
|
|
121
|
+
limit?: number;
|
|
122
|
+
order?: "asc" | "desc";
|
|
123
|
+
}): AsyncGenerator<{
|
|
124
|
+
cell: ccc.Cell;
|
|
125
|
+
spore: ccc.Cell;
|
|
126
|
+
sporeData: SporeDataView;
|
|
127
|
+
scriptInfo: SporeScriptInfo;
|
|
128
|
+
}>;
|
|
103
129
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,EACL,aAAa,EAGd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,mBAAmB,EAGpB,MAAM,wBAAwB,CAAC;AAGhC,wBAAsB,SAAS,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,EAAE,EAAE,GAAG,CAAC,OAAO,EACf,OAAO,CAAC,EAAE,mBAAmB,EAAE,GAC9B,OAAO,CACN;IACE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD,SAAS,CACZ,CAgBA;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,CAAC,EAAE,GAAG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 -26,17 +26,17 @@ export async function assertSpore(client, args, scripts) {
|
|
|
26
26
|
/**
|
|
27
27
|
* Create one Spore cell with the specified Spore data.
|
|
28
28
|
*
|
|
29
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
30
|
-
* @param data specific format of data required by Spore protocol
|
|
31
|
-
* @param to owner of new spore cell, signer if no provided
|
|
32
|
-
* @param clusterMode how to process cluster cell **(if clusterId is not provided in SporeData, this parameter will be ignored)**
|
|
29
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
30
|
+
* @param params.data specific format of data required by Spore protocol
|
|
31
|
+
* @param params.to owner of new spore cell, signer if no provided
|
|
32
|
+
* @param params.clusterMode how to process cluster cell **(if clusterId is not provided in SporeData, this parameter will be ignored)**
|
|
33
33
|
* - undefined: error if the spore has a cluster but the clusterMode is not set
|
|
34
34
|
* - lockProxy: put a cell that uses the same lock from Cluster cell in both Inputs and Outputs
|
|
35
35
|
* - clusterCell: directly put Cluster cell in Inputs and Outputs
|
|
36
36
|
* - skip: don't handle the cluster logic
|
|
37
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
38
|
-
* @param scriptInfo the script info of Spore cell, if not provided, the default script info will be used
|
|
39
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
37
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
38
|
+
* @param params.scriptInfo the script info of Spore cell, if not provided, the default script info will be used
|
|
39
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
40
40
|
* @returns
|
|
41
41
|
* - **tx**: a new transaction that contains created Spore cells
|
|
42
42
|
* - **id**: the sporeId of created Spore cell
|
|
@@ -81,29 +81,26 @@ export async function createSpore(params) {
|
|
|
81
81
|
/**
|
|
82
82
|
* Transfer one Spore cell
|
|
83
83
|
*
|
|
84
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
85
|
-
* @param id sporeId
|
|
86
|
-
* @param to Spore's new owner
|
|
87
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
88
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
84
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
85
|
+
* @param params.id sporeId
|
|
86
|
+
* @param params.to Spore's new owner
|
|
87
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
88
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
89
89
|
* @returns
|
|
90
90
|
* - **tx**: a new transaction that contains transferred Spore cells
|
|
91
91
|
*/
|
|
92
92
|
export async function transferSpore(params) {
|
|
93
|
-
const { signer, id, to, scriptInfoHash } = params;
|
|
93
|
+
const { signer, id, to, scripts, scriptInfoHash } = params;
|
|
94
94
|
// prepare transaction
|
|
95
95
|
const tx = ccc.Transaction.from(params.tx ?? {});
|
|
96
|
-
const { cell: sporeCell, scriptInfo } = await assertSpore(signer.client, id);
|
|
97
|
-
await tx.addCellDepInfos(signer.client,
|
|
98
|
-
tx.
|
|
99
|
-
previousOutput: sporeCell.outPoint,
|
|
100
|
-
...sporeCell,
|
|
101
|
-
}));
|
|
96
|
+
const { cell: sporeCell, scriptInfo: sporeScriptInfo } = await assertSpore(signer.client, id, scripts);
|
|
97
|
+
await tx.addCellDepInfos(signer.client, sporeScriptInfo.cellDeps);
|
|
98
|
+
tx.addInput(sporeCell);
|
|
102
99
|
tx.addOutput({
|
|
103
100
|
lock: to,
|
|
104
101
|
type: sporeCell.cellOutput.type,
|
|
105
102
|
}, sporeCell.outputData);
|
|
106
|
-
const actions =
|
|
103
|
+
const actions = sporeScriptInfo.cobuild
|
|
107
104
|
? [
|
|
108
105
|
assembleTransferSporeAction(sporeCell.cellOutput, tx.outputs[tx.outputs.length - 1], scriptInfoHash),
|
|
109
106
|
]
|
|
@@ -115,25 +112,22 @@ export async function transferSpore(params) {
|
|
|
115
112
|
/**
|
|
116
113
|
* Melt one Spore cell
|
|
117
114
|
*
|
|
118
|
-
* @param signer who takes the responsibility to balance and sign the transaction
|
|
119
|
-
* @param id sporeId to be melted
|
|
120
|
-
* @param tx the transaction skeleton, if not provided, a new one will be created
|
|
121
|
-
* @param scriptInfoHash the script info hash used in cobuild
|
|
115
|
+
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
116
|
+
* @param params.id sporeId to be melted
|
|
117
|
+
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
118
|
+
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
122
119
|
* @returns
|
|
123
120
|
* - **tx**: a new transaction that contains melted Spore cell
|
|
124
121
|
*/
|
|
125
122
|
export async function meltSpore(params) {
|
|
126
|
-
const { signer, id, scriptInfoHash } = params;
|
|
123
|
+
const { signer, id, scripts, scriptInfoHash } = params;
|
|
127
124
|
// prepare transaction
|
|
128
125
|
const tx = ccc.Transaction.from(params.tx ?? {});
|
|
129
126
|
// build spore cell
|
|
130
|
-
const { cell: sporeCell, scriptInfo } = await assertSpore(signer.client, id);
|
|
131
|
-
await tx.addCellDepInfos(signer.client,
|
|
132
|
-
tx.
|
|
133
|
-
|
|
134
|
-
...sporeCell,
|
|
135
|
-
}));
|
|
136
|
-
const actions = scriptInfo.cobuild
|
|
127
|
+
const { cell: sporeCell, scriptInfo: sporeScriptInfo } = await assertSpore(signer.client, id, scripts);
|
|
128
|
+
await tx.addCellDepInfos(signer.client, sporeScriptInfo.cellDeps);
|
|
129
|
+
tx.addInput(sporeCell);
|
|
130
|
+
const actions = sporeScriptInfo.cobuild
|
|
137
131
|
? [assembleMeltSporeAction(sporeCell.cellOutput, scriptInfoHash)]
|
|
138
132
|
: [];
|
|
139
133
|
return {
|
|
@@ -143,13 +137,14 @@ export async function meltSpore(params) {
|
|
|
143
137
|
/**
|
|
144
138
|
* Search on-chain spores under the signer's control, if cluster provided, filter spores belonging to this cluster
|
|
145
139
|
*
|
|
146
|
-
* @param signer the owner of spores
|
|
147
|
-
* @param order the order in creation time of spores
|
|
148
|
-
* @param clusterId the cluster that spores belong to. "" to find public spores
|
|
149
|
-
* @param scriptInfos the deployed script infos of spores
|
|
140
|
+
* @param params.signer the owner of spores
|
|
141
|
+
* @param params.order the order in creation time of spores
|
|
142
|
+
* @param params.clusterId the cluster that spores belong to. "" to find public spores
|
|
143
|
+
* @param params.scriptInfos the deployed script infos of spores
|
|
150
144
|
* @returns specified spore cells
|
|
151
145
|
*/
|
|
152
|
-
export async function* findSporesBySigner(
|
|
146
|
+
export async function* findSporesBySigner(params) {
|
|
147
|
+
const { signer, clusterId, scriptInfos, limit, order } = params;
|
|
153
148
|
for (const scriptInfo of scriptInfos ??
|
|
154
149
|
Object.values(getSporeScriptInfos(signer.client))) {
|
|
155
150
|
if (!scriptInfo) {
|
|
@@ -175,3 +170,49 @@ export async function* findSporesBySigner({ signer, clusterId, scriptInfos, limi
|
|
|
175
170
|
}
|
|
176
171
|
}
|
|
177
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Search on-chain spores under the specified lock or not, if cluster provided, filter spores belonging to this cluster
|
|
175
|
+
*
|
|
176
|
+
* @param params.client the client to search spores
|
|
177
|
+
* @param params.lock the lock of spores
|
|
178
|
+
* @param params.clusterId the cluster that spores belong to. "" to find public spores
|
|
179
|
+
* @param params.scriptInfos the deployed script infos of spores
|
|
180
|
+
* @param params.limit the limit of spores to search
|
|
181
|
+
* @param params.order the order in creation time of spores
|
|
182
|
+
* @returns specified spore cells
|
|
183
|
+
*/
|
|
184
|
+
export async function* findSpores(params) {
|
|
185
|
+
const { client, lock, clusterId, scriptInfos, limit, order } = params;
|
|
186
|
+
for (const scriptInfo of scriptInfos ??
|
|
187
|
+
Object.values(getSporeScriptInfos(client))) {
|
|
188
|
+
if (!scriptInfo) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
for await (const spore of client.findCells({
|
|
192
|
+
script: {
|
|
193
|
+
...scriptInfo,
|
|
194
|
+
args: [],
|
|
195
|
+
},
|
|
196
|
+
scriptType: "type",
|
|
197
|
+
scriptSearchMode: "prefix",
|
|
198
|
+
withData: true,
|
|
199
|
+
filter: lock
|
|
200
|
+
? {
|
|
201
|
+
script: lock,
|
|
202
|
+
}
|
|
203
|
+
: undefined,
|
|
204
|
+
}, order, limit)) {
|
|
205
|
+
const sporeData = unpackToRawSporeData(spore.outputData);
|
|
206
|
+
if (!clusterId ||
|
|
207
|
+
(clusterId === "" && !sporeData.clusterId) ||
|
|
208
|
+
sporeData.clusterId === ccc.hexFrom(clusterId)) {
|
|
209
|
+
yield {
|
|
210
|
+
cell: spore,
|
|
211
|
+
spore,
|
|
212
|
+
sporeData,
|
|
213
|
+
scriptInfo: SporeScriptInfo.from(scriptInfo),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
39
|
exports.sporeA = void 0;
|
|
30
40
|
__exportStar(require("./advancedBarrel.js"), exports);
|