@ckb-ccc/core 0.0.0-canary-20250214032000

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 (623) hide show
  1. package/CHANGELOG.md +375 -0
  2. package/README.md +41 -0
  3. package/dist/address/address.advanced.d.ts +65 -0
  4. package/dist/address/address.advanced.d.ts.map +1 -0
  5. package/dist/address/address.advanced.js +147 -0
  6. package/dist/address/advanced.d.ts +2 -0
  7. package/dist/address/advanced.d.ts.map +1 -0
  8. package/dist/address/advanced.js +1 -0
  9. package/dist/address/index.d.ts +58 -0
  10. package/dist/address/index.d.ts.map +1 -0
  11. package/dist/address/index.js +78 -0
  12. package/dist/advanced.d.ts +3 -0
  13. package/dist/advanced.d.ts.map +1 -0
  14. package/dist/advanced.js +2 -0
  15. package/dist/advancedBarrel.d.ts +7 -0
  16. package/dist/advancedBarrel.d.ts.map +1 -0
  17. package/dist/advancedBarrel.js +6 -0
  18. package/dist/barrel.d.ts +14 -0
  19. package/dist/barrel.d.ts.map +1 -0
  20. package/dist/barrel.js +13 -0
  21. package/dist/bytes/advanced.d.ts +6 -0
  22. package/dist/bytes/advanced.d.ts.map +1 -0
  23. package/dist/bytes/advanced.js +1 -0
  24. package/dist/bytes/index.d.ts +108 -0
  25. package/dist/bytes/index.d.ts.map +1 -0
  26. package/dist/bytes/index.js +151 -0
  27. package/dist/ckb/advanced.d.ts +3 -0
  28. package/dist/ckb/advanced.d.ts.map +1 -0
  29. package/dist/ckb/advanced.js +2 -0
  30. package/dist/ckb/index.d.ts +4 -0
  31. package/dist/ckb/index.d.ts.map +1 -0
  32. package/dist/ckb/index.js +3 -0
  33. package/dist/ckb/script.advanced.d.ts +5 -0
  34. package/dist/ckb/script.advanced.d.ts.map +1 -0
  35. package/dist/ckb/script.advanced.js +13 -0
  36. package/dist/ckb/script.d.ts +143 -0
  37. package/dist/ckb/script.d.ts.map +1 -0
  38. package/dist/ckb/script.js +167 -0
  39. package/dist/ckb/transaction.advanced.d.ts +5 -0
  40. package/dist/ckb/transaction.advanced.d.ts.map +1 -0
  41. package/dist/ckb/transaction.advanced.js +9 -0
  42. package/dist/ckb/transaction.d.ts +893 -0
  43. package/dist/ckb/transaction.d.ts.map +1 -0
  44. package/dist/ckb/transaction.js +1299 -0
  45. package/dist/ckb/transactionLumos.d.ts +30 -0
  46. package/dist/ckb/transactionLumos.d.ts.map +1 -0
  47. package/dist/ckb/transactionLumos.js +1 -0
  48. package/dist/client/advanced.d.ts +6 -0
  49. package/dist/client/advanced.d.ts.map +1 -0
  50. package/dist/client/advanced.js +5 -0
  51. package/dist/client/cache/advanced.d.ts +2 -0
  52. package/dist/client/cache/advanced.d.ts.map +1 -0
  53. package/dist/client/cache/advanced.js +1 -0
  54. package/dist/client/cache/cache.d.ts +91 -0
  55. package/dist/client/cache/cache.d.ts.map +1 -0
  56. package/dist/client/cache/cache.js +128 -0
  57. package/dist/client/cache/index.d.ts +3 -0
  58. package/dist/client/cache/index.d.ts.map +1 -0
  59. package/dist/client/cache/index.js +2 -0
  60. package/dist/client/cache/memory.advanced.d.ts +22 -0
  61. package/dist/client/cache/memory.advanced.d.ts.map +1 -0
  62. package/dist/client/cache/memory.advanced.js +118 -0
  63. package/dist/client/cache/memory.d.ts +44 -0
  64. package/dist/client/cache/memory.d.ts.map +1 -0
  65. package/dist/client/cache/memory.js +137 -0
  66. package/dist/client/client.d.ts +98 -0
  67. package/dist/client/client.d.ts.map +1 -0
  68. package/dist/client/client.js +323 -0
  69. package/dist/client/clientPublicMainnet.advanced.d.ts +3 -0
  70. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -0
  71. package/dist/client/clientPublicMainnet.advanced.js +326 -0
  72. package/dist/client/clientPublicMainnet.d.ts +16 -0
  73. package/dist/client/clientPublicMainnet.d.ts.map +1 -0
  74. package/dist/client/clientPublicMainnet.js +40 -0
  75. package/dist/client/clientPublicTestnet.advanced.d.ts +3 -0
  76. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -0
  77. package/dist/client/clientPublicTestnet.advanced.js +336 -0
  78. package/dist/client/clientPublicTestnet.d.ts +16 -0
  79. package/dist/client/clientPublicTestnet.d.ts.map +1 -0
  80. package/dist/client/clientPublicTestnet.js +40 -0
  81. package/dist/client/clientTypes.advanced.d.ts +26 -0
  82. package/dist/client/clientTypes.advanced.d.ts.map +1 -0
  83. package/dist/client/clientTypes.advanced.js +7 -0
  84. package/dist/client/clientTypes.d.ts +360 -0
  85. package/dist/client/clientTypes.d.ts.map +1 -0
  86. package/dist/client/clientTypes.js +259 -0
  87. package/dist/client/index.d.ts +7 -0
  88. package/dist/client/index.d.ts.map +1 -0
  89. package/dist/client/index.js +6 -0
  90. package/dist/client/jsonRpc/advanced.d.ts +3 -0
  91. package/dist/client/jsonRpc/advanced.d.ts.map +1 -0
  92. package/dist/client/jsonRpc/advanced.js +2 -0
  93. package/dist/client/jsonRpc/client.d.ts +160 -0
  94. package/dist/client/jsonRpc/client.d.ts.map +1 -0
  95. package/dist/client/jsonRpc/client.js +220 -0
  96. package/dist/client/jsonRpc/index.d.ts +2 -0
  97. package/dist/client/jsonRpc/index.d.ts.map +1 -0
  98. package/dist/client/jsonRpc/index.js +1 -0
  99. package/dist/client/jsonRpc/transformers.d.ts +51 -0
  100. package/dist/client/jsonRpc/transformers.d.ts.map +1 -0
  101. package/dist/client/jsonRpc/transformers.js +246 -0
  102. package/dist/client/jsonRpc/types.d.ts +101 -0
  103. package/dist/client/jsonRpc/types.d.ts.map +1 -0
  104. package/dist/client/jsonRpc/types.js +1 -0
  105. package/dist/fixedPoint/index.d.ts +55 -0
  106. package/dist/fixedPoint/index.d.ts.map +1 -0
  107. package/dist/fixedPoint/index.js +68 -0
  108. package/dist/hasher/advanced.d.ts +2 -0
  109. package/dist/hasher/advanced.d.ts.map +1 -0
  110. package/dist/hasher/advanced.js +1 -0
  111. package/dist/hasher/hasher.d.ts +35 -0
  112. package/dist/hasher/hasher.d.ts.map +1 -0
  113. package/dist/hasher/hasher.js +1 -0
  114. package/dist/hasher/hasherCkb.d.ts +73 -0
  115. package/dist/hasher/hasherCkb.d.ts.map +1 -0
  116. package/dist/hasher/hasherCkb.js +88 -0
  117. package/dist/hasher/hasherKeecak256.d.ts +41 -0
  118. package/dist/hasher/hasherKeecak256.d.ts.map +1 -0
  119. package/dist/hasher/hasherKeecak256.js +46 -0
  120. package/dist/hasher/index.d.ts +4 -0
  121. package/dist/hasher/index.d.ts.map +1 -0
  122. package/dist/hasher/index.js +3 -0
  123. package/dist/hex/index.d.ts +27 -0
  124. package/dist/hex/index.d.ts.map +1 -0
  125. package/dist/hex/index.js +17 -0
  126. package/dist/index.d.ts +3 -0
  127. package/dist/index.d.ts.map +1 -0
  128. package/dist/index.js +2 -0
  129. package/dist/jsonRpc/advanced.d.ts +2 -0
  130. package/dist/jsonRpc/advanced.d.ts.map +1 -0
  131. package/dist/jsonRpc/advanced.js +1 -0
  132. package/dist/jsonRpc/index.d.ts +2 -0
  133. package/dist/jsonRpc/index.d.ts.map +1 -0
  134. package/dist/jsonRpc/index.js +1 -0
  135. package/dist/jsonRpc/requestor.d.ts +49 -0
  136. package/dist/jsonRpc/requestor.d.ts.map +1 -0
  137. package/dist/jsonRpc/requestor.js +109 -0
  138. package/dist/jsonRpc/transports/advanced.d.ts +6 -0
  139. package/dist/jsonRpc/transports/advanced.d.ts.map +1 -0
  140. package/dist/jsonRpc/transports/advanced.js +5 -0
  141. package/dist/jsonRpc/transports/factory.d.ts +6 -0
  142. package/dist/jsonRpc/transports/factory.d.ts.map +1 -0
  143. package/dist/jsonRpc/transports/factory.js +8 -0
  144. package/dist/jsonRpc/transports/fallback.d.ts +8 -0
  145. package/dist/jsonRpc/transports/fallback.d.ts.map +1 -0
  146. package/dist/jsonRpc/transports/fallback.js +22 -0
  147. package/dist/jsonRpc/transports/http.d.ts +8 -0
  148. package/dist/jsonRpc/transports/http.d.ts.map +1 -0
  149. package/dist/jsonRpc/transports/http.js +22 -0
  150. package/dist/jsonRpc/transports/transport.d.ts +18 -0
  151. package/dist/jsonRpc/transports/transport.d.ts.map +1 -0
  152. package/dist/jsonRpc/transports/transport.js +1 -0
  153. package/dist/jsonRpc/transports/webSocket.d.ts +11 -0
  154. package/dist/jsonRpc/transports/webSocket.d.ts.map +1 -0
  155. package/dist/jsonRpc/transports/webSocket.js +87 -0
  156. package/dist/keystore/index.d.ts +31 -0
  157. package/dist/keystore/index.d.ts.map +1 -0
  158. package/dist/keystore/index.js +106 -0
  159. package/dist/molecule/barrel.d.ts +4 -0
  160. package/dist/molecule/barrel.d.ts.map +1 -0
  161. package/dist/molecule/barrel.js +3 -0
  162. package/dist/molecule/codec.d.ts +120 -0
  163. package/dist/molecule/codec.d.ts.map +1 -0
  164. package/dist/molecule/codec.js +468 -0
  165. package/dist/molecule/entity.d.ts +119 -0
  166. package/dist/molecule/entity.d.ts.map +1 -0
  167. package/dist/molecule/entity.js +134 -0
  168. package/dist/molecule/index.d.ts +2 -0
  169. package/dist/molecule/index.d.ts.map +1 -0
  170. package/dist/molecule/index.js +1 -0
  171. package/dist/molecule/predefined.d.ts +57 -0
  172. package/dist/molecule/predefined.d.ts.map +1 -0
  173. package/dist/molecule/predefined.js +83 -0
  174. package/dist/num/index.d.ts +148 -0
  175. package/dist/num/index.d.ts.map +1 -0
  176. package/dist/num/index.js +188 -0
  177. package/dist/package.json +3 -0
  178. package/dist/signer/btc/index.d.ts +4 -0
  179. package/dist/signer/btc/index.d.ts.map +1 -0
  180. package/dist/signer/btc/index.js +3 -0
  181. package/dist/signer/btc/signerBtc.d.ts +59 -0
  182. package/dist/signer/btc/signerBtc.d.ts.map +1 -0
  183. package/dist/signer/btc/signerBtc.js +83 -0
  184. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +55 -0
  185. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -0
  186. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +61 -0
  187. package/dist/signer/btc/verify.d.ts +19 -0
  188. package/dist/signer/btc/verify.d.ts.map +1 -0
  189. package/dist/signer/btc/verify.js +33 -0
  190. package/dist/signer/ckb/index.d.ts +6 -0
  191. package/dist/signer/ckb/index.d.ts.map +1 -0
  192. package/dist/signer/ckb/index.js +5 -0
  193. package/dist/signer/ckb/signerCkbPrivateKey.d.ts +16 -0
  194. package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -0
  195. package/dist/signer/ckb/signerCkbPrivateKey.js +42 -0
  196. package/dist/signer/ckb/signerCkbPublicKey.d.ts +27 -0
  197. package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +1 -0
  198. package/dist/signer/ckb/signerCkbPublicKey.js +105 -0
  199. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +56 -0
  200. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -0
  201. package/dist/signer/ckb/signerCkbScriptReadonly.js +66 -0
  202. package/dist/signer/ckb/verifyCkbSecp256k1.d.ts +11 -0
  203. package/dist/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -0
  204. package/dist/signer/ckb/verifyCkbSecp256k1.js +20 -0
  205. package/dist/signer/ckb/verifyJoyId.d.ts +6 -0
  206. package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -0
  207. package/dist/signer/ckb/verifyJoyId.js +16 -0
  208. package/dist/signer/doge/index.d.ts +5 -0
  209. package/dist/signer/doge/index.d.ts.map +1 -0
  210. package/dist/signer/doge/index.js +4 -0
  211. package/dist/signer/doge/signerDoge.d.ts +52 -0
  212. package/dist/signer/doge/signerDoge.d.ts.map +1 -0
  213. package/dist/signer/doge/signerDoge.js +82 -0
  214. package/dist/signer/doge/signerDogeAddressReadonly.d.ts +41 -0
  215. package/dist/signer/doge/signerDogeAddressReadonly.d.ts.map +1 -0
  216. package/dist/signer/doge/signerDogeAddressReadonly.js +45 -0
  217. package/dist/signer/doge/signerDogePrivateKey.d.ts +52 -0
  218. package/dist/signer/doge/signerDogePrivateKey.d.ts.map +1 -0
  219. package/dist/signer/doge/signerDogePrivateKey.js +68 -0
  220. package/dist/signer/doge/verify.d.ts +6 -0
  221. package/dist/signer/doge/verify.d.ts.map +1 -0
  222. package/dist/signer/doge/verify.js +19 -0
  223. package/dist/signer/dummy/alwaysError.d.ts +12 -0
  224. package/dist/signer/dummy/alwaysError.d.ts.map +1 -0
  225. package/dist/signer/dummy/alwaysError.js +13 -0
  226. package/dist/signer/dummy/dummy.d.ts +15 -0
  227. package/dist/signer/dummy/dummy.d.ts.map +1 -0
  228. package/dist/signer/dummy/dummy.js +22 -0
  229. package/dist/signer/dummy/index.d.ts +4 -0
  230. package/dist/signer/dummy/index.d.ts.map +1 -0
  231. package/dist/signer/dummy/index.js +3 -0
  232. package/dist/signer/dummy/openLink.d.ts +12 -0
  233. package/dist/signer/dummy/openLink.d.ts.map +1 -0
  234. package/dist/signer/dummy/openLink.js +13 -0
  235. package/dist/signer/evm/index.d.ts +4 -0
  236. package/dist/signer/evm/index.d.ts.map +1 -0
  237. package/dist/signer/evm/index.js +3 -0
  238. package/dist/signer/evm/signerEvm.d.ts +59 -0
  239. package/dist/signer/evm/signerEvm.d.ts.map +1 -0
  240. package/dist/signer/evm/signerEvm.js +139 -0
  241. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +47 -0
  242. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -0
  243. package/dist/signer/evm/signerEvmAddressReadonly.js +51 -0
  244. package/dist/signer/evm/verify.d.ts +6 -0
  245. package/dist/signer/evm/verify.d.ts.map +1 -0
  246. package/dist/signer/evm/verify.js +9 -0
  247. package/dist/signer/index.d.ts +8 -0
  248. package/dist/signer/index.d.ts.map +1 -0
  249. package/dist/signer/index.js +7 -0
  250. package/dist/signer/nostr/index.d.ts +4 -0
  251. package/dist/signer/nostr/index.d.ts.map +1 -0
  252. package/dist/signer/nostr/index.js +3 -0
  253. package/dist/signer/nostr/signerNostr.d.ts +72 -0
  254. package/dist/signer/nostr/signerNostr.d.ts.map +1 -0
  255. package/dist/signer/nostr/signerNostr.js +88 -0
  256. package/dist/signer/nostr/signerNostrPrivateKey.d.ts +12 -0
  257. package/dist/signer/nostr/signerNostrPrivateKey.d.ts.map +1 -0
  258. package/dist/signer/nostr/signerNostrPrivateKey.js +28 -0
  259. package/dist/signer/nostr/verify.d.ts +9 -0
  260. package/dist/signer/nostr/verify.d.ts.map +1 -0
  261. package/dist/signer/nostr/verify.js +55 -0
  262. package/dist/signer/signer/index.d.ts +237 -0
  263. package/dist/signer/signer/index.d.ts.map +1 -0
  264. package/dist/signer/signer/index.js +274 -0
  265. package/dist/utils/index.d.ts +97 -0
  266. package/dist/utils/index.d.ts.map +1 -0
  267. package/dist/utils/index.js +55 -0
  268. package/dist.commonjs/address/address.advanced.d.ts +65 -0
  269. package/dist.commonjs/address/address.advanced.d.ts.map +1 -0
  270. package/dist.commonjs/address/address.advanced.js +152 -0
  271. package/dist.commonjs/address/advanced.d.ts +2 -0
  272. package/dist.commonjs/address/advanced.d.ts.map +1 -0
  273. package/dist.commonjs/address/advanced.js +17 -0
  274. package/dist.commonjs/address/index.d.ts +58 -0
  275. package/dist.commonjs/address/index.d.ts.map +1 -0
  276. package/dist.commonjs/address/index.js +82 -0
  277. package/dist.commonjs/advanced.d.ts +3 -0
  278. package/dist.commonjs/advanced.d.ts.map +1 -0
  279. package/dist.commonjs/advanced.js +41 -0
  280. package/dist.commonjs/advancedBarrel.d.ts +7 -0
  281. package/dist.commonjs/advancedBarrel.d.ts.map +1 -0
  282. package/dist.commonjs/advancedBarrel.js +22 -0
  283. package/dist.commonjs/barrel.d.ts +14 -0
  284. package/dist.commonjs/barrel.d.ts.map +1 -0
  285. package/dist.commonjs/barrel.js +29 -0
  286. package/dist.commonjs/bytes/advanced.d.ts +6 -0
  287. package/dist.commonjs/bytes/advanced.d.ts.map +1 -0
  288. package/dist.commonjs/bytes/advanced.js +2 -0
  289. package/dist.commonjs/bytes/index.d.ts +108 -0
  290. package/dist.commonjs/bytes/index.d.ts.map +1 -0
  291. package/dist.commonjs/bytes/index.js +158 -0
  292. package/dist.commonjs/ckb/advanced.d.ts +3 -0
  293. package/dist.commonjs/ckb/advanced.d.ts.map +1 -0
  294. package/dist.commonjs/ckb/advanced.js +18 -0
  295. package/dist.commonjs/ckb/index.d.ts +4 -0
  296. package/dist.commonjs/ckb/index.d.ts.map +1 -0
  297. package/dist.commonjs/ckb/index.js +19 -0
  298. package/dist.commonjs/ckb/script.advanced.d.ts +5 -0
  299. package/dist.commonjs/ckb/script.advanced.d.ts.map +1 -0
  300. package/dist.commonjs/ckb/script.advanced.js +16 -0
  301. package/dist.commonjs/ckb/script.d.ts +143 -0
  302. package/dist.commonjs/ckb/script.d.ts.map +1 -0
  303. package/dist.commonjs/ckb/script.js +173 -0
  304. package/dist.commonjs/ckb/transaction.advanced.d.ts +5 -0
  305. package/dist.commonjs/ckb/transaction.advanced.d.ts.map +1 -0
  306. package/dist.commonjs/ckb/transaction.advanced.js +12 -0
  307. package/dist.commonjs/ckb/transaction.d.ts +893 -0
  308. package/dist.commonjs/ckb/transaction.d.ts.map +1 -0
  309. package/dist.commonjs/ckb/transaction.js +1310 -0
  310. package/dist.commonjs/ckb/transactionLumos.d.ts +30 -0
  311. package/dist.commonjs/ckb/transactionLumos.d.ts.map +1 -0
  312. package/dist.commonjs/ckb/transactionLumos.js +2 -0
  313. package/dist.commonjs/client/advanced.d.ts +6 -0
  314. package/dist.commonjs/client/advanced.d.ts.map +1 -0
  315. package/dist.commonjs/client/advanced.js +21 -0
  316. package/dist.commonjs/client/cache/advanced.d.ts +2 -0
  317. package/dist.commonjs/client/cache/advanced.d.ts.map +1 -0
  318. package/dist.commonjs/client/cache/advanced.js +17 -0
  319. package/dist.commonjs/client/cache/cache.d.ts +91 -0
  320. package/dist.commonjs/client/cache/cache.d.ts.map +1 -0
  321. package/dist.commonjs/client/cache/cache.js +132 -0
  322. package/dist.commonjs/client/cache/index.d.ts +3 -0
  323. package/dist.commonjs/client/cache/index.d.ts.map +1 -0
  324. package/dist.commonjs/client/cache/index.js +18 -0
  325. package/dist.commonjs/client/cache/memory.advanced.d.ts +22 -0
  326. package/dist.commonjs/client/cache/memory.advanced.d.ts.map +1 -0
  327. package/dist.commonjs/client/cache/memory.advanced.js +127 -0
  328. package/dist.commonjs/client/cache/memory.d.ts +44 -0
  329. package/dist.commonjs/client/cache/memory.d.ts.map +1 -0
  330. package/dist.commonjs/client/cache/memory.js +141 -0
  331. package/dist.commonjs/client/client.d.ts +98 -0
  332. package/dist.commonjs/client/client.d.ts.map +1 -0
  333. package/dist.commonjs/client/client.js +327 -0
  334. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +3 -0
  335. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -0
  336. package/dist.commonjs/client/clientPublicMainnet.advanced.js +329 -0
  337. package/dist.commonjs/client/clientPublicMainnet.d.ts +16 -0
  338. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -0
  339. package/dist.commonjs/client/clientPublicMainnet.js +47 -0
  340. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -0
  341. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -0
  342. package/dist.commonjs/client/clientPublicTestnet.advanced.js +339 -0
  343. package/dist.commonjs/client/clientPublicTestnet.d.ts +16 -0
  344. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -0
  345. package/dist.commonjs/client/clientPublicTestnet.js +47 -0
  346. package/dist.commonjs/client/clientTypes.advanced.d.ts +26 -0
  347. package/dist.commonjs/client/clientTypes.advanced.d.ts.map +1 -0
  348. package/dist.commonjs/client/clientTypes.advanced.js +11 -0
  349. package/dist.commonjs/client/clientTypes.d.ts +360 -0
  350. package/dist.commonjs/client/clientTypes.d.ts.map +1 -0
  351. package/dist.commonjs/client/clientTypes.js +278 -0
  352. package/dist.commonjs/client/index.d.ts +7 -0
  353. package/dist.commonjs/client/index.d.ts.map +1 -0
  354. package/dist.commonjs/client/index.js +22 -0
  355. package/dist.commonjs/client/jsonRpc/advanced.d.ts +3 -0
  356. package/dist.commonjs/client/jsonRpc/advanced.d.ts.map +1 -0
  357. package/dist.commonjs/client/jsonRpc/advanced.js +18 -0
  358. package/dist.commonjs/client/jsonRpc/client.d.ts +160 -0
  359. package/dist.commonjs/client/jsonRpc/client.d.ts.map +1 -0
  360. package/dist.commonjs/client/jsonRpc/client.js +224 -0
  361. package/dist.commonjs/client/jsonRpc/index.d.ts +2 -0
  362. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -0
  363. package/dist.commonjs/client/jsonRpc/index.js +17 -0
  364. package/dist.commonjs/client/jsonRpc/transformers.d.ts +51 -0
  365. package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -0
  366. package/dist.commonjs/client/jsonRpc/transformers.js +250 -0
  367. package/dist.commonjs/client/jsonRpc/types.d.ts +101 -0
  368. package/dist.commonjs/client/jsonRpc/types.d.ts.map +1 -0
  369. package/dist.commonjs/client/jsonRpc/types.js +2 -0
  370. package/dist.commonjs/fixedPoint/index.d.ts +55 -0
  371. package/dist.commonjs/fixedPoint/index.d.ts.map +1 -0
  372. package/dist.commonjs/fixedPoint/index.js +73 -0
  373. package/dist.commonjs/hasher/advanced.d.ts +2 -0
  374. package/dist.commonjs/hasher/advanced.d.ts.map +1 -0
  375. package/dist.commonjs/hasher/advanced.js +4 -0
  376. package/dist.commonjs/hasher/hasher.d.ts +35 -0
  377. package/dist.commonjs/hasher/hasher.d.ts.map +1 -0
  378. package/dist.commonjs/hasher/hasher.js +2 -0
  379. package/dist.commonjs/hasher/hasherCkb.d.ts +73 -0
  380. package/dist.commonjs/hasher/hasherCkb.d.ts.map +1 -0
  381. package/dist.commonjs/hasher/hasherCkb.js +94 -0
  382. package/dist.commonjs/hasher/hasherKeecak256.d.ts +41 -0
  383. package/dist.commonjs/hasher/hasherKeecak256.d.ts.map +1 -0
  384. package/dist.commonjs/hasher/hasherKeecak256.js +50 -0
  385. package/dist.commonjs/hasher/index.d.ts +4 -0
  386. package/dist.commonjs/hasher/index.d.ts.map +1 -0
  387. package/dist.commonjs/hasher/index.js +19 -0
  388. package/dist.commonjs/hex/index.d.ts +27 -0
  389. package/dist.commonjs/hex/index.d.ts.map +1 -0
  390. package/dist.commonjs/hex/index.js +20 -0
  391. package/dist.commonjs/index.d.ts +3 -0
  392. package/dist.commonjs/index.d.ts.map +1 -0
  393. package/dist.commonjs/index.js +41 -0
  394. package/dist.commonjs/jsonRpc/advanced.d.ts +2 -0
  395. package/dist.commonjs/jsonRpc/advanced.d.ts.map +1 -0
  396. package/dist.commonjs/jsonRpc/advanced.js +17 -0
  397. package/dist.commonjs/jsonRpc/index.d.ts +2 -0
  398. package/dist.commonjs/jsonRpc/index.d.ts.map +1 -0
  399. package/dist.commonjs/jsonRpc/index.js +17 -0
  400. package/dist.commonjs/jsonRpc/requestor.d.ts +49 -0
  401. package/dist.commonjs/jsonRpc/requestor.d.ts.map +1 -0
  402. package/dist.commonjs/jsonRpc/requestor.js +113 -0
  403. package/dist.commonjs/jsonRpc/transports/advanced.d.ts +6 -0
  404. package/dist.commonjs/jsonRpc/transports/advanced.d.ts.map +1 -0
  405. package/dist.commonjs/jsonRpc/transports/advanced.js +21 -0
  406. package/dist.commonjs/jsonRpc/transports/factory.d.ts +6 -0
  407. package/dist.commonjs/jsonRpc/transports/factory.d.ts.map +1 -0
  408. package/dist.commonjs/jsonRpc/transports/factory.js +11 -0
  409. package/dist.commonjs/jsonRpc/transports/fallback.d.ts +8 -0
  410. package/dist.commonjs/jsonRpc/transports/fallback.d.ts.map +1 -0
  411. package/dist.commonjs/jsonRpc/transports/fallback.js +26 -0
  412. package/dist.commonjs/jsonRpc/transports/http.d.ts +8 -0
  413. package/dist.commonjs/jsonRpc/transports/http.d.ts.map +1 -0
  414. package/dist.commonjs/jsonRpc/transports/http.js +26 -0
  415. package/dist.commonjs/jsonRpc/transports/transport.d.ts +18 -0
  416. package/dist.commonjs/jsonRpc/transports/transport.d.ts.map +1 -0
  417. package/dist.commonjs/jsonRpc/transports/transport.js +2 -0
  418. package/dist.commonjs/jsonRpc/transports/webSocket.d.ts +11 -0
  419. package/dist.commonjs/jsonRpc/transports/webSocket.d.ts.map +1 -0
  420. package/dist.commonjs/jsonRpc/transports/webSocket.js +94 -0
  421. package/dist.commonjs/keystore/index.d.ts +31 -0
  422. package/dist.commonjs/keystore/index.d.ts.map +1 -0
  423. package/dist.commonjs/keystore/index.js +110 -0
  424. package/dist.commonjs/molecule/barrel.d.ts +4 -0
  425. package/dist.commonjs/molecule/barrel.d.ts.map +1 -0
  426. package/dist.commonjs/molecule/barrel.js +19 -0
  427. package/dist.commonjs/molecule/codec.d.ts +120 -0
  428. package/dist.commonjs/molecule/codec.d.ts.map +1 -0
  429. package/dist.commonjs/molecule/codec.js +483 -0
  430. package/dist.commonjs/molecule/entity.d.ts +119 -0
  431. package/dist.commonjs/molecule/entity.d.ts.map +1 -0
  432. package/dist.commonjs/molecule/entity.js +139 -0
  433. package/dist.commonjs/molecule/index.d.ts +2 -0
  434. package/dist.commonjs/molecule/index.d.ts.map +1 -0
  435. package/dist.commonjs/molecule/index.js +37 -0
  436. package/dist.commonjs/molecule/predefined.d.ts +57 -0
  437. package/dist.commonjs/molecule/predefined.d.ts.map +1 -0
  438. package/dist.commonjs/molecule/predefined.js +87 -0
  439. package/dist.commonjs/num/index.d.ts +148 -0
  440. package/dist.commonjs/num/index.d.ts.map +1 -0
  441. package/dist.commonjs/num/index.js +200 -0
  442. package/dist.commonjs/package.json +3 -0
  443. package/dist.commonjs/signer/btc/index.d.ts +4 -0
  444. package/dist.commonjs/signer/btc/index.d.ts.map +1 -0
  445. package/dist.commonjs/signer/btc/index.js +19 -0
  446. package/dist.commonjs/signer/btc/signerBtc.d.ts +59 -0
  447. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -0
  448. package/dist.commonjs/signer/btc/signerBtc.js +87 -0
  449. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +55 -0
  450. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -0
  451. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +65 -0
  452. package/dist.commonjs/signer/btc/verify.d.ts +19 -0
  453. package/dist.commonjs/signer/btc/verify.d.ts.map +1 -0
  454. package/dist.commonjs/signer/btc/verify.js +42 -0
  455. package/dist.commonjs/signer/ckb/index.d.ts +6 -0
  456. package/dist.commonjs/signer/ckb/index.d.ts.map +1 -0
  457. package/dist.commonjs/signer/ckb/index.js +21 -0
  458. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +16 -0
  459. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -0
  460. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +46 -0
  461. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +27 -0
  462. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +1 -0
  463. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +109 -0
  464. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +56 -0
  465. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -0
  466. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +70 -0
  467. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +11 -0
  468. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -0
  469. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +24 -0
  470. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +6 -0
  471. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
  472. package/dist.commonjs/signer/ckb/verifyJoyId.js +19 -0
  473. package/dist.commonjs/signer/doge/index.d.ts +5 -0
  474. package/dist.commonjs/signer/doge/index.d.ts.map +1 -0
  475. package/dist.commonjs/signer/doge/index.js +20 -0
  476. package/dist.commonjs/signer/doge/signerDoge.d.ts +52 -0
  477. package/dist.commonjs/signer/doge/signerDoge.d.ts.map +1 -0
  478. package/dist.commonjs/signer/doge/signerDoge.js +89 -0
  479. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts +41 -0
  480. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts.map +1 -0
  481. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.js +49 -0
  482. package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts +52 -0
  483. package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts.map +1 -0
  484. package/dist.commonjs/signer/doge/signerDogePrivateKey.js +72 -0
  485. package/dist.commonjs/signer/doge/verify.d.ts +6 -0
  486. package/dist.commonjs/signer/doge/verify.d.ts.map +1 -0
  487. package/dist.commonjs/signer/doge/verify.js +22 -0
  488. package/dist.commonjs/signer/dummy/alwaysError.d.ts +12 -0
  489. package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -0
  490. package/dist.commonjs/signer/dummy/alwaysError.js +17 -0
  491. package/dist.commonjs/signer/dummy/dummy.d.ts +15 -0
  492. package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -0
  493. package/dist.commonjs/signer/dummy/dummy.js +26 -0
  494. package/dist.commonjs/signer/dummy/index.d.ts +4 -0
  495. package/dist.commonjs/signer/dummy/index.d.ts.map +1 -0
  496. package/dist.commonjs/signer/dummy/index.js +19 -0
  497. package/dist.commonjs/signer/dummy/openLink.d.ts +12 -0
  498. package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -0
  499. package/dist.commonjs/signer/dummy/openLink.js +17 -0
  500. package/dist.commonjs/signer/evm/index.d.ts +4 -0
  501. package/dist.commonjs/signer/evm/index.d.ts.map +1 -0
  502. package/dist.commonjs/signer/evm/index.js +19 -0
  503. package/dist.commonjs/signer/evm/signerEvm.d.ts +59 -0
  504. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -0
  505. package/dist.commonjs/signer/evm/signerEvm.js +143 -0
  506. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +47 -0
  507. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -0
  508. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +55 -0
  509. package/dist.commonjs/signer/evm/verify.d.ts +6 -0
  510. package/dist.commonjs/signer/evm/verify.d.ts.map +1 -0
  511. package/dist.commonjs/signer/evm/verify.js +12 -0
  512. package/dist.commonjs/signer/index.d.ts +8 -0
  513. package/dist.commonjs/signer/index.d.ts.map +1 -0
  514. package/dist.commonjs/signer/index.js +23 -0
  515. package/dist.commonjs/signer/nostr/index.d.ts +4 -0
  516. package/dist.commonjs/signer/nostr/index.d.ts.map +1 -0
  517. package/dist.commonjs/signer/nostr/index.js +19 -0
  518. package/dist.commonjs/signer/nostr/signerNostr.d.ts +72 -0
  519. package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +1 -0
  520. package/dist.commonjs/signer/nostr/signerNostr.js +92 -0
  521. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts +12 -0
  522. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts.map +1 -0
  523. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.js +32 -0
  524. package/dist.commonjs/signer/nostr/verify.d.ts +9 -0
  525. package/dist.commonjs/signer/nostr/verify.d.ts.map +1 -0
  526. package/dist.commonjs/signer/nostr/verify.js +60 -0
  527. package/dist.commonjs/signer/signer/index.d.ts +237 -0
  528. package/dist.commonjs/signer/signer/index.d.ts.map +1 -0
  529. package/dist.commonjs/signer/signer/index.js +280 -0
  530. package/dist.commonjs/utils/index.d.ts +97 -0
  531. package/dist.commonjs/utils/index.d.ts.map +1 -0
  532. package/dist.commonjs/utils/index.js +62 -0
  533. package/jest.config.js +5 -0
  534. package/package.json +80 -0
  535. package/src/address/address.advanced.ts +182 -0
  536. package/src/address/advanced.ts +1 -0
  537. package/src/address/index.ts +127 -0
  538. package/src/advanced.ts +2 -0
  539. package/src/advancedBarrel.ts +6 -0
  540. package/src/barrel.ts +13 -0
  541. package/src/bytes/advanced.ts +14 -0
  542. package/src/bytes/index.ts +184 -0
  543. package/src/ckb/advanced.ts +2 -0
  544. package/src/ckb/index.ts +3 -0
  545. package/src/ckb/script.advanced.ts +15 -0
  546. package/src/ckb/script.ts +214 -0
  547. package/src/ckb/transaction.advanced.ts +11 -0
  548. package/src/ckb/transaction.ts +1781 -0
  549. package/src/ckb/transactionLumos.ts +27 -0
  550. package/src/client/advanced.ts +5 -0
  551. package/src/client/cache/advanced.ts +1 -0
  552. package/src/client/cache/cache.ts +188 -0
  553. package/src/client/cache/index.ts +2 -0
  554. package/src/client/cache/memory.advanced.ts +190 -0
  555. package/src/client/cache/memory.ts +219 -0
  556. package/src/client/client.ts +703 -0
  557. package/src/client/clientPublicMainnet.advanced.ts +372 -0
  558. package/src/client/clientPublicMainnet.ts +54 -0
  559. package/src/client/clientPublicTestnet.advanced.ts +384 -0
  560. package/src/client/clientPublicTestnet.ts +54 -0
  561. package/src/client/clientTypes.advanced.ts +30 -0
  562. package/src/client/clientTypes.ts +590 -0
  563. package/src/client/index.ts +6 -0
  564. package/src/client/jsonRpc/advanced.ts +2 -0
  565. package/src/client/jsonRpc/client.ts +397 -0
  566. package/src/client/jsonRpc/index.ts +1 -0
  567. package/src/client/jsonRpc/transformers.ts +358 -0
  568. package/src/client/jsonRpc/types.ts +115 -0
  569. package/src/fixedPoint/index.ts +92 -0
  570. package/src/hasher/advanced.ts +1 -0
  571. package/src/hasher/hasher.ts +38 -0
  572. package/src/hasher/hasherCkb.ts +107 -0
  573. package/src/hasher/hasherKeecak256.ts +55 -0
  574. package/src/hasher/index.ts +3 -0
  575. package/src/hex/index.ts +30 -0
  576. package/src/index.ts +2 -0
  577. package/src/jsonRpc/advanced.ts +1 -0
  578. package/src/jsonRpc/index.ts +1 -0
  579. package/src/jsonRpc/requestor.ts +166 -0
  580. package/src/jsonRpc/transports/advanced.ts +5 -0
  581. package/src/jsonRpc/transports/factory.ts +10 -0
  582. package/src/jsonRpc/transports/fallback.ts +27 -0
  583. package/src/jsonRpc/transports/http.ts +28 -0
  584. package/src/jsonRpc/transports/transport.ts +18 -0
  585. package/src/jsonRpc/transports/webSocket.ts +114 -0
  586. package/src/keystore/index.ts +162 -0
  587. package/src/molecule/barrel.ts +3 -0
  588. package/src/molecule/codec.ts +651 -0
  589. package/src/molecule/entity.ts +183 -0
  590. package/src/molecule/index.ts +1 -0
  591. package/src/molecule/predefined.ts +97 -0
  592. package/src/num/index.ts +217 -0
  593. package/src/signer/btc/index.ts +3 -0
  594. package/src/signer/btc/signerBtc.ts +126 -0
  595. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +73 -0
  596. package/src/signer/btc/verify.ts +49 -0
  597. package/src/signer/ckb/index.ts +5 -0
  598. package/src/signer/ckb/signerCkbPrivateKey.ts +65 -0
  599. package/src/signer/ckb/signerCkbPublicKey.ts +151 -0
  600. package/src/signer/ckb/signerCkbScriptReadonly.ts +78 -0
  601. package/src/signer/ckb/verifyCkbSecp256k1.ts +33 -0
  602. package/src/signer/ckb/verifyJoyId.ts +27 -0
  603. package/src/signer/doge/index.ts +4 -0
  604. package/src/signer/doge/signerDoge.ts +116 -0
  605. package/src/signer/doge/signerDogeAddressReadonly.ts +52 -0
  606. package/src/signer/doge/signerDogePrivateKey.ts +97 -0
  607. package/src/signer/doge/verify.ts +40 -0
  608. package/src/signer/dummy/alwaysError.ts +20 -0
  609. package/src/signer/dummy/dummy.ts +31 -0
  610. package/src/signer/dummy/index.ts +3 -0
  611. package/src/signer/dummy/openLink.ts +20 -0
  612. package/src/signer/evm/index.ts +3 -0
  613. package/src/signer/evm/signerEvm.ts +259 -0
  614. package/src/signer/evm/signerEvmAddressReadonly.ts +60 -0
  615. package/src/signer/evm/verify.ts +19 -0
  616. package/src/signer/index.ts +7 -0
  617. package/src/signer/nostr/index.ts +3 -0
  618. package/src/signer/nostr/signerNostr.ts +141 -0
  619. package/src/signer/nostr/signerNostrPrivateKey.ts +37 -0
  620. package/src/signer/nostr/verify.ts +72 -0
  621. package/src/signer/signer/index.ts +468 -0
  622. package/src/utils/index.ts +198 -0
  623. package/typedoc.json +6 -0
@@ -0,0 +1,703 @@
1
+ import {
2
+ Cell,
3
+ CellDep,
4
+ OutPoint,
5
+ OutPointLike,
6
+ ScriptLike,
7
+ Transaction,
8
+ TransactionLike,
9
+ } from "../ckb/index.js";
10
+ import { Zero } from "../fixedPoint/index.js";
11
+ import { Hex, HexLike, hexFrom } from "../hex/index.js";
12
+ import { Num, NumLike, numFrom, numMax, numMin } from "../num/index.js";
13
+ import { reduceAsync, sleep } from "../utils/index.js";
14
+ import { ClientCache } from "./cache/index.js";
15
+ import { ClientCacheMemory } from "./cache/memory.js";
16
+ import {
17
+ CONFIRMED_BLOCK_TIME,
18
+ ClientCollectableSearchKeyLike,
19
+ DEFAULT_MAX_FEE_RATE,
20
+ DEFAULT_MIN_FEE_RATE,
21
+ } from "./clientTypes.advanced.js";
22
+ import {
23
+ CellDepInfo,
24
+ CellDepInfoLike,
25
+ ClientBlock,
26
+ ClientBlockHeader,
27
+ ClientFindCellsResponse,
28
+ ClientFindTransactionsGroupedResponse,
29
+ ClientFindTransactionsResponse,
30
+ ClientIndexerSearchKey,
31
+ ClientIndexerSearchKeyLike,
32
+ ClientIndexerSearchKeyTransactionLike,
33
+ ClientTransactionResponse,
34
+ ErrorClientMaxFeeRateExceeded,
35
+ ErrorClientWaitTransactionTimeout,
36
+ KnownScript,
37
+ OutputsValidator,
38
+ ScriptInfo,
39
+ } from "./clientTypes.js";
40
+
41
+ function hasHeaderConfirmed(header: ClientBlockHeader): boolean {
42
+ return numFrom(Date.now()) - header.timestamp >= CONFIRMED_BLOCK_TIME;
43
+ }
44
+
45
+ /**
46
+ * @public
47
+ */
48
+ export abstract class Client {
49
+ public cache: ClientCache;
50
+
51
+ constructor(config?: { cache?: ClientCache }) {
52
+ this.cache = config?.cache ?? new ClientCacheMemory();
53
+ }
54
+
55
+ abstract get url(): string;
56
+ abstract get addressPrefix(): string;
57
+
58
+ abstract getKnownScript(script: KnownScript): Promise<ScriptInfo>;
59
+
60
+ abstract getFeeRateStatistics(
61
+ blockRange?: NumLike,
62
+ ): Promise<{ mean: Num; median: Num }>;
63
+ async getFeeRate(
64
+ blockRange?: NumLike,
65
+ options?: { maxFeeRate?: NumLike },
66
+ ): Promise<Num> {
67
+ const feeRate = numMax(
68
+ (await this.getFeeRateStatistics(blockRange)).median,
69
+ DEFAULT_MIN_FEE_RATE,
70
+ );
71
+
72
+ const maxFeeRate = numFrom(options?.maxFeeRate ?? DEFAULT_MAX_FEE_RATE);
73
+ if (maxFeeRate === Zero) {
74
+ return feeRate;
75
+ }
76
+
77
+ return numMin(feeRate, maxFeeRate);
78
+ }
79
+
80
+ abstract getTip(): Promise<Num>;
81
+ abstract getTipHeader(verbosity?: number | null): Promise<ClientBlockHeader>;
82
+ abstract getBlockByNumberNoCache(
83
+ blockNumber: NumLike,
84
+ verbosity?: number | null,
85
+ withCycles?: boolean | null,
86
+ ): Promise<ClientBlock | undefined>;
87
+ abstract getBlockByHashNoCache(
88
+ blockHash: HexLike,
89
+ verbosity?: number | null,
90
+ withCycles?: boolean | null,
91
+ ): Promise<ClientBlock | undefined>;
92
+ abstract getHeaderByNumberNoCache(
93
+ blockNumber: NumLike,
94
+ verbosity?: number | null,
95
+ ): Promise<ClientBlockHeader | undefined>;
96
+ abstract getHeaderByHashNoCache(
97
+ blockHash: HexLike,
98
+ verbosity?: number | null,
99
+ ): Promise<ClientBlockHeader | undefined>;
100
+ async getBlockByNumber(
101
+ blockNumber: NumLike,
102
+ verbosity?: number | null,
103
+ withCycles?: boolean | null,
104
+ ): Promise<ClientBlock | undefined> {
105
+ const block = await this.cache.getBlockByNumber(blockNumber);
106
+ if (block) {
107
+ return block;
108
+ }
109
+
110
+ const res = await this.getBlockByNumberNoCache(
111
+ blockNumber,
112
+ verbosity,
113
+ withCycles,
114
+ );
115
+ if (res && hasHeaderConfirmed(res.header)) {
116
+ await this.cache.recordBlocks(res);
117
+ }
118
+ return res;
119
+ }
120
+ async getBlockByHash(
121
+ blockHash: HexLike,
122
+ verbosity?: number | null,
123
+ withCycles?: boolean | null,
124
+ ): Promise<ClientBlock | undefined> {
125
+ const block = await this.cache.getBlockByHash(blockHash);
126
+ if (block) {
127
+ return block;
128
+ }
129
+
130
+ const res = await this.getBlockByHashNoCache(
131
+ blockHash,
132
+ verbosity,
133
+ withCycles,
134
+ );
135
+ if (res && hasHeaderConfirmed(res.header)) {
136
+ await this.cache.recordBlocks(res);
137
+ }
138
+ return res;
139
+ }
140
+ async getHeaderByNumber(
141
+ blockNumber: NumLike,
142
+ verbosity?: number | null,
143
+ ): Promise<ClientBlockHeader | undefined> {
144
+ const header = await this.cache.getHeaderByNumber(blockNumber);
145
+ if (header) {
146
+ return header;
147
+ }
148
+
149
+ const res = await this.getHeaderByNumberNoCache(blockNumber, verbosity);
150
+ if (res && hasHeaderConfirmed(res)) {
151
+ await this.cache.recordHeaders(res);
152
+ }
153
+ return res;
154
+ }
155
+ async getHeaderByHash(
156
+ blockHash: HexLike,
157
+ verbosity?: number | null,
158
+ ): Promise<ClientBlockHeader | undefined> {
159
+ const header = await this.cache.getHeaderByHash(blockHash);
160
+ if (header) {
161
+ return header;
162
+ }
163
+
164
+ const res = await this.getHeaderByHashNoCache(blockHash, verbosity);
165
+ if (res && hasHeaderConfirmed(res)) {
166
+ await this.cache.recordHeaders(res);
167
+ }
168
+ return res;
169
+ }
170
+
171
+ abstract estimateCycles(transaction: TransactionLike): Promise<Num>;
172
+ abstract sendTransactionDry(
173
+ transaction: TransactionLike,
174
+ validator?: OutputsValidator,
175
+ ): Promise<Num>;
176
+
177
+ abstract sendTransactionNoCache(
178
+ transaction: TransactionLike,
179
+ validator?: OutputsValidator,
180
+ ): Promise<Hex>;
181
+ abstract getTransactionNoCache(
182
+ txHash: HexLike,
183
+ ): Promise<ClientTransactionResponse | undefined>;
184
+
185
+ async getCell(outPointLike: OutPointLike): Promise<Cell | undefined> {
186
+ const outPoint = OutPoint.from(outPointLike);
187
+ const cached = await this.cache.getCell(outPoint);
188
+
189
+ if (cached) {
190
+ return cached;
191
+ }
192
+
193
+ const transaction = await this.getTransaction(outPoint.txHash);
194
+ if (!transaction) {
195
+ return;
196
+ }
197
+ const output = transaction.transaction.getOutput(outPoint.index);
198
+ if (!output) {
199
+ return;
200
+ }
201
+
202
+ const cell = Cell.from({
203
+ outPoint,
204
+ ...output,
205
+ });
206
+ await this.cache.recordCells(cell);
207
+ return cell;
208
+ }
209
+
210
+ async getCellWithHeader(
211
+ outPointLike: OutPointLike,
212
+ ): Promise<{ cell: Cell; header?: ClientBlockHeader } | undefined> {
213
+ const outPoint = OutPoint.from(outPointLike);
214
+
215
+ const res = await this.getTransactionWithHeader(outPoint.txHash);
216
+ if (!res) {
217
+ return;
218
+ }
219
+ const { transaction, header } = res;
220
+
221
+ const output = transaction.transaction.getOutput(outPoint.index);
222
+ if (!output) {
223
+ return;
224
+ }
225
+
226
+ const cell = Cell.from({
227
+ outPoint,
228
+ ...output,
229
+ });
230
+ await this.cache.recordCells(cell);
231
+ return { cell, header };
232
+ }
233
+
234
+ abstract getCellLiveNoCache(
235
+ outPointLike: OutPointLike,
236
+ withData?: boolean | null,
237
+ includeTxPool?: boolean | null,
238
+ ): Promise<Cell | undefined>;
239
+ async getCellLive(
240
+ outPointLike: OutPointLike,
241
+ withData?: boolean | null,
242
+ includeTxPool?: boolean | null,
243
+ ): Promise<Cell | undefined> {
244
+ const cell = await this.getCellLiveNoCache(
245
+ outPointLike,
246
+ withData,
247
+ includeTxPool,
248
+ );
249
+ if (withData && cell) {
250
+ await this.cache.recordCells(cell);
251
+ }
252
+ return cell;
253
+ }
254
+
255
+ abstract findCellsPagedNoCache(
256
+ key: ClientIndexerSearchKeyLike,
257
+ order?: "asc" | "desc",
258
+ limit?: NumLike,
259
+ after?: string,
260
+ ): Promise<ClientFindCellsResponse>;
261
+ async findCellsPaged(
262
+ key: ClientIndexerSearchKeyLike,
263
+ order?: "asc" | "desc",
264
+ limit?: NumLike,
265
+ after?: string,
266
+ ): Promise<ClientFindCellsResponse> {
267
+ const res = await this.findCellsPagedNoCache(key, order, limit, after);
268
+ await this.cache.recordCells(res.cells);
269
+ return res;
270
+ }
271
+
272
+ async *findCellsOnChain(
273
+ key: ClientIndexerSearchKeyLike,
274
+ order?: "asc" | "desc",
275
+ limit = 10,
276
+ ): AsyncGenerator<Cell> {
277
+ let last: string | undefined = undefined;
278
+
279
+ while (true) {
280
+ const { cells, lastCursor } = await this.findCellsPaged(
281
+ key,
282
+ order,
283
+ limit,
284
+ last,
285
+ );
286
+ for (const cell of cells) {
287
+ yield cell;
288
+ }
289
+ if (cells.length === 0 || cells.length < limit) {
290
+ return;
291
+ }
292
+ last = lastCursor;
293
+ }
294
+ }
295
+
296
+ /**
297
+ * Find cells by search key designed for collectable cells.
298
+ *
299
+ * @param keyLike - The search key.
300
+ * @returns A async generator for yielding cells.
301
+ */
302
+ async *findCells(
303
+ keyLike: ClientCollectableSearchKeyLike,
304
+ order?: "asc" | "desc",
305
+ limit = 10,
306
+ ): AsyncGenerator<Cell> {
307
+ const key = ClientIndexerSearchKey.from(keyLike);
308
+ const foundedOutPoints = [];
309
+
310
+ for await (const cell of this.cache.findCells(key)) {
311
+ foundedOutPoints.push(cell.outPoint);
312
+ yield cell;
313
+ }
314
+
315
+ for await (const cell of this.findCellsOnChain(key, order, limit)) {
316
+ if (
317
+ (await this.cache.isUnusable(cell.outPoint)) ||
318
+ foundedOutPoints.some((founded) => founded.eq(cell.outPoint))
319
+ ) {
320
+ continue;
321
+ }
322
+
323
+ yield cell;
324
+ }
325
+ }
326
+
327
+ findCellsByLock(
328
+ lock: ScriptLike,
329
+ type?: ScriptLike | null,
330
+ withData = true,
331
+ order?: "asc" | "desc",
332
+ limit = 10,
333
+ ): AsyncGenerator<Cell> {
334
+ return this.findCells(
335
+ {
336
+ script: lock,
337
+ scriptType: "lock",
338
+ scriptSearchMode: "exact",
339
+ filter: {
340
+ script: type,
341
+ },
342
+ withData,
343
+ },
344
+ order,
345
+ limit,
346
+ );
347
+ }
348
+
349
+ findCellsByType(
350
+ type: ScriptLike,
351
+ withData = true,
352
+ order?: "asc" | "desc",
353
+ limit = 10,
354
+ ): AsyncGenerator<Cell> {
355
+ return this.findCells(
356
+ {
357
+ script: type,
358
+ scriptType: "type",
359
+ scriptSearchMode: "exact",
360
+ withData,
361
+ },
362
+ order,
363
+ limit,
364
+ );
365
+ }
366
+
367
+ async findSingletonCellByType(
368
+ type: ScriptLike,
369
+ withData = false,
370
+ ): Promise<Cell | undefined> {
371
+ for await (const cell of this.findCellsByType(
372
+ type,
373
+ withData,
374
+ undefined,
375
+ 1,
376
+ )) {
377
+ return cell;
378
+ }
379
+ }
380
+
381
+ async getCellDeps(
382
+ ...cellDepsInfoLike: (CellDepInfoLike | CellDepInfoLike[])[]
383
+ ): Promise<CellDep[]> {
384
+ return Promise.all(
385
+ cellDepsInfoLike.flat().map(async (infoLike) => {
386
+ const { cellDep, type } = CellDepInfo.from(infoLike);
387
+ if (type === undefined) {
388
+ return cellDep;
389
+ }
390
+ const found = await this.findSingletonCellByType(type);
391
+ if (!found) {
392
+ return cellDep;
393
+ }
394
+
395
+ return CellDep.from({
396
+ outPoint: found.outPoint,
397
+ depType: cellDep.depType,
398
+ });
399
+ }),
400
+ );
401
+ }
402
+
403
+ abstract findTransactionsPaged(
404
+ key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
405
+ groupByTransaction: true;
406
+ },
407
+ order?: "asc" | "desc",
408
+ limit?: NumLike,
409
+ after?: string,
410
+ ): Promise<ClientFindTransactionsGroupedResponse>;
411
+ abstract findTransactionsPaged(
412
+ key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
413
+ groupByTransaction?: false | null;
414
+ },
415
+ order?: "asc" | "desc",
416
+ limit?: NumLike,
417
+ after?: string,
418
+ ): Promise<ClientFindTransactionsResponse>;
419
+ abstract findTransactionsPaged(
420
+ key: ClientIndexerSearchKeyTransactionLike,
421
+ order?: "asc" | "desc",
422
+ limit?: NumLike,
423
+ after?: string,
424
+ ): Promise<
425
+ ClientFindTransactionsResponse | ClientFindTransactionsGroupedResponse
426
+ >;
427
+
428
+ findTransactions(
429
+ key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
430
+ groupByTransaction: true;
431
+ },
432
+ order?: "asc" | "desc",
433
+ limit?: number,
434
+ ): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
435
+ findTransactions(
436
+ key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
437
+ groupByTransaction?: false | null;
438
+ },
439
+ order?: "asc" | "desc",
440
+ limit?: number,
441
+ ): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
442
+ findTransactions(
443
+ key: ClientIndexerSearchKeyTransactionLike,
444
+ order?: "asc" | "desc",
445
+ limit?: number,
446
+ ): AsyncGenerator<
447
+ | ClientFindTransactionsResponse["transactions"][0]
448
+ | ClientFindTransactionsGroupedResponse["transactions"][0]
449
+ >;
450
+ async *findTransactions(
451
+ key: ClientIndexerSearchKeyTransactionLike,
452
+ order?: "asc" | "desc",
453
+ limit = 10,
454
+ ): AsyncGenerator<
455
+ | ClientFindTransactionsResponse["transactions"][0]
456
+ | ClientFindTransactionsGroupedResponse["transactions"][0]
457
+ > {
458
+ let last: string | undefined = undefined;
459
+
460
+ while (true) {
461
+ const {
462
+ transactions,
463
+ lastCursor,
464
+ }:
465
+ | ClientFindTransactionsResponse
466
+ | ClientFindTransactionsGroupedResponse =
467
+ await this.findTransactionsPaged(key, order, limit, last);
468
+ for (const tx of transactions) {
469
+ yield tx;
470
+ }
471
+ if (transactions.length === 0 || transactions.length < limit) {
472
+ return;
473
+ }
474
+ last = lastCursor;
475
+ }
476
+ }
477
+
478
+ findTransactionsByLock(
479
+ lock: ScriptLike,
480
+ type: ScriptLike | undefined | null,
481
+ groupByTransaction: true,
482
+ order?: "asc" | "desc",
483
+ limit?: number,
484
+ ): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
485
+ findTransactionsByLock(
486
+ lock: ScriptLike,
487
+ type?: ScriptLike | null,
488
+ groupByTransaction?: false | null,
489
+ order?: "asc" | "desc",
490
+ limit?: number,
491
+ ): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
492
+ findTransactionsByLock(
493
+ lock: ScriptLike,
494
+ type?: ScriptLike | null,
495
+ groupByTransaction?: boolean | null,
496
+ order?: "asc" | "desc",
497
+ limit?: number,
498
+ ): AsyncGenerator<
499
+ | ClientFindTransactionsResponse["transactions"][0]
500
+ | ClientFindTransactionsGroupedResponse["transactions"][0]
501
+ >;
502
+ findTransactionsByLock(
503
+ lock: ScriptLike,
504
+ type?: ScriptLike | null,
505
+ groupByTransaction?: boolean | null,
506
+ order?: "asc" | "desc",
507
+ limit = 10,
508
+ ): AsyncGenerator<
509
+ | ClientFindTransactionsResponse["transactions"][0]
510
+ | ClientFindTransactionsGroupedResponse["transactions"][0]
511
+ > {
512
+ return this.findTransactions(
513
+ {
514
+ script: lock,
515
+ scriptType: "lock",
516
+ scriptSearchMode: "exact",
517
+ filter: {
518
+ script: type,
519
+ },
520
+ groupByTransaction,
521
+ },
522
+ order,
523
+ limit,
524
+ );
525
+ }
526
+
527
+ findTransactionsByType(
528
+ type: ScriptLike,
529
+ groupByTransaction: true,
530
+ order?: "asc" | "desc",
531
+ limit?: number,
532
+ ): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
533
+ findTransactionsByType(
534
+ type: ScriptLike,
535
+ groupByTransaction?: false | null,
536
+ order?: "asc" | "desc",
537
+ limit?: number,
538
+ ): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
539
+ findTransactionsByType(
540
+ type: ScriptLike,
541
+ groupByTransaction?: boolean | null,
542
+ order?: "asc" | "desc",
543
+ limit?: number,
544
+ ): AsyncGenerator<
545
+ | ClientFindTransactionsResponse["transactions"][0]
546
+ | ClientFindTransactionsGroupedResponse["transactions"][0]
547
+ >;
548
+ findTransactionsByType(
549
+ type: ScriptLike,
550
+ groupByTransaction?: boolean | null,
551
+ order?: "asc" | "desc",
552
+ limit = 10,
553
+ ): AsyncGenerator<
554
+ | ClientFindTransactionsResponse["transactions"][0]
555
+ | ClientFindTransactionsGroupedResponse["transactions"][0]
556
+ > {
557
+ return this.findTransactions(
558
+ {
559
+ script: type,
560
+ scriptType: "type",
561
+ scriptSearchMode: "exact",
562
+ groupByTransaction,
563
+ },
564
+ order,
565
+ limit,
566
+ );
567
+ }
568
+
569
+ abstract getCellsCapacity(key: ClientIndexerSearchKeyLike): Promise<Num>;
570
+
571
+ async getBalanceSingle(lock: ScriptLike): Promise<Num> {
572
+ return this.getCellsCapacity({
573
+ script: lock,
574
+ scriptType: "lock",
575
+ scriptSearchMode: "exact",
576
+ filter: {
577
+ scriptLenRange: [0, 1],
578
+ outputDataLenRange: [0, 1],
579
+ },
580
+ });
581
+ }
582
+
583
+ async getBalance(locks: ScriptLike[]): Promise<Num> {
584
+ return reduceAsync(
585
+ locks,
586
+ async (acc, lock) => acc + (await this.getBalanceSingle(lock)),
587
+ Zero,
588
+ );
589
+ }
590
+
591
+ async sendTransaction(
592
+ transaction: TransactionLike,
593
+ validator?: OutputsValidator,
594
+ options?: { maxFeeRate?: NumLike },
595
+ ): Promise<Hex> {
596
+ const tx = Transaction.from(transaction);
597
+
598
+ const maxFeeRate = numFrom(options?.maxFeeRate ?? DEFAULT_MAX_FEE_RATE);
599
+ const fee = await tx.feeRate(this);
600
+ if (maxFeeRate > Zero && fee > maxFeeRate) {
601
+ throw new ErrorClientMaxFeeRateExceeded(maxFeeRate, fee);
602
+ }
603
+
604
+ const txHash = await this.sendTransactionNoCache(tx, validator);
605
+
606
+ await this.cache.markTransactions(tx);
607
+ return txHash;
608
+ }
609
+
610
+ async getTransaction(
611
+ txHashLike: HexLike,
612
+ ): Promise<ClientTransactionResponse | undefined> {
613
+ const txHash = hexFrom(txHashLike);
614
+ const res = await this.getTransactionNoCache(txHash);
615
+ if (res) {
616
+ await this.cache.recordTransactionResponses(res);
617
+ return res;
618
+ }
619
+
620
+ return this.cache.getTransactionResponse(txHash);
621
+ }
622
+
623
+ /**
624
+ * This method gets specified transaction with its block header (if existed).
625
+ * This is mainly for caching because we need the header to test if we can safely trust the cached tx status.
626
+ * @param txHashLike
627
+ */
628
+ async getTransactionWithHeader(
629
+ txHashLike: HexLike,
630
+ ): Promise<
631
+ | { transaction: ClientTransactionResponse; header?: ClientBlockHeader }
632
+ | undefined
633
+ > {
634
+ const txHash = hexFrom(txHashLike);
635
+ const tx = await this.cache.getTransactionResponse(txHash);
636
+ if (tx?.blockHash) {
637
+ const header = await this.getHeaderByHash(tx.blockHash);
638
+ if (header && hasHeaderConfirmed(header)) {
639
+ return {
640
+ transaction: tx,
641
+ header,
642
+ };
643
+ }
644
+ }
645
+
646
+ const res = await this.getTransactionNoCache(txHash);
647
+ if (!res) {
648
+ return;
649
+ }
650
+
651
+ await this.cache.recordTransactionResponses(res);
652
+ return {
653
+ transaction: res,
654
+ header: res.blockHash
655
+ ? await this.getHeaderByHash(res.blockHash)
656
+ : undefined,
657
+ };
658
+ }
659
+
660
+ async waitTransaction(
661
+ txHash: HexLike,
662
+ confirmations: number = 0,
663
+ timeout: number = 60000,
664
+ interval: number = 2000,
665
+ ): Promise<ClientTransactionResponse | undefined> {
666
+ const startTime = Date.now();
667
+ let tx: ClientTransactionResponse | undefined;
668
+
669
+ const getTx = async () => {
670
+ const res = await this.getTransaction(txHash);
671
+ if (
672
+ !res ||
673
+ res.blockNumber == null ||
674
+ ["sent", "pending", "proposed"].includes(res.status)
675
+ ) {
676
+ return undefined;
677
+ }
678
+
679
+ tx = res;
680
+ return res;
681
+ };
682
+
683
+ while (true) {
684
+ if (!tx) {
685
+ if (await getTx()) {
686
+ continue;
687
+ }
688
+ } else if (confirmations === 0) {
689
+ return tx;
690
+ } else if (
691
+ (await this.getTipHeader()).number - tx.blockNumber! >=
692
+ confirmations
693
+ ) {
694
+ return tx;
695
+ }
696
+
697
+ if (Date.now() - startTime + interval >= timeout) {
698
+ throw new ErrorClientWaitTransactionTimeout(timeout);
699
+ }
700
+ await sleep(interval);
701
+ }
702
+ }
703
+ }