@ckb-ccc/core 1.12.5 → 1.13.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 (611) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/address.advanced-CWGrVD-M.mjs +2 -0
  3. package/dist/address.advanced-CWGrVD-M.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-DchA_RPN.mjs +7 -0
  12. package/dist/barrel-DchA_RPN.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-COp7SNhZ.js +2 -0
  19. package/dist.commonjs/address.advanced-COp7SNhZ.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-CXC2Uy5L.js +7 -0
  28. package/dist.commonjs/barrel-CXC2Uy5L.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 +20 -23
  34. package/src/barrel.ts +1 -0
  35. package/src/ckb/epoch.ts +489 -0
  36. package/src/ckb/index.ts +1 -0
  37. package/src/ckb/script.ts +4 -3
  38. package/src/ckb/transaction.ts +83 -94
  39. package/src/client/client.ts +377 -1
  40. package/src/client/clientPublicMainnet.advanced.ts +23 -0
  41. package/src/client/clientPublicTestnet.advanced.ts +23 -0
  42. package/src/client/clientTypes.ts +1 -2
  43. package/src/client/jsonRpc/transformers.ts +2 -2
  44. package/src/client/knownScript.ts +1 -0
  45. package/src/codec/codec.ts +108 -0
  46. package/src/{molecule → codec}/entity.ts +17 -7
  47. package/src/codec/predefined.ts +145 -0
  48. package/src/hasher/advanced.ts +3 -1
  49. package/src/hasher/hasherCkb.ts +1 -1
  50. package/src/hasher/hasherKeecak256.ts +1 -1
  51. package/src/keystore/index.ts +4 -4
  52. package/src/molecule/barrel.ts +10 -1
  53. package/src/molecule/codec.ts +33 -138
  54. package/src/molecule/predefined.ts +63 -50
  55. package/src/signer/btc/index.ts +1 -0
  56. package/src/signer/btc/psbt.ts +98 -0
  57. package/src/signer/btc/signerBtc.ts +41 -1
  58. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +15 -0
  59. package/src/signer/btc/verify.ts +2 -1
  60. package/src/signer/ckb/signerCkbPrivateKey.ts +6 -11
  61. package/src/signer/ckb/verifyCkbSecp256k1.ts +6 -10
  62. package/src/signer/doge/signerDogePrivateKey.ts +6 -3
  63. package/src/signer/doge/verify.ts +7 -8
  64. package/src/signer/nostr/signerNostrPrivateKey.ts +9 -8
  65. package/src/signer/nostr/verify.ts +2 -2
  66. package/src/utils/index.ts +20 -1
  67. package/tsdown.config.mts +44 -0
  68. package/dist/address/address.advanced.d.ts +0 -65
  69. package/dist/address/address.advanced.d.ts.map +0 -1
  70. package/dist/address/address.advanced.js +0 -147
  71. package/dist/address/advanced.d.ts +0 -2
  72. package/dist/address/advanced.d.ts.map +0 -1
  73. package/dist/address/advanced.js +0 -1
  74. package/dist/address/index.d.ts +0 -58
  75. package/dist/address/index.d.ts.map +0 -1
  76. package/dist/address/index.js +0 -78
  77. package/dist/advanced.d.ts +0 -3
  78. package/dist/advanced.d.ts.map +0 -1
  79. package/dist/advanced.js +0 -2
  80. package/dist/advancedBarrel.d.ts +0 -7
  81. package/dist/advancedBarrel.d.ts.map +0 -1
  82. package/dist/advancedBarrel.js +0 -6
  83. package/dist/barrel.d.ts +0 -14
  84. package/dist/barrel.d.ts.map +0 -1
  85. package/dist/barrel.js +0 -13
  86. package/dist/bytes/advanced.d.ts +0 -6
  87. package/dist/bytes/advanced.d.ts.map +0 -1
  88. package/dist/bytes/advanced.js +0 -1
  89. package/dist/bytes/index.d.ts +0 -112
  90. package/dist/bytes/index.d.ts.map +0 -1
  91. package/dist/bytes/index.js +0 -155
  92. package/dist/ckb/advanced.d.ts +0 -3
  93. package/dist/ckb/advanced.d.ts.map +0 -1
  94. package/dist/ckb/advanced.js +0 -2
  95. package/dist/ckb/hash.d.ts +0 -18
  96. package/dist/ckb/hash.d.ts.map +0 -1
  97. package/dist/ckb/hash.js +0 -19
  98. package/dist/ckb/index.d.ts +0 -6
  99. package/dist/ckb/index.d.ts.map +0 -1
  100. package/dist/ckb/index.js +0 -5
  101. package/dist/ckb/script.advanced.d.ts +0 -5
  102. package/dist/ckb/script.advanced.d.ts.map +0 -1
  103. package/dist/ckb/script.advanced.js +0 -13
  104. package/dist/ckb/script.d.ts +0 -156
  105. package/dist/ckb/script.d.ts.map +0 -1
  106. package/dist/ckb/script.js +0 -184
  107. package/dist/ckb/transaction.advanced.d.ts +0 -5
  108. package/dist/ckb/transaction.advanced.d.ts.map +0 -1
  109. package/dist/ckb/transaction.advanced.js +0 -9
  110. package/dist/ckb/transaction.d.ts +0 -1401
  111. package/dist/ckb/transaction.d.ts.map +0 -1
  112. package/dist/ckb/transaction.js +0 -1880
  113. package/dist/ckb/transactionErrors.d.ts +0 -15
  114. package/dist/ckb/transactionErrors.d.ts.map +0 -1
  115. package/dist/ckb/transactionErrors.js +0 -21
  116. package/dist/ckb/transactionLumos.d.ts +0 -30
  117. package/dist/ckb/transactionLumos.d.ts.map +0 -1
  118. package/dist/ckb/transactionLumos.js +0 -1
  119. package/dist/client/advanced.d.ts +0 -6
  120. package/dist/client/advanced.d.ts.map +0 -1
  121. package/dist/client/advanced.js +0 -5
  122. package/dist/client/cache/advanced.d.ts +0 -2
  123. package/dist/client/cache/advanced.d.ts.map +0 -1
  124. package/dist/client/cache/advanced.js +0 -1
  125. package/dist/client/cache/cache.d.ts +0 -98
  126. package/dist/client/cache/cache.d.ts.map +0 -1
  127. package/dist/client/cache/cache.js +0 -139
  128. package/dist/client/cache/index.d.ts +0 -3
  129. package/dist/client/cache/index.d.ts.map +0 -1
  130. package/dist/client/cache/index.js +0 -2
  131. package/dist/client/cache/memory.advanced.d.ts +0 -52
  132. package/dist/client/cache/memory.advanced.d.ts.map +0 -1
  133. package/dist/client/cache/memory.advanced.js +0 -149
  134. package/dist/client/cache/memory.d.ts +0 -53
  135. package/dist/client/cache/memory.d.ts.map +0 -1
  136. package/dist/client/cache/memory.js +0 -148
  137. package/dist/client/client.d.ts +0 -107
  138. package/dist/client/client.d.ts.map +0 -1
  139. package/dist/client/client.js +0 -328
  140. package/dist/client/clientPublicMainnet.advanced.d.ts +0 -4
  141. package/dist/client/clientPublicMainnet.advanced.d.ts.map +0 -1
  142. package/dist/client/clientPublicMainnet.advanced.js +0 -402
  143. package/dist/client/clientPublicMainnet.d.ts +0 -17
  144. package/dist/client/clientPublicMainnet.d.ts.map +0 -1
  145. package/dist/client/clientPublicMainnet.js +0 -40
  146. package/dist/client/clientPublicTestnet.advanced.d.ts +0 -4
  147. package/dist/client/clientPublicTestnet.advanced.d.ts.map +0 -1
  148. package/dist/client/clientPublicTestnet.advanced.js +0 -412
  149. package/dist/client/clientPublicTestnet.d.ts +0 -17
  150. package/dist/client/clientPublicTestnet.d.ts.map +0 -1
  151. package/dist/client/clientPublicTestnet.js +0 -40
  152. package/dist/client/clientTypes.advanced.d.ts +0 -25
  153. package/dist/client/clientTypes.advanced.d.ts.map +0 -1
  154. package/dist/client/clientTypes.advanced.js +0 -6
  155. package/dist/client/clientTypes.d.ts +0 -335
  156. package/dist/client/clientTypes.d.ts.map +0 -1
  157. package/dist/client/clientTypes.js +0 -232
  158. package/dist/client/index.d.ts +0 -8
  159. package/dist/client/index.d.ts.map +0 -1
  160. package/dist/client/index.js +0 -7
  161. package/dist/client/jsonRpc/advanced.d.ts +0 -3
  162. package/dist/client/jsonRpc/advanced.d.ts.map +0 -1
  163. package/dist/client/jsonRpc/advanced.js +0 -2
  164. package/dist/client/jsonRpc/client.d.ts +0 -160
  165. package/dist/client/jsonRpc/client.d.ts.map +0 -1
  166. package/dist/client/jsonRpc/client.js +0 -223
  167. package/dist/client/jsonRpc/index.d.ts +0 -2
  168. package/dist/client/jsonRpc/index.d.ts.map +0 -1
  169. package/dist/client/jsonRpc/index.js +0 -1
  170. package/dist/client/jsonRpc/transformers.d.ts +0 -51
  171. package/dist/client/jsonRpc/transformers.d.ts.map +0 -1
  172. package/dist/client/jsonRpc/transformers.js +0 -247
  173. package/dist/client/jsonRpc/types.d.ts +0 -101
  174. package/dist/client/jsonRpc/types.d.ts.map +0 -1
  175. package/dist/client/jsonRpc/types.js +0 -1
  176. package/dist/client/knownScript.d.ts +0 -27
  177. package/dist/client/knownScript.d.ts.map +0 -1
  178. package/dist/client/knownScript.js +0 -28
  179. package/dist/fixedPoint/index.d.ts +0 -55
  180. package/dist/fixedPoint/index.d.ts.map +0 -1
  181. package/dist/fixedPoint/index.js +0 -68
  182. package/dist/hasher/advanced.d.ts +0 -2
  183. package/dist/hasher/advanced.d.ts.map +0 -1
  184. package/dist/hasher/advanced.js +0 -1
  185. package/dist/hasher/hasher.d.ts +0 -35
  186. package/dist/hasher/hasher.d.ts.map +0 -1
  187. package/dist/hasher/hasher.js +0 -1
  188. package/dist/hasher/hasherCkb.d.ts +0 -57
  189. package/dist/hasher/hasherCkb.d.ts.map +0 -1
  190. package/dist/hasher/hasherCkb.js +0 -70
  191. package/dist/hasher/hasherKeecak256.d.ts +0 -41
  192. package/dist/hasher/hasherKeecak256.d.ts.map +0 -1
  193. package/dist/hasher/hasherKeecak256.js +0 -46
  194. package/dist/hasher/index.d.ts +0 -4
  195. package/dist/hasher/index.d.ts.map +0 -1
  196. package/dist/hasher/index.js +0 -3
  197. package/dist/hex/index.d.ts +0 -27
  198. package/dist/hex/index.d.ts.map +0 -1
  199. package/dist/hex/index.js +0 -17
  200. package/dist/index.d.ts +0 -3
  201. package/dist/index.d.ts.map +0 -1
  202. package/dist/index.js +0 -2
  203. package/dist/jsonRpc/advanced.d.ts +0 -2
  204. package/dist/jsonRpc/advanced.d.ts.map +0 -1
  205. package/dist/jsonRpc/advanced.js +0 -1
  206. package/dist/jsonRpc/index.d.ts +0 -2
  207. package/dist/jsonRpc/index.d.ts.map +0 -1
  208. package/dist/jsonRpc/index.js +0 -1
  209. package/dist/jsonRpc/requestor.d.ts +0 -49
  210. package/dist/jsonRpc/requestor.d.ts.map +0 -1
  211. package/dist/jsonRpc/requestor.js +0 -109
  212. package/dist/jsonRpc/transports/advanced.d.ts +0 -6
  213. package/dist/jsonRpc/transports/advanced.d.ts.map +0 -1
  214. package/dist/jsonRpc/transports/advanced.js +0 -5
  215. package/dist/jsonRpc/transports/factory.d.ts +0 -6
  216. package/dist/jsonRpc/transports/factory.d.ts.map +0 -1
  217. package/dist/jsonRpc/transports/factory.js +0 -8
  218. package/dist/jsonRpc/transports/fallback.d.ts +0 -8
  219. package/dist/jsonRpc/transports/fallback.d.ts.map +0 -1
  220. package/dist/jsonRpc/transports/fallback.js +0 -22
  221. package/dist/jsonRpc/transports/http.d.ts +0 -8
  222. package/dist/jsonRpc/transports/http.d.ts.map +0 -1
  223. package/dist/jsonRpc/transports/http.js +0 -22
  224. package/dist/jsonRpc/transports/transport.d.ts +0 -18
  225. package/dist/jsonRpc/transports/transport.d.ts.map +0 -1
  226. package/dist/jsonRpc/transports/transport.js +0 -1
  227. package/dist/jsonRpc/transports/webSocket.d.ts +0 -11
  228. package/dist/jsonRpc/transports/webSocket.d.ts.map +0 -1
  229. package/dist/jsonRpc/transports/webSocket.js +0 -87
  230. package/dist/keystore/index.d.ts +0 -31
  231. package/dist/keystore/index.d.ts.map +0 -1
  232. package/dist/keystore/index.js +0 -106
  233. package/dist/molecule/barrel.d.ts +0 -4
  234. package/dist/molecule/barrel.d.ts.map +0 -1
  235. package/dist/molecule/codec.d.ts +0 -146
  236. package/dist/molecule/codec.d.ts.map +0 -1
  237. package/dist/molecule/codec.js +0 -516
  238. package/dist/molecule/entity.d.ts +0 -112
  239. package/dist/molecule/entity.d.ts.map +0 -1
  240. package/dist/molecule/entity.js +0 -142
  241. package/dist/molecule/index.d.ts +0 -2
  242. package/dist/molecule/index.d.ts.map +0 -1
  243. package/dist/molecule/index.js +0 -1
  244. package/dist/molecule/predefined.d.ts +0 -57
  245. package/dist/molecule/predefined.d.ts.map +0 -1
  246. package/dist/molecule/predefined.js +0 -83
  247. package/dist/num/index.d.ts +0 -148
  248. package/dist/num/index.d.ts.map +0 -1
  249. package/dist/num/index.js +0 -204
  250. package/dist/signer/btc/index.d.ts +0 -4
  251. package/dist/signer/btc/index.d.ts.map +0 -1
  252. package/dist/signer/btc/index.js +0 -3
  253. package/dist/signer/btc/signerBtc.d.ts +0 -59
  254. package/dist/signer/btc/signerBtc.d.ts.map +0 -1
  255. package/dist/signer/btc/signerBtc.js +0 -83
  256. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -55
  257. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +0 -1
  258. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +0 -61
  259. package/dist/signer/btc/verify.d.ts +0 -40
  260. package/dist/signer/btc/verify.d.ts.map +0 -1
  261. package/dist/signer/btc/verify.js +0 -69
  262. package/dist/signer/ckb/index.d.ts +0 -6
  263. package/dist/signer/ckb/index.d.ts.map +0 -1
  264. package/dist/signer/ckb/index.js +0 -5
  265. package/dist/signer/ckb/signerCkbPrivateKey.d.ts +0 -16
  266. package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +0 -1
  267. package/dist/signer/ckb/signerCkbPrivateKey.js +0 -42
  268. package/dist/signer/ckb/signerCkbPublicKey.d.ts +0 -27
  269. package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +0 -1
  270. package/dist/signer/ckb/signerCkbPublicKey.js +0 -101
  271. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +0 -68
  272. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +0 -1
  273. package/dist/signer/ckb/signerCkbScriptReadonly.js +0 -78
  274. package/dist/signer/ckb/verifyCkbSecp256k1.d.ts +0 -11
  275. package/dist/signer/ckb/verifyCkbSecp256k1.d.ts.map +0 -1
  276. package/dist/signer/ckb/verifyCkbSecp256k1.js +0 -22
  277. package/dist/signer/ckb/verifyJoyId.d.ts +0 -6
  278. package/dist/signer/ckb/verifyJoyId.d.ts.map +0 -1
  279. package/dist/signer/ckb/verifyJoyId.js +0 -16
  280. package/dist/signer/doge/index.d.ts +0 -5
  281. package/dist/signer/doge/index.d.ts.map +0 -1
  282. package/dist/signer/doge/index.js +0 -4
  283. package/dist/signer/doge/signerDoge.d.ts +0 -52
  284. package/dist/signer/doge/signerDoge.d.ts.map +0 -1
  285. package/dist/signer/doge/signerDoge.js +0 -82
  286. package/dist/signer/doge/signerDogeAddressReadonly.d.ts +0 -41
  287. package/dist/signer/doge/signerDogeAddressReadonly.d.ts.map +0 -1
  288. package/dist/signer/doge/signerDogeAddressReadonly.js +0 -45
  289. package/dist/signer/doge/signerDogePrivateKey.d.ts +0 -52
  290. package/dist/signer/doge/signerDogePrivateKey.d.ts.map +0 -1
  291. package/dist/signer/doge/signerDogePrivateKey.js +0 -68
  292. package/dist/signer/doge/verify.d.ts +0 -17
  293. package/dist/signer/doge/verify.d.ts.map +0 -1
  294. package/dist/signer/doge/verify.js +0 -29
  295. package/dist/signer/dummy/alwaysError.d.ts +0 -12
  296. package/dist/signer/dummy/alwaysError.d.ts.map +0 -1
  297. package/dist/signer/dummy/alwaysError.js +0 -13
  298. package/dist/signer/dummy/dummy.d.ts +0 -15
  299. package/dist/signer/dummy/dummy.d.ts.map +0 -1
  300. package/dist/signer/dummy/dummy.js +0 -22
  301. package/dist/signer/dummy/index.d.ts +0 -4
  302. package/dist/signer/dummy/index.d.ts.map +0 -1
  303. package/dist/signer/dummy/index.js +0 -3
  304. package/dist/signer/dummy/openLink.d.ts +0 -12
  305. package/dist/signer/dummy/openLink.d.ts.map +0 -1
  306. package/dist/signer/dummy/openLink.js +0 -13
  307. package/dist/signer/evm/index.d.ts +0 -4
  308. package/dist/signer/evm/index.d.ts.map +0 -1
  309. package/dist/signer/evm/index.js +0 -3
  310. package/dist/signer/evm/signerEvm.d.ts +0 -59
  311. package/dist/signer/evm/signerEvm.d.ts.map +0 -1
  312. package/dist/signer/evm/signerEvm.js +0 -139
  313. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +0 -47
  314. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +0 -1
  315. package/dist/signer/evm/signerEvmAddressReadonly.js +0 -51
  316. package/dist/signer/evm/verify.d.ts +0 -6
  317. package/dist/signer/evm/verify.d.ts.map +0 -1
  318. package/dist/signer/evm/verify.js +0 -9
  319. package/dist/signer/index.d.ts +0 -8
  320. package/dist/signer/index.d.ts.map +0 -1
  321. package/dist/signer/index.js +0 -7
  322. package/dist/signer/nostr/index.d.ts +0 -5
  323. package/dist/signer/nostr/index.d.ts.map +0 -1
  324. package/dist/signer/nostr/index.js +0 -4
  325. package/dist/signer/nostr/signerNostr.d.ts +0 -72
  326. package/dist/signer/nostr/signerNostr.d.ts.map +0 -1
  327. package/dist/signer/nostr/signerNostr.js +0 -96
  328. package/dist/signer/nostr/signerNostrPrivateKey.d.ts +0 -14
  329. package/dist/signer/nostr/signerNostrPrivateKey.d.ts.map +0 -1
  330. package/dist/signer/nostr/signerNostrPrivateKey.js +0 -34
  331. package/dist/signer/nostr/signerNostrPublicKeyReadonly.d.ts +0 -15
  332. package/dist/signer/nostr/signerNostrPublicKeyReadonly.d.ts.map +0 -1
  333. package/dist/signer/nostr/signerNostrPublicKeyReadonly.js +0 -26
  334. package/dist/signer/nostr/verify.d.ts +0 -9
  335. package/dist/signer/nostr/verify.d.ts.map +0 -1
  336. package/dist/signer/nostr/verify.js +0 -55
  337. package/dist/signer/signer/index.d.ts +0 -256
  338. package/dist/signer/signer/index.d.ts.map +0 -1
  339. package/dist/signer/signer/index.js +0 -305
  340. package/dist/utils/index.d.ts +0 -97
  341. package/dist/utils/index.d.ts.map +0 -1
  342. package/dist/utils/index.js +0 -55
  343. package/dist.commonjs/address/address.advanced.d.ts +0 -65
  344. package/dist.commonjs/address/address.advanced.d.ts.map +0 -1
  345. package/dist.commonjs/address/address.advanced.js +0 -152
  346. package/dist.commonjs/address/advanced.d.ts +0 -2
  347. package/dist.commonjs/address/advanced.d.ts.map +0 -1
  348. package/dist.commonjs/address/advanced.js +0 -17
  349. package/dist.commonjs/address/index.d.ts +0 -58
  350. package/dist.commonjs/address/index.d.ts.map +0 -1
  351. package/dist.commonjs/address/index.js +0 -82
  352. package/dist.commonjs/advanced.d.ts.map +0 -1
  353. package/dist.commonjs/advancedBarrel.d.ts.map +0 -1
  354. package/dist.commonjs/barrel.d.ts.map +0 -1
  355. package/dist.commonjs/bytes/advanced.d.ts +0 -6
  356. package/dist.commonjs/bytes/advanced.d.ts.map +0 -1
  357. package/dist.commonjs/bytes/advanced.js +0 -2
  358. package/dist.commonjs/bytes/index.d.ts +0 -112
  359. package/dist.commonjs/bytes/index.d.ts.map +0 -1
  360. package/dist.commonjs/bytes/index.js +0 -163
  361. package/dist.commonjs/ckb/advanced.d.ts +0 -3
  362. package/dist.commonjs/ckb/advanced.d.ts.map +0 -1
  363. package/dist.commonjs/ckb/advanced.js +0 -18
  364. package/dist.commonjs/ckb/hash.d.ts +0 -18
  365. package/dist.commonjs/ckb/hash.d.ts.map +0 -1
  366. package/dist.commonjs/ckb/hash.js +0 -22
  367. package/dist.commonjs/ckb/index.d.ts +0 -6
  368. package/dist.commonjs/ckb/index.d.ts.map +0 -1
  369. package/dist.commonjs/ckb/index.js +0 -21
  370. package/dist.commonjs/ckb/script.advanced.d.ts +0 -5
  371. package/dist.commonjs/ckb/script.advanced.d.ts.map +0 -1
  372. package/dist.commonjs/ckb/script.advanced.js +0 -16
  373. package/dist.commonjs/ckb/script.d.ts +0 -156
  374. package/dist.commonjs/ckb/script.d.ts.map +0 -1
  375. package/dist.commonjs/ckb/script.js +0 -190
  376. package/dist.commonjs/ckb/transaction.advanced.d.ts +0 -5
  377. package/dist.commonjs/ckb/transaction.advanced.d.ts.map +0 -1
  378. package/dist.commonjs/ckb/transaction.advanced.js +0 -12
  379. package/dist.commonjs/ckb/transaction.d.ts +0 -1401
  380. package/dist.commonjs/ckb/transaction.d.ts.map +0 -1
  381. package/dist.commonjs/ckb/transaction.js +0 -1894
  382. package/dist.commonjs/ckb/transactionErrors.d.ts +0 -15
  383. package/dist.commonjs/ckb/transactionErrors.d.ts.map +0 -1
  384. package/dist.commonjs/ckb/transactionErrors.js +0 -26
  385. package/dist.commonjs/ckb/transactionLumos.d.ts +0 -30
  386. package/dist.commonjs/ckb/transactionLumos.d.ts.map +0 -1
  387. package/dist.commonjs/ckb/transactionLumos.js +0 -2
  388. package/dist.commonjs/client/advanced.d.ts +0 -6
  389. package/dist.commonjs/client/advanced.d.ts.map +0 -1
  390. package/dist.commonjs/client/advanced.js +0 -21
  391. package/dist.commonjs/client/cache/advanced.d.ts +0 -2
  392. package/dist.commonjs/client/cache/advanced.d.ts.map +0 -1
  393. package/dist.commonjs/client/cache/advanced.js +0 -17
  394. package/dist.commonjs/client/cache/cache.d.ts +0 -98
  395. package/dist.commonjs/client/cache/cache.d.ts.map +0 -1
  396. package/dist.commonjs/client/cache/cache.js +0 -143
  397. package/dist.commonjs/client/cache/index.d.ts +0 -3
  398. package/dist.commonjs/client/cache/index.d.ts.map +0 -1
  399. package/dist.commonjs/client/cache/index.js +0 -18
  400. package/dist.commonjs/client/cache/memory.advanced.d.ts +0 -52
  401. package/dist.commonjs/client/cache/memory.advanced.d.ts.map +0 -1
  402. package/dist.commonjs/client/cache/memory.advanced.js +0 -158
  403. package/dist.commonjs/client/cache/memory.d.ts +0 -53
  404. package/dist.commonjs/client/cache/memory.d.ts.map +0 -1
  405. package/dist.commonjs/client/cache/memory.js +0 -152
  406. package/dist.commonjs/client/client.d.ts +0 -107
  407. package/dist.commonjs/client/client.d.ts.map +0 -1
  408. package/dist.commonjs/client/client.js +0 -332
  409. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +0 -4
  410. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +0 -1
  411. package/dist.commonjs/client/clientPublicMainnet.advanced.js +0 -405
  412. package/dist.commonjs/client/clientPublicMainnet.d.ts +0 -17
  413. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +0 -1
  414. package/dist.commonjs/client/clientPublicMainnet.js +0 -47
  415. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +0 -4
  416. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +0 -1
  417. package/dist.commonjs/client/clientPublicTestnet.advanced.js +0 -415
  418. package/dist.commonjs/client/clientPublicTestnet.d.ts +0 -17
  419. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +0 -1
  420. package/dist.commonjs/client/clientPublicTestnet.js +0 -47
  421. package/dist.commonjs/client/clientTypes.advanced.d.ts +0 -25
  422. package/dist.commonjs/client/clientTypes.advanced.d.ts.map +0 -1
  423. package/dist.commonjs/client/clientTypes.advanced.js +0 -10
  424. package/dist.commonjs/client/clientTypes.d.ts +0 -335
  425. package/dist.commonjs/client/clientTypes.d.ts.map +0 -1
  426. package/dist.commonjs/client/clientTypes.js +0 -251
  427. package/dist.commonjs/client/index.d.ts +0 -8
  428. package/dist.commonjs/client/index.d.ts.map +0 -1
  429. package/dist.commonjs/client/index.js +0 -23
  430. package/dist.commonjs/client/jsonRpc/advanced.d.ts +0 -3
  431. package/dist.commonjs/client/jsonRpc/advanced.d.ts.map +0 -1
  432. package/dist.commonjs/client/jsonRpc/advanced.js +0 -18
  433. package/dist.commonjs/client/jsonRpc/client.d.ts +0 -160
  434. package/dist.commonjs/client/jsonRpc/client.d.ts.map +0 -1
  435. package/dist.commonjs/client/jsonRpc/client.js +0 -227
  436. package/dist.commonjs/client/jsonRpc/index.d.ts +0 -2
  437. package/dist.commonjs/client/jsonRpc/index.d.ts.map +0 -1
  438. package/dist.commonjs/client/jsonRpc/index.js +0 -17
  439. package/dist.commonjs/client/jsonRpc/transformers.d.ts +0 -51
  440. package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +0 -1
  441. package/dist.commonjs/client/jsonRpc/transformers.js +0 -251
  442. package/dist.commonjs/client/jsonRpc/types.d.ts +0 -101
  443. package/dist.commonjs/client/jsonRpc/types.d.ts.map +0 -1
  444. package/dist.commonjs/client/jsonRpc/types.js +0 -2
  445. package/dist.commonjs/client/knownScript.d.ts +0 -27
  446. package/dist.commonjs/client/knownScript.d.ts.map +0 -1
  447. package/dist.commonjs/client/knownScript.js +0 -31
  448. package/dist.commonjs/fixedPoint/index.d.ts +0 -55
  449. package/dist.commonjs/fixedPoint/index.d.ts.map +0 -1
  450. package/dist.commonjs/fixedPoint/index.js +0 -73
  451. package/dist.commonjs/hasher/advanced.d.ts +0 -2
  452. package/dist.commonjs/hasher/advanced.d.ts.map +0 -1
  453. package/dist.commonjs/hasher/advanced.js +0 -4
  454. package/dist.commonjs/hasher/hasher.d.ts +0 -35
  455. package/dist.commonjs/hasher/hasher.d.ts.map +0 -1
  456. package/dist.commonjs/hasher/hasher.js +0 -2
  457. package/dist.commonjs/hasher/hasherCkb.d.ts +0 -57
  458. package/dist.commonjs/hasher/hasherCkb.d.ts.map +0 -1
  459. package/dist.commonjs/hasher/hasherCkb.js +0 -75
  460. package/dist.commonjs/hasher/hasherKeecak256.d.ts +0 -41
  461. package/dist.commonjs/hasher/hasherKeecak256.d.ts.map +0 -1
  462. package/dist.commonjs/hasher/hasherKeecak256.js +0 -50
  463. package/dist.commonjs/hasher/index.d.ts +0 -4
  464. package/dist.commonjs/hasher/index.d.ts.map +0 -1
  465. package/dist.commonjs/hasher/index.js +0 -19
  466. package/dist.commonjs/hex/index.d.ts +0 -27
  467. package/dist.commonjs/hex/index.d.ts.map +0 -1
  468. package/dist.commonjs/hex/index.js +0 -20
  469. package/dist.commonjs/index.d.ts.map +0 -1
  470. package/dist.commonjs/jsonRpc/advanced.d.ts +0 -2
  471. package/dist.commonjs/jsonRpc/advanced.d.ts.map +0 -1
  472. package/dist.commonjs/jsonRpc/advanced.js +0 -17
  473. package/dist.commonjs/jsonRpc/index.d.ts +0 -2
  474. package/dist.commonjs/jsonRpc/index.d.ts.map +0 -1
  475. package/dist.commonjs/jsonRpc/index.js +0 -17
  476. package/dist.commonjs/jsonRpc/requestor.d.ts +0 -49
  477. package/dist.commonjs/jsonRpc/requestor.d.ts.map +0 -1
  478. package/dist.commonjs/jsonRpc/requestor.js +0 -113
  479. package/dist.commonjs/jsonRpc/transports/advanced.d.ts +0 -6
  480. package/dist.commonjs/jsonRpc/transports/advanced.d.ts.map +0 -1
  481. package/dist.commonjs/jsonRpc/transports/advanced.js +0 -21
  482. package/dist.commonjs/jsonRpc/transports/factory.d.ts +0 -6
  483. package/dist.commonjs/jsonRpc/transports/factory.d.ts.map +0 -1
  484. package/dist.commonjs/jsonRpc/transports/factory.js +0 -11
  485. package/dist.commonjs/jsonRpc/transports/fallback.d.ts +0 -8
  486. package/dist.commonjs/jsonRpc/transports/fallback.d.ts.map +0 -1
  487. package/dist.commonjs/jsonRpc/transports/fallback.js +0 -26
  488. package/dist.commonjs/jsonRpc/transports/http.d.ts +0 -8
  489. package/dist.commonjs/jsonRpc/transports/http.d.ts.map +0 -1
  490. package/dist.commonjs/jsonRpc/transports/http.js +0 -26
  491. package/dist.commonjs/jsonRpc/transports/transport.d.ts +0 -18
  492. package/dist.commonjs/jsonRpc/transports/transport.d.ts.map +0 -1
  493. package/dist.commonjs/jsonRpc/transports/transport.js +0 -2
  494. package/dist.commonjs/jsonRpc/transports/webSocket.d.ts +0 -11
  495. package/dist.commonjs/jsonRpc/transports/webSocket.d.ts.map +0 -1
  496. package/dist.commonjs/jsonRpc/transports/webSocket.js +0 -94
  497. package/dist.commonjs/keystore/index.d.ts +0 -31
  498. package/dist.commonjs/keystore/index.d.ts.map +0 -1
  499. package/dist.commonjs/keystore/index.js +0 -110
  500. package/dist.commonjs/molecule/barrel.d.ts +0 -4
  501. package/dist.commonjs/molecule/barrel.d.ts.map +0 -1
  502. package/dist.commonjs/molecule/barrel.js +0 -19
  503. package/dist.commonjs/molecule/codec.d.ts +0 -146
  504. package/dist.commonjs/molecule/codec.d.ts.map +0 -1
  505. package/dist.commonjs/molecule/codec.js +0 -531
  506. package/dist.commonjs/molecule/entity.d.ts +0 -112
  507. package/dist.commonjs/molecule/entity.d.ts.map +0 -1
  508. package/dist.commonjs/molecule/entity.js +0 -147
  509. package/dist.commonjs/molecule/index.d.ts +0 -2
  510. package/dist.commonjs/molecule/index.d.ts.map +0 -1
  511. package/dist.commonjs/molecule/index.js +0 -37
  512. package/dist.commonjs/molecule/predefined.d.ts +0 -57
  513. package/dist.commonjs/molecule/predefined.d.ts.map +0 -1
  514. package/dist.commonjs/molecule/predefined.js +0 -87
  515. package/dist.commonjs/num/index.d.ts +0 -148
  516. package/dist.commonjs/num/index.d.ts.map +0 -1
  517. package/dist.commonjs/num/index.js +0 -216
  518. package/dist.commonjs/signer/btc/index.d.ts +0 -4
  519. package/dist.commonjs/signer/btc/index.d.ts.map +0 -1
  520. package/dist.commonjs/signer/btc/index.js +0 -19
  521. package/dist.commonjs/signer/btc/signerBtc.d.ts +0 -59
  522. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +0 -1
  523. package/dist.commonjs/signer/btc/signerBtc.js +0 -87
  524. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -55
  525. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +0 -1
  526. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +0 -65
  527. package/dist.commonjs/signer/btc/verify.d.ts +0 -40
  528. package/dist.commonjs/signer/btc/verify.d.ts.map +0 -1
  529. package/dist.commonjs/signer/btc/verify.js +0 -80
  530. package/dist.commonjs/signer/ckb/index.d.ts +0 -6
  531. package/dist.commonjs/signer/ckb/index.d.ts.map +0 -1
  532. package/dist.commonjs/signer/ckb/index.js +0 -21
  533. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +0 -16
  534. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +0 -1
  535. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +0 -46
  536. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +0 -27
  537. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +0 -1
  538. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +0 -105
  539. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +0 -68
  540. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +0 -1
  541. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +0 -82
  542. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +0 -11
  543. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts.map +0 -1
  544. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +0 -26
  545. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +0 -6
  546. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +0 -1
  547. package/dist.commonjs/signer/ckb/verifyJoyId.js +0 -19
  548. package/dist.commonjs/signer/doge/index.d.ts +0 -5
  549. package/dist.commonjs/signer/doge/index.d.ts.map +0 -1
  550. package/dist.commonjs/signer/doge/index.js +0 -20
  551. package/dist.commonjs/signer/doge/signerDoge.d.ts +0 -52
  552. package/dist.commonjs/signer/doge/signerDoge.d.ts.map +0 -1
  553. package/dist.commonjs/signer/doge/signerDoge.js +0 -89
  554. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts +0 -41
  555. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts.map +0 -1
  556. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.js +0 -49
  557. package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts +0 -52
  558. package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts.map +0 -1
  559. package/dist.commonjs/signer/doge/signerDogePrivateKey.js +0 -72
  560. package/dist.commonjs/signer/doge/verify.d.ts +0 -17
  561. package/dist.commonjs/signer/doge/verify.d.ts.map +0 -1
  562. package/dist.commonjs/signer/doge/verify.js +0 -33
  563. package/dist.commonjs/signer/dummy/alwaysError.d.ts +0 -12
  564. package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +0 -1
  565. package/dist.commonjs/signer/dummy/alwaysError.js +0 -17
  566. package/dist.commonjs/signer/dummy/dummy.d.ts +0 -15
  567. package/dist.commonjs/signer/dummy/dummy.d.ts.map +0 -1
  568. package/dist.commonjs/signer/dummy/dummy.js +0 -26
  569. package/dist.commonjs/signer/dummy/index.d.ts +0 -4
  570. package/dist.commonjs/signer/dummy/index.d.ts.map +0 -1
  571. package/dist.commonjs/signer/dummy/index.js +0 -19
  572. package/dist.commonjs/signer/dummy/openLink.d.ts +0 -12
  573. package/dist.commonjs/signer/dummy/openLink.d.ts.map +0 -1
  574. package/dist.commonjs/signer/dummy/openLink.js +0 -17
  575. package/dist.commonjs/signer/evm/index.d.ts +0 -4
  576. package/dist.commonjs/signer/evm/index.d.ts.map +0 -1
  577. package/dist.commonjs/signer/evm/index.js +0 -19
  578. package/dist.commonjs/signer/evm/signerEvm.d.ts +0 -59
  579. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +0 -1
  580. package/dist.commonjs/signer/evm/signerEvm.js +0 -143
  581. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +0 -47
  582. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +0 -1
  583. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +0 -55
  584. package/dist.commonjs/signer/evm/verify.d.ts +0 -6
  585. package/dist.commonjs/signer/evm/verify.d.ts.map +0 -1
  586. package/dist.commonjs/signer/evm/verify.js +0 -12
  587. package/dist.commonjs/signer/index.d.ts +0 -8
  588. package/dist.commonjs/signer/index.d.ts.map +0 -1
  589. package/dist.commonjs/signer/index.js +0 -23
  590. package/dist.commonjs/signer/nostr/index.d.ts +0 -5
  591. package/dist.commonjs/signer/nostr/index.d.ts.map +0 -1
  592. package/dist.commonjs/signer/nostr/index.js +0 -20
  593. package/dist.commonjs/signer/nostr/signerNostr.d.ts +0 -72
  594. package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +0 -1
  595. package/dist.commonjs/signer/nostr/signerNostr.js +0 -100
  596. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts +0 -14
  597. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts.map +0 -1
  598. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.js +0 -38
  599. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.d.ts +0 -15
  600. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.d.ts.map +0 -1
  601. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.js +0 -30
  602. package/dist.commonjs/signer/nostr/verify.d.ts +0 -9
  603. package/dist.commonjs/signer/nostr/verify.d.ts.map +0 -1
  604. package/dist.commonjs/signer/nostr/verify.js +0 -60
  605. package/dist.commonjs/signer/signer/index.d.ts +0 -256
  606. package/dist.commonjs/signer/signer/index.d.ts.map +0 -1
  607. package/dist.commonjs/signer/signer/index.js +0 -311
  608. package/dist.commonjs/utils/index.d.ts +0 -97
  609. package/dist.commonjs/utils/index.d.ts.map +0 -1
  610. package/dist.commonjs/utils/index.js +0 -62
  611. /package/{dist/molecule/barrel.js → src/codec/index.ts} +0 -0
@@ -1,1894 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var OutPoint_1, CellOutput_1, Since_1, CellInput_1, CellDep_1, WitnessArgs_1, Transaction_1;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Transaction = exports.RawTransaction = exports.WitnessArgs = exports.CellDepVec = exports.CellDep = exports.CellInputVec = exports.CellInput = exports.Since = exports.Cell = exports.CellAny = exports.CellOutputVec = exports.CellOutput = exports.OutPoint = exports.DepTypeCodec = void 0;
11
- exports.depTypeFrom = depTypeFrom;
12
- exports.depTypeToBytes = depTypeToBytes;
13
- exports.depTypeFromBytes = depTypeFromBytes;
14
- exports.epochFrom = epochFrom;
15
- exports.epochFromHex = epochFromHex;
16
- exports.epochToHex = epochToHex;
17
- exports.udtBalanceFrom = udtBalanceFrom;
18
- exports.calcDaoProfit = calcDaoProfit;
19
- exports.calcDaoClaimEpoch = calcDaoClaimEpoch;
20
- const index_js_1 = require("../bytes/index.js");
21
- const index_js_2 = require("../client/index.js");
22
- const knownScript_js_1 = require("../client/knownScript.js");
23
- const index_js_3 = require("../fixedPoint/index.js");
24
- const index_js_4 = require("../hasher/index.js");
25
- const index_js_5 = require("../hex/index.js");
26
- const index_js_6 = require("../molecule/index.js");
27
- const index_js_7 = require("../num/index.js");
28
- const index_js_8 = require("../utils/index.js");
29
- const script_js_1 = require("./script.js");
30
- const transaction_advanced_js_1 = require("./transaction.advanced.js");
31
- const transactionErrors_js_1 = require("./transactionErrors.js");
32
- exports.DepTypeCodec = index_js_6.mol.Codec.from({
33
- byteLength: 1,
34
- encode: depTypeToBytes,
35
- decode: depTypeFromBytes,
36
- });
37
- /**
38
- * Converts a DepTypeLike value to a DepType.
39
- * @public
40
- *
41
- * @param val - The value to convert, which can be a string, number, or bigint.
42
- * @returns The corresponding DepType.
43
- *
44
- * @throws Will throw an error if the input value is not a valid dep type.
45
- *
46
- * @example
47
- * ```typescript
48
- * const depType = depTypeFrom(1); // Outputs "code"
49
- * const depType = depTypeFrom("depGroup"); // Outputs "depGroup"
50
- * ```
51
- */
52
- function depTypeFrom(val) {
53
- const depType = (() => {
54
- if (typeof val === "number") {
55
- return transaction_advanced_js_1.NUM_TO_DEP_TYPE[val];
56
- }
57
- if (typeof val === "bigint") {
58
- return transaction_advanced_js_1.NUM_TO_DEP_TYPE[Number(val)];
59
- }
60
- return val;
61
- })();
62
- if (depType === undefined) {
63
- throw new Error(`Invalid dep type ${val}`);
64
- }
65
- return depType;
66
- }
67
- /**
68
- * Converts a DepTypeLike value to its corresponding byte representation.
69
- * @public
70
- *
71
- * @param depType - The dep type value to convert.
72
- * @returns A Uint8Array containing the byte representation of the dep type.
73
- *
74
- * @example
75
- * ```typescript
76
- * const depTypeBytes = depTypeToBytes("code"); // Outputs Uint8Array [1]
77
- * ```
78
- */
79
- function depTypeToBytes(depType) {
80
- return (0, index_js_1.bytesFrom)([transaction_advanced_js_1.DEP_TYPE_TO_NUM[depTypeFrom(depType)]]);
81
- }
82
- /**
83
- * Converts a byte-like value to a DepType.
84
- * @public
85
- *
86
- * @param bytes - The byte-like value to convert.
87
- * @returns The corresponding DepType.
88
- *
89
- * @throws Will throw an error if the input bytes do not correspond to a valid dep type.
90
- *
91
- * @example
92
- * ```typescript
93
- * const depType = depTypeFromBytes(new Uint8Array([1])); // Outputs "code"
94
- * ```
95
- */
96
- function depTypeFromBytes(bytes) {
97
- return transaction_advanced_js_1.NUM_TO_DEP_TYPE[(0, index_js_1.bytesFrom)(bytes)[0]];
98
- }
99
- /**
100
- * @public
101
- */
102
- let OutPoint = OutPoint_1 = class OutPoint extends index_js_6.mol.Entity.Base() {
103
- /**
104
- * Creates an instance of OutPoint.
105
- *
106
- * @param txHash - The transaction hash.
107
- * @param index - The index of the output in the transaction.
108
- */
109
- constructor(txHash, index) {
110
- super();
111
- this.txHash = txHash;
112
- this.index = index;
113
- }
114
- /**
115
- * Creates an OutPoint instance from an OutPointLike object.
116
- *
117
- * @param outPoint - An OutPointLike object or an instance of OutPoint.
118
- * @returns An OutPoint instance.
119
- *
120
- * @example
121
- * ```typescript
122
- * const outPoint = OutPoint.from({ txHash: "0x...", index: 0 });
123
- * ```
124
- */
125
- static from(outPoint) {
126
- if (outPoint instanceof OutPoint_1) {
127
- return outPoint;
128
- }
129
- return new OutPoint_1((0, index_js_5.hexFrom)(outPoint.txHash), (0, index_js_7.numFrom)(outPoint.index));
130
- }
131
- /**
132
- * Clone a OutPoint.
133
- *
134
- * @returns A cloned OutPoint instance.
135
- *
136
- * @example
137
- * ```typescript
138
- * const outPoint1 = outPoint0.clone();
139
- * ```
140
- */
141
- clone() {
142
- return new OutPoint_1(this.txHash, this.index);
143
- }
144
- /**
145
- * Check if the OutPoint is equal to another OutPoint.
146
- * @public
147
- * @param other - The other OutPoint to compare with
148
- * @returns True if the OutPoints are equal, false otherwise
149
- *
150
- * @example
151
- * ```typescript
152
- * const isEqual = outPoint0.eq(outPoint1);
153
- * ```
154
- */
155
- eq(other) {
156
- other = OutPoint_1.from(other);
157
- return this.txHash === other.txHash && this.index === other.index;
158
- }
159
- };
160
- exports.OutPoint = OutPoint;
161
- exports.OutPoint = OutPoint = OutPoint_1 = __decorate([
162
- index_js_6.mol.codec(index_js_6.mol.struct({
163
- txHash: index_js_6.mol.Byte32,
164
- index: index_js_6.mol.Uint32,
165
- }))
166
- ], OutPoint);
167
- /**
168
- * @public
169
- */
170
- let CellOutput = CellOutput_1 = class CellOutput extends index_js_6.mol.Entity.Base() {
171
- /**
172
- * Creates an instance of CellOutput.
173
- *
174
- * @param capacity - The capacity of the cell.
175
- * @param lock - The lock script of the cell.
176
- * @param type - The optional type script of the cell.
177
- */
178
- constructor(capacity, lock, type) {
179
- super();
180
- this.capacity = capacity;
181
- this.lock = lock;
182
- this.type = type;
183
- }
184
- get occupiedSize() {
185
- return 8 + this.lock.occupiedSize + (this.type?.occupiedSize ?? 0);
186
- }
187
- /**
188
- * Creates a CellOutput instance from a CellOutputLike object.
189
- * This method supports automatic capacity calculation when outputData is provided and capacity is 0 or omitted.
190
- *
191
- * @param cellOutput - A CellOutputLike object or an instance of CellOutput.
192
- * @param outputData - Optional output data used for automatic capacity calculation.
193
- * When provided and capacity is 0, the capacity will be calculated
194
- * as occupiedSize + outputData.length.
195
- * @returns A CellOutput instance.
196
- *
197
- * @example
198
- * ```typescript
199
- * // Basic usage with explicit capacity
200
- * const cellOutput1 = CellOutput.from({
201
- * capacity: 1000n,
202
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." },
203
- * type: { codeHash: "0x...", hashType: "type", args: "0x..." }
204
- * });
205
- *
206
- * // Automatic capacity calculation
207
- * const cellOutput2 = CellOutput.from({
208
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
209
- * }, "0x1234"); // Capacity will be calculated automatically
210
- * ```
211
- */
212
- static from(cellOutput, outputData) {
213
- const output = (() => {
214
- if (cellOutput instanceof CellOutput_1) {
215
- return cellOutput;
216
- }
217
- return new CellOutput_1((0, index_js_7.numFrom)(cellOutput.capacity ?? 0), script_js_1.Script.from(cellOutput.lock), (0, index_js_8.apply)(script_js_1.Script.from, cellOutput.type));
218
- })();
219
- if (output.capacity === index_js_3.Zero && outputData != null) {
220
- output.capacity = (0, index_js_3.fixedPointFrom)(output.occupiedSize + (0, index_js_1.bytesFrom)(outputData).length);
221
- }
222
- return output;
223
- }
224
- /**
225
- * Clone a CellOutput.
226
- *
227
- * @returns A cloned CellOutput instance.
228
- *
229
- * @example
230
- * ```typescript
231
- * const cellOutput1 = cellOutput0.clone();
232
- * ```
233
- */
234
- clone() {
235
- return new CellOutput_1(this.capacity, this.lock.clone(), this.type?.clone());
236
- }
237
- };
238
- exports.CellOutput = CellOutput;
239
- exports.CellOutput = CellOutput = CellOutput_1 = __decorate([
240
- index_js_6.mol.codec(index_js_6.mol.table({
241
- capacity: index_js_6.mol.Uint64,
242
- lock: script_js_1.Script,
243
- type: script_js_1.ScriptOpt,
244
- }))
245
- ], CellOutput);
246
- exports.CellOutputVec = index_js_6.mol.vector(CellOutput);
247
- /**
248
- * Represents a CKB cell that can be either on-chain (with an `outPoint`) or off-chain (without an `outPoint`).
249
- * This class provides a unified interface for handling cells before they are included in a transaction,
250
- * or for cells that are already part of the blockchain state.
251
- *
252
- * @public
253
- */
254
- class CellAny {
255
- /**
256
- * Creates an instance of CellAny.
257
- *
258
- * @param cellOutput - The cell output of the cell.
259
- * @param outputData - The output data of the cell.
260
- * @param outPoint - The optional output point of the cell. If provided, the cell is considered on-chain.
261
- */
262
- constructor(cellOutput, outputData, outPoint) {
263
- this.cellOutput = cellOutput;
264
- this.outputData = outputData;
265
- this.outPoint = outPoint;
266
- }
267
- /**
268
- * Creates a `CellAny` instance from a `CellAnyLike` object.
269
- * This factory method provides a convenient way to create `CellAny` instances
270
- * from plain objects, automatically handling the optional `outPoint` or `previousOutput`.
271
- *
272
- * @param cell - A `CellAnyLike` object.
273
- * @returns A new `CellAny` instance.
274
- *
275
- * @example
276
- * ```typescript
277
- * // Create an off-chain cell (e.g., a new output)
278
- * const offChainCell = CellAny.from({
279
- * cellOutput: { capacity: 1000n, lock: lockScript },
280
- * outputData: "0x"
281
- * });
282
- *
283
- * // Create an on-chain cell from an input
284
- * const onChainCell = CellAny.from({
285
- * outPoint: { txHash: "0x...", index: 0 },
286
- * cellOutput: { capacity: 2000n, lock: lockScript },
287
- * outputData: "0x1234"
288
- * });
289
- * ```
290
- */
291
- static from(cell) {
292
- if (cell instanceof CellAny) {
293
- return cell;
294
- }
295
- const outputData = (0, index_js_5.hexFrom)(cell.outputData ?? "0x");
296
- return new CellAny(CellOutput.from(cell.cellOutput, outputData), outputData, (0, index_js_8.apply)(OutPoint.from, cell.outPoint ?? cell.previousOutput));
297
- }
298
- /**
299
- * Calculates the total occupied size of the cell in bytes.
300
- * This includes the size of the `CellOutput` structure plus the size of the `outputData`.
301
- *
302
- * @returns The total occupied size in bytes.
303
- */
304
- get occupiedSize() {
305
- return this.cellOutput.occupiedSize + (0, index_js_1.bytesFrom)(this.outputData).byteLength;
306
- }
307
- /**
308
- * Calculates the free capacity of the cell.
309
- * Free capacity is the total capacity minus the capacity occupied by the cell's structure and data.
310
- *
311
- * @returns The free capacity in shannons as a `Num`.
312
- */
313
- get capacityFree() {
314
- return this.cellOutput.capacity - (0, index_js_3.fixedPointFrom)(this.occupiedSize);
315
- }
316
- /**
317
- * Checks if the cell is a Nervos DAO cell and optionally checks its phase.
318
- *
319
- * @param client - A CKB client instance to fetch known script information.
320
- * @param phase - Optional phase to check: "deposited" or "withdrew".
321
- * If omitted, it checks if the cell is a DAO cell regardless of phase.
322
- * @returns A promise that resolves to `true` if the cell is a matching Nervos DAO cell, `false` otherwise.
323
- */
324
- async isNervosDao(client, phase) {
325
- const { type } = this.cellOutput;
326
- const daoType = await client.getKnownScript(knownScript_js_1.KnownScript.NervosDao);
327
- if (!type ||
328
- type.codeHash !== daoType.codeHash ||
329
- type.hashType !== daoType.hashType) {
330
- // Non Nervos DAO cell
331
- return false;
332
- }
333
- const hasWithdrew = (0, index_js_7.numFrom)(this.outputData) !== index_js_3.Zero;
334
- return (!phase ||
335
- (phase === "deposited" && !hasWithdrew) ||
336
- (phase === "withdrew" && hasWithdrew));
337
- }
338
- /**
339
- * Clones the `CellAny` instance.
340
- *
341
- * @returns A new `CellAny` instance that is a deep copy of the current one.
342
- *
343
- * @example
344
- * ```typescript
345
- * const clonedCell = cellAny.clone();
346
- * ```
347
- */
348
- clone() {
349
- return new CellAny(this.cellOutput.clone(), this.outputData, this.outPoint?.clone());
350
- }
351
- }
352
- exports.CellAny = CellAny;
353
- /**
354
- * Represents an on-chain CKB cell, which is a `CellAny` that is guaranteed to have an `outPoint`.
355
- * This class is typically used for cells that are already part of the blockchain state, such as transaction inputs.
356
- * @public
357
- */
358
- class Cell extends CellAny {
359
- /**
360
- * Creates an instance of an on-chain Cell.
361
- *
362
- * @param outPoint - The output point of the cell.
363
- * @param cellOutput - The cell output of the cell.
364
- * @param outputData - The output data of the cell.
365
- */
366
- constructor(outPoint, cellOutput, outputData) {
367
- super(cellOutput, outputData, outPoint);
368
- this.outPoint = outPoint;
369
- }
370
- /**
371
- * Creates a Cell instance from a CellLike object.
372
- * This method accepts either `outPoint` or `previousOutput` to specify the cell's location,
373
- * and supports automatic capacity calculation for the cell output.
374
- *
375
- * @param cell - A CellLike object or an instance of Cell. The object can use either:
376
- * - `outPoint`: For referencing a cell output
377
- * - `previousOutput`: For referencing a cell input (alternative name for outPoint)
378
- * The cellOutput can omit capacity for automatic calculation.
379
- * @returns A Cell instance.
380
- *
381
- * @example
382
- * ```typescript
383
- * // Using outPoint with explicit capacity
384
- * const cell1 = Cell.from({
385
- * outPoint: { txHash: "0x...", index: 0 },
386
- * cellOutput: {
387
- * capacity: 1000n,
388
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
389
- * },
390
- * outputData: "0x"
391
- * });
392
- *
393
- * // Using previousOutput with automatic capacity calculation
394
- * const cell2 = Cell.from({
395
- * previousOutput: { txHash: "0x...", index: 0 },
396
- * cellOutput: {
397
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
398
- * // capacity will be calculated automatically
399
- * },
400
- * outputData: "0x1234"
401
- * });
402
- * ```
403
- */
404
- static from(cell) {
405
- if (cell instanceof Cell) {
406
- return cell;
407
- }
408
- return new Cell(OutPoint.from(cell.outPoint ?? cell.previousOutput), CellOutput.from(cell.cellOutput, cell.outputData), (0, index_js_5.hexFrom)(cell.outputData ?? "0x"));
409
- }
410
- /**
411
- * Gets confirmed Nervos DAO profit of a Cell
412
- * It returns non-zero value only when the cell is in withdrawal phase 2
413
- * See https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md
414
- *
415
- * @param client - A client for searching DAO related headers
416
- * @returns Profit
417
- *
418
- * @example
419
- * ```typescript
420
- * const profit = await cell.getDaoProfit(client);
421
- * ```
422
- */
423
- async getDaoProfit(client) {
424
- if (!(await this.isNervosDao(client, "withdrew"))) {
425
- return index_js_3.Zero;
426
- }
427
- const { depositHeader, withdrawHeader } = await this.getNervosDaoInfo(client);
428
- if (!withdrawHeader || !depositHeader) {
429
- throw new Error(`Unable to get headers of a Nervos DAO cell ${this.outPoint.txHash}:${this.outPoint.index.toString()}`);
430
- }
431
- return calcDaoProfit(this.capacityFree, depositHeader, withdrawHeader);
432
- }
433
- /**
434
- * Retrieves detailed information about a Nervos DAO cell, including its deposit and withdrawal headers.
435
- *
436
- * @param client - A CKB client instance to fetch cell and header data.
437
- * @returns A promise that resolves to an object containing header information.
438
- * - If not a DAO cell, returns `{}`.
439
- * - If a deposited DAO cell, returns `{ depositHeader }`.
440
- * - If a withdrawn DAO cell, returns `{ depositHeader, withdrawHeader }`.
441
- *
442
- * @throws If the cell is a DAO cell but its corresponding headers cannot be fetched.
443
- *
444
- * @example
445
- * ```typescript
446
- * const daoInfo = await cell.getNervosDaoInfo(client);
447
- * ```
448
- */
449
- async getNervosDaoInfo(client) {
450
- if (!(await this.isNervosDao(client))) {
451
- // Non Nervos DAO cell
452
- return {};
453
- }
454
- if ((0, index_js_7.numFrom)(this.outputData) === index_js_3.Zero) {
455
- // Deposited Nervos DAO cell
456
- const depositRes = await client.getCellWithHeader(this.outPoint);
457
- if (!depositRes?.header) {
458
- throw new Error(`Unable to get header of a Nervos DAO deposited cell ${this.outPoint.txHash}:${this.outPoint.index.toString()}`);
459
- }
460
- return {
461
- depositHeader: depositRes.header,
462
- };
463
- }
464
- // Withdrew Nervos DAO cell
465
- const [depositHeader, withdrawRes] = await Promise.all([
466
- client.getHeaderByNumber((0, index_js_7.numFromBytes)(this.outputData)),
467
- client.getCellWithHeader(this.outPoint),
468
- ]);
469
- if (!withdrawRes?.header || !depositHeader) {
470
- throw new Error(`Unable to get headers of a Nervos DAO withdrew cell ${this.outPoint.txHash}:${this.outPoint.index.toString()}`);
471
- }
472
- return {
473
- depositHeader,
474
- withdrawHeader: withdrawRes.header,
475
- };
476
- }
477
- /**
478
- * Clone a Cell
479
- *
480
- * @returns A cloned Cell instance.
481
- *
482
- * @example
483
- * ```typescript
484
- * const cell1 = cell0.clone();
485
- * ```
486
- */
487
- clone() {
488
- return new Cell(this.outPoint.clone(), this.cellOutput.clone(), this.outputData);
489
- }
490
- }
491
- exports.Cell = Cell;
492
- /**
493
- * @public
494
- */
495
- function epochFrom(epochLike) {
496
- return [(0, index_js_7.numFrom)(epochLike[0]), (0, index_js_7.numFrom)(epochLike[1]), (0, index_js_7.numFrom)(epochLike[2])];
497
- }
498
- /**
499
- * @public
500
- */
501
- function epochFromHex(hex) {
502
- const num = (0, index_js_7.numFrom)((0, index_js_5.hexFrom)(hex));
503
- return [
504
- num & (0, index_js_7.numFrom)("0xffffff"),
505
- (num >> (0, index_js_7.numFrom)(24)) & (0, index_js_7.numFrom)("0xffff"),
506
- (num >> (0, index_js_7.numFrom)(40)) & (0, index_js_7.numFrom)("0xffff"),
507
- ];
508
- }
509
- /**
510
- * @public
511
- */
512
- function epochToHex(epochLike) {
513
- const epoch = epochFrom(epochLike);
514
- return (0, index_js_7.numToHex)((0, index_js_7.numFrom)(epoch[0]) +
515
- ((0, index_js_7.numFrom)(epoch[1]) << (0, index_js_7.numFrom)(24)) +
516
- ((0, index_js_7.numFrom)(epoch[2]) << (0, index_js_7.numFrom)(40)));
517
- }
518
- /**
519
- * @public
520
- */
521
- let Since = Since_1 = class Since extends index_js_6.mol.Entity.Base() {
522
- /**
523
- * Creates an instance of Since.
524
- *
525
- * @param relative - Absolute or relative
526
- * @param metric - The metric of since
527
- * @param value - The value of since
528
- */
529
- constructor(relative, metric, value) {
530
- super();
531
- this.relative = relative;
532
- this.metric = metric;
533
- this.value = value;
534
- }
535
- /**
536
- * Clone a Since.
537
- *
538
- * @returns A cloned Since instance.
539
- *
540
- * @example
541
- * ```typescript
542
- * const since1 = since0.clone();
543
- * ```
544
- */
545
- clone() {
546
- return new Since_1(this.relative, this.metric, this.value);
547
- }
548
- /**
549
- * Creates a Since instance from a SinceLike object.
550
- *
551
- * @param since - A SinceLike object or an instance of Since.
552
- * @returns A Since instance.
553
- *
554
- * @example
555
- * ```typescript
556
- * const since = Since.from("0x1234567812345678");
557
- * ```
558
- */
559
- static from(since) {
560
- if (since instanceof Since_1) {
561
- return since;
562
- }
563
- if (typeof since === "object" && "relative" in since) {
564
- return new Since_1(since.relative, since.metric, (0, index_js_7.numFrom)(since.value));
565
- }
566
- return Since_1.fromNum(since);
567
- }
568
- /**
569
- * Converts the Since instance to num.
570
- *
571
- * @returns A num
572
- *
573
- * @example
574
- * ```typescript
575
- * const num = since.toNum();
576
- * ```
577
- */
578
- toNum() {
579
- return (this.value |
580
- (this.relative === "absolute" ? index_js_3.Zero : (0, index_js_7.numFrom)("0x8000000000000000")) |
581
- {
582
- blockNumber: (0, index_js_7.numFrom)("0x0000000000000000"),
583
- epoch: (0, index_js_7.numFrom)("0x2000000000000000"),
584
- timestamp: (0, index_js_7.numFrom)("0x4000000000000000"),
585
- }[this.metric]);
586
- }
587
- /**
588
- * Creates a Since instance from a num-like value.
589
- *
590
- * @param numLike - The num-like value to convert.
591
- * @returns A Since instance.
592
- *
593
- * @example
594
- * ```typescript
595
- * const since = Since.fromNum("0x0");
596
- * ```
597
- */
598
- static fromNum(numLike) {
599
- const num = (0, index_js_7.numFrom)(numLike);
600
- const relative = num >> (0, index_js_7.numFrom)(63) === index_js_3.Zero ? "absolute" : "relative";
601
- const metric = ["blockNumber", "epoch", "timestamp"][Number((num >> (0, index_js_7.numFrom)(61)) & (0, index_js_7.numFrom)(3))];
602
- const value = num & (0, index_js_7.numFrom)("0x00ffffffffffffff");
603
- return new Since_1(relative, metric, value);
604
- }
605
- };
606
- exports.Since = Since;
607
- exports.Since = Since = Since_1 = __decorate([
608
- index_js_6.mol.codec(index_js_6.mol.Uint64.mapIn((encodable) => Since.from(encodable).toNum()))
609
- ], Since);
610
- /**
611
- * @public
612
- */
613
- let CellInput = CellInput_1 = class CellInput extends index_js_6.mol.Entity.Base() {
614
- /**
615
- * Creates an instance of CellInput.
616
- *
617
- * @param previousOutput - The previous outpoint of the cell.
618
- * @param since - The since value of the cell input.
619
- * @param cellOutput - The optional cell output associated with the cell input.
620
- * @param outputData - The optional output data associated with the cell input.
621
- */
622
- constructor(previousOutput, since, cellOutput, outputData) {
623
- super();
624
- this.previousOutput = previousOutput;
625
- this.since = since;
626
- this.cellOutput = cellOutput;
627
- this.outputData = outputData;
628
- }
629
- /**
630
- * Creates a CellInput instance from a CellInputLike object.
631
- *
632
- * @param cellInput - A CellInputLike object or an instance of CellInput.
633
- * @returns A CellInput instance.
634
- *
635
- * @example
636
- * ```typescript
637
- * const cellInput = CellInput.from({
638
- * previousOutput: { txHash: "0x...", index: 0 },
639
- * since: 0n
640
- * });
641
- * ```
642
- */
643
- static from(cellInput) {
644
- if (cellInput instanceof CellInput_1) {
645
- return cellInput;
646
- }
647
- return new CellInput_1(OutPoint.from("previousOutput" in cellInput
648
- ? cellInput.previousOutput
649
- : cellInput.outPoint), Since.from(cellInput.since ?? 0).toNum(), (0, index_js_8.apply)(CellOutput.from, cellInput.cellOutput), (0, index_js_8.apply)(index_js_5.hexFrom, cellInput.outputData));
650
- }
651
- async getCell(client) {
652
- await this.completeExtraInfos(client);
653
- if (!this.cellOutput || !this.outputData) {
654
- throw new Error("Unable to complete input");
655
- }
656
- return Cell.from({
657
- outPoint: this.previousOutput,
658
- cellOutput: this.cellOutput,
659
- outputData: this.outputData,
660
- });
661
- }
662
- /**
663
- * Complete extra infos in the input. Including
664
- * - Previous cell output
665
- * - Previous cell data
666
- * The instance will be modified.
667
- *
668
- * @returns true if succeed.
669
- * @example
670
- * ```typescript
671
- * await cellInput.completeExtraInfos(client);
672
- * ```
673
- */
674
- async completeExtraInfos(client) {
675
- if (this.cellOutput && this.outputData) {
676
- return;
677
- }
678
- const cell = await client.getCell(this.previousOutput);
679
- if (!cell) {
680
- return;
681
- }
682
- this.cellOutput = cell.cellOutput;
683
- this.outputData = cell.outputData;
684
- }
685
- /**
686
- * The extra capacity created when consume this input.
687
- * This is usually NervosDAO interest, see https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md.
688
- * And it can also be miners' income. (But this is not implemented yet)
689
- */
690
- async getExtraCapacity(client) {
691
- return (await this.getCell(client)).getDaoProfit(client);
692
- }
693
- /**
694
- * Clone a CellInput.
695
- *
696
- * @returns A cloned CellInput instance.
697
- *
698
- * @example
699
- * ```typescript
700
- * const cellInput1 = cellInput0.clone();
701
- * ```
702
- */
703
- clone() {
704
- return new CellInput_1(this.previousOutput.clone(), this.since, this.cellOutput?.clone(), this.outputData);
705
- }
706
- };
707
- exports.CellInput = CellInput;
708
- exports.CellInput = CellInput = CellInput_1 = __decorate([
709
- index_js_6.mol.codec(index_js_6.mol
710
- .struct({
711
- since: Since,
712
- previousOutput: OutPoint,
713
- })
714
- .mapIn((encodable) => CellInput.from(encodable)))
715
- ], CellInput);
716
- exports.CellInputVec = index_js_6.mol.vector(CellInput);
717
- /**
718
- * @public
719
- */
720
- let CellDep = CellDep_1 = class CellDep extends index_js_6.mol.Entity.Base() {
721
- /**
722
- * Creates an instance of CellDep.
723
- *
724
- * @param outPoint - The outpoint of the cell dependency.
725
- * @param depType - The dependency type.
726
- */
727
- constructor(outPoint, depType) {
728
- super();
729
- this.outPoint = outPoint;
730
- this.depType = depType;
731
- }
732
- /**
733
- * Creates a CellDep instance from a CellDepLike object.
734
- *
735
- * @param cellDep - A CellDepLike object or an instance of CellDep.
736
- * @returns A CellDep instance.
737
- *
738
- * @example
739
- * ```typescript
740
- * const cellDep = CellDep.from({
741
- * outPoint: { txHash: "0x...", index: 0 },
742
- * depType: "depGroup"
743
- * });
744
- * ```
745
- */
746
- static from(cellDep) {
747
- if (cellDep instanceof CellDep_1) {
748
- return cellDep;
749
- }
750
- return new CellDep_1(OutPoint.from(cellDep.outPoint), depTypeFrom(cellDep.depType));
751
- }
752
- /**
753
- * Clone a CellDep.
754
- *
755
- * @returns A cloned CellDep instance.
756
- *
757
- * @example
758
- * ```typescript
759
- * const cellDep1 = cellDep0.clone();
760
- * ```
761
- */
762
- clone() {
763
- return new CellDep_1(this.outPoint.clone(), this.depType);
764
- }
765
- };
766
- exports.CellDep = CellDep;
767
- exports.CellDep = CellDep = CellDep_1 = __decorate([
768
- index_js_6.mol.codec(index_js_6.mol.struct({
769
- outPoint: OutPoint,
770
- depType: exports.DepTypeCodec,
771
- }))
772
- ], CellDep);
773
- exports.CellDepVec = index_js_6.mol.vector(CellDep);
774
- /**
775
- * @public
776
- */
777
- let WitnessArgs = WitnessArgs_1 = class WitnessArgs extends index_js_6.mol.Entity.Base() {
778
- /**
779
- * Creates an instance of WitnessArgs.
780
- *
781
- * @param lock - The optional lock field of the witness.
782
- * @param inputType - The optional input type field of the witness.
783
- * @param outputType - The optional output type field of the witness.
784
- */
785
- constructor(lock, inputType, outputType) {
786
- super();
787
- this.lock = lock;
788
- this.inputType = inputType;
789
- this.outputType = outputType;
790
- }
791
- /**
792
- * Creates a WitnessArgs instance from a WitnessArgsLike object.
793
- *
794
- * @param witnessArgs - A WitnessArgsLike object or an instance of WitnessArgs.
795
- * @returns A WitnessArgs instance.
796
- *
797
- * @example
798
- * ```typescript
799
- * const witnessArgs = WitnessArgs.from({
800
- * lock: "0x...",
801
- * inputType: "0x...",
802
- * outputType: "0x..."
803
- * });
804
- * ```
805
- */
806
- static from(witnessArgs) {
807
- if (witnessArgs instanceof WitnessArgs_1) {
808
- return witnessArgs;
809
- }
810
- return new WitnessArgs_1((0, index_js_8.apply)(index_js_5.hexFrom, witnessArgs.lock), (0, index_js_8.apply)(index_js_5.hexFrom, witnessArgs.inputType), (0, index_js_8.apply)(index_js_5.hexFrom, witnessArgs.outputType));
811
- }
812
- };
813
- exports.WitnessArgs = WitnessArgs;
814
- exports.WitnessArgs = WitnessArgs = WitnessArgs_1 = __decorate([
815
- index_js_6.mol.codec(index_js_6.mol.table({
816
- lock: index_js_6.mol.BytesOpt,
817
- inputType: index_js_6.mol.BytesOpt,
818
- outputType: index_js_6.mol.BytesOpt,
819
- }))
820
- ], WitnessArgs);
821
- /**
822
- * Convert a bytes to a num.
823
- *
824
- * @public
825
- */
826
- function udtBalanceFrom(dataLike) {
827
- const data = (0, index_js_1.bytesFrom)(dataLike).slice(0, 16);
828
- return data.length === 0 ? index_js_3.Zero : (0, index_js_7.numFromBytes)(data);
829
- }
830
- exports.RawTransaction = index_js_6.mol.table({
831
- version: index_js_6.mol.Uint32,
832
- cellDeps: exports.CellDepVec,
833
- headerDeps: index_js_6.mol.Byte32Vec,
834
- inputs: exports.CellInputVec,
835
- outputs: exports.CellOutputVec,
836
- outputsData: index_js_6.mol.BytesVec,
837
- });
838
- /**
839
- * @public
840
- */
841
- let Transaction = Transaction_1 = class Transaction extends index_js_6.mol.Entity.Base() {
842
- /**
843
- * Creates an instance of Transaction.
844
- *
845
- * @param version - The version of the transaction.
846
- * @param cellDeps - The cell dependencies of the transaction.
847
- * @param headerDeps - The header dependencies of the transaction.
848
- * @param inputs - The inputs of the transaction.
849
- * @param outputs - The outputs of the transaction.
850
- * @param outputsData - The data associated with the outputs.
851
- * @param witnesses - The witnesses of the transaction.
852
- */
853
- constructor(version, cellDeps, headerDeps, inputs, outputs, outputsData, witnesses) {
854
- super();
855
- this.version = version;
856
- this.cellDeps = cellDeps;
857
- this.headerDeps = headerDeps;
858
- this.inputs = inputs;
859
- this.outputs = outputs;
860
- this.outputsData = outputsData;
861
- this.witnesses = witnesses;
862
- }
863
- /**
864
- * Creates a default Transaction instance with empty fields.
865
- *
866
- * @returns A default Transaction instance.
867
- *
868
- * @example
869
- * ```typescript
870
- * const defaultTx = Transaction.default();
871
- * ```
872
- */
873
- static default() {
874
- return new Transaction_1(0n, [], [], [], [], [], []);
875
- }
876
- /**
877
- * Copy every properties from another transaction.
878
- * This method replaces all properties of the current transaction with those from the provided transaction.
879
- *
880
- * @param txLike - The transaction-like object to copy properties from.
881
- *
882
- * @example
883
- * ```typescript
884
- * this.copy(Transaction.default());
885
- * ```
886
- */
887
- copy(txLike) {
888
- const tx = Transaction_1.from(txLike);
889
- this.version = tx.version;
890
- this.cellDeps = tx.cellDeps;
891
- this.headerDeps = tx.headerDeps;
892
- this.inputs = tx.inputs;
893
- this.outputs = tx.outputs;
894
- this.outputsData = tx.outputsData;
895
- this.witnesses = tx.witnesses;
896
- }
897
- /**
898
- * Creates a deep copy of the transaction.
899
- * This method creates a new Transaction instance with all nested objects cloned,
900
- * ensuring that modifications to the cloned transaction do not affect the original.
901
- *
902
- * @returns A new Transaction instance that is a deep copy of the current transaction.
903
- *
904
- * @example
905
- * ```typescript
906
- * const originalTx = Transaction.from({
907
- * version: 0,
908
- * inputs: [{ previousOutput: { txHash: "0x...", index: 0 } }],
909
- * outputs: [{ capacity: 1000n, lock: lockScript }],
910
- * outputsData: ["0x"],
911
- * witnesses: ["0x"]
912
- * });
913
- *
914
- * const clonedTx = originalTx.clone();
915
- *
916
- * // Modifications to clonedTx won't affect originalTx
917
- * clonedTx.addOutput({ capacity: 2000n, lock: anotherLockScript });
918
- * console.log(originalTx.outputs.length); // Still 1
919
- * console.log(clonedTx.outputs.length); // Now 2
920
- * ```
921
- *
922
- * @remarks
923
- * The clone operation performs deep copying for:
924
- * - Cell dependencies (cellDeps) - each CellDep is cloned
925
- * - Inputs - each CellInput is cloned
926
- * - Outputs - each CellOutput is cloned
927
- *
928
- * The following are shallow copied (references to immutable data):
929
- * - Header dependencies (headerDeps) - Hex strings are immutable
930
- * - Output data (outputsData) - Hex strings are immutable
931
- * - Witnesses - Hex strings are immutable
932
- * - Version - bigint is immutable
933
- */
934
- clone() {
935
- return new Transaction_1(this.version, this.cellDeps.map((c) => c.clone()), this.headerDeps.map((h) => h), this.inputs.map((i) => i.clone()), this.outputs.map((o) => o.clone()), this.outputsData.map((o) => o), this.witnesses.map((w) => w));
936
- }
937
- /**
938
- * Creates a Transaction instance from a TransactionLike object.
939
- *
940
- * @param tx - A TransactionLike object or an instance of Transaction.
941
- * @returns A Transaction instance.
942
- *
943
- * @example
944
- * ```typescript
945
- * const transaction = Transaction.from({
946
- * version: 0,
947
- * cellDeps: [],
948
- * headerDeps: [],
949
- * inputs: [],
950
- * outputs: [],
951
- * outputsData: [],
952
- * witnesses: []
953
- * });
954
- * ```
955
- */
956
- static from(tx) {
957
- if (tx instanceof Transaction_1) {
958
- return tx;
959
- }
960
- const outputs = tx.outputs?.map((output, i) => CellOutput.from(output, tx.outputsData?.[i] ?? [])) ?? [];
961
- const outputsData = outputs.map((_, i) => (0, index_js_5.hexFrom)(tx.outputsData?.[i] ?? "0x"));
962
- if (tx.outputsData != null && outputsData.length < tx.outputsData.length) {
963
- outputsData.push(...tx.outputsData.slice(outputsData.length).map((d) => (0, index_js_5.hexFrom)(d)));
964
- }
965
- return new Transaction_1((0, index_js_7.numFrom)(tx.version ?? 0), tx.cellDeps?.map((cellDep) => CellDep.from(cellDep)) ?? [], tx.headerDeps?.map(index_js_5.hexFrom) ?? [], tx.inputs?.map((input) => CellInput.from(input)) ?? [], outputs, outputsData, tx.witnesses?.map(index_js_5.hexFrom) ?? []);
966
- }
967
- /**
968
- * Creates a Transaction instance from a Lumos skeleton.
969
- *
970
- * @param skeleton - The Lumos transaction skeleton.
971
- * @returns A Transaction instance.
972
- *
973
- * @throws Will throw an error if an input's outPoint is missing.
974
- *
975
- * @example
976
- * ```typescript
977
- * const transaction = Transaction.fromLumosSkeleton(skeleton);
978
- * ```
979
- */
980
- static fromLumosSkeleton(skeleton) {
981
- return Transaction_1.from({
982
- version: 0n,
983
- cellDeps: skeleton.cellDeps.toArray(),
984
- headerDeps: skeleton.headerDeps.toArray(),
985
- inputs: skeleton.inputs.toArray().map((input, i) => {
986
- if (!input.outPoint) {
987
- throw new Error("outPoint is required in input");
988
- }
989
- return CellInput.from({
990
- previousOutput: input.outPoint,
991
- since: skeleton.inputSinces.get(i, "0x0"),
992
- cellOutput: input.cellOutput,
993
- outputData: input.data,
994
- });
995
- }),
996
- outputs: skeleton.outputs.toArray().map((output) => output.cellOutput),
997
- outputsData: skeleton.outputs.toArray().map((output) => output.data),
998
- witnesses: skeleton.witnesses.toArray(),
999
- });
1000
- }
1001
- /**
1002
- * @deprecated
1003
- * Use ccc.stringify instead.
1004
- * stringify the tx to JSON string.
1005
- */
1006
- stringify() {
1007
- return JSON.stringify(this, (_, value) => {
1008
- if (typeof value === "bigint") {
1009
- return (0, index_js_7.numToHex)(value);
1010
- }
1011
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
1012
- return value;
1013
- });
1014
- }
1015
- /**
1016
- * Converts the raw transaction data to bytes.
1017
- *
1018
- * @returns A Uint8Array containing the raw transaction bytes.
1019
- *
1020
- * @example
1021
- * ```typescript
1022
- * const rawTxBytes = transaction.rawToBytes();
1023
- * ```
1024
- */
1025
- rawToBytes() {
1026
- return exports.RawTransaction.encode(this);
1027
- }
1028
- /**
1029
- * Calculates the hash of the transaction without witnesses. This is the transaction hash in the usual sense.
1030
- * To calculate the hash of the whole transaction including the witnesses, use transaction.hashFull() instead.
1031
- *
1032
- * @returns The hash of the transaction.
1033
- *
1034
- * @example
1035
- * ```typescript
1036
- * const txHash = transaction.hash();
1037
- * ```
1038
- */
1039
- hash() {
1040
- return (0, index_js_4.hashCkb)(this.rawToBytes());
1041
- }
1042
- /**
1043
- * Calculates the hash of the transaction with witnesses.
1044
- *
1045
- * @returns The hash of the transaction with witnesses.
1046
- *
1047
- * @example
1048
- * ```typescript
1049
- * const txFullHash = transaction.hashFull();
1050
- * ```
1051
- */
1052
- hashFull() {
1053
- return (0, index_js_4.hashCkb)(this.toBytes());
1054
- }
1055
- /**
1056
- * Hashes a witness and updates the hasher.
1057
- *
1058
- * @param witness - The witness to hash.
1059
- * @param hasher - The hasher instance to update.
1060
- *
1061
- * @example
1062
- * ```typescript
1063
- * Transaction.hashWitnessToHasher("0x...", hasher);
1064
- * ```
1065
- */
1066
- static hashWitnessToHasher(witness, hasher) {
1067
- const raw = (0, index_js_1.bytesFrom)((0, index_js_5.hexFrom)(witness));
1068
- hasher.update((0, index_js_7.numToBytes)(raw.length, 8));
1069
- hasher.update(raw);
1070
- }
1071
- /**
1072
- * Computes the signing hash information for a given script.
1073
- *
1074
- * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
1075
- * @param client - The client for complete extra infos in the transaction.
1076
- * @returns A promise that resolves to an object containing the signing message and the witness position,
1077
- * or undefined if no matching input is found.
1078
- *
1079
- * @example
1080
- * ```typescript
1081
- * const signHashInfo = await tx.getSignHashInfo(scriptLike, client);
1082
- * if (signHashInfo) {
1083
- * console.log(signHashInfo.message); // Outputs the signing message
1084
- * console.log(signHashInfo.position); // Outputs the witness position
1085
- * }
1086
- * ```
1087
- */
1088
- async getSignHashInfo(scriptLike, client, hasher = new index_js_4.HasherCkb()) {
1089
- const script = script_js_1.Script.from(scriptLike);
1090
- let position = -1;
1091
- hasher.update(this.hash());
1092
- for (let i = 0; i < this.witnesses.length; i += 1) {
1093
- const input = this.inputs[i];
1094
- if (input) {
1095
- const { cellOutput } = await input.getCell(client);
1096
- if (!script.eq(cellOutput.lock)) {
1097
- continue;
1098
- }
1099
- if (position === -1) {
1100
- position = i;
1101
- }
1102
- }
1103
- if (position === -1) {
1104
- return undefined;
1105
- }
1106
- Transaction_1.hashWitnessToHasher(this.witnesses[i], hasher);
1107
- }
1108
- if (position === -1) {
1109
- return undefined;
1110
- }
1111
- return {
1112
- message: hasher.digest(),
1113
- position,
1114
- };
1115
- }
1116
- /**
1117
- * Find the first occurrence of a input with the specified lock id
1118
- *
1119
- * @param scriptIdLike - The script associated with the transaction, represented as a ScriptLike object without args.
1120
- * @param client - The client for complete extra infos in the transaction.
1121
- * @returns A promise that resolves to the found index
1122
- *
1123
- * @example
1124
- * ```typescript
1125
- * const index = await tx.findInputIndexByLockId(scriptIdLike, client);
1126
- * ```
1127
- */
1128
- async findInputIndexByLockId(scriptIdLike, client) {
1129
- const script = script_js_1.Script.from({ ...scriptIdLike, args: "0x" });
1130
- for (let i = 0; i < this.inputs.length; i += 1) {
1131
- const { cellOutput } = await this.inputs[i].getCell(client);
1132
- if (script.codeHash === cellOutput.lock.codeHash &&
1133
- script.hashType === cellOutput.lock.hashType) {
1134
- return i;
1135
- }
1136
- }
1137
- }
1138
- /**
1139
- * Find the first occurrence of a input with the specified lock
1140
- *
1141
- * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
1142
- * @param client - The client for complete extra infos in the transaction.
1143
- * @returns A promise that resolves to the found index, or undefined if no matching input is found.
1144
- *
1145
- * @example
1146
- * ```typescript
1147
- * const index = await tx.findInputIndexByLock(scriptLike, client);
1148
- * ```
1149
- */
1150
- async findInputIndexByLock(scriptLike, client) {
1151
- const script = script_js_1.Script.from(scriptLike);
1152
- for (let i = 0; i < this.inputs.length; i += 1) {
1153
- const { cellOutput } = await this.inputs[i].getCell(client);
1154
- if (script.eq(cellOutput.lock)) {
1155
- return i;
1156
- }
1157
- }
1158
- }
1159
- /**
1160
- * Find the last occurrence of a input with the specified lock
1161
- *
1162
- * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
1163
- * @param client - The client for complete extra infos in the transaction.
1164
- * @returns A promise that resolves to the found index, or undefined if no matching input is found.
1165
- *
1166
- * @example
1167
- * ```typescript
1168
- * const index = await tx.findLastInputIndexByLock(scriptLike, client);
1169
- * ```
1170
- */
1171
- async findLastInputIndexByLock(scriptLike, client) {
1172
- const script = script_js_1.Script.from(scriptLike);
1173
- for (let i = this.inputs.length - 1; i >= 0; i -= 1) {
1174
- const { cellOutput } = await this.inputs[i].getCell(client);
1175
- if (script.eq(cellOutput.lock)) {
1176
- return i;
1177
- }
1178
- }
1179
- }
1180
- /**
1181
- * Add cell deps if they are not existed
1182
- *
1183
- * @param cellDepLikes - The cell deps to add
1184
- *
1185
- * @example
1186
- * ```typescript
1187
- * tx.addCellDeps(cellDep);
1188
- * ```
1189
- */
1190
- addCellDeps(...cellDepLikes) {
1191
- cellDepLikes.flat().forEach((cellDepLike) => {
1192
- const cellDep = CellDep.from(cellDepLike);
1193
- if (this.cellDeps.some((c) => c.eq(cellDep))) {
1194
- return;
1195
- }
1196
- this.cellDeps.push(cellDep);
1197
- });
1198
- }
1199
- /**
1200
- * Add cell deps at the start if they are not existed
1201
- *
1202
- * @param cellDepLikes - The cell deps to add
1203
- *
1204
- * @example
1205
- * ```typescript
1206
- * tx.addCellDepsAtBegin(cellDep);
1207
- * ```
1208
- */
1209
- addCellDepsAtStart(...cellDepLikes) {
1210
- cellDepLikes.flat().forEach((cellDepLike) => {
1211
- const cellDep = CellDep.from(cellDepLike);
1212
- if (this.cellDeps.some((c) => c.eq(cellDep))) {
1213
- return;
1214
- }
1215
- this.cellDeps.unshift(cellDep);
1216
- });
1217
- }
1218
- /**
1219
- * Add cell dep from infos if they are not existed
1220
- *
1221
- * @param client - A client for searching cell deps
1222
- * @param cellDepInfoLikes - The cell dep infos to add
1223
- *
1224
- * @example
1225
- * ```typescript
1226
- * tx.addCellDepInfos(client, cellDepInfos);
1227
- * ```
1228
- */
1229
- async addCellDepInfos(client, ...cellDepInfoLikes) {
1230
- this.addCellDeps(await client.getCellDeps(...cellDepInfoLikes));
1231
- }
1232
- /**
1233
- * Add cell deps from known script
1234
- *
1235
- * @param client - The client for searching known script and cell deps
1236
- * @param scripts - The known scripts to add
1237
- *
1238
- * @example
1239
- * ```typescript
1240
- * tx.addCellDepsOfKnownScripts(client, KnownScript.OmniLock);
1241
- * ```
1242
- */
1243
- async addCellDepsOfKnownScripts(client, ...scripts) {
1244
- await Promise.all(scripts
1245
- .flat()
1246
- .map(async (script) => this.addCellDepInfos(client, (await client.getKnownScript(script)).cellDeps)));
1247
- }
1248
- /**
1249
- * Set output data at index.
1250
- *
1251
- * @param index - The index of the output data.
1252
- * @param data - The data to set.
1253
- *
1254
- * @example
1255
- * ```typescript
1256
- * tx.setOutputDataAt(0, "0x00");
1257
- * ```
1258
- */
1259
- setOutputDataAt(index, data) {
1260
- if (this.outputsData.length < index) {
1261
- this.outputsData.push(...Array.from(new Array(index - this.outputsData.length), () => "0x"));
1262
- }
1263
- this.outputsData[index] = (0, index_js_5.hexFrom)(data);
1264
- }
1265
- /**
1266
- * get input
1267
- *
1268
- * @param index - The cell input index
1269
- *
1270
- * @example
1271
- * ```typescript
1272
- * await tx.getInput(0);
1273
- * ```
1274
- */
1275
- getInput(index) {
1276
- return this.inputs[Number((0, index_js_7.numFrom)(index))];
1277
- }
1278
- /**
1279
- * add input
1280
- *
1281
- * @param inputLike - The cell input.
1282
- *
1283
- * @example
1284
- * ```typescript
1285
- * await tx.addInput({ });
1286
- * ```
1287
- */
1288
- addInput(inputLike) {
1289
- if (this.witnesses.length > this.inputs.length) {
1290
- this.witnesses.splice(this.inputs.length, 0, "0x");
1291
- }
1292
- return this.inputs.push(CellInput.from(inputLike));
1293
- }
1294
- /**
1295
- * get output
1296
- *
1297
- * @param index - The cell output index
1298
- *
1299
- * @example
1300
- * ```typescript
1301
- * await tx.getOutput(0);
1302
- * ```
1303
- */
1304
- getOutput(index) {
1305
- const i = Number((0, index_js_7.numFrom)(index));
1306
- if (i >= this.outputs.length) {
1307
- return;
1308
- }
1309
- return CellAny.from({
1310
- cellOutput: this.outputs[i],
1311
- outputData: this.outputsData[i] ?? "0x",
1312
- });
1313
- }
1314
- /**
1315
- * Provides an iterable over the transaction's output cells.
1316
- *
1317
- * This getter is a convenient way to iterate through all the output cells (`CellAny`)
1318
- * of the transaction, combining the `outputs` and `outputsData` arrays.
1319
- * It can be used with `for...of` loops or other iterable-consuming patterns.
1320
- *
1321
- * @public
1322
- * @category Getter
1323
- * @returns An `Iterable<CellAny>` that yields each output cell of the transaction.
1324
- *
1325
- * @example
1326
- * ```typescript
1327
- * for (const cell of tx.outputCells) {
1328
- * console.log(`Output cell capacity: ${cell.cellOutput.capacity}`);
1329
- * }
1330
- * ```
1331
- */
1332
- get outputCells() {
1333
- const { outputs, outputsData } = this;
1334
- function* generator() {
1335
- for (let i = 0; i < outputs.length; i++) {
1336
- yield CellAny.from({
1337
- cellOutput: outputs[i],
1338
- outputData: outputsData[i] ?? "0x",
1339
- });
1340
- }
1341
- }
1342
- return generator();
1343
- }
1344
- addOutput(cellOrOutputLike, outputDataLike) {
1345
- const cell = "cellOutput" in cellOrOutputLike
1346
- ? CellAny.from(cellOrOutputLike)
1347
- : CellAny.from({
1348
- cellOutput: cellOrOutputLike,
1349
- outputData: outputDataLike,
1350
- });
1351
- const len = this.outputs.push(cell.cellOutput);
1352
- this.setOutputDataAt(len - 1, cell.outputData);
1353
- return len;
1354
- }
1355
- /**
1356
- * Get witness at index as WitnessArgs
1357
- *
1358
- * @param index - The index of the witness.
1359
- * @returns The witness parsed as WitnessArgs.
1360
- *
1361
- * @example
1362
- * ```typescript
1363
- * const witnessArgs = await tx.getWitnessArgsAt(0);
1364
- * ```
1365
- */
1366
- getWitnessArgsAt(index) {
1367
- const rawWitness = this.witnesses[index];
1368
- return (rawWitness ?? "0x") !== "0x"
1369
- ? WitnessArgs.fromBytes(rawWitness)
1370
- : undefined;
1371
- }
1372
- /**
1373
- * Set witness at index by WitnessArgs
1374
- *
1375
- * @param index - The index of the witness.
1376
- * @param witness - The WitnessArgs to set.
1377
- *
1378
- * @example
1379
- * ```typescript
1380
- * await tx.setWitnessArgsAt(0, witnessArgs);
1381
- * ```
1382
- */
1383
- setWitnessArgsAt(index, witness) {
1384
- this.setWitnessAt(index, witness.toBytes());
1385
- }
1386
- /**
1387
- * Set witness at index
1388
- *
1389
- * @param index - The index of the witness.
1390
- * @param witness - The witness to set.
1391
- *
1392
- * @example
1393
- * ```typescript
1394
- * await tx.setWitnessAt(0, witness);
1395
- * ```
1396
- */
1397
- setWitnessAt(index, witness) {
1398
- if (this.witnesses.length < index) {
1399
- this.witnesses.push(...Array.from(new Array(index - this.witnesses.length), () => "0x"));
1400
- }
1401
- this.witnesses[index] = (0, index_js_5.hexFrom)(witness);
1402
- }
1403
- /**
1404
- * Prepare dummy witness for sighash all method
1405
- *
1406
- * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
1407
- * @param lockLen - The length of dummy lock bytes.
1408
- * @param client - The client for complete extra infos in the transaction.
1409
- * @returns A promise that resolves to the prepared transaction
1410
- *
1411
- * @example
1412
- * ```typescript
1413
- * await tx.prepareSighashAllWitness(scriptLike, 85, client);
1414
- * ```
1415
- */
1416
- async prepareSighashAllWitness(scriptLike, lockLen, client) {
1417
- const position = await this.findInputIndexByLock(scriptLike, client);
1418
- if (position === undefined) {
1419
- return;
1420
- }
1421
- const witness = this.getWitnessArgsAt(position) ?? WitnessArgs.from({});
1422
- witness.lock = (0, index_js_5.hexFrom)(Array.from(new Array(lockLen), () => 0));
1423
- this.setWitnessArgsAt(position, witness);
1424
- }
1425
- async getInputsCapacityExtra(client) {
1426
- return (0, index_js_8.reduceAsync)(this.inputs, async (acc, input) => acc + (await input.getExtraCapacity(client)), (0, index_js_7.numFrom)(0));
1427
- }
1428
- // This also includes extra amount
1429
- async getInputsCapacity(client) {
1430
- return ((await (0, index_js_8.reduceAsync)(this.inputs, async (acc, input) => {
1431
- const { cellOutput: { capacity }, } = await input.getCell(client);
1432
- return acc + capacity;
1433
- }, (0, index_js_7.numFrom)(0))) + (await this.getInputsCapacityExtra(client)));
1434
- }
1435
- getOutputsCapacity() {
1436
- return this.outputs.reduce((acc, { capacity }) => acc + capacity, (0, index_js_7.numFrom)(0));
1437
- }
1438
- async getInputsUdtBalance(client, type) {
1439
- return (0, index_js_8.reduceAsync)(this.inputs, async (acc, input) => {
1440
- const { cellOutput, outputData } = await input.getCell(client);
1441
- if (!cellOutput.type?.eq(type)) {
1442
- return;
1443
- }
1444
- return acc + udtBalanceFrom(outputData);
1445
- }, (0, index_js_7.numFrom)(0));
1446
- }
1447
- getOutputsUdtBalance(type) {
1448
- return this.outputs.reduce((acc, output, i) => {
1449
- if (!output.type?.eq(type)) {
1450
- return acc;
1451
- }
1452
- return acc + udtBalanceFrom(this.outputsData[i]);
1453
- }, (0, index_js_7.numFrom)(0));
1454
- }
1455
- async completeInputs(from, filter, accumulator, init) {
1456
- const collectedCells = [];
1457
- let acc = init;
1458
- let fulfilled = false;
1459
- for await (const cell of from.findCells(filter, true)) {
1460
- if (this.inputs.some(({ previousOutput }) => previousOutput.eq(cell.outPoint))) {
1461
- continue;
1462
- }
1463
- const i = collectedCells.push(cell);
1464
- const next = await Promise.resolve(accumulator(acc, cell, i - 1, collectedCells));
1465
- if (next === undefined) {
1466
- fulfilled = true;
1467
- break;
1468
- }
1469
- acc = next;
1470
- }
1471
- collectedCells.forEach((cell) => this.addInput(cell));
1472
- if (fulfilled) {
1473
- return {
1474
- addedCount: collectedCells.length,
1475
- };
1476
- }
1477
- return {
1478
- addedCount: collectedCells.length,
1479
- accumulated: acc,
1480
- };
1481
- }
1482
- async completeInputsByCapacity(from, capacityTweak, filter) {
1483
- const expectedCapacity = this.getOutputsCapacity() + (0, index_js_7.numFrom)(capacityTweak ?? 0);
1484
- const inputsCapacity = await this.getInputsCapacity(from.client);
1485
- if (inputsCapacity >= expectedCapacity) {
1486
- return 0;
1487
- }
1488
- const { addedCount, accumulated } = await this.completeInputs(from, filter ?? {
1489
- scriptLenRange: [0, 1],
1490
- outputDataLenRange: [0, 1],
1491
- }, (acc, { cellOutput: { capacity } }) => {
1492
- const sum = acc + capacity;
1493
- return sum >= expectedCapacity ? undefined : sum;
1494
- }, inputsCapacity);
1495
- if (accumulated === undefined) {
1496
- return addedCount;
1497
- }
1498
- throw new transactionErrors_js_1.ErrorTransactionInsufficientCapacity(expectedCapacity - accumulated);
1499
- }
1500
- async completeInputsAll(from, filter) {
1501
- const { addedCount } = await this.completeInputs(from, filter ?? {
1502
- scriptLenRange: [0, 1],
1503
- outputDataLenRange: [0, 1],
1504
- }, (acc, { cellOutput: { capacity } }) => acc + capacity, index_js_3.Zero);
1505
- return addedCount;
1506
- }
1507
- /**
1508
- * Complete inputs by UDT balance
1509
- *
1510
- * This method succeeds only if enough balance is collected.
1511
- *
1512
- * 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.
1513
- * @param from - The signer to complete the inputs.
1514
- * @param type - The type script of the UDT.
1515
- * @param balanceTweak - The tweak of the balance.
1516
- * @returns A promise that resolves to the number of inputs added.
1517
- */
1518
- async completeInputsByUdt(from, type, balanceTweak) {
1519
- const expectedBalance = this.getOutputsUdtBalance(type) + (0, index_js_7.numFrom)(balanceTweak ?? 0);
1520
- if (expectedBalance === (0, index_js_7.numFrom)(0)) {
1521
- return 0;
1522
- }
1523
- const [inputsBalance, inputsCount] = await (0, index_js_8.reduceAsync)(this.inputs, async ([balanceAcc, countAcc], input) => {
1524
- const { cellOutput, outputData } = await input.getCell(from.client);
1525
- if (!cellOutput.type?.eq(type)) {
1526
- return;
1527
- }
1528
- return [balanceAcc + udtBalanceFrom(outputData), countAcc + 1];
1529
- }, [(0, index_js_7.numFrom)(0), 0]);
1530
- if (inputsBalance === expectedBalance ||
1531
- (inputsBalance >= expectedBalance && inputsCount >= 2)) {
1532
- return 0;
1533
- }
1534
- const { addedCount, accumulated } = await this.completeInputs(from, {
1535
- script: type,
1536
- outputDataLenRange: [16, (0, index_js_7.numFrom)("0xffffffff")],
1537
- }, (acc, { outputData }, _i, collected) => {
1538
- const balance = udtBalanceFrom(outputData);
1539
- const sum = acc + balance;
1540
- return sum === expectedBalance ||
1541
- (sum >= expectedBalance && inputsCount + collected.length >= 2)
1542
- ? undefined
1543
- : sum;
1544
- }, inputsBalance);
1545
- if (accumulated === undefined || accumulated >= expectedBalance) {
1546
- return addedCount;
1547
- }
1548
- throw new transactionErrors_js_1.ErrorTransactionInsufficientCoin(expectedBalance - accumulated, type);
1549
- }
1550
- async completeInputsAddOne(from, filter) {
1551
- const { addedCount, accumulated } = await this.completeInputs(from, filter ?? {
1552
- scriptLenRange: [0, 1],
1553
- outputDataLenRange: [0, 1],
1554
- }, () => undefined, true);
1555
- if (accumulated === undefined) {
1556
- return addedCount;
1557
- }
1558
- throw new Error(`Insufficient CKB, need at least one new cell`);
1559
- }
1560
- async completeInputsAtLeastOne(from, filter) {
1561
- if (this.inputs.length > 0) {
1562
- return 0;
1563
- }
1564
- return this.completeInputsAddOne(from, filter);
1565
- }
1566
- async getFee(client) {
1567
- return (await this.getInputsCapacity(client)) - this.getOutputsCapacity();
1568
- }
1569
- async getFeeRate(client) {
1570
- return (((await this.getFee(client)) * (0, index_js_7.numFrom)(1000)) /
1571
- (0, index_js_7.numFrom)(this.toBytes().length + 4));
1572
- }
1573
- estimateFee(feeRate) {
1574
- const txSize = this.toBytes().length + 4;
1575
- // + 999 then / 1000 to ceil the calculated fee
1576
- return ((0, index_js_7.numFrom)(txSize) * (0, index_js_7.numFrom)(feeRate) + (0, index_js_7.numFrom)(999)) / (0, index_js_7.numFrom)(1000);
1577
- }
1578
- /**
1579
- * Completes the transaction fee by adding inputs and handling change outputs.
1580
- * This method automatically calculates the required fee based on the transaction size and fee rate,
1581
- * adds necessary inputs to cover the fee, and handles change outputs through the provided change function.
1582
- *
1583
- * @param from - The signer to complete inputs from and prepare the transaction.
1584
- * @param change - A function that handles change capacity. It receives the transaction and excess capacity,
1585
- * and should return the additional capacity needed (0 if change is handled successfully,
1586
- * positive number if more capacity is needed for change cell creation).
1587
- * @param expectedFeeRate - The expected fee rate in shannons per 1000 bytes. If not provided,
1588
- * it will be fetched from the client.
1589
- * @param filter - Optional filter for selecting cells when adding inputs.
1590
- * @param options - Optional configuration object.
1591
- * @param options.feeRateBlockRange - Block range for fee rate calculation when expectedFeeRate is not provided.
1592
- * @param options.maxFeeRate - Maximum allowed fee rate.
1593
- * @param options.shouldAddInputs - Whether to add inputs automatically. Defaults to true.
1594
- * @returns A promise that resolves to a tuple containing:
1595
- * - The number of inputs added during the process
1596
- * - A boolean indicating whether change outputs were created (true) or fee was paid without change (false)
1597
- *
1598
- * @throws {ErrorTransactionInsufficientCapacity} When there's not enough capacity to cover the fee.
1599
- * @throws {Error} When the change function doesn't properly handle the available capacity.
1600
- *
1601
- * @example
1602
- * ```typescript
1603
- * const [addedInputs, hasChange] = await tx.completeFee(
1604
- * signer,
1605
- * (tx, capacity) => {
1606
- * if (capacity >= 61_00000000n) { // Minimum for a change cell
1607
- * tx.addOutput({ capacity, lock: changeScript });
1608
- * return 0;
1609
- * }
1610
- * return 61_00000000n; // Need more capacity for change cell
1611
- * },
1612
- * 1000n // 1000 shannons per 1000 bytes
1613
- * );
1614
- * ```
1615
- */
1616
- async completeFee(from, change, expectedFeeRate, filter, options) {
1617
- const feeRate = expectedFeeRate ??
1618
- (await from.client.getFeeRate(options?.feeRateBlockRange, options));
1619
- // Complete all inputs extra infos for cache
1620
- await this.getInputsCapacity(from.client);
1621
- let leastFee = index_js_3.Zero;
1622
- let leastExtraCapacity = index_js_3.Zero;
1623
- let collected = 0;
1624
- // ===
1625
- // Usually, for the worst situation, three iterations are needed
1626
- // 1. First attempt to complete the transaction.
1627
- // 2. Not enough capacity for the change cell.
1628
- // 3. Fee increased by the change cell.
1629
- // ===
1630
- while (true) {
1631
- collected += await (async () => {
1632
- if (!(options?.shouldAddInputs ?? true)) {
1633
- return 0;
1634
- }
1635
- try {
1636
- return await this.completeInputsByCapacity(from, leastFee + leastExtraCapacity, filter);
1637
- }
1638
- catch (err) {
1639
- if (err instanceof transactionErrors_js_1.ErrorTransactionInsufficientCapacity &&
1640
- leastExtraCapacity !== index_js_3.Zero) {
1641
- throw new transactionErrors_js_1.ErrorTransactionInsufficientCapacity(err.amount, {
1642
- isForChange: true,
1643
- });
1644
- }
1645
- throw err;
1646
- }
1647
- })();
1648
- const fee = await this.getFee(from.client);
1649
- if (fee < leastFee + leastExtraCapacity) {
1650
- // Not enough capacity are collected, it should only happens when shouldAddInputs is false
1651
- throw new transactionErrors_js_1.ErrorTransactionInsufficientCapacity(leastFee + leastExtraCapacity - fee, { isForChange: leastExtraCapacity !== index_js_3.Zero });
1652
- }
1653
- await from.prepareTransaction(this);
1654
- if (leastFee === index_js_3.Zero) {
1655
- // The initial fee is calculated based on prepared transaction
1656
- // This should only happens during the first iteration
1657
- leastFee = this.estimateFee(feeRate);
1658
- }
1659
- // The extra capacity paid the fee without a change
1660
- // leastExtraCapacity should be 0 here, otherwise we should failed in the previous check
1661
- // So this only happens in the first iteration
1662
- if (fee === leastFee) {
1663
- return [collected, false];
1664
- }
1665
- // Invoke the change function on a transaction multiple times may cause problems, so we clone it
1666
- const tx = this.clone();
1667
- const needed = (0, index_js_7.numFrom)(await Promise.resolve(change(tx, fee - leastFee)));
1668
- if (needed > index_js_3.Zero) {
1669
- // No enough extra capacity to create new cells for change, collect inputs again
1670
- leastExtraCapacity = needed;
1671
- continue;
1672
- }
1673
- if ((await tx.getFee(from.client)) !== leastFee) {
1674
- throw new Error("The change function doesn't use all available capacity");
1675
- }
1676
- // New change cells created, update the fee
1677
- await from.prepareTransaction(tx);
1678
- const changedFee = tx.estimateFee(feeRate);
1679
- if (leastFee > changedFee) {
1680
- throw new Error("The change function removed existed transaction data");
1681
- }
1682
- // The fee has been paid
1683
- if (leastFee === changedFee) {
1684
- this.copy(tx);
1685
- return [collected, true];
1686
- }
1687
- // The fee after changing is more than the original fee
1688
- leastFee = changedFee;
1689
- }
1690
- }
1691
- /**
1692
- * Completes the transaction fee by adding inputs and creating a change output with the specified lock script.
1693
- * This is a convenience method that automatically creates a change cell with the provided lock script
1694
- * when there's excess capacity after paying the transaction fee.
1695
- *
1696
- * @param from - The signer to complete inputs from and prepare the transaction.
1697
- * @param change - The lock script for the change output cell.
1698
- * @param feeRate - Optional fee rate in shannons per 1000 bytes. If not provided, it will be fetched from the client.
1699
- * @param filter - Optional filter for selecting cells when adding inputs.
1700
- * @param options - Optional configuration object.
1701
- * @param options.feeRateBlockRange - Block range for fee rate calculation when feeRate is not provided.
1702
- * @param options.maxFeeRate - Maximum allowed fee rate.
1703
- * @param options.shouldAddInputs - Whether to add inputs automatically. Defaults to true.
1704
- * @returns A promise that resolves to a tuple containing:
1705
- * - The number of inputs added during the process
1706
- * - A boolean indicating whether change outputs were created (true) or fee was paid without change (false)
1707
- *
1708
- * @example
1709
- * ```typescript
1710
- * const changeScript = Script.from({
1711
- * codeHash: "0x...",
1712
- * hashType: "type",
1713
- * args: "0x..."
1714
- * });
1715
- *
1716
- * const [addedInputs, hasChange] = await tx.completeFeeChangeToLock(
1717
- * signer,
1718
- * changeScript,
1719
- * 1000n // 1000 shannons per 1000 bytes
1720
- * );
1721
- * ```
1722
- */
1723
- completeFeeChangeToLock(from, change, feeRate, filter, options) {
1724
- const script = script_js_1.Script.from(change);
1725
- return this.completeFee(from, (tx, capacity) => {
1726
- const changeCell = CellOutput.from({ capacity: 0, lock: script });
1727
- const occupiedCapacity = (0, index_js_3.fixedPointFrom)(changeCell.occupiedSize);
1728
- if (capacity < occupiedCapacity) {
1729
- return occupiedCapacity;
1730
- }
1731
- changeCell.capacity = capacity;
1732
- tx.addOutput(changeCell);
1733
- return 0;
1734
- }, feeRate, filter, options);
1735
- }
1736
- /**
1737
- * Completes the transaction fee using the signer's recommended address for change.
1738
- * This is a convenience method that automatically uses the signer's recommended
1739
- * address as the change destination, making it easier to complete transactions
1740
- * without manually specifying a change address.
1741
- *
1742
- * @param from - The signer to complete inputs from and prepare the transaction.
1743
- * @param feeRate - Optional fee rate in shannons per 1000 bytes. If not provided, it will be fetched from the client.
1744
- * @param filter - Optional filter for selecting cells when adding inputs.
1745
- * @param options - Optional configuration object.
1746
- * @param options.feeRateBlockRange - Block range for fee rate calculation when feeRate is not provided.
1747
- * @param options.maxFeeRate - Maximum allowed fee rate.
1748
- * @param options.shouldAddInputs - Whether to add inputs automatically. Defaults to true.
1749
- * @returns A promise that resolves to a tuple containing:
1750
- * - The number of inputs added during the process
1751
- * - A boolean indicating whether change outputs were created (true) or fee was paid without change (false)
1752
- *
1753
- * @example
1754
- * ```typescript
1755
- * const [addedInputs, hasChange] = await tx.completeFeeBy(
1756
- * signer,
1757
- * 1000n // 1000 shannons per 1000 bytes
1758
- * );
1759
- *
1760
- * // Change will automatically go to signer's recommended address
1761
- * ```
1762
- */
1763
- async completeFeeBy(from, feeRate, filter, options) {
1764
- const { script } = await from.getRecommendedAddressObj();
1765
- return this.completeFeeChangeToLock(from, script, feeRate, filter, options);
1766
- }
1767
- /**
1768
- * Completes the transaction fee by adding excess capacity to an existing output.
1769
- * Instead of creating a new change output, this method adds any excess capacity
1770
- * to the specified existing output in the transaction.
1771
- *
1772
- * @param from - The signer to complete inputs from and prepare the transaction.
1773
- * @param index - The index of the existing output to add excess capacity to.
1774
- * @param feeRate - Optional fee rate in shannons per 1000 bytes. If not provided, it will be fetched from the client.
1775
- * @param filter - Optional filter for selecting cells when adding inputs.
1776
- * @param options - Optional configuration object.
1777
- * @param options.feeRateBlockRange - Block range for fee rate calculation when feeRate is not provided.
1778
- * @param options.maxFeeRate - Maximum allowed fee rate.
1779
- * @param options.shouldAddInputs - Whether to add inputs automatically. Defaults to true.
1780
- * @returns A promise that resolves to a tuple containing:
1781
- * - The number of inputs added during the process
1782
- * - A boolean indicating whether change was applied (true) or fee was paid without change (false)
1783
- *
1784
- * @throws {Error} When the specified output index doesn't exist.
1785
- *
1786
- * @example
1787
- * ```typescript
1788
- * // Add excess capacity to the first output (index 0)
1789
- * const [addedInputs, hasChange] = await tx.completeFeeChangeToOutput(
1790
- * signer,
1791
- * 0, // Output index
1792
- * 1000n // 1000 shannons per 1000 bytes
1793
- * );
1794
- * ```
1795
- */
1796
- completeFeeChangeToOutput(from, index, feeRate, filter, options) {
1797
- const change = Number((0, index_js_7.numFrom)(index));
1798
- if (!this.outputs[change]) {
1799
- throw new Error("Non-existed output to change");
1800
- }
1801
- return this.completeFee(from, (tx, capacity) => {
1802
- tx.outputs[change].capacity += capacity;
1803
- return 0;
1804
- }, feeRate, filter, options);
1805
- }
1806
- };
1807
- exports.Transaction = Transaction;
1808
- exports.Transaction = Transaction = Transaction_1 = __decorate([
1809
- index_js_6.mol.codec(index_js_6.mol
1810
- .table({
1811
- raw: exports.RawTransaction,
1812
- witnesses: index_js_6.mol.BytesVec,
1813
- })
1814
- .mapIn((txLike) => {
1815
- const tx = Transaction.from(txLike);
1816
- return {
1817
- raw: tx,
1818
- witnesses: tx.witnesses,
1819
- };
1820
- })
1821
- .mapOut((tx) => Transaction.from({ ...tx.raw, witnesses: tx.witnesses })))
1822
- ], Transaction);
1823
- /**
1824
- * Calculate Nervos DAO profit between two blocks.
1825
- * This function computes the profit earned from a Nervos DAO deposit
1826
- * based on the capacity and the time period between deposit and withdrawal.
1827
- *
1828
- * @param profitableCapacity - The capacity that earns profit (total capacity minus occupied capacity).
1829
- * @param depositHeaderLike - The block header when the DAO deposit was made.
1830
- * @param withdrawHeaderLike - The block header when the DAO withdrawal is made.
1831
- * @returns The profit amount in CKB (capacity units).
1832
- *
1833
- * @example
1834
- * ```typescript
1835
- * const profit = calcDaoProfit(
1836
- * ccc.fixedPointFrom(100), // 100 CKB profitable capacity
1837
- * depositHeader,
1838
- * withdrawHeader
1839
- * );
1840
- * console.log(`Profit: ${profit} shannons`);
1841
- * ```
1842
- *
1843
- * @see {@link https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md | Nervos DAO RFC}
1844
- */
1845
- function calcDaoProfit(profitableCapacity, depositHeaderLike, withdrawHeaderLike) {
1846
- const depositHeader = index_js_2.ClientBlockHeader.from(depositHeaderLike);
1847
- const withdrawHeader = index_js_2.ClientBlockHeader.from(withdrawHeaderLike);
1848
- const profitableSize = (0, index_js_7.numFrom)(profitableCapacity);
1849
- return ((profitableSize * withdrawHeader.dao.ar) / depositHeader.dao.ar -
1850
- profitableSize);
1851
- }
1852
- /**
1853
- * Calculate claimable epoch for Nervos DAO withdrawal.
1854
- * This function determines the earliest epoch when a Nervos DAO withdrawal
1855
- * can be claimed based on the deposit and withdrawal epochs.
1856
- *
1857
- * @param depositHeader - The block header when the DAO deposit was made.
1858
- * @param withdrawHeader - The block header when the DAO withdrawal was initiated.
1859
- * @returns The epoch when the withdrawal can be claimed, represented as [number, index, length].
1860
- *
1861
- * @example
1862
- * ```typescript
1863
- * const claimEpoch = calcDaoClaimEpoch(depositHeader, withdrawHeader);
1864
- * console.log(`Can claim at epoch: ${claimEpoch[0]}, index: ${claimEpoch[1]}, length: ${claimEpoch[2]}`);
1865
- * ```
1866
- *
1867
- * @remarks
1868
- * The Nervos DAO has a minimum lock period of 180 epochs (~30 days).
1869
- * This function calculates the exact epoch when the withdrawal becomes claimable
1870
- * based on the deposit epoch and withdrawal epoch timing.
1871
- *
1872
- * @see {@link https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md | Nervos DAO RFC}
1873
- */
1874
- function calcDaoClaimEpoch(depositHeader, withdrawHeader) {
1875
- const depositEpoch = index_js_2.ClientBlockHeader.from(depositHeader).epoch;
1876
- const withdrawEpoch = index_js_2.ClientBlockHeader.from(withdrawHeader).epoch;
1877
- const intDiff = withdrawEpoch[0] - depositEpoch[0];
1878
- // deposit[1] withdraw[1]
1879
- // ---------- <= -----------
1880
- // deposit[2] withdraw[2]
1881
- if (intDiff % (0, index_js_7.numFrom)(180) !== (0, index_js_7.numFrom)(0) ||
1882
- depositEpoch[1] * withdrawEpoch[2] <= depositEpoch[2] * withdrawEpoch[1]) {
1883
- return [
1884
- depositEpoch[0] + (intDiff / (0, index_js_7.numFrom)(180) + (0, index_js_7.numFrom)(1)) * (0, index_js_7.numFrom)(180),
1885
- depositEpoch[1],
1886
- depositEpoch[2],
1887
- ];
1888
- }
1889
- return [
1890
- depositEpoch[0] + (intDiff / (0, index_js_7.numFrom)(180)) * (0, index_js_7.numFrom)(180),
1891
- depositEpoch[1],
1892
- depositEpoch[2],
1893
- ];
1894
- }