@ckb-ccc/core 1.12.5 → 1.14.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 (612) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/address.advanced-BmJKF_Lg.mjs +2 -0
  3. package/dist/address.advanced-BmJKF_Lg.mjs.map +1 -0
  4. package/dist/advanced.d.mts +2 -0
  5. package/dist/advanced.mjs +1 -0
  6. package/dist/advancedBarrel-BD7EAPVd.d.mts +5480 -0
  7. package/dist/advancedBarrel-BD7EAPVd.d.mts.map +1 -0
  8. package/dist/advancedBarrel.d.mts +2 -0
  9. package/dist/advancedBarrel.mjs +2 -0
  10. package/dist/advancedBarrel.mjs.map +1 -0
  11. package/dist/barrel-C-sr5NLL.mjs +7 -0
  12. package/dist/barrel-C-sr5NLL.mjs.map +1 -0
  13. package/dist/barrel.d.mts +2 -0
  14. package/dist/barrel.mjs +1 -0
  15. package/dist/index.d.mts +2 -0
  16. package/dist/index.mjs +1 -0
  17. package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
  18. package/dist.commonjs/address.advanced-D9nKvIr3.js +2 -0
  19. package/dist.commonjs/address.advanced-D9nKvIr3.js.map +1 -0
  20. package/dist.commonjs/advanced.d.ts +2 -3
  21. package/dist.commonjs/advanced.js +1 -41
  22. package/dist.commonjs/advancedBarrel-DRDT4GBS.d.ts +5481 -0
  23. package/dist.commonjs/advancedBarrel-DRDT4GBS.d.ts.map +1 -0
  24. package/dist.commonjs/advancedBarrel.d.ts +2 -7
  25. package/dist.commonjs/advancedBarrel.js +2 -22
  26. package/dist.commonjs/advancedBarrel.js.map +1 -0
  27. package/dist.commonjs/barrel-SuR9mcfv.js +21 -0
  28. package/dist.commonjs/barrel-SuR9mcfv.js.map +1 -0
  29. package/dist.commonjs/barrel.d.ts +2 -14
  30. package/dist.commonjs/barrel.js +1 -29
  31. package/dist.commonjs/index.d.ts +2 -3
  32. package/dist.commonjs/index.js +1 -41
  33. package/package.json +42 -34
  34. package/src/address/address.advanced.ts +3 -3
  35. package/src/barrel.ts +1 -0
  36. package/src/ckb/epoch.ts +489 -0
  37. package/src/ckb/index.ts +1 -0
  38. package/src/ckb/script.ts +4 -3
  39. package/src/ckb/transaction.ts +83 -94
  40. package/src/client/client.ts +377 -1
  41. package/src/client/clientPublicMainnet.advanced.ts +23 -0
  42. package/src/client/clientPublicTestnet.advanced.ts +23 -0
  43. package/src/client/clientTypes.ts +1 -2
  44. package/src/client/jsonRpc/transformers.ts +2 -2
  45. package/src/client/knownScript.ts +1 -0
  46. package/src/codec/codec.ts +108 -0
  47. package/src/{molecule → codec}/entity.ts +18 -10
  48. package/src/codec/predefined.ts +145 -0
  49. package/src/hasher/advanced.ts +3 -1
  50. package/src/hasher/hasherCkb.ts +1 -1
  51. package/src/hasher/hasherKeecak256.ts +1 -1
  52. package/src/keystore/index.ts +4 -4
  53. package/src/molecule/barrel.ts +10 -1
  54. package/src/molecule/codec.ts +48 -153
  55. package/src/molecule/predefined.ts +63 -50
  56. package/src/signer/btc/index.ts +1 -0
  57. package/src/signer/btc/psbt.ts +98 -0
  58. package/src/signer/btc/signerBtc.ts +41 -1
  59. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +15 -0
  60. package/src/signer/btc/verify.ts +2 -1
  61. package/src/signer/ckb/signerCkbPrivateKey.ts +6 -11
  62. package/src/signer/ckb/verifyCkbSecp256k1.ts +6 -10
  63. package/src/signer/doge/signerDogePrivateKey.ts +6 -3
  64. package/src/signer/doge/verify.ts +7 -8
  65. package/src/signer/nostr/signerNostrPrivateKey.ts +9 -8
  66. package/src/signer/nostr/verify.ts +2 -2
  67. package/src/utils/index.ts +20 -1
  68. package/tsdown.config.mts +53 -0
  69. package/dist/address/address.advanced.d.ts +0 -65
  70. package/dist/address/address.advanced.d.ts.map +0 -1
  71. package/dist/address/address.advanced.js +0 -147
  72. package/dist/address/advanced.d.ts +0 -2
  73. package/dist/address/advanced.d.ts.map +0 -1
  74. package/dist/address/advanced.js +0 -1
  75. package/dist/address/index.d.ts +0 -58
  76. package/dist/address/index.d.ts.map +0 -1
  77. package/dist/address/index.js +0 -78
  78. package/dist/advanced.d.ts +0 -3
  79. package/dist/advanced.d.ts.map +0 -1
  80. package/dist/advanced.js +0 -2
  81. package/dist/advancedBarrel.d.ts +0 -7
  82. package/dist/advancedBarrel.d.ts.map +0 -1
  83. package/dist/advancedBarrel.js +0 -6
  84. package/dist/barrel.d.ts +0 -14
  85. package/dist/barrel.d.ts.map +0 -1
  86. package/dist/barrel.js +0 -13
  87. package/dist/bytes/advanced.d.ts +0 -6
  88. package/dist/bytes/advanced.d.ts.map +0 -1
  89. package/dist/bytes/advanced.js +0 -1
  90. package/dist/bytes/index.d.ts +0 -112
  91. package/dist/bytes/index.d.ts.map +0 -1
  92. package/dist/bytes/index.js +0 -155
  93. package/dist/ckb/advanced.d.ts +0 -3
  94. package/dist/ckb/advanced.d.ts.map +0 -1
  95. package/dist/ckb/advanced.js +0 -2
  96. package/dist/ckb/hash.d.ts +0 -18
  97. package/dist/ckb/hash.d.ts.map +0 -1
  98. package/dist/ckb/hash.js +0 -19
  99. package/dist/ckb/index.d.ts +0 -6
  100. package/dist/ckb/index.d.ts.map +0 -1
  101. package/dist/ckb/index.js +0 -5
  102. package/dist/ckb/script.advanced.d.ts +0 -5
  103. package/dist/ckb/script.advanced.d.ts.map +0 -1
  104. package/dist/ckb/script.advanced.js +0 -13
  105. package/dist/ckb/script.d.ts +0 -156
  106. package/dist/ckb/script.d.ts.map +0 -1
  107. package/dist/ckb/script.js +0 -184
  108. package/dist/ckb/transaction.advanced.d.ts +0 -5
  109. package/dist/ckb/transaction.advanced.d.ts.map +0 -1
  110. package/dist/ckb/transaction.advanced.js +0 -9
  111. package/dist/ckb/transaction.d.ts +0 -1401
  112. package/dist/ckb/transaction.d.ts.map +0 -1
  113. package/dist/ckb/transaction.js +0 -1880
  114. package/dist/ckb/transactionErrors.d.ts +0 -15
  115. package/dist/ckb/transactionErrors.d.ts.map +0 -1
  116. package/dist/ckb/transactionErrors.js +0 -21
  117. package/dist/ckb/transactionLumos.d.ts +0 -30
  118. package/dist/ckb/transactionLumos.d.ts.map +0 -1
  119. package/dist/ckb/transactionLumos.js +0 -1
  120. package/dist/client/advanced.d.ts +0 -6
  121. package/dist/client/advanced.d.ts.map +0 -1
  122. package/dist/client/advanced.js +0 -5
  123. package/dist/client/cache/advanced.d.ts +0 -2
  124. package/dist/client/cache/advanced.d.ts.map +0 -1
  125. package/dist/client/cache/advanced.js +0 -1
  126. package/dist/client/cache/cache.d.ts +0 -98
  127. package/dist/client/cache/cache.d.ts.map +0 -1
  128. package/dist/client/cache/cache.js +0 -139
  129. package/dist/client/cache/index.d.ts +0 -3
  130. package/dist/client/cache/index.d.ts.map +0 -1
  131. package/dist/client/cache/index.js +0 -2
  132. package/dist/client/cache/memory.advanced.d.ts +0 -52
  133. package/dist/client/cache/memory.advanced.d.ts.map +0 -1
  134. package/dist/client/cache/memory.advanced.js +0 -149
  135. package/dist/client/cache/memory.d.ts +0 -53
  136. package/dist/client/cache/memory.d.ts.map +0 -1
  137. package/dist/client/cache/memory.js +0 -148
  138. package/dist/client/client.d.ts +0 -107
  139. package/dist/client/client.d.ts.map +0 -1
  140. package/dist/client/client.js +0 -328
  141. package/dist/client/clientPublicMainnet.advanced.d.ts +0 -4
  142. package/dist/client/clientPublicMainnet.advanced.d.ts.map +0 -1
  143. package/dist/client/clientPublicMainnet.advanced.js +0 -402
  144. package/dist/client/clientPublicMainnet.d.ts +0 -17
  145. package/dist/client/clientPublicMainnet.d.ts.map +0 -1
  146. package/dist/client/clientPublicMainnet.js +0 -40
  147. package/dist/client/clientPublicTestnet.advanced.d.ts +0 -4
  148. package/dist/client/clientPublicTestnet.advanced.d.ts.map +0 -1
  149. package/dist/client/clientPublicTestnet.advanced.js +0 -412
  150. package/dist/client/clientPublicTestnet.d.ts +0 -17
  151. package/dist/client/clientPublicTestnet.d.ts.map +0 -1
  152. package/dist/client/clientPublicTestnet.js +0 -40
  153. package/dist/client/clientTypes.advanced.d.ts +0 -25
  154. package/dist/client/clientTypes.advanced.d.ts.map +0 -1
  155. package/dist/client/clientTypes.advanced.js +0 -6
  156. package/dist/client/clientTypes.d.ts +0 -335
  157. package/dist/client/clientTypes.d.ts.map +0 -1
  158. package/dist/client/clientTypes.js +0 -232
  159. package/dist/client/index.d.ts +0 -8
  160. package/dist/client/index.d.ts.map +0 -1
  161. package/dist/client/index.js +0 -7
  162. package/dist/client/jsonRpc/advanced.d.ts +0 -3
  163. package/dist/client/jsonRpc/advanced.d.ts.map +0 -1
  164. package/dist/client/jsonRpc/advanced.js +0 -2
  165. package/dist/client/jsonRpc/client.d.ts +0 -160
  166. package/dist/client/jsonRpc/client.d.ts.map +0 -1
  167. package/dist/client/jsonRpc/client.js +0 -223
  168. package/dist/client/jsonRpc/index.d.ts +0 -2
  169. package/dist/client/jsonRpc/index.d.ts.map +0 -1
  170. package/dist/client/jsonRpc/index.js +0 -1
  171. package/dist/client/jsonRpc/transformers.d.ts +0 -51
  172. package/dist/client/jsonRpc/transformers.d.ts.map +0 -1
  173. package/dist/client/jsonRpc/transformers.js +0 -247
  174. package/dist/client/jsonRpc/types.d.ts +0 -101
  175. package/dist/client/jsonRpc/types.d.ts.map +0 -1
  176. package/dist/client/jsonRpc/types.js +0 -1
  177. package/dist/client/knownScript.d.ts +0 -27
  178. package/dist/client/knownScript.d.ts.map +0 -1
  179. package/dist/client/knownScript.js +0 -28
  180. package/dist/fixedPoint/index.d.ts +0 -55
  181. package/dist/fixedPoint/index.d.ts.map +0 -1
  182. package/dist/fixedPoint/index.js +0 -68
  183. package/dist/hasher/advanced.d.ts +0 -2
  184. package/dist/hasher/advanced.d.ts.map +0 -1
  185. package/dist/hasher/advanced.js +0 -1
  186. package/dist/hasher/hasher.d.ts +0 -35
  187. package/dist/hasher/hasher.d.ts.map +0 -1
  188. package/dist/hasher/hasher.js +0 -1
  189. package/dist/hasher/hasherCkb.d.ts +0 -57
  190. package/dist/hasher/hasherCkb.d.ts.map +0 -1
  191. package/dist/hasher/hasherCkb.js +0 -70
  192. package/dist/hasher/hasherKeecak256.d.ts +0 -41
  193. package/dist/hasher/hasherKeecak256.d.ts.map +0 -1
  194. package/dist/hasher/hasherKeecak256.js +0 -46
  195. package/dist/hasher/index.d.ts +0 -4
  196. package/dist/hasher/index.d.ts.map +0 -1
  197. package/dist/hasher/index.js +0 -3
  198. package/dist/hex/index.d.ts +0 -27
  199. package/dist/hex/index.d.ts.map +0 -1
  200. package/dist/hex/index.js +0 -17
  201. package/dist/index.d.ts +0 -3
  202. package/dist/index.d.ts.map +0 -1
  203. package/dist/index.js +0 -2
  204. package/dist/jsonRpc/advanced.d.ts +0 -2
  205. package/dist/jsonRpc/advanced.d.ts.map +0 -1
  206. package/dist/jsonRpc/advanced.js +0 -1
  207. package/dist/jsonRpc/index.d.ts +0 -2
  208. package/dist/jsonRpc/index.d.ts.map +0 -1
  209. package/dist/jsonRpc/index.js +0 -1
  210. package/dist/jsonRpc/requestor.d.ts +0 -49
  211. package/dist/jsonRpc/requestor.d.ts.map +0 -1
  212. package/dist/jsonRpc/requestor.js +0 -109
  213. package/dist/jsonRpc/transports/advanced.d.ts +0 -6
  214. package/dist/jsonRpc/transports/advanced.d.ts.map +0 -1
  215. package/dist/jsonRpc/transports/advanced.js +0 -5
  216. package/dist/jsonRpc/transports/factory.d.ts +0 -6
  217. package/dist/jsonRpc/transports/factory.d.ts.map +0 -1
  218. package/dist/jsonRpc/transports/factory.js +0 -8
  219. package/dist/jsonRpc/transports/fallback.d.ts +0 -8
  220. package/dist/jsonRpc/transports/fallback.d.ts.map +0 -1
  221. package/dist/jsonRpc/transports/fallback.js +0 -22
  222. package/dist/jsonRpc/transports/http.d.ts +0 -8
  223. package/dist/jsonRpc/transports/http.d.ts.map +0 -1
  224. package/dist/jsonRpc/transports/http.js +0 -22
  225. package/dist/jsonRpc/transports/transport.d.ts +0 -18
  226. package/dist/jsonRpc/transports/transport.d.ts.map +0 -1
  227. package/dist/jsonRpc/transports/transport.js +0 -1
  228. package/dist/jsonRpc/transports/webSocket.d.ts +0 -11
  229. package/dist/jsonRpc/transports/webSocket.d.ts.map +0 -1
  230. package/dist/jsonRpc/transports/webSocket.js +0 -87
  231. package/dist/keystore/index.d.ts +0 -31
  232. package/dist/keystore/index.d.ts.map +0 -1
  233. package/dist/keystore/index.js +0 -106
  234. package/dist/molecule/barrel.d.ts +0 -4
  235. package/dist/molecule/barrel.d.ts.map +0 -1
  236. package/dist/molecule/codec.d.ts +0 -146
  237. package/dist/molecule/codec.d.ts.map +0 -1
  238. package/dist/molecule/codec.js +0 -516
  239. package/dist/molecule/entity.d.ts +0 -112
  240. package/dist/molecule/entity.d.ts.map +0 -1
  241. package/dist/molecule/entity.js +0 -142
  242. package/dist/molecule/index.d.ts +0 -2
  243. package/dist/molecule/index.d.ts.map +0 -1
  244. package/dist/molecule/index.js +0 -1
  245. package/dist/molecule/predefined.d.ts +0 -57
  246. package/dist/molecule/predefined.d.ts.map +0 -1
  247. package/dist/molecule/predefined.js +0 -83
  248. package/dist/num/index.d.ts +0 -148
  249. package/dist/num/index.d.ts.map +0 -1
  250. package/dist/num/index.js +0 -204
  251. package/dist/signer/btc/index.d.ts +0 -4
  252. package/dist/signer/btc/index.d.ts.map +0 -1
  253. package/dist/signer/btc/index.js +0 -3
  254. package/dist/signer/btc/signerBtc.d.ts +0 -59
  255. package/dist/signer/btc/signerBtc.d.ts.map +0 -1
  256. package/dist/signer/btc/signerBtc.js +0 -83
  257. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -55
  258. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +0 -1
  259. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +0 -61
  260. package/dist/signer/btc/verify.d.ts +0 -40
  261. package/dist/signer/btc/verify.d.ts.map +0 -1
  262. package/dist/signer/btc/verify.js +0 -69
  263. package/dist/signer/ckb/index.d.ts +0 -6
  264. package/dist/signer/ckb/index.d.ts.map +0 -1
  265. package/dist/signer/ckb/index.js +0 -5
  266. package/dist/signer/ckb/signerCkbPrivateKey.d.ts +0 -16
  267. package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +0 -1
  268. package/dist/signer/ckb/signerCkbPrivateKey.js +0 -42
  269. package/dist/signer/ckb/signerCkbPublicKey.d.ts +0 -27
  270. package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +0 -1
  271. package/dist/signer/ckb/signerCkbPublicKey.js +0 -101
  272. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +0 -68
  273. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +0 -1
  274. package/dist/signer/ckb/signerCkbScriptReadonly.js +0 -78
  275. package/dist/signer/ckb/verifyCkbSecp256k1.d.ts +0 -11
  276. package/dist/signer/ckb/verifyCkbSecp256k1.d.ts.map +0 -1
  277. package/dist/signer/ckb/verifyCkbSecp256k1.js +0 -22
  278. package/dist/signer/ckb/verifyJoyId.d.ts +0 -6
  279. package/dist/signer/ckb/verifyJoyId.d.ts.map +0 -1
  280. package/dist/signer/ckb/verifyJoyId.js +0 -16
  281. package/dist/signer/doge/index.d.ts +0 -5
  282. package/dist/signer/doge/index.d.ts.map +0 -1
  283. package/dist/signer/doge/index.js +0 -4
  284. package/dist/signer/doge/signerDoge.d.ts +0 -52
  285. package/dist/signer/doge/signerDoge.d.ts.map +0 -1
  286. package/dist/signer/doge/signerDoge.js +0 -82
  287. package/dist/signer/doge/signerDogeAddressReadonly.d.ts +0 -41
  288. package/dist/signer/doge/signerDogeAddressReadonly.d.ts.map +0 -1
  289. package/dist/signer/doge/signerDogeAddressReadonly.js +0 -45
  290. package/dist/signer/doge/signerDogePrivateKey.d.ts +0 -52
  291. package/dist/signer/doge/signerDogePrivateKey.d.ts.map +0 -1
  292. package/dist/signer/doge/signerDogePrivateKey.js +0 -68
  293. package/dist/signer/doge/verify.d.ts +0 -17
  294. package/dist/signer/doge/verify.d.ts.map +0 -1
  295. package/dist/signer/doge/verify.js +0 -29
  296. package/dist/signer/dummy/alwaysError.d.ts +0 -12
  297. package/dist/signer/dummy/alwaysError.d.ts.map +0 -1
  298. package/dist/signer/dummy/alwaysError.js +0 -13
  299. package/dist/signer/dummy/dummy.d.ts +0 -15
  300. package/dist/signer/dummy/dummy.d.ts.map +0 -1
  301. package/dist/signer/dummy/dummy.js +0 -22
  302. package/dist/signer/dummy/index.d.ts +0 -4
  303. package/dist/signer/dummy/index.d.ts.map +0 -1
  304. package/dist/signer/dummy/index.js +0 -3
  305. package/dist/signer/dummy/openLink.d.ts +0 -12
  306. package/dist/signer/dummy/openLink.d.ts.map +0 -1
  307. package/dist/signer/dummy/openLink.js +0 -13
  308. package/dist/signer/evm/index.d.ts +0 -4
  309. package/dist/signer/evm/index.d.ts.map +0 -1
  310. package/dist/signer/evm/index.js +0 -3
  311. package/dist/signer/evm/signerEvm.d.ts +0 -59
  312. package/dist/signer/evm/signerEvm.d.ts.map +0 -1
  313. package/dist/signer/evm/signerEvm.js +0 -139
  314. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +0 -47
  315. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +0 -1
  316. package/dist/signer/evm/signerEvmAddressReadonly.js +0 -51
  317. package/dist/signer/evm/verify.d.ts +0 -6
  318. package/dist/signer/evm/verify.d.ts.map +0 -1
  319. package/dist/signer/evm/verify.js +0 -9
  320. package/dist/signer/index.d.ts +0 -8
  321. package/dist/signer/index.d.ts.map +0 -1
  322. package/dist/signer/index.js +0 -7
  323. package/dist/signer/nostr/index.d.ts +0 -5
  324. package/dist/signer/nostr/index.d.ts.map +0 -1
  325. package/dist/signer/nostr/index.js +0 -4
  326. package/dist/signer/nostr/signerNostr.d.ts +0 -72
  327. package/dist/signer/nostr/signerNostr.d.ts.map +0 -1
  328. package/dist/signer/nostr/signerNostr.js +0 -96
  329. package/dist/signer/nostr/signerNostrPrivateKey.d.ts +0 -14
  330. package/dist/signer/nostr/signerNostrPrivateKey.d.ts.map +0 -1
  331. package/dist/signer/nostr/signerNostrPrivateKey.js +0 -34
  332. package/dist/signer/nostr/signerNostrPublicKeyReadonly.d.ts +0 -15
  333. package/dist/signer/nostr/signerNostrPublicKeyReadonly.d.ts.map +0 -1
  334. package/dist/signer/nostr/signerNostrPublicKeyReadonly.js +0 -26
  335. package/dist/signer/nostr/verify.d.ts +0 -9
  336. package/dist/signer/nostr/verify.d.ts.map +0 -1
  337. package/dist/signer/nostr/verify.js +0 -55
  338. package/dist/signer/signer/index.d.ts +0 -256
  339. package/dist/signer/signer/index.d.ts.map +0 -1
  340. package/dist/signer/signer/index.js +0 -305
  341. package/dist/utils/index.d.ts +0 -97
  342. package/dist/utils/index.d.ts.map +0 -1
  343. package/dist/utils/index.js +0 -55
  344. package/dist.commonjs/address/address.advanced.d.ts +0 -65
  345. package/dist.commonjs/address/address.advanced.d.ts.map +0 -1
  346. package/dist.commonjs/address/address.advanced.js +0 -152
  347. package/dist.commonjs/address/advanced.d.ts +0 -2
  348. package/dist.commonjs/address/advanced.d.ts.map +0 -1
  349. package/dist.commonjs/address/advanced.js +0 -17
  350. package/dist.commonjs/address/index.d.ts +0 -58
  351. package/dist.commonjs/address/index.d.ts.map +0 -1
  352. package/dist.commonjs/address/index.js +0 -82
  353. package/dist.commonjs/advanced.d.ts.map +0 -1
  354. package/dist.commonjs/advancedBarrel.d.ts.map +0 -1
  355. package/dist.commonjs/barrel.d.ts.map +0 -1
  356. package/dist.commonjs/bytes/advanced.d.ts +0 -6
  357. package/dist.commonjs/bytes/advanced.d.ts.map +0 -1
  358. package/dist.commonjs/bytes/advanced.js +0 -2
  359. package/dist.commonjs/bytes/index.d.ts +0 -112
  360. package/dist.commonjs/bytes/index.d.ts.map +0 -1
  361. package/dist.commonjs/bytes/index.js +0 -163
  362. package/dist.commonjs/ckb/advanced.d.ts +0 -3
  363. package/dist.commonjs/ckb/advanced.d.ts.map +0 -1
  364. package/dist.commonjs/ckb/advanced.js +0 -18
  365. package/dist.commonjs/ckb/hash.d.ts +0 -18
  366. package/dist.commonjs/ckb/hash.d.ts.map +0 -1
  367. package/dist.commonjs/ckb/hash.js +0 -22
  368. package/dist.commonjs/ckb/index.d.ts +0 -6
  369. package/dist.commonjs/ckb/index.d.ts.map +0 -1
  370. package/dist.commonjs/ckb/index.js +0 -21
  371. package/dist.commonjs/ckb/script.advanced.d.ts +0 -5
  372. package/dist.commonjs/ckb/script.advanced.d.ts.map +0 -1
  373. package/dist.commonjs/ckb/script.advanced.js +0 -16
  374. package/dist.commonjs/ckb/script.d.ts +0 -156
  375. package/dist.commonjs/ckb/script.d.ts.map +0 -1
  376. package/dist.commonjs/ckb/script.js +0 -190
  377. package/dist.commonjs/ckb/transaction.advanced.d.ts +0 -5
  378. package/dist.commonjs/ckb/transaction.advanced.d.ts.map +0 -1
  379. package/dist.commonjs/ckb/transaction.advanced.js +0 -12
  380. package/dist.commonjs/ckb/transaction.d.ts +0 -1401
  381. package/dist.commonjs/ckb/transaction.d.ts.map +0 -1
  382. package/dist.commonjs/ckb/transaction.js +0 -1894
  383. package/dist.commonjs/ckb/transactionErrors.d.ts +0 -15
  384. package/dist.commonjs/ckb/transactionErrors.d.ts.map +0 -1
  385. package/dist.commonjs/ckb/transactionErrors.js +0 -26
  386. package/dist.commonjs/ckb/transactionLumos.d.ts +0 -30
  387. package/dist.commonjs/ckb/transactionLumos.d.ts.map +0 -1
  388. package/dist.commonjs/ckb/transactionLumos.js +0 -2
  389. package/dist.commonjs/client/advanced.d.ts +0 -6
  390. package/dist.commonjs/client/advanced.d.ts.map +0 -1
  391. package/dist.commonjs/client/advanced.js +0 -21
  392. package/dist.commonjs/client/cache/advanced.d.ts +0 -2
  393. package/dist.commonjs/client/cache/advanced.d.ts.map +0 -1
  394. package/dist.commonjs/client/cache/advanced.js +0 -17
  395. package/dist.commonjs/client/cache/cache.d.ts +0 -98
  396. package/dist.commonjs/client/cache/cache.d.ts.map +0 -1
  397. package/dist.commonjs/client/cache/cache.js +0 -143
  398. package/dist.commonjs/client/cache/index.d.ts +0 -3
  399. package/dist.commonjs/client/cache/index.d.ts.map +0 -1
  400. package/dist.commonjs/client/cache/index.js +0 -18
  401. package/dist.commonjs/client/cache/memory.advanced.d.ts +0 -52
  402. package/dist.commonjs/client/cache/memory.advanced.d.ts.map +0 -1
  403. package/dist.commonjs/client/cache/memory.advanced.js +0 -158
  404. package/dist.commonjs/client/cache/memory.d.ts +0 -53
  405. package/dist.commonjs/client/cache/memory.d.ts.map +0 -1
  406. package/dist.commonjs/client/cache/memory.js +0 -152
  407. package/dist.commonjs/client/client.d.ts +0 -107
  408. package/dist.commonjs/client/client.d.ts.map +0 -1
  409. package/dist.commonjs/client/client.js +0 -332
  410. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +0 -4
  411. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +0 -1
  412. package/dist.commonjs/client/clientPublicMainnet.advanced.js +0 -405
  413. package/dist.commonjs/client/clientPublicMainnet.d.ts +0 -17
  414. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +0 -1
  415. package/dist.commonjs/client/clientPublicMainnet.js +0 -47
  416. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +0 -4
  417. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +0 -1
  418. package/dist.commonjs/client/clientPublicTestnet.advanced.js +0 -415
  419. package/dist.commonjs/client/clientPublicTestnet.d.ts +0 -17
  420. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +0 -1
  421. package/dist.commonjs/client/clientPublicTestnet.js +0 -47
  422. package/dist.commonjs/client/clientTypes.advanced.d.ts +0 -25
  423. package/dist.commonjs/client/clientTypes.advanced.d.ts.map +0 -1
  424. package/dist.commonjs/client/clientTypes.advanced.js +0 -10
  425. package/dist.commonjs/client/clientTypes.d.ts +0 -335
  426. package/dist.commonjs/client/clientTypes.d.ts.map +0 -1
  427. package/dist.commonjs/client/clientTypes.js +0 -251
  428. package/dist.commonjs/client/index.d.ts +0 -8
  429. package/dist.commonjs/client/index.d.ts.map +0 -1
  430. package/dist.commonjs/client/index.js +0 -23
  431. package/dist.commonjs/client/jsonRpc/advanced.d.ts +0 -3
  432. package/dist.commonjs/client/jsonRpc/advanced.d.ts.map +0 -1
  433. package/dist.commonjs/client/jsonRpc/advanced.js +0 -18
  434. package/dist.commonjs/client/jsonRpc/client.d.ts +0 -160
  435. package/dist.commonjs/client/jsonRpc/client.d.ts.map +0 -1
  436. package/dist.commonjs/client/jsonRpc/client.js +0 -227
  437. package/dist.commonjs/client/jsonRpc/index.d.ts +0 -2
  438. package/dist.commonjs/client/jsonRpc/index.d.ts.map +0 -1
  439. package/dist.commonjs/client/jsonRpc/index.js +0 -17
  440. package/dist.commonjs/client/jsonRpc/transformers.d.ts +0 -51
  441. package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +0 -1
  442. package/dist.commonjs/client/jsonRpc/transformers.js +0 -251
  443. package/dist.commonjs/client/jsonRpc/types.d.ts +0 -101
  444. package/dist.commonjs/client/jsonRpc/types.d.ts.map +0 -1
  445. package/dist.commonjs/client/jsonRpc/types.js +0 -2
  446. package/dist.commonjs/client/knownScript.d.ts +0 -27
  447. package/dist.commonjs/client/knownScript.d.ts.map +0 -1
  448. package/dist.commonjs/client/knownScript.js +0 -31
  449. package/dist.commonjs/fixedPoint/index.d.ts +0 -55
  450. package/dist.commonjs/fixedPoint/index.d.ts.map +0 -1
  451. package/dist.commonjs/fixedPoint/index.js +0 -73
  452. package/dist.commonjs/hasher/advanced.d.ts +0 -2
  453. package/dist.commonjs/hasher/advanced.d.ts.map +0 -1
  454. package/dist.commonjs/hasher/advanced.js +0 -4
  455. package/dist.commonjs/hasher/hasher.d.ts +0 -35
  456. package/dist.commonjs/hasher/hasher.d.ts.map +0 -1
  457. package/dist.commonjs/hasher/hasher.js +0 -2
  458. package/dist.commonjs/hasher/hasherCkb.d.ts +0 -57
  459. package/dist.commonjs/hasher/hasherCkb.d.ts.map +0 -1
  460. package/dist.commonjs/hasher/hasherCkb.js +0 -75
  461. package/dist.commonjs/hasher/hasherKeecak256.d.ts +0 -41
  462. package/dist.commonjs/hasher/hasherKeecak256.d.ts.map +0 -1
  463. package/dist.commonjs/hasher/hasherKeecak256.js +0 -50
  464. package/dist.commonjs/hasher/index.d.ts +0 -4
  465. package/dist.commonjs/hasher/index.d.ts.map +0 -1
  466. package/dist.commonjs/hasher/index.js +0 -19
  467. package/dist.commonjs/hex/index.d.ts +0 -27
  468. package/dist.commonjs/hex/index.d.ts.map +0 -1
  469. package/dist.commonjs/hex/index.js +0 -20
  470. package/dist.commonjs/index.d.ts.map +0 -1
  471. package/dist.commonjs/jsonRpc/advanced.d.ts +0 -2
  472. package/dist.commonjs/jsonRpc/advanced.d.ts.map +0 -1
  473. package/dist.commonjs/jsonRpc/advanced.js +0 -17
  474. package/dist.commonjs/jsonRpc/index.d.ts +0 -2
  475. package/dist.commonjs/jsonRpc/index.d.ts.map +0 -1
  476. package/dist.commonjs/jsonRpc/index.js +0 -17
  477. package/dist.commonjs/jsonRpc/requestor.d.ts +0 -49
  478. package/dist.commonjs/jsonRpc/requestor.d.ts.map +0 -1
  479. package/dist.commonjs/jsonRpc/requestor.js +0 -113
  480. package/dist.commonjs/jsonRpc/transports/advanced.d.ts +0 -6
  481. package/dist.commonjs/jsonRpc/transports/advanced.d.ts.map +0 -1
  482. package/dist.commonjs/jsonRpc/transports/advanced.js +0 -21
  483. package/dist.commonjs/jsonRpc/transports/factory.d.ts +0 -6
  484. package/dist.commonjs/jsonRpc/transports/factory.d.ts.map +0 -1
  485. package/dist.commonjs/jsonRpc/transports/factory.js +0 -11
  486. package/dist.commonjs/jsonRpc/transports/fallback.d.ts +0 -8
  487. package/dist.commonjs/jsonRpc/transports/fallback.d.ts.map +0 -1
  488. package/dist.commonjs/jsonRpc/transports/fallback.js +0 -26
  489. package/dist.commonjs/jsonRpc/transports/http.d.ts +0 -8
  490. package/dist.commonjs/jsonRpc/transports/http.d.ts.map +0 -1
  491. package/dist.commonjs/jsonRpc/transports/http.js +0 -26
  492. package/dist.commonjs/jsonRpc/transports/transport.d.ts +0 -18
  493. package/dist.commonjs/jsonRpc/transports/transport.d.ts.map +0 -1
  494. package/dist.commonjs/jsonRpc/transports/transport.js +0 -2
  495. package/dist.commonjs/jsonRpc/transports/webSocket.d.ts +0 -11
  496. package/dist.commonjs/jsonRpc/transports/webSocket.d.ts.map +0 -1
  497. package/dist.commonjs/jsonRpc/transports/webSocket.js +0 -94
  498. package/dist.commonjs/keystore/index.d.ts +0 -31
  499. package/dist.commonjs/keystore/index.d.ts.map +0 -1
  500. package/dist.commonjs/keystore/index.js +0 -110
  501. package/dist.commonjs/molecule/barrel.d.ts +0 -4
  502. package/dist.commonjs/molecule/barrel.d.ts.map +0 -1
  503. package/dist.commonjs/molecule/barrel.js +0 -19
  504. package/dist.commonjs/molecule/codec.d.ts +0 -146
  505. package/dist.commonjs/molecule/codec.d.ts.map +0 -1
  506. package/dist.commonjs/molecule/codec.js +0 -531
  507. package/dist.commonjs/molecule/entity.d.ts +0 -112
  508. package/dist.commonjs/molecule/entity.d.ts.map +0 -1
  509. package/dist.commonjs/molecule/entity.js +0 -147
  510. package/dist.commonjs/molecule/index.d.ts +0 -2
  511. package/dist.commonjs/molecule/index.d.ts.map +0 -1
  512. package/dist.commonjs/molecule/index.js +0 -37
  513. package/dist.commonjs/molecule/predefined.d.ts +0 -57
  514. package/dist.commonjs/molecule/predefined.d.ts.map +0 -1
  515. package/dist.commonjs/molecule/predefined.js +0 -87
  516. package/dist.commonjs/num/index.d.ts +0 -148
  517. package/dist.commonjs/num/index.d.ts.map +0 -1
  518. package/dist.commonjs/num/index.js +0 -216
  519. package/dist.commonjs/signer/btc/index.d.ts +0 -4
  520. package/dist.commonjs/signer/btc/index.d.ts.map +0 -1
  521. package/dist.commonjs/signer/btc/index.js +0 -19
  522. package/dist.commonjs/signer/btc/signerBtc.d.ts +0 -59
  523. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +0 -1
  524. package/dist.commonjs/signer/btc/signerBtc.js +0 -87
  525. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -55
  526. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +0 -1
  527. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +0 -65
  528. package/dist.commonjs/signer/btc/verify.d.ts +0 -40
  529. package/dist.commonjs/signer/btc/verify.d.ts.map +0 -1
  530. package/dist.commonjs/signer/btc/verify.js +0 -80
  531. package/dist.commonjs/signer/ckb/index.d.ts +0 -6
  532. package/dist.commonjs/signer/ckb/index.d.ts.map +0 -1
  533. package/dist.commonjs/signer/ckb/index.js +0 -21
  534. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +0 -16
  535. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +0 -1
  536. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +0 -46
  537. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +0 -27
  538. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +0 -1
  539. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +0 -105
  540. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +0 -68
  541. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +0 -1
  542. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +0 -82
  543. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +0 -11
  544. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts.map +0 -1
  545. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +0 -26
  546. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +0 -6
  547. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +0 -1
  548. package/dist.commonjs/signer/ckb/verifyJoyId.js +0 -19
  549. package/dist.commonjs/signer/doge/index.d.ts +0 -5
  550. package/dist.commonjs/signer/doge/index.d.ts.map +0 -1
  551. package/dist.commonjs/signer/doge/index.js +0 -20
  552. package/dist.commonjs/signer/doge/signerDoge.d.ts +0 -52
  553. package/dist.commonjs/signer/doge/signerDoge.d.ts.map +0 -1
  554. package/dist.commonjs/signer/doge/signerDoge.js +0 -89
  555. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts +0 -41
  556. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts.map +0 -1
  557. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.js +0 -49
  558. package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts +0 -52
  559. package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts.map +0 -1
  560. package/dist.commonjs/signer/doge/signerDogePrivateKey.js +0 -72
  561. package/dist.commonjs/signer/doge/verify.d.ts +0 -17
  562. package/dist.commonjs/signer/doge/verify.d.ts.map +0 -1
  563. package/dist.commonjs/signer/doge/verify.js +0 -33
  564. package/dist.commonjs/signer/dummy/alwaysError.d.ts +0 -12
  565. package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +0 -1
  566. package/dist.commonjs/signer/dummy/alwaysError.js +0 -17
  567. package/dist.commonjs/signer/dummy/dummy.d.ts +0 -15
  568. package/dist.commonjs/signer/dummy/dummy.d.ts.map +0 -1
  569. package/dist.commonjs/signer/dummy/dummy.js +0 -26
  570. package/dist.commonjs/signer/dummy/index.d.ts +0 -4
  571. package/dist.commonjs/signer/dummy/index.d.ts.map +0 -1
  572. package/dist.commonjs/signer/dummy/index.js +0 -19
  573. package/dist.commonjs/signer/dummy/openLink.d.ts +0 -12
  574. package/dist.commonjs/signer/dummy/openLink.d.ts.map +0 -1
  575. package/dist.commonjs/signer/dummy/openLink.js +0 -17
  576. package/dist.commonjs/signer/evm/index.d.ts +0 -4
  577. package/dist.commonjs/signer/evm/index.d.ts.map +0 -1
  578. package/dist.commonjs/signer/evm/index.js +0 -19
  579. package/dist.commonjs/signer/evm/signerEvm.d.ts +0 -59
  580. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +0 -1
  581. package/dist.commonjs/signer/evm/signerEvm.js +0 -143
  582. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +0 -47
  583. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +0 -1
  584. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +0 -55
  585. package/dist.commonjs/signer/evm/verify.d.ts +0 -6
  586. package/dist.commonjs/signer/evm/verify.d.ts.map +0 -1
  587. package/dist.commonjs/signer/evm/verify.js +0 -12
  588. package/dist.commonjs/signer/index.d.ts +0 -8
  589. package/dist.commonjs/signer/index.d.ts.map +0 -1
  590. package/dist.commonjs/signer/index.js +0 -23
  591. package/dist.commonjs/signer/nostr/index.d.ts +0 -5
  592. package/dist.commonjs/signer/nostr/index.d.ts.map +0 -1
  593. package/dist.commonjs/signer/nostr/index.js +0 -20
  594. package/dist.commonjs/signer/nostr/signerNostr.d.ts +0 -72
  595. package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +0 -1
  596. package/dist.commonjs/signer/nostr/signerNostr.js +0 -100
  597. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts +0 -14
  598. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts.map +0 -1
  599. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.js +0 -38
  600. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.d.ts +0 -15
  601. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.d.ts.map +0 -1
  602. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.js +0 -30
  603. package/dist.commonjs/signer/nostr/verify.d.ts +0 -9
  604. package/dist.commonjs/signer/nostr/verify.d.ts.map +0 -1
  605. package/dist.commonjs/signer/nostr/verify.js +0 -60
  606. package/dist.commonjs/signer/signer/index.d.ts +0 -256
  607. package/dist.commonjs/signer/signer/index.d.ts.map +0 -1
  608. package/dist.commonjs/signer/signer/index.js +0 -311
  609. package/dist.commonjs/utils/index.d.ts +0 -97
  610. package/dist.commonjs/utils/index.d.ts.map +0 -1
  611. package/dist.commonjs/utils/index.js +0 -62
  612. /package/{dist/molecule/barrel.js → src/codec/index.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.advanced-BmJKF_Lg.mjs","names":["Bytes","Uint8","Uint16","Uint32","Uint64","Uint128","Uint256","Uint512","Bool","Byte","Byte4","Byte8","Byte16","Byte32","mol.struct","mol.table","mol.Byte32","mol.Bytes","mol.option","mol.vector","mol.struct","mol.Byte32","mol.Uint32","mol.table","mol.Uint64","mol.vector","mol\n .struct","mol.BytesOpt","mol.Byte32Vec","mol.BytesVec","mol\n .table"],"sources":["../src/bytes/index.ts","../src/codec/codec.ts","../src/hex/index.ts","../src/hasher/advanced.ts","../src/hasher/hasherCkb.ts","../src/codec/entity.ts","../src/num/index.ts","../src/codec/predefined.ts","../src/fixedPoint/index.ts","../src/molecule/codec.ts","../src/molecule/predefined.ts","../src/utils/index.ts","../src/ckb/epoch.ts","../src/client/clientTypes.advanced.ts","../src/client/clientTypes.ts","../src/client/cache/memory.advanced.ts","../src/client/knownScript.ts","../src/client/clientPublicMainnet.advanced.ts","../src/jsonRpc/transports/http.ts","../src/jsonRpc/transports/webSocket.ts","../src/jsonRpc/transports/factory.ts","../src/jsonRpc/transports/fallback.ts","../src/client/jsonRpc/transformers.ts","../src/client/clientPublicTestnet.advanced.ts","../src/ckb/script.advanced.ts","../src/ckb/script.ts","../src/ckb/transaction.advanced.ts","../src/ckb/transactionErrors.ts","../src/ckb/transaction.ts","../src/address/address.advanced.ts"],"sourcesContent":["import { Buffer } from \"buffer/index.js\";\nimport { BytesFromEncoding } from \"./advanced.js\";\n\n/**\n * @public\n */\nexport type Bytes = Uint8Array;\n/**\n * @public\n */\nexport const Bytes = Uint8Array;\n/**\n * @public\n */\nexport type BytesLike = string | Uint8Array | ArrayBuffer | ArrayLike<number>;\n\n/**\n * Concatenates multiple byte-like arrays to the first number array.\n * @public\n *\n * @param result - The number array as result\n * @param args - The byte-like arrays to concatenate.\n * @returns The first number array\n *\n * @example\n * ```typescript\n * const concatenatedBytes = [1, 2];\n * bytesConcatTo(\n * concatenatedBytes\n * new Uint8Array([3, 4]),\n * \"hello\",\n * [5, 6, 7]\n * );\n * console.log(concatenatedBytes); // Outputs [1, 2, 3, 4, /* bytes of \"hello\" *\\/, 5, 6, 7]\n * ```\n */\n\nexport function bytesConcatTo(\n result: number[],\n ...args: BytesLike[]\n): number[] {\n return args.reduce((acc: number[], v) => {\n const bytes = bytesFrom(v);\n // Spread operator will cause call stack size exceeded\n for (const byte of bytes) {\n result.push(byte);\n }\n return acc;\n }, result);\n}\n\n/**\n * Concatenates multiple byte-like arrays into a single byte array.\n * @public\n *\n * @param args - The byte-like arrays to concatenate.\n * @returns A Uint8Array containing the concatenated bytes.\n *\n * @example\n * ```typescript\n * const concatenatedBytes = bytesConcat(\n * new Uint8Array([1, 2]),\n * new Uint8Array([3, 4]),\n * \"hello\",\n * [5, 6, 7]\n * );\n * console.log(concatenatedBytes); // Outputs Uint8Array [1, 2, 3, 4, /* bytes of \"hello\" *\\/, 5, 6, 7]\n * ```\n */\n\nexport function bytesConcat(...args: BytesLike[]): Bytes {\n return new Uint8Array(bytesConcatTo([], ...args));\n}\n\n/**\n * Converts a byte-like value to a string using the specified encoding.\n * @public\n *\n * @param val - The byte-like value to convert.\n * @param encoding - The encoding to use for the conversion, as defined by the BytesFromEncoding type.\n * @returns A string representing the encoded bytes.\n *\n * @example\n * ```typescript\n * const encodedString = bytesTo(new Uint8Array([104, 101, 108, 108, 111]), \"utf8\");\n * console.log(encodedString); // Outputs \"hello\"\n *\n * const base64String = bytesTo(new Uint8Array([104, 101, 108, 108, 111]), \"base64\");\n * console.log(base64String); // Outputs \"aGVsbG8=\"\n * ```\n */\n\nexport function bytesTo(val: BytesLike, encoding: BytesFromEncoding): string {\n return Buffer.from(bytesFrom(val)).toString(encoding);\n}\n\n/**\n * Converts various types of byte-like values to a Uint8Array.\n * @public\n *\n * @param bytes - The byte-like value to convert. It can be a string, Uint8Array, ArrayBuffer, or number array.\n * @param encoding - Optional encoding to use if the input is a string. Defaults to hexadecimal if not specified.\n * @returns A Uint8Array representing the input bytes.\n *\n * @throws Will throw an error if the input bytes are invalid or out of range.\n *\n * @example\n * ```typescript\n * const bytes1 = bytesFrom(new Uint8Array([1, 2, 3]));\n * console.log(bytes1); // Outputs Uint8Array [1, 2, 3]\n *\n * const bytes2 = bytesFrom(\"68656c6c6f\", \"hex\");\n * console.log(bytes2); // Outputs Uint8Array [104, 101, 108, 108, 111]\n *\n * const bytes3 = bytesFrom(\"hello\", \"utf8\");\n * console.log(bytes3); // Outputs Uint8Array [104, 101, 108, 108, 111]\n *\n * const bytes4 = bytesFrom([1, 2, 255]);\n * console.log(bytes4); // Outputs Uint8Array [1, 2, 255]\n * ```\n */\n\nexport function bytesFrom(\n bytes: BytesLike,\n encoding?: BytesFromEncoding,\n): Bytes {\n if (bytes instanceof Uint8Array) {\n return bytes;\n }\n\n if (bytes instanceof ArrayBuffer) {\n return new Uint8Array(bytes);\n }\n\n if (typeof bytes === \"string\") {\n if (encoding !== undefined) {\n return Buffer.from(bytes, encoding);\n }\n\n const str = bytes.startsWith(\"0x\") ? bytes.slice(2) : bytes;\n const paddedStr = str.length % 2 === 0 ? str : `0${str}`;\n const data = Buffer.from(paddedStr, \"hex\");\n if (data.length * 2 !== paddedStr.length) {\n throw new Error(`Invalid bytes ${bytes}`);\n }\n return data;\n }\n\n const bytesArr = Array.from(bytes);\n if (bytesArr.some((v) => v < 0 || 0xff < v)) {\n throw new Error(`Invalid bytes ${JSON.stringify(bytes)}`);\n }\n return new Uint8Array(bytes);\n}\n\n/**\n * Compares two byte-like values for equality.\n * @public\n *\n * @param a - The first byte-like value to compare.\n * @param b - The second byte-like value to compare.\n * @returns A boolean indicating whether the two byte-like values are equal.\n *\n * @example\n * ```typescript\n * bytesEq([1], Uint8Array.from([1])) // true\n * ```\n */\nexport function bytesEq(a: BytesLike, b: BytesLike): boolean {\n if (a === b) {\n return true;\n }\n\n const x = bytesFrom(a);\n const y = bytesFrom(b);\n\n if (x.length !== y.length) {\n return false;\n }\n\n for (let i = 0; i < x.length; i++) {\n if (x[i] !== y[i]) {\n return false;\n }\n }\n\n return true;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { Bytes, bytesFrom, BytesLike } from \"../bytes/index.js\";\n\nexport type CodecLike<Encodable, Decoded = Encodable> = {\n readonly encode: (encodable: Encodable) => Bytes;\n readonly decode: (\n decodable: BytesLike,\n config?: { isExtraFieldIgnored?: boolean },\n ) => Decoded;\n readonly byteLength?: number;\n};\nexport class Codec<Encodable, Decoded = Encodable> {\n constructor(\n public readonly encode: (encodable: Encodable) => Bytes,\n public readonly decode: (\n decodable: BytesLike,\n config?: { isExtraFieldIgnored?: boolean }, // This is equivalent to \"compatible\" in the Rust implementation of Molecule.\n ) => Decoded,\n public readonly byteLength?: number, // if provided, treat codec as fixed length\n ) {}\n\n encodeOr<T>(encodable: Encodable, fallback: T): Bytes | T {\n try {\n return this.encode(encodable);\n } catch (_) {\n return fallback;\n }\n }\n\n decodeOr<T>(\n decodable: BytesLike,\n fallback: T,\n config?: { isExtraFieldIgnored?: boolean }, // This is equivalent to \"compatible\" in the Rust implementation of Molecule.\n ) {\n try {\n return this.decode(decodable, config);\n } catch (_) {\n return fallback;\n }\n }\n\n static from<Encodable, Decoded = Encodable>({\n encode,\n decode,\n byteLength,\n }: CodecLike<Encodable, Decoded>): Codec<Encodable, Decoded> {\n return new Codec(\n (encodable: Encodable) => {\n const encoded = encode(encodable);\n if (byteLength !== undefined && encoded.byteLength !== byteLength) {\n throw new Error(\n `Codec.encode: expected byte length ${byteLength}, got ${encoded.byteLength}`,\n );\n }\n return encoded;\n },\n (decodable, config) => {\n const decodableBytes = bytesFrom(decodable);\n if (\n byteLength !== undefined &&\n decodableBytes.byteLength !== byteLength\n ) {\n throw new Error(\n `Codec.decode: expected byte length ${byteLength}, got ${decodableBytes.byteLength}`,\n );\n }\n return decode(decodable, config);\n },\n byteLength,\n );\n }\n\n map<NewEncodable = Encodable, NewDecoded = Decoded>({\n inMap,\n outMap,\n }: {\n inMap?: (encodable: NewEncodable) => Encodable;\n outMap?: (decoded: Decoded) => NewDecoded;\n }): Codec<NewEncodable, NewDecoded> {\n return new Codec(\n (encodable) =>\n this.encode((inMap ? inMap(encodable) : encodable) as Encodable),\n (buffer, config) =>\n (outMap\n ? outMap(this.decode(buffer, config))\n : this.decode(buffer, config)) as NewDecoded,\n this.byteLength,\n );\n }\n\n mapIn<NewEncodable>(\n map: (encodable: NewEncodable) => Encodable,\n ): Codec<NewEncodable, Decoded> {\n return this.map({ inMap: map });\n }\n\n mapOut<NewDecoded>(\n map: (decoded: Decoded) => NewDecoded,\n ): Codec<Encodable, NewDecoded> {\n return this.map({ outMap: map });\n }\n}\n\nexport type EncodableType<T extends CodecLike<any, any>> =\n T extends CodecLike<infer Encodable, unknown> ? Encodable : never;\nexport type DecodedType<T extends CodecLike<any, any>> =\n T extends CodecLike<any, infer Decoded> ? Decoded : never;\n","import { bytesFrom, BytesLike, bytesTo } from \"../bytes/index.js\";\n\n/**\n * Represents a hexadecimal string prefixed with \"0x\".\n * @public\n */\nexport type Hex = `0x${string}`;\n/**\n * Represents a value that can be converted to a hexadecimal string.\n * It extends the BytesLike type.\n * @public\n */\nexport type HexLike = BytesLike;\n\n/**\n * Converts a HexLike value to a Hex string.\n * @public\n *\n * @param hex - The value to convert, which can be a string, Uint8Array, ArrayBuffer, or number array.\n * @returns A Hex string representing the value.\n *\n * @example\n * ```typescript\n * const hexString = hexFrom(\"68656c6c6f\"); // Outputs \"0x68656c6c6f\"\n * const hexStringFromBytes = hexFrom(new Uint8Array([104, 101, 108, 108, 111])); // Outputs \"0x68656c6c6f\"\n * ```\n */\nexport function hexFrom(hex: HexLike): Hex {\n return `0x${bytesTo(bytesFrom(hex), \"hex\")}`;\n}\n","import { bytesFrom } from \"../bytes/index.js\";\n\nexport const CKB_BLAKE2B_PERSONAL = bytesFrom(\"ckb-default-hash\", \"utf8\");\n","import { blake2b } from \"@noble/hashes/blake2.js\";\nimport { BytesLike, bytesFrom } from \"../bytes/index.js\";\nimport { Hex, hexFrom } from \"../hex/index.js\";\nimport { CKB_BLAKE2B_PERSONAL } from \"./advanced.js\";\nimport { Hasher } from \"./hasher.js\";\n\n/**\n * @public\n */\nexport class HasherCkb implements Hasher {\n private readonly hasher: ReturnType<(typeof blake2b)[\"create\"]>;\n\n /**\n * Creates an instance of Hasher.\n *\n * @param outLength - The output length of the hash in bytes. Default is 32.\n * @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.\n */\n\n constructor(outLength = 32, personal = CKB_BLAKE2B_PERSONAL) {\n this.hasher = blake2b.create({\n personalization: personal,\n dkLen: outLength,\n });\n }\n\n /**\n * Updates the hash with the given data.\n *\n * @param data - The data to update the hash with.\n * @returns The current Hasher instance for chaining.\n *\n * @example\n * ```typescript\n * const hasher = new Hasher();\n * hasher.update(\"some data\").update(\"more data\");\n * const hash = hasher.digest();\n * ```\n */\n\n update(data: BytesLike): HasherCkb {\n this.hasher.update(bytesFrom(data));\n return this;\n }\n\n /**\n * Finalizes the hash and returns the digest as a hexadecimal string.\n *\n * @returns The hexadecimal string representation of the hash.\n *\n * @example\n * ```typescript\n * const hasher = new Hasher();\n * hasher.update(\"some data\");\n * const hash = hasher.digest(); // Outputs something like \"0x...\"\n * ```\n */\n\n digest(): Hex {\n return hexFrom(this.hasher.digest());\n }\n}\n\n/**\n * Computes the CKB hash of the given data using the Blake2b algorithm.\n * @public\n *\n * @param data - The data to hash.\n * @returns The hexadecimal string representation of the hash.\n *\n * @example\n * ```typescript\n * const hash = hashCkb(\"some data\"); // Outputs something like \"0x...\"\n * ```\n */\n\nexport function hashCkb(...data: BytesLike[]): Hex {\n const hasher = new HasherCkb();\n data.forEach((d) => hasher.update(d));\n return hasher.digest();\n}\n","import { Bytes, bytesEq, BytesLike } from \"../bytes/index.js\";\nimport { hashCkb } from \"../hasher/index.js\";\nimport { Hex, hexFrom } from \"../hex/index.js\";\nimport { Constructor } from \"../utils/index.js\";\nimport { Codec } from \"./codec.js\";\n\n/**\n * The base class of CCC to create a serializable instance. This should be used with the {@link codec} decorator.\n * @public\n */\nexport abstract class Entity {\n /**\n * Generate a base class of CCC to create a serializable instance.\n * This should be used with the {@link codec} decorator.\n * @public\n */\n static Base<SubTypeLike, SubType = SubTypeLike>() {\n abstract class Impl {\n /**\n * The bytes length of the entity, if it is fixed, otherwise undefined\n * @public\n * @static\n */\n static byteLength?: number;\n /**\n * Encode the entity into bytes\n * @public\n * @static\n * @param _ - The entity to encode\n * @returns The encoded bytes\n * @throws Will throw an error if the entity is not serializable\n */\n static encode(_: SubTypeLike): Bytes {\n throw new Error(\n \"encode not implemented, use @ccc.codec to decorate your type\",\n );\n }\n /**\n * Decode the entity from bytes\n * @public\n * @static\n * @param _ - The bytes to decode\n * @returns The decoded entity\n * @throws Will throw an error if the entity is not serializable\n */\n static decode(_: BytesLike): SubType {\n throw new Error(\n \"decode not implemented, use @ccc.codec to decorate your type\",\n );\n }\n\n /**\n * Create an entity from bytes\n * @public\n * @static\n * @param _ - The bytes to create the entity from\n * @returns The created entity\n * @throws Will throw an error if the entity is not serializable\n */\n static fromBytes(_bytes: BytesLike): SubType {\n throw new Error(\n \"fromBytes not implemented, use @ccc.codec to decorate your type\",\n );\n }\n\n /**\n * Create an entity from a serializable object\n * @public\n * @static\n * @param _ - The serializable object to create the entity from\n * @returns The created entity\n * @throws Will throw an error if the entity is not serializable\n */\n static from(_: SubTypeLike): SubType {\n throw new Error(\"from not implemented\");\n }\n\n /**\n * Convert the entity to bytes\n * @public\n * @returns The bytes representation of the entity\n */\n toBytes(): Bytes {\n return (this.constructor as typeof Impl).encode(\n this as unknown as SubTypeLike,\n );\n }\n\n /**\n * Create a clone of the entity\n * @public\n * @returns A clone of the entity\n */\n clone(): SubType {\n return (this.constructor as typeof Impl).fromBytes(this.toBytes());\n }\n\n /**\n * Check if the entity is equal to another entity\n * @public\n * @param other - The other entity to compare with\n * @returns True if the entities are equal, false otherwise\n */\n eq(other: SubTypeLike): boolean {\n if (this === (other as unknown as this)) {\n return true;\n }\n\n return bytesEq(\n this.toBytes(),\n /* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any */\n (\n ((this.constructor as any)?.from(other) ?? other) as unknown as Impl\n ).toBytes(),\n /* eslint-enable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any */\n );\n }\n\n /**\n * Calculate the hash of the entity\n * @public\n * @returns The hash of the entity\n */\n hash(): Hex {\n return hashCkb(this.toBytes());\n }\n\n /**\n * Convert the entity to a full-byte untrimmed Hex representation\n * @public\n * @returns The entity full-byte untrimmed hexadecimal representation\n */\n toHex(): Hex {\n return hexFrom(this.toBytes());\n }\n }\n\n /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment */\n Impl.encode = undefined as any;\n Impl.decode = undefined as any;\n Impl.fromBytes = undefined as any;\n /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment */\n\n return Impl;\n }\n\n abstract toBytes(): Bytes;\n abstract hash(): Hex;\n abstract toHex(): Hex;\n abstract clone(): Entity;\n}\n\n/**\n * A class decorator to add methods implementation on the {@link Entity.Base} class\n * @example\n * ```typescript\n * @codec(\n * mol.table({\n * codeHash: mol.Byte32,\n * hashType: HashTypeCodec,\n * args: mol.Bytes,\n * }),\n * )\n * export class Script extends Entity.Base<ScriptLike, Script>() {\n * from(scriptLike: ScriptLike): Script {}\n * }\n * ```\n */\nexport function codec<\n Encodable,\n TypeLike extends Encodable,\n Decoded extends TypeLike,\n>(codec: Codec<Encodable, Decoded>) {\n return function <\n Type extends TypeLike,\n ConstructorType extends Constructor<Type> & {\n from(decoded: TypeLike): Type;\n byteLength?: number;\n encode(encodable: TypeLike): Bytes;\n decode(bytesLike: BytesLike): Type;\n fromBytes(bytes: BytesLike): Type;\n },\n >(Constructor: ConstructorType, ..._: unknown[]) {\n Constructor.byteLength = codec.byteLength;\n if (Constructor.encode === undefined) {\n Constructor.encode = function (encodable: TypeLike) {\n return codec.encode(Constructor.from(encodable));\n };\n }\n if (Constructor.decode === undefined) {\n Constructor.decode = function (bytesLike: BytesLike) {\n return Constructor.from(codec.decode(bytesLike));\n };\n }\n if (Constructor.fromBytes === undefined) {\n Constructor.fromBytes = function (bytes: BytesLike) {\n return Constructor.from(codec.decode(bytes));\n };\n }\n\n return Constructor;\n };\n}\n","import { Bytes, BytesLike, bytesConcat, bytesFrom } from \"../bytes/index.js\";\nimport { Hex, HexLike, hexFrom } from \"../hex/index.js\";\n\n/**\n * Represents a numeric value as a bigint.\n * @public\n */\nexport type Num = bigint;\n\n/**\n * Represents a value that can be converted to a numeric value.\n * It can be a string, number, bigint, or HexLike.\n * @public\n */\nexport type NumLike = string | number | bigint | HexLike;\n\n/**\n * Get the min among all numbers.\n * @public\n *\n * @param numbers - numbers.\n * @returns The min numbers among them.\n *\n * @example\n * ```typescript\n * numMin(1, 2, 3); // Outputs 1n\n * ```\n */\nexport function numMin(a: NumLike, ...numbers: NumLike[]): Num {\n let min = numFrom(a);\n numbers.forEach((nLike) => {\n const n = numFrom(nLike);\n if (n < min) {\n min = n;\n }\n });\n return min;\n}\n\n/**\n * Get the max among all numbers.\n * @public\n *\n * @param numbers - numbers.\n * @returns The max numbers among them.\n *\n * @example\n * ```typescript\n * numMax(1, 2, 3); // Outputs 3n\n * ```\n */\nexport function numMax(a: NumLike, ...numbers: NumLike[]): Num {\n let max = numFrom(a);\n numbers.forEach((nLike) => {\n const n = numFrom(nLike);\n if (n > max) {\n max = n;\n }\n });\n return max;\n}\n\n/**\n * Converts a NumLike value to a Num (bigint).\n * @public\n *\n * @param val - The value to convert, which can be a string, number, bigint, or HexLike.\n * @returns A Num (bigint) representing the value.\n *\n * @example\n * ```typescript\n * const num = numFrom(\"12345\"); // Outputs 12345n\n * const numFromHex = numFrom(\"0x3039\"); // Outputs 12345n\n * ```\n */\nexport function numFrom(val: NumLike): Num {\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (val === \"0x\") {\n return BigInt(0);\n }\n if (typeof val === \"string\" || typeof val === \"number\") {\n return BigInt(val);\n }\n\n const hex = hexFrom(val);\n return BigInt(hex);\n}\n\n/**\n * Converts a NumLike value to a hexadecimal string.\n * @public\n *\n * @param val - The value to convert, which can be a string, number, bigint, or HexLike.\n * @returns A Hex string representing the numeric value.\n *\n * @example\n * ```typescript\n * const hex = numToHex(12345); // Outputs \"0x3039\"\n * ```\n */\nexport function numToHex(val: NumLike): Hex {\n return `0x${numFrom(val).toString(16)}`;\n}\n\n/**\n * Converts a NumLike value to a byte array in little-endian order.\n * @public\n *\n * @param val - The value to convert, which can be a string, number, bigint, or HexLike.\n * @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.\n * @returns A Uint8Array containing the byte representation of the numeric value.\n *\n * @example\n * ```typescript\n * const bytes = numToBytes(12345, 4); // Outputs Uint8Array [57, 48, 0, 0]\n * ```\n */\n\nexport function numToBytes(val: NumLike, bytes?: number): Bytes {\n return numLeToBytes(val, bytes);\n}\n\n/**\n * Converts a NumLike value to a byte array in little-endian order.\n * @public\n *\n * @param val - The value to convert, which can be a string, number, bigint, or HexLike.\n * @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.\n * @returns A Uint8Array containing the byte representation of the numeric value.\n *\n * @example\n * ```typescript\n * const bytes = numLeToBytes(12345, 4); // Outputs Uint8Array [57, 48, 0, 0]\n * ```\n */\nexport function numLeToBytes(val: NumLike, bytes?: number): Bytes {\n return numBeToBytes(val, bytes).reverse();\n}\n\n/**\n * Converts a NumLike value to a byte array in big-endian order.\n * @public\n *\n * @param val - The value to convert, which can be a string, number, bigint, or HexLike.\n * @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.\n * @returns A Uint8Array containing the byte representation of the numeric value.\n *\n * @example\n * ```typescript\n * const bytes = numBeToBytes(12345, 4); // Outputs Uint8Array [0, 0, 48, 57]\n * ```\n */\nexport function numBeToBytes(val: NumLike, bytes?: number): Bytes {\n let num = numFrom(val);\n if (num < numFrom(0)) {\n if (bytes == null) {\n throw Error(\n \"negative number can not be serialized without knowing bytes length\",\n );\n }\n\n // 0x100............00 - abs(num)\n // | . bytes * 8 .|\n // 2's complement for negative number\n num = (numFrom(1) << (numFrom(8) * numFrom(bytes))) + num;\n if (num < 0) {\n throw Error(\"negative number underflow\");\n }\n }\n\n const rawBytes = bytesFrom(num.toString(16));\n if (bytes == null) {\n return rawBytes;\n }\n\n if (rawBytes.length > bytes) {\n throw Error(\"number overflow\");\n }\n return bytesConcat(\"00\".repeat(bytes - rawBytes.length), rawBytes);\n}\n\n/**\n * Converts a byte array to a Num (bigint) assuming little-endian order.\n * @public\n *\n * @param val - The byte array to convert.\n * @returns A Num (bigint) representing the numeric value.\n *\n * @example\n * ```typescript\n * const num = numFromBytes(new Uint8Array([57, 48, 0, 0])); // Outputs 12345n\n * ```\n */\nexport function numFromBytes(val: BytesLike): Num {\n return numLeFromBytes(val);\n}\n\n/**\n * Converts a byte array to a Num (bigint) assuming little-endian order.\n * @public\n *\n * @param val - The byte array to convert.\n * @returns A Num (bigint) representing the numeric value.\n *\n * @example\n * ```typescript\n * const num = numLeFromBytes(new Uint8Array([57, 48, 0, 0])); // Outputs 12345n\n * ```\n */\nexport function numLeFromBytes(val: BytesLike): Num {\n // reverse() modifies the original array\n // so we use the map to copy it to avoid this\n return numBeFromBytes(\n bytesFrom(val)\n .map((v) => v)\n .reverse(),\n );\n}\n\n/**\n * Converts a byte array to a Num (bigint) assuming big-endian order.\n * @public\n *\n * @param val - The byte array to convert.\n * @returns A Num (bigint) representing the numeric value.\n *\n * @example\n * ```typescript\n * const num = numBeFromBytes(new Uint8Array([0, 0, 48, 57])); // Outputs 12345n\n * ```\n */\nexport function numBeFromBytes(val: BytesLike): Num {\n return numFrom(bytesFrom(val));\n}\n","import { Bytes, bytesFrom, BytesLike } from \"../bytes/index.js\";\nimport { Hex, hexFrom, HexLike } from \"../hex/index.js\";\nimport {\n Num,\n numBeFromBytes,\n numBeToBytes,\n numFromBytes,\n NumLike,\n numToBytes,\n} from \"../num/index.js\";\nimport { Codec } from \"./codec.js\";\n\n/**\n * Create a codec to deal with fixed LE or BE bytes.\n * @param byteLength\n * @param littleEndian\n */\nexport function codecUint(\n byteLength: number,\n littleEndian = false,\n): Codec<NumLike, Num> {\n return Codec.from({\n byteLength,\n encode: (numLike) => {\n if (littleEndian) {\n return numToBytes(numLike, byteLength);\n } else {\n return numBeToBytes(numLike, byteLength);\n }\n },\n decode: (buffer) => {\n if (littleEndian) {\n return numFromBytes(buffer);\n } else {\n return numBeFromBytes(buffer);\n }\n },\n });\n}\n\n/**\n * Create a codec to deal with fixed LE or BE bytes.\n * @param byteLength\n * @param littleEndian\n */\nexport function codecUintNumber(\n byteLength: number,\n littleEndian = false,\n): Codec<NumLike, number> {\n if (byteLength > 4) {\n throw new Error(\"uintNumber: byteLength must be less than or equal to 4\");\n }\n return codecUint(byteLength, littleEndian).map({\n outMap: (num) => Number(num),\n });\n}\n\n/**\n * Create a codec for padding bytes.\n * The padding bytes are zero-filled when encoding and ignored when decoding.\n * @param byteLength The length of the padding in bytes.\n */\nexport function codecPadding(\n byteLength: number,\n): Codec<void | undefined | null, void> {\n return Codec.from({\n byteLength,\n encode: () => {\n return new Uint8Array(byteLength);\n },\n decode: () => {},\n });\n}\n\nexport const CodecRaw: Codec<BytesLike, Bytes> = Codec.from({\n encode: (value) => bytesFrom(value),\n decode: (buffer) => bytesFrom(buffer),\n});\n\nexport const CodecBytes: Codec<HexLike, Hex> = Codec.from({\n encode: (value) => bytesFrom(value),\n decode: (buffer) => hexFrom(buffer),\n});\n\nexport const CodecUint8 = codecUintNumber(1, true);\n\nexport const CodecUint16LE = codecUintNumber(2, true);\nexport const CodecUint16BE = codecUintNumber(2);\nexport const CodecUint16 = CodecUint16LE;\n\nexport const CodecUint32LE = codecUintNumber(4, true);\nexport const CodecUint32BE = codecUintNumber(4);\nexport const CodecUint32 = CodecUint32LE;\n\nexport const CodecUint64LE = codecUint(8, true);\nexport const CodecUint64BE = codecUint(8);\nexport const CodecUint64 = CodecUint64LE;\n\nexport const CodecUint128LE = codecUint(16, true);\nexport const CodecUint128BE = codecUint(16);\nexport const CodecUint128 = CodecUint128LE;\n\nexport const CodecUint256LE = codecUint(32, true);\nexport const CodecUint256BE = codecUint(32);\nexport const CodecUint256 = CodecUint256LE;\n\nexport const CodecUint512LE = codecUint(64, true);\nexport const CodecUint512BE = codecUint(64);\nexport const CodecUint512 = CodecUint512LE;\n\nexport const CodecBool: Codec<boolean> = Codec.from({\n byteLength: 1,\n encode: (value) => bytesFrom(value ? [1] : [0]),\n decode: (buffer) => bytesFrom(buffer)[0] !== 0,\n});\n\nexport const CodecByte: Codec<HexLike, Hex> = Codec.from({\n byteLength: 1,\n encode: (value) => bytesFrom(value),\n decode: (buffer) => hexFrom(buffer),\n});\n\nexport const CodecByte4: Codec<HexLike, Hex> = Codec.from({\n byteLength: 4,\n encode: (value) => bytesFrom(value),\n decode: (buffer) => hexFrom(buffer),\n});\n\nexport const CodecByte8: Codec<HexLike, Hex> = Codec.from({\n byteLength: 8,\n encode: (value) => bytesFrom(value),\n decode: (buffer) => hexFrom(buffer),\n});\n\nexport const CodecByte16: Codec<HexLike, Hex> = Codec.from({\n byteLength: 16,\n encode: (value) => bytesFrom(value),\n decode: (buffer) => hexFrom(buffer),\n});\n\nexport const CodecByte32: Codec<HexLike, Hex> = Codec.from({\n byteLength: 32,\n encode: (value) => bytesFrom(value),\n decode: (buffer) => hexFrom(buffer),\n});\n","/**\n * Represents a fixed point value as a bigint.\n * @public\n */\n\nexport type FixedPoint = bigint;\n\n/**\n * Represents a value that can be converted to a fixed point value.\n * It can be a bigint, string, or number.\n * @public\n */\n\nexport type FixedPointLike = bigint | string | number;\n\n/**\n * Converts a FixedPointLike value to its string representation with fixed-point decimals.\n * @public\n *\n * @param val - The value to convert, which can be a bigint, string, or number.\n * @param decimals - The number of decimal places for the fixed-point representation. Default is 8.\n * @returns A string representing the fixed-point value.\n *\n * @example\n * ```typescript\n * const str = fixedPointToString(123456789n, 8); // Outputs \"1.23456789\"\n * const strFromString = fixedPointToString(\"1.23456789\", 8); // Outputs \"1.23456789\"\n * const strFromNumber = fixedPointToString(1.23456789, 8); // Outputs \"1.23456789\"\n * ```\n */\n\nexport function fixedPointToString(val: FixedPointLike, decimals = 8): string {\n const str = fixedPointFrom(val).toString();\n if (decimals === 0) {\n return str;\n }\n\n const l = str.length <= decimals ? \"0\" : str.slice(0, -decimals);\n const r = str.slice(-decimals).padStart(decimals, \"0\").replace(/0*$/, \"\");\n if (r === \"\") {\n return l;\n }\n\n return `${l}.${r}`;\n}\n\n/**\n * Converts a FixedPointLike value to a FixedPoint (bigint) with fixed-point decimals.\n * @public\n *\n * @param val - The value to convert, which can be a bigint, string, or number.\n * @param decimals - The number of decimal places for the fixed-point representation. Default is 8.\n * @returns A FixedPoint (bigint) representing the value with fixed-point decimals.\n *\n * @example\n * ```typescript\n * const fixedPoint = fixedPointFrom(123456789n, 8); // Outputs 123456789n\n * const fixedPointFromString = fixedPointFrom(\"1.23456789\", 8); // Outputs 123456789n\n * const fixedPointFromNumber = fixedPointFrom(1.23456789, 8); // Outputs 123456789n\n * ```\n */\n\nexport function fixedPointFrom(val: FixedPointLike, decimals = 8): FixedPoint {\n if (typeof val === \"bigint\") {\n return val;\n }\n\n const [l, r] = (\n typeof val === \"number\" ? val.toFixed(decimals) : val.toString()\n ).split(\".\");\n const lVal = BigInt(l.padEnd(l.length + decimals, \"0\"));\n if (r === undefined) {\n return lVal;\n }\n\n return lVal + BigInt(r.slice(0, decimals).padEnd(decimals, \"0\"));\n}\n\n/**\n * Represents the fixed point value of zero as a bigint.\n * @public\n */\n\nexport const Zero: FixedPoint = 0n;\n\n/**\n * Represents the fixed point value of one as a FixedPoint (bigint).\n * Equivalent to 1 in fixed-point representation with default decimals (8).\n * @public\n */\n\nexport const One: FixedPoint = fixedPointFrom(\"1\");\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n bytesConcat,\n bytesConcatTo,\n bytesFrom,\n BytesLike,\n} from \"../bytes/index.js\";\nimport {\n Codec,\n CodecLike,\n DecodedType,\n EncodableType,\n} from \"../codec/index.js\";\nimport { numFromBytes, NumLike, numToBytes } from \"../num/index.js\";\n\nexport {\n /**\n * @deprecated Use ccc.Codec instead\n */\n Codec,\n /**\n * @deprecated Use ccc.codecUint instead\n */\n codecUint as uint,\n /**\n * @deprecated Use ccc.codecUintNumber instead\n */\n codecUintNumber as uintNumber,\n /**\n * @deprecated Use ccc.CodecLike instead\n */\n type CodecLike,\n /**\n * @deprecated Use ccc.DecodedType instead\n */\n type DecodedType,\n /**\n * @deprecated Use ccc.EncodableType instead\n */\n type EncodableType,\n} from \"../codec/index.js\";\n\nfunction uint32To(numLike: NumLike) {\n return numToBytes(numLike, 4);\n}\n\nfunction uint32From(bytesLike: BytesLike) {\n return Number(numFromBytes(bytesLike));\n}\n\n/**\n * Vector with fixed size item codec\n * @param itemCodec fixed-size vector item codec\n */\nexport function fixedItemVec<Encodable, Decoded>(\n itemCodec: CodecLike<Encodable, Decoded>,\n): Codec<Array<Encodable>, Array<Decoded>> {\n const itemByteLength = itemCodec.byteLength;\n if (itemByteLength === undefined) {\n throw new Error(\"fixedItemVec: itemCodec requires a byte length\");\n }\n\n return Codec.from({\n encode(userDefinedItems) {\n try {\n const concatted: number[] = [];\n bytesConcatTo(concatted, uint32To(userDefinedItems.length));\n for (const item of userDefinedItems) {\n bytesConcatTo(concatted, itemCodec.encode(item));\n }\n return bytesFrom(concatted);\n } catch (e: unknown) {\n throw new Error(\"fixedItemVec failed\", { cause: e });\n }\n },\n decode(buffer, config) {\n const value = bytesFrom(buffer);\n if (value.byteLength < 4) {\n throw new Error(\n `fixedItemVec: too short buffer, expected at least 4 bytes, but got ${value.byteLength}`,\n );\n }\n const itemCount = uint32From(value.slice(0, 4));\n const byteLength = 4 + itemCount * itemByteLength;\n if (value.byteLength !== byteLength) {\n throw new Error(\n `fixedItemVec: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`,\n );\n }\n\n try {\n const decodedArray: Array<Decoded> = [];\n for (let offset = 4; offset < byteLength; offset += itemByteLength) {\n decodedArray.push(\n itemCodec.decode(\n value.slice(offset, offset + itemByteLength),\n config,\n ),\n );\n }\n return decodedArray;\n } catch (e) {\n throw new Error(\"fixedItemVec failed\", { cause: e });\n }\n },\n });\n}\n\n/**\n * Vector with dynamic size item codec, you can create a recursive vector with this function\n * @param itemCodec the vector item codec. It can be fixed-size or dynamic-size.\n */\nexport function dynItemVec<Encodable, Decoded>(\n itemCodec: CodecLike<Encodable, Decoded>,\n): Codec<Array<Encodable>, Array<Decoded>> {\n return Codec.from({\n encode(userDefinedItems) {\n try {\n let offset = 4 + userDefinedItems.length * 4;\n const header: number[] = [];\n const body: number[] = [];\n\n for (const item of userDefinedItems) {\n const encoded = itemCodec.encode(item);\n bytesConcatTo(header, uint32To(offset));\n bytesConcatTo(body, encoded);\n offset += encoded.byteLength;\n }\n\n const packedTotalSize = uint32To(header.length + body.length + 4);\n return bytesConcat(packedTotalSize, header, body);\n } catch (e) {\n throw new Error(\"dynItemVec failed\", { cause: e });\n }\n },\n decode(buffer, config) {\n const value = bytesFrom(buffer);\n if (value.byteLength < 4) {\n throw new Error(\n `dynItemVec: too short buffer, expected at least 4 bytes, but got ${value.byteLength}`,\n );\n }\n const byteLength = uint32From(value.slice(0, 4));\n if (byteLength !== value.byteLength) {\n throw new Error(\n `dynItemVec: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`,\n );\n }\n\n if (byteLength === 4) {\n return [];\n }\n\n const offset = uint32From(value.slice(4, 8));\n const itemCount = (offset - 4) / 4;\n const offsets = Array.from(new Array(itemCount), (_, index) =>\n uint32From(value.slice(4 + index * 4, 8 + index * 4)),\n );\n offsets.push(byteLength);\n try {\n const decodedArray: Array<Decoded> = [];\n for (let index = 0; index < offsets.length - 1; index++) {\n const start = offsets[index];\n const end = offsets[index + 1];\n const itemBuffer = value.slice(start, end);\n decodedArray.push(itemCodec.decode(itemBuffer, config));\n }\n return decodedArray;\n } catch (e) {\n throw new Error(\"dynItemVec failed\", { cause: e });\n }\n },\n });\n}\n\n/**\n * General vector codec, if `itemCodec` is fixed size type, it will create a fixvec codec, otherwise a dynvec codec will be created.\n * @param itemCodec\n */\nexport function vector<Encodable, Decoded>(\n itemCodec: CodecLike<Encodable, Decoded>,\n): Codec<Array<Encodable>, Array<Decoded>> {\n if (itemCodec.byteLength !== undefined) {\n return fixedItemVec(itemCodec);\n }\n return dynItemVec(itemCodec);\n}\n\n/**\n * Option is a dynamic-size type.\n * Serializing an option depends on whether it is empty or not:\n * - if it's empty, there is zero bytes (the size is 0).\n * - if it's not empty, just serialize the inner item (the size is same as the inner item's size).\n * @param innerCodec\n */\nexport function option<Encodable, Decoded>(\n innerCodec: CodecLike<Encodable, Decoded>,\n): Codec<Encodable | undefined | null, Decoded | undefined> {\n return Codec.from({\n encode(userDefinedOrNull) {\n if (userDefinedOrNull == null) {\n return bytesFrom([]);\n }\n try {\n return innerCodec.encode(userDefinedOrNull);\n } catch (e) {\n throw new Error(\"option failed\", { cause: e });\n }\n },\n decode(buffer, config) {\n const value = bytesFrom(buffer);\n if (value.byteLength === 0) {\n return undefined;\n }\n try {\n return innerCodec.decode(buffer, config);\n } catch (e) {\n throw new Error(\"option failed\", { cause: e });\n }\n },\n });\n}\n\n/**\n * Wrap the encoded value with a fixed-length buffer\n * @param codec\n */\nexport function byteVec<Encodable, Decoded>(\n codec: CodecLike<Encodable, Decoded>,\n): Codec<Encodable, Decoded> {\n return Codec.from({\n encode(userDefined) {\n try {\n const payload = bytesFrom(codec.encode(userDefined));\n const byteLength = uint32To(payload.byteLength);\n return bytesConcat(byteLength, payload);\n } catch (e) {\n throw new Error(\"byteVec failed\", { cause: e });\n }\n },\n decode(buffer, config) {\n const value = bytesFrom(buffer);\n if (value.byteLength < 4) {\n throw new Error(\n `byteVec: too short buffer, expected at least 4 bytes, but got ${value.byteLength}`,\n );\n }\n const byteLength = uint32From(value.slice(0, 4));\n if (byteLength !== value.byteLength - 4) {\n throw new Error(\n `byteVec: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`,\n );\n }\n try {\n return codec.decode(value.slice(4), config);\n } catch (e: unknown) {\n throw new Error(\"byteVec failed\", { cause: e });\n }\n },\n });\n}\n\nexport type EncodableRecordOptionalKeys<\n T extends Record<string, CodecLike<any, any>>,\n> = {\n [K in keyof T]: Extract<EncodableType<T[K]>, undefined> extends never\n ? never\n : K;\n}[keyof T];\nexport type EncodableRecord<T extends Record<string, CodecLike<any, any>>> = {\n [key in keyof Pick<T, EncodableRecordOptionalKeys<T>>]+?: EncodableType<\n T[key]\n >;\n} & {\n [key in keyof Omit<T, EncodableRecordOptionalKeys<T>>]: EncodableType<T[key]>;\n};\n\nexport type DecodedRecordOptionalKeys<\n T extends Record<string, CodecLike<any, any>>,\n> = {\n [K in keyof T]: Extract<DecodedType<T[K]>, undefined> extends never\n ? never\n : K;\n}[keyof T];\nexport type DecodedRecord<T extends Record<string, CodecLike<any, any>>> = {\n [key in keyof Pick<T, DecodedRecordOptionalKeys<T>>]+?: DecodedType<T[key]>;\n} & {\n [key in keyof Omit<T, DecodedRecordOptionalKeys<T>>]: DecodedType<T[key]>;\n};\n\n/**\n * Table is a dynamic-size type. It can be considered as a dynvec but the length is fixed.\n * @param codecLayout\n */\nexport function table<\n T extends Record<string, CodecLike<any, any>>,\n Encodable extends EncodableRecord<T>,\n Decoded extends DecodedRecord<T>,\n>(codecLayout: T): Codec<Encodable, Decoded> {\n const keys = Object.keys(codecLayout);\n\n return Codec.from({\n encode(object) {\n let offset = 4 + keys.length * 4;\n const header: number[] = [];\n const body: number[] = [];\n\n for (const key of keys) {\n try {\n const encoded = codecLayout[key].encode((object as any)[key]);\n bytesConcatTo(header, uint32To(offset));\n bytesConcatTo(body, encoded);\n offset += encoded.byteLength;\n } catch (e: unknown) {\n throw new Error(`table.${key} failed`, { cause: e });\n }\n }\n\n const packedTotalSize = uint32To(header.length + body.length + 4);\n return bytesConcat(packedTotalSize, header, body);\n },\n decode(buffer, config) {\n const value = bytesFrom(buffer);\n if (value.byteLength < 4) {\n throw new Error(\n `table: too short buffer, expected at least 4 bytes, but got ${value.byteLength}`,\n );\n }\n const byteLength = uint32From(value.slice(0, 4));\n const headerLength = uint32From(value.slice(4, 8));\n const actualFieldCount = (headerLength - 4) / 4;\n\n if (byteLength !== value.byteLength) {\n throw new Error(\n `table: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`,\n );\n }\n\n if (actualFieldCount < keys.length) {\n throw new Error(\n `table: invalid field count, expected ${keys.length}, but got ${actualFieldCount}`,\n );\n }\n\n if (actualFieldCount > keys.length && !config?.isExtraFieldIgnored) {\n throw new Error(\n `table: invalid field count, expected ${keys.length}, but got ${actualFieldCount}, and extra fields are not allowed in the current configuration. If you want to ignore extra fields, set isExtraFieldIgnored to true.`,\n );\n }\n const offsets = keys.map((_, index) =>\n uint32From(value.slice(4 + index * 4, 8 + index * 4)),\n );\n // If there are extra fields, add the last offset to the offsets array\n if (actualFieldCount > keys.length) {\n offsets.push(\n uint32From(value.slice(4 + keys.length * 4, 8 + keys.length * 4)),\n );\n } else {\n // If there are no extra fields, add the byte length to the offsets array\n offsets.push(byteLength);\n }\n const object = {};\n for (let i = 0; i < offsets.length - 1; i++) {\n const start = offsets[i];\n const end = offsets[i + 1];\n const field = keys[i];\n const codec = codecLayout[field];\n const payload = value.slice(start, end);\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n Object.assign(object, { [field]: codec.decode(payload, config) });\n } catch (e: unknown) {\n throw new Error(`table.${field} failed`, { cause: e });\n }\n }\n return object as Decoded;\n },\n });\n}\n\ntype UnionEncodable<\n T extends Record<string, CodecLike<any, any>>,\n K extends keyof T = keyof T,\n> = K extends unknown\n ? {\n type: K;\n value: EncodableType<T[K]>;\n }\n : never;\ntype UnionDecoded<\n T extends Record<string, CodecLike<any, any>>,\n K extends keyof T = keyof T,\n> = K extends unknown\n ? {\n type: K;\n value: DecodedType<T[K]>;\n }\n : never;\n\n/**\n * Constructs a union codec that can serialize and deserialize values tagged with a type identifier.\n *\n * If all variants have the same fixed size, the resulting union codec is fixed-size (header + payload).\n * Otherwise, it falls back to a dynamic-size codec.\n *\n * Serialization format:\n * 1. 4-byte little-endian unsigned integer for the variant index.\n * 2. Encoded bytes of the selected variant.\n *\n * @typeParam T\n * A record mapping variant names to codecs.\n * @param codecLayout\n * An object whose keys are variant names and values are codecs for each variant.\n * @param fields\n * Optional mapping from variant names to custom numeric IDs. If omitted, the index\n * of each variant in `codecLayout` is used as its ID.\n *\n *\n * @example\n * // Dynamic union without custom numeric IDs\n * union({ cafe: Uint8, bee: Uint16 })\n *\n * // Dynamic union with custom numeric IDs\n * union({ cafe: Uint8, bee: Uint16 }, { cafe: 0xcafe, bee: 0xbee })\n *\n * // Fixed-size union without custom numeric IDs\n * const PaddedUint8 = struct({ data : u8, padding : u8 })\n * union({ cafe: PaddedUint8, bee: Uint16 });\n *\n * // Fixed-size union with custom numeric IDs\n * union({ cafe: PaddedUint8, bee: Uint16 }, { cafe: 0xcafe, bee: 0xbee })\n */\n\nexport function union<T extends Record<string, CodecLike<any, any>>>(\n codecLayout: T,\n fields?: Record<keyof T, number | undefined | null>,\n): Codec<UnionEncodable<T>, UnionDecoded<T>> {\n const entries = Object.entries(codecLayout);\n\n // Determine if all variants have a fixed and equal byteLength.\n let byteLength: number | undefined;\n if (entries.length > 0) {\n const firstLen = entries[0][1].byteLength;\n if (\n firstLen !== undefined &&\n entries.every(([, { byteLength: len }]) => len === firstLen)\n ) {\n // Add 4 bytes for the type header\n byteLength = firstLen + 4;\n }\n }\n\n return Codec.from({\n byteLength,\n encode({ type, value }) {\n const typeStr = type.toString();\n const codec = codecLayout[typeStr];\n if (!codec) {\n throw new Error(\n `union: invalid type, expected ${entries.map((e) => e[0]).toString()}, but got ${typeStr}`,\n );\n }\n const fieldId = fields\n ? (fields[typeStr] ?? -1)\n : entries.findIndex((e) => e[0] === typeStr);\n if (fieldId < 0) {\n throw new Error(`union: invalid field id ${fieldId} of ${typeStr}`);\n }\n const header = uint32To(fieldId);\n try {\n const body = codec.encode(value);\n return bytesConcat(header, body);\n } catch (e: unknown) {\n throw new Error(`union.${typeStr} failed`, { cause: e });\n }\n },\n decode(buffer, config) {\n const value = bytesFrom(buffer);\n const fieldIndex = uint32From(value.slice(0, 4));\n const keys = Object.keys(codecLayout);\n\n const field = (() => {\n if (!fields) {\n return keys[fieldIndex];\n }\n const entry = Object.entries(fields).find(\n ([, id]) => id === fieldIndex,\n );\n return entry?.[0];\n })();\n\n if (!field) {\n if (!fields) {\n throw new Error(\n `union: unknown union field index ${fieldIndex}, only ${keys.toString()} are allowed`,\n );\n }\n const fieldKeys = Object.keys(fields);\n throw new Error(\n `union: unknown union field index ${fieldIndex}, only ${fieldKeys.toString()} and ${keys.toString()} are allowed`,\n );\n }\n\n return {\n type: field,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n value: codecLayout[field].decode(value.slice(4), config),\n } as UnionDecoded<T>;\n },\n });\n}\n\n/**\n * Struct is a fixed-size type: all fields in struct are fixed-size and it has a fixed quantity of fields.\n * The size of a struct is the sum of all fields' size.\n * @param codecLayout a object contains all fields' codec\n */\nexport function struct<\n T extends Record<string, CodecLike<any, any>>,\n Encodable extends EncodableRecord<T>,\n Decoded extends DecodedRecord<T>,\n>(codecLayout: T): Codec<Encodable, Decoded> {\n const codecArray = Object.values(codecLayout);\n const keys = Object.keys(codecLayout);\n\n return Codec.from({\n byteLength: codecArray.reduce((acc, codec) => {\n if (codec.byteLength === undefined) {\n throw new Error(\"struct: all fields must be fixed-size\");\n }\n return acc + codec.byteLength;\n }, 0),\n encode(object) {\n const bytes: number[] = [];\n for (const key of keys) {\n try {\n const encoded = codecLayout[key].encode((object as any)[key]);\n bytesConcatTo(bytes, encoded);\n } catch (e: unknown) {\n throw new Error(`struct.${key} failed`, { cause: e });\n }\n }\n\n return bytesFrom(bytes);\n },\n decode(buffer, config) {\n const value = bytesFrom(buffer);\n const object = {};\n let offset = 0;\n Object.entries(codecLayout).forEach(([key, codec]) => {\n const payload = value.slice(offset, offset + codec.byteLength!);\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n Object.assign(object, { [key]: codec.decode(payload, config) });\n } catch (e: unknown) {\n throw new Error(`struct.${key} failed`, { cause: e });\n }\n offset = offset + codec.byteLength!;\n });\n return object as Decoded;\n },\n });\n}\n\n/**\n * The array is a fixed-size type: it has a fixed-size inner type and a fixed length.\n * The size of an array is the size of inner type times the length.\n * @param itemCodec the fixed-size array item codec\n * @param itemCount\n */\nexport function array<Encodable, Decoded>(\n itemCodec: CodecLike<Encodable, Decoded>,\n itemCount: number,\n): Codec<Array<Encodable>, Array<Decoded>> {\n if (itemCodec.byteLength === undefined) {\n throw new Error(\"array: itemCodec requires a byte length\");\n }\n const byteLength = itemCodec.byteLength * itemCount;\n\n return Codec.from({\n byteLength,\n encode(items) {\n try {\n const bytes: number[] = [];\n for (const item of items) {\n bytesConcatTo(bytes, itemCodec.encode(item));\n }\n\n return bytesFrom(bytes);\n } catch (e: unknown) {\n throw new Error(\"array failed\", { cause: e });\n }\n },\n decode(buffer, config) {\n const value = bytesFrom(buffer);\n if (value.byteLength != byteLength) {\n throw new Error(\n `array: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`,\n );\n }\n try {\n const result: Array<Decoded> = [];\n for (let i = 0; i < value.byteLength; i += itemCodec.byteLength!) {\n result.push(\n itemCodec.decode(value.slice(i, i + itemCodec.byteLength!), config),\n );\n }\n return result;\n } catch (e: unknown) {\n throw new Error(\"array failed\", { cause: e });\n }\n },\n });\n}\n","import { bytesFrom, bytesTo } from \"../bytes/index.js\";\nimport { Codec, CodecBytes } from \"../codec/index.js\";\nimport { Hex, HexLike } from \"../hex/index.js\";\nimport { byteVec, option, vector } from \"./codec.js\";\n\nimport {\n CodecBool as Bool,\n CodecByte as Byte,\n CodecByte16 as Byte16,\n CodecByte32 as Byte32,\n CodecByte4 as Byte4,\n CodecByte8 as Byte8,\n CodecUint128 as Uint128,\n CodecUint128BE as Uint128BE,\n CodecUint128LE as Uint128LE,\n CodecUint16 as Uint16,\n CodecUint16BE as Uint16BE,\n CodecUint16LE as Uint16LE,\n CodecUint256 as Uint256,\n CodecUint256BE as Uint256BE,\n CodecUint256LE as Uint256LE,\n CodecUint32 as Uint32,\n CodecUint32BE as Uint32BE,\n CodecUint32LE as Uint32LE,\n CodecUint512 as Uint512,\n CodecUint512BE as Uint512BE,\n CodecUint512LE as Uint512LE,\n CodecUint64 as Uint64,\n CodecUint64BE as Uint64BE,\n CodecUint64LE as Uint64LE,\n CodecUint8 as Uint8,\n} from \"../codec/index.js\";\n\nexport {\n Bool,\n Byte,\n Byte16,\n Byte32,\n Byte4,\n Byte8,\n Uint128,\n Uint128BE,\n Uint128LE,\n Uint16,\n Uint16BE,\n Uint16LE,\n Uint256,\n Uint256BE,\n Uint256LE,\n Uint32,\n Uint32BE,\n Uint32LE,\n Uint512,\n Uint512BE,\n Uint512LE,\n Uint64,\n Uint64BE,\n Uint64LE,\n Uint8,\n};\n\nexport const Uint8Opt = option(Uint8);\nexport const Uint8Vec = vector(Uint8);\n\nexport const Uint16Opt = option(Uint16);\nexport const Uint16Vec = vector(Uint16);\n\nexport const Uint32Opt = option(Uint32);\nexport const Uint32Vec = vector(Uint32);\n\nexport const Uint64Opt = option(Uint64);\nexport const Uint64Vec = vector(Uint64);\n\nexport const Uint128Opt = option(Uint128);\nexport const Uint128Vec = vector(Uint128);\n\nexport const Uint256Opt = option(Uint256);\nexport const Uint256Vec = vector(Uint256);\n\nexport const Uint512Opt = option(Uint512);\nexport const Uint512Vec = vector(Uint512);\n\nexport const Bytes: Codec<HexLike, Hex> = byteVec(CodecBytes);\nexport const BytesOpt = option(Bytes);\nexport const BytesVec = vector(Bytes);\n\nexport const BoolOpt = option(Bool);\nexport const BoolVec = vector(Bool);\n\nexport const ByteOpt = option(Byte);\nexport const ByteVec = vector(Byte);\n\nexport const Byte4Opt = option(Byte4);\nexport const Byte4Vec = vector(Byte4);\n\nexport const Byte8Opt = option(Byte8);\nexport const Byte8Vec = vector(Byte8);\n\nexport const Byte16Opt = option(Byte16);\nexport const Byte16Vec = vector(Byte16);\n\nexport const Byte32Opt = option(Byte32);\nexport const Byte32Vec = vector(Byte32);\n\nexport const String = byteVec({\n encode: (value: string) => bytesFrom(value, \"utf8\"),\n decode: (buffer) => bytesTo(buffer, \"utf8\"),\n});\nexport const StringVec = vector(String);\nexport const StringOpt = option(String);\n","import { Zero } from \"../fixedPoint/index.js\";\nimport { NumLike, numFrom, numToHex, type Num } from \"../num/index.js\";\n\n/**\n * A type safe way to apply a transformer on a value if it's not empty.\n * @public\n *\n * @param transformer - The transformer.\n * @param value - The value to be transformed.\n * @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.\n */\nexport function apply<T, R>(\n transformer: (val: T) => R,\n value: undefined,\n): undefined;\n/**\n * A type safe way to apply a transformer on a value if it's not empty.\n * @public\n *\n * @param transformer - The transformer.\n * @param value - The value to be transformed.\n * @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.\n */\nexport function apply<T, R>(transformer: (val: T) => R, value: null): undefined;\n/**\n * A type safe way to apply a transformer on a value if it's not empty.\n * @public\n *\n * @param transformer - The transformer.\n * @param value - The value to be transformed.\n * @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.\n */\nexport function apply<T, R>(transformer: (val: T) => R, value: T): R;\n/**\n * A type safe way to apply a transformer on a value if it's not empty.\n * @public\n *\n * @param transformer - The transformer.\n * @param value - The value to be transformed.\n * @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.\n */\nexport function apply<T, R>(\n transformer: (val: T) => R,\n value: T | undefined,\n): R | undefined;\n/**\n * A type safe way to apply a transformer on a value if it's not empty.\n * @public\n *\n * @param transformer - The transformer.\n * @param value - The value to be transformed.\n * @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.\n */\nexport function apply<T, R>(\n transformer: (val: T) => R,\n value: T | null,\n): R | undefined;\n/**\n * A type safe way to apply a transformer on a value if it's not empty.\n * @public\n *\n * @param transformer - The transformer.\n * @param value - The value to be transformed.\n * @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.\n */\nexport function apply<T, R>(\n transformer: (val: T) => R,\n value: undefined | null,\n): undefined;\n/**\n/**\n * A type safe way to apply a transformer on a value if it's not empty.\n * @public\n *\n * @param transformer - The transformer.\n * @param value - The value to be transformed.\n * @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.\n */\nexport function apply<T, R>(\n transformer: (val: T) => R,\n value: T | undefined | null,\n): R | undefined;\n/**\n * A type safe way to apply a transformer on a value if it's not empty.\n * @public\n *\n * @param transformer - The transformer.\n * @param value - The value to be transformed.\n * @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.\n */\nexport function apply<T, R>(\n transformer: (val: T) => R,\n value: T | undefined | null,\n): R | undefined {\n if (value == null) {\n return undefined;\n }\n\n return transformer(value);\n}\n\n/**\n * Similar to Array.reduce, but the accumulator can returns Promise.\n * @public\n *\n * @param values - The array to be reduced.\n * @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.\n * @returns The accumulated result.\n */\nexport async function reduceAsync<T>(\n values: T[],\n accumulator: (\n a: T,\n b: T,\n ) => Promise<T | undefined | null | void> | T | undefined | null | void,\n): Promise<T>;\n/**\n * Similar to Array.reduce, but the accumulator can returns Promise.\n * @public\n *\n * @param values - The array to be reduced.\n * @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.\n * @param init - The initial value.\n * @returns The accumulated result.\n */\nexport async function reduceAsync<T, V>(\n values: V[],\n accumulator: (\n a: T,\n b: V,\n i: number,\n values: V[],\n ) => Promise<T | undefined | null | void> | T | undefined | null | void,\n init: T | Promise<T>,\n): Promise<T>;\n/**\n * Similar to Array.reduce, but the accumulator can returns Promise.\n * @public\n *\n * @param values - The array to be reduced.\n * @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.\n * @param init - The initial value.\n * @returns The accumulated result.\n */\nexport async function reduceAsync<T, V>(\n values: (V | T)[],\n accumulator: (\n a: T,\n b: T | V,\n i: number,\n values: (V | T)[],\n ) => Promise<T | undefined | null | void> | T | undefined | null | void,\n init?: T | Promise<T>,\n): Promise<T> {\n if (init === undefined) {\n if (values.length === 0) {\n throw new TypeError(\"Reduce of empty array with no initial value\");\n }\n init = values[0] as T;\n values = values.slice(1);\n }\n\n return values.reduce(\n (current: Promise<T>, b: T | V, i, array) =>\n current.then((v) =>\n Promise.resolve(accumulator(v, b, i, array)).then((r) => r ?? v),\n ),\n Promise.resolve(init),\n );\n}\n\nexport function sleep(ms: NumLike) {\n return new Promise((resolve) => setTimeout(resolve, Number(numFrom(ms))));\n}\n\nexport type Constructor<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n};\n\n/**\n * @public\n */\nexport function isWebview(userAgent: string): boolean {\n return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(userAgent);\n}\n\n/**\n * @public\n */\nexport function stringify(val: unknown) {\n return JSON.stringify(val, (_, value) => {\n if (typeof value === \"bigint\") {\n return numToHex(value);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n });\n}\n\n/**\n * Calculate the greatest common divisor (GCD) of two NumLike values using the Euclidean algorithm.\n *\n * @param a - First operand.\n * @param b - Second operand.\n * @returns GCD(a, b) as a Num.\n */\nexport function gcd(a: NumLike, b: NumLike): Num {\n a = numFrom(a);\n b = numFrom(b);\n a = a < Zero ? -a : a;\n b = b < Zero ? -b : b;\n while (b !== Zero) {\n [a, b] = [b, a % b];\n }\n return a;\n}\n","import type { ClientBlockHeader } from \"../client/clientTypes.js\";\nimport { codec, codecPadding, codecUint, Entity } from \"../codec/index.js\";\nimport { Zero } from \"../fixedPoint/index.js\";\nimport { type Hex, type HexLike } from \"../hex/index.js\";\nimport { mol } from \"../molecule/index.js\";\nimport { numFrom, NumLike, numToHex, type Num } from \"../num/index.js\";\nimport { gcd } from \"../utils/index.js\";\n\n/**\n * EpochLike\n *\n * Union type that represents any allowed input shapes that can be converted\n * into an Epoch instance.\n *\n * Accepted shapes:\n * - Tuple: [integer, numerator, denominator] where each element is NumLike\n * - Object: { integer, numerator, denominator } where each field is NumLike\n * - Packed numeric form: Num (bigint) or Hex (RPC-style packed hex)\n *\n * Notes:\n * - When constructing an Epoch from a Num or Hex the packed numeric representation\n * encodes integer (24 bits), numerator (16 bits) and denominator (16 bits).\n * - Use Epoch.from() to convert any EpochLike into an Epoch instance.\n *\n * @example\n * // From tuple\n * Epoch.from([1n, 0n, 1n]);\n */\nexport type EpochLike =\n | [NumLike, NumLike, NumLike]\n | {\n integer: NumLike;\n numerator: NumLike;\n denominator: NumLike;\n }\n | Num\n | Hex;\n\n/**\n * Epoch\n *\n * Represents a blockchain epoch consisting of a whole integer part and an\n * optional fractional part represented as numerator/denominator.\n *\n * Behavior highlights:\n * - Internally stores values as Num (bigint).\n * - Provides normalization routines to canonicalize the fractional part:\n * - normalizeBase(): fixes zero/negative denominators\n * - normalizeCanonical(): reduces fraction, borrows/carries whole units\n * - Supports arithmetic (add/sub), comparison and conversion utilities.\n *\n * @example\n * const e = new Epoch(1n, 1n, 2n); // 1 + 1/2\n *\n * @remarks\n * This class is primarily a thin value-object; operations return new Epoch instances.\n */\n@codec(\n mol.struct({\n padding: codecPadding(1),\n denominator: codecUint(2),\n numerator: codecUint(2),\n integer: codecUint(3),\n }),\n)\nexport class Epoch extends Entity.Base<EpochLike, Epoch>() {\n /**\n * Construct a new Epoch instance.\n *\n * @param integer - Whole epoch units (Num/bigint)\n * @param numerator - Fractional numerator (Num).\n * @param denominator - Fractional denominator (Num).\n */\n public constructor(\n public readonly integer: Num,\n public readonly numerator: Num,\n public readonly denominator: Num,\n ) {\n super();\n }\n\n /**\n * Normalize simpler base invariants:\n * - If denominator === 0, set denominator to 1 and numerator to 0 for arithmetic convenience.\n * - If denominator is negative flip signs of numerator and denominator to keep denominator positive.\n *\n * This is a minimal correction used before arithmetic or canonical normalization.\n *\n * @returns New Epoch with denominator corrected (but fraction not reduced).\n */\n normalizeBase(): Epoch {\n if (this.denominator === Zero) {\n return new Epoch(this.integer, Zero, numFrom(1));\n }\n\n if (this.denominator < Zero) {\n return new Epoch(this.integer, -this.numerator, -this.denominator);\n }\n\n return this;\n }\n\n /**\n * Perform full canonical normalization of the epoch value.\n *\n * Steps:\n * 1. Apply base normalization (normalizeBase).\n * 2. If numerator is negative, borrow whole denominator(s) from the integer part\n * so numerator becomes non-negative. This ensures 0 <= numerator < denominator whenever possible.\n * 3. Reduce numerator/denominator by their greatest common divisor (gcd).\n * 4. Carry any whole units from the reduced numerator into the integer part.\n * 5. Ensure numerator is the strict remainder (numerator < denominator).\n *\n * @returns Canonicalized Epoch with a non-negative, reduced fractional part and integer adjusted accordingly.\n */\n normalizeCanonical(): Epoch {\n let { integer, numerator, denominator } = this.normalizeBase();\n\n // If numerator is negative, borrow enough whole denominators from integer so numerator >= 0.\n if (numerator < Zero) {\n // n is the minimal non-negative integer such that numerator + n * denominator >= 0\n const n = (-numerator + denominator - 1n) / denominator;\n integer -= n;\n numerator += denominator * n;\n }\n\n // Reduce the fractional part to lowest terms to keep canonical form and avoid unnecessarily large multiples.\n const g = gcd(numerator, denominator);\n numerator /= g;\n denominator /= g;\n\n // Move any full units contained in the fraction into integer (e.g., 5/2 => +2 integer, remainder 1/2).\n integer += numerator / denominator;\n\n // Remainder numerator after removing whole units; ensures numerator < denominator.\n numerator %= denominator;\n\n return new Epoch(integer, numerator, denominator);\n }\n\n /**\n * Backwards-compatible array-style index 0 referencing the whole epoch integer.\n *\n * @returns integer portion (Num)\n * @deprecated Use `.integer` property instead.\n */\n get 0(): Num {\n return this.integer;\n }\n\n /**\n * Backwards-compatible array-style index 1 referencing the epoch fractional numerator.\n *\n * @returns numerator portion (Num)\n * @deprecated Use `.numerator` property instead.\n */\n get 1(): Num {\n return this.numerator;\n }\n\n /**\n * Backwards-compatible array-style index 2 referencing the epoch fractional denominator.\n *\n * @returns denominator portion (Num)\n * @deprecated Use `.denominator` property instead.\n */\n get 2(): Num {\n return this.denominator;\n }\n\n /**\n * Convert this Epoch into its RPC-style packed numeric representation (Num).\n *\n * Packing layout (little-endian style fields):\n * - integer: lower 24 bits\n * - numerator: next 16 bits\n * - denominator: next 16 bits\n *\n * Throws if any component is negative since packed representation assumes non-negative components.\n *\n * @throws {Error} If integer, numerator or denominator are negative.\n * @throws {Error} If integer, numerator or denominator overflow the packing limits.\n * @returns Packed numeric representation (Num) suitable for RPC packing.\n */\n toNum(): Num {\n if (\n this.integer < Zero ||\n this.numerator < Zero ||\n this.denominator < Zero\n ) {\n throw Error(\"Negative values in Epoch to Num conversion\");\n }\n\n if (\n this.integer >= numFrom(\"0x1000000\") || // 24-bit limit\n this.numerator >= numFrom(\"0x10000\") || // 16-bit limit\n this.denominator >= numFrom(\"0x10000\") // 16-bit limit\n ) {\n throw Error(\n \"Integer must be < 2^24, numerator and denominator must be < 2^16\",\n );\n }\n\n return (\n this.integer +\n (this.numerator << numFrom(24)) +\n (this.denominator << numFrom(40))\n );\n }\n\n /**\n * Convert epoch to hex string representation of the RPC-style packed numeric form.\n *\n * Returns the same representation used by CKB RPC responses where the\n * packed numeric bytes may be trimmed of leading zeros, see {@link numToHex}\n *\n * @returns Hex string corresponding to the packed epoch.\n */\n toPackedHex(): Hex {\n return numToHex(this.toNum());\n }\n\n /**\n * Construct an Epoch by unpacking a RPC-style packed numeric form.\n *\n * @param v - NumLike packed epoch (like Num and Hex)\n * @returns Epoch whose integer, numerator and denominator are extracted from the packed layout.\n */\n static fromNum(v: NumLike): Epoch {\n const num = numFrom(v);\n\n return new Epoch(\n num & numFrom(\"0xffffff\"),\n (num >> numFrom(24)) & numFrom(\"0xffff\"),\n (num >> numFrom(40)) & numFrom(\"0xffff\"),\n );\n }\n\n /**\n * Create an Epoch from an EpochLike value.\n *\n * Accepts:\n * - an Epoch instance (returned as-is)\n * - an array [integer, numerator, denominator] where each element is NumLike\n * - an object { integer, numerator, denominator } where each field is NumLike\n * - a packed numeric-like value handled by fromNum\n *\n * All numeric-like inputs are converted with numFrom() to produce internal Num values.\n *\n * @param e - Value convertible to Epoch\n * @returns Epoch instance\n */\n static override from(e: EpochLike): Epoch {\n if (e instanceof Epoch) {\n return e;\n }\n\n if (Array.isArray(e)) {\n return new Epoch(numFrom(e[0]), numFrom(e[1]), numFrom(e[2]));\n }\n\n if (typeof e === \"object\") {\n return new Epoch(\n numFrom(e.integer),\n numFrom(e.numerator),\n numFrom(e.denominator),\n );\n }\n\n return Epoch.fromNum(e);\n }\n\n /**\n * Return a deep copy of this Epoch.\n *\n * @returns New Epoch instance with identical components.\n */\n override clone(): Epoch {\n return new Epoch(this.integer, this.numerator, this.denominator);\n }\n\n /**\n * Return the genesis epoch.\n *\n * Note: for historical reasons the genesis epoch is represented with all-zero\n * fields, no other epoch instance should use a zero denominator.\n *\n * @returns Epoch with integer = 0, numerator = 0, denominator = 0.\n */\n static get Genesis(): Epoch {\n return new Epoch(Zero, Zero, Zero);\n }\n\n /**\n * Return an Epoch representing one Nervos DAO cycle (180 epochs exactly).\n *\n * @returns Epoch equal to 180 with denominator set to 1 to represent an exact whole unit.\n */\n static get OneNervosDaoCycle(): Epoch {\n return new Epoch(numFrom(180), Zero, numFrom(1));\n }\n\n /**\n * Compare this epoch to another EpochLike.\n *\n * The comparison computes scaled integer values so fractions are compared without precision loss:\n * scaled = (integer * denominator + numerator) * other.denominator\n *\n * Special-case: identical object references return equality immediately.\n *\n * @param other - Epoch-like value to compare against.\n * @returns 1 if this > other, 0 if equal, -1 if this < other.\n *\n * @example\n * epochA.compare(epochB); // -1|0|1\n */\n compare(other: EpochLike): 1 | 0 | -1 {\n if (this === other) {\n return 0;\n }\n\n const t = this.normalizeBase();\n const o = Epoch.from(other).normalizeBase();\n\n // Compute scaled representations to compare fractions without floating-point arithmetic.\n const a = (t.integer * t.denominator + t.numerator) * o.denominator;\n const b = (o.integer * o.denominator + o.numerator) * t.denominator;\n\n return a > b ? 1 : a < b ? -1 : 0;\n }\n\n /**\n * Check whether this epoch is less than another EpochLike.\n *\n * @param other - EpochLike to compare against.\n * @returns true if this < other.\n */\n lt(other: EpochLike): boolean {\n return this.compare(other) < 0;\n }\n\n /**\n * Check whether this epoch is less than or equal to another EpochLike.\n *\n * @param other - EpochLike to compare against.\n * @returns true if this <= other.\n */\n le(other: EpochLike): boolean {\n return this.compare(other) <= 0;\n }\n\n /**\n * Check whether this epoch equals another EpochLike.\n *\n * @param other - EpochLike to compare against.\n * @returns true if equal.\n */\n eq(other: EpochLike): boolean {\n return this.compare(other) === 0;\n }\n\n /**\n * Check whether this epoch is greater than or equal to another EpochLike.\n *\n * @param other - EpochLike to compare against.\n * @returns true if this >= other.\n */\n ge(other: EpochLike): boolean {\n return this.compare(other) >= 0;\n }\n\n /**\n * Check whether this epoch is greater than another EpochLike.\n *\n * @param other - EpochLike to compare against.\n * @returns true if this > other.\n */\n gt(other: EpochLike): boolean {\n return this.compare(other) > 0;\n }\n\n /**\n * Add another EpochLike to this epoch and return the normalized result.\n *\n * Rules and edge-cases:\n * - Whole parts are added directly; fractional parts are aligned to a common denominator and added.\n * - Final result is canonicalized to reduce the fraction and carry any overflow to the integer part.\n *\n * @param other - Epoch-like value to add.\n * @returns Normalized Epoch representing the sum.\n */\n add(other: EpochLike): Epoch {\n const t = this.normalizeBase();\n const o = Epoch.from(other).normalizeBase();\n\n // Sum whole integer parts.\n const integer = t.integer + o.integer;\n let numerator: Num;\n let denominator: Num;\n\n // Align denominators if they differ; use multiplication to obtain a common denominator.\n if (t.denominator !== o.denominator) {\n // Numerators & Denominators are generally small (<= 2000n); multiplication produces a safe common denominator.\n numerator = t.numerator * o.denominator + o.numerator * t.denominator;\n denominator = t.denominator * o.denominator;\n } else {\n numerator = t.numerator + o.numerator;\n denominator = t.denominator;\n }\n\n // Normalize to reduce fraction and carry whole units into integer.\n return new Epoch(integer, numerator, denominator).normalizeCanonical();\n }\n\n /**\n * Subtract an EpochLike from this epoch and return the normalized result.\n *\n * Implementation notes:\n * - Delegates to add by negating the other epoch's integer and numerator while preserving denominator.\n * - normalizeCanonical will handle negative numerators by borrowing from integer as necessary.\n *\n * @param other - Epoch-like value to subtract.\n * @returns Normalized Epoch representing this - other.\n */\n sub(other: EpochLike): Epoch {\n const { integer, numerator, denominator } = Epoch.from(other);\n return this.add(new Epoch(-integer, -numerator, denominator));\n }\n\n /**\n * Convert this epoch to an estimated Unix timestamp in milliseconds using a reference header.\n *\n * Note: This is an estimation that assumes a constant epoch duration.\n *\n * @param reference - Object providing `epoch` (Epoch) and `timestamp` (Num) fields, such as a ClientBlockHeader.\n * @param epochInMilliseconds - Duration of a single epoch in milliseconds. Defaults to 4 hours.\n * @returns Estimated Unix timestamp in milliseconds as bigint.\n */\n toUnix(\n reference: Pick<ClientBlockHeader, \"epoch\" | \"timestamp\">,\n epochInMilliseconds: Num = numFrom(4 * 60 * 60 * 1000),\n ): bigint {\n // Compute relative epoch difference against the reference header.\n const { integer, numerator, denominator } = this.sub(reference.epoch);\n\n // Add whole epoch duration and fractional epoch duration to the reference timestamp.\n return (\n reference.timestamp +\n epochInMilliseconds * integer +\n (epochInMilliseconds * numerator) / denominator\n );\n }\n}\n\n/**\n * epochFrom\n *\n * @deprecated prefer using Epoch.from() directly.\n *\n * @param epochLike - Epoch-like value to convert.\n * @returns Epoch instance corresponding to the input.\n */\nexport function epochFrom(epochLike: EpochLike): Epoch {\n return Epoch.from(epochLike);\n}\n\n/**\n * epochFromHex\n *\n * @deprecated use Epoch.fromNum() with numeric input instead.\n *\n * @param hex - Hex-like or numeric-like value encoding a packed epoch.\n * @returns Decoded Epoch instance.\n */\nexport function epochFromHex(hex: HexLike): Epoch {\n return Epoch.fromNum(hex);\n}\n\n/**\n * epochToHex\n *\n * @deprecated use Epoch.from(epochLike).toPackedHex() instead.\n *\n * @param epochLike - Value convertible to an Epoch (object, tuple or Epoch).\n * @returns Hex string representing the packed epoch encoding.\n */\nexport function epochToHex(epochLike: EpochLike): Hex {\n return Epoch.from(epochLike).toPackedHex();\n}\n","import { ScriptLike } from \"../ckb/index.js\";\nimport { HexLike } from \"../hex/index.js\";\nimport { Num, numFrom, NumLike } from \"../num/index.js\";\n\nexport const DEFAULT_MAX_FEE_RATE = numFrom(10000000);\nexport const DEFAULT_MIN_FEE_RATE = numFrom(1000);\n\nexport function clientSearchKeyRangeFrom([a, b]: [NumLike, NumLike]): [\n Num,\n Num,\n] {\n return [numFrom(a), numFrom(b)];\n}\n\nexport type ClientCollectableSearchKeyFilterLike = {\n script?: ScriptLike | null;\n scriptLenRange?: [NumLike, NumLike] | null;\n outputData?: HexLike | null;\n outputDataSearchMode?: \"prefix\" | \"exact\" | \"partial\" | null;\n outputDataLenRange?: [NumLike, NumLike] | null;\n outputCapacityRange?: [NumLike, NumLike] | null;\n};\nexport type ClientCollectableSearchKeyLike = {\n script: ScriptLike;\n scriptType: \"lock\" | \"type\";\n scriptSearchMode: \"prefix\" | \"exact\" | \"partial\";\n filter?: ClientCollectableSearchKeyFilterLike | null;\n withData?: boolean | null;\n};\n","import {\n Cell,\n CellDep,\n CellDepLike,\n Epoch,\n EpochLike,\n HashType,\n HashTypeLike,\n OutPoint,\n OutPointLike,\n Script,\n ScriptLike,\n Transaction,\n TransactionLike,\n hashTypeFrom,\n} from \"../ckb/index.js\";\nimport { Hex, HexLike, hexFrom } from \"../hex/index.js\";\nimport { Num, NumLike, numFrom } from \"../num/index.js\";\nimport { apply } from \"../utils/index.js\";\nimport {\n ClientCollectableSearchKeyFilterLike,\n ClientCollectableSearchKeyLike,\n clientSearchKeyRangeFrom,\n} from \"./clientTypes.advanced.js\";\n\n/**\n * @public\n */\nexport type CellDepInfoLike = {\n cellDep: CellDepLike;\n type?: ScriptLike | null;\n};\n\n/**\n * @public\n */\nexport class CellDepInfo {\n constructor(\n public cellDep: CellDep,\n public type?: Script,\n ) {}\n\n static from(cellDepInfoLike: CellDepInfoLike): CellDepInfo {\n if (cellDepInfoLike instanceof CellDepInfo) {\n return cellDepInfoLike;\n }\n\n return new CellDepInfo(\n CellDep.from(cellDepInfoLike.cellDep),\n apply(Script.from, cellDepInfoLike.type),\n );\n }\n}\n\n/**\n * @public\n */\nexport type ScriptInfoLike = {\n codeHash: HexLike;\n hashType: HashTypeLike;\n cellDeps: CellDepInfoLike[];\n};\n\n/**\n * @public\n */\nexport class ScriptInfo {\n constructor(\n public codeHash: Hex,\n public hashType: HashType,\n public cellDeps: CellDepInfo[],\n ) {}\n\n static from(scriptInfoLike: ScriptInfoLike): ScriptInfo {\n if (scriptInfoLike instanceof ScriptInfo) {\n return scriptInfoLike;\n }\n\n return new ScriptInfo(\n hexFrom(scriptInfoLike.codeHash),\n hashTypeFrom(scriptInfoLike.hashType),\n scriptInfoLike.cellDeps.map((c) => CellDepInfo.from(c)),\n );\n }\n}\n\n/**\n * @public\n */\nexport type OutputsValidator = \"passthrough\" | \"well_known_scripts_only\";\n\n/**\n * @public\n */\nexport type TransactionStatus =\n | \"sent\"\n | \"pending\"\n | \"proposed\"\n | \"committed\"\n | \"unknown\"\n | \"rejected\";\n/**\n * @public\n */\nexport type ClientTransactionResponseLike = {\n transaction: TransactionLike;\n status: TransactionStatus;\n cycles?: NumLike;\n blockHash?: HexLike;\n blockNumber?: NumLike;\n txIndex?: NumLike;\n reason?: string;\n};\n/**\n * @public\n */\nexport class ClientTransactionResponse {\n constructor(\n public transaction: Transaction,\n public status: TransactionStatus,\n public cycles?: Num,\n public blockHash?: Hex,\n public blockNumber?: Num,\n public txIndex?: Num,\n public reason?: string,\n ) {}\n\n static from(\n responseLike: ClientTransactionResponseLike,\n ): ClientTransactionResponse {\n if (responseLike instanceof ClientTransactionResponse) {\n return responseLike;\n }\n\n return new ClientTransactionResponse(\n Transaction.from(responseLike.transaction),\n responseLike.status,\n apply(numFrom, responseLike.cycles),\n apply(hexFrom, responseLike.blockHash),\n apply(numFrom, responseLike.blockNumber),\n apply(numFrom, responseLike.txIndex),\n responseLike.reason,\n );\n }\n\n clone() {\n return new ClientTransactionResponse(\n this.transaction.clone(),\n this.status,\n this.cycles,\n this.blockHash,\n this.blockNumber,\n this.txIndex,\n this.reason,\n );\n }\n}\n\n/**\n * @public\n */\nexport type ClientIndexerSearchKeyFilterLike =\n ClientCollectableSearchKeyFilterLike & {\n blockRange?: [NumLike, NumLike] | null;\n };\n/**\n * @public\n */\nexport class ClientIndexerSearchKeyFilter {\n constructor(\n public script: Script | undefined,\n public scriptLenRange: [Num, Num] | undefined,\n public outputData: Hex | undefined,\n public outputDataSearchMode: \"prefix\" | \"exact\" | \"partial\" | undefined,\n public outputDataLenRange: [Num, Num] | undefined,\n public outputCapacityRange: [Num, Num] | undefined,\n public blockRange: [Num, Num] | undefined,\n ) {}\n\n static from(\n filterLike: ClientIndexerSearchKeyFilterLike,\n ): ClientIndexerSearchKeyFilter {\n if (filterLike instanceof ClientIndexerSearchKeyFilter) {\n return filterLike;\n }\n\n return new ClientIndexerSearchKeyFilter(\n apply(Script.from, filterLike.script),\n apply(clientSearchKeyRangeFrom, filterLike.scriptLenRange),\n apply(hexFrom, filterLike.outputData),\n filterLike.outputDataSearchMode ?? undefined,\n apply(clientSearchKeyRangeFrom, filterLike.outputDataLenRange),\n apply(clientSearchKeyRangeFrom, filterLike.outputCapacityRange),\n apply(clientSearchKeyRangeFrom, filterLike.blockRange),\n );\n }\n}\n\n/**\n * @public\n */\nexport type ClientIndexerSearchKeyLike = ClientCollectableSearchKeyLike & {\n filter?: ClientIndexerSearchKeyFilterLike | null;\n};\n\n/**\n * @public\n */\nexport class ClientIndexerSearchKey {\n constructor(\n public script: Script,\n public scriptType: \"lock\" | \"type\",\n public scriptSearchMode: \"prefix\" | \"exact\" | \"partial\",\n public filter: ClientIndexerSearchKeyFilter | undefined,\n public withData: boolean | undefined,\n ) {}\n\n static from(keyLike: ClientIndexerSearchKeyLike): ClientIndexerSearchKey {\n if (keyLike instanceof ClientIndexerSearchKey) {\n return keyLike;\n }\n\n return new ClientIndexerSearchKey(\n Script.from(keyLike.script),\n keyLike.scriptType,\n keyLike.scriptSearchMode,\n apply(ClientIndexerSearchKeyFilter.from, keyLike.filter),\n keyLike.withData ?? undefined,\n );\n }\n}\n\n/**\n * @public\n */\nexport type ClientFindCellsResponse = {\n lastCursor: string;\n cells: Cell[];\n};\n\n/**\n * @public\n */\nexport type ClientIndexerSearchKeyTransactionLike = Omit<\n ClientCollectableSearchKeyLike,\n \"withData\"\n> & {\n filter?: ClientIndexerSearchKeyFilterLike | null;\n groupByTransaction?: boolean | null;\n};\n\n/**\n * @public\n */\nexport class ClientIndexerSearchKeyTransaction {\n constructor(\n public script: Script,\n public scriptType: \"lock\" | \"type\",\n public scriptSearchMode: \"prefix\" | \"exact\" | \"partial\",\n public filter: ClientIndexerSearchKeyFilter | undefined,\n public groupByTransaction: boolean | undefined,\n ) {}\n\n static from(\n keyLike: ClientIndexerSearchKeyTransactionLike,\n ): ClientIndexerSearchKeyTransaction {\n if (keyLike instanceof ClientIndexerSearchKeyTransaction) {\n return keyLike;\n }\n\n return new ClientIndexerSearchKeyTransaction(\n Script.from(keyLike.script),\n keyLike.scriptType,\n keyLike.scriptSearchMode,\n apply(ClientIndexerSearchKeyFilter.from, keyLike.filter),\n keyLike.groupByTransaction ?? undefined,\n );\n }\n}\n\n/**\n * @public\n */\nexport type ClientFindTransactionsResponse = {\n lastCursor: string;\n transactions: {\n txHash: Hex;\n blockNumber: Num;\n txIndex: Num;\n isInput: boolean;\n cellIndex: Num;\n }[];\n};\n\n/**\n * @public\n */\nexport type ClientFindTransactionsGroupedResponse = {\n lastCursor: string;\n transactions: {\n txHash: Hex;\n blockNumber: Num;\n txIndex: Num;\n cells: {\n isInput: boolean;\n cellIndex: Num;\n }[];\n }[];\n};\n\n/**\n * @public\n */\nexport type ClientBlockHeaderLike = {\n compactTarget: NumLike;\n dao: {\n /**\n * C_i: the total issuance up to and including block i.\n */\n c: NumLike;\n /**\n * AR_i: the current accumulated rate at block i.\n * AR_j / AR_i reflects the CKByte amount if one deposit 1 CKB to Nervos DAO at block i, and withdraw at block j.\n */\n ar: NumLike;\n /**\n * S_i: the total unissued secondary issuance up to and including block i,\n * including unclaimed Nervos DAO compensation and treasury funds.\n */\n s: NumLike;\n /**\n * U_i: the total occupied capacities currently in the blockchain up to and including block i.\n * Occupied capacity is the sum of capacities used to store all cells.\n */\n u: NumLike;\n };\n epoch: EpochLike;\n extraHash: HexLike;\n hash: HexLike;\n nonce: NumLike;\n number: NumLike;\n parentHash: HexLike;\n proposalsHash: HexLike;\n timestamp: NumLike;\n transactionsRoot: HexLike;\n version: NumLike;\n};\n/**\n * @public\n */\nexport class ClientBlockHeader {\n constructor(\n public compactTarget: Num,\n public dao: {\n /**\n * C_i: the total issuance up to and including block i.\n */\n c: Num;\n /**\n * AR_i: the current accumulated rate at block i.\n * AR_j / AR_i reflects the CKByte amount if one deposit 1 CKB to Nervos DAO at block i, and withdraw at block j.\n */\n ar: Num;\n /**\n * S_i: the total unissued secondary issuance up to and including block i,\n * including unclaimed Nervos DAO compensation and treasury funds.\n */\n s: Num;\n /**\n * U_i: the total occupied capacities currently in the blockchain up to and including block i.\n * Occupied capacity is the sum of capacities used to store all cells.\n */\n u: Num;\n },\n public epoch: Epoch,\n public extraHash: Hex,\n public hash: Hex,\n public nonce: Num,\n public number: Num,\n public parentHash: Hex,\n public proposalsHash: Hex,\n public timestamp: Num,\n public transactionsRoot: Hex,\n public version: Num,\n ) {}\n\n static from(headerLike: ClientBlockHeaderLike): ClientBlockHeader {\n if (headerLike instanceof ClientBlockHeader) {\n return headerLike;\n }\n\n return new ClientBlockHeader(\n numFrom(headerLike.compactTarget),\n {\n c: numFrom(headerLike.dao.c),\n ar: numFrom(headerLike.dao.ar),\n s: numFrom(headerLike.dao.s),\n u: numFrom(headerLike.dao.u),\n },\n Epoch.from(headerLike.epoch),\n hexFrom(headerLike.extraHash),\n hexFrom(headerLike.hash),\n numFrom(headerLike.nonce),\n numFrom(headerLike.number),\n hexFrom(headerLike.parentHash),\n hexFrom(headerLike.proposalsHash),\n numFrom(headerLike.timestamp),\n hexFrom(headerLike.transactionsRoot),\n numFrom(headerLike.version),\n );\n }\n}\n\n/**\n * @public\n */\nexport type ClientBlockUncleLike = {\n header: ClientBlockHeaderLike;\n proposals: HexLike[];\n};\n/**\n * @public\n */\nexport class ClientBlockUncle {\n constructor(\n public header: ClientBlockHeader,\n public proposals: Hex[],\n ) {}\n\n static from(uncleLike: ClientBlockUncleLike): ClientBlockUncle {\n if (uncleLike instanceof ClientBlockUncle) {\n return uncleLike;\n }\n\n return new ClientBlockUncle(\n ClientBlockHeader.from(uncleLike.header),\n uncleLike.proposals.map(hexFrom),\n );\n }\n}\n\n/**\n * @public\n */\nexport type ClientBlockLike = {\n header: ClientBlockHeaderLike;\n proposals: HexLike[];\n transactions: TransactionLike[];\n uncles: ClientBlockUncleLike[];\n};\n/**\n * @public\n */\nexport class ClientBlock {\n constructor(\n public header: ClientBlockHeader,\n public proposals: Hex[],\n public transactions: Transaction[],\n public uncles: ClientBlockUncle[],\n ) {}\n\n static from(blockLike: ClientBlockLike): ClientBlock {\n if (blockLike instanceof ClientBlock) {\n return blockLike;\n }\n\n return new ClientBlock(\n ClientBlockHeader.from(blockLike.header),\n blockLike.proposals.map(hexFrom),\n blockLike.transactions.map(Transaction.from),\n blockLike.uncles.map(ClientBlockUncle.from),\n );\n }\n}\n\nexport interface ErrorClientBaseLike {\n message?: string;\n code?: number;\n data: string;\n}\nexport class ErrorClientBase extends Error {\n public readonly code?: number;\n public readonly data: string;\n\n constructor(origin: ErrorClientBaseLike) {\n super(`Client request error ${origin.message}`);\n this.code = origin.code;\n this.data = origin.data;\n }\n}\n\nexport class ErrorClientResolveUnknown extends ErrorClientBase {\n public readonly outPoint: OutPoint;\n constructor(origin: ErrorClientBaseLike, outPointLike: OutPointLike) {\n super(origin);\n this.outPoint = OutPoint.from(outPointLike);\n }\n}\n\nexport class ErrorClientVerification extends ErrorClientBase {\n public readonly sourceIndex: Num;\n public readonly scriptCodeHash: Hex;\n\n constructor(\n origin: ErrorClientBaseLike,\n public readonly source: \"lock\" | \"inputType\" | \"outputType\",\n sourceIndex: NumLike,\n public readonly errorCode: number,\n public readonly scriptHashType: \"data\" | \"type\",\n scriptCodeHash: HexLike,\n ) {\n super(origin);\n this.sourceIndex = numFrom(sourceIndex);\n this.scriptCodeHash = hexFrom(scriptCodeHash);\n }\n}\n\nexport class ErrorClientDuplicatedTransaction extends ErrorClientBase {\n public readonly txHash: Hex;\n\n constructor(origin: ErrorClientBaseLike, txHash: HexLike) {\n super(origin);\n this.txHash = hexFrom(txHash);\n }\n}\n\nexport class ErrorClientRBFRejected extends ErrorClientBase {\n public readonly currentFee: Num;\n public readonly leastFee: Num;\n\n constructor(\n origin: ErrorClientBaseLike,\n currentFee: NumLike,\n leastFee: NumLike,\n ) {\n super(origin);\n this.currentFee = numFrom(currentFee);\n this.leastFee = numFrom(leastFee);\n }\n}\n\nexport class ErrorClientWaitTransactionTimeout extends ErrorClientBase {\n constructor(timeoutLike: NumLike) {\n const timeout = numFrom(timeoutLike).toString();\n super({\n message: `Wait transaction timeout ${timeout}ms`,\n data: JSON.stringify({ timeout }),\n });\n }\n}\n\nexport class ErrorClientMaxFeeRateExceeded extends ErrorClientBase {\n constructor(limitLike: NumLike, actualLike: NumLike) {\n const limit = numFrom(limitLike).toString();\n const actual = numFrom(actualLike).toString();\n super({\n message: `Max fee rate exceeded limit ${limit}, actual ${actual}. Developer might forgot to complete transaction fee before sending. See https://api.ckbccc.com/classes/_ckb_ccc_core.index.ccc.Transaction.html#completeFeeBy.`,\n data: JSON.stringify({ limit, actual }),\n });\n }\n}\n","import { bytesFrom } from \"../../bytes/index.js\";\nimport { Cell, CellLike, Script, ScriptLike } from \"../../ckb/index.js\";\nimport { HexLike, hexFrom } from \"../../hex/index.js\";\nimport { NumLike, numFrom } from \"../../num/index.js\";\nimport {\n ClientCollectableSearchKeyLike,\n clientSearchKeyRangeFrom,\n} from \"../clientTypes.advanced.js\";\nimport { ClientIndexerSearchKey } from \"../clientTypes.js\";\n\nexport const DEFAULT_CONFIRMED_BLOCK_TIME = numFrom(1000 * 10 * 50); // 50 blocks * 10s\n\n// [isLive, Cell | OutPoint]\nexport type CellRecord =\n | [\n false,\n Pick<Cell, \"outPoint\"> & Partial<Pick<Cell, \"cellOutput\" | \"outputData\">>,\n ]\n | [true, Cell]\n | [undefined, Cell];\n\nexport function filterData(\n dataLike: HexLike,\n filterLike: HexLike | undefined,\n filterMode: \"exact\" | \"prefix\" | \"partial\",\n): boolean {\n if (!filterLike) {\n return true;\n }\n\n const data = hexFrom(dataLike);\n const filter = hexFrom(filterLike);\n if (\n (filterMode === \"exact\" && data !== filter) ||\n (filterMode === \"prefix\" && !data.startsWith(filter)) ||\n (filterMode === \"partial\" && data.search(filter) === -1)\n ) {\n return false;\n }\n\n return true;\n}\n\nexport function filterScript(\n valueLike: ScriptLike | undefined,\n filterLike: ScriptLike | undefined,\n filterMode: \"prefix\" | \"exact\" | \"partial\",\n): boolean {\n if (!filterLike) {\n return true;\n }\n if (!valueLike) {\n return false;\n }\n\n const value = Script.from(valueLike);\n const filter = Script.from(filterLike);\n if (\n value.codeHash !== filter.codeHash ||\n value.hashType !== filter.hashType\n ) {\n return false;\n }\n\n return filterData(value.args, filter?.args, filterMode);\n}\n\nexport function filterNumByRange(\n lengthLike: NumLike,\n range: [NumLike, NumLike] | undefined,\n): boolean {\n if (!range) {\n return true;\n }\n const length = numFrom(lengthLike);\n const [lower, upper] = clientSearchKeyRangeFrom(range);\n\n return lower <= length && length < upper;\n}\n\nexport function filterScriptByLenRange(\n valueLike?: ScriptLike,\n scriptLenRange?: [NumLike, NumLike],\n): boolean {\n if (!scriptLenRange) {\n return true;\n }\n\n const len = (() => {\n if (!valueLike) {\n return 0;\n }\n return bytesFrom(Script.from(valueLike).args).length + 33;\n })();\n return filterNumByRange(len, scriptLenRange);\n}\n\nexport function filterCell(\n searchKeyLike: ClientCollectableSearchKeyLike,\n cellLike: CellLike,\n): boolean {\n const key = ClientIndexerSearchKey.from(searchKeyLike);\n const cell = Cell.from(cellLike);\n\n if (key.scriptType === \"lock\") {\n if (\n !filterScript(cell.cellOutput.lock, key.script, key.scriptSearchMode) ||\n !filterScript(cell.cellOutput.type, key.filter?.script, \"prefix\") ||\n !filterScriptByLenRange(cell.cellOutput.type, key.filter?.scriptLenRange)\n ) {\n return false;\n }\n }\n if (key.scriptType === \"type\") {\n if (\n !filterScript(cell.cellOutput.type, key.script, key.scriptSearchMode) ||\n !filterScript(cell.cellOutput.lock, key.filter?.script, \"prefix\") ||\n !filterScriptByLenRange(cell.cellOutput.lock, key.filter?.scriptLenRange)\n ) {\n return false;\n }\n }\n\n if (\n !filterData(\n cell.outputData,\n key.filter?.outputData,\n key.filter?.outputDataSearchMode ?? \"prefix\",\n ) ||\n !filterNumByRange(\n bytesFrom(cell.outputData).length,\n key.filter?.outputDataLenRange,\n )\n ) {\n return false;\n }\n\n if (\n !filterNumByRange(cell.cellOutput.capacity, key.filter?.outputCapacityRange)\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * A Map-like class that implements a \"Least Recently Used\" (LRU) cache policy.\n * When the cache reaches its capacity, the least recently used item is removed.\n * @public\n */\nexport class MapLru<K, V> extends Map<K, V> {\n private readonly lru: Set<K> = new Set<K>();\n\n /**\n * @param capacity - The maximum number of items to store in the cache. Must be a positive integer.\n */\n constructor(private readonly capacity: number) {\n super();\n\n if (!Number.isInteger(capacity) || capacity < 1) {\n throw new Error(\"Capacity must be a positive integer\");\n }\n }\n\n /**\n * Retrieves the value for a given key and marks it as recently used.\n * @param key - The key of the element to retrieve.\n * @returns The value associated with the key, or `undefined` if the key is not in the cache.\n */\n override get(key: K) {\n if (!super.has(key)) {\n return;\n }\n\n this.lru.delete(key);\n this.lru.add(key);\n\n return super.get(key);\n }\n\n /**\n * Adds or updates a key-value pair in the cache and marks the key as recently used.\n * If setting a new key causes the cache to exceed its capacity, the least recently used item is evicted.\n * @param key - The key of the element to add or update.\n * @param value - The value of the element to add or update.\n * @returns The `MapLru` instance.\n */\n override set(key: K, value: V) {\n super.set(key, value);\n\n this.lru.delete(key);\n this.lru.add(key);\n\n // Evict the oldest entry if capacity is exceeded.\n if (this.lru.size > this.capacity) {\n const oldestKey = this.lru.keys().next().value!;\n this.delete(oldestKey);\n }\n return this;\n }\n\n /**\n * Removes the specified element from the cache.\n * @param key - The key of the element to remove.\n * @returns `true` if an element in the `MapLru` object existed and has been removed, or `false` if the element does not exist.\n */\n override delete(key: K): boolean {\n if (!super.delete(key)) {\n return false;\n }\n\n this.lru.delete(key);\n return true;\n }\n\n /**\n * Removes all key-value pairs from the cache.\n */\n override clear() {\n super.clear();\n this.lru.clear();\n }\n}\n","/**\n * @public\n */\nexport enum KnownScript {\n NervosDao = \"NervosDao\",\n Secp256k1Blake160 = \"Secp256k1Blake160\",\n Secp256k1Multisig = \"Secp256k1Multisig\",\n Secp256k1MultisigV2 = \"Secp256k1MultisigV2\", // Enhanced since handling (https://github.com/nervosnetwork/ckb-system-scripts/pull/99)\n AnyoneCanPay = \"AnyoneCanPay\",\n TypeId = \"TypeId\",\n XUdt = \"XUdt\",\n JoyId = \"JoyId\",\n COTA = \"COTA\",\n PWLock = \"PWLock\",\n OmniLock = \"OmniLock\",\n NostrLock = \"NostrLock\",\n UniqueType = \"UniqueType\",\n DidCkb = \"DidCkb\",\n\n // ckb-proxy-locks https://github.com/ckb-devrel/ckb-proxy-locks\n AlwaysSuccess = \"AlwaysSuccess\",\n InputTypeProxyLock = \"InputTypeProxyLock\",\n OutputTypeProxyLock = \"OutputTypeProxyLock\",\n LockProxyLock = \"LockProxyLock\",\n SingleUseLock = \"SingleUseLock\",\n TypeBurnLock = \"TypeBurnLock\",\n EasyToDiscoverType = \"EasyToDiscoverType\",\n TimeLock = \"TimeLock\",\n}\n","import { ScriptInfoLike } from \"./clientTypes.js\";\nimport { KnownScript } from \"./knownScript.js\";\n\nexport const MAINNET_SCRIPTS: Record<KnownScript, ScriptInfoLike | undefined> =\n Object.freeze({\n [KnownScript.NervosDao]: {\n codeHash:\n \"0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xe2fb199810d49a4d8beec56718ba2593b665db9d52299a0f9e6e75416d73ff5c\",\n index: 2,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.Secp256k1Blake160]: {\n codeHash:\n \"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.Secp256k1Multisig]: {\n codeHash:\n \"0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c\",\n index: 1,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.Secp256k1MultisigV2]: {\n codeHash:\n \"0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x6888aa39ab30c570c2c30d9d5684d3769bf77265a7973211a3c087fe8efbf738\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.AnyoneCanPay]: {\n codeHash:\n \"0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x4153a2014952d7cac45f285ce9a7c5c0c0e1b21f2d378b82ac1433cb11c25c4d\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.TypeId]: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n cellDeps: [],\n },\n [KnownScript.XUdt]: {\n codeHash:\n \"0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xc07844ce21b38e4b071dd0e1ee3b0e27afd8d7532491327f39b786343f558ab7\",\n index: 0,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.JoyId]: {\n codeHash:\n \"0xd00c84f0ec8fd441c38bc3f87a371f547190f2fcff88e642bc5bf54b9e318323\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x8a605a4402cadda69fa64fd25cbbd74058e3eb86a7a72aee3d25df278564d31b\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x2d1f2d4d1514ccc3bb4f04f5437a5ae30d00636ee57cedd2c70ab3ea75b62adc\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x8a605a4402cadda69fa64fd25cbbd74058e3eb86a7a72aee3d25df278564d31b\",\n index: 1,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0xc086090432098835ec542a1b94bdd1b842c5aa1ccd1616873fe77f4a04044417\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x8a605a4402cadda69fa64fd25cbbd74058e3eb86a7a72aee3d25df278564d31b\",\n index: 2,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x165b225c6fbed7e655b024384d9083de3243375f9893706f4452858ecd694e96\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x8a605a4402cadda69fa64fd25cbbd74058e3eb86a7a72aee3d25df278564d31b\",\n index: 3,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0xafb8408d0094ab944e6286aac750b9bb854ac0bcb66dfe5c60559744a700e70c\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x8a605a4402cadda69fa64fd25cbbd74058e3eb86a7a72aee3d25df278564d31b\",\n index: 4,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x773bf0647be24b4e18ef44068fd069b9de5549c4b86be227779ceb9179598ec4\",\n },\n },\n ],\n },\n [KnownScript.COTA]: {\n codeHash:\n \"0x1122a4fb54697cf2e6e3a96c9d80fd398a936559b90954c6e88eb7ba0cf652df\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xabaa25237554f0d6c586dc010e7e85e6870bcfd9fb8773257ecacfbe1fd738a0\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.PWLock]: {\n codeHash:\n \"0xbf43c3602455798c1a61a596e0d95278864c552fafe231c063b3fabf97a8febc\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x1d60cb8f4666e039f418ea94730b1a8c5aa0bf2f7781474406387462924d15d4\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x42ade2f25eb938b5dbfd3d8f07b8b07aa593d848e7ff14bdfbbea5aeb6175261\",\n },\n },\n ],\n },\n [KnownScript.OmniLock]: {\n codeHash:\n \"0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xc76edf469816aa22f416503c38d0b533d2a018e253e379f134c3985b3472c842\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x855508fe0f0ca25b935b070452ecaee48f6c9f1d66cd15f046616b99e948236a\",\n },\n },\n ],\n },\n [KnownScript.NostrLock]: {\n codeHash:\n \"0x641a89ad2f77721b803cd50d01351c1f308444072d5fa20088567196c0574c68\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x99b116dd1e4f1fa903b70112ae672c18bb34241d3d03a9ad555cd2a611be7327\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0xfad8cb75eb0bb01718e2336002064568bc05887af107f74ed5dd501829e192f8\",\n },\n },\n ],\n },\n [KnownScript.UniqueType]: {\n codeHash:\n \"0x2c8c11c985da60b0a330c61a85507416d6382c130ba67f0c47ab071e00aec628\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x67524c01c0cb5492e499c7c7e406f2f9d823e162d6b0cf432eacde0c9808c2ad\",\n index: 0,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.DidCkb]: {\n codeHash:\n \"0x4a06164dc34dccade5afe3e847a97b6db743e79f5477fa3295acf02849c5984a\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xe2f74c56cdc610d2b9fe898a96a80118845f5278605d7f9ad535dad69ae015bf\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n args: \"0x55573ef6d78e3ca75170ff476176732309a8b31efe94320a954ded3d75c2cb18\",\n hashType: \"type\",\n },\n },\n ],\n },\n [KnownScript.AlwaysSuccess]: {\n codeHash:\n \"0x3b521cc4b552f109d092d8cc468a8048acb53c5952dbe769d2b2f9cf6e47f7f1\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x10d63a996157d32c01078058000052674ca58d15f921bec7f1dcdac2160eb66b\",\n index: 0,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.InputTypeProxyLock]: {\n codeHash:\n \"0x5123908965c711b0ffd8aec642f1ede329649bda1ebdca6bd24124d3796f768a\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x10d63a996157d32c01078058000052674ca58d15f921bec7f1dcdac2160eb66b\",\n index: 1,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.OutputTypeProxyLock]: {\n codeHash:\n \"0x2df53b592db3ae3685b7787adcfef0332a611edb83ca3feca435809964c3aff2\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x10d63a996157d32c01078058000052674ca58d15f921bec7f1dcdac2160eb66b\",\n index: 2,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.LockProxyLock]: {\n codeHash:\n \"0x5d41e32e224c15f152b7e6529100ebeac83b162f5f692a5365774dad2c1a1d02\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x10d63a996157d32c01078058000052674ca58d15f921bec7f1dcdac2160eb66b\",\n index: 3,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.SingleUseLock]: {\n codeHash:\n \"0x8290467a512e5b9a6b816469b0edabba1f4ac474e28ffdd604c2a7c76446bbaf\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x10d63a996157d32c01078058000052674ca58d15f921bec7f1dcdac2160eb66b\",\n index: 4,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.TypeBurnLock]: {\n codeHash:\n \"0xff78bae0abf17d7a404c0be0f9ad9c9185b3f88dcc60403453d5ba8e1f22f53a\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x10d63a996157d32c01078058000052674ca58d15f921bec7f1dcdac2160eb66b\",\n index: 5,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.EasyToDiscoverType]: {\n codeHash:\n \"0xaba4430cc7110d699007095430a1faa72973edf2322ddbfd4d1d219cacf237af\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xb0ed754fb27d67fd8388c97fed914fb7998eceaa01f3e6f967e498de1ba0ac9b\",\n index: 0,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.TimeLock]: {\n codeHash:\n \"0x6fac4b2e89360a1e692efcddcb3a28656d8446549fb83da6d896db8b714f4451\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xb0ed754fb27d67fd8388c97fed914fb7998eceaa01f3e6f967e498de1ba0ac9b\",\n index: 1,\n },\n depType: \"code\",\n },\n },\n ],\n },\n });\n","import { JsonRpcPayload, Transport } from \"./transport.js\";\n\nexport class TransportHttp implements Transport {\n constructor(\n private readonly url: string,\n private readonly timeout = 30000,\n ) {}\n\n async request(payload: JsonRpcPayload) {\n const aborter = new AbortController();\n const abortTimer = setTimeout(() => aborter.abort(), this.timeout);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const raw = await (\n await fetch(this.url, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n signal: aborter.signal,\n })\n ).json();\n clearTimeout(abortTimer);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return raw;\n }\n}\n","import WebSocket from \"isomorphic-ws\";\nimport { JsonRpcPayload, Transport } from \"./transport.js\";\n\nexport class TransportWebSocket implements Transport {\n private ongoing: Map<\n number,\n [\n (response: unknown) => unknown,\n (error: unknown) => unknown,\n ReturnType<typeof setTimeout>,\n ]\n > = new Map();\n private socket?: WebSocket;\n private openSocket?: Promise<WebSocket>;\n\n constructor(\n private readonly url: string,\n private readonly timeout = 30000,\n ) {}\n\n request(data: JsonRpcPayload) {\n const socket = (() => {\n if (\n this.socket &&\n this.socket.readyState !== this.socket.CLOSING &&\n this.socket.readyState !== this.socket.CLOSED &&\n this.openSocket\n ) {\n return this.openSocket;\n }\n const socket = new WebSocket(this.url);\n const onMessage = ({ data }: WebSocket.MessageEvent) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const res = JSON.parse(data as string);\n if (\n typeof res !== \"object\" ||\n res === null ||\n typeof res.id !== \"number\"\n ) {\n throw new Error(`Unknown response ${data as string}`);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const id: number = res.id;\n\n const req = this.ongoing.get(id);\n if (!req) {\n return;\n }\n const [resolve, _, timeout] = req;\n clearTimeout(timeout);\n this.ongoing.delete(id);\n\n resolve(res);\n };\n const onClose = () => {\n this.ongoing.forEach(([_, reject, timeout]) => {\n clearTimeout(timeout);\n reject(new Error(\"Connection closed\"));\n });\n this.ongoing.clear();\n };\n\n socket.onclose = onClose;\n socket.onerror = onClose;\n socket.onmessage = onMessage;\n\n this.socket = socket;\n this.openSocket = new Promise<WebSocket>((resolve) => {\n if (socket.readyState === socket.OPEN) {\n resolve(socket);\n } else {\n socket.onopen = () => {\n resolve(socket);\n };\n }\n });\n return this.openSocket;\n })();\n\n return new Promise((resolve, reject) => {\n const req: [\n (res: unknown) => unknown,\n (err: unknown) => unknown,\n ReturnType<typeof setTimeout>,\n ] = [\n resolve,\n reject,\n setTimeout(() => {\n this.ongoing.delete(data.id);\n void socket\n .then((socket) => socket.close())\n .catch((err) => reject(err));\n reject(new Error(\"Request timeout\"));\n }, this.timeout),\n ];\n this.ongoing.set(data.id, req);\n\n void socket\n .then((socket) => {\n if (\n socket.readyState === socket.CLOSED ||\n socket.readyState === socket.CLOSING\n ) {\n clearTimeout(req[2]);\n this.ongoing.delete(data.id);\n reject(new Error(\"Connection closed\"));\n } else {\n socket.send(JSON.stringify(data));\n }\n })\n .catch((err) => reject(err));\n });\n }\n}\n","import { TransportHttp } from \"./http.js\";\nimport { TransportWebSocket } from \"./webSocket.js\";\n\nexport function transportFromUri(uri: string, config?: { timeout?: number }) {\n if (uri.startsWith(\"wss://\") || uri.startsWith(\"ws://\")) {\n return new TransportWebSocket(uri, config?.timeout);\n }\n\n return new TransportHttp(uri, config?.timeout);\n}\n","import { JsonRpcPayload, Transport } from \"./transport.js\";\n\nexport class TransportFallback implements Transport {\n // Current transport index\n private i = 0;\n\n constructor(private readonly transports: Transport[]) {}\n\n async request(data: JsonRpcPayload): Promise<unknown> {\n let triedCount = 0;\n\n while (true) {\n try {\n return await this.transports[this.i % this.transports.length].request(\n data,\n );\n } catch (err) {\n triedCount += 1;\n this.i += 1;\n\n if (triedCount >= this.transports.length) {\n throw err;\n }\n }\n }\n }\n}\n","import { bytesFrom } from \"../../bytes/index.js\";\nimport {\n Cell,\n CellDep,\n CellDepLike,\n CellInput,\n CellInputLike,\n CellOutput,\n CellOutputLike,\n DepType,\n DepTypeLike,\n Epoch,\n HashType,\n HashTypeLike,\n OutPoint,\n OutPointLike,\n Script,\n ScriptLike,\n Transaction,\n TransactionLike,\n depTypeFrom,\n hashTypeFrom,\n} from \"../../ckb/index.js\";\nimport { Hex, HexLike, hexFrom } from \"../../hex/index.js\";\nimport { NumLike, numFrom, numLeFromBytes, numToHex } from \"../../num/index.js\";\nimport { apply } from \"../../utils/index.js\";\nimport {\n ClientBlock,\n ClientBlockHeader,\n ClientBlockUncle,\n ClientFindCellsResponse,\n ClientFindTransactionsGroupedResponse,\n ClientFindTransactionsResponse,\n ClientIndexerSearchKey,\n ClientIndexerSearchKeyFilter,\n ClientIndexerSearchKeyLike,\n ClientIndexerSearchKeyTransaction,\n ClientIndexerSearchKeyTransactionLike,\n ClientTransactionResponse,\n TransactionStatus,\n} from \"../clientTypes.js\";\nimport {\n JsonRpcBlock,\n JsonRpcBlockHeader,\n JsonRpcBlockUncle,\n JsonRpcCellDep,\n JsonRpcCellInput,\n JsonRpcCellOutput,\n JsonRpcDepType,\n JsonRpcHashType,\n JsonRpcIndexerFindTransactionsGroupedResponse,\n JsonRpcIndexerFindTransactionsResponse,\n JsonRpcIndexerSearchKey,\n JsonRpcIndexerSearchKeyFilter,\n JsonRpcIndexerSearchKeyTransaction,\n JsonRpcOutPoint,\n JsonRpcScript,\n JsonRpcTransaction,\n} from \"./types.js\";\n\nexport class JsonRpcTransformers {\n static hashTypeFrom(hashType: HashTypeLike): JsonRpcHashType {\n return hashTypeFrom(hashType);\n }\n static hashTypeTo(hashType: JsonRpcHashType): HashType {\n return hashType;\n }\n static depTypeFrom(depType: DepTypeLike): JsonRpcDepType {\n switch (depTypeFrom(depType)) {\n case \"code\":\n return \"code\";\n case \"depGroup\":\n return \"dep_group\";\n }\n }\n static depTypeTo(depType: JsonRpcDepType): DepType {\n switch (depType) {\n case \"code\":\n return \"code\";\n case \"dep_group\":\n return \"depGroup\";\n }\n }\n static scriptFrom(scriptLike: ScriptLike): JsonRpcScript {\n const script = Script.from(scriptLike);\n return {\n code_hash: script.codeHash,\n hash_type: JsonRpcTransformers.hashTypeFrom(script.hashType),\n args: script.args,\n };\n }\n static scriptTo(script: JsonRpcScript): Script {\n return Script.from({\n codeHash: script.code_hash,\n hashType: JsonRpcTransformers.hashTypeTo(script.hash_type),\n args: script.args,\n });\n }\n static outPointFrom(outPointLike: OutPointLike): JsonRpcOutPoint {\n const outPoint = OutPoint.from(outPointLike);\n return {\n index: numToHex(outPoint.index),\n tx_hash: outPoint.txHash,\n };\n }\n static outPointTo(outPoint: JsonRpcOutPoint): OutPoint {\n return OutPoint.from({\n index: outPoint.index,\n txHash: outPoint.tx_hash,\n });\n }\n static cellInputFrom(cellInputLike: CellInputLike): JsonRpcCellInput {\n const cellInput = CellInput.from(cellInputLike);\n return {\n previous_output: JsonRpcTransformers.outPointFrom(\n cellInput.previousOutput,\n ),\n since: numToHex(cellInput.since),\n };\n }\n static cellInputTo(cellInput: JsonRpcCellInput): CellInput {\n return CellInput.from({\n previousOutput: JsonRpcTransformers.outPointTo(cellInput.previous_output),\n since: cellInput.since,\n });\n }\n static cellOutputFrom(\n cellOutputLike: CellOutputLike,\n outputData?: HexLike | null,\n ): JsonRpcCellOutput {\n const cellOutput = CellOutput.from(cellOutputLike, outputData);\n\n return {\n capacity: numToHex(cellOutput.capacity),\n lock: JsonRpcTransformers.scriptFrom(cellOutput.lock),\n type: apply(JsonRpcTransformers.scriptFrom, cellOutput.type),\n };\n }\n static cellOutputTo(cellOutput: JsonRpcCellOutput): CellOutput {\n return CellOutput.from({\n capacity: cellOutput.capacity,\n lock: JsonRpcTransformers.scriptTo(cellOutput.lock),\n type: apply(JsonRpcTransformers.scriptTo, cellOutput.type),\n });\n }\n static cellDepFrom(cellDep: CellDepLike): JsonRpcCellDep {\n return {\n out_point: JsonRpcTransformers.outPointFrom(cellDep.outPoint),\n dep_type: JsonRpcTransformers.depTypeFrom(cellDep.depType),\n };\n }\n static cellDepTo(cellDep: JsonRpcCellDep): CellDep {\n return CellDep.from({\n outPoint: JsonRpcTransformers.outPointTo(cellDep.out_point),\n depType: JsonRpcTransformers.depTypeTo(cellDep.dep_type),\n });\n }\n static transactionFrom(txLike: TransactionLike): JsonRpcTransaction {\n const tx = Transaction.from(txLike);\n return {\n version: numToHex(tx.version),\n cell_deps: tx.cellDeps.map((c) => JsonRpcTransformers.cellDepFrom(c)),\n header_deps: tx.headerDeps,\n inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputFrom(i)),\n outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputFrom(o)),\n outputs_data: tx.outputsData,\n witnesses: tx.witnesses,\n };\n }\n static transactionTo(tx: JsonRpcTransaction): Transaction {\n return Transaction.from({\n version: tx.version,\n cellDeps: tx.cell_deps.map((c) => JsonRpcTransformers.cellDepTo(c)),\n headerDeps: tx.header_deps,\n inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputTo(i)),\n outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputTo(o)),\n outputsData: tx.outputs_data,\n witnesses: tx.witnesses,\n });\n }\n static transactionResponseTo({\n cycles,\n tx_status: { status, block_number, block_hash, tx_index, reason },\n transaction,\n }: {\n cycles?: NumLike;\n tx_status: {\n status: TransactionStatus;\n block_hash?: HexLike;\n tx_index?: NumLike;\n block_number?: NumLike;\n reason?: string;\n };\n transaction: JsonRpcTransaction | null;\n }): ClientTransactionResponse | undefined {\n if (transaction == null) {\n return;\n }\n\n return ClientTransactionResponse.from({\n transaction: JsonRpcTransformers.transactionTo(transaction),\n status,\n cycles: apply(numFrom, cycles),\n blockHash: apply(hexFrom, block_hash),\n blockNumber: apply(numFrom, block_number),\n txIndex: apply(numFrom, tx_index),\n reason,\n });\n }\n static blockHeaderTo(header: JsonRpcBlockHeader): ClientBlockHeader {\n const dao = bytesFrom(header.dao);\n return {\n compactTarget: numFrom(header.compact_target),\n dao: {\n c: numLeFromBytes(dao.slice(0, 8)),\n ar: numLeFromBytes(dao.slice(8, 16)),\n s: numLeFromBytes(dao.slice(16, 24)),\n u: numLeFromBytes(dao.slice(24, 32)),\n },\n epoch: Epoch.fromNum(header.epoch),\n extraHash: header.extra_hash,\n hash: header.hash,\n nonce: numFrom(header.nonce),\n number: numFrom(header.number),\n parentHash: header.parent_hash,\n proposalsHash: header.proposals_hash,\n timestamp: numFrom(header.timestamp),\n transactionsRoot: header.transactions_root,\n version: numFrom(header.version),\n };\n }\n static blockUncleTo(block: JsonRpcBlockUncle): ClientBlockUncle {\n return {\n header: JsonRpcTransformers.blockHeaderTo(block.header),\n proposals: block.proposals,\n };\n }\n static blockTo(block: JsonRpcBlock): ClientBlock {\n return {\n header: JsonRpcTransformers.blockHeaderTo(block.header),\n proposals: block.proposals,\n transactions: block.transactions.map((t) =>\n JsonRpcTransformers.transactionTo(t),\n ),\n uncles: block.uncles.map((u) => JsonRpcTransformers.blockUncleTo(u)),\n };\n }\n static rangeFrom([a, b]: [NumLike, NumLike]): [Hex, Hex] {\n return [numToHex(a), numToHex(b)];\n }\n static indexerSearchKeyFilterFrom(\n filter: ClientIndexerSearchKeyFilter,\n ): JsonRpcIndexerSearchKeyFilter {\n return {\n script: apply(JsonRpcTransformers.scriptFrom, filter.script),\n script_len_range: apply(\n JsonRpcTransformers.rangeFrom,\n filter.scriptLenRange,\n ),\n output_data: filter.outputData,\n output_data_filter_mode: filter.outputDataSearchMode,\n output_data_len_range: apply(\n JsonRpcTransformers.rangeFrom,\n filter.outputDataLenRange,\n ),\n output_capacity_range: apply(\n JsonRpcTransformers.rangeFrom,\n filter.outputCapacityRange,\n ),\n block_range: apply(JsonRpcTransformers.rangeFrom, filter.blockRange),\n };\n }\n static indexerSearchKeyFrom(\n keyLike: ClientIndexerSearchKeyLike,\n ): JsonRpcIndexerSearchKey {\n const key = ClientIndexerSearchKey.from(keyLike);\n return {\n script: JsonRpcTransformers.scriptFrom(key.script),\n script_type: key.scriptType,\n script_search_mode: key.scriptSearchMode,\n filter: apply(JsonRpcTransformers.indexerSearchKeyFilterFrom, key.filter),\n with_data: key.withData,\n };\n }\n static findCellsResponseTo({\n last_cursor,\n objects,\n }: {\n last_cursor: string;\n objects: {\n out_point: JsonRpcOutPoint;\n output: JsonRpcCellOutput;\n output_data?: Hex;\n }[];\n }): ClientFindCellsResponse {\n return {\n lastCursor: last_cursor,\n cells: objects.map((cell) =>\n Cell.from({\n outPoint: JsonRpcTransformers.outPointTo(cell.out_point),\n cellOutput: JsonRpcTransformers.cellOutputTo(cell.output),\n outputData: cell.output_data ?? \"0x\",\n }),\n ),\n };\n }\n static indexerSearchKeyTransactionFrom(\n keyLike: ClientIndexerSearchKeyTransactionLike,\n ): JsonRpcIndexerSearchKeyTransaction {\n const key = ClientIndexerSearchKeyTransaction.from(keyLike);\n return {\n script: JsonRpcTransformers.scriptFrom(key.script),\n script_type: key.scriptType,\n script_search_mode: key.scriptSearchMode,\n filter: apply(JsonRpcTransformers.indexerSearchKeyFilterFrom, key.filter),\n group_by_transaction: key.groupByTransaction,\n };\n }\n static findTransactionsResponseTo({\n last_cursor,\n objects,\n }:\n | JsonRpcIndexerFindTransactionsResponse\n | JsonRpcIndexerFindTransactionsGroupedResponse):\n | ClientFindTransactionsResponse\n | ClientFindTransactionsGroupedResponse {\n if (objects.length === 0) {\n return {\n lastCursor: last_cursor,\n transactions: [],\n };\n }\n if (\"io_index\" in objects[0]) {\n return {\n lastCursor: last_cursor,\n transactions: (\n objects as JsonRpcIndexerFindTransactionsResponse[\"objects\"]\n ).map((tx) => ({\n txHash: tx.tx_hash,\n blockNumber: numFrom(tx.block_number),\n txIndex: numFrom(tx.tx_index),\n cellIndex: numFrom(tx.io_index),\n isInput: tx.io_type === \"input\",\n })),\n };\n }\n\n return {\n lastCursor: last_cursor,\n transactions: (\n objects as JsonRpcIndexerFindTransactionsGroupedResponse[\"objects\"]\n ).map((tx) => ({\n txHash: tx.tx_hash,\n blockNumber: numFrom(tx.block_number),\n txIndex: numFrom(tx.tx_index),\n cells: tx.cells.map(([type, i]) => ({\n isInput: type === \"input\",\n cellIndex: numFrom(i),\n })),\n })),\n };\n }\n}\n","import { ScriptInfoLike } from \"./clientTypes.js\";\nimport { KnownScript } from \"./knownScript.js\";\n\nexport const TESTNET_SCRIPTS: Record<KnownScript, ScriptInfoLike> =\n Object.freeze({\n [KnownScript.NervosDao]: {\n codeHash:\n \"0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x8f8c79eb6671709633fe6a46de93c0fedc9c1b8a6527a18d3983879542635c9f\",\n index: 2,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.Secp256k1Blake160]: {\n codeHash:\n \"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.Secp256k1Multisig]: {\n codeHash:\n \"0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37\",\n index: 1,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.Secp256k1MultisigV2]: {\n codeHash:\n \"0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x2eefdeb21f3a3edf697c28a52601b4419806ed60bb427420455cc29a090b26d5\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.AnyoneCanPay]: {\n codeHash:\n \"0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xec26b0f85ed839ece5f11c4c4e837ec359f5adc4420410f6453b1f6b60fb96a6\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.TypeId]: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n cellDeps: [],\n },\n [KnownScript.XUdt]: {\n codeHash:\n \"0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x44ec8b96663e06cc94c8c468a4d46d7d9af69eaf418f6390c9f11bb763dda0ae\",\n },\n },\n ],\n },\n [KnownScript.JoyId]: {\n codeHash:\n \"0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x4a596d31dc35e88fb1591debbf680b04a44b4a434e3a94453c21ea8950ffb4d9\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x1c9fc299ba0570d077b4d7fb9acff1ccc0de69d369942d82678bae937c44ec30\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x4a596d31dc35e88fb1591debbf680b04a44b4a434e3a94453c21ea8950ffb4d9\",\n index: 1,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x27f0d3ccdc2fcd52ae31fbacad5f86b97bc147d7093e4807cd6e3d21c1fe6841\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xf2c9dbfe7438a8c622558da8fa912d36755271ea469d3a25cb8d3373d35c8638\",\n index: 1,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x0ac15fe5b2d059ec39de03f2d3159d5463abb918a1a07a9fa00d2b9c61d89ef3\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x95ecf9b41701b45d431657a67bbfa3f07ef7ceb53bf87097f3674e1a4a19ce62\",\n index: 1,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0xc7bafc5550ccad7cea32c27764f5df6aca4de547da65e3e67fa08477a1af7f5e\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x8b3255491f3c4dcc1cfca33d5c6bcaec5409efe4bbda243900f9580c47e0242e\",\n index: 1,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x71decef9ca8725e64ec99a5521790d16b8d5daadb4989b45dd6ab51806a8c0e4\",\n },\n },\n ],\n },\n [KnownScript.COTA]: {\n codeHash:\n \"0x89cd8003a0eaf8e65e0c31525b7d1d5c1becefd2ea75bb4cff87810ae37764d8\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x636a786001f87cb615acfcf408be0f9a1f077001f0bbc75ca54eadfe7e221713\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n ],\n },\n [KnownScript.PWLock]: {\n codeHash:\n \"0x58c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x57a62003daeab9d54aa29b944fc3b451213a5ebdf2e232216a3cfed0dde61b38\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0xf6d90bfe3041d0fd7e01c45770241697f5f837974bd6ae1672a7ec0f9f523268\",\n },\n },\n ],\n },\n [KnownScript.OmniLock]: {\n codeHash:\n \"0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37\",\n index: 0,\n },\n depType: \"depGroup\",\n },\n },\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xec18bf0d857c981c3d1f4e17999b9b90c484b303378e94de1a57b0872f5d4602\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x761f51fc9cd6a504c32c6ae64b3746594d1af27629b427c5ccf6c9a725a89144\",\n },\n },\n ],\n },\n [KnownScript.NostrLock]: {\n codeHash:\n \"0x6ae5ee0cb887b2df5a9a18137315b9bdc55be8d52637b2de0624092d5f0c91d5\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xa2a434dcdbe280b9ed75bb7d6c7d68186a842456aba0fc506657dc5ed7c01d68\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0x8dc56c6f35f0c535e23ded1629b1f20535477a1b43e59f14617d11e32c50e0aa\",\n },\n },\n ],\n },\n [KnownScript.UniqueType]: {\n codeHash:\n \"0x8e341bcfec6393dcd41e635733ff2dca00a6af546949f70c57a706c0f344df8b\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xff91b063c78ed06f10a1ed436122bd7d671f9a72ef5f5fa28d05252c17cf4cef\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n hashType: \"type\",\n args: \"0xe04976b67600fd25ac50305f77b33aee2c12e3c18e63ece9119e5b32117884b5\",\n },\n },\n ],\n },\n [KnownScript.DidCkb]: {\n codeHash:\n \"0x510150477b10d6ab551a509b71265f3164e9fd4137fcb5a4322f49f03092c7c5\",\n hashType: \"type\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x0e7a830e2d5ebd05cd45a55f93f94559edea0ef1237b7233f49f7facfb3d6a6c\",\n index: 0,\n },\n depType: \"code\",\n },\n type: {\n codeHash:\n \"0x00000000000000000000000000000000000000000000000000545950455f4944\",\n args: \"0x3c27695173b888ed44ddf36f901789014384ad6c05a9137f3db9a0779c141c35\",\n hashType: \"type\",\n },\n },\n ],\n },\n [KnownScript.AlwaysSuccess]: {\n codeHash:\n \"0x3b521cc4b552f109d092d8cc468a8048acb53c5952dbe769d2b2f9cf6e47f7f1\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xb4f171c9c9caf7401f54a8e56225ae21d95032150a87a4678eac3f66a3137b93\",\n index: 0,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.InputTypeProxyLock]: {\n codeHash:\n \"0x5123908965c711b0ffd8aec642f1ede329649bda1ebdca6bd24124d3796f768a\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xb4f171c9c9caf7401f54a8e56225ae21d95032150a87a4678eac3f66a3137b93\",\n index: 1,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.OutputTypeProxyLock]: {\n codeHash:\n \"0x2df53b592db3ae3685b7787adcfef0332a611edb83ca3feca435809964c3aff2\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xb4f171c9c9caf7401f54a8e56225ae21d95032150a87a4678eac3f66a3137b93\",\n index: 2,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.LockProxyLock]: {\n codeHash:\n \"0x5d41e32e224c15f152b7e6529100ebeac83b162f5f692a5365774dad2c1a1d02\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xb4f171c9c9caf7401f54a8e56225ae21d95032150a87a4678eac3f66a3137b93\",\n index: 3,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.SingleUseLock]: {\n codeHash:\n \"0x8290467a512e5b9a6b816469b0edabba1f4ac474e28ffdd604c2a7c76446bbaf\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xb4f171c9c9caf7401f54a8e56225ae21d95032150a87a4678eac3f66a3137b93\",\n index: 4,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.TypeBurnLock]: {\n codeHash:\n \"0xff78bae0abf17d7a404c0be0f9ad9c9185b3f88dcc60403453d5ba8e1f22f53a\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0xb4f171c9c9caf7401f54a8e56225ae21d95032150a87a4678eac3f66a3137b93\",\n index: 5,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.EasyToDiscoverType]: {\n codeHash:\n \"0xaba4430cc7110d699007095430a1faa72973edf2322ddbfd4d1d219cacf237af\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x1b4ffcad55ecd36ffb2715b6816b83da73851f1a24fe594f263c4f34dad90792\",\n index: 0,\n },\n depType: \"code\",\n },\n },\n ],\n },\n [KnownScript.TimeLock]: {\n codeHash:\n \"0x6fac4b2e89360a1e692efcddcb3a28656d8446549fb83da6d896db8b714f4451\",\n hashType: \"data1\",\n cellDeps: [\n {\n cellDep: {\n outPoint: {\n txHash:\n \"0x1b4ffcad55ecd36ffb2715b6816b83da73851f1a24fe594f263c4f34dad90792\",\n index: 1,\n },\n depType: \"code\",\n },\n },\n ],\n },\n });\n","import { type HashType } from \"./script.js\";\n\nexport const HASH_TYPE_TO_NUM: Record<HashType, number> = {\n type: 0x01,\n data: 0x00,\n data1: 0x02,\n data2: 0x04,\n};\nexport const NUM_TO_HASH_TYPE: Record<number, HashType> = {\n 0x01: \"type\",\n 0x00: \"data\",\n 0x02: \"data1\",\n 0x04: \"data2\",\n};\nexport const HASH_TYPES: string[] = Object.keys(HASH_TYPE_TO_NUM);\n","import { Bytes, BytesLike, bytesFrom } from \"../bytes/index.js\";\nimport type { Client } from \"../client/index.js\";\nimport { KnownScript } from \"../client/knownScript.js\";\nimport { Codec, Entity, codec } from \"../codec/index.js\";\nimport { Hex, HexLike, hexFrom } from \"../hex/index.js\";\nimport { mol } from \"../molecule/index.js\";\nimport {\n HASH_TYPES,\n HASH_TYPE_TO_NUM,\n NUM_TO_HASH_TYPE,\n} from \"./script.advanced.js\";\n\nexport const HashTypeCodec: Codec<HashTypeLike, HashType> = Codec.from({\n byteLength: 1,\n encode: hashTypeToBytes,\n decode: hashTypeFromBytes,\n});\n\n/**\n * @public\n */\nexport type HashTypeLike = string | number | bigint;\n/**\n * @public\n */\nexport type HashType = \"type\" | \"data\" | \"data1\" | \"data2\";\n\n/**\n * Converts a HashTypeLike value to a HashType.\n * @public\n *\n * @param val - The value to convert, which can be a string, number, or bigint.\n * @returns The corresponding HashType.\n *\n * @throws Will throw an error if the input value is not a valid hash type.\n *\n * @example\n * ```typescript\n * const hashType = hashTypeFrom(1); // Outputs \"data\"\n * const hashType = hashTypeFrom(\"type\"); // Outputs \"type\"\n * ```\n */\n\nexport function hashTypeFrom(val: HashTypeLike): HashType {\n const hashType = (() => {\n if (typeof val === \"number\") {\n return NUM_TO_HASH_TYPE[val];\n }\n\n if (typeof val === \"bigint\") {\n return NUM_TO_HASH_TYPE[Number(val)];\n }\n\n if (!HASH_TYPES.includes(val)) {\n return;\n }\n return val as HashType;\n })();\n if (hashType === undefined) {\n throw new Error(`Invalid hash type ${val}`);\n }\n return hashType;\n}\n\n/**\n * Converts a HashTypeLike value to its corresponding byte representation.\n * @public\n *\n * @param hashType - The hash type value to convert.\n * @returns A Uint8Array containing the byte representation of the hash type.\n *\n * @example\n * ```typescript\n * const hashTypeBytes = hashTypeToBytes(\"type\"); // Outputs Uint8Array [0]\n * ```\n */\n\nexport function hashTypeToBytes(hashType: HashTypeLike): Bytes {\n return bytesFrom([HASH_TYPE_TO_NUM[hashTypeFrom(hashType)]]);\n}\n\n/**\n * Converts a byte-like value to a HashType.\n * @public\n *\n * @param bytes - The byte-like value to convert.\n * @returns The corresponding HashType.\n *\n * @throws Will throw an error if the input bytes do not correspond to a valid hash type.\n *\n * @example\n * ```typescript\n * const hashType = hashTypeFromBytes(new Uint8Array([0])); // Outputs \"type\"\n * ```\n */\n\nexport function hashTypeFromBytes(bytes: BytesLike): HashType {\n return NUM_TO_HASH_TYPE[bytesFrom(bytes)[0]];\n}\n\n/**\n * @public\n */\nexport type ScriptLike = {\n codeHash: BytesLike;\n hashType: HashTypeLike;\n args: BytesLike;\n};\n/**\n * @public\n */\n@codec(\n mol.table({\n codeHash: mol.Byte32,\n hashType: HashTypeCodec,\n args: mol.Bytes,\n }),\n)\nexport class Script extends Entity.Base<ScriptLike, Script>() {\n /**\n * Creates an instance of Script.\n *\n * @param codeHash - The code hash of the script.\n * @param hashType - The hash type of the script.\n * @param args - The arguments for the script.\n */\n constructor(\n public codeHash: Hex,\n public hashType: HashType,\n public args: Hex,\n ) {\n super();\n }\n\n get occupiedSize(): number {\n return 33 + bytesFrom(this.args).length;\n }\n\n /**\n * Clone a script.\n *\n * @returns A cloned Script instance.\n *\n * @example\n * ```typescript\n * const script1 = script0.clone();\n * ```\n */\n clone(): Script {\n return new Script(this.codeHash, this.hashType, this.args);\n }\n\n /**\n * Check if the script is equal to another script.\n * @public\n * @param other - The other script to compare with\n * @returns True if the scripts are equal, false otherwise\n *\n * @example\n * ```typescript\n * const isEqual = script0.eq(script1);\n * ```\n */\n eq(other: ScriptLike): boolean {\n other = Script.from(other);\n return (\n this.args === other.args &&\n this.codeHash === other.codeHash &&\n this.hashType === other.hashType\n );\n }\n\n /**\n * Creates a Script instance from a ScriptLike object.\n *\n * @param script - A ScriptLike object or an instance of Script.\n * @returns A Script instance.\n *\n * @example\n * ```typescript\n * const script = Script.from({\n * codeHash: \"0x1234...\",\n * hashType: \"type\",\n * args: \"0xabcd...\"\n * });\n * ```\n */\n\n static from(script: ScriptLike): Script {\n if (script instanceof Script) {\n return script;\n }\n\n return new Script(\n hexFrom(script.codeHash),\n hashTypeFrom(script.hashType),\n hexFrom(script.args),\n );\n }\n\n /**\n * Creates a Script instance from client and known script.\n *\n * @param knownScript - A KnownScript enum.\n * @param args - Args for the script.\n * @param client - A ScriptLike object or an instance of Script.\n * @returns A promise that resolves to the script instance.\n *\n * @example\n * ```typescript\n * const script = await Script.fromKnownScript(\n * client,\n * KnownScript.XUdt,\n * args: \"0xabcd...\"\n * );\n * ```\n */\n\n static async fromKnownScript(\n client: Client,\n knownScript: KnownScript,\n args: HexLike,\n ): Promise<Script> {\n const script = await client.getKnownScript(knownScript);\n return new Script(script.codeHash, script.hashType, hexFrom(args));\n }\n\n /**\n * Converts the Script instance to molecule data format.\n *\n * @returns An object representing the script in molecule data format.\n */\n}\n\nexport const ScriptOpt = mol.option(Script);\nexport const ScriptVec = mol.vector(Script);\n","import { type DepType } from \"./transaction.js\";\n\nexport const DEP_TYPE_TO_NUM: Record<DepType, number> = {\n code: 0x00,\n depGroup: 0x01,\n};\nexport const NUM_TO_DEP_TYPE: Record<number, DepType> = {\n 0x00: \"code\",\n 0x01: \"depGroup\",\n};\nexport const DEP_TYPES: string[] = Object.keys(DEP_TYPE_TO_NUM);\n","import { fixedPointToString } from \"../fixedPoint/index.js\";\nimport { Num, numFrom, NumLike } from \"../num/index.js\";\nimport { Script, ScriptLike } from \"./script.js\";\n\nexport class ErrorTransactionInsufficientCapacity extends Error {\n public readonly amount: Num;\n public readonly isForChange: boolean;\n\n constructor(\n amountLike: NumLike,\n reason?: {\n isForChange?: boolean;\n },\n ) {\n const amount = numFrom(amountLike);\n const isForChange = reason?.isForChange ?? false;\n super(\n `Insufficient CKB, need ${fixedPointToString(amount)} extra CKB${isForChange ? \" for the change cell\" : \"\"}`,\n );\n this.amount = amount;\n this.isForChange = isForChange;\n }\n}\n\nexport class ErrorTransactionInsufficientCoin extends Error {\n public readonly amount: Num;\n public readonly type: Script;\n\n constructor(amountLike: NumLike, typeLike: ScriptLike) {\n const amount = numFrom(amountLike);\n const type = Script.from(typeLike);\n super(`Insufficient coin, need ${amount} extra coin`);\n this.amount = amount;\n this.type = type;\n }\n}\n","import { Bytes, BytesLike, bytesFrom } from \"../bytes/index.js\";\nimport type { ClientCollectableSearchKeyFilterLike } from \"../client/clientTypes.advanced.js\";\nimport {\n ClientBlockHeader,\n type CellDepInfoLike,\n type Client,\n type ClientBlockHeaderLike,\n} from \"../client/index.js\";\nimport { KnownScript } from \"../client/knownScript.js\";\nimport { Codec, Entity, codec } from \"../codec/index.js\";\nimport { Zero, fixedPointFrom } from \"../fixedPoint/index.js\";\nimport { Hasher, HasherCkb, hashCkb } from \"../hasher/index.js\";\nimport { Hex, HexLike, hexFrom } from \"../hex/index.js\";\nimport { mol } from \"../molecule/index.js\";\nimport {\n Num,\n NumLike,\n numFrom,\n numFromBytes,\n numMax,\n numToBytes,\n numToHex,\n} from \"../num/index.js\";\nimport type { Signer } from \"../signer/index.js\";\nimport { apply, reduceAsync } from \"../utils/index.js\";\nimport { Epoch } from \"./epoch.js\";\nimport { Script, ScriptLike, ScriptOpt } from \"./script.js\";\nimport { DEP_TYPE_TO_NUM, NUM_TO_DEP_TYPE } from \"./transaction.advanced.js\";\nimport {\n ErrorTransactionInsufficientCapacity,\n ErrorTransactionInsufficientCoin,\n} from \"./transactionErrors.js\";\nimport type { LumosTransactionSkeletonType } from \"./transactionLumos.js\";\n\nexport const DepTypeCodec: Codec<DepTypeLike, DepType> = Codec.from({\n byteLength: 1,\n encode: depTypeToBytes,\n decode: depTypeFromBytes,\n});\n\n/**\n * @public\n */\nexport type DepTypeLike = string | number | bigint;\n/**\n * @public\n */\nexport type DepType = \"depGroup\" | \"code\";\n\n/**\n * Converts a DepTypeLike value to a DepType.\n * @public\n *\n * @param val - The value to convert, which can be a string, number, or bigint.\n * @returns The corresponding DepType.\n *\n * @throws Will throw an error if the input value is not a valid dep type.\n *\n * @example\n * ```typescript\n * const depType = depTypeFrom(1); // Outputs \"code\"\n * const depType = depTypeFrom(\"depGroup\"); // Outputs \"depGroup\"\n * ```\n */\n\nexport function depTypeFrom(val: DepTypeLike): DepType {\n const depType = (() => {\n if (typeof val === \"number\") {\n return NUM_TO_DEP_TYPE[val];\n }\n\n if (typeof val === \"bigint\") {\n return NUM_TO_DEP_TYPE[Number(val)];\n }\n\n return val as DepType;\n })();\n if (depType === undefined) {\n throw new Error(`Invalid dep type ${val}`);\n }\n return depType;\n}\n\n/**\n * Converts a DepTypeLike value to its corresponding byte representation.\n * @public\n *\n * @param depType - The dep type value to convert.\n * @returns A Uint8Array containing the byte representation of the dep type.\n *\n * @example\n * ```typescript\n * const depTypeBytes = depTypeToBytes(\"code\"); // Outputs Uint8Array [1]\n * ```\n */\n\nexport function depTypeToBytes(depType: DepTypeLike): Bytes {\n return bytesFrom([DEP_TYPE_TO_NUM[depTypeFrom(depType)]]);\n}\n\n/**\n * Converts a byte-like value to a DepType.\n * @public\n *\n * @param bytes - The byte-like value to convert.\n * @returns The corresponding DepType.\n *\n * @throws Will throw an error if the input bytes do not correspond to a valid dep type.\n *\n * @example\n * ```typescript\n * const depType = depTypeFromBytes(new Uint8Array([1])); // Outputs \"code\"\n * ```\n */\n\nexport function depTypeFromBytes(bytes: BytesLike): DepType {\n return NUM_TO_DEP_TYPE[bytesFrom(bytes)[0]];\n}\n\n/**\n * @public\n */\nexport type OutPointLike = {\n txHash: HexLike;\n index: NumLike;\n};\n/**\n * @public\n */\n@codec(\n mol.struct({\n txHash: mol.Byte32,\n index: mol.Uint32,\n }),\n)\nexport class OutPoint extends Entity.Base<OutPointLike, OutPoint>() {\n /**\n * Creates an instance of OutPoint.\n *\n * @param txHash - The transaction hash.\n * @param index - The index of the output in the transaction.\n */\n\n constructor(\n public txHash: Hex,\n public index: Num,\n ) {\n super();\n }\n\n /**\n * Creates an OutPoint instance from an OutPointLike object.\n *\n * @param outPoint - An OutPointLike object or an instance of OutPoint.\n * @returns An OutPoint instance.\n *\n * @example\n * ```typescript\n * const outPoint = OutPoint.from({ txHash: \"0x...\", index: 0 });\n * ```\n */\n static from(outPoint: OutPointLike): OutPoint {\n if (outPoint instanceof OutPoint) {\n return outPoint;\n }\n return new OutPoint(hexFrom(outPoint.txHash), numFrom(outPoint.index));\n }\n\n /**\n * Clone a OutPoint.\n *\n * @returns A cloned OutPoint instance.\n *\n * @example\n * ```typescript\n * const outPoint1 = outPoint0.clone();\n * ```\n */\n clone(): OutPoint {\n return new OutPoint(this.txHash, this.index);\n }\n\n /**\n * Check if the OutPoint is equal to another OutPoint.\n * @public\n * @param other - The other OutPoint to compare with\n * @returns True if the OutPoints are equal, false otherwise\n *\n * @example\n * ```typescript\n * const isEqual = outPoint0.eq(outPoint1);\n * ```\n */\n eq(other: OutPointLike): boolean {\n other = OutPoint.from(other);\n return this.txHash === other.txHash && this.index === other.index;\n }\n}\n\n/**\n * @public\n */\nexport type CellOutputLike = {\n capacity?: NumLike | null;\n lock: ScriptLike;\n type?: ScriptLike | null;\n};\n/**\n * @public\n */\n@codec(\n mol.table({\n capacity: mol.Uint64,\n lock: Script,\n type: ScriptOpt,\n }),\n)\nexport class CellOutput extends Entity.Base<CellOutputLike, CellOutput>() {\n /**\n * Creates an instance of CellOutput.\n *\n * @param capacity - The capacity of the cell.\n * @param lock - The lock script of the cell.\n * @param type - The optional type script of the cell.\n */\n\n constructor(\n public capacity: Num,\n public lock: Script,\n public type?: Script,\n ) {\n super();\n }\n\n get occupiedSize(): number {\n return 8 + this.lock.occupiedSize + (this.type?.occupiedSize ?? 0);\n }\n\n /**\n * Creates a CellOutput instance from a CellOutputLike object.\n * This method supports automatic capacity calculation when outputData is provided and capacity is 0 or omitted.\n *\n * @param cellOutput - A CellOutputLike object or an instance of CellOutput.\n * @param outputData - Optional output data used for automatic capacity calculation.\n * When provided and capacity is 0, the capacity will be calculated\n * as occupiedSize + outputData.length.\n * @returns A CellOutput instance.\n *\n * @example\n * ```typescript\n * // Basic usage with explicit capacity\n * const cellOutput1 = CellOutput.from({\n * capacity: 1000n,\n * lock: { codeHash: \"0x...\", hashType: \"type\", args: \"0x...\" },\n * type: { codeHash: \"0x...\", hashType: \"type\", args: \"0x...\" }\n * });\n *\n * // Automatic capacity calculation\n * const cellOutput2 = CellOutput.from({\n * lock: { codeHash: \"0x...\", hashType: \"type\", args: \"0x...\" }\n * }, \"0x1234\"); // Capacity will be calculated automatically\n * ```\n */\n static from(\n cellOutput: CellOutputLike,\n outputData?: HexLike | null,\n ): CellOutput {\n const output = (() => {\n if (cellOutput instanceof CellOutput) {\n return cellOutput;\n }\n return new CellOutput(\n numFrom(cellOutput.capacity ?? 0),\n Script.from(cellOutput.lock),\n apply(Script.from, cellOutput.type),\n );\n })();\n\n if (outputData != null) {\n output.capacity = numMax(\n output.capacity,\n fixedPointFrom(output.occupiedSize + bytesFrom(outputData).length),\n );\n }\n\n return output;\n }\n\n /**\n * Clone a CellOutput.\n *\n * @returns A cloned CellOutput instance.\n *\n * @example\n * ```typescript\n * const cellOutput1 = cellOutput0.clone();\n * ```\n */\n clone(): CellOutput {\n return new CellOutput(this.capacity, this.lock.clone(), this.type?.clone());\n }\n}\nexport const CellOutputVec = mol.vector(CellOutput);\n\n/**\n * @public\n * Represents a cell-like object that may or may not be on-chain.\n * It can optionally have an `outPoint` (or `previousOutput`).\n * This is used as a flexible input for creating `CellAny` instances.\n * @see CellAny\n */\nexport type CellAnyLike = {\n outPoint?: OutPointLike | null;\n previousOutput?: OutPointLike | null;\n cellOutput: CellOutputLike;\n outputData?: HexLike | null;\n};\n/**\n * Represents a CKB cell that can be either on-chain (with an `outPoint`) or off-chain (without an `outPoint`).\n * This class provides a unified interface for handling cells before they are included in a transaction,\n * or for cells that are already part of the blockchain state.\n *\n * @public\n */\nexport class CellAny {\n public outPoint: OutPoint | undefined;\n\n /**\n * Creates an instance of CellAny.\n *\n * @param cellOutput - The cell output of the cell.\n * @param outputData - The output data of the cell.\n * @param outPoint - The optional output point of the cell. If provided, the cell is considered on-chain.\n */\n\n constructor(\n public cellOutput: CellOutput,\n public outputData: Hex,\n outPoint?: OutPoint,\n ) {\n this.outPoint = outPoint;\n }\n\n /**\n * Creates a `CellAny` instance from a `CellAnyLike` object.\n * This factory method provides a convenient way to create `CellAny` instances\n * from plain objects, automatically handling the optional `outPoint` or `previousOutput`.\n *\n * @param cell - A `CellAnyLike` object.\n * @returns A new `CellAny` instance.\n *\n * @example\n * ```typescript\n * // Create an off-chain cell (e.g., a new output)\n * const offChainCell = CellAny.from({\n * cellOutput: { capacity: 1000n, lock: lockScript },\n * outputData: \"0x\"\n * });\n *\n * // Create an on-chain cell from an input\n * const onChainCell = CellAny.from({\n * outPoint: { txHash: \"0x...\", index: 0 },\n * cellOutput: { capacity: 2000n, lock: lockScript },\n * outputData: \"0x1234\"\n * });\n * ```\n */\n static from(cell: CellAnyLike): CellAny {\n if (cell instanceof CellAny) {\n return cell;\n }\n\n const outputData = hexFrom(cell.outputData ?? \"0x\");\n\n return new CellAny(\n CellOutput.from(cell.cellOutput, outputData),\n outputData,\n apply(OutPoint.from, cell.outPoint ?? cell.previousOutput),\n );\n }\n\n /**\n * Calculates the total occupied size of the cell in bytes.\n * This includes the size of the `CellOutput` structure plus the size of the `outputData`.\n *\n * @returns The total occupied size in bytes.\n */\n get occupiedSize() {\n return this.cellOutput.occupiedSize + bytesFrom(this.outputData).byteLength;\n }\n\n /**\n * Calculates the free capacity of the cell.\n * Free capacity is the total capacity minus the capacity occupied by the cell's structure and data.\n *\n * @returns The free capacity in shannons as a `Num`.\n */\n get capacityFree() {\n return this.cellOutput.capacity - fixedPointFrom(this.occupiedSize);\n }\n\n /**\n * Checks if the cell is a Nervos DAO cell and optionally checks its phase.\n *\n * @param client - A CKB client instance to fetch known script information.\n * @param phase - Optional phase to check: \"deposited\" or \"withdrew\".\n * If omitted, it checks if the cell is a DAO cell regardless of phase.\n * @returns A promise that resolves to `true` if the cell is a matching Nervos DAO cell, `false` otherwise.\n */\n async isNervosDao(\n client: Client,\n phase?: \"deposited\" | \"withdrew\",\n ): Promise<boolean> {\n const { type } = this.cellOutput;\n\n const daoType = await client.getKnownScript(KnownScript.NervosDao);\n if (\n !type ||\n type.codeHash !== daoType.codeHash ||\n type.hashType !== daoType.hashType\n ) {\n // Non Nervos DAO cell\n return false;\n }\n\n const hasWithdrew = numFrom(this.outputData) !== Zero;\n return (\n !phase ||\n (phase === \"deposited\" && !hasWithdrew) ||\n (phase === \"withdrew\" && hasWithdrew)\n );\n }\n\n /**\n * Clones the `CellAny` instance.\n *\n * @returns A new `CellAny` instance that is a deep copy of the current one.\n *\n * @example\n * ```typescript\n * const clonedCell = cellAny.clone();\n * ```\n */\n clone(): CellAny {\n return new CellAny(\n this.cellOutput.clone(),\n this.outputData,\n this.outPoint?.clone(),\n );\n }\n}\n\n/**\n * Represents a cell-like object that is guaranteed to be on-chain.\n * It must have an `outPoint` (or its alias `previousOutput`).\n * This is used as a type constraint for creating `Cell` instances.\n * @see Cell\n * @public\n */\nexport type CellLike = CellAnyLike &\n (\n | {\n outPoint: OutPointLike;\n previousOutput?: undefined | null;\n }\n | {\n outPoint?: undefined | null;\n previousOutput: OutPointLike;\n }\n );\n/**\n * Represents an on-chain CKB cell, which is a `CellAny` that is guaranteed to have an `outPoint`.\n * This class is typically used for cells that are already part of the blockchain state, such as transaction inputs.\n * @public\n */\nexport class Cell extends CellAny {\n /**\n * Creates an instance of an on-chain Cell.\n *\n * @param outPoint - The output point of the cell.\n * @param cellOutput - The cell output of the cell.\n * @param outputData - The output data of the cell.\n */\n\n constructor(\n public outPoint: OutPoint,\n cellOutput: CellOutput,\n outputData: Hex,\n ) {\n super(cellOutput, outputData, outPoint);\n }\n\n /**\n * Creates a Cell instance from a CellLike object.\n * This method accepts either `outPoint` or `previousOutput` to specify the cell's location,\n * and supports automatic capacity calculation for the cell output.\n *\n * @param cell - A CellLike object or an instance of Cell. The object can use either:\n * - `outPoint`: For referencing a cell output\n * - `previousOutput`: For referencing a cell input (alternative name for outPoint)\n * The cellOutput can omit capacity for automatic calculation.\n * @returns A Cell instance.\n *\n * @example\n * ```typescript\n * // Using outPoint with explicit capacity\n * const cell1 = Cell.from({\n * outPoint: { txHash: \"0x...\", index: 0 },\n * cellOutput: {\n * capacity: 1000n,\n * lock: { codeHash: \"0x...\", hashType: \"type\", args: \"0x...\" }\n * },\n * outputData: \"0x\"\n * });\n *\n * // Using previousOutput with automatic capacity calculation\n * const cell2 = Cell.from({\n * previousOutput: { txHash: \"0x...\", index: 0 },\n * cellOutput: {\n * lock: { codeHash: \"0x...\", hashType: \"type\", args: \"0x...\" }\n * // capacity will be calculated automatically\n * },\n * outputData: \"0x1234\"\n * });\n * ```\n */\n\n static from(cell: CellLike): Cell {\n if (cell instanceof Cell) {\n return cell;\n }\n\n return new Cell(\n OutPoint.from(cell.outPoint ?? cell.previousOutput),\n CellOutput.from(cell.cellOutput, cell.outputData),\n hexFrom(cell.outputData ?? \"0x\"),\n );\n }\n\n /**\n * Gets confirmed Nervos DAO profit of a Cell\n * It returns non-zero value only when the cell is in withdrawal phase 2\n * See https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md\n *\n * @param client - A client for searching DAO related headers\n * @returns Profit\n *\n * @example\n * ```typescript\n * const profit = await cell.getDaoProfit(client);\n * ```\n */\n async getDaoProfit(client: Client): Promise<Num> {\n if (!(await this.isNervosDao(client, \"withdrew\"))) {\n return Zero;\n }\n\n const { depositHeader, withdrawHeader } =\n await this.getNervosDaoInfo(client);\n if (!withdrawHeader || !depositHeader) {\n throw new Error(\n `Unable to get headers of a Nervos DAO cell ${this.outPoint.txHash}:${this.outPoint.index.toString()}`,\n );\n }\n\n return calcDaoProfit(this.capacityFree, depositHeader, withdrawHeader);\n }\n\n /**\n * Retrieves detailed information about a Nervos DAO cell, including its deposit and withdrawal headers.\n *\n * @param client - A CKB client instance to fetch cell and header data.\n * @returns A promise that resolves to an object containing header information.\n * - If not a DAO cell, returns `{}`.\n * - If a deposited DAO cell, returns `{ depositHeader }`.\n * - If a withdrawn DAO cell, returns `{ depositHeader, withdrawHeader }`.\n *\n * @throws If the cell is a DAO cell but its corresponding headers cannot be fetched.\n *\n * @example\n * ```typescript\n * const daoInfo = await cell.getNervosDaoInfo(client);\n * ```\n */\n async getNervosDaoInfo(client: Client): Promise<\n // Non Nervos DAO cell\n | {\n depositHeader?: undefined;\n withdrawHeader?: undefined;\n }\n // Deposited Nervos DAO cell\n | {\n depositHeader: ClientBlockHeader;\n withdrawHeader?: undefined;\n }\n // Withdrew Nervos DAO cell\n | {\n depositHeader: ClientBlockHeader;\n withdrawHeader: ClientBlockHeader;\n }\n > {\n if (!(await this.isNervosDao(client))) {\n // Non Nervos DAO cell\n return {};\n }\n\n if (numFrom(this.outputData) === Zero) {\n // Deposited Nervos DAO cell\n const depositRes = await client.getCellWithHeader(this.outPoint);\n if (!depositRes?.header) {\n throw new Error(\n `Unable to get header of a Nervos DAO deposited cell ${this.outPoint.txHash}:${this.outPoint.index.toString()}`,\n );\n }\n\n return {\n depositHeader: depositRes.header,\n };\n }\n\n // Withdrew Nervos DAO cell\n const [depositHeader, withdrawRes] = await Promise.all([\n client.getHeaderByNumber(numFromBytes(this.outputData)),\n client.getCellWithHeader(this.outPoint),\n ]);\n if (!withdrawRes?.header || !depositHeader) {\n throw new Error(\n `Unable to get headers of a Nervos DAO withdrew cell ${this.outPoint.txHash}:${this.outPoint.index.toString()}`,\n );\n }\n\n return {\n depositHeader,\n withdrawHeader: withdrawRes.header,\n };\n }\n\n /**\n * Clone a Cell\n *\n * @returns A cloned Cell instance.\n *\n * @example\n * ```typescript\n * const cell1 = cell0.clone();\n * ```\n */\n clone(): Cell {\n return new Cell(\n this.outPoint.clone(),\n this.cellOutput.clone(),\n this.outputData,\n );\n }\n}\n\n/**\n * @public\n */\nexport type SinceLike =\n | {\n relative: \"absolute\" | \"relative\";\n metric: \"blockNumber\" | \"epoch\" | \"timestamp\";\n value: NumLike;\n }\n | NumLike;\n/**\n * @public\n */\n@codec(\n mol.Uint64.mapIn((encodable: SinceLike) => Since.from(encodable).toNum()),\n)\nexport class Since extends Entity.Base<SinceLike, Since>() {\n /**\n * Creates an instance of Since.\n *\n * @param relative - Absolute or relative\n * @param metric - The metric of since\n * @param value - The value of since\n */\n\n constructor(\n public relative: \"absolute\" | \"relative\",\n public metric: \"blockNumber\" | \"epoch\" | \"timestamp\",\n public value: Num,\n ) {\n super();\n }\n\n /**\n * Clone a Since.\n *\n * @returns A cloned Since instance.\n *\n * @example\n * ```typescript\n * const since1 = since0.clone();\n * ```\n */\n clone(): Since {\n return new Since(this.relative, this.metric, this.value);\n }\n\n /**\n * Creates a Since instance from a SinceLike object.\n *\n * @param since - A SinceLike object or an instance of Since.\n * @returns A Since instance.\n *\n * @example\n * ```typescript\n * const since = Since.from(\"0x1234567812345678\");\n * ```\n */\n static from(since: SinceLike): Since {\n if (since instanceof Since) {\n return since;\n }\n\n if (typeof since === \"object\" && \"relative\" in since) {\n return new Since(since.relative, since.metric, numFrom(since.value));\n }\n\n return Since.fromNum(since);\n }\n\n /**\n * Converts the Since instance to num.\n *\n * @returns A num\n *\n * @example\n * ```typescript\n * const num = since.toNum();\n * ```\n */\n\n toNum(): Num {\n return (\n this.value |\n (this.relative === \"absolute\" ? Zero : numFrom(\"0x8000000000000000\")) |\n {\n blockNumber: numFrom(\"0x0000000000000000\"),\n epoch: numFrom(\"0x2000000000000000\"),\n timestamp: numFrom(\"0x4000000000000000\"),\n }[this.metric]\n );\n }\n\n /**\n * Creates a Since instance from a num-like value.\n *\n * @param numLike - The num-like value to convert.\n * @returns A Since instance.\n *\n * @example\n * ```typescript\n * const since = Since.fromNum(\"0x0\");\n * ```\n */\n\n static fromNum(numLike: NumLike): Since {\n const num = numFrom(numLike);\n\n const relative = num >> numFrom(63) === Zero ? \"absolute\" : \"relative\";\n const metric = ([\"blockNumber\", \"epoch\", \"timestamp\"] as Since[\"metric\"][])[\n Number((num >> numFrom(61)) & numFrom(3))\n ];\n const value = num & numFrom(\"0x00ffffffffffffff\");\n\n return new Since(relative, metric, value);\n }\n}\n\n/**\n * @public\n */\nexport type CellInputLike = (\n | {\n previousOutput: OutPointLike;\n }\n | { outPoint: OutPointLike }\n) & {\n since?: SinceLike | NumLike | null;\n cellOutput?: CellOutputLike | null;\n outputData?: HexLike | null;\n};\n/**\n * @public\n */\n@codec(\n mol\n .struct({\n since: Since,\n previousOutput: OutPoint,\n })\n .mapIn((encodable: CellInputLike) => CellInput.from(encodable)),\n)\nexport class CellInput extends Entity.Base<CellInputLike, CellInput>() {\n /**\n * Creates an instance of CellInput.\n *\n * @param previousOutput - The previous outpoint of the cell.\n * @param since - The since value of the cell input.\n * @param cellOutput - The optional cell output associated with the cell input.\n * @param outputData - The optional output data associated with the cell input.\n */\n\n constructor(\n public previousOutput: OutPoint,\n public since: Num,\n public cellOutput?: CellOutput,\n public outputData?: Hex,\n ) {\n super();\n }\n\n /**\n * Creates a CellInput instance from a CellInputLike object.\n *\n * @param cellInput - A CellInputLike object or an instance of CellInput.\n * @returns A CellInput instance.\n *\n * @example\n * ```typescript\n * const cellInput = CellInput.from({\n * previousOutput: { txHash: \"0x...\", index: 0 },\n * since: 0n\n * });\n * ```\n */\n static from(cellInput: CellInputLike): CellInput {\n if (cellInput instanceof CellInput) {\n return cellInput;\n }\n\n return new CellInput(\n OutPoint.from(\n \"previousOutput\" in cellInput\n ? cellInput.previousOutput\n : cellInput.outPoint,\n ),\n Since.from(cellInput.since ?? 0).toNum(),\n apply(CellOutput.from, cellInput.cellOutput),\n apply(hexFrom, cellInput.outputData),\n );\n }\n\n async getCell(client: Client): Promise<Cell> {\n await this.completeExtraInfos(client);\n if (!this.cellOutput || !this.outputData) {\n throw new Error(\"Unable to complete input\");\n }\n\n return Cell.from({\n outPoint: this.previousOutput,\n cellOutput: this.cellOutput,\n outputData: this.outputData,\n });\n }\n\n /**\n * Complete extra infos in the input. Including\n * - Previous cell output\n * - Previous cell data\n * The instance will be modified.\n *\n * @returns true if succeed.\n * @example\n * ```typescript\n * await cellInput.completeExtraInfos(client);\n * ```\n */\n async completeExtraInfos(client: Client): Promise<void> {\n if (this.cellOutput && this.outputData) {\n return;\n }\n\n const cell = await client.getCell(this.previousOutput);\n if (!cell) {\n return;\n }\n\n this.cellOutput = cell.cellOutput;\n this.outputData = cell.outputData;\n }\n\n /**\n * The extra capacity created when consume this input.\n * This is usually NervosDAO interest, see https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md.\n * And it can also be miners' income. (But this is not implemented yet)\n */\n async getExtraCapacity(client: Client): Promise<Num> {\n return (await this.getCell(client)).getDaoProfit(client);\n }\n\n /**\n * Clone a CellInput.\n *\n * @returns A cloned CellInput instance.\n *\n * @example\n * ```typescript\n * const cellInput1 = cellInput0.clone();\n * ```\n */\n clone(): CellInput {\n return new CellInput(\n this.previousOutput.clone(),\n this.since,\n this.cellOutput?.clone(),\n this.outputData,\n );\n }\n}\nexport const CellInputVec = mol.vector(CellInput);\n\n/**\n * @public\n */\nexport type CellDepLike = {\n outPoint: OutPointLike;\n depType: DepTypeLike;\n};\n/**\n * @public\n */\n@codec(\n mol.struct({\n outPoint: OutPoint,\n depType: DepTypeCodec,\n }),\n)\nexport class CellDep extends Entity.Base<CellDepLike, CellDep>() {\n /**\n * Creates an instance of CellDep.\n *\n * @param outPoint - The outpoint of the cell dependency.\n * @param depType - The dependency type.\n */\n\n constructor(\n public outPoint: OutPoint,\n public depType: DepType,\n ) {\n super();\n }\n\n /**\n * Creates a CellDep instance from a CellDepLike object.\n *\n * @param cellDep - A CellDepLike object or an instance of CellDep.\n * @returns A CellDep instance.\n *\n * @example\n * ```typescript\n * const cellDep = CellDep.from({\n * outPoint: { txHash: \"0x...\", index: 0 },\n * depType: \"depGroup\"\n * });\n * ```\n */\n\n static from(cellDep: CellDepLike): CellDep {\n if (cellDep instanceof CellDep) {\n return cellDep;\n }\n\n return new CellDep(\n OutPoint.from(cellDep.outPoint),\n depTypeFrom(cellDep.depType),\n );\n }\n\n /**\n * Clone a CellDep.\n *\n * @returns A cloned CellDep instance.\n *\n * @example\n * ```typescript\n * const cellDep1 = cellDep0.clone();\n * ```\n */\n clone(): CellDep {\n return new CellDep(this.outPoint.clone(), this.depType);\n }\n}\nexport const CellDepVec = mol.vector(CellDep);\n\n/**\n * @public\n */\nexport type WitnessArgsLike = {\n lock?: HexLike | null;\n inputType?: HexLike | null;\n outputType?: HexLike | null;\n};\n/**\n * @public\n */\n@codec(\n mol.table({\n lock: mol.BytesOpt,\n inputType: mol.BytesOpt,\n outputType: mol.BytesOpt,\n }),\n)\nexport class WitnessArgs extends Entity.Base<WitnessArgsLike, WitnessArgs>() {\n /**\n * Creates an instance of WitnessArgs.\n *\n * @param lock - The optional lock field of the witness.\n * @param inputType - The optional input type field of the witness.\n * @param outputType - The optional output type field of the witness.\n */\n\n constructor(\n public lock?: Hex,\n public inputType?: Hex,\n public outputType?: Hex,\n ) {\n super();\n }\n\n /**\n * Creates a WitnessArgs instance from a WitnessArgsLike object.\n *\n * @param witnessArgs - A WitnessArgsLike object or an instance of WitnessArgs.\n * @returns A WitnessArgs instance.\n *\n * @example\n * ```typescript\n * const witnessArgs = WitnessArgs.from({\n * lock: \"0x...\",\n * inputType: \"0x...\",\n * outputType: \"0x...\"\n * });\n * ```\n */\n\n static from(witnessArgs: WitnessArgsLike): WitnessArgs {\n if (witnessArgs instanceof WitnessArgs) {\n return witnessArgs;\n }\n\n return new WitnessArgs(\n apply(hexFrom, witnessArgs.lock),\n apply(hexFrom, witnessArgs.inputType),\n apply(hexFrom, witnessArgs.outputType),\n );\n }\n}\n\n/**\n * Convert a bytes to a num.\n *\n * @public\n */\nexport function udtBalanceFrom(dataLike: BytesLike): Num {\n const data = bytesFrom(dataLike).slice(0, 16);\n return data.length === 0 ? Zero : numFromBytes(data);\n}\n\nexport const RawTransaction = mol.table({\n version: mol.Uint32,\n cellDeps: CellDepVec,\n headerDeps: mol.Byte32Vec,\n inputs: CellInputVec,\n outputs: CellOutputVec,\n outputsData: mol.BytesVec,\n});\n\n/**\n * @public\n */\nexport type TransactionLike = {\n version?: NumLike | null;\n cellDeps?: CellDepLike[] | null;\n headerDeps?: HexLike[] | null;\n inputs?: CellInputLike[] | null;\n outputs?:\n | (Omit<CellOutputLike, \"capacity\"> &\n Partial<Pick<CellOutputLike, \"capacity\">>)[]\n | null;\n outputsData?: HexLike[] | null;\n witnesses?: HexLike[] | null;\n};\n/**\n * @public\n */\n@codec(\n mol\n .table({\n raw: RawTransaction,\n witnesses: mol.BytesVec,\n })\n .mapIn((txLike: TransactionLike) => {\n const tx = Transaction.from(txLike);\n return {\n raw: tx,\n witnesses: tx.witnesses,\n };\n })\n .mapOut((tx) => Transaction.from({ ...tx.raw, witnesses: tx.witnesses })),\n)\nexport class Transaction extends Entity.Base<TransactionLike, Transaction>() {\n /**\n * Creates an instance of Transaction.\n *\n * @param version - The version of the transaction.\n * @param cellDeps - The cell dependencies of the transaction.\n * @param headerDeps - The header dependencies of the transaction.\n * @param inputs - The inputs of the transaction.\n * @param outputs - The outputs of the transaction.\n * @param outputsData - The data associated with the outputs.\n * @param witnesses - The witnesses of the transaction.\n */\n\n constructor(\n public version: Num,\n public cellDeps: CellDep[],\n public headerDeps: Hex[],\n public inputs: CellInput[],\n public outputs: CellOutput[],\n public outputsData: Hex[],\n public witnesses: Hex[],\n ) {\n super();\n }\n\n /**\n * Creates a default Transaction instance with empty fields.\n *\n * @returns A default Transaction instance.\n *\n * @example\n * ```typescript\n * const defaultTx = Transaction.default();\n * ```\n */\n static default(): Transaction {\n return new Transaction(0n, [], [], [], [], [], []);\n }\n\n /**\n * Copy every properties from another transaction.\n * This method replaces all properties of the current transaction with those from the provided transaction.\n *\n * @param txLike - The transaction-like object to copy properties from.\n *\n * @example\n * ```typescript\n * this.copy(Transaction.default());\n * ```\n */\n copy(txLike: TransactionLike) {\n const tx = Transaction.from(txLike);\n this.version = tx.version;\n this.cellDeps = tx.cellDeps;\n this.headerDeps = tx.headerDeps;\n this.inputs = tx.inputs;\n this.outputs = tx.outputs;\n this.outputsData = tx.outputsData;\n this.witnesses = tx.witnesses;\n }\n\n /**\n * Creates a deep copy of the transaction.\n * This method creates a new Transaction instance with all nested objects cloned,\n * ensuring that modifications to the cloned transaction do not affect the original.\n *\n * @returns A new Transaction instance that is a deep copy of the current transaction.\n *\n * @example\n * ```typescript\n * const originalTx = Transaction.from({\n * version: 0,\n * inputs: [{ previousOutput: { txHash: \"0x...\", index: 0 } }],\n * outputs: [{ capacity: 1000n, lock: lockScript }],\n * outputsData: [\"0x\"],\n * witnesses: [\"0x\"]\n * });\n *\n * const clonedTx = originalTx.clone();\n *\n * // Modifications to clonedTx won't affect originalTx\n * clonedTx.addOutput({ capacity: 2000n, lock: anotherLockScript });\n * console.log(originalTx.outputs.length); // Still 1\n * console.log(clonedTx.outputs.length); // Now 2\n * ```\n *\n * @remarks\n * The clone operation performs deep copying for:\n * - Cell dependencies (cellDeps) - each CellDep is cloned\n * - Inputs - each CellInput is cloned\n * - Outputs - each CellOutput is cloned\n *\n * The following are shallow copied (references to immutable data):\n * - Header dependencies (headerDeps) - Hex strings are immutable\n * - Output data (outputsData) - Hex strings are immutable\n * - Witnesses - Hex strings are immutable\n * - Version - bigint is immutable\n */\n clone(): Transaction {\n return new Transaction(\n this.version,\n this.cellDeps.map((c) => c.clone()),\n this.headerDeps.map((h) => h),\n this.inputs.map((i) => i.clone()),\n this.outputs.map((o) => o.clone()),\n this.outputsData.map((o) => o),\n this.witnesses.map((w) => w),\n );\n }\n\n /**\n * Creates a Transaction instance from a TransactionLike object.\n *\n * @param tx - A TransactionLike object or an instance of Transaction.\n * @returns A Transaction instance.\n *\n * @example\n * ```typescript\n * const transaction = Transaction.from({\n * version: 0,\n * cellDeps: [],\n * headerDeps: [],\n * inputs: [],\n * outputs: [],\n * outputsData: [],\n * witnesses: []\n * });\n * ```\n */\n\n static from(tx: TransactionLike): Transaction {\n if (tx instanceof Transaction) {\n return tx;\n }\n const outputs =\n tx.outputs?.map((output, i) =>\n CellOutput.from(output, tx.outputsData?.[i] ?? []),\n ) ?? [];\n const outputsData = outputs.map((_, i) =>\n hexFrom(tx.outputsData?.[i] ?? \"0x\"),\n );\n if (tx.outputsData != null && outputsData.length < tx.outputsData.length) {\n outputsData.push(\n ...tx.outputsData.slice(outputsData.length).map((d) => hexFrom(d)),\n );\n }\n\n return new Transaction(\n numFrom(tx.version ?? 0),\n tx.cellDeps?.map((cellDep) => CellDep.from(cellDep)) ?? [],\n tx.headerDeps?.map(hexFrom) ?? [],\n tx.inputs?.map((input) => CellInput.from(input)) ?? [],\n outputs,\n outputsData,\n tx.witnesses?.map(hexFrom) ?? [],\n );\n }\n\n /**\n * Creates a Transaction instance from a Lumos skeleton.\n *\n * @param skeleton - The Lumos transaction skeleton.\n * @returns A Transaction instance.\n *\n * @throws Will throw an error if an input's outPoint is missing.\n *\n * @example\n * ```typescript\n * const transaction = Transaction.fromLumosSkeleton(skeleton);\n * ```\n */\n\n static fromLumosSkeleton(\n skeleton: LumosTransactionSkeletonType,\n ): Transaction {\n return Transaction.from({\n version: 0n,\n cellDeps: skeleton.cellDeps.toArray(),\n headerDeps: skeleton.headerDeps.toArray(),\n inputs: skeleton.inputs.toArray().map((input, i) => {\n if (!input.outPoint) {\n throw new Error(\"outPoint is required in input\");\n }\n\n return CellInput.from({\n previousOutput: input.outPoint,\n since: skeleton.inputSinces.get(i, \"0x0\"),\n cellOutput: input.cellOutput,\n outputData: input.data,\n });\n }),\n outputs: skeleton.outputs.toArray().map((output) => output.cellOutput),\n outputsData: skeleton.outputs.toArray().map((output) => output.data),\n witnesses: skeleton.witnesses.toArray(),\n });\n }\n\n /**\n * @deprecated\n * Use ccc.stringify instead.\n * stringify the tx to JSON string.\n */\n stringify(): string {\n return JSON.stringify(this, (_, value) => {\n if (typeof value === \"bigint\") {\n return numToHex(value);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n });\n }\n\n /**\n * Converts the raw transaction data to bytes.\n *\n * @returns A Uint8Array containing the raw transaction bytes.\n *\n * @example\n * ```typescript\n * const rawTxBytes = transaction.rawToBytes();\n * ```\n */\n rawToBytes(): Bytes {\n return RawTransaction.encode(this);\n }\n\n /**\n * Calculates the hash of the transaction without witnesses. This is the transaction hash in the usual sense.\n * To calculate the hash of the whole transaction including the witnesses, use transaction.hashFull() instead.\n *\n * @returns The hash of the transaction.\n *\n * @example\n * ```typescript\n * const txHash = transaction.hash();\n * ```\n */\n hash(): Hex {\n return hashCkb(this.rawToBytes());\n }\n\n /**\n * Calculates the hash of the transaction with witnesses.\n *\n * @returns The hash of the transaction with witnesses.\n *\n * @example\n * ```typescript\n * const txFullHash = transaction.hashFull();\n * ```\n */\n hashFull(): Hex {\n return hashCkb(this.toBytes());\n }\n\n /**\n * Hashes a witness and updates the hasher.\n *\n * @param witness - The witness to hash.\n * @param hasher - The hasher instance to update.\n *\n * @example\n * ```typescript\n * Transaction.hashWitnessToHasher(\"0x...\", hasher);\n * ```\n */\n\n static hashWitnessToHasher(witness: HexLike, hasher: Hasher) {\n const raw = bytesFrom(hexFrom(witness));\n hasher.update(numToBytes(raw.length, 8));\n hasher.update(raw);\n }\n\n /**\n * Computes the signing hash information for a given script.\n *\n * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.\n * @param client - The client for complete extra infos in the transaction.\n * @returns A promise that resolves to an object containing the signing message and the witness position,\n * or undefined if no matching input is found.\n *\n * @example\n * ```typescript\n * const signHashInfo = await tx.getSignHashInfo(scriptLike, client);\n * if (signHashInfo) {\n * console.log(signHashInfo.message); // Outputs the signing message\n * console.log(signHashInfo.position); // Outputs the witness position\n * }\n * ```\n */\n async getSignHashInfo(\n scriptLike: ScriptLike,\n client: Client,\n hasher: Hasher = new HasherCkb(),\n ): Promise<{ message: Hex; position: number } | undefined> {\n const script = Script.from(scriptLike);\n let position = -1;\n hasher.update(this.hash());\n\n for (let i = 0; i < this.witnesses.length; i += 1) {\n const input = this.inputs[i];\n if (input) {\n const { cellOutput } = await input.getCell(client);\n\n if (!script.eq(cellOutput.lock)) {\n continue;\n }\n\n if (position === -1) {\n position = i;\n }\n }\n\n if (position === -1) {\n return undefined;\n }\n\n Transaction.hashWitnessToHasher(this.witnesses[i], hasher);\n }\n\n if (position === -1) {\n return undefined;\n }\n\n return {\n message: hasher.digest(),\n position,\n };\n }\n\n /**\n * Find the first occurrence of a input with the specified lock id\n *\n * @param scriptIdLike - The script associated with the transaction, represented as a ScriptLike object without args.\n * @param client - The client for complete extra infos in the transaction.\n * @returns A promise that resolves to the found index\n *\n * @example\n * ```typescript\n * const index = await tx.findInputIndexByLockId(scriptIdLike, client);\n * ```\n */\n async findInputIndexByLockId(\n scriptIdLike: Pick<ScriptLike, \"codeHash\" | \"hashType\">,\n client: Client,\n ): Promise<number | undefined> {\n const script = Script.from({ ...scriptIdLike, args: \"0x\" });\n\n for (let i = 0; i < this.inputs.length; i += 1) {\n const { cellOutput } = await this.inputs[i].getCell(client);\n\n if (\n script.codeHash === cellOutput.lock.codeHash &&\n script.hashType === cellOutput.lock.hashType\n ) {\n return i;\n }\n }\n }\n\n /**\n * Find the first occurrence of a input with the specified lock\n *\n * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.\n * @param client - The client for complete extra infos in the transaction.\n * @returns A promise that resolves to the found index, or undefined if no matching input is found.\n *\n * @example\n * ```typescript\n * const index = await tx.findInputIndexByLock(scriptLike, client);\n * ```\n */\n async findInputIndexByLock(\n scriptLike: ScriptLike,\n client: Client,\n ): Promise<number | undefined> {\n const script = Script.from(scriptLike);\n\n for (let i = 0; i < this.inputs.length; i += 1) {\n const { cellOutput } = await this.inputs[i].getCell(client);\n\n if (script.eq(cellOutput.lock)) {\n return i;\n }\n }\n }\n\n /**\n * Find the last occurrence of a input with the specified lock\n *\n * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.\n * @param client - The client for complete extra infos in the transaction.\n * @returns A promise that resolves to the found index, or undefined if no matching input is found.\n *\n * @example\n * ```typescript\n * const index = await tx.findLastInputIndexByLock(scriptLike, client);\n * ```\n */\n async findLastInputIndexByLock(\n scriptLike: ScriptLike,\n client: Client,\n ): Promise<number | undefined> {\n const script = Script.from(scriptLike);\n\n for (let i = this.inputs.length - 1; i >= 0; i -= 1) {\n const { cellOutput } = await this.inputs[i].getCell(client);\n\n if (script.eq(cellOutput.lock)) {\n return i;\n }\n }\n }\n\n /**\n * Add cell deps if they are not existed\n *\n * @param cellDepLikes - The cell deps to add\n *\n * @example\n * ```typescript\n * tx.addCellDeps(cellDep);\n * ```\n */\n addCellDeps(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void {\n cellDepLikes.flat().forEach((cellDepLike) => {\n const cellDep = CellDep.from(cellDepLike);\n if (this.cellDeps.some((c) => c.eq(cellDep))) {\n return;\n }\n\n this.cellDeps.push(cellDep);\n });\n }\n\n /**\n * Add cell deps at the start if they are not existed\n *\n * @param cellDepLikes - The cell deps to add\n *\n * @example\n * ```typescript\n * tx.addCellDepsAtBegin(cellDep);\n * ```\n */\n addCellDepsAtStart(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void {\n cellDepLikes.flat().forEach((cellDepLike) => {\n const cellDep = CellDep.from(cellDepLike);\n if (this.cellDeps.some((c) => c.eq(cellDep))) {\n return;\n }\n\n this.cellDeps.unshift(cellDep);\n });\n }\n\n /**\n * Add cell dep from infos if they are not existed\n *\n * @param client - A client for searching cell deps\n * @param cellDepInfoLikes - The cell dep infos to add\n *\n * @example\n * ```typescript\n * tx.addCellDepInfos(client, cellDepInfos);\n * ```\n */\n async addCellDepInfos(\n client: Client,\n ...cellDepInfoLikes: (CellDepInfoLike | CellDepInfoLike[])[]\n ): Promise<void> {\n this.addCellDeps(await client.getCellDeps(...cellDepInfoLikes));\n }\n\n /**\n * Add cell deps from known script\n *\n * @param client - The client for searching known script and cell deps\n * @param scripts - The known scripts to add\n *\n * @example\n * ```typescript\n * tx.addCellDepsOfKnownScripts(client, KnownScript.OmniLock);\n * ```\n */\n async addCellDepsOfKnownScripts(\n client: Client,\n ...scripts: (KnownScript | KnownScript[])[]\n ): Promise<void> {\n await Promise.all(\n scripts\n .flat()\n .map(async (script) =>\n this.addCellDepInfos(\n client,\n (await client.getKnownScript(script)).cellDeps,\n ),\n ),\n );\n }\n\n /**\n * Set output data at index.\n *\n * @param index - The index of the output data.\n * @param data - The data to set.\n *\n * @example\n * ```typescript\n * tx.setOutputDataAt(0, \"0x00\");\n * ```\n */\n setOutputDataAt(index: number, data: HexLike): void {\n if (this.outputsData.length < index) {\n this.outputsData.push(\n ...Array.from(\n new Array(index - this.outputsData.length),\n (): Hex => \"0x\",\n ),\n );\n }\n\n this.outputsData[index] = hexFrom(data);\n }\n\n /**\n * get input\n *\n * @param index - The cell input index\n *\n * @example\n * ```typescript\n * await tx.getInput(0);\n * ```\n */\n getInput(index: NumLike): CellInput | undefined {\n return this.inputs[Number(numFrom(index))];\n }\n /**\n * add input\n *\n * @param inputLike - The cell input.\n *\n * @example\n * ```typescript\n * await tx.addInput({ });\n * ```\n */\n addInput(inputLike: CellInputLike): number {\n if (this.witnesses.length > this.inputs.length) {\n this.witnesses.splice(this.inputs.length, 0, \"0x\");\n }\n\n return this.inputs.push(CellInput.from(inputLike));\n }\n\n /**\n * get output\n *\n * @param index - The cell output index\n *\n * @example\n * ```typescript\n * await tx.getOutput(0);\n * ```\n */\n getOutput(index: NumLike): CellAny | undefined {\n const i = Number(numFrom(index));\n if (i >= this.outputs.length) {\n return;\n }\n return CellAny.from({\n cellOutput: this.outputs[i],\n outputData: this.outputsData[i] ?? \"0x\",\n });\n }\n\n /**\n * Provides an iterable over the transaction's output cells.\n *\n * This getter is a convenient way to iterate through all the output cells (`CellAny`)\n * of the transaction, combining the `outputs` and `outputsData` arrays.\n * It can be used with `for...of` loops or other iterable-consuming patterns.\n *\n * @public\n * @category Getter\n * @returns An `Iterable<CellAny>` that yields each output cell of the transaction.\n *\n * @example\n * ```typescript\n * for (const cell of tx.outputCells) {\n * console.log(`Output cell capacity: ${cell.cellOutput.capacity}`);\n * }\n * ```\n */\n get outputCells(): Iterable<CellAny> {\n const { outputs, outputsData } = this;\n\n function* generator(): Generator<CellAny> {\n for (let i = 0; i < outputs.length; i++) {\n yield CellAny.from({\n cellOutput: outputs[i],\n outputData: outputsData[i] ?? \"0x\",\n });\n }\n }\n\n return generator();\n }\n\n /**\n * Adds an output to the transaction.\n *\n * This method supports two overloads for adding an output:\n * 1. By providing a `CellAnyLike` object, which encapsulates both `cellOutput` and `outputData`.\n * 2. By providing a `CellOutputLike` object and an optional `outputData`.\n *\n * @param cellOrOutputLike - A cell-like object containing both cell output and data, or just the cell output object.\n * @param outputDataLike - Optional data for the cell output. Defaults to \"0x\" if not provided in the first argument.\n * @returns The new number of outputs in the transaction.\n *\n * @example\n * ```typescript\n * // 1. Add an output using a CellAnyLike object\n * const newLength1 = tx.addOutput({\n * cellOutput: { lock: recipientLock }, // capacity is calculated automatically\n * outputData: \"0x1234\",\n * });\n *\n * // 2. Add an output using CellOutputLike and data separately\n * const newLength2 = tx.addOutput({ lock: recipientLock }, \"0xabcd\");\n * ```\n */\n addOutput(cellLike: CellAnyLike): number;\n addOutput(\n outputLike: CellOutputLike,\n outputDataLike?: HexLike | null,\n ): number;\n addOutput(\n cellOrOutputLike: CellAnyLike | CellOutputLike,\n outputDataLike?: HexLike | null,\n ): number {\n const cell =\n \"cellOutput\" in cellOrOutputLike\n ? CellAny.from(cellOrOutputLike)\n : CellAny.from({\n cellOutput: cellOrOutputLike,\n outputData: outputDataLike,\n });\n\n const len = this.outputs.push(cell.cellOutput);\n this.setOutputDataAt(len - 1, cell.outputData);\n\n return len;\n }\n\n /**\n * Get witness at index as WitnessArgs\n *\n * @param index - The index of the witness.\n * @returns The witness parsed as WitnessArgs.\n *\n * @example\n * ```typescript\n * const witnessArgs = await tx.getWitnessArgsAt(0);\n * ```\n */\n getWitnessArgsAt(index: number): WitnessArgs | undefined {\n const rawWitness = this.witnesses[index];\n return (rawWitness ?? \"0x\") !== \"0x\"\n ? WitnessArgs.fromBytes(rawWitness)\n : undefined;\n }\n\n /**\n * Set witness at index by WitnessArgs\n *\n * @param index - The index of the witness.\n * @param witness - The WitnessArgs to set.\n *\n * @example\n * ```typescript\n * await tx.setWitnessArgsAt(0, witnessArgs);\n * ```\n */\n setWitnessArgsAt(index: number, witness: WitnessArgs): void {\n this.setWitnessAt(index, witness.toBytes());\n }\n\n /**\n * Set witness at index\n *\n * @param index - The index of the witness.\n * @param witness - The witness to set.\n *\n * @example\n * ```typescript\n * await tx.setWitnessAt(0, witness);\n * ```\n */\n setWitnessAt(index: number, witness: HexLike): void {\n if (this.witnesses.length < index) {\n this.witnesses.push(\n ...Array.from(\n new Array(index - this.witnesses.length),\n (): Hex => \"0x\",\n ),\n );\n }\n\n this.witnesses[index] = hexFrom(witness);\n }\n\n /**\n * Prepare dummy witness for sighash all method\n *\n * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.\n * @param lockLen - The length of dummy lock bytes.\n * @param client - The client for complete extra infos in the transaction.\n * @returns A promise that resolves to the prepared transaction\n *\n * @example\n * ```typescript\n * await tx.prepareSighashAllWitness(scriptLike, 85, client);\n * ```\n */\n async prepareSighashAllWitness(\n scriptLike: ScriptLike,\n lockLen: number,\n client: Client,\n ): Promise<void> {\n const position = await this.findInputIndexByLock(scriptLike, client);\n if (position === undefined) {\n return;\n }\n\n const witness = this.getWitnessArgsAt(position) ?? WitnessArgs.from({});\n witness.lock = hexFrom(Array.from(new Array(lockLen), () => 0));\n this.setWitnessArgsAt(position, witness);\n }\n\n async getInputsCapacityExtra(client: Client): Promise<Num> {\n return reduceAsync(\n this.inputs,\n async (acc, input) => acc + (await input.getExtraCapacity(client)),\n Zero,\n );\n }\n\n // This also includes extra amount\n async getInputsCapacity(client: Client): Promise<Num> {\n return (\n (await reduceAsync(\n this.inputs,\n async (acc, input) => {\n const {\n cellOutput: { capacity },\n } = await input.getCell(client);\n\n return acc + capacity;\n },\n Zero,\n )) + (await this.getInputsCapacityExtra(client))\n );\n }\n\n getOutputsCapacity(): Num {\n return this.outputs.reduce((acc, { capacity }) => acc + capacity, Zero);\n }\n\n async getInputsUdtBalance(client: Client, type: ScriptLike): Promise<Num> {\n return reduceAsync(\n this.inputs,\n async (acc, input) => {\n const { cellOutput, outputData } = await input.getCell(client);\n if (!cellOutput.type?.eq(type)) {\n return;\n }\n\n return acc + udtBalanceFrom(outputData);\n },\n Zero,\n );\n }\n\n getOutputsUdtBalance(type: ScriptLike): Num {\n return this.outputs.reduce((acc, output, i) => {\n if (!output.type?.eq(type)) {\n return acc;\n }\n\n return acc + udtBalanceFrom(this.outputsData[i]);\n }, Zero);\n }\n\n async completeInputs<T>(\n from: Signer,\n filter: ClientCollectableSearchKeyFilterLike,\n accumulator: (\n acc: T,\n v: Cell,\n i: number,\n array: Cell[],\n ) => Promise<T | undefined> | T | undefined,\n init: T,\n ): Promise<{\n addedCount: number;\n accumulated?: T;\n }> {\n const collectedCells = [];\n\n let acc: T = init;\n let fulfilled = false;\n for await (const cell of from.findCells(filter, true)) {\n if (\n this.inputs.some(({ previousOutput }) =>\n previousOutput.eq(cell.outPoint),\n )\n ) {\n continue;\n }\n const i = collectedCells.push(cell);\n const next = await Promise.resolve(\n accumulator(acc, cell, i - 1, collectedCells),\n );\n if (next === undefined) {\n fulfilled = true;\n break;\n }\n acc = next;\n }\n\n collectedCells.forEach((cell) => this.addInput(cell));\n if (fulfilled) {\n return {\n addedCount: collectedCells.length,\n };\n }\n\n return {\n addedCount: collectedCells.length,\n accumulated: acc,\n };\n }\n\n async completeInputsByCapacity(\n from: Signer,\n capacityTweak?: NumLike,\n filter?: ClientCollectableSearchKeyFilterLike,\n ): Promise<number> {\n const expectedCapacity =\n this.getOutputsCapacity() + numFrom(capacityTweak ?? 0);\n const inputsCapacity = await this.getInputsCapacity(from.client);\n if (inputsCapacity >= expectedCapacity) {\n return 0;\n }\n\n const { addedCount, accumulated } = await this.completeInputs(\n from,\n filter ?? {\n scriptLenRange: [0, 1],\n outputDataLenRange: [0, 1],\n },\n (acc, { cellOutput: { capacity } }) => {\n const sum = acc + capacity;\n return sum >= expectedCapacity ? undefined : sum;\n },\n inputsCapacity,\n );\n\n if (accumulated === undefined) {\n return addedCount;\n }\n\n throw new ErrorTransactionInsufficientCapacity(\n expectedCapacity - accumulated,\n );\n }\n\n async completeInputsAll(\n from: Signer,\n filter?: ClientCollectableSearchKeyFilterLike,\n ): Promise<number> {\n const { addedCount } = await this.completeInputs(\n from,\n filter ?? {\n scriptLenRange: [0, 1],\n outputDataLenRange: [0, 1],\n },\n (acc, { cellOutput: { capacity } }) => acc + capacity,\n Zero,\n );\n\n return addedCount;\n }\n\n /**\n * Complete inputs by UDT balance\n *\n * This method succeeds only if enough balance is collected.\n *\n * It will try to collect at least two inputs, even when the first input already contains enough balance, to avoid extra occupation fees introduced by the change cell. An edge case: If the first cell has the same amount as the output, a new cell is not needed.\n * @param from - The signer to complete the inputs.\n * @param type - The type script of the UDT.\n * @param balanceTweak - The tweak of the balance.\n * @returns A promise that resolves to the number of inputs added.\n */\n async completeInputsByUdt(\n from: Signer,\n type: ScriptLike,\n balanceTweak?: NumLike,\n ): Promise<number> {\n const expectedBalance =\n this.getOutputsUdtBalance(type) + numFrom(balanceTweak ?? 0);\n if (expectedBalance === Zero) {\n return 0;\n }\n\n const [inputsBalance, inputsCount] = await reduceAsync(\n this.inputs,\n async ([balanceAcc, countAcc], input) => {\n const { cellOutput, outputData } = await input.getCell(from.client);\n if (!cellOutput.type?.eq(type)) {\n return;\n }\n\n return [balanceAcc + udtBalanceFrom(outputData), countAcc + 1];\n },\n [Zero, 0],\n );\n\n if (\n inputsBalance === expectedBalance ||\n (inputsBalance >= expectedBalance && inputsCount >= 2)\n ) {\n return 0;\n }\n\n const { addedCount, accumulated } = await this.completeInputs(\n from,\n {\n script: type,\n outputDataLenRange: [16, numFrom(\"0xffffffff\")],\n },\n (acc, { outputData }, _i, collected) => {\n const balance = udtBalanceFrom(outputData);\n const sum = acc + balance;\n return sum === expectedBalance ||\n (sum >= expectedBalance && inputsCount + collected.length >= 2)\n ? undefined\n : sum;\n },\n inputsBalance,\n );\n\n if (accumulated === undefined || accumulated >= expectedBalance) {\n return addedCount;\n }\n\n throw new ErrorTransactionInsufficientCoin(\n expectedBalance - accumulated,\n type,\n );\n }\n\n async completeInputsAddOne(\n from: Signer,\n filter?: ClientCollectableSearchKeyFilterLike,\n ): Promise<number> {\n const { addedCount, accumulated } = await this.completeInputs(\n from,\n filter ?? {\n scriptLenRange: [0, 1],\n outputDataLenRange: [0, 1],\n },\n () => undefined,\n true,\n );\n\n if (accumulated === undefined) {\n return addedCount;\n }\n\n throw new Error(`Insufficient CKB, need at least one new cell`);\n }\n\n async completeInputsAtLeastOne(\n from: Signer,\n filter?: ClientCollectableSearchKeyFilterLike,\n ): Promise<number> {\n if (this.inputs.length > 0) {\n return 0;\n }\n\n return this.completeInputsAddOne(from, filter);\n }\n\n async getFee(client: Client): Promise<Num> {\n return (await this.getInputsCapacity(client)) - this.getOutputsCapacity();\n }\n\n async getFeeRate(client: Client): Promise<Num> {\n return (\n ((await this.getFee(client)) * numFrom(1000)) /\n numFrom(this.toBytes().length + 4)\n );\n }\n\n estimateFee(feeRate: NumLike): Num {\n const txSize = this.toBytes().length + 4;\n // + 999 then / 1000 to ceil the calculated fee\n return (numFrom(txSize) * numFrom(feeRate) + numFrom(999)) / numFrom(1000);\n }\n\n /**\n * Completes the transaction fee by adding inputs and handling change outputs.\n * This method automatically calculates the required fee based on the transaction size and fee rate,\n * adds necessary inputs to cover the fee, and handles change outputs through the provided change function.\n *\n * @param from - The signer to complete inputs from and prepare the transaction.\n * @param change - A function that handles change capacity. It receives the transaction and excess capacity,\n * and should return the additional capacity needed (0 if change is handled successfully,\n * positive number if more capacity is needed for change cell creation).\n * @param expectedFeeRate - The expected fee rate in shannons per 1000 bytes. If not provided,\n * it will be fetched from the client.\n * @param filter - Optional filter for selecting cells when adding inputs.\n * @param options - Optional configuration object.\n * @param options.feeRateBlockRange - Block range for fee rate calculation when expectedFeeRate is not provided.\n * @param options.maxFeeRate - Maximum allowed fee rate.\n * @param options.shouldAddInputs - Whether to add inputs automatically. Defaults to true.\n * @returns A promise that resolves to a tuple containing:\n * - The number of inputs added during the process\n * - A boolean indicating whether change outputs were created (true) or fee was paid without change (false)\n *\n * @throws {ErrorTransactionInsufficientCapacity} When there's not enough capacity to cover the fee.\n * @throws {Error} When the change function doesn't properly handle the available capacity.\n *\n * @example\n * ```typescript\n * const [addedInputs, hasChange] = await tx.completeFee(\n * signer,\n * (tx, capacity) => {\n * if (capacity >= 61_00000000n) { // Minimum for a change cell\n * tx.addOutput({ capacity, lock: changeScript });\n * return 0;\n * }\n * return 61_00000000n; // Need more capacity for change cell\n * },\n * 1000n // 1000 shannons per 1000 bytes\n * );\n * ```\n */\n async completeFee(\n from: Signer,\n change: (tx: Transaction, capacity: Num) => Promise<NumLike> | NumLike,\n expectedFeeRate?: NumLike,\n filter?: ClientCollectableSearchKeyFilterLike,\n options?: {\n feeRateBlockRange?: NumLike;\n maxFeeRate?: NumLike;\n shouldAddInputs?: boolean;\n },\n ): Promise<[number, boolean]> {\n const feeRate =\n expectedFeeRate ??\n (await from.client.getFeeRate(options?.feeRateBlockRange, options));\n\n // Complete all inputs extra infos for cache\n await this.getInputsCapacity(from.client);\n\n let leastFee = Zero;\n let leastExtraCapacity = Zero;\n let collected = 0;\n\n // ===\n // Usually, for the worst situation, three iterations are needed\n // 1. First attempt to complete the transaction.\n // 2. Not enough capacity for the change cell.\n // 3. Fee increased by the change cell.\n // ===\n while (true) {\n collected += await (async () => {\n if (!(options?.shouldAddInputs ?? true)) {\n return 0;\n }\n\n try {\n return await this.completeInputsByCapacity(\n from,\n leastFee + leastExtraCapacity,\n filter,\n );\n } catch (err) {\n if (\n err instanceof ErrorTransactionInsufficientCapacity &&\n leastExtraCapacity !== Zero\n ) {\n throw new ErrorTransactionInsufficientCapacity(err.amount, {\n isForChange: true,\n });\n }\n\n throw err;\n }\n })();\n\n const fee = await this.getFee(from.client);\n if (fee < leastFee + leastExtraCapacity) {\n // Not enough capacity are collected, it should only happens when shouldAddInputs is false\n throw new ErrorTransactionInsufficientCapacity(\n leastFee + leastExtraCapacity - fee,\n { isForChange: leastExtraCapacity !== Zero },\n );\n }\n\n await from.prepareTransaction(this);\n if (leastFee === Zero) {\n // The initial fee is calculated based on prepared transaction\n // This should only happens during the first iteration\n leastFee = this.estimateFee(feeRate);\n }\n // The extra capacity paid the fee without a change\n // leastExtraCapacity should be 0 here, otherwise we should failed in the previous check\n // So this only happens in the first iteration\n if (fee === leastFee) {\n return [collected, false];\n }\n\n // Invoke the change function on a transaction multiple times may cause problems, so we clone it\n const tx = this.clone();\n const needed = numFrom(await Promise.resolve(change(tx, fee - leastFee)));\n if (needed > Zero) {\n // No enough extra capacity to create new cells for change, collect inputs again\n leastExtraCapacity = needed;\n continue;\n }\n\n if ((await tx.getFee(from.client)) !== leastFee) {\n throw new Error(\n \"The change function doesn't use all available capacity\",\n );\n }\n\n // New change cells created, update the fee\n await from.prepareTransaction(tx);\n const changedFee = tx.estimateFee(feeRate);\n if (leastFee > changedFee) {\n throw new Error(\"The change function removed existed transaction data\");\n }\n // The fee has been paid\n if (leastFee === changedFee) {\n this.copy(tx);\n return [collected, true];\n }\n\n // The fee after changing is more than the original fee\n leastFee = changedFee;\n }\n }\n\n /**\n * Completes the transaction fee by adding inputs and creating a change output with the specified lock script.\n * This is a convenience method that automatically creates a change cell with the provided lock script\n * when there's excess capacity after paying the transaction fee.\n *\n * @param from - The signer to complete inputs from and prepare the transaction.\n * @param change - The lock script for the change output cell.\n * @param feeRate - Optional fee rate in shannons per 1000 bytes. If not provided, it will be fetched from the client.\n * @param filter - Optional filter for selecting cells when adding inputs.\n * @param options - Optional configuration object.\n * @param options.feeRateBlockRange - Block range for fee rate calculation when feeRate is not provided.\n * @param options.maxFeeRate - Maximum allowed fee rate.\n * @param options.shouldAddInputs - Whether to add inputs automatically. Defaults to true.\n * @returns A promise that resolves to a tuple containing:\n * - The number of inputs added during the process\n * - A boolean indicating whether change outputs were created (true) or fee was paid without change (false)\n *\n * @example\n * ```typescript\n * const changeScript = Script.from({\n * codeHash: \"0x...\",\n * hashType: \"type\",\n * args: \"0x...\"\n * });\n *\n * const [addedInputs, hasChange] = await tx.completeFeeChangeToLock(\n * signer,\n * changeScript,\n * 1000n // 1000 shannons per 1000 bytes\n * );\n * ```\n */\n completeFeeChangeToLock(\n from: Signer,\n change: ScriptLike,\n feeRate?: NumLike,\n filter?: ClientCollectableSearchKeyFilterLike,\n options?: {\n feeRateBlockRange?: NumLike;\n maxFeeRate?: NumLike;\n shouldAddInputs?: boolean;\n },\n ): Promise<[number, boolean]> {\n const script = Script.from(change);\n\n return this.completeFee(\n from,\n (tx, capacity) => {\n const changeCell = CellOutput.from({ capacity: 0, lock: script });\n const occupiedCapacity = fixedPointFrom(changeCell.occupiedSize);\n if (capacity < occupiedCapacity) {\n return occupiedCapacity;\n }\n changeCell.capacity = capacity;\n tx.addOutput(changeCell);\n return 0;\n },\n feeRate,\n filter,\n options,\n );\n }\n\n /**\n * Completes the transaction fee using the signer's recommended address for change.\n * This is a convenience method that automatically uses the signer's recommended\n * address as the change destination, making it easier to complete transactions\n * without manually specifying a change address.\n *\n * @param from - The signer to complete inputs from and prepare the transaction.\n * @param feeRate - Optional fee rate in shannons per 1000 bytes. If not provided, it will be fetched from the client.\n * @param filter - Optional filter for selecting cells when adding inputs.\n * @param options - Optional configuration object.\n * @param options.feeRateBlockRange - Block range for fee rate calculation when feeRate is not provided.\n * @param options.maxFeeRate - Maximum allowed fee rate.\n * @param options.shouldAddInputs - Whether to add inputs automatically. Defaults to true.\n * @returns A promise that resolves to a tuple containing:\n * - The number of inputs added during the process\n * - A boolean indicating whether change outputs were created (true) or fee was paid without change (false)\n *\n * @example\n * ```typescript\n * const [addedInputs, hasChange] = await tx.completeFeeBy(\n * signer,\n * 1000n // 1000 shannons per 1000 bytes\n * );\n *\n * // Change will automatically go to signer's recommended address\n * ```\n */\n async completeFeeBy(\n from: Signer,\n feeRate?: NumLike,\n filter?: ClientCollectableSearchKeyFilterLike,\n options?: {\n feeRateBlockRange?: NumLike;\n maxFeeRate?: NumLike;\n shouldAddInputs?: boolean;\n },\n ): Promise<[number, boolean]> {\n const { script } = await from.getRecommendedAddressObj();\n\n return this.completeFeeChangeToLock(from, script, feeRate, filter, options);\n }\n\n /**\n * Completes the transaction fee by adding excess capacity to an existing output.\n * Instead of creating a new change output, this method adds any excess capacity\n * to the specified existing output in the transaction.\n *\n * @param from - The signer to complete inputs from and prepare the transaction.\n * @param index - The index of the existing output to add excess capacity to.\n * @param feeRate - Optional fee rate in shannons per 1000 bytes. If not provided, it will be fetched from the client.\n * @param filter - Optional filter for selecting cells when adding inputs.\n * @param options - Optional configuration object.\n * @param options.feeRateBlockRange - Block range for fee rate calculation when feeRate is not provided.\n * @param options.maxFeeRate - Maximum allowed fee rate.\n * @param options.shouldAddInputs - Whether to add inputs automatically. Defaults to true.\n * @returns A promise that resolves to a tuple containing:\n * - The number of inputs added during the process\n * - A boolean indicating whether change was applied (true) or fee was paid without change (false)\n *\n * @throws {Error} When the specified output index doesn't exist.\n *\n * @example\n * ```typescript\n * // Add excess capacity to the first output (index 0)\n * const [addedInputs, hasChange] = await tx.completeFeeChangeToOutput(\n * signer,\n * 0, // Output index\n * 1000n // 1000 shannons per 1000 bytes\n * );\n * ```\n */\n completeFeeChangeToOutput(\n from: Signer,\n index: NumLike,\n feeRate?: NumLike,\n filter?: ClientCollectableSearchKeyFilterLike,\n options?: {\n feeRateBlockRange?: NumLike;\n maxFeeRate?: NumLike;\n shouldAddInputs?: boolean;\n },\n ): Promise<[number, boolean]> {\n const change = Number(numFrom(index));\n if (!this.outputs[change]) {\n throw new Error(\"Non-existed output to change\");\n }\n return this.completeFee(\n from,\n (tx, capacity) => {\n tx.outputs[change].capacity += capacity;\n return 0;\n },\n feeRate,\n filter,\n options,\n );\n }\n}\n\n/**\n * Checks whether a NervosDAO transaction exceeds the 64-output limit.\n * Returns true if the transaction is DAO-related and has more than 64 outputs.\n * Short-circuits to false when outputs <= 64.\n *\n * @param tx - The transaction to check\n * @param client - CKB client for resolving the NervosDAO script and input cell info\n * @returns true if the DAO output limit is exceeded\n */\nexport async function isDaoOutputLimitExceeded(\n tx: Transaction,\n client: Client,\n): Promise<boolean> {\n if (tx.outputs.length <= 64) {\n return false;\n }\n\n const { codeHash, hashType } = await client.getKnownScript(\n KnownScript.NervosDao,\n );\n const dao = Script.from({ codeHash, hashType, args: \"0x\" });\n\n if (tx.outputs.some((o) => o.type?.eq(dao))) {\n return true;\n }\n\n for (const input of tx.inputs) {\n await input.completeExtraInfos(client);\n if (input.cellOutput?.type?.eq(dao)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Calculate Nervos DAO profit between two blocks.\n * This function computes the profit earned from a Nervos DAO deposit\n * based on the capacity and the time period between deposit and withdrawal.\n *\n * @param profitableCapacity - The capacity that earns profit (total capacity minus occupied capacity).\n * @param depositHeaderLike - The block header when the DAO deposit was made.\n * @param withdrawHeaderLike - The block header when the DAO withdrawal is made.\n * @returns The profit amount in CKB (capacity units).\n *\n * @example\n * ```typescript\n * const profit = calcDaoProfit(\n * ccc.fixedPointFrom(100), // 100 CKB profitable capacity\n * depositHeader,\n * withdrawHeader\n * );\n * console.log(`Profit: ${profit} shannons`);\n * ```\n *\n * @see {@link https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md | Nervos DAO RFC}\n */\nexport function calcDaoProfit(\n profitableCapacity: NumLike,\n depositHeaderLike: ClientBlockHeaderLike,\n withdrawHeaderLike: ClientBlockHeaderLike,\n): Num {\n const depositHeader = ClientBlockHeader.from(depositHeaderLike);\n const withdrawHeader = ClientBlockHeader.from(withdrawHeaderLike);\n\n const profitableSize = numFrom(profitableCapacity);\n\n return (\n (profitableSize * withdrawHeader.dao.ar) / depositHeader.dao.ar -\n profitableSize\n );\n}\n\n/**\n * Calculate claimable epoch for Nervos DAO withdrawal.\n * This function determines the earliest epoch when a Nervos DAO withdrawal\n * can be claimed based on the deposit and withdrawal epochs.\n *\n * @param depositHeader - The block header when the DAO deposit was made.\n * @param withdrawHeader - The block header when the DAO withdrawal was initiated.\n * @returns The epoch when the withdrawal can be claimed, represented as an Epoch instance.\n *\n * @example\n * ```typescript\n * const epoch = calcDaoClaimEpoch(depositHeader, withdrawHeader);\n * console.log(`Can claim at epoch: ${epoch.integer}, numerator: ${epoch.numerator}, denominator: ${epoch.denominator}`);\n * ```\n *\n * @remarks\n * The Nervos DAO has a minimum lock period of 180 epochs (~30 days).\n * This function calculates the exact epoch when the withdrawal becomes claimable\n * based on the deposit epoch and withdrawal epoch timing.\n *\n * @see {@link https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md | Nervos DAO RFC}\n */\nexport function calcDaoClaimEpoch(\n depositHeader: ClientBlockHeaderLike,\n withdrawHeader: ClientBlockHeaderLike,\n): Epoch {\n const deposit = ClientBlockHeader.from(depositHeader).epoch.normalizeBase();\n const withdraw = ClientBlockHeader.from(withdrawHeader).epoch.normalizeBase();\n\n const fullCycle = numFrom(180);\n const partialCycle = (withdraw.integer - deposit.integer) % fullCycle;\n let withdrawInteger = withdraw.integer;\n if (\n partialCycle !== Zero ||\n // deposit.numerator withdraw.numerator\n // --------------------- <= ----------------------\n // deposit.denominator withdraw.denominator\n deposit.numerator * withdraw.denominator <=\n withdraw.numerator * deposit.denominator\n ) {\n // Need to wait for the next cycle\n withdrawInteger += -partialCycle + fullCycle;\n }\n\n return new Epoch(withdrawInteger, deposit.numerator, deposit.denominator);\n}\n","import { bech32, bech32m } from \"bech32\";\nimport { Script, hashTypeFromBytes } from \"../ckb/index.js\";\nimport { Client, KnownScript } from \"../client/index.js\";\nimport { hexFrom } from \"../hex/index.js\";\nimport { type AddressLike } from \"./index.js\";\n\n/**\n * Parses an address string into an address information object.\n *\n * @param address - The address string to parse.\n * @returns An object containing the address prefix, address format, and payload array.\n *\n * @throws Will throw an error if the address format is unknown.\n *\n * @example\n * ```typescript\n * const addressInfo = addressPayloadFromString(\"ckt1112139193129\");\n * console.log(addressInfo.prefix); // Outputs the address prefix\n * console.log(addressInfo.format); // Outputs the address format\n * console.log(addressInfo.payload); // Outputs the payload array\n * ```\n */\n\nexport function addressPayloadFromString(address: string): {\n prefix: string;\n format: AddressFormat;\n payload: number[];\n} {\n // Try parse full format address\n try {\n const { words, prefix } = bech32m.decode(address, ADDRESS_BECH32_LIMIT);\n const decoded = bech32m.fromWords(words);\n const formatType: AddressFormat = decoded[0];\n const payload = decoded.slice(1);\n\n if (formatType === AddressFormat.Full) {\n return { prefix, format: AddressFormat.Full, payload };\n }\n } catch (_) {}\n\n // Try parse legacy 2019 format address\n try {\n const { prefix, words } = bech32.decode(address, ADDRESS_BECH32_LIMIT);\n const decoded = bech32.fromWords(words);\n const formatType: AddressFormat = decoded[0];\n const payload = decoded.slice(1);\n if (\n [\n AddressFormat.FullData,\n AddressFormat.FullType,\n AddressFormat.Short,\n ].includes(formatType)\n ) {\n return { prefix, format: formatType, payload };\n }\n } catch (_) {}\n\n throw Error(`Unknown address format ${address}`);\n}\n\n/**\n * Converts an address payload into an address-like object.\n *\n * @param prefix - The address prefix.\n * @param format - The format of the address, as defined by the AddressFormat enum.\n * @param payload - The payload array containing the address data.\n * @param client - The client instance used to fetch known scripts.\n * @returns A promise that resolves to an AddressLike object.\n *\n * @throws Will throw an error if the payload length is insufficient or if the script type is unknown.\n *\n * @example\n * ```typescript\n * const address = await addressFromPayload(\"ckt\", AddressFormat.Full, [/* payload data *\\/], client);\n * console.log(address.script); // Outputs the script object\n * console.log(address.prefix); // Outputs the address prefix\n * ```\n */\n\nexport async function addressFromPayload(\n prefix: string,\n format: AddressFormat,\n payload: number[],\n client: Client,\n): Promise<AddressLike> {\n if (format === AddressFormat.Full) {\n if (payload.length < 32 + 1) {\n throw new Error(\n `Invalid full address without enough payload ${hexFrom(payload)}`,\n );\n }\n\n return {\n script: {\n codeHash: payload.slice(0, 32),\n hashType: hashTypeFromBytes(payload.slice(32, 33)),\n args: payload.slice(33),\n },\n prefix,\n };\n }\n\n if (format === AddressFormat.FullData) {\n if (payload.length < 32) {\n throw new Error(\n `Invalid full data address without enough payload ${hexFrom(payload)}`,\n );\n }\n\n return {\n script: {\n codeHash: payload.slice(0, 32),\n hashType: \"data\",\n args: payload.slice(32),\n },\n prefix,\n };\n }\n\n if (format === AddressFormat.FullType) {\n if (payload.length < 32) {\n throw new Error(\n `Invalid full type address without enough payload ${hexFrom(payload)}`,\n );\n }\n\n return {\n script: {\n codeHash: payload.slice(0, 32),\n hashType: \"type\",\n args: payload.slice(32),\n },\n prefix,\n };\n }\n\n // format === AddressFormat.Short\n if (payload.length !== 21) {\n throw new Error(\n `Invalid short address without enough payload ${hexFrom(payload)}`,\n );\n }\n const script = [\n KnownScript.Secp256k1Blake160,\n KnownScript.Secp256k1Multisig,\n KnownScript.AnyoneCanPay,\n ][payload[0]];\n if (script === undefined) {\n throw new Error(\n `Invalid short address with unknown script ${hexFrom(payload)}`,\n );\n }\n\n return {\n script: await Script.fromKnownScript(client, script, payload.slice(1)),\n prefix,\n };\n}\n\nexport enum AddressFormat {\n /**\n * full version identifies the hashType\n */\n Full = 0x00,\n /**\n * @deprecated\n * short version for locks with Known codeHash, deprecated\n */\n Short = 0x01,\n /**\n * @deprecated\n * full version with hashType = \"Data\", deprecated\n */\n FullData = 0x02,\n /**\n * @deprecated\n * full version with hashType = \"Type\", deprecated\n */\n FullType = 0x04,\n}\n\nexport const ADDRESS_BECH32_LIMIT = 1023;\n"],"mappings":"qKAUA,MAAaA,EAAQ,WA2BrB,SAAgB,EACd,EACA,GAAG,EACO,CACV,OAAO,EAAK,QAAQ,EAAe,IAAM,CACvC,IAAM,EAAQ,EAAU,CAAC,EAEzB,IAAK,IAAM,KAAQ,EACjB,EAAO,KAAK,CAAI,EAElB,OAAO,CACT,EAAG,CAAM,CACX,CAqBA,SAAgB,EAAY,GAAG,EAA0B,CACvD,OAAO,IAAI,WAAW,EAAc,CAAC,EAAG,GAAG,CAAI,CAAC,CAClD,CAoBA,SAAgB,EAAQ,EAAgB,EAAqC,CAC3E,OAAO,EAAO,KAAK,EAAU,CAAG,CAAC,CAAC,CAAC,SAAS,CAAQ,CACtD,CA4BA,SAAgB,EACd,EACA,EACO,CACP,GAAI,aAAiB,WACnB,OAAO,EAGT,GAAI,aAAiB,YACnB,OAAO,IAAI,WAAW,CAAK,EAG7B,GAAI,OAAO,GAAU,SAAU,CAC7B,GAAI,IAAa,IAAA,GACf,OAAO,EAAO,KAAK,EAAO,CAAQ,EAGpC,IAAM,EAAM,EAAM,WAAW,IAAI,EAAI,EAAM,MAAM,CAAC,EAAI,EAChD,EAAY,EAAI,OAAS,GAAM,EAAI,EAAM,IAAI,IAC7C,EAAO,EAAO,KAAK,EAAW,KAAK,EACzC,GAAI,EAAK,OAAS,IAAM,EAAU,OAChC,MAAU,MAAM,iBAAiB,GAAO,EAE1C,OAAO,CACT,CAGA,GADiB,M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BACmC,CACjC,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,CACF,CACF,eAC4B,CAC1B,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,CACF,CACF,SACsB,CACpB,SACE,qEACF,SAAU,OACV,SAAU,CAAC,CACb,OACoB,CAClB,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,QACqB,CACnB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,OACoB,CAClB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,CACF,CACF,SACsB,CACpB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,WACwB,CACtB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,YACyB,CACvB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,aAC0B,CACxB,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,SACsB,CACpB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,KAAM,qEACN,SAAU,MACZ,CACF,CACF,CACF,gBAC6B,CAC3B,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,qBACkC,CAChC,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,sBACmC,CACjC,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,gBAC6B,CAC3B,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,gBAC6B,CAC3B,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,eAC4B,CAC1B,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,qBACkC,CAChC,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,WACwB,CACtB,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,CACF,CAAC,ECheH,IAAa,GAAb,KAAgD,CAC9C,YACE,EACA,EAA2B,IAC3B,CAFiB,KAAA,IAAA,EACA,KAAA,QAAA,CAChB,CAEH,MAAM,QAAQ,EAAyB,CACrC,IAAM,EAAU,IAAI,gBACd,EAAa,eAAiB,EAAQ,MAAM,EAAG,KAAK,OAAO,EAG3D,EAAM,MACV,MAAM,MAAM,KAAK,IAAK,CACpB,OAAQ,OACR,QAAS,CACP,eAAgB,kBAClB,EACA,KAAM,KAAK,UAAU,CAAO,EAC5B,OAAQ,EAAQ,MAClB,CAAC,EAAA,CACD,KAAK,EAGP,OAFA,aAAa,CAAU,EAEhB,CACT,CACF,ECxBa,GAAb,KAAqD,CAYnD,YACE,EACA,EAA2B,IAC3B,CAFiB,KAAA,IAAA,EACA,KAAA,QAAA,eANf,IAAI,GAOL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,CACF,CACF,ECvWA,MAAa,GACX,OAAO,OAAO,WACa,CACvB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,oBACiC,CAC/B,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,CACF,CACF,oBACiC,CAC/B,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,CACF,CACF,sBACmC,CACjC,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,CACF,CACF,eAC4B,CAC1B,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,CACF,CACF,SACsB,CACpB,SACE,qEACF,SAAU,OACV,SAAU,CAAC,CACb,OACoB,CAClB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,QACqB,CACnB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,OACoB,CAClB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,CACF,CACF,SACsB,CACpB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,WACwB,CACtB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,UACX,CACF,EACA,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,YACyB,CACvB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,aAC0B,CACxB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,SAAU,OACV,KAAM,oEACR,CACF,CACF,CACF,SACsB,CACpB,SACE,qEACF,SAAU,OACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,EACA,KAAM,CACJ,SACE,qEACF,KAAM,qEACN,SAAU,MACZ,CACF,CACF,CACF,gBAC6B,CAC3B,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,qBACkC,CAChC,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,sBACmC,CACjC,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,gBAC6B,CAC3B,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,gBAC6B,CAC3B,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,eAC4B,CAC1B,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,qBACkC,CAChC,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,WACwB,CACtB,SACE,qEACF,SAAU,QACV,SAAU,CACR,CACE,QAAS,CACP,SAAU,CACR,OACE,qEACF,MAAO,CACT,EACA,QAAS,MACX,CACF,CACF,CACF,CACF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