@ckb-ccc/core 0.0.12-alpha.1 → 0.0.12

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 (267) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +5 -5
  3. package/dist/address/index.d.ts +4 -0
  4. package/dist/address/index.d.ts.map +1 -1
  5. package/dist/address/index.js +1 -0
  6. package/dist/advancedBarrel.d.ts +1 -0
  7. package/dist/advancedBarrel.d.ts.map +1 -1
  8. package/dist/advancedBarrel.js +1 -0
  9. package/dist/bytes/advanced.d.ts +1 -0
  10. package/dist/bytes/advanced.d.ts.map +1 -1
  11. package/dist/bytes/index.d.ts +9 -0
  12. package/dist/bytes/index.d.ts.map +1 -1
  13. package/dist/bytes/index.js +3 -0
  14. package/dist/ckb/index.d.ts +1 -0
  15. package/dist/ckb/index.d.ts.map +1 -1
  16. package/dist/ckb/index.js +1 -0
  17. package/dist/ckb/script.d.ts +15 -0
  18. package/dist/ckb/script.d.ts.map +1 -1
  19. package/dist/ckb/script.js +6 -0
  20. package/dist/ckb/transaction.d.ts +65 -11
  21. package/dist/ckb/transaction.d.ts.map +1 -1
  22. package/dist/ckb/transaction.js +41 -14
  23. package/dist/ckb/transactionLumos.d.ts +29 -0
  24. package/dist/ckb/transactionLumos.d.ts.map +1 -0
  25. package/dist/ckb/transactionLumos.js +1 -0
  26. package/dist/client/client.d.ts +13 -1
  27. package/dist/client/client.d.ts.map +1 -1
  28. package/dist/client/client.js +10 -1
  29. package/dist/client/clientPublicMainnet.d.ts +3 -0
  30. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  31. package/dist/client/clientPublicMainnet.js +3 -0
  32. package/dist/client/clientPublicTestnet.d.ts +3 -0
  33. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  34. package/dist/client/clientPublicTestnet.js +3 -0
  35. package/dist/client/clientTypes.d.ts +45 -0
  36. package/dist/client/clientTypes.d.ts.map +1 -1
  37. package/dist/client/clientTypes.js +9 -0
  38. package/dist/client/jsonRpc/index.d.ts +6 -6
  39. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  40. package/dist/client/jsonRpc/index.js +3 -3
  41. package/dist/fixedPoint/index.d.ts +6 -0
  42. package/dist/fixedPoint/index.d.ts.map +1 -1
  43. package/dist/fixedPoint/index.js +5 -0
  44. package/dist/hasher/hasher.d.ts +3 -0
  45. package/dist/hasher/hasher.d.ts.map +1 -1
  46. package/dist/hasher/hasherCkb.d.ts +6 -1
  47. package/dist/hasher/hasherCkb.d.ts.map +1 -1
  48. package/dist/hasher/hasherCkb.js +6 -1
  49. package/dist/hasher/hasherKeecak256.d.ts +3 -0
  50. package/dist/hasher/hasherKeecak256.d.ts.map +1 -1
  51. package/dist/hasher/hasherKeecak256.js +3 -0
  52. package/dist/hex/index.d.ts +3 -0
  53. package/dist/hex/index.d.ts.map +1 -1
  54. package/dist/hex/index.js +1 -0
  55. package/dist/keystore/index.d.ts +6 -0
  56. package/dist/keystore/index.d.ts.map +1 -1
  57. package/dist/keystore/index.js +6 -0
  58. package/dist/num/index.d.ts +11 -0
  59. package/dist/num/index.d.ts.map +1 -1
  60. package/dist/num/index.js +9 -0
  61. package/dist/package.json +1 -1
  62. package/dist/signer/btc/signerBtc.d.ts +1 -0
  63. package/dist/signer/btc/signerBtc.d.ts.map +1 -1
  64. package/dist/signer/btc/signerBtc.js +1 -0
  65. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +1 -0
  66. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  67. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +1 -0
  68. package/dist/signer/btc/verify.d.ts +3 -0
  69. package/dist/signer/btc/verify.d.ts.map +1 -1
  70. package/dist/signer/btc/verify.js +3 -0
  71. package/dist/signer/ckb/signerCkbPrivateKey.d.ts +3 -0
  72. package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
  73. package/dist/signer/ckb/signerCkbPrivateKey.js +3 -0
  74. package/dist/signer/ckb/signerCkbPublicKey.d.ts +3 -0
  75. package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +1 -1
  76. package/dist/signer/ckb/signerCkbPublicKey.js +3 -0
  77. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +1 -0
  78. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  79. package/dist/signer/ckb/signerCkbScriptReadonly.js +1 -0
  80. package/dist/signer/ckb/verifyCkbSecp256k1.d.ts +6 -0
  81. package/dist/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -1
  82. package/dist/signer/ckb/verifyCkbSecp256k1.js +6 -0
  83. package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
  84. package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -1
  85. package/dist/signer/ckb/verifyJoyId.js +3 -0
  86. package/dist/signer/dummy/alwaysError.d.ts +3 -0
  87. package/dist/signer/dummy/alwaysError.d.ts.map +1 -1
  88. package/dist/signer/dummy/alwaysError.js +3 -0
  89. package/dist/signer/dummy/dummy.d.ts +3 -0
  90. package/dist/signer/dummy/dummy.d.ts.map +1 -1
  91. package/dist/signer/dummy/dummy.js +3 -0
  92. package/dist/signer/dummy/openLink.d.ts +3 -0
  93. package/dist/signer/dummy/openLink.d.ts.map +1 -1
  94. package/dist/signer/dummy/openLink.js +3 -0
  95. package/dist/signer/evm/signerEvm.d.ts +1 -0
  96. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  97. package/dist/signer/evm/signerEvm.js +1 -0
  98. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +1 -0
  99. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  100. package/dist/signer/evm/signerEvmAddressReadonly.js +1 -0
  101. package/dist/signer/evm/verify.d.ts +3 -0
  102. package/dist/signer/evm/verify.d.ts.map +1 -1
  103. package/dist/signer/evm/verify.js +3 -0
  104. package/dist/signer/nostr/signerNostr.d.ts +6 -0
  105. package/dist/signer/nostr/signerNostr.d.ts.map +1 -1
  106. package/dist/signer/nostr/signerNostr.js +3 -0
  107. package/dist/signer/nostr/verify.d.ts +3 -0
  108. package/dist/signer/nostr/verify.d.ts.map +1 -1
  109. package/dist/signer/nostr/verify.js +3 -0
  110. package/dist/signer/signer/index.d.ts +26 -3
  111. package/dist/signer/signer/index.d.ts.map +1 -1
  112. package/dist/signer/signer/index.js +12 -3
  113. package/dist/utils/index.d.ts +12 -0
  114. package/dist/utils/index.d.ts.map +1 -1
  115. package/dist/utils/index.js +13 -0
  116. package/dist.commonjs/address/index.d.ts +4 -0
  117. package/dist.commonjs/address/index.d.ts.map +1 -1
  118. package/dist.commonjs/address/index.js +1 -0
  119. package/dist.commonjs/advancedBarrel.d.ts +1 -0
  120. package/dist.commonjs/advancedBarrel.d.ts.map +1 -1
  121. package/dist.commonjs/advancedBarrel.js +1 -0
  122. package/dist.commonjs/bytes/advanced.d.ts +1 -0
  123. package/dist.commonjs/bytes/advanced.d.ts.map +1 -1
  124. package/dist.commonjs/bytes/index.d.ts +9 -0
  125. package/dist.commonjs/bytes/index.d.ts.map +1 -1
  126. package/dist.commonjs/bytes/index.js +3 -0
  127. package/dist.commonjs/ckb/index.d.ts +1 -0
  128. package/dist.commonjs/ckb/index.d.ts.map +1 -1
  129. package/dist.commonjs/ckb/index.js +1 -0
  130. package/dist.commonjs/ckb/script.d.ts +15 -0
  131. package/dist.commonjs/ckb/script.d.ts.map +1 -1
  132. package/dist.commonjs/ckb/script.js +6 -0
  133. package/dist.commonjs/ckb/transaction.d.ts +65 -11
  134. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  135. package/dist.commonjs/ckb/transaction.js +41 -14
  136. package/dist.commonjs/ckb/transactionLumos.d.ts +29 -0
  137. package/dist.commonjs/ckb/transactionLumos.d.ts.map +1 -0
  138. package/dist.commonjs/ckb/transactionLumos.js +2 -0
  139. package/dist.commonjs/client/client.d.ts +13 -1
  140. package/dist.commonjs/client/client.d.ts.map +1 -1
  141. package/dist.commonjs/client/client.js +10 -1
  142. package/dist.commonjs/client/clientPublicMainnet.d.ts +3 -0
  143. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
  144. package/dist.commonjs/client/clientPublicMainnet.js +3 -0
  145. package/dist.commonjs/client/clientPublicTestnet.d.ts +3 -0
  146. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
  147. package/dist.commonjs/client/clientPublicTestnet.js +3 -0
  148. package/dist.commonjs/client/clientTypes.d.ts +45 -0
  149. package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
  150. package/dist.commonjs/client/clientTypes.js +9 -0
  151. package/dist.commonjs/client/jsonRpc/index.d.ts +6 -6
  152. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
  153. package/dist.commonjs/client/jsonRpc/index.js +3 -3
  154. package/dist.commonjs/fixedPoint/index.d.ts +6 -0
  155. package/dist.commonjs/fixedPoint/index.d.ts.map +1 -1
  156. package/dist.commonjs/fixedPoint/index.js +5 -0
  157. package/dist.commonjs/hasher/hasher.d.ts +3 -0
  158. package/dist.commonjs/hasher/hasher.d.ts.map +1 -1
  159. package/dist.commonjs/hasher/hasherCkb.d.ts +6 -1
  160. package/dist.commonjs/hasher/hasherCkb.d.ts.map +1 -1
  161. package/dist.commonjs/hasher/hasherCkb.js +6 -1
  162. package/dist.commonjs/hasher/hasherKeecak256.d.ts +3 -0
  163. package/dist.commonjs/hasher/hasherKeecak256.d.ts.map +1 -1
  164. package/dist.commonjs/hasher/hasherKeecak256.js +3 -0
  165. package/dist.commonjs/hex/index.d.ts +3 -0
  166. package/dist.commonjs/hex/index.d.ts.map +1 -1
  167. package/dist.commonjs/hex/index.js +1 -0
  168. package/dist.commonjs/keystore/index.d.ts +6 -0
  169. package/dist.commonjs/keystore/index.d.ts.map +1 -1
  170. package/dist.commonjs/keystore/index.js +6 -0
  171. package/dist.commonjs/num/index.d.ts +11 -0
  172. package/dist.commonjs/num/index.d.ts.map +1 -1
  173. package/dist.commonjs/num/index.js +9 -0
  174. package/dist.commonjs/signer/btc/signerBtc.d.ts +1 -0
  175. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
  176. package/dist.commonjs/signer/btc/signerBtc.js +1 -0
  177. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +1 -0
  178. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  179. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +1 -0
  180. package/dist.commonjs/signer/btc/verify.d.ts +3 -0
  181. package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
  182. package/dist.commonjs/signer/btc/verify.js +3 -0
  183. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +3 -0
  184. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
  185. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +3 -0
  186. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +3 -0
  187. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +1 -1
  188. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +3 -0
  189. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +1 -0
  190. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  191. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +1 -0
  192. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +6 -0
  193. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -1
  194. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +6 -0
  195. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +3 -0
  196. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -1
  197. package/dist.commonjs/signer/ckb/verifyJoyId.js +3 -0
  198. package/dist.commonjs/signer/dummy/alwaysError.d.ts +3 -0
  199. package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -1
  200. package/dist.commonjs/signer/dummy/alwaysError.js +3 -0
  201. package/dist.commonjs/signer/dummy/dummy.d.ts +3 -0
  202. package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -1
  203. package/dist.commonjs/signer/dummy/dummy.js +3 -0
  204. package/dist.commonjs/signer/dummy/openLink.d.ts +3 -0
  205. package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -1
  206. package/dist.commonjs/signer/dummy/openLink.js +3 -0
  207. package/dist.commonjs/signer/evm/signerEvm.d.ts +1 -0
  208. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
  209. package/dist.commonjs/signer/evm/signerEvm.js +1 -0
  210. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +1 -0
  211. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  212. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +1 -0
  213. package/dist.commonjs/signer/evm/verify.d.ts +3 -0
  214. package/dist.commonjs/signer/evm/verify.d.ts.map +1 -1
  215. package/dist.commonjs/signer/evm/verify.js +3 -0
  216. package/dist.commonjs/signer/nostr/signerNostr.d.ts +6 -0
  217. package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +1 -1
  218. package/dist.commonjs/signer/nostr/signerNostr.js +3 -0
  219. package/dist.commonjs/signer/nostr/verify.d.ts +3 -0
  220. package/dist.commonjs/signer/nostr/verify.d.ts.map +1 -1
  221. package/dist.commonjs/signer/nostr/verify.js +3 -0
  222. package/dist.commonjs/signer/signer/index.d.ts +26 -3
  223. package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
  224. package/dist.commonjs/signer/signer/index.js +12 -3
  225. package/dist.commonjs/utils/index.d.ts +12 -0
  226. package/dist.commonjs/utils/index.d.ts.map +1 -1
  227. package/dist.commonjs/utils/index.js +13 -0
  228. package/package.json +8 -10
  229. package/src/address/index.ts +4 -1
  230. package/src/advancedBarrel.ts +1 -0
  231. package/src/bytes/advanced.ts +1 -0
  232. package/src/bytes/index.ts +9 -0
  233. package/src/ckb/index.ts +1 -0
  234. package/src/ckb/script.ts +15 -0
  235. package/src/ckb/transaction.ts +72 -16
  236. package/src/ckb/transactionLumos.ts +26 -0
  237. package/src/client/client.ts +13 -1
  238. package/src/client/clientPublicMainnet.ts +3 -0
  239. package/src/client/clientPublicTestnet.ts +3 -0
  240. package/src/client/clientTypes.ts +45 -0
  241. package/src/client/jsonRpc/index.ts +5 -6
  242. package/src/fixedPoint/index.ts +6 -0
  243. package/src/hasher/hasher.ts +3 -0
  244. package/src/hasher/hasherCkb.ts +6 -1
  245. package/src/hasher/hasherKeecak256.ts +3 -0
  246. package/src/hex/index.ts +3 -0
  247. package/src/keystore/index.ts +6 -0
  248. package/src/num/index.ts +11 -0
  249. package/src/signer/btc/signerBtc.ts +1 -0
  250. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +1 -0
  251. package/src/signer/btc/verify.ts +3 -0
  252. package/src/signer/ckb/signerCkbPrivateKey.ts +3 -0
  253. package/src/signer/ckb/signerCkbPublicKey.ts +3 -0
  254. package/src/signer/ckb/signerCkbScriptReadonly.ts +1 -0
  255. package/src/signer/ckb/verifyCkbSecp256k1.ts +6 -0
  256. package/src/signer/ckb/verifyJoyId.ts +3 -0
  257. package/src/signer/dummy/alwaysError.ts +3 -0
  258. package/src/signer/dummy/dummy.ts +3 -0
  259. package/src/signer/dummy/openLink.ts +3 -0
  260. package/src/signer/evm/signerEvm.ts +1 -0
  261. package/src/signer/evm/signerEvmAddressReadonly.ts +1 -0
  262. package/src/signer/evm/verify.ts +3 -0
  263. package/src/signer/nostr/signerNostr.ts +6 -0
  264. package/src/signer/nostr/verify.ts +3 -0
  265. package/src/signer/signer/index.ts +26 -14
  266. package/src/utils/index.ts +22 -0
  267. package/typedoc.json +6 -0
@@ -1,4 +1,3 @@
1
- import type { TransactionSkeletonType } from "@ckb-lumos/helpers";
2
1
  import { ClientCollectableSearchKeyFilterLike } from "../advancedBarrel.js";
3
2
  import { Bytes, BytesLike, bytesFrom } from "../bytes/index.js";
4
3
  import { CellDepInfoLike, Client, KnownScript } from "../client/index.js";
@@ -22,12 +21,20 @@ import { apply, reduceAsync } from "../utils/index.js";
22
21
  import * as mol from "./molecule.advanced/index.js";
23
22
  import { Script, ScriptLike } from "./script.js";
24
23
  import { DEP_TYPE_TO_NUM, NUM_TO_DEP_TYPE } from "./transaction.advanced.js";
24
+ import { LumosTransactionSkeletonType } from "./transactionLumos.js";
25
25
 
26
+ /**
27
+ * @public
28
+ */
26
29
  export type DepTypeLike = string | number | bigint;
30
+ /**
31
+ * @public
32
+ */
27
33
  export type DepType = "depGroup" | "code";
28
34
 
29
35
  /**
30
36
  * Converts a DepTypeLike value to a DepType.
37
+ * @public
31
38
  *
32
39
  * @param val - The value to convert, which can be a string, number, or bigint.
33
40
  * @returns The corresponding DepType.
@@ -61,6 +68,7 @@ export function depTypeFrom(val: DepTypeLike): DepType {
61
68
 
62
69
  /**
63
70
  * Converts a DepTypeLike value to its corresponding byte representation.
71
+ * @public
64
72
  *
65
73
  * @param depType - The dep type value to convert.
66
74
  * @returns A Uint8Array containing the byte representation of the dep type.
@@ -77,6 +85,7 @@ export function depTypeToBytes(depType: DepTypeLike): Bytes {
77
85
 
78
86
  /**
79
87
  * Converts a byte-like value to a DepType.
88
+ * @public
80
89
  *
81
90
  * @param bytes - The byte-like value to convert.
82
91
  * @returns The corresponding DepType.
@@ -93,10 +102,16 @@ export function depTypeFromBytes(bytes: BytesLike): DepType {
93
102
  return NUM_TO_DEP_TYPE[bytesFrom(bytes)[0]];
94
103
  }
95
104
 
105
+ /**
106
+ * @public
107
+ */
96
108
  export type OutPointLike = {
97
109
  txHash: HexLike;
98
110
  index: NumLike;
99
111
  };
112
+ /**
113
+ * @public
114
+ */
100
115
  export class OutPoint {
101
116
  /**
102
117
  * Creates an instance of OutPoint.
@@ -211,11 +226,17 @@ export class OutPoint {
211
226
  }
212
227
  }
213
228
 
229
+ /**
230
+ * @public
231
+ */
214
232
  export type CellOutputLike = {
215
233
  capacity: NumLike;
216
234
  lock: ScriptLike;
217
235
  type?: ScriptLike | null;
218
236
  };
237
+ /**
238
+ * @public
239
+ */
219
240
  export class CellOutput {
220
241
  /**
221
242
  * Creates an instance of CellOutput.
@@ -331,11 +352,17 @@ export class CellOutput {
331
352
  }
332
353
  }
333
354
 
355
+ /**
356
+ * @public
357
+ */
334
358
  export type CellLike = {
335
359
  outPoint: OutPointLike;
336
360
  cellOutput: CellOutputLike;
337
361
  outputData: HexLike;
338
362
  };
363
+ /**
364
+ * @public
365
+ */
339
366
  export class Cell {
340
367
  /**
341
368
  * Creates an instance of Cell.
@@ -389,12 +416,18 @@ export class Cell {
389
416
  }
390
417
  }
391
418
 
419
+ /**
420
+ * @public
421
+ */
392
422
  export type CellInputLike = {
393
423
  previousOutput: OutPointLike;
394
424
  since?: NumLike | null;
395
425
  cellOutput?: CellOutputLike | null;
396
426
  outputData?: HexLike | null;
397
427
  };
428
+ /**
429
+ * @public
430
+ */
398
431
  export class CellInput {
399
432
  /**
400
433
  * Creates an instance of CellInput.
@@ -535,10 +568,16 @@ export class CellInput {
535
568
  }
536
569
  }
537
570
 
571
+ /**
572
+ * @public
573
+ */
538
574
  export type CellDepLike = {
539
575
  outPoint: OutPointLike;
540
576
  depType: DepTypeLike;
541
577
  };
578
+ /**
579
+ * @public
580
+ */
542
581
  export class CellDep {
543
582
  /**
544
583
  * Creates an instance of CellDep.
@@ -662,11 +701,17 @@ export class CellDep {
662
701
  }
663
702
  }
664
703
 
704
+ /**
705
+ * @public
706
+ */
665
707
  export type WitnessArgsLike = {
666
708
  lock?: HexLike | null;
667
709
  inputType?: HexLike | null;
668
710
  outputType?: HexLike | null;
669
711
  };
712
+ /**
713
+ * @public
714
+ */
670
715
  export class WitnessArgs {
671
716
  /**
672
717
  * Creates an instance of WitnessArgs.
@@ -765,6 +810,9 @@ export class WitnessArgs {
765
810
  }
766
811
  }
767
812
 
813
+ /**
814
+ * @public
815
+ */
768
816
  export function udtBalanceFrom(dataLike: BytesLike): Num {
769
817
  const data = bytesFrom(dataLike).slice(0, 16);
770
818
  if (data.length !== 16) {
@@ -774,6 +822,9 @@ export function udtBalanceFrom(dataLike: BytesLike): Num {
774
822
  return numFromBytes(data);
775
823
  }
776
824
 
825
+ /**
826
+ * @public
827
+ */
777
828
  export type TransactionLike = {
778
829
  version?: NumLike | null;
779
830
  cellDeps?: CellDepLike[] | null;
@@ -786,6 +837,9 @@ export type TransactionLike = {
786
837
  outputsData?: HexLike[] | null;
787
838
  witnesses?: HexLike[] | null;
788
839
  };
840
+ /**
841
+ * @public
842
+ */
789
843
  export class Transaction {
790
844
  /**
791
845
  * Creates an instance of Transaction.
@@ -936,7 +990,9 @@ export class Transaction {
936
990
  * ```
937
991
  */
938
992
 
939
- static fromLumosSkeleton(skeleton: TransactionSkeletonType): Transaction {
993
+ static fromLumosSkeleton(
994
+ skeleton: LumosTransactionSkeletonType,
995
+ ): Transaction {
940
996
  return Transaction.from({
941
997
  version: 0n,
942
998
  cellDeps: skeleton.cellDeps.toArray(),
@@ -1124,10 +1180,10 @@ export class Transaction {
1124
1180
  * ```
1125
1181
  */
1126
1182
  async findInputIndexByLockId(
1127
- scriptLike: Pick<ScriptLike, "codeHash" | "hashType">,
1183
+ scriptIdLike: Pick<ScriptLike, "codeHash" | "hashType">,
1128
1184
  client: Client,
1129
1185
  ): Promise<number | undefined> {
1130
- const script = Script.from({ ...scriptLike, args: "0x" });
1186
+ const script = Script.from({ ...scriptIdLike, args: "0x" });
1131
1187
 
1132
1188
  for (let i = 0; i < this.inputs.length; i += 1) {
1133
1189
  const input = this.inputs[i];
@@ -1217,8 +1273,8 @@ export class Transaction {
1217
1273
  * tx.addCellDeps(cellDep);
1218
1274
  * ```
1219
1275
  */
1220
- addCellDeps(...cellDepsLike: (CellDepLike | CellDepLike[])[]): void {
1221
- cellDepsLike.flat().forEach((cellDepLike) => {
1276
+ addCellDeps(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void {
1277
+ cellDepLikes.flat().forEach((cellDepLike) => {
1222
1278
  const cellDep = CellDep.from(cellDepLike);
1223
1279
  if (this.cellDeps.some((c) => c.eq(cellDep))) {
1224
1280
  return;
@@ -1238,8 +1294,8 @@ export class Transaction {
1238
1294
  * tx.addCellDepsAtBegin(cellDep);
1239
1295
  * ```
1240
1296
  */
1241
- addCellDepsAtStart(...cellDepsLike: (CellDepLike | CellDepLike[])[]): void {
1242
- cellDepsLike.flat().forEach((cellDepLike) => {
1297
+ addCellDepsAtStart(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void {
1298
+ cellDepLikes.flat().forEach((cellDepLike) => {
1243
1299
  const cellDep = CellDep.from(cellDepLike);
1244
1300
  if (this.cellDeps.some((c) => c.eq(cellDep))) {
1245
1301
  return;
@@ -1253,7 +1309,7 @@ export class Transaction {
1253
1309
  * Add cell dep from infos if they are not existed
1254
1310
  *
1255
1311
  * @param client - A client for searching cell deps
1256
- * @param cellDepLikes - The cell dep infos to add
1312
+ * @param cellDepInfoLikes - The cell dep infos to add
1257
1313
  *
1258
1314
  * @example
1259
1315
  * ```typescript
@@ -1262,9 +1318,9 @@ export class Transaction {
1262
1318
  */
1263
1319
  async addCellDepInfos(
1264
1320
  client: Client,
1265
- ...cellDepInfosLike: (CellDepInfoLike | CellDepInfoLike[])[]
1321
+ ...cellDepInfoLikes: (CellDepInfoLike | CellDepInfoLike[])[]
1266
1322
  ): Promise<void> {
1267
- this.addCellDeps(await client.getCellDeps(...cellDepInfosLike));
1323
+ this.addCellDeps(await client.getCellDeps(...cellDepInfoLikes));
1268
1324
  }
1269
1325
 
1270
1326
  /**
@@ -1302,10 +1358,10 @@ export class Transaction {
1302
1358
  *
1303
1359
  * @example
1304
1360
  * ```typescript
1305
- * await tx.setOutputData(0, "0x00");
1361
+ * await tx.setOutputDataAt(0, "0x00");
1306
1362
  * ```
1307
1363
  */
1308
- setOutputDataAt(index: number, data: HexLike): void {
1364
+ setOutputDataAt(index: number, witness: HexLike): void {
1309
1365
  if (this.outputsData.length < index) {
1310
1366
  this.outputsData.push(
1311
1367
  ...Array.from(
@@ -1315,14 +1371,14 @@ export class Transaction {
1315
1371
  );
1316
1372
  }
1317
1373
 
1318
- this.outputsData[index] = hexFrom(data);
1374
+ this.outputsData[index] = hexFrom(witness);
1319
1375
  }
1320
1376
 
1321
1377
  /**
1322
1378
  * Add output
1323
1379
  *
1324
- * @param output - The cell output to add
1325
- * @param data - optional output data
1380
+ * @param outputLike - The cell output to add
1381
+ * @param outputData - optional output data
1326
1382
  *
1327
1383
  * @example
1328
1384
  * ```typescript
@@ -0,0 +1,26 @@
1
+ import { CellDepLike, CellOutputLike, HexLike, OutPointLike } from "../barrel";
2
+
3
+ export interface LumosTransactionSkeletonType {
4
+ cellDeps: {
5
+ toArray(): CellDepLike[];
6
+ };
7
+ headerDeps: {
8
+ toArray(): HexLike[];
9
+ };
10
+ inputs: {
11
+ toArray(): {
12
+ outPoint?: OutPointLike;
13
+ cellOutput: CellOutputLike;
14
+ data: HexLike;
15
+ }[];
16
+ };
17
+ inputSinces: {
18
+ get(i: number, defaultVal: string): HexLike;
19
+ };
20
+ outputs: {
21
+ toArray(): { cellOutput: CellOutputLike; data: HexLike }[];
22
+ };
23
+ witnesses: {
24
+ toArray(): HexLike[];
25
+ };
26
+ }
@@ -28,6 +28,9 @@ import {
28
28
  OutputsValidator,
29
29
  } from "./clientTypes.js";
30
30
 
31
+ /**
32
+ * @public
33
+ */
31
34
  export enum KnownScript {
32
35
  Secp256k1Blake160 = "Secp256k1Blake160",
33
36
  Secp256k1Multisig = "Secp256k1Multisig",
@@ -44,11 +47,17 @@ export enum KnownScript {
44
47
  OutputTypeProxyLock = "OutputTypeProxyLock",
45
48
  }
46
49
 
50
+ /**
51
+ * @public
52
+ */
47
53
  export type CellDepInfoLike = {
48
54
  cellDep: CellDepLike;
49
55
  type?: ScriptLike | null;
50
56
  };
51
57
 
58
+ /**
59
+ * @public
60
+ */
52
61
  export class CellDepInfo {
53
62
  constructor(
54
63
  public cellDep: CellDep,
@@ -63,6 +72,9 @@ export class CellDepInfo {
63
72
  }
64
73
  }
65
74
 
75
+ /**
76
+ * @public
77
+ */
66
78
  export abstract class Client {
67
79
  private readonly cachedTransactions: Transaction[] = [];
68
80
  private readonly unusableOutPoints: OutPoint[] = [];
@@ -190,7 +202,7 @@ export abstract class Client {
190
202
  /**
191
203
  * Find cells by search key designed for collectable cells.
192
204
  *
193
- * @param key - The search key.
205
+ * @param keyLike - The search key.
194
206
  * @returns A async generator for yielding cells.
195
207
  */
196
208
  async *findCellsByCollectableSearchKey(
@@ -3,6 +3,9 @@ import { CellDepInfo, KnownScript } from "./client.js";
3
3
  import { MAINNET_SCRIPTS } from "./clientPublicMainnet.advanced.js";
4
4
  import { ClientJsonRpc } from "./jsonRpc/index.js";
5
5
 
6
+ /**
7
+ * @public
8
+ */
6
9
  export class ClientPublicMainnet extends ClientJsonRpc {
7
10
  constructor(
8
11
  url = "https://mainnet.ckb.dev/",
@@ -3,6 +3,9 @@ import { CellDepInfo, KnownScript } from "./client.js";
3
3
  import { TESTNET_SCRIPTS } from "./clientPublicTestnet.advanced.js";
4
4
  import { ClientJsonRpc } from "./jsonRpc/index.js";
5
5
 
6
+ /**
7
+ * @public
8
+ */
6
9
  export class ClientPublicTestnet extends ClientJsonRpc {
7
10
  constructor(
8
11
  url = "https://testnet.ckb.dev/",
@@ -8,23 +8,38 @@ import {
8
8
  clientSearchKeyRangeFrom,
9
9
  } from "./clientTypes.advanced.js";
10
10
 
11
+ /**
12
+ * @public
13
+ */
11
14
  export type OutputsValidator = "passthrough" | "well_known_scripts_only";
12
15
 
16
+ /**
17
+ * @public
18
+ */
13
19
  export type TransactionStatus =
14
20
  | "pending"
15
21
  | "proposed"
16
22
  | "committed"
17
23
  | "unknown"
18
24
  | "rejected";
25
+ /**
26
+ * @public
27
+ */
19
28
  export type ClientTransactionResponse = {
20
29
  transaction: Transaction;
21
30
  status: TransactionStatus;
22
31
  };
23
32
 
33
+ /**
34
+ * @public
35
+ */
24
36
  export type ClientIndexerSearchKeyFilterLike =
25
37
  ClientCollectableSearchKeyFilterLike & {
26
38
  blockRange?: [NumLike, NumLike] | null;
27
39
  };
40
+ /**
41
+ * @public
42
+ */
28
43
  export class ClientIndexerSearchKeyFilter {
29
44
  constructor(
30
45
  public script: Script | undefined,
@@ -51,10 +66,16 @@ export class ClientIndexerSearchKeyFilter {
51
66
  }
52
67
  }
53
68
 
69
+ /**
70
+ * @public
71
+ */
54
72
  export type ClientIndexerSearchKeyLike = ClientCollectableSearchKeyLike & {
55
73
  filter?: ClientIndexerSearchKeyFilterLike | null;
56
74
  };
57
75
 
76
+ /**
77
+ * @public
78
+ */
58
79
  export class ClientIndexerSearchKey {
59
80
  constructor(
60
81
  public script: Script,
@@ -75,11 +96,17 @@ export class ClientIndexerSearchKey {
75
96
  }
76
97
  }
77
98
 
99
+ /**
100
+ * @public
101
+ */
78
102
  export type ClientFindCellsResponse = {
79
103
  lastCursor: string;
80
104
  cells: Cell[];
81
105
  };
82
106
 
107
+ /**
108
+ * @public
109
+ */
83
110
  export type ClientIndexerSearchKeyTransactionLike = Omit<
84
111
  ClientCollectableSearchKeyLike,
85
112
  "withData"
@@ -88,6 +115,9 @@ export type ClientIndexerSearchKeyTransactionLike = Omit<
88
115
  groupByTransaction?: boolean | null;
89
116
  };
90
117
 
118
+ /**
119
+ * @public
120
+ */
91
121
  export class ClientIndexerSearchKeyTransaction {
92
122
  constructor(
93
123
  public script: Script,
@@ -110,6 +140,9 @@ export class ClientIndexerSearchKeyTransaction {
110
140
  }
111
141
  }
112
142
 
143
+ /**
144
+ * @public
145
+ */
113
146
  export type ClientFindTransactionsResponse = {
114
147
  lastCursor: string;
115
148
  transactions: {
@@ -121,6 +154,9 @@ export type ClientFindTransactionsResponse = {
121
154
  }[];
122
155
  };
123
156
 
157
+ /**
158
+ * @public
159
+ */
124
160
  export type ClientFindTransactionsGroupedResponse = {
125
161
  lastCursor: string;
126
162
  transactions: {
@@ -134,6 +170,9 @@ export type ClientFindTransactionsGroupedResponse = {
134
170
  }[];
135
171
  };
136
172
 
173
+ /**
174
+ * @public
175
+ */
137
176
  export type ClientBlockHeader = {
138
177
  compactTarget: Num;
139
178
  dao: Hex;
@@ -149,11 +188,17 @@ export type ClientBlockHeader = {
149
188
  version: Num;
150
189
  };
151
190
 
191
+ /**
192
+ * @public
193
+ */
152
194
  export type ClientBlockUncle = {
153
195
  header: ClientBlockHeader;
154
196
  proposals: Hex[];
155
197
  };
156
198
 
199
+ /**
200
+ * @public
201
+ */
157
202
  export type ClientBlock = {
158
203
  header: ClientBlockHeader;
159
204
  proposals: Hex[];
@@ -5,7 +5,6 @@ import { Hex, HexLike, hexFrom } from "../../hex/index.js";
5
5
  import { Num, NumLike, numFrom, numToHex } from "../../num/index.js";
6
6
  import { Client } from "../client.js";
7
7
  import {
8
- ClientBlock,
9
8
  ClientFindCellsResponse,
10
9
  ClientIndexerSearchKeyLike,
11
10
  ClientTransactionResponse,
@@ -46,7 +45,7 @@ export abstract class ClientJsonRpc extends Client {
46
45
  /**
47
46
  * Creates an instance of ClientJsonRpc.
48
47
  *
49
- * @param url - The URL of the JSON-RPC server.
48
+ * @param url_ - The URL of the JSON-RPC server.
50
49
  * @param timeout - The timeout for requests in milliseconds, default is 30000.
51
50
  */
52
51
 
@@ -84,26 +83,26 @@ export abstract class ClientJsonRpc extends Client {
84
83
  *
85
84
  * @param blockNumber - The block number.
86
85
  * @param verbosity - result format which allows 0 and 2. (Optional, the default is 2.)
87
- * @param with_cycles - whether the return cycles of block transactions. (Optional, default false.)
86
+ * @param withCycles - whether the return cycles of block transactions. (Optional, default false.)
88
87
  * @returns Block
89
88
  */
90
89
  getBlockByNumber = this.buildSender(
91
90
  "get_block_by_number",
92
91
  [(v: NumLike) => numToHex(numFrom(v))],
93
92
  (b) => apply(JsonRpcTransformers.blockTo, b),
94
- ) as () => Promise<ClientBlock | undefined>;
93
+ ) as Client["getBlockByNumber"];
95
94
 
96
95
  /**
97
96
  * Get block by block hash
98
97
  *
99
98
  * @param blockHash - The block hash.
100
99
  * @param verbosity - result format which allows 0 and 2. (Optional, the default is 2.)
101
- * @param with_cycles - whether the return cycles of block transactions. (Optional, default false.)
100
+ * @param withCycles - whether the return cycles of block transactions. (Optional, default false.)
102
101
  * @returns Block
103
102
  */
104
103
  getBlockByHash = this.buildSender("get_block", [hexFrom], (b) =>
105
104
  apply(JsonRpcTransformers.blockTo, b),
106
- ) as () => Promise<ClientBlock | undefined>;
105
+ ) as Client["getBlockByHash"];
107
106
 
108
107
  /**
109
108
  * Send a transaction to node.
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Represents a fixed point value as a bigint.
3
+ * @public
3
4
  */
4
5
 
5
6
  export type FixedPoint = bigint;
@@ -7,12 +8,14 @@ export type FixedPoint = bigint;
7
8
  /**
8
9
  * Represents a value that can be converted to a fixed point value.
9
10
  * It can be a bigint, string, or number.
11
+ * @public
10
12
  */
11
13
 
12
14
  export type FixedPointLike = bigint | string | number;
13
15
 
14
16
  /**
15
17
  * Converts a FixedPointLike value to its string representation with fixed-point decimals.
18
+ * @public
16
19
  *
17
20
  * @param val - The value to convert, which can be a bigint, string, or number.
18
21
  * @param decimals - The number of decimal places for the fixed-point representation. Default is 8.
@@ -43,6 +46,7 @@ export function fixedPointToString(val: FixedPointLike, decimals = 8): string {
43
46
 
44
47
  /**
45
48
  * Converts a FixedPointLike value to a FixedPoint (bigint) with fixed-point decimals.
49
+ * @public
46
50
  *
47
51
  * @param val - The value to convert, which can be a bigint, string, or number.
48
52
  * @param decimals - The number of decimal places for the fixed-point representation. Default is 8.
@@ -74,6 +78,7 @@ export function fixedPointFrom(val: FixedPointLike, decimals = 8): FixedPoint {
74
78
 
75
79
  /**
76
80
  * Represents the fixed point value of zero as a bigint.
81
+ * @public
77
82
  */
78
83
 
79
84
  export const Zero: FixedPoint = 0n;
@@ -81,6 +86,7 @@ export const Zero: FixedPoint = 0n;
81
86
  /**
82
87
  * Represents the fixed point value of one as a FixedPoint (bigint).
83
88
  * Equivalent to 1 in fixed-point representation with default decimals (8).
89
+ * @public
84
90
  */
85
91
 
86
92
  export const One: FixedPoint = fixedPointFrom("1");
@@ -1,6 +1,9 @@
1
1
  import { BytesLike } from "../bytes/index.js";
2
2
  import { Hex } from "../hex/index.js";
3
3
 
4
+ /**
5
+ * @public
6
+ */
4
7
  export interface Hasher {
5
8
  /**
6
9
  * Updates the hash with the given data.
@@ -6,6 +6,9 @@ import { NumLike, numLeToBytes } from "../num/index.js";
6
6
  import { CKB_BLAKE2B_PERSONAL } from "./advanced.js";
7
7
  import { Hasher } from "./hasher.js";
8
8
 
9
+ /**
10
+ * @public
11
+ */
9
12
  export class HasherCkb implements Hasher {
10
13
  private readonly hasher: ReturnType<(typeof blake2b)["create"]>;
11
14
 
@@ -62,6 +65,7 @@ export class HasherCkb implements Hasher {
62
65
 
63
66
  /**
64
67
  * Computes the CKB hash of the given data using the Blake2b algorithm.
68
+ * @public
65
69
  *
66
70
  * @param data - The data to hash.
67
71
  * @returns The hexadecimal string representation of the hash.
@@ -80,8 +84,9 @@ export function hashCkb(...data: BytesLike[]): Hex {
80
84
 
81
85
  /**
82
86
  * Computes the Type ID hash of the given data.
87
+ * @public
83
88
  *
84
- * @param cellInput - The first cell input of the transaction.
89
+ * @param cellInputLike - The first cell input of the transaction.
85
90
  * @param outputIndex - The output index of the Type ID cell.
86
91
  * @returns The hexadecimal string representation of the hash.
87
92
  *
@@ -3,6 +3,9 @@ import { BytesLike, bytesFrom } from "../bytes/index.js";
3
3
  import { Hex, hexFrom } from "../hex/index.js";
4
4
  import { Hasher } from "./hasher.js";
5
5
 
6
+ /**
7
+ * @public
8
+ */
6
9
  export class HasherKeecak256 implements Hasher {
7
10
  private readonly hasher: ReturnType<(typeof keccak_256)["create"]>;
8
11
 
package/src/hex/index.ts CHANGED
@@ -2,16 +2,19 @@ import { bytesFrom, BytesLike, bytesTo } from "../bytes/index.js";
2
2
 
3
3
  /**
4
4
  * Represents a hexadecimal string prefixed with "0x".
5
+ * @public
5
6
  */
6
7
  export type Hex = `0x${string}`;
7
8
  /**
8
9
  * Represents a value that can be converted to a hexadecimal string.
9
10
  * It extends the BytesLike type.
11
+ * @public
10
12
  */
11
13
  export type HexLike = BytesLike;
12
14
 
13
15
  /**
14
16
  * Converts a HexLike value to a Hex string.
17
+ * @public
15
18
  *
16
19
  * @param hex - The value to convert, which can be a string, Uint8Array, ArrayBuffer, or number array.
17
20
  * @returns A Hex string representing the value.
@@ -18,6 +18,9 @@ function mac(derivedKey: Bytes, cipherText: Bytes) {
18
18
  ).slice(2);
19
19
  }
20
20
 
21
+ /**
22
+ * @public
23
+ */
21
24
  export async function keystoreEncrypt(
22
25
  privateKeyLike: BytesLike,
23
26
  chainCodeLike: BytesLike,
@@ -79,6 +82,9 @@ export async function keystoreEncrypt(
79
82
  };
80
83
  }
81
84
 
85
+ /**
86
+ * @public
87
+ */
82
88
  export async function keystoreDecrypt(
83
89
  keystore: unknown,
84
90
  password: string,