@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
package/src/num/index.ts CHANGED
@@ -3,17 +3,20 @@ import { Hex, HexLike, hexFrom } from "../hex/index.js";
3
3
 
4
4
  /**
5
5
  * Represents a numeric value as a bigint.
6
+ * @public
6
7
  */
7
8
  export type Num = bigint;
8
9
 
9
10
  /**
10
11
  * Represents a value that can be converted to a numeric value.
11
12
  * It can be a string, number, bigint, or HexLike.
13
+ * @public
12
14
  */
13
15
  export type NumLike = string | number | bigint | HexLike;
14
16
 
15
17
  /**
16
18
  * Get the max among all numbers.
19
+ * @public
17
20
  *
18
21
  * @param numbers - numbers.
19
22
  * @returns The max numbers among them.
@@ -36,6 +39,7 @@ export function numMax(a: NumLike, ...numbers: NumLike[]): Num {
36
39
 
37
40
  /**
38
41
  * Converts a NumLike value to a Num (bigint).
42
+ * @public
39
43
  *
40
44
  * @param val - The value to convert, which can be a string, number, bigint, or HexLike.
41
45
  * @returns A Num (bigint) representing the value.
@@ -60,6 +64,7 @@ export function numFrom(val: NumLike): Num {
60
64
 
61
65
  /**
62
66
  * Converts a NumLike value to a hexadecimal string.
67
+ * @public
63
68
  *
64
69
  * @param val - The value to convert, which can be a string, number, bigint, or HexLike.
65
70
  * @returns A Hex string representing the numeric value.
@@ -75,6 +80,7 @@ export function numToHex(val: NumLike): Hex {
75
80
 
76
81
  /**
77
82
  * Converts a NumLike value to a byte array in little-endian order.
83
+ * @public
78
84
  *
79
85
  * @param val - The value to convert, which can be a string, number, bigint, or HexLike.
80
86
  * @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
@@ -92,6 +98,7 @@ export function numToBytes(val: NumLike, bytes?: number): Bytes {
92
98
 
93
99
  /**
94
100
  * Converts a NumLike value to a byte array in little-endian order.
101
+ * @public
95
102
  *
96
103
  * @param val - The value to convert, which can be a string, number, bigint, or HexLike.
97
104
  * @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
@@ -108,6 +115,7 @@ export function numLeToBytes(val: NumLike, bytes?: number): Bytes {
108
115
 
109
116
  /**
110
117
  * Converts a NumLike value to a byte array in big-endian order.
118
+ * @public
111
119
  *
112
120
  * @param val - The value to convert, which can be a string, number, bigint, or HexLike.
113
121
  * @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
@@ -132,6 +140,7 @@ export function numBeToBytes(val: NumLike, bytes?: number): Bytes {
132
140
 
133
141
  /**
134
142
  * Converts a byte array to a Num (bigint) assuming little-endian order.
143
+ * @public
135
144
  *
136
145
  * @param val - The byte array to convert.
137
146
  * @returns A Num (bigint) representing the numeric value.
@@ -147,6 +156,7 @@ export function numFromBytes(val: BytesLike): Num {
147
156
 
148
157
  /**
149
158
  * Converts a byte array to a Num (bigint) assuming little-endian order.
159
+ * @public
150
160
  *
151
161
  * @param val - The byte array to convert.
152
162
  * @returns A Num (bigint) representing the numeric value.
@@ -162,6 +172,7 @@ export function numLeFromBytes(val: BytesLike): Num {
162
172
 
163
173
  /**
164
174
  * Converts a byte array to a Num (bigint) assuming big-endian order.
175
+ * @public
165
176
  *
166
177
  * @param val - The byte array to convert.
167
178
  * @returns A Num (bigint) representing the numeric value.
@@ -12,6 +12,7 @@ import { Signer, SignerSignType, SignerType } from "../signer/index.js";
12
12
  * An abstract class extending the Signer class for Bitcoin-like signing operations.
13
13
  * This class provides methods to get Bitcoin account, public key, and internal address,
14
14
  * as well as signing transactions.
15
+ * @public
15
16
  */
16
17
  export abstract class SignerBtc extends Signer {
17
18
  get type(): SignerType {
@@ -5,6 +5,7 @@ import { SignerBtc } from "./signerBtc.js";
5
5
  /**
6
6
  * A class extending SignerBtc that provides read-only access to a Bitcoin public key and account.
7
7
  * This class does not support signing operations.
8
+ * @public
8
9
  */
9
10
  export class SignerBtcPublicKeyReadonly extends SignerBtc {
10
11
  private readonly publicKey: Hex;
@@ -3,6 +3,9 @@ import { magicHash } from "bitcoinjs-message";
3
3
  import { BytesLike, bytesFrom } from "../../bytes/index.js";
4
4
  import { hexFrom } from "../../hex/index.js";
5
5
 
6
+ /**
7
+ * @public
8
+ */
6
9
  export function verifyMessageBtcEcdsa(
7
10
  message: string | BytesLike,
8
11
  signature: string,
@@ -7,6 +7,9 @@ import { numBeToBytes } from "../../num/index.js";
7
7
  import { SignerCkbPublicKey } from "./signerCkbPublicKey.js";
8
8
  import { messageHashCkbSecp256k1 } from "./verifyCkbSecp256k1.js";
9
9
 
10
+ /**
11
+ * @public
12
+ */
10
13
  export class SignerCkbPrivateKey extends SignerCkbPublicKey {
11
14
  public readonly privateKey: Hex;
12
15
 
@@ -6,6 +6,9 @@ import { hashCkb } from "../../hasher/index.js";
6
6
  import { Hex, HexLike, hexFrom } from "../../hex/index.js";
7
7
  import { Signer, SignerSignType, SignerType } from "../signer/index.js";
8
8
 
9
+ /**
10
+ * @public
11
+ */
9
12
  export class SignerCkbPublicKey extends Signer {
10
13
  get type(): SignerType {
11
14
  return SignerType.CKB;
@@ -6,6 +6,7 @@ import { Signer, SignerSignType, SignerType } from "../signer/index.js";
6
6
  /**
7
7
  * A class extending Signer that provides read-only access to a CKB script.
8
8
  * This class does not support signing operations.
9
+ * @public
9
10
  */
10
11
  export class SignerCkbScriptReadonly extends Signer {
11
12
  get type(): SignerType {
@@ -4,12 +4,18 @@ import { hashCkb } from "../../hasher/index.js";
4
4
  import { Hex, hexFrom } from "../../hex/index.js";
5
5
  import { numFrom } from "../../num/index.js";
6
6
 
7
+ /**
8
+ * @public
9
+ */
7
10
  export function messageHashCkbSecp256k1(message: string | BytesLike): Hex {
8
11
  const msg = typeof message === "string" ? message : hexFrom(message);
9
12
  const buffer = bytesFrom(`Nervos Message:${msg}`, "utf8");
10
13
  return hashCkb(buffer);
11
14
  }
12
15
 
16
+ /**
17
+ * @public
18
+ */
13
19
  export function verifyMessageCkbSecp256k1(
14
20
  message: string | BytesLike,
15
21
  signature: string,
@@ -2,6 +2,9 @@ import { verifySignature } from "@joyid/ckb";
2
2
  import { BytesLike } from "../../bytes/index.js";
3
3
  import { hexFrom } from "../../hex/index.js";
4
4
 
5
+ /**
6
+ * @public
7
+ */
5
8
  export function verifyMessageJoyId(
6
9
  message: string | BytesLike,
7
10
  signature: string,
@@ -2,6 +2,9 @@ import { Client } from "../../client/index.js";
2
2
  import { SignerType } from "../signer/index.js";
3
3
  import { SignerDummy } from "./dummy.js";
4
4
 
5
+ /**
6
+ * @public
7
+ */
5
8
  export class SignerAlwaysError extends SignerDummy {
6
9
  constructor(
7
10
  client: Client,
@@ -2,6 +2,9 @@ import { Address } from "../../address/index.js";
2
2
  import { Client } from "../../client/index.js";
3
3
  import { Signer, SignerSignType, SignerType } from "../signer/index.js";
4
4
 
5
+ /**
6
+ * @public
7
+ */
5
8
  export abstract class SignerDummy extends Signer {
6
9
  get signType(): SignerSignType {
7
10
  return SignerSignType.Unknown;
@@ -2,6 +2,9 @@ import { Client } from "../../client/index.js";
2
2
  import { SignerType } from "../signer/index.js";
3
3
  import { SignerDummy } from "./dummy.js";
4
4
 
5
+ /**
6
+ * @public
7
+ */
5
8
  export class SignerOpenLink extends SignerDummy {
6
9
  constructor(
7
10
  client: Client,
@@ -16,6 +16,7 @@ import { Signer, SignerSignType, SignerType } from "../signer/index.js";
16
16
  /**
17
17
  * An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
18
18
  * This class provides methods to get EVM account, internal address, and signing transactions.
19
+ * @public
19
20
  */
20
21
  export abstract class SignerEvm extends Signer {
21
22
  get type(): SignerType {
@@ -5,6 +5,7 @@ import { SignerEvm } from "./signerEvm.js";
5
5
  /**
6
6
  * A class extending SignerEvm that provides read-only access to an EVM address.
7
7
  * This class does not support signing operations.
8
+ * @public
8
9
  */
9
10
  export class SignerEvmAddressReadonly extends SignerEvm {
10
11
  private readonly address: Hex;
@@ -1,6 +1,9 @@
1
1
  import { verifyMessage } from "ethers";
2
2
  import { BytesLike, bytesFrom } from "../../bytes/index.js";
3
3
 
4
+ /**
5
+ * @public
6
+ */
4
7
  export function verifyMessageEvmPersonal(
5
8
  message: string | BytesLike,
6
9
  signature: string,
@@ -8,6 +8,9 @@ import { Hex, hexFrom } from "../../hex/index.js";
8
8
  import { Signer, SignerSignType, SignerType } from "../signer/index.js";
9
9
  import { buildNostrEventFromMessage } from "./verify.js";
10
10
 
11
+ /**
12
+ * @public
13
+ */
11
14
  export interface NostrEvent {
12
15
  id?: string;
13
16
  pubkey?: string;
@@ -18,6 +21,9 @@ export interface NostrEvent {
18
21
  content: string;
19
22
  }
20
23
 
24
+ /**
25
+ * @public
26
+ */
21
27
  export abstract class SignerNostr extends Signer {
22
28
  static CKB_SIG_HASH_ALL_TAG = "ckb_sighash_all";
23
29
  static CKB_UNLOCK_EVENT_KIND = 23334;
@@ -5,6 +5,9 @@ import { BytesLike, bytesFrom } from "../../bytes/index.js";
5
5
  import { hexFrom } from "../../hex/index.js";
6
6
  import { NostrEvent } from "./signerNostr.js";
7
7
 
8
+ /**
9
+ * @public
10
+ */
8
11
  export function buildNostrEventFromMessage(
9
12
  message: string | BytesLike,
10
13
  ): NostrEvent {
@@ -10,6 +10,9 @@ import { verifyMessageJoyId } from "../ckb/verifyJoyId.js";
10
10
  import { verifyMessageEvmPersonal } from "../evm/verify.js";
11
11
  import { verifyMessageNostrEvent } from "../nostr/verify.js";
12
12
 
13
+ /**
14
+ * @public
15
+ */
13
16
  export enum SignerSignType {
14
17
  Unknown = "Unknown",
15
18
  BtcEcdsa = "BtcEcdsa",
@@ -21,6 +24,7 @@ export enum SignerSignType {
21
24
 
22
25
  /**
23
26
  * An enumeration of signer display types in wallet.
27
+ * @public
24
28
  */
25
29
  export enum SignerType {
26
30
  EVM = "EVM",
@@ -29,23 +33,28 @@ export enum SignerType {
29
33
  Nostr = "Nostr",
30
34
  }
31
35
 
36
+ /**
37
+ * @public
38
+ */
32
39
  export type NetworkPreference = {
33
40
  addressPrefix: string;
34
41
  signerType: SignerType;
42
+ /**
43
+ * Wallet signers should check if the wallet is using preferred networks.
44
+ * If not, try to switch to the first preferred network.
45
+ * If non preferred, let users choose what they want.
46
+ * BTC: // They made a mess...
47
+ * btc
48
+ * btcTestnet
49
+ * btcSignet // OKX
50
+ * fractalBtc // UniSat
51
+ */
35
52
  network: string;
36
- /*
37
- Wallet signers should check if the wallet is using preferred networks.
38
- If not, try to switch to the first preferred network.
39
- If non preferred, let users choose what they want.
40
-
41
- BTC: // They made a mess...
42
- btc
43
- btcTestnet
44
- btcSignet // OKX
45
- fractalBtc // UniSat
46
- */
47
53
  };
48
54
 
55
+ /**
56
+ * @public
57
+ */
49
58
  export class Signature {
50
59
  constructor(
51
60
  public signature: string,
@@ -57,6 +66,7 @@ export class Signature {
57
66
  /**
58
67
  * An abstract class representing a generic signer.
59
68
  * This class provides methods to connect, get addresses, and sign transactions.
69
+ * @public
60
70
  */
61
71
  export abstract class Signer {
62
72
  constructor(protected client_: Client) {}
@@ -227,7 +237,7 @@ export abstract class Signer {
227
237
  /**
228
238
  * Signs a message.
229
239
  *
230
- * @param _ - The message to sign, as a string or BytesLike object.
240
+ * @param message - The message to sign, as a string or BytesLike object.
231
241
  * @returns A promise that resolves to the signature info.
232
242
  * @throws Will throw an error if not implemented.
233
243
  */
@@ -253,8 +263,8 @@ export abstract class Signer {
253
263
  /**
254
264
  * Verify a signature.
255
265
  *
256
- * @param _ - The original message.
257
- * @param _ - The signature to verify.
266
+ * @param message - The original message.
267
+ * @param signature - The signature to verify.
258
268
  * @returns A promise that resolves to the verification result.
259
269
  * @throws Will throw an error if not implemented.
260
270
  */
@@ -326,6 +336,7 @@ export abstract class Signer {
326
336
 
327
337
  /**
328
338
  * A class representing information about a signer, including its type and the signer instance.
339
+ * @public
329
340
  */
330
341
  export class SignerInfo {
331
342
  constructor(
@@ -336,6 +347,7 @@ export class SignerInfo {
336
347
 
337
348
  /**
338
349
  * Represents a wallet with a name, icon, and an array of signer information.
350
+ * @public
339
351
  */
340
352
  export type Wallet = {
341
353
  name: string;
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * A type safe way to apply a transformer on a value if it's not empty.
3
+ * @public
3
4
  *
4
5
  * @param transformer - The transformer.
5
6
  * @param value - The value to be transformed.
@@ -11,6 +12,7 @@ export function apply<T, R>(
11
12
  ): undefined;
12
13
  /**
13
14
  * A type safe way to apply a transformer on a value if it's not empty.
15
+ * @public
14
16
  *
15
17
  * @param transformer - The transformer.
16
18
  * @param value - The value to be transformed.
@@ -19,6 +21,7 @@ export function apply<T, R>(
19
21
  export function apply<T, R>(transformer: (val: T) => R, value: null): undefined;
20
22
  /**
21
23
  * A type safe way to apply a transformer on a value if it's not empty.
24
+ * @public
22
25
  *
23
26
  * @param transformer - The transformer.
24
27
  * @param value - The value to be transformed.
@@ -27,6 +30,7 @@ export function apply<T, R>(transformer: (val: T) => R, value: null): undefined;
27
30
  export function apply<T, R>(transformer: (val: T) => R, value: T): R;
28
31
  /**
29
32
  * A type safe way to apply a transformer on a value if it's not empty.
33
+ * @public
30
34
  *
31
35
  * @param transformer - The transformer.
32
36
  * @param value - The value to be transformed.
@@ -38,6 +42,7 @@ export function apply<T, R>(
38
42
  ): R | undefined;
39
43
  /**
40
44
  * A type safe way to apply a transformer on a value if it's not empty.
45
+ * @public
41
46
  *
42
47
  * @param transformer - The transformer.
43
48
  * @param value - The value to be transformed.
@@ -49,6 +54,7 @@ export function apply<T, R>(
49
54
  ): R | undefined;
50
55
  /**
51
56
  * A type safe way to apply a transformer on a value if it's not empty.
57
+ * @public
52
58
  *
53
59
  * @param transformer - The transformer.
54
60
  * @param value - The value to be transformed.
@@ -61,6 +67,7 @@ export function apply<T, R>(
61
67
  /**
62
68
  /**
63
69
  * A type safe way to apply a transformer on a value if it's not empty.
70
+ * @public
64
71
  *
65
72
  * @param transformer - The transformer.
66
73
  * @param value - The value to be transformed.
@@ -72,6 +79,7 @@ export function apply<T, R>(
72
79
  ): R | undefined;
73
80
  /**
74
81
  * A type safe way to apply a transformer on a value if it's not empty.
82
+ * @public
75
83
  *
76
84
  * @param transformer - The transformer.
77
85
  * @param value - The value to be transformed.
@@ -90,6 +98,7 @@ export function apply<T, R>(
90
98
 
91
99
  /**
92
100
  * Similar to Array.reduce, but the accumulator can returns Promise.
101
+ * @public
93
102
  *
94
103
  * @param values - The array to be reduced.
95
104
  * @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
@@ -104,6 +113,7 @@ export async function reduceAsync<T, V>(
104
113
  ): Promise<T>;
105
114
  /**
106
115
  * Similar to Array.reduce, but the accumulator can returns Promise.
116
+ * @public
107
117
  *
108
118
  * @param values - The array to be reduced.
109
119
  * @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
@@ -120,6 +130,15 @@ export async function reduceAsync<T, V>(
120
130
  ) => Promise<T | undefined | null | void> | T | undefined | null | void,
121
131
  init: T | Promise<T>,
122
132
  ): Promise<T>;
133
+ /**
134
+ * Similar to Array.reduce, but the accumulator can returns Promise.
135
+ * @public
136
+ *
137
+ * @param values - The array to be reduced.
138
+ * @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
139
+ * @param init - The initial value.
140
+ * @returns The accumulated result.
141
+ */
123
142
  export async function reduceAsync<T, V>(
124
143
  values: (V | T)[],
125
144
  accumulator: (
@@ -147,6 +166,9 @@ export async function reduceAsync<T, V>(
147
166
  );
148
167
  }
149
168
 
169
+ /**
170
+ * @public
171
+ */
150
172
  export function isWebview(userAgent: string): boolean {
151
173
  return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(userAgent);
152
174
  }
package/typedoc.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "entryPoints": ["./src/index.ts", "./src/advanced.ts"],
4
+ "extends": ["../../typedoc.base.json"],
5
+ "name": "@ckb-ccc core"
6
+ }