@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.
Files changed (70) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cluster/index.d.ts +17 -2
  3. package/dist/cluster/index.d.ts.map +1 -1
  4. package/dist/cluster/index.js +40 -1
  5. package/dist/cobuild/index.d.ts +10 -11
  6. package/dist/cobuild/index.d.ts.map +1 -1
  7. package/dist/cobuild/index.js +17 -17
  8. package/dist/codec/cluster.d.ts +17 -24
  9. package/dist/codec/cluster.d.ts.map +1 -1
  10. package/dist/codec/cluster.js +17 -28
  11. package/dist/codec/cobuild/buildingPacket.d.ts +258 -455
  12. package/dist/codec/cobuild/buildingPacket.d.ts.map +1 -1
  13. package/dist/codec/cobuild/buildingPacket.js +27 -38
  14. package/dist/codec/cobuild/sporeAction.d.ts +532 -257
  15. package/dist/codec/cobuild/sporeAction.d.ts.map +1 -1
  16. package/dist/codec/cobuild/sporeAction.js +45 -59
  17. package/dist/codec/cobuild/witnessLayout.d.ts +113 -30
  18. package/dist/codec/cobuild/witnessLayout.d.ts.map +1 -1
  19. package/dist/codec/cobuild/witnessLayout.js +10 -11
  20. package/dist/codec/spore.d.ts +5 -10
  21. package/dist/codec/spore.d.ts.map +1 -1
  22. package/dist/codec/spore.js +9 -17
  23. package/dist/spore/advanced.d.ts +3 -4
  24. package/dist/spore/advanced.d.ts.map +1 -1
  25. package/dist/spore/index.d.ts +20 -2
  26. package/dist/spore/index.d.ts.map +1 -1
  27. package/dist/spore/index.js +44 -1
  28. package/dist.commonjs/cluster/index.d.ts +17 -2
  29. package/dist.commonjs/cluster/index.d.ts.map +1 -1
  30. package/dist.commonjs/cluster/index.js +40 -0
  31. package/dist.commonjs/cobuild/index.d.ts +10 -11
  32. package/dist.commonjs/cobuild/index.d.ts.map +1 -1
  33. package/dist.commonjs/cobuild/index.js +17 -17
  34. package/dist.commonjs/codec/cluster.d.ts +17 -24
  35. package/dist.commonjs/codec/cluster.d.ts.map +1 -1
  36. package/dist.commonjs/codec/cluster.js +17 -28
  37. package/dist.commonjs/codec/cobuild/buildingPacket.d.ts +258 -455
  38. package/dist.commonjs/codec/cobuild/buildingPacket.d.ts.map +1 -1
  39. package/dist.commonjs/codec/cobuild/buildingPacket.js +27 -38
  40. package/dist.commonjs/codec/cobuild/sporeAction.d.ts +532 -257
  41. package/dist.commonjs/codec/cobuild/sporeAction.d.ts.map +1 -1
  42. package/dist.commonjs/codec/cobuild/sporeAction.js +45 -59
  43. package/dist.commonjs/codec/cobuild/witnessLayout.d.ts +113 -30
  44. package/dist.commonjs/codec/cobuild/witnessLayout.d.ts.map +1 -1
  45. package/dist.commonjs/codec/cobuild/witnessLayout.js +10 -11
  46. package/dist.commonjs/codec/spore.d.ts +5 -10
  47. package/dist.commonjs/codec/spore.d.ts.map +1 -1
  48. package/dist.commonjs/codec/spore.js +9 -17
  49. package/dist.commonjs/spore/advanced.d.ts +3 -4
  50. package/dist.commonjs/spore/advanced.d.ts.map +1 -1
  51. package/dist.commonjs/spore/index.d.ts +20 -2
  52. package/dist.commonjs/spore/index.d.ts.map +1 -1
  53. package/dist.commonjs/spore/index.js +44 -0
  54. package/package.json +5 -6
  55. package/src/cluster/index.ts +59 -2
  56. package/src/cobuild/index.ts +27 -28
  57. package/src/codec/cluster.ts +51 -56
  58. package/src/codec/cobuild/buildingPacket.ts +41 -72
  59. package/src/codec/cobuild/sporeAction.ts +75 -129
  60. package/src/codec/cobuild/witnessLayout.ts +12 -18
  61. package/src/codec/spore.ts +18 -27
  62. package/src/spore/advanced.ts +4 -5
  63. package/src/spore/index.ts +58 -2
  64. package/dist/codec/base.d.ts +0 -6
  65. package/dist/codec/base.d.ts.map +0 -1
  66. package/dist/codec/base.js +0 -10
  67. package/dist.commonjs/codec/base.d.ts +0 -6
  68. package/dist.commonjs/codec/base.d.ts.map +0 -1
  69. package/dist.commonjs/codec/base.js +0 -13
  70. package/src/codec/base.ts +0 -11
@@ -4,7 +4,12 @@ import {
4
4
  assembleTransferClusterAction,
5
5
  prepareSporeTransaction,
6
6
  } from "../advanced.js";
7
- import { ClusterData, packRawClusterData } from "../codec/index.js";
7
+ import {
8
+ ClusterData,
9
+ ClusterDataV1,
10
+ ClusterDataView,
11
+ packRawClusterData,
12
+ } from "../codec/index.js";
8
13
  import {
9
14
  findSingletonCellByArgs,
10
15
  injectOneCapacityCell,
@@ -66,7 +71,7 @@ export async function assertCluster(
66
71
  */
67
72
  export async function createSporeCluster(params: {
68
73
  signer: ccc.Signer;
69
- data: ClusterData;
74
+ data: ClusterDataView;
70
75
  to?: ccc.ScriptLike;
71
76
  tx?: ccc.TransactionLike;
72
77
  scriptInfo?: SporeScriptInfoLike;
@@ -178,3 +183,55 @@ export async function transferSporeCluster(params: {
178
183
  tx: await prepareSporeTransaction(signer, tx, actions),
179
184
  };
180
185
  }
186
+
187
+ /**
188
+ * Search on-chain clusters under the signer's control
189
+ *
190
+ * @param signer the owner of clusters
191
+ * @param order the order in creation time of clusters
192
+ * @param scriptInfos the deployed script infos of clusters
193
+ */
194
+ export async function* findSporeClustersBySigner(params: {
195
+ signer: ccc.Signer;
196
+ order?: "asc" | "desc";
197
+ scriptInfos?: SporeScriptInfoLike[];
198
+ }): AsyncGenerator<{
199
+ cluster: ccc.Cell;
200
+ clusterData: ClusterDataView;
201
+ }> {
202
+ const { signer, order, scriptInfos } = params;
203
+ for (const scriptInfo of scriptInfos ??
204
+ Object.values(getClusterScriptInfos(signer.client))) {
205
+ if (!scriptInfo) {
206
+ continue;
207
+ }
208
+ for await (const cluster of signer.findCells(
209
+ {
210
+ script: {
211
+ ...scriptInfo,
212
+ args: [],
213
+ },
214
+ },
215
+ true,
216
+ order,
217
+ 10,
218
+ )) {
219
+ let clusterData: ClusterDataView;
220
+ try {
221
+ clusterData = ClusterData.decode(cluster.outputData);
222
+ } catch (_) {
223
+ try {
224
+ clusterData = ClusterDataV1.decode(cluster.outputData);
225
+ } catch (e: unknown) {
226
+ throw new Error(
227
+ `Cluster data decode failed: ${(e as Error).toString()}`,
228
+ );
229
+ }
230
+ }
231
+ yield {
232
+ cluster,
233
+ clusterData,
234
+ };
235
+ }
236
+ }
237
+ }
@@ -1,5 +1,4 @@
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 {
4
3
  Action,
5
4
  ActionVec,
@@ -12,21 +11,21 @@ export function assembleCreateSporeAction(
12
11
  sporeOutput: ccc.CellOutputLike,
13
12
  sporeData: ccc.BytesLike,
14
13
  scriptInfoHash: ccc.HexLike = DEFAULT_COBUILD_INFO_HASH,
15
- ): UnpackResult<typeof Action> {
14
+ ): mol.EncodableType<typeof Action> {
16
15
  if (!sporeOutput.type) {
17
16
  throw new Error("Spore cell must have a type script");
18
17
  }
19
18
  const sporeType = ccc.Script.from(sporeOutput.type);
20
19
  const sporeTypeHash = sporeType.hash();
21
- const actionData = SporeAction.pack({
20
+ const actionData = SporeAction.encode({
22
21
  type: "CreateSpore",
23
22
  value: {
24
23
  sporeId: sporeType.args,
25
- dataHash: ccc.hashCkb(sporeData),
26
24
  to: {
27
25
  type: "Script",
28
- value: ccc.Script.from(sporeOutput.lock),
26
+ value: sporeOutput.lock,
29
27
  },
28
+ dataHash: ccc.hashCkb(sporeData),
30
29
  },
31
30
  });
32
31
  return {
@@ -40,24 +39,24 @@ export function assembleTransferSporeAction(
40
39
  sporeInput: ccc.CellOutputLike,
41
40
  sporeOutput: ccc.CellOutputLike,
42
41
  scriptInfoHash: ccc.HexLike = DEFAULT_COBUILD_INFO_HASH,
43
- ): UnpackResult<typeof Action> {
42
+ ): mol.EncodableType<typeof Action> {
44
43
  if (!sporeInput.type || !sporeOutput.type) {
45
44
  throw new Error("Spore cell must have a type script");
46
45
  }
47
46
 
48
47
  const sporeType = ccc.Script.from(sporeOutput.type);
49
48
  const sporeTypeHash = sporeType.hash();
50
- const actionData = SporeAction.pack({
49
+ const actionData = SporeAction.encode({
51
50
  type: "TransferSpore",
52
51
  value: {
53
52
  sporeId: sporeType.args,
54
53
  from: {
55
54
  type: "Script",
56
- value: ccc.Script.from(sporeInput.lock),
55
+ value: sporeInput.lock,
57
56
  },
58
57
  to: {
59
58
  type: "Script",
60
- value: ccc.Script.from(sporeOutput.lock),
59
+ value: sporeOutput.lock,
61
60
  },
62
61
  },
63
62
  });
@@ -71,19 +70,19 @@ export function assembleTransferSporeAction(
71
70
  export function assembleMeltSporeAction(
72
71
  sporeInput: ccc.CellOutputLike,
73
72
  scriptInfoHash: ccc.HexLike = DEFAULT_COBUILD_INFO_HASH,
74
- ): UnpackResult<typeof Action> {
73
+ ): mol.EncodableType<typeof Action> {
75
74
  if (!sporeInput.type) {
76
75
  throw new Error("Spore cell must have a type script");
77
76
  }
78
77
  const sporeType = ccc.Script.from(sporeInput.type);
79
78
  const sporeTypeHash = sporeType.hash();
80
- const actionData = SporeAction.pack({
79
+ const actionData = SporeAction.encode({
81
80
  type: "MeltSpore",
82
81
  value: {
83
82
  sporeId: sporeType.args,
84
83
  from: {
85
84
  type: "Script",
86
- value: ccc.Script.from(sporeInput.lock),
85
+ value: sporeInput.lock,
87
86
  },
88
87
  },
89
88
  });
@@ -98,21 +97,21 @@ export function assembleCreateClusterAction(
98
97
  clusterOutput: ccc.CellOutputLike,
99
98
  clusterData: ccc.BytesLike,
100
99
  scriptInfoHash: ccc.HexLike = DEFAULT_COBUILD_INFO_HASH,
101
- ): UnpackResult<typeof Action> {
100
+ ): mol.EncodableType<typeof Action> {
102
101
  if (!clusterOutput.type) {
103
102
  throw new Error("Cluster cell must have a type script");
104
103
  }
105
104
  const clusterType = ccc.Script.from(clusterOutput.type);
106
105
  const clusterTypeHash = clusterType.hash();
107
- const actionData = SporeAction.pack({
106
+ const actionData = SporeAction.encode({
108
107
  type: "CreateCluster",
109
108
  value: {
110
109
  clusterId: clusterType.args,
111
- dataHash: ccc.hashCkb(clusterData),
112
110
  to: {
113
111
  type: "Script",
114
- value: ccc.Script.from(clusterOutput.lock),
112
+ value: clusterOutput.lock,
115
113
  },
114
+ dataHash: ccc.hashCkb(clusterData),
116
115
  },
117
116
  });
118
117
  return {
@@ -126,23 +125,23 @@ export function assembleTransferClusterAction(
126
125
  clusterInput: ccc.CellOutputLike,
127
126
  clusterOutput: ccc.CellOutputLike,
128
127
  scriptInfoHash: ccc.HexLike = DEFAULT_COBUILD_INFO_HASH,
129
- ): UnpackResult<typeof Action> {
128
+ ): mol.EncodableType<typeof Action> {
130
129
  if (!clusterInput.type || !clusterOutput.type) {
131
130
  throw new Error("Cluster cell must have a type script");
132
131
  }
133
132
  const clusterType = ccc.Script.from(clusterOutput.type);
134
133
  const clusterTypeHash = clusterType.hash();
135
- const actionData = SporeAction.pack({
134
+ const actionData = SporeAction.encode({
136
135
  type: "TransferCluster",
137
136
  value: {
138
137
  clusterId: clusterType.args,
139
138
  from: {
140
139
  type: "Script",
141
- value: ccc.Script.from(clusterInput.lock),
140
+ value: clusterInput.lock,
142
141
  },
143
142
  to: {
144
143
  type: "Script",
145
- value: ccc.Script.from(clusterOutput.lock),
144
+ value: clusterOutput.lock,
146
145
  },
147
146
  },
148
147
  });
@@ -156,7 +155,7 @@ export function assembleTransferClusterAction(
156
155
  export async function prepareSporeTransaction(
157
156
  signer: ccc.Signer,
158
157
  txLike: ccc.TransactionLike,
159
- actions: UnpackResult<typeof ActionVec>,
158
+ actions: mol.EncodableType<typeof ActionVec>,
160
159
  ): Promise<ccc.Transaction> {
161
160
  let tx = ccc.Transaction.from(txLike);
162
161
 
@@ -172,9 +171,9 @@ export async function prepareSporeTransaction(
172
171
 
173
172
  export function unpackCommonCobuildProof(
174
173
  data: ccc.HexLike,
175
- ): UnpackResult<typeof WitnessLayout> | undefined {
174
+ ): mol.EncodableType<typeof WitnessLayout> | undefined {
176
175
  try {
177
- return WitnessLayout.unpack(ccc.bytesFrom(data));
176
+ return WitnessLayout.decode(ccc.bytesFrom(data));
178
177
  } catch {
179
178
  return;
180
179
  }
@@ -182,7 +181,7 @@ export function unpackCommonCobuildProof(
182
181
 
183
182
  export function extractCobuildActionsFromTx(
184
183
  tx: ccc.Transaction,
185
- ): UnpackResult<typeof ActionVec> {
184
+ ): mol.EncodableType<typeof ActionVec> {
186
185
  if (tx.witnesses.length === 0) {
187
186
  return [];
188
187
  }
@@ -193,7 +192,7 @@ export function extractCobuildActionsFromTx(
193
192
  return [];
194
193
  }
195
194
  if (witnessLayout.type !== "SighashAll") {
196
- throw new Error("Invalid cobuild proof type: " + witnessLayout.type);
195
+ throw new Error("Invalid cobuild proof type: SighashAll");
197
196
  }
198
197
 
199
198
  // Remove existed cobuild witness
@@ -203,10 +202,10 @@ export function extractCobuildActionsFromTx(
203
202
 
204
203
  export function injectCobuild(
205
204
  tx: ccc.Transaction,
206
- actions: UnpackResult<typeof ActionVec>,
205
+ actions: mol.EncodableType<typeof ActionVec>,
207
206
  ): void {
208
207
  const witnessLayout = ccc.hexFrom(
209
- WitnessLayout.pack({
208
+ WitnessLayout.encode({
210
209
  type: "SighashAll",
211
210
  value: {
212
211
  seal: "0x",
@@ -1,58 +1,53 @@
1
- import { ccc } from "@ckb-ccc/core";
2
- import { blockchain } from "@ckb-lumos/base";
3
- import { molecule } from "@ckb-lumos/codec";
4
- import { RawString } from "./base.js";
1
+ import { ccc, mol } from "@ckb-ccc/core";
5
2
 
6
- export const MolClusterDataV1 = molecule.table(
7
- {
8
- name: RawString,
9
- description: RawString,
10
- },
11
- ["name", "description"],
12
- );
13
- export const MolClusterDataV2 = molecule.table(
14
- {
15
- name: RawString,
16
- description: RawString,
17
- mutantId: blockchain.BytesOpt,
18
- },
19
- ["name", "description", "mutantId"],
20
- );
21
-
22
- export interface ClusterDataV1 {
3
+ export interface ClusterDataV1View {
23
4
  name: string;
24
5
  description: string;
25
6
  }
26
- export interface ClusterDataV2 {
7
+
8
+ export const ClusterDataV1: mol.Codec<ClusterDataV1View> = mol.table({
9
+ name: mol.String,
10
+ description: mol.String,
11
+ });
12
+
13
+ export interface ClusterDataV2View {
27
14
  name: string;
28
15
  description: string;
29
16
  mutantId?: ccc.HexLike;
30
17
  }
31
- export type ClusterData = ClusterDataV2;
18
+
19
+ export const ClusterDataV2: mol.Codec<ClusterDataV2View> = mol.table({
20
+ name: mol.String,
21
+ description: mol.String,
22
+ mutantId: mol.BytesOpt,
23
+ });
24
+
25
+ export type ClusterDataView = ClusterDataV2View;
32
26
 
33
27
  export type ClusterDataVersion = "v1" | "v2";
34
28
 
29
+ export const ClusterData = ClusterDataV2;
30
+
35
31
  /**
36
32
  * Pack RawClusterData to Uint8Array.
37
33
  * Pass an optional "version" field to select a specific packing version.
38
34
  */
39
- export function packRawClusterData(packable: ClusterData): Uint8Array;
35
+ export function packRawClusterData(packable: ClusterDataView): Uint8Array;
40
36
  export function packRawClusterData(
41
- packable: ClusterDataV1,
37
+ packable: ClusterDataV1View,
42
38
  version: "v1",
43
39
  ): Uint8Array;
44
40
  export function packRawClusterData(
45
- packable: ClusterDataV2,
41
+ packable: ClusterDataV2View,
46
42
  version: "v2",
47
43
  ): Uint8Array;
48
44
  export function packRawClusterData(
49
- packable: ClusterDataV1 | ClusterDataV2,
45
+ packable: ClusterDataV1View | ClusterDataV2View,
50
46
  version?: ClusterDataVersion,
51
47
  ): Uint8Array {
52
48
  if (!version) {
53
49
  return packRawClusterDataV2(packable);
54
50
  }
55
-
56
51
  switch (version) {
57
52
  case "v1":
58
53
  return packRawClusterDataV1(packable);
@@ -60,33 +55,41 @@ export function packRawClusterData(
60
55
  return packRawClusterDataV2(packable);
61
56
  }
62
57
  }
63
- export function packRawClusterDataV1(packable: ClusterDataV1): Uint8Array {
64
- return MolClusterDataV1.pack({
65
- name: packable.name,
66
- description: packable.description,
67
- });
58
+
59
+ export function packRawClusterDataV1(packable: ClusterDataV1View): Uint8Array {
60
+ return ccc.bytesFrom(
61
+ ClusterDataV1.encode({
62
+ name: packable.name,
63
+ description: packable.description,
64
+ }),
65
+ );
68
66
  }
69
- export function packRawClusterDataV2(packable: ClusterDataV2): Uint8Array {
70
- return MolClusterDataV2.pack({
71
- name: packable.name,
72
- description: packable.description,
73
- mutantId: packable.mutantId,
74
- });
67
+
68
+ export function packRawClusterDataV2(packable: ClusterDataV2View): Uint8Array {
69
+ return ccc.bytesFrom(
70
+ ClusterDataV2.encode({
71
+ name: packable.name,
72
+ description: packable.description,
73
+ mutantId: packable.mutantId,
74
+ }),
75
+ );
75
76
  }
76
77
 
77
78
  /**
78
79
  * Unpack Hex/Bytes to RawClusterData.
79
80
  * Pass an optional "version" field to select a specific unpacking version.
80
81
  */
81
- export function unpackToRawClusterData(unpackable: ccc.BytesLike): ClusterData;
82
+ export function unpackToRawClusterData(
83
+ unpackable: ccc.BytesLike,
84
+ ): ClusterDataView;
82
85
  export function unpackToRawClusterData(
83
86
  unpackable: ccc.BytesLike,
84
87
  version: "v1",
85
- ): ClusterDataV1;
88
+ ): ClusterDataV1View;
86
89
  export function unpackToRawClusterData(
87
90
  unpackable: ccc.BytesLike,
88
91
  version: "v2",
89
- ): ClusterDataV2;
92
+ ): ClusterDataV2View;
90
93
  export function unpackToRawClusterData(
91
94
  unpackable: ccc.BytesLike,
92
95
  version?: ClusterDataVersion,
@@ -99,7 +102,6 @@ export function unpackToRawClusterData(
99
102
  return unpackToRawClusterDataV2(unpackable);
100
103
  }
101
104
  }
102
-
103
105
  try {
104
106
  return unpackToRawClusterDataV2(unpackable);
105
107
  } catch {
@@ -112,22 +114,15 @@ export function unpackToRawClusterData(
112
114
  }
113
115
  }
114
116
  }
117
+
115
118
  export function unpackToRawClusterDataV1(
116
119
  unpackable: ccc.BytesLike,
117
- ): ClusterDataV1 {
118
- const decoded = MolClusterDataV1.unpack(unpackable);
119
- return {
120
- name: decoded.name,
121
- description: decoded.description,
122
- };
120
+ ): ClusterDataV1View {
121
+ return ClusterDataV1.decode(unpackable);
123
122
  }
123
+
124
124
  export function unpackToRawClusterDataV2(
125
125
  unpackable: ccc.BytesLike,
126
- ): ClusterDataV2 {
127
- const decoded = MolClusterDataV2.unpack(unpackable);
128
- return {
129
- name: decoded.name,
130
- description: decoded.description,
131
- mutantId: ccc.apply(ccc.hexFrom, decoded.mutantId),
132
- };
126
+ ): ClusterDataV2View {
127
+ return ClusterDataV2.decode(unpackable);
133
128
  }
@@ -1,72 +1,41 @@
1
- import { blockchain } from "@ckb-lumos/base";
2
- import { molecule, number } from "@ckb-lumos/codec";
3
- import { RawString } from "../base.js";
4
-
5
- const Uint32Opt = molecule.option(number.Uint32LE);
6
-
7
- const Hash = blockchain.Byte32;
8
-
9
- export const Action = molecule.table(
10
- {
11
- scriptInfoHash: Hash,
12
- scriptHash: Hash,
13
- data: blockchain.Bytes,
14
- },
15
- ["scriptInfoHash", "scriptHash", "data"],
16
- );
17
-
18
- export const ActionVec = molecule.vector(Action);
19
-
20
- export const Message = molecule.table(
21
- {
22
- actions: ActionVec,
23
- },
24
- ["actions"],
25
- );
26
-
27
- export const ResolvedInputs = molecule.table(
28
- {
29
- outputs: blockchain.CellOutputVec,
30
- outputsData: blockchain.BytesVec,
31
- },
32
- ["outputs", "outputsData"],
33
- );
34
-
35
- export const ScriptInfo = molecule.table(
36
- {
37
- name: RawString,
38
- url: RawString,
39
- scriptHash: Hash,
40
- schema: RawString,
41
- messageType: RawString,
42
- },
43
- ["name", "url", "scriptHash", "schema", "messageType"],
44
- );
45
-
46
- export const ScriptInfoVec = molecule.vector(ScriptInfo);
47
-
48
- export const BuildingPacketV1 = molecule.table(
49
- {
50
- message: Message,
51
- payload: blockchain.Transaction,
52
- resolvedInputs: ResolvedInputs,
53
- changeOutput: Uint32Opt,
54
- scriptInfos: ScriptInfoVec,
55
- lockActions: ActionVec,
56
- },
57
- [
58
- "message",
59
- "payload",
60
- "resolvedInputs",
61
- "changeOutput",
62
- "scriptInfos",
63
- "lockActions",
64
- ],
65
- );
66
-
67
- export const BuildingPacket = molecule.union(
68
- {
69
- BuildingPacketV1,
70
- },
71
- ["BuildingPacketV1"],
72
- );
1
+ import { mol } from "@ckb-ccc/core";
2
+
3
+ export const Action = mol.table({
4
+ scriptInfoHash: mol.Hash,
5
+ scriptHash: mol.Hash,
6
+ data: mol.Bytes,
7
+ });
8
+
9
+ export const ActionVec = mol.vector(Action);
10
+
11
+ export const Message = mol.table({
12
+ actions: ActionVec,
13
+ });
14
+
15
+ export const ResolvedInputs = mol.table({
16
+ outputs: mol.CellOutputVec,
17
+ outputsData: mol.BytesVec,
18
+ });
19
+
20
+ export const ScriptInfo = mol.table({
21
+ name: mol.String,
22
+ url: mol.String,
23
+ scriptHash: mol.Hash,
24
+ schema: mol.String,
25
+ messageType: mol.String,
26
+ });
27
+
28
+ export const ScriptInfoVec = mol.vector(ScriptInfo);
29
+
30
+ export const BuildingPacketV1 = mol.table({
31
+ message: Message,
32
+ payload: mol.Transaction,
33
+ resolvedInputs: ResolvedInputs,
34
+ changeOutput: mol.Uint32Opt,
35
+ scriptInfos: ScriptInfoVec,
36
+ lockActions: ActionVec,
37
+ });
38
+
39
+ export const BuildingPacket = mol.union({
40
+ BuildingPacketV1,
41
+ });