@ckb-ccc/spore 0.1.0-alpha.4 → 0.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 +22 -0
- package/dist/cluster/index.d.ts +17 -2
- package/dist/cluster/index.d.ts.map +1 -1
- package/dist/cluster/index.js +40 -1
- package/dist/cobuild/index.d.ts +10 -11
- package/dist/cobuild/index.d.ts.map +1 -1
- package/dist/cobuild/index.js +17 -17
- package/dist/codec/cluster.d.ts +17 -24
- package/dist/codec/cluster.d.ts.map +1 -1
- package/dist/codec/cluster.js +17 -28
- package/dist/codec/cobuild/buildingPacket.d.ts +258 -455
- package/dist/codec/cobuild/buildingPacket.d.ts.map +1 -1
- package/dist/codec/cobuild/buildingPacket.js +27 -38
- package/dist/codec/cobuild/sporeAction.d.ts +532 -257
- package/dist/codec/cobuild/sporeAction.d.ts.map +1 -1
- package/dist/codec/cobuild/sporeAction.js +45 -59
- package/dist/codec/cobuild/witnessLayout.d.ts +113 -30
- package/dist/codec/cobuild/witnessLayout.d.ts.map +1 -1
- package/dist/codec/cobuild/witnessLayout.js +10 -11
- package/dist/codec/spore.d.ts +5 -10
- package/dist/codec/spore.d.ts.map +1 -1
- package/dist/codec/spore.js +9 -17
- package/dist/spore/advanced.d.ts +3 -4
- package/dist/spore/advanced.d.ts.map +1 -1
- package/dist/spore/index.d.ts +20 -2
- package/dist/spore/index.d.ts.map +1 -1
- package/dist/spore/index.js +44 -1
- package/dist.commonjs/cluster/index.d.ts +17 -2
- package/dist.commonjs/cluster/index.d.ts.map +1 -1
- package/dist.commonjs/cluster/index.js +40 -0
- package/dist.commonjs/cobuild/index.d.ts +10 -11
- package/dist.commonjs/cobuild/index.d.ts.map +1 -1
- package/dist.commonjs/cobuild/index.js +17 -17
- package/dist.commonjs/codec/cluster.d.ts +17 -24
- package/dist.commonjs/codec/cluster.d.ts.map +1 -1
- package/dist.commonjs/codec/cluster.js +17 -28
- package/dist.commonjs/codec/cobuild/buildingPacket.d.ts +258 -455
- package/dist.commonjs/codec/cobuild/buildingPacket.d.ts.map +1 -1
- package/dist.commonjs/codec/cobuild/buildingPacket.js +27 -38
- package/dist.commonjs/codec/cobuild/sporeAction.d.ts +532 -257
- package/dist.commonjs/codec/cobuild/sporeAction.d.ts.map +1 -1
- package/dist.commonjs/codec/cobuild/sporeAction.js +45 -59
- package/dist.commonjs/codec/cobuild/witnessLayout.d.ts +113 -30
- package/dist.commonjs/codec/cobuild/witnessLayout.d.ts.map +1 -1
- package/dist.commonjs/codec/cobuild/witnessLayout.js +10 -11
- package/dist.commonjs/codec/spore.d.ts +5 -10
- package/dist.commonjs/codec/spore.d.ts.map +1 -1
- package/dist.commonjs/codec/spore.js +9 -17
- package/dist.commonjs/spore/advanced.d.ts +3 -4
- package/dist.commonjs/spore/advanced.d.ts.map +1 -1
- package/dist.commonjs/spore/index.d.ts +20 -2
- package/dist.commonjs/spore/index.d.ts.map +1 -1
- package/dist.commonjs/spore/index.js +44 -0
- package/package.json +5 -6
- package/src/cluster/index.ts +59 -2
- package/src/cobuild/index.ts +27 -28
- package/src/codec/cluster.ts +51 -56
- package/src/codec/cobuild/buildingPacket.ts +41 -72
- package/src/codec/cobuild/sporeAction.ts +75 -129
- package/src/codec/cobuild/witnessLayout.ts +12 -18
- package/src/codec/spore.ts +18 -27
- package/src/spore/advanced.ts +4 -5
- package/src/spore/index.ts +58 -2
- package/dist/codec/base.d.ts +0 -6
- package/dist/codec/base.d.ts.map +0 -1
- package/dist/codec/base.js +0 -10
- package/dist.commonjs/codec/base.d.ts +0 -6
- package/dist.commonjs/codec/base.d.ts.map +0 -1
- package/dist.commonjs/codec/base.js +0 -13
- package/src/codec/base.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @ckb-ccc/spore
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#74](https://github.com/ckb-devrel/ccc/pull/74) [`f21d7e4`](https://github.com/ckb-devrel/ccc/commit/f21d7e4cf422edab4a836ef6d678b620594fef8d) Thanks [@Hanssen0](https://github.com/Hanssen0)! - add spore package and some known scripts
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#88](https://github.com/ckb-devrel/ccc/pull/88) [`f07a506`](https://github.com/ckb-devrel/ccc/commit/f07a506bd6fc27fe659a17d2f7baaeec54716d81) Thanks [@ashuralyk](https://github.com/ashuralyk)! - feat: molecule codec
|
|
12
|
+
feat: spore searcher
|
|
13
|
+
- Updated dependencies [[`a3d5359`](https://github.com/ckb-devrel/ccc/commit/a3d53595f6dd11f2f59cdf0086b3d7ce558a2fdd), [`8824ff2`](https://github.com/ckb-devrel/ccc/commit/8824ff27af3b76186f1a7d6db8c907cd66f09d6a), [`f07a506`](https://github.com/ckb-devrel/ccc/commit/f07a506bd6fc27fe659a17d2f7baaeec54716d81), [`f21d7e4`](https://github.com/ckb-devrel/ccc/commit/f21d7e4cf422edab4a836ef6d678b620594fef8d), [`acfc050`](https://github.com/ckb-devrel/ccc/commit/acfc0502cd6beb48b9310dec8411dcd630507366), [`1720d5a`](https://github.com/ckb-devrel/ccc/commit/1720d5a398543f1c6e24763eeaf15d84cd2214bf), [`e63a06e`](https://github.com/ckb-devrel/ccc/commit/e63a06ee75ac8595208d216dec88a4228c465e23), [`c092988`](https://github.com/ckb-devrel/ccc/commit/c092988e7765b9ac79498d6bd72a6a2f62859b6f), [`50f2ce0`](https://github.com/ckb-devrel/ccc/commit/50f2ce08e74cb3fbeae926267d42e28b426fd7f4), [`4709384`](https://github.com/ckb-devrel/ccc/commit/4709384e37188991cb937b16f99f47ca82c912b8)]:
|
|
14
|
+
- @ckb-ccc/core@0.1.0
|
|
15
|
+
|
|
16
|
+
## 0.1.0-alpha.5
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#88](https://github.com/ckb-devrel/ccc/pull/88) [`f07a506`](https://github.com/ckb-devrel/ccc/commit/f07a506bd6fc27fe659a17d2f7baaeec54716d81) Thanks [@ashuralyk](https://github.com/ashuralyk)! - feat: molecule codec
|
|
21
|
+
feat: spore searcher
|
|
22
|
+
- Updated dependencies [[`f07a506`](https://github.com/ckb-devrel/ccc/commit/f07a506bd6fc27fe659a17d2f7baaeec54716d81)]:
|
|
23
|
+
- @ckb-ccc/core@0.1.0-alpha.7
|
|
24
|
+
|
|
3
25
|
## 0.1.0-alpha.4
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/cluster/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import {
|
|
2
|
+
import { ClusterDataView } from "../codec/index.js";
|
|
3
3
|
import { SporeScriptInfo, SporeScriptInfoLike } from "../predefined/index.js";
|
|
4
4
|
export declare function findCluster(client: ccc.Client, args: ccc.HexLike, scripts?: SporeScriptInfoLike[]): Promise<{
|
|
5
5
|
cell: ccc.Cell;
|
|
@@ -24,7 +24,7 @@ export declare function assertCluster(client: ccc.Client, args: ccc.HexLike, scr
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function createSporeCluster(params: {
|
|
26
26
|
signer: ccc.Signer;
|
|
27
|
-
data:
|
|
27
|
+
data: ClusterDataView;
|
|
28
28
|
to?: ccc.ScriptLike;
|
|
29
29
|
tx?: ccc.TransactionLike;
|
|
30
30
|
scriptInfo?: SporeScriptInfoLike;
|
|
@@ -53,4 +53,19 @@ export declare function transferSporeCluster(params: {
|
|
|
53
53
|
}): Promise<{
|
|
54
54
|
tx: ccc.Transaction;
|
|
55
55
|
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Search on-chain clusters under the signer's control
|
|
58
|
+
*
|
|
59
|
+
* @param signer the owner of clusters
|
|
60
|
+
* @param order the order in creation time of clusters
|
|
61
|
+
* @param scriptInfos the deployed script infos of clusters
|
|
62
|
+
*/
|
|
63
|
+
export declare function findSporeClustersBySigner(params: {
|
|
64
|
+
signer: ccc.Signer;
|
|
65
|
+
order?: "asc" | "desc";
|
|
66
|
+
scriptInfos?: SporeScriptInfoLike[];
|
|
67
|
+
}): AsyncGenerator<{
|
|
68
|
+
cluster: ccc.Cell;
|
|
69
|
+
clusterData: ClusterDataView;
|
|
70
|
+
}>;
|
|
56
71
|
//# 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,
|
|
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;AAK3B,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,CAAC;IACT,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC,CAQD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;IACpB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC;IACzB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CAC9B,GAAG,OAAO,CAAC;IACV,EAAE,EAAE,GAAG,CAAC,WAAW,CAAC;IACpB,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC;CACb,CAAC,CA0CD;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,6 +1,6 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { assembleCreateClusterAction, assembleTransferClusterAction, prepareSporeTransaction, } from "../advanced.js";
|
|
3
|
-
import { packRawClusterData } from "../codec/index.js";
|
|
3
|
+
import { ClusterData, ClusterDataV1, packRawClusterData, } from "../codec/index.js";
|
|
4
4
|
import { findSingletonCellByArgs, injectOneCapacityCell, } from "../helper/index.js";
|
|
5
5
|
import { getClusterScriptInfo, getClusterScriptInfos, } from "../predefined/index.js";
|
|
6
6
|
export async function findCluster(client, args, scripts) {
|
|
@@ -94,3 +94,42 @@ export async function transferSporeCluster(params) {
|
|
|
94
94
|
tx: await prepareSporeTransaction(signer, tx, actions),
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Search on-chain clusters under the signer's control
|
|
99
|
+
*
|
|
100
|
+
* @param signer the owner of clusters
|
|
101
|
+
* @param order the order in creation time of clusters
|
|
102
|
+
* @param scriptInfos the deployed script infos of clusters
|
|
103
|
+
*/
|
|
104
|
+
export async function* findSporeClustersBySigner(params) {
|
|
105
|
+
const { signer, order, scriptInfos } = params;
|
|
106
|
+
for (const scriptInfo of scriptInfos ??
|
|
107
|
+
Object.values(getClusterScriptInfos(signer.client))) {
|
|
108
|
+
if (!scriptInfo) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
for await (const cluster of signer.findCells({
|
|
112
|
+
script: {
|
|
113
|
+
...scriptInfo,
|
|
114
|
+
args: [],
|
|
115
|
+
},
|
|
116
|
+
}, true, order, 10)) {
|
|
117
|
+
let clusterData;
|
|
118
|
+
try {
|
|
119
|
+
clusterData = ClusterData.decode(cluster.outputData);
|
|
120
|
+
}
|
|
121
|
+
catch (_) {
|
|
122
|
+
try {
|
|
123
|
+
clusterData = ClusterDataV1.decode(cluster.outputData);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
throw new Error(`Cluster data decode failed: ${e.toString()}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
yield {
|
|
130
|
+
cluster,
|
|
131
|
+
clusterData,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
package/dist/cobuild/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { UnpackResult } from "@ckb-lumos/codec";
|
|
1
|
+
import { ccc, mol } from "@ckb-ccc/core";
|
|
3
2
|
import { Action, ActionVec, WitnessLayout } from "../codec/index.js";
|
|
4
|
-
export declare function assembleCreateSporeAction(sporeOutput: ccc.CellOutputLike, sporeData: ccc.BytesLike, scriptInfoHash?: ccc.HexLike):
|
|
5
|
-
export declare function assembleTransferSporeAction(sporeInput: ccc.CellOutputLike, sporeOutput: ccc.CellOutputLike, scriptInfoHash?: ccc.HexLike):
|
|
6
|
-
export declare function assembleMeltSporeAction(sporeInput: ccc.CellOutputLike, scriptInfoHash?: ccc.HexLike):
|
|
7
|
-
export declare function assembleCreateClusterAction(clusterOutput: ccc.CellOutputLike, clusterData: ccc.BytesLike, scriptInfoHash?: ccc.HexLike):
|
|
8
|
-
export declare function assembleTransferClusterAction(clusterInput: ccc.CellOutputLike, clusterOutput: ccc.CellOutputLike, scriptInfoHash?: ccc.HexLike):
|
|
9
|
-
export declare function prepareSporeTransaction(signer: ccc.Signer, txLike: ccc.TransactionLike, actions:
|
|
10
|
-
export declare function unpackCommonCobuildProof(data: ccc.HexLike):
|
|
11
|
-
export declare function extractCobuildActionsFromTx(tx: ccc.Transaction):
|
|
12
|
-
export declare function injectCobuild(tx: ccc.Transaction, actions:
|
|
3
|
+
export declare function assembleCreateSporeAction(sporeOutput: ccc.CellOutputLike, sporeData: ccc.BytesLike, scriptInfoHash?: ccc.HexLike): mol.EncodableType<typeof Action>;
|
|
4
|
+
export declare function assembleTransferSporeAction(sporeInput: ccc.CellOutputLike, sporeOutput: ccc.CellOutputLike, scriptInfoHash?: ccc.HexLike): mol.EncodableType<typeof Action>;
|
|
5
|
+
export declare function assembleMeltSporeAction(sporeInput: ccc.CellOutputLike, scriptInfoHash?: ccc.HexLike): mol.EncodableType<typeof Action>;
|
|
6
|
+
export declare function assembleCreateClusterAction(clusterOutput: ccc.CellOutputLike, clusterData: ccc.BytesLike, scriptInfoHash?: ccc.HexLike): mol.EncodableType<typeof Action>;
|
|
7
|
+
export declare function assembleTransferClusterAction(clusterInput: ccc.CellOutputLike, clusterOutput: ccc.CellOutputLike, scriptInfoHash?: ccc.HexLike): mol.EncodableType<typeof Action>;
|
|
8
|
+
export declare function prepareSporeTransaction(signer: ccc.Signer, txLike: ccc.TransactionLike, actions: mol.EncodableType<typeof ActionVec>): Promise<ccc.Transaction>;
|
|
9
|
+
export declare function unpackCommonCobuildProof(data: ccc.HexLike): mol.EncodableType<typeof WitnessLayout> | undefined;
|
|
10
|
+
export declare function extractCobuildActionsFromTx(tx: ccc.Transaction): mol.EncodableType<typeof ActionVec>;
|
|
11
|
+
export declare function injectCobuild(tx: ccc.Transaction, actions: mol.EncodableType<typeof ActionVec>): void;
|
|
13
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cobuild/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cobuild/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,MAAM,EACN,SAAS,EAET,aAAa,EACd,MAAM,mBAAmB,CAAC;AAG3B,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,GAAG,CAAC,cAAc,EAC/B,SAAS,EAAE,GAAG,CAAC,SAAS,EACxB,cAAc,GAAE,GAAG,CAAC,OAAmC,GACtD,GAAG,CAAC,aAAa,CAAC,OAAO,MAAM,CAAC,CAsBlC;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,GAAG,CAAC,cAAc,EAC9B,WAAW,EAAE,GAAG,CAAC,cAAc,E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GED
|
@@ -7,15 +7,15 @@ export function assembleCreateSporeAction(sporeOutput, sporeData, scriptInfoHash
|
|
|
7
7
|
}
|
|
8
8
|
const sporeType = ccc.Script.from(sporeOutput.type);
|
|
9
9
|
const sporeTypeHash = sporeType.hash();
|
|
10
|
-
const actionData = SporeAction.
|
|
10
|
+
const actionData = SporeAction.encode({
|
|
11
11
|
type: "CreateSpore",
|
|
12
12
|
value: {
|
|
13
13
|
sporeId: sporeType.args,
|
|
14
|
-
dataHash: ccc.hashCkb(sporeData),
|
|
15
14
|
to: {
|
|
16
15
|
type: "Script",
|
|
17
|
-
value:
|
|
16
|
+
value: sporeOutput.lock,
|
|
18
17
|
},
|
|
18
|
+
dataHash: ccc.hashCkb(sporeData),
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
21
|
return {
|
|
@@ -30,17 +30,17 @@ export function assembleTransferSporeAction(sporeInput, sporeOutput, scriptInfoH
|
|
|
30
30
|
}
|
|
31
31
|
const sporeType = ccc.Script.from(sporeOutput.type);
|
|
32
32
|
const sporeTypeHash = sporeType.hash();
|
|
33
|
-
const actionData = SporeAction.
|
|
33
|
+
const actionData = SporeAction.encode({
|
|
34
34
|
type: "TransferSpore",
|
|
35
35
|
value: {
|
|
36
36
|
sporeId: sporeType.args,
|
|
37
37
|
from: {
|
|
38
38
|
type: "Script",
|
|
39
|
-
value:
|
|
39
|
+
value: sporeInput.lock,
|
|
40
40
|
},
|
|
41
41
|
to: {
|
|
42
42
|
type: "Script",
|
|
43
|
-
value:
|
|
43
|
+
value: sporeOutput.lock,
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
});
|
|
@@ -56,13 +56,13 @@ export function assembleMeltSporeAction(sporeInput, scriptInfoHash = DEFAULT_COB
|
|
|
56
56
|
}
|
|
57
57
|
const sporeType = ccc.Script.from(sporeInput.type);
|
|
58
58
|
const sporeTypeHash = sporeType.hash();
|
|
59
|
-
const actionData = SporeAction.
|
|
59
|
+
const actionData = SporeAction.encode({
|
|
60
60
|
type: "MeltSpore",
|
|
61
61
|
value: {
|
|
62
62
|
sporeId: sporeType.args,
|
|
63
63
|
from: {
|
|
64
64
|
type: "Script",
|
|
65
|
-
value:
|
|
65
|
+
value: sporeInput.lock,
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
});
|
|
@@ -78,15 +78,15 @@ export function assembleCreateClusterAction(clusterOutput, clusterData, scriptIn
|
|
|
78
78
|
}
|
|
79
79
|
const clusterType = ccc.Script.from(clusterOutput.type);
|
|
80
80
|
const clusterTypeHash = clusterType.hash();
|
|
81
|
-
const actionData = SporeAction.
|
|
81
|
+
const actionData = SporeAction.encode({
|
|
82
82
|
type: "CreateCluster",
|
|
83
83
|
value: {
|
|
84
84
|
clusterId: clusterType.args,
|
|
85
|
-
dataHash: ccc.hashCkb(clusterData),
|
|
86
85
|
to: {
|
|
87
86
|
type: "Script",
|
|
88
|
-
value:
|
|
87
|
+
value: clusterOutput.lock,
|
|
89
88
|
},
|
|
89
|
+
dataHash: ccc.hashCkb(clusterData),
|
|
90
90
|
},
|
|
91
91
|
});
|
|
92
92
|
return {
|
|
@@ -101,17 +101,17 @@ export function assembleTransferClusterAction(clusterInput, clusterOutput, scrip
|
|
|
101
101
|
}
|
|
102
102
|
const clusterType = ccc.Script.from(clusterOutput.type);
|
|
103
103
|
const clusterTypeHash = clusterType.hash();
|
|
104
|
-
const actionData = SporeAction.
|
|
104
|
+
const actionData = SporeAction.encode({
|
|
105
105
|
type: "TransferCluster",
|
|
106
106
|
value: {
|
|
107
107
|
clusterId: clusterType.args,
|
|
108
108
|
from: {
|
|
109
109
|
type: "Script",
|
|
110
|
-
value:
|
|
110
|
+
value: clusterInput.lock,
|
|
111
111
|
},
|
|
112
112
|
to: {
|
|
113
113
|
type: "Script",
|
|
114
|
-
value:
|
|
114
|
+
value: clusterOutput.lock,
|
|
115
115
|
},
|
|
116
116
|
},
|
|
117
117
|
});
|
|
@@ -133,7 +133,7 @@ export async function prepareSporeTransaction(signer, txLike, actions) {
|
|
|
133
133
|
}
|
|
134
134
|
export function unpackCommonCobuildProof(data) {
|
|
135
135
|
try {
|
|
136
|
-
return WitnessLayout.
|
|
136
|
+
return WitnessLayout.decode(ccc.bytesFrom(data));
|
|
137
137
|
}
|
|
138
138
|
catch {
|
|
139
139
|
return;
|
|
@@ -148,14 +148,14 @@ export function extractCobuildActionsFromTx(tx) {
|
|
|
148
148
|
return [];
|
|
149
149
|
}
|
|
150
150
|
if (witnessLayout.type !== "SighashAll") {
|
|
151
|
-
throw new Error("Invalid cobuild proof type: "
|
|
151
|
+
throw new Error("Invalid cobuild proof type: SighashAll");
|
|
152
152
|
}
|
|
153
153
|
// Remove existed cobuild witness
|
|
154
154
|
tx.witnesses.pop();
|
|
155
155
|
return witnessLayout.value.message.actions;
|
|
156
156
|
}
|
|
157
157
|
export function injectCobuild(tx, actions) {
|
|
158
|
-
const witnessLayout = ccc.hexFrom(WitnessLayout.
|
|
158
|
+
const witnessLayout = ccc.hexFrom(WitnessLayout.encode({
|
|
159
159
|
type: "SighashAll",
|
|
160
160
|
value: {
|
|
161
161
|
seal: "0x",
|
package/dist/codec/cluster.d.ts
CHANGED
|
@@ -1,41 +1,34 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
|
|
3
|
-
export declare const MolClusterDataV1: molecule.ObjectLayoutCodec<{
|
|
4
|
-
name: import("@ckb-lumos/codec/lib/base.js").BytesCodec<string, string>;
|
|
5
|
-
description: import("@ckb-lumos/codec/lib/base.js").BytesCodec<string, string>;
|
|
6
|
-
}>;
|
|
7
|
-
export declare const MolClusterDataV2: molecule.ObjectLayoutCodec<{
|
|
8
|
-
name: import("@ckb-lumos/codec/lib/base.js").BytesCodec<string, string>;
|
|
9
|
-
description: import("@ckb-lumos/codec/lib/base.js").BytesCodec<string, string>;
|
|
10
|
-
mutantId: molecule.OptionLayoutCodec<import("@ckb-lumos/codec/lib/base.js").BytesCodec<string, import("@ckb-lumos/codec").BytesLike>>;
|
|
11
|
-
}>;
|
|
12
|
-
export interface ClusterDataV1 {
|
|
1
|
+
import { ccc, mol } from "@ckb-ccc/core";
|
|
2
|
+
export interface ClusterDataV1View {
|
|
13
3
|
name: string;
|
|
14
4
|
description: string;
|
|
15
5
|
}
|
|
16
|
-
export
|
|
6
|
+
export declare const ClusterDataV1: mol.Codec<ClusterDataV1View>;
|
|
7
|
+
export interface ClusterDataV2View {
|
|
17
8
|
name: string;
|
|
18
9
|
description: string;
|
|
19
10
|
mutantId?: ccc.HexLike;
|
|
20
11
|
}
|
|
21
|
-
export
|
|
12
|
+
export declare const ClusterDataV2: mol.Codec<ClusterDataV2View>;
|
|
13
|
+
export type ClusterDataView = ClusterDataV2View;
|
|
22
14
|
export type ClusterDataVersion = "v1" | "v2";
|
|
15
|
+
export declare const ClusterData: ccc.mol.Codec<ClusterDataV2View, ClusterDataV2View>;
|
|
23
16
|
/**
|
|
24
17
|
* Pack RawClusterData to Uint8Array.
|
|
25
18
|
* Pass an optional "version" field to select a specific packing version.
|
|
26
19
|
*/
|
|
27
|
-
export declare function packRawClusterData(packable:
|
|
28
|
-
export declare function packRawClusterData(packable:
|
|
29
|
-
export declare function packRawClusterData(packable:
|
|
30
|
-
export declare function packRawClusterDataV1(packable:
|
|
31
|
-
export declare function packRawClusterDataV2(packable:
|
|
20
|
+
export declare function packRawClusterData(packable: ClusterDataView): Uint8Array;
|
|
21
|
+
export declare function packRawClusterData(packable: ClusterDataV1View, version: "v1"): Uint8Array;
|
|
22
|
+
export declare function packRawClusterData(packable: ClusterDataV2View, version: "v2"): Uint8Array;
|
|
23
|
+
export declare function packRawClusterDataV1(packable: ClusterDataV1View): Uint8Array;
|
|
24
|
+
export declare function packRawClusterDataV2(packable: ClusterDataV2View): Uint8Array;
|
|
32
25
|
/**
|
|
33
26
|
* Unpack Hex/Bytes to RawClusterData.
|
|
34
27
|
* Pass an optional "version" field to select a specific unpacking version.
|
|
35
28
|
*/
|
|
36
|
-
export declare function unpackToRawClusterData(unpackable: ccc.BytesLike):
|
|
37
|
-
export declare function unpackToRawClusterData(unpackable: ccc.BytesLike, version: "v1"):
|
|
38
|
-
export declare function unpackToRawClusterData(unpackable: ccc.BytesLike, version: "v2"):
|
|
39
|
-
export declare function unpackToRawClusterDataV1(unpackable: ccc.BytesLike):
|
|
40
|
-
export declare function unpackToRawClusterDataV2(unpackable: ccc.BytesLike):
|
|
29
|
+
export declare function unpackToRawClusterData(unpackable: ccc.BytesLike): ClusterDataView;
|
|
30
|
+
export declare function unpackToRawClusterData(unpackable: ccc.BytesLike, version: "v1"): ClusterDataV1View;
|
|
31
|
+
export declare function unpackToRawClusterData(unpackable: ccc.BytesLike, version: "v2"): ClusterDataV2View;
|
|
32
|
+
export declare function unpackToRawClusterDataV1(unpackable: ccc.BytesLike): ClusterDataV1View;
|
|
33
|
+
export declare function unpackToRawClusterDataV2(unpackable: ccc.BytesLike): ClusterDataV2View;
|
|
41
34
|
//# sourceMappingURL=cluster.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster.d.ts","sourceRoot":"","sources":["../../src/codec/cluster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"cluster.d.ts","sourceRoot":"","sources":["../../src/codec/cluster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAGrD,CAAC;AAEH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,aAAa,E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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
mutantId: blockchain.BytesOpt,
|
|
13
|
-
}, ["name", "description", "mutantId"]);
|
|
1
|
+
import { ccc, mol } from "@ckb-ccc/core";
|
|
2
|
+
export const ClusterDataV1 = mol.table({
|
|
3
|
+
name: mol.String,
|
|
4
|
+
description: mol.String,
|
|
5
|
+
});
|
|
6
|
+
export const ClusterDataV2 = mol.table({
|
|
7
|
+
name: mol.String,
|
|
8
|
+
description: mol.String,
|
|
9
|
+
mutantId: mol.BytesOpt,
|
|
10
|
+
});
|
|
11
|
+
export const ClusterData = ClusterDataV2;
|
|
14
12
|
export function packRawClusterData(packable, version) {
|
|
15
13
|
if (!version) {
|
|
16
14
|
return packRawClusterDataV2(packable);
|
|
@@ -23,17 +21,17 @@ export function packRawClusterData(packable, version) {
|
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
export function packRawClusterDataV1(packable) {
|
|
26
|
-
return
|
|
24
|
+
return ccc.bytesFrom(ClusterDataV1.encode({
|
|
27
25
|
name: packable.name,
|
|
28
26
|
description: packable.description,
|
|
29
|
-
});
|
|
27
|
+
}));
|
|
30
28
|
}
|
|
31
29
|
export function packRawClusterDataV2(packable) {
|
|
32
|
-
return
|
|
30
|
+
return ccc.bytesFrom(ClusterDataV2.encode({
|
|
33
31
|
name: packable.name,
|
|
34
32
|
description: packable.description,
|
|
35
33
|
mutantId: packable.mutantId,
|
|
36
|
-
});
|
|
34
|
+
}));
|
|
37
35
|
}
|
|
38
36
|
export function unpackToRawClusterData(unpackable, version) {
|
|
39
37
|
if (version) {
|
|
@@ -57,17 +55,8 @@ export function unpackToRawClusterData(unpackable, version) {
|
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
export function unpackToRawClusterDataV1(unpackable) {
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
name: decoded.name,
|
|
63
|
-
description: decoded.description,
|
|
64
|
-
};
|
|
58
|
+
return ClusterDataV1.decode(unpackable);
|
|
65
59
|
}
|
|
66
60
|
export function unpackToRawClusterDataV2(unpackable) {
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
name: decoded.name,
|
|
70
|
-
description: decoded.description,
|
|
71
|
-
mutantId: ccc.apply(ccc.hexFrom, decoded.mutantId),
|
|
72
|
-
};
|
|
61
|
+
return ClusterDataV2.decode(unpackable);
|
|
73
62
|
}
|