@ckb-ccc/spore 1.5.17 → 1.6.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 (225) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/advanced.d.mts +3 -0
  3. package/dist/advanced.mjs +1 -0
  4. package/dist/advancedBarrel.d.mts +30 -0
  5. package/dist/advancedBarrel.d.mts.map +1 -0
  6. package/dist/advancedBarrel.mjs +1 -0
  7. package/dist/barrel-B4pnDQ_D.d.mts +324 -0
  8. package/dist/barrel-B4pnDQ_D.d.mts.map +1 -0
  9. package/dist/barrel-C4fV1nUf.mjs +2 -0
  10. package/dist/barrel-C4fV1nUf.mjs.map +1 -0
  11. package/dist/barrel.d.mts +3 -0
  12. package/dist/barrel.mjs +1 -0
  13. package/dist/cluster-KsFIhwZx.mjs +2 -0
  14. package/dist/cluster-KsFIhwZx.mjs.map +1 -0
  15. package/dist/index.d.mts +3 -0
  16. package/dist/index.mjs +1 -0
  17. package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
  18. package/dist/types-1b682ehT.d.mts +1048 -0
  19. package/dist/types-1b682ehT.d.mts.map +1 -0
  20. package/dist.commonjs/advanced.d.ts +3 -3
  21. package/dist.commonjs/advanced.js +1 -41
  22. package/dist.commonjs/advancedBarrel.d.ts +29 -4
  23. package/dist.commonjs/advancedBarrel.d.ts.map +1 -1
  24. package/dist.commonjs/advancedBarrel.js +1 -20
  25. package/dist.commonjs/barrel-Dj_LwfvL.js +2 -0
  26. package/dist.commonjs/barrel-Dj_LwfvL.js.map +1 -0
  27. package/dist.commonjs/barrel-DsEUm55S.d.ts +324 -0
  28. package/dist.commonjs/barrel-DsEUm55S.d.ts.map +1 -0
  29. package/dist.commonjs/barrel.d.ts +3 -5
  30. package/dist.commonjs/barrel.js +1 -43
  31. package/dist.commonjs/cluster-CGo0DCM9.js +2 -0
  32. package/dist.commonjs/cluster-CGo0DCM9.js.map +1 -0
  33. package/dist.commonjs/index.d.ts +3 -3
  34. package/dist.commonjs/index.js +1 -41
  35. package/dist.commonjs/types-DjAlFsfK.d.ts +1050 -0
  36. package/dist.commonjs/types-DjAlFsfK.d.ts.map +1 -0
  37. package/package.json +30 -33
  38. package/src/cobuild/index.ts +10 -10
  39. package/src/codec/cluster.ts +2 -2
  40. package/src/codec/spore.ts +1 -1
  41. package/src/spore/advanced.ts +2 -2
  42. package/tsdown.config.mts +43 -0
  43. package/dist/advanced.d.ts +0 -3
  44. package/dist/advanced.d.ts.map +0 -1
  45. package/dist/advanced.js +0 -2
  46. package/dist/advancedBarrel.d.ts +0 -5
  47. package/dist/advancedBarrel.d.ts.map +0 -1
  48. package/dist/advancedBarrel.js +0 -4
  49. package/dist/barrel.d.ts +0 -5
  50. package/dist/barrel.d.ts.map +0 -1
  51. package/dist/barrel.js +0 -4
  52. package/dist/cluster/index.d.ts +0 -95
  53. package/dist/cluster/index.d.ts.map +0 -1
  54. package/dist/cluster/index.js +0 -165
  55. package/dist/cobuild/index.d.ts +0 -12
  56. package/dist/cobuild/index.d.ts.map +0 -1
  57. package/dist/cobuild/index.js +0 -167
  58. package/dist/codec/cluster.d.ts +0 -34
  59. package/dist/codec/cluster.d.ts.map +0 -1
  60. package/dist/codec/cluster.js +0 -62
  61. package/dist/codec/cobuild/buildingPacket.d.ts +0 -268
  62. package/dist/codec/cobuild/buildingPacket.d.ts.map +0 -1
  63. package/dist/codec/cobuild/buildingPacket.js +0 -33
  64. package/dist/codec/cobuild/index.d.ts +0 -4
  65. package/dist/codec/cobuild/index.d.ts.map +0 -1
  66. package/dist/codec/cobuild/index.js +0 -3
  67. package/dist/codec/cobuild/sporeAction.d.ts +0 -589
  68. package/dist/codec/cobuild/sporeAction.d.ts.map +0 -1
  69. package/dist/codec/cobuild/sporeAction.js +0 -90
  70. package/dist/codec/cobuild/witnessLayout.d.ts +0 -126
  71. package/dist/codec/cobuild/witnessLayout.d.ts.map +0 -1
  72. package/dist/codec/cobuild/witnessLayout.js +0 -26
  73. package/dist/codec/index.d.ts +0 -4
  74. package/dist/codec/index.d.ts.map +0 -1
  75. package/dist/codec/index.js +0 -3
  76. package/dist/codec/spore.d.ts +0 -10
  77. package/dist/codec/spore.d.ts.map +0 -1
  78. package/dist/codec/spore.js +0 -16
  79. package/dist/dob/api/decode.d.ts +0 -8
  80. package/dist/dob/api/decode.d.ts.map +0 -1
  81. package/dist/dob/api/decode.js +0 -63
  82. package/dist/dob/api/encode.d.ts +0 -5
  83. package/dist/dob/api/encode.d.ts.map +0 -1
  84. package/dist/dob/api/encode.js +0 -81
  85. package/dist/dob/api/index.d.ts +0 -3
  86. package/dist/dob/api/index.d.ts.map +0 -1
  87. package/dist/dob/api/index.js +0 -2
  88. package/dist/dob/config/index.d.ts +0 -2
  89. package/dist/dob/config/index.d.ts.map +0 -1
  90. package/dist/dob/config/index.js +0 -1
  91. package/dist/dob/config/predefined.d.ts +0 -8
  92. package/dist/dob/config/predefined.d.ts.map +0 -1
  93. package/dist/dob/config/predefined.js +0 -59
  94. package/dist/dob/helper/check.d.ts +0 -5
  95. package/dist/dob/helper/check.d.ts.map +0 -1
  96. package/dist/dob/helper/check.js +0 -75
  97. package/dist/dob/helper/error.d.ts +0 -2
  98. package/dist/dob/helper/error.d.ts.map +0 -1
  99. package/dist/dob/helper/error.js +0 -40
  100. package/dist/dob/helper/index.d.ts +0 -4
  101. package/dist/dob/helper/index.d.ts.map +0 -1
  102. package/dist/dob/helper/index.js +0 -3
  103. package/dist/dob/helper/object.d.ts +0 -59
  104. package/dist/dob/helper/object.d.ts.map +0 -1
  105. package/dist/dob/helper/object.js +0 -1
  106. package/dist/dob/index.d.ts +0 -4
  107. package/dist/dob/index.d.ts.map +0 -1
  108. package/dist/dob/index.js +0 -3
  109. package/dist/helper/index.d.ts +0 -7
  110. package/dist/helper/index.d.ts.map +0 -1
  111. package/dist/helper/index.js +0 -18
  112. package/dist/index.d.ts +0 -3
  113. package/dist/index.d.ts.map +0 -1
  114. package/dist/index.js +0 -2
  115. package/dist/predefined/advanced.d.ts +0 -3
  116. package/dist/predefined/advanced.d.ts.map +0 -1
  117. package/dist/predefined/advanced.js +0 -2
  118. package/dist/predefined/index.d.ts +0 -3
  119. package/dist/predefined/index.d.ts.map +0 -1
  120. package/dist/predefined/index.js +0 -2
  121. package/dist/predefined/mainnet.advanced.d.ts +0 -4
  122. package/dist/predefined/mainnet.advanced.d.ts.map +0 -1
  123. package/dist/predefined/mainnet.advanced.js +0 -61
  124. package/dist/predefined/testnet.advanced.d.ts +0 -4
  125. package/dist/predefined/testnet.advanced.d.ts.map +0 -1
  126. package/dist/predefined/testnet.advanced.js +0 -88
  127. package/dist/predefined/types.d.ts +0 -17
  128. package/dist/predefined/types.d.ts.map +0 -1
  129. package/dist/predefined/types.js +0 -18
  130. package/dist/predefined/utils.d.ts +0 -7
  131. package/dist/predefined/utils.d.ts.map +0 -1
  132. package/dist/predefined/utils.js +0 -26
  133. package/dist/spore/advanced.d.ts +0 -4
  134. package/dist/spore/advanced.d.ts.map +0 -1
  135. package/dist/spore/advanced.js +0 -54
  136. package/dist/spore/index.d.ts +0 -129
  137. package/dist/spore/index.d.ts.map +0 -1
  138. package/dist/spore/index.js +0 -218
  139. package/dist.commonjs/advanced.d.ts.map +0 -1
  140. package/dist.commonjs/barrel.d.ts.map +0 -1
  141. package/dist.commonjs/cluster/index.d.ts +0 -95
  142. package/dist.commonjs/cluster/index.d.ts.map +0 -1
  143. package/dist.commonjs/cluster/index.js +0 -173
  144. package/dist.commonjs/cobuild/index.d.ts +0 -12
  145. package/dist.commonjs/cobuild/index.d.ts.map +0 -1
  146. package/dist.commonjs/cobuild/index.js +0 -178
  147. package/dist.commonjs/codec/cluster.d.ts +0 -34
  148. package/dist.commonjs/codec/cluster.d.ts.map +0 -1
  149. package/dist.commonjs/codec/cluster.js +0 -71
  150. package/dist.commonjs/codec/cobuild/buildingPacket.d.ts +0 -268
  151. package/dist.commonjs/codec/cobuild/buildingPacket.d.ts.map +0 -1
  152. package/dist.commonjs/codec/cobuild/buildingPacket.js +0 -36
  153. package/dist.commonjs/codec/cobuild/index.d.ts +0 -4
  154. package/dist.commonjs/codec/cobuild/index.d.ts.map +0 -1
  155. package/dist.commonjs/codec/cobuild/index.js +0 -19
  156. package/dist.commonjs/codec/cobuild/sporeAction.d.ts +0 -589
  157. package/dist.commonjs/codec/cobuild/sporeAction.d.ts.map +0 -1
  158. package/dist.commonjs/codec/cobuild/sporeAction.js +0 -93
  159. package/dist.commonjs/codec/cobuild/witnessLayout.d.ts +0 -126
  160. package/dist.commonjs/codec/cobuild/witnessLayout.d.ts.map +0 -1
  161. package/dist.commonjs/codec/cobuild/witnessLayout.js +0 -29
  162. package/dist.commonjs/codec/index.d.ts +0 -4
  163. package/dist.commonjs/codec/index.d.ts.map +0 -1
  164. package/dist.commonjs/codec/index.js +0 -19
  165. package/dist.commonjs/codec/spore.d.ts +0 -10
  166. package/dist.commonjs/codec/spore.d.ts.map +0 -1
  167. package/dist.commonjs/codec/spore.js +0 -21
  168. package/dist.commonjs/dob/api/decode.d.ts +0 -8
  169. package/dist.commonjs/dob/api/decode.d.ts.map +0 -1
  170. package/dist.commonjs/dob/api/decode.js +0 -70
  171. package/dist.commonjs/dob/api/encode.d.ts +0 -5
  172. package/dist.commonjs/dob/api/encode.d.ts.map +0 -1
  173. package/dist.commonjs/dob/api/encode.js +0 -86
  174. package/dist.commonjs/dob/api/index.d.ts +0 -3
  175. package/dist.commonjs/dob/api/index.d.ts.map +0 -1
  176. package/dist.commonjs/dob/api/index.js +0 -18
  177. package/dist.commonjs/dob/config/index.d.ts +0 -2
  178. package/dist.commonjs/dob/config/index.d.ts.map +0 -1
  179. package/dist.commonjs/dob/config/index.js +0 -17
  180. package/dist.commonjs/dob/config/predefined.d.ts +0 -8
  181. package/dist.commonjs/dob/config/predefined.d.ts.map +0 -1
  182. package/dist.commonjs/dob/config/predefined.js +0 -63
  183. package/dist.commonjs/dob/helper/check.d.ts +0 -5
  184. package/dist.commonjs/dob/helper/check.d.ts.map +0 -1
  185. package/dist.commonjs/dob/helper/check.js +0 -80
  186. package/dist.commonjs/dob/helper/error.d.ts +0 -2
  187. package/dist.commonjs/dob/helper/error.d.ts.map +0 -1
  188. package/dist.commonjs/dob/helper/error.js +0 -43
  189. package/dist.commonjs/dob/helper/index.d.ts +0 -4
  190. package/dist.commonjs/dob/helper/index.d.ts.map +0 -1
  191. package/dist.commonjs/dob/helper/index.js +0 -19
  192. package/dist.commonjs/dob/helper/object.d.ts +0 -59
  193. package/dist.commonjs/dob/helper/object.d.ts.map +0 -1
  194. package/dist.commonjs/dob/helper/object.js +0 -2
  195. package/dist.commonjs/dob/index.d.ts +0 -4
  196. package/dist.commonjs/dob/index.d.ts.map +0 -1
  197. package/dist.commonjs/dob/index.js +0 -19
  198. package/dist.commonjs/helper/index.d.ts +0 -7
  199. package/dist.commonjs/helper/index.d.ts.map +0 -1
  200. package/dist.commonjs/helper/index.js +0 -21
  201. package/dist.commonjs/index.d.ts.map +0 -1
  202. package/dist.commonjs/predefined/advanced.d.ts +0 -3
  203. package/dist.commonjs/predefined/advanced.d.ts.map +0 -1
  204. package/dist.commonjs/predefined/advanced.js +0 -18
  205. package/dist.commonjs/predefined/index.d.ts +0 -3
  206. package/dist.commonjs/predefined/index.d.ts.map +0 -1
  207. package/dist.commonjs/predefined/index.js +0 -18
  208. package/dist.commonjs/predefined/mainnet.advanced.d.ts +0 -4
  209. package/dist.commonjs/predefined/mainnet.advanced.d.ts.map +0 -1
  210. package/dist.commonjs/predefined/mainnet.advanced.js +0 -64
  211. package/dist.commonjs/predefined/testnet.advanced.d.ts +0 -4
  212. package/dist.commonjs/predefined/testnet.advanced.d.ts.map +0 -1
  213. package/dist.commonjs/predefined/testnet.advanced.js +0 -91
  214. package/dist.commonjs/predefined/types.d.ts +0 -17
  215. package/dist.commonjs/predefined/types.d.ts.map +0 -1
  216. package/dist.commonjs/predefined/types.js +0 -22
  217. package/dist.commonjs/predefined/utils.d.ts +0 -7
  218. package/dist.commonjs/predefined/utils.d.ts.map +0 -1
  219. package/dist.commonjs/predefined/utils.js +0 -32
  220. package/dist.commonjs/spore/advanced.d.ts +0 -4
  221. package/dist.commonjs/spore/advanced.d.ts.map +0 -1
  222. package/dist.commonjs/spore/advanced.js +0 -57
  223. package/dist.commonjs/spore/index.d.ts +0 -129
  224. package/dist.commonjs/spore/index.d.ts.map +0 -1
  225. package/dist.commonjs/spore/index.js +0 -227
@@ -1,218 +0,0 @@
1
- import { ccc } from "@ckb-ccc/core";
2
- import { assembleCreateSporeAction, assembleMeltSporeAction, assembleTransferSporeAction, prepareSporeTransaction, } from "../advanced.js";
3
- import { packRawSporeData, unpackToRawSporeData, } from "../codec/index.js";
4
- import { findSingletonCellByArgs } from "../helper/index.js";
5
- import { SporeScriptInfo, getSporeScriptInfo, getSporeScriptInfos, } from "../predefined/index.js";
6
- import { prepareCluster } from "./advanced.js";
7
- export async function findSpore(client, id, scripts) {
8
- const found = await findSingletonCellByArgs(client, id, scripts ?? Object.values(getSporeScriptInfos(client)));
9
- if (!found) {
10
- return undefined;
11
- }
12
- return {
13
- cell: found.cell,
14
- spore: found.cell,
15
- sporeData: unpackToRawSporeData(found.cell.outputData),
16
- scriptInfo: found.scriptInfo,
17
- };
18
- }
19
- export async function assertSpore(client, args, scripts) {
20
- const res = await findSpore(client, args, scripts);
21
- if (!res) {
22
- throw new Error(`Spore ${ccc.hexFrom(args)} not found`);
23
- }
24
- return res;
25
- }
26
- /**
27
- * Create one Spore cell with the specified Spore data.
28
- *
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
- * - undefined: error if the spore has a cluster but the clusterMode is not set
34
- * - lockProxy: put a cell that uses the same lock from Cluster cell in both Inputs and Outputs
35
- * - clusterCell: directly put Cluster cell in Inputs and Outputs
36
- * - skip: don't handle the cluster logic
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
- * @returns
41
- * - **tx**: a new transaction that contains created Spore cells
42
- * - **id**: the sporeId of created Spore cell
43
- */
44
- export async function createSpore(params) {
45
- const { signer, data, to, clusterMode, scriptInfoHash } = params;
46
- const scriptInfo = params.scriptInfo ?? getSporeScriptInfo(signer.client);
47
- // prepare transaction
48
- const actions = [];
49
- const ids = [];
50
- const tx = ccc.Transaction.from(params.tx ?? {});
51
- await tx.completeInputsAtLeastOne(signer);
52
- const { script: lock } = await signer.getRecommendedAddressObj();
53
- // build spore cell
54
- const id = ccc.hashTypeId(tx.inputs[0], tx.outputs.length);
55
- ids.push(id);
56
- const packedData = packRawSporeData(data);
57
- tx.addOutput({
58
- lock: to ?? lock,
59
- type: {
60
- ...scriptInfo,
61
- args: id,
62
- },
63
- }, packedData);
64
- // create spore action
65
- if (scriptInfo.cobuild) {
66
- const output = tx.outputs[tx.outputs.length - 1];
67
- const createAction = assembleCreateSporeAction(output, packedData, scriptInfoHash);
68
- actions.push(createAction);
69
- }
70
- // complete cellDeps
71
- await tx.addCellDepInfos(signer.client, scriptInfo.cellDeps);
72
- const action = await prepareCluster(signer, tx, data, clusterMode);
73
- if (action) {
74
- actions.push(action);
75
- }
76
- return {
77
- tx: await prepareSporeTransaction(signer, tx, actions),
78
- id,
79
- };
80
- }
81
- /**
82
- * Transfer one Spore cell
83
- *
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
- * @returns
90
- * - **tx**: a new transaction that contains transferred Spore cells
91
- */
92
- export async function transferSpore(params) {
93
- const { signer, id, to, scripts, scriptInfoHash } = params;
94
- // prepare transaction
95
- const tx = ccc.Transaction.from(params.tx ?? {});
96
- const { cell: sporeCell, scriptInfo: sporeScriptInfo } = await assertSpore(signer.client, id, scripts);
97
- await tx.addCellDepInfos(signer.client, sporeScriptInfo.cellDeps);
98
- tx.addInput(sporeCell);
99
- tx.addOutput({
100
- lock: to,
101
- type: sporeCell.cellOutput.type,
102
- }, sporeCell.outputData);
103
- const actions = sporeScriptInfo.cobuild
104
- ? [
105
- assembleTransferSporeAction(sporeCell.cellOutput, tx.outputs[tx.outputs.length - 1], scriptInfoHash),
106
- ]
107
- : [];
108
- return {
109
- tx: await prepareSporeTransaction(signer, tx, actions),
110
- };
111
- }
112
- /**
113
- * Melt one Spore cell
114
- *
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
119
- * @returns
120
- * - **tx**: a new transaction that contains melted Spore cell
121
- */
122
- export async function meltSpore(params) {
123
- const { signer, id, scripts, scriptInfoHash } = params;
124
- // prepare transaction
125
- const tx = ccc.Transaction.from(params.tx ?? {});
126
- // build spore cell
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
131
- ? [assembleMeltSporeAction(sporeCell.cellOutput, scriptInfoHash)]
132
- : [];
133
- return {
134
- tx: await prepareSporeTransaction(signer, tx, actions),
135
- };
136
- }
137
- /**
138
- * Search on-chain spores under the signer's control, if cluster provided, filter spores belonging to this cluster
139
- *
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
144
- * @returns specified spore cells
145
- */
146
- export async function* findSporesBySigner(params) {
147
- const { signer, clusterId, scriptInfos, limit, order } = params;
148
- for (const scriptInfo of scriptInfos ??
149
- Object.values(getSporeScriptInfos(signer.client))) {
150
- if (!scriptInfo) {
151
- continue;
152
- }
153
- for await (const spore of signer.findCells({
154
- script: {
155
- ...scriptInfo,
156
- args: [],
157
- },
158
- }, true, order, limit)) {
159
- const sporeData = unpackToRawSporeData(spore.outputData);
160
- if (!clusterId ||
161
- (clusterId === "" && !sporeData.clusterId) ||
162
- sporeData.clusterId === ccc.hexFrom(clusterId)) {
163
- yield {
164
- cell: spore,
165
- spore,
166
- sporeData,
167
- scriptInfo: SporeScriptInfo.from(scriptInfo),
168
- };
169
- }
170
- }
171
- }
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
- }
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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"}
@@ -1,95 +0,0 @@
1
- import { ccc } from "@ckb-ccc/core";
2
- import { ClusterDataView } from "../codec/index.js";
3
- import { SporeScriptInfo, SporeScriptInfoLike } from "../predefined/index.js";
4
- export declare function findCluster(client: ccc.Client, id: ccc.HexLike, scripts?: SporeScriptInfoLike[]): Promise<{
5
- cell: ccc.Cell;
6
- cluster: ccc.Cell;
7
- clusterData: ClusterDataView;
8
- scriptInfo: SporeScriptInfo;
9
- } | undefined>;
10
- export declare function assertCluster(client: ccc.Client, args: ccc.HexLike, scripts?: SporeScriptInfoLike[]): Promise<{
11
- cell: ccc.Cell;
12
- scriptInfo: SporeScriptInfo;
13
- }>;
14
- /**
15
- * Create a new Cluster cell
16
- *
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
- * @returns
24
- * - **tx**: a new transaction that contains created Cluster cell
25
- * - **id**: the id of the created Cluster cell
26
- */
27
- export declare function createSporeCluster(params: {
28
- signer: ccc.Signer;
29
- data: ClusterDataView;
30
- to?: ccc.ScriptLike;
31
- tx?: ccc.TransactionLike;
32
- scriptInfo?: SporeScriptInfoLike;
33
- scriptInfoHash?: ccc.HexLike;
34
- }): Promise<{
35
- tx: ccc.Transaction;
36
- id: ccc.Hex;
37
- }>;
38
- /**
39
- * Transfer a Cluster cell
40
- *
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
- * @returns
47
- * - **tx**: a new transaction that contains transferred Cluster cell
48
- */
49
- export declare function transferSporeCluster(params: {
50
- signer: ccc.Signer;
51
- id: ccc.HexLike;
52
- to: ccc.ScriptLike;
53
- tx?: ccc.TransactionLike;
54
- scripts?: SporeScriptInfoLike[];
55
- scriptInfoHash?: ccc.HexLike;
56
- }): Promise<{
57
- tx: ccc.Transaction;
58
- }>;
59
- /**
60
- * Search on-chain clusters under the signer's control
61
- *
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
65
- */
66
- export declare function findSporeClustersBySigner(params: {
67
- signer: ccc.Signer;
68
- order?: "asc" | "desc";
69
- limit?: number;
70
- scriptInfos?: SporeScriptInfoLike[];
71
- }): AsyncGenerator<{
72
- cell: ccc.Cell;
73
- cluster: ccc.Cell;
74
- clusterData: ClusterDataView;
75
- scriptInfo: SporeScriptInfo;
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
- }>;
95
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cluster/index.ts"],"names":[],"mappings":"AAAA,OAAO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,173 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findCluster = findCluster;
4
- exports.assertCluster = assertCluster;
5
- exports.createSporeCluster = createSporeCluster;
6
- exports.transferSporeCluster = transferSporeCluster;
7
- exports.findSporeClustersBySigner = findSporeClustersBySigner;
8
- exports.findSporeClusters = findSporeClusters;
9
- const core_1 = require("@ckb-ccc/core");
10
- const advanced_js_1 = require("../advanced.js");
11
- const index_js_1 = require("../codec/index.js");
12
- const index_js_2 = require("../helper/index.js");
13
- const index_js_3 = require("../predefined/index.js");
14
- async function findCluster(client, id, scripts) {
15
- const found = await (0, index_js_2.findSingletonCellByArgs)(client, id, scripts ?? Object.values((0, index_js_3.getClusterScriptInfos)(client)));
16
- if (!found) {
17
- return;
18
- }
19
- return {
20
- cell: found.cell,
21
- cluster: found.cell,
22
- clusterData: (0, index_js_1.unpackToRawClusterData)(found.cell.outputData),
23
- scriptInfo: found.scriptInfo,
24
- };
25
- }
26
- async function assertCluster(client, args, scripts) {
27
- const res = await findCluster(client, args, scripts);
28
- if (!res) {
29
- throw new Error(`Cluster ${core_1.ccc.hexFrom(args)} not found`);
30
- }
31
- return res;
32
- }
33
- /**
34
- * Create a new Cluster cell
35
- *
36
- * @param params.signer who takes the responsibility to balance and sign the transaction
37
- * @param params.data specific format of data required by Cluster protocol
38
- * @param params.to the owner of the Cluster cell, which will be replaced with signer if not provided
39
- * @param params.tx the transaction skeleton, if not provided, a new one will be created
40
- * @param params.scriptInfo the script info of new cluster, default spore version if undefined
41
- * @param params.scriptInfoHash the script info hash used in cobuild
42
- * @returns
43
- * - **tx**: a new transaction that contains created Cluster cell
44
- * - **id**: the id of the created Cluster cell
45
- */
46
- async function createSporeCluster(params) {
47
- const { signer, data, to, scriptInfoHash } = params;
48
- const scriptInfo = params.scriptInfo ?? (0, index_js_3.getClusterScriptInfo)(signer.client);
49
- // prepare transaction
50
- const tx = core_1.ccc.Transaction.from(params.tx ?? {});
51
- await tx.completeInputsAtLeastOne(signer);
52
- // build cluster cell
53
- const id = core_1.ccc.hashTypeId(tx.inputs[0], tx.outputs.length);
54
- const packedClusterData = (0, index_js_1.packRawClusterData)(data);
55
- tx.addOutput({
56
- lock: to ?? (await signer.getRecommendedAddressObj()).script,
57
- type: {
58
- ...scriptInfo,
59
- args: id,
60
- },
61
- }, packedClusterData);
62
- // complete cellDeps
63
- await tx.addCellDepInfos(signer.client, scriptInfo.cellDeps);
64
- // generate cobuild action
65
- const actions = scriptInfo.cobuild
66
- ? [
67
- (0, advanced_js_1.assembleCreateClusterAction)(tx.outputs[tx.outputs.length - 1], packedClusterData, scriptInfoHash),
68
- ]
69
- : [];
70
- return {
71
- tx: await (0, advanced_js_1.prepareSporeTransaction)(signer, tx, actions),
72
- id,
73
- };
74
- }
75
- /**
76
- * Transfer a Cluster cell
77
- *
78
- * @param params.signer who takes the responsibility to balance and sign the transaction
79
- * @param params.id the id of the Cluster cell to be transferred
80
- * @param params.to the new owner of the Cluster cell
81
- * @param params.tx the transaction skeleton, if not provided, a new one will be created
82
- * @param params.scriptInfoHash the script info hash used in cobuild
83
- * @returns
84
- * - **tx**: a new transaction that contains transferred Cluster cell
85
- */
86
- async function transferSporeCluster(params) {
87
- const { signer, id, to, scripts, scriptInfoHash } = params;
88
- // prepare transaction
89
- const tx = core_1.ccc.Transaction.from(params.tx ?? {});
90
- // build cluster cell
91
- const { cell: cluster, scriptInfo: clusterScriptInfo } = await assertCluster(signer.client, id, scripts);
92
- tx.addInput(cluster);
93
- tx.addOutput({
94
- lock: to,
95
- type: cluster.cellOutput.type,
96
- }, cluster.outputData);
97
- // complete cellDeps
98
- await tx.addCellDepInfos(signer.client, clusterScriptInfo.cellDeps);
99
- // generate cobuild action
100
- const actions = clusterScriptInfo.cobuild
101
- ? [
102
- (0, advanced_js_1.assembleTransferClusterAction)(cluster.cellOutput, tx.outputs[tx.outputs.length - 1], scriptInfoHash),
103
- ]
104
- : [];
105
- return {
106
- tx: await (0, advanced_js_1.prepareSporeTransaction)(signer, tx, actions),
107
- };
108
- }
109
- /**
110
- * Search on-chain clusters under the signer's control
111
- *
112
- * @param params.signer the owner of clusters
113
- * @param params.order the order in creation time of clusters
114
- * @param params.scriptInfos the deployed script infos of clusters
115
- */
116
- async function* findSporeClustersBySigner(params) {
117
- const { signer, order, limit, scriptInfos } = params;
118
- for (const scriptInfo of scriptInfos ??
119
- Object.values((0, index_js_3.getClusterScriptInfos)(signer.client))) {
120
- if (!scriptInfo) {
121
- continue;
122
- }
123
- for await (const cluster of signer.findCells({
124
- script: {
125
- ...scriptInfo,
126
- args: "",
127
- },
128
- }, true, order, limit)) {
129
- yield {
130
- cell: cluster,
131
- cluster,
132
- clusterData: (0, index_js_1.unpackToRawClusterData)(cluster.outputData),
133
- scriptInfo: index_js_3.SporeScriptInfo.from(scriptInfo),
134
- };
135
- }
136
- }
137
- }
138
- /**
139
- * Search on-chain clusters under the specified lock or not
140
- *
141
- * @param params.client the client to search clusters
142
- * @param params.lock the lock of clusters
143
- */
144
- async function* findSporeClusters(params) {
145
- const { client, lock, order, limit, scriptInfos } = params;
146
- for (const scriptInfo of scriptInfos ??
147
- Object.values((0, index_js_3.getClusterScriptInfos)(client))) {
148
- if (!scriptInfo) {
149
- continue;
150
- }
151
- for await (const cluster of client.findCells({
152
- script: {
153
- ...scriptInfo,
154
- args: "",
155
- },
156
- scriptType: "type",
157
- scriptSearchMode: "prefix",
158
- withData: true,
159
- filter: lock
160
- ? {
161
- script: lock,
162
- }
163
- : undefined,
164
- }, order, limit)) {
165
- yield {
166
- cell: cluster,
167
- cluster,
168
- clusterData: (0, index_js_1.unpackToRawClusterData)(cluster.outputData),
169
- scriptInfo: index_js_3.SporeScriptInfo.from(scriptInfo),
170
- };
171
- }
172
- }
173
- }
@@ -1,12 +0,0 @@
1
- import { ccc, mol } from "@ckb-ccc/core";
2
- import { Action, ActionVec, WitnessLayout } from "../codec/index.js";
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;
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,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