@bigmi/core 0.1.0 → 0.2.0-beta.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 (575) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +6 -4
  3. package/dist/cjs/actions/getBalance.d.ts +6 -3
  4. package/dist/cjs/actions/getBalance.js.map +1 -1
  5. package/dist/cjs/actions/getBlock.d.ts +4 -1
  6. package/dist/cjs/actions/getBlock.js +3 -3
  7. package/dist/cjs/actions/getBlock.js.map +1 -1
  8. package/dist/cjs/actions/getBlockCount.d.ts +4 -1
  9. package/dist/cjs/actions/getBlockCount.js.map +1 -1
  10. package/dist/cjs/actions/getBlockStats.d.ts +4 -1
  11. package/dist/cjs/actions/getBlockStats.js +3 -3
  12. package/dist/cjs/actions/getBlockStats.js.map +1 -1
  13. package/dist/cjs/actions/getUTXOTransaction.d.ts +4 -1
  14. package/dist/cjs/actions/getUTXOTransaction.js +2 -2
  15. package/dist/cjs/actions/getUTXOTransaction.js.map +1 -1
  16. package/dist/cjs/actions/sendUTXOTransaction.d.ts +4 -1
  17. package/dist/cjs/actions/sendUTXOTransaction.js.map +1 -1
  18. package/dist/cjs/actions/signPsbt.d.ts +5 -2
  19. package/dist/cjs/actions/signPsbt.js.map +1 -1
  20. package/dist/cjs/actions/waitForTransaction.d.ts +3 -1
  21. package/dist/cjs/actions/waitForTransaction.js +16 -14
  22. package/dist/cjs/actions/waitForTransaction.js.map +1 -1
  23. package/dist/cjs/actions/watchBlockNumber.d.ts +3 -1
  24. package/dist/cjs/actions/watchBlockNumber.js +4 -4
  25. package/dist/cjs/actions/watchBlockNumber.js.map +1 -1
  26. package/dist/cjs/chains/bitcoin.d.ts +5 -17
  27. package/dist/cjs/chains/bitcoin.js +2 -2
  28. package/dist/cjs/chains/bitcoin.js.map +1 -1
  29. package/dist/cjs/chains/defineChain.d.ts +3 -0
  30. package/dist/cjs/chains/defineChain.js +12 -0
  31. package/dist/cjs/chains/defineChain.js.map +1 -0
  32. package/dist/cjs/clients/decorators/public.d.ts +18 -0
  33. package/dist/cjs/clients/decorators/public.js +18 -0
  34. package/dist/cjs/clients/decorators/public.js.map +1 -0
  35. package/dist/cjs/clients/decorators/wallet.d.ts +11 -0
  36. package/dist/cjs/clients/decorators/wallet.js +12 -0
  37. package/dist/cjs/clients/decorators/wallet.js.map +1 -0
  38. package/dist/cjs/errors/address.d.ts +9 -0
  39. package/dist/cjs/errors/address.js +17 -0
  40. package/dist/cjs/errors/address.js.map +1 -0
  41. package/dist/cjs/errors/base.d.ts +27 -0
  42. package/dist/cjs/errors/base.js +55 -0
  43. package/dist/cjs/errors/base.js.map +1 -0
  44. package/dist/cjs/errors/block.d.ts +11 -0
  45. package/dist/cjs/errors/block.js +18 -0
  46. package/dist/cjs/errors/block.js.map +1 -0
  47. package/dist/cjs/errors/config.d.ts +61 -0
  48. package/dist/cjs/errors/config.js +65 -0
  49. package/dist/cjs/errors/config.js.map +1 -0
  50. package/dist/cjs/errors/provider.d.ts +4 -0
  51. package/dist/cjs/errors/provider.js +15 -0
  52. package/dist/cjs/errors/provider.js.map +1 -0
  53. package/dist/cjs/errors/request.d.ts +80 -0
  54. package/dist/cjs/errors/request.js +72 -0
  55. package/dist/cjs/errors/request.js.map +1 -0
  56. package/dist/cjs/errors/rpc.d.ts +23 -0
  57. package/dist/cjs/errors/rpc.js +49 -0
  58. package/dist/cjs/errors/rpc.js.map +1 -0
  59. package/dist/cjs/errors/transaction.d.ts +31 -0
  60. package/dist/cjs/errors/transaction.js +40 -0
  61. package/dist/cjs/errors/transaction.js.map +1 -0
  62. package/dist/cjs/errors/transport.d.ts +7 -0
  63. package/dist/cjs/errors/transport.js +13 -0
  64. package/dist/cjs/errors/transport.js.map +1 -0
  65. package/dist/cjs/errors/utils.d.ts +6 -0
  66. package/dist/cjs/errors/utils.js +8 -0
  67. package/dist/cjs/errors/utils.js.map +1 -0
  68. package/dist/cjs/factories/createClient.d.ts +50 -0
  69. package/dist/cjs/factories/createClient.js +45 -0
  70. package/dist/cjs/factories/createClient.js.map +1 -0
  71. package/dist/cjs/factories/createTransport.d.ts +31 -0
  72. package/dist/cjs/factories/createTransport.js +23 -0
  73. package/dist/cjs/factories/createTransport.js.map +1 -0
  74. package/dist/cjs/index.d.ts +37 -4
  75. package/dist/cjs/index.js +63 -5
  76. package/dist/cjs/index.js.map +1 -1
  77. package/dist/cjs/transports/custom.d.ts +16 -0
  78. package/dist/cjs/transports/custom.js +17 -0
  79. package/dist/cjs/transports/custom.js.map +1 -0
  80. package/dist/cjs/transports/fallback.d.ts +56 -0
  81. package/dist/cjs/transports/fallback.js +165 -0
  82. package/dist/cjs/transports/fallback.js.map +1 -0
  83. package/dist/cjs/transports/getHttpRpcClient.d.ts +11 -1
  84. package/dist/cjs/transports/getHttpRpcClient.js +12 -10
  85. package/dist/cjs/transports/getHttpRpcClient.js.map +1 -1
  86. package/dist/cjs/transports/http.d.ts +28 -0
  87. package/dist/cjs/transports/http.js +72 -0
  88. package/dist/cjs/transports/http.js.map +1 -0
  89. package/dist/cjs/transports/types.d.ts +20 -5
  90. package/dist/cjs/transports/utxo.d.ts +1 -1
  91. package/dist/cjs/transports/utxo.js +6 -4
  92. package/dist/cjs/transports/utxo.js.map +1 -1
  93. package/dist/cjs/types/account.d.ts +9 -0
  94. package/dist/cjs/types/account.js +3 -0
  95. package/dist/cjs/types/account.js.map +1 -0
  96. package/dist/cjs/types/actions.d.ts +17 -0
  97. package/dist/cjs/types/actions.js +3 -0
  98. package/dist/cjs/types/actions.js.map +1 -0
  99. package/dist/cjs/types/address.d.ts +1 -0
  100. package/dist/cjs/types/address.js +3 -0
  101. package/dist/cjs/types/address.js.map +1 -0
  102. package/dist/cjs/types/base.d.ts +0 -0
  103. package/dist/cjs/types/base.js +2 -0
  104. package/dist/cjs/types/base.js.map +1 -0
  105. package/dist/cjs/types/block.d.ts +1 -0
  106. package/dist/cjs/{clients/types.js → types/block.js} +1 -1
  107. package/dist/cjs/types/block.js.map +1 -0
  108. package/dist/cjs/types/chain.d.ts +37 -0
  109. package/dist/cjs/types/chain.js +3 -0
  110. package/dist/cjs/types/chain.js.map +1 -0
  111. package/dist/cjs/types/client.d.ts +41 -0
  112. package/dist/cjs/types/client.js +3 -0
  113. package/dist/cjs/types/client.js.map +1 -0
  114. package/dist/cjs/types/hash.d.ts +1 -0
  115. package/dist/cjs/types/hash.js +3 -0
  116. package/dist/cjs/types/hash.js.map +1 -0
  117. package/dist/cjs/types/request.d.ts +43 -0
  118. package/dist/cjs/types/request.js +3 -0
  119. package/dist/cjs/types/request.js.map +1 -0
  120. package/dist/cjs/types/rpc.d.ts +34 -0
  121. package/dist/cjs/types/rpc.js +3 -0
  122. package/dist/cjs/types/rpc.js.map +1 -0
  123. package/dist/cjs/types/storage.d.ts +22 -0
  124. package/dist/cjs/types/storage.js +3 -0
  125. package/dist/cjs/types/storage.js.map +1 -0
  126. package/dist/cjs/types/transport.d.ts +29 -0
  127. package/dist/cjs/types/transport.js +3 -0
  128. package/dist/cjs/types/transport.js.map +1 -0
  129. package/dist/cjs/types/utils.d.ts +36 -0
  130. package/dist/cjs/types/utils.js +3 -0
  131. package/dist/cjs/types/utils.js.map +1 -0
  132. package/dist/cjs/utils/buildRequest.d.ts +5 -0
  133. package/dist/cjs/utils/buildRequest.js +102 -0
  134. package/dist/cjs/utils/buildRequest.js.map +1 -0
  135. package/dist/cjs/utils/converter.d.ts +3 -0
  136. package/dist/cjs/utils/converter.js +28 -0
  137. package/dist/cjs/utils/converter.js.map +1 -0
  138. package/dist/cjs/utils/createBatchScheduler.d.ts +20 -0
  139. package/dist/cjs/utils/createBatchScheduler.js +54 -0
  140. package/dist/cjs/utils/createBatchScheduler.js.map +1 -0
  141. package/dist/cjs/utils/deepEqual.d.ts +1 -0
  142. package/dist/cjs/utils/deepEqual.js +52 -0
  143. package/dist/cjs/utils/deepEqual.js.map +1 -0
  144. package/dist/cjs/utils/getAction.d.ts +10 -0
  145. package/dist/cjs/utils/getAction.js +15 -0
  146. package/dist/cjs/utils/getAction.js.map +1 -0
  147. package/dist/cjs/utils/getUTXOAddress.d.ts +3 -2
  148. package/dist/cjs/utils/getUTXOAddress.js.map +1 -1
  149. package/dist/cjs/utils/isUTXOAddress.js.map +1 -1
  150. package/dist/cjs/utils/lru.d.ts +6 -0
  151. package/dist/cjs/utils/lru.js +29 -0
  152. package/dist/cjs/utils/lru.js.map +1 -0
  153. package/dist/cjs/utils/observe.d.ts +1 -1
  154. package/dist/cjs/utils/parseAccount.d.ts +5 -0
  155. package/dist/cjs/utils/parseAccount.js +10 -0
  156. package/dist/cjs/utils/parseAccount.js.map +1 -0
  157. package/dist/cjs/utils/stringify.d.ts +3 -0
  158. package/dist/cjs/utils/stringify.js +9 -0
  159. package/dist/cjs/utils/stringify.js.map +1 -0
  160. package/dist/cjs/utils/uid.d.ts +1 -0
  161. package/dist/cjs/utils/uid.js +17 -0
  162. package/dist/cjs/utils/uid.js.map +1 -0
  163. package/dist/cjs/utils/wait.d.ts +1 -0
  164. package/dist/cjs/utils/wait.js +7 -0
  165. package/dist/cjs/utils/wait.js.map +1 -0
  166. package/dist/cjs/utils/withDedupe.d.ts +8 -0
  167. package/dist/cjs/utils/withDedupe.js +18 -0
  168. package/dist/cjs/utils/withDedupe.js.map +1 -0
  169. package/dist/cjs/utils/withResolvers.d.ts +6 -0
  170. package/dist/cjs/utils/withResolvers.js +13 -0
  171. package/dist/cjs/utils/withResolvers.js.map +1 -0
  172. package/dist/cjs/utils/withRetry.d.ts +14 -0
  173. package/dist/cjs/utils/withRetry.js +30 -0
  174. package/dist/cjs/utils/withRetry.js.map +1 -0
  175. package/dist/cjs/utils/withTimeout.d.ts +9 -0
  176. package/dist/cjs/utils/withTimeout.js +35 -0
  177. package/dist/cjs/utils/withTimeout.js.map +1 -0
  178. package/dist/cjs/version.d.ts +1 -0
  179. package/dist/cjs/version.js +5 -0
  180. package/dist/cjs/version.js.map +1 -0
  181. package/dist/esm/actions/getBalance.d.ts +6 -3
  182. package/dist/esm/actions/getBalance.js.map +1 -1
  183. package/dist/esm/actions/getBlock.d.ts +4 -1
  184. package/dist/esm/actions/getBlock.js +1 -1
  185. package/dist/esm/actions/getBlock.js.map +1 -1
  186. package/dist/esm/actions/getBlockCount.d.ts +4 -1
  187. package/dist/esm/actions/getBlockCount.js.map +1 -1
  188. package/dist/esm/actions/getBlockStats.d.ts +4 -1
  189. package/dist/esm/actions/getBlockStats.js +1 -1
  190. package/dist/esm/actions/getBlockStats.js.map +1 -1
  191. package/dist/esm/actions/getUTXOTransaction.d.ts +4 -1
  192. package/dist/esm/actions/getUTXOTransaction.js +1 -1
  193. package/dist/esm/actions/getUTXOTransaction.js.map +1 -1
  194. package/dist/esm/actions/sendUTXOTransaction.d.ts +4 -1
  195. package/dist/esm/actions/sendUTXOTransaction.js.map +1 -1
  196. package/dist/esm/actions/signPsbt.d.ts +5 -2
  197. package/dist/esm/actions/signPsbt.js.map +1 -1
  198. package/dist/esm/actions/waitForTransaction.d.ts +3 -1
  199. package/dist/esm/actions/waitForTransaction.js +4 -2
  200. package/dist/esm/actions/waitForTransaction.js.map +1 -1
  201. package/dist/esm/actions/watchBlockNumber.d.ts +3 -1
  202. package/dist/esm/actions/watchBlockNumber.js +2 -2
  203. package/dist/esm/actions/watchBlockNumber.js.map +1 -1
  204. package/dist/esm/chains/bitcoin.d.ts +5 -17
  205. package/dist/esm/chains/bitcoin.js +1 -1
  206. package/dist/esm/chains/bitcoin.js.map +1 -1
  207. package/dist/esm/chains/defineChain.d.ts +3 -0
  208. package/dist/esm/chains/defineChain.js +9 -0
  209. package/dist/esm/chains/defineChain.js.map +1 -0
  210. package/dist/esm/clients/decorators/public.d.ts +18 -0
  211. package/dist/esm/clients/decorators/public.js +15 -0
  212. package/dist/esm/clients/decorators/public.js.map +1 -0
  213. package/dist/esm/clients/decorators/wallet.d.ts +14 -0
  214. package/dist/esm/clients/decorators/wallet.js +9 -0
  215. package/dist/esm/clients/decorators/wallet.js.map +1 -0
  216. package/dist/esm/errors/address.d.ts +9 -0
  217. package/dist/esm/errors/address.js +13 -0
  218. package/dist/esm/errors/address.js.map +1 -0
  219. package/dist/esm/errors/base.d.ts +27 -0
  220. package/dist/esm/errors/base.js +50 -0
  221. package/dist/esm/errors/base.js.map +1 -0
  222. package/dist/esm/errors/block.d.ts +11 -0
  223. package/dist/esm/errors/block.js +14 -0
  224. package/dist/esm/errors/block.js.map +1 -0
  225. package/dist/esm/errors/config.d.ts +61 -0
  226. package/dist/esm/errors/config.js +55 -0
  227. package/dist/esm/errors/config.js.map +1 -0
  228. package/dist/esm/errors/provider.d.ts +4 -0
  229. package/dist/esm/errors/provider.js +11 -0
  230. package/dist/esm/errors/provider.js.map +1 -0
  231. package/dist/esm/errors/request.d.ts +80 -0
  232. package/dist/esm/errors/request.js +64 -0
  233. package/dist/esm/errors/request.js.map +1 -0
  234. package/dist/esm/errors/rpc.d.ts +53 -0
  235. package/dist/esm/errors/rpc.js +73 -0
  236. package/dist/esm/errors/rpc.js.map +1 -0
  237. package/dist/esm/errors/transaction.d.ts +31 -0
  238. package/dist/esm/errors/transaction.js +34 -0
  239. package/dist/esm/errors/transaction.js.map +1 -0
  240. package/dist/esm/errors/transport.d.ts +7 -0
  241. package/dist/esm/errors/transport.js +9 -0
  242. package/dist/esm/errors/transport.js.map +1 -0
  243. package/dist/esm/errors/utils.d.ts +6 -0
  244. package/dist/esm/errors/utils.js +3 -0
  245. package/dist/esm/errors/utils.js.map +1 -0
  246. package/dist/esm/factories/createClient.d.ts +85 -0
  247. package/dist/esm/factories/createClient.js +45 -0
  248. package/dist/esm/factories/createClient.js.map +1 -0
  249. package/dist/esm/factories/createTransport.d.ts +42 -0
  250. package/dist/esm/factories/createTransport.js +23 -0
  251. package/dist/esm/factories/createTransport.js.map +1 -0
  252. package/dist/esm/index.d.ts +37 -4
  253. package/dist/esm/index.js +26 -3
  254. package/dist/esm/index.js.map +1 -1
  255. package/dist/esm/transports/custom.d.ts +24 -0
  256. package/dist/esm/transports/custom.js +17 -0
  257. package/dist/esm/transports/custom.js.map +1 -0
  258. package/dist/esm/transports/fallback.d.ts +89 -0
  259. package/dist/esm/transports/fallback.js +172 -0
  260. package/dist/esm/transports/fallback.js.map +1 -0
  261. package/dist/esm/transports/getHttpRpcClient.d.ts +15 -1
  262. package/dist/esm/transports/getHttpRpcClient.js +4 -2
  263. package/dist/esm/transports/getHttpRpcClient.js.map +1 -1
  264. package/dist/esm/transports/http.d.ts +53 -0
  265. package/dist/esm/transports/http.js +74 -0
  266. package/dist/esm/transports/http.js.map +1 -0
  267. package/dist/esm/transports/types.d.ts +36 -5
  268. package/dist/esm/transports/utxo.d.ts +1 -1
  269. package/dist/esm/transports/utxo.js +3 -1
  270. package/dist/esm/transports/utxo.js.map +1 -1
  271. package/dist/esm/types/account.d.ts +9 -0
  272. package/dist/esm/types/account.js +2 -0
  273. package/dist/esm/types/account.js.map +1 -0
  274. package/dist/esm/types/actions.d.ts +20 -0
  275. package/dist/esm/types/actions.js +2 -0
  276. package/dist/esm/types/actions.js.map +1 -0
  277. package/dist/esm/types/address.d.ts +1 -0
  278. package/dist/esm/types/address.js +2 -0
  279. package/dist/esm/types/address.js.map +1 -0
  280. package/dist/esm/types/base.d.ts +0 -0
  281. package/dist/esm/types/base.js +2 -0
  282. package/dist/esm/types/base.js.map +1 -0
  283. package/dist/esm/types/block.d.ts +19 -0
  284. package/dist/esm/types/block.js +2 -0
  285. package/dist/esm/types/block.js.map +1 -0
  286. package/dist/esm/types/chain.d.ts +48 -0
  287. package/dist/esm/types/chain.js +2 -0
  288. package/dist/esm/types/chain.js.map +1 -0
  289. package/dist/esm/types/client.d.ts +68 -0
  290. package/dist/esm/types/client.js +2 -0
  291. package/dist/esm/types/client.js.map +1 -0
  292. package/dist/esm/types/hash.d.ts +1 -0
  293. package/dist/esm/types/hash.js +2 -0
  294. package/dist/esm/types/hash.js.map +1 -0
  295. package/dist/esm/types/request.d.ts +48 -0
  296. package/dist/esm/types/request.js +2 -0
  297. package/dist/esm/types/request.js.map +1 -0
  298. package/dist/esm/types/rpc.d.ts +34 -0
  299. package/dist/esm/types/rpc.js +2 -0
  300. package/dist/esm/types/rpc.js.map +1 -0
  301. package/dist/esm/types/storage.d.ts +22 -0
  302. package/dist/esm/types/storage.js +2 -0
  303. package/dist/esm/types/storage.js.map +1 -0
  304. package/dist/esm/types/transport.d.ts +37 -0
  305. package/dist/esm/types/transport.js +2 -0
  306. package/dist/esm/types/transport.js.map +1 -0
  307. package/dist/esm/types/utils.d.ts +72 -0
  308. package/dist/esm/types/utils.js +2 -0
  309. package/dist/esm/types/utils.js.map +1 -0
  310. package/dist/esm/utils/buildRequest.d.ts +6 -0
  311. package/dist/esm/utils/buildRequest.js +111 -0
  312. package/dist/esm/utils/buildRequest.js.map +1 -0
  313. package/dist/esm/utils/converter.d.ts +3 -0
  314. package/dist/esm/utils/converter.js +23 -0
  315. package/dist/esm/utils/converter.js.map +1 -0
  316. package/dist/esm/utils/createBatchScheduler.d.ts +21 -0
  317. package/dist/esm/utils/createBatchScheduler.js +52 -0
  318. package/dist/esm/utils/createBatchScheduler.js.map +1 -0
  319. package/dist/esm/utils/deepEqual.d.ts +2 -0
  320. package/dist/esm/utils/deepEqual.js +52 -0
  321. package/dist/esm/utils/deepEqual.js.map +1 -0
  322. package/dist/esm/utils/getAction.d.ts +17 -0
  323. package/dist/esm/utils/getAction.js +23 -0
  324. package/dist/esm/utils/getAction.js.map +1 -0
  325. package/dist/esm/utils/getUTXOAddress.d.ts +3 -2
  326. package/dist/esm/utils/getUTXOAddress.js.map +1 -1
  327. package/dist/esm/utils/isUTXOAddress.js.map +1 -1
  328. package/dist/esm/utils/lru.d.ts +11 -0
  329. package/dist/esm/utils/lru.js +30 -0
  330. package/dist/esm/utils/lru.js.map +1 -0
  331. package/dist/esm/utils/observe.d.ts +1 -1
  332. package/dist/esm/utils/parseAccount.d.ts +5 -0
  333. package/dist/esm/utils/parseAccount.js +7 -0
  334. package/dist/esm/utils/parseAccount.js.map +1 -0
  335. package/dist/esm/utils/stringify.d.ts +3 -0
  336. package/dist/esm/utils/stringify.js +5 -0
  337. package/dist/esm/utils/stringify.js.map +1 -0
  338. package/dist/esm/utils/uid.d.ts +1 -0
  339. package/dist/esm/utils/uid.js +14 -0
  340. package/dist/esm/utils/uid.js.map +1 -0
  341. package/dist/esm/utils/wait.d.ts +1 -0
  342. package/dist/esm/utils/wait.js +4 -0
  343. package/dist/esm/utils/wait.js.map +1 -0
  344. package/dist/esm/utils/withDedupe.d.ts +10 -0
  345. package/dist/esm/utils/withDedupe.js +16 -0
  346. package/dist/esm/utils/withDedupe.js.map +1 -0
  347. package/dist/esm/utils/withResolvers.d.ts +8 -0
  348. package/dist/esm/utils/withResolvers.js +11 -0
  349. package/dist/esm/utils/withResolvers.js.map +1 -0
  350. package/dist/esm/utils/withRetry.d.ts +14 -0
  351. package/dist/esm/utils/withRetry.js +27 -0
  352. package/dist/esm/utils/withRetry.js.map +1 -0
  353. package/dist/esm/utils/withTimeout.d.ts +9 -0
  354. package/dist/esm/utils/withTimeout.js +32 -0
  355. package/dist/esm/utils/withTimeout.js.map +1 -0
  356. package/dist/esm/version.d.ts +1 -0
  357. package/dist/esm/version.js +2 -0
  358. package/dist/esm/version.js.map +1 -0
  359. package/dist/types/actions/getBalance.d.ts +6 -3
  360. package/dist/types/actions/getBalance.d.ts.map +1 -1
  361. package/dist/types/actions/getBlock.d.ts +4 -1
  362. package/dist/types/actions/getBlock.d.ts.map +1 -1
  363. package/dist/types/actions/getBlockCount.d.ts +4 -1
  364. package/dist/types/actions/getBlockCount.d.ts.map +1 -1
  365. package/dist/types/actions/getBlockStats.d.ts +4 -1
  366. package/dist/types/actions/getBlockStats.d.ts.map +1 -1
  367. package/dist/types/actions/getUTXOTransaction.d.ts +4 -1
  368. package/dist/types/actions/getUTXOTransaction.d.ts.map +1 -1
  369. package/dist/types/actions/sendUTXOTransaction.d.ts +4 -1
  370. package/dist/types/actions/sendUTXOTransaction.d.ts.map +1 -1
  371. package/dist/types/actions/signPsbt.d.ts +5 -2
  372. package/dist/types/actions/signPsbt.d.ts.map +1 -1
  373. package/dist/types/actions/waitForTransaction.d.ts +3 -1
  374. package/dist/types/actions/waitForTransaction.d.ts.map +1 -1
  375. package/dist/types/actions/watchBlockNumber.d.ts +3 -1
  376. package/dist/types/actions/watchBlockNumber.d.ts.map +1 -1
  377. package/dist/types/chains/bitcoin.d.ts +5 -17
  378. package/dist/types/chains/bitcoin.d.ts.map +1 -1
  379. package/dist/types/chains/defineChain.d.ts +4 -0
  380. package/dist/types/chains/defineChain.d.ts.map +1 -0
  381. package/dist/types/clients/decorators/public.d.ts +19 -0
  382. package/dist/types/clients/decorators/public.d.ts.map +1 -0
  383. package/dist/types/clients/decorators/wallet.d.ts +15 -0
  384. package/dist/types/clients/decorators/wallet.d.ts.map +1 -0
  385. package/dist/types/errors/address.d.ts +10 -0
  386. package/dist/types/errors/address.d.ts.map +1 -0
  387. package/dist/types/errors/base.d.ts +28 -0
  388. package/dist/types/errors/base.d.ts.map +1 -0
  389. package/dist/types/errors/block.d.ts +12 -0
  390. package/dist/types/errors/block.d.ts.map +1 -0
  391. package/dist/types/errors/config.d.ts +62 -0
  392. package/dist/types/errors/config.d.ts.map +1 -0
  393. package/dist/types/errors/provider.d.ts +5 -0
  394. package/dist/types/errors/provider.d.ts.map +1 -0
  395. package/dist/types/errors/request.d.ts +81 -0
  396. package/dist/types/errors/request.d.ts.map +1 -0
  397. package/dist/types/errors/rpc.d.ts +54 -0
  398. package/dist/types/errors/rpc.d.ts.map +1 -0
  399. package/dist/types/errors/transaction.d.ts +32 -0
  400. package/dist/types/errors/transaction.d.ts.map +1 -0
  401. package/dist/types/errors/transport.d.ts +8 -0
  402. package/dist/types/errors/transport.d.ts.map +1 -0
  403. package/dist/types/errors/utils.d.ts +7 -0
  404. package/dist/types/errors/utils.d.ts.map +1 -0
  405. package/dist/types/factories/createClient.d.ts +86 -0
  406. package/dist/types/factories/createClient.d.ts.map +1 -0
  407. package/dist/types/factories/createTransport.d.ts +43 -0
  408. package/dist/types/factories/createTransport.d.ts.map +1 -0
  409. package/dist/types/index.d.ts +37 -4
  410. package/dist/types/index.d.ts.map +1 -1
  411. package/dist/types/transports/custom.d.ts +25 -0
  412. package/dist/types/transports/custom.d.ts.map +1 -0
  413. package/dist/types/transports/fallback.d.ts +90 -0
  414. package/dist/types/transports/fallback.d.ts.map +1 -0
  415. package/dist/types/transports/getHttpRpcClient.d.ts +15 -1
  416. package/dist/types/transports/getHttpRpcClient.d.ts.map +1 -1
  417. package/dist/types/transports/http.d.ts +54 -0
  418. package/dist/types/transports/http.d.ts.map +1 -0
  419. package/dist/types/transports/types.d.ts +36 -5
  420. package/dist/types/transports/types.d.ts.map +1 -1
  421. package/dist/types/transports/utxo.d.ts +1 -1
  422. package/dist/types/transports/utxo.d.ts.map +1 -1
  423. package/dist/types/types/account.d.ts +10 -0
  424. package/dist/types/types/account.d.ts.map +1 -0
  425. package/dist/types/types/actions.d.ts +21 -0
  426. package/dist/types/types/actions.d.ts.map +1 -0
  427. package/dist/types/types/address.d.ts +2 -0
  428. package/dist/types/types/address.d.ts.map +1 -0
  429. package/dist/types/types/base.d.ts +1 -0
  430. package/dist/types/types/base.d.ts.map +1 -0
  431. package/dist/types/types/block.d.ts +20 -0
  432. package/dist/types/types/block.d.ts.map +1 -0
  433. package/dist/types/types/chain.d.ts +49 -0
  434. package/dist/types/types/chain.d.ts.map +1 -0
  435. package/dist/types/types/client.d.ts +69 -0
  436. package/dist/types/types/client.d.ts.map +1 -0
  437. package/dist/types/types/hash.d.ts +2 -0
  438. package/dist/types/types/hash.d.ts.map +1 -0
  439. package/dist/types/types/request.d.ts +49 -0
  440. package/dist/types/types/request.d.ts.map +1 -0
  441. package/dist/types/types/rpc.d.ts +35 -0
  442. package/dist/types/types/rpc.d.ts.map +1 -0
  443. package/dist/types/types/storage.d.ts +23 -0
  444. package/dist/types/types/storage.d.ts.map +1 -0
  445. package/dist/types/types/transport.d.ts +38 -0
  446. package/dist/types/types/transport.d.ts.map +1 -0
  447. package/dist/types/types/utils.d.ts +73 -0
  448. package/dist/types/types/utils.d.ts.map +1 -0
  449. package/dist/types/utils/buildRequest.d.ts +7 -0
  450. package/dist/types/utils/buildRequest.d.ts.map +1 -0
  451. package/dist/types/utils/converter.d.ts +4 -0
  452. package/dist/types/utils/converter.d.ts.map +1 -0
  453. package/dist/types/utils/createBatchScheduler.d.ts +22 -0
  454. package/dist/types/utils/createBatchScheduler.d.ts.map +1 -0
  455. package/dist/types/utils/deepEqual.d.ts +3 -0
  456. package/dist/types/utils/deepEqual.d.ts.map +1 -0
  457. package/dist/types/utils/getAction.d.ts +18 -0
  458. package/dist/types/utils/getAction.d.ts.map +1 -0
  459. package/dist/types/utils/getUTXOAddress.d.ts +3 -2
  460. package/dist/types/utils/getUTXOAddress.d.ts.map +1 -1
  461. package/dist/types/utils/isUTXOAddress.d.ts.map +1 -1
  462. package/dist/types/utils/lru.d.ts +12 -0
  463. package/dist/types/utils/lru.d.ts.map +1 -0
  464. package/dist/types/utils/observe.d.ts +1 -1
  465. package/dist/types/utils/observe.d.ts.map +1 -1
  466. package/dist/types/utils/parseAccount.d.ts +6 -0
  467. package/dist/types/utils/parseAccount.d.ts.map +1 -0
  468. package/dist/types/utils/stringify.d.ts +4 -0
  469. package/dist/types/utils/stringify.d.ts.map +1 -0
  470. package/dist/types/utils/uid.d.ts +2 -0
  471. package/dist/types/utils/uid.d.ts.map +1 -0
  472. package/dist/types/utils/wait.d.ts +2 -0
  473. package/dist/types/utils/wait.d.ts.map +1 -0
  474. package/dist/types/utils/withDedupe.d.ts +11 -0
  475. package/dist/types/utils/withDedupe.d.ts.map +1 -0
  476. package/dist/types/utils/withResolvers.d.ts +9 -0
  477. package/dist/types/utils/withResolvers.d.ts.map +1 -0
  478. package/dist/types/utils/withRetry.d.ts +15 -0
  479. package/dist/types/utils/withRetry.d.ts.map +1 -0
  480. package/dist/types/utils/withTimeout.d.ts +10 -0
  481. package/dist/types/utils/withTimeout.d.ts.map +1 -0
  482. package/dist/types/version.d.ts +2 -0
  483. package/dist/types/version.d.ts.map +1 -0
  484. package/package.json +4 -3
  485. package/package.json.tmp +61 -0
  486. package/src/actions/getBalance.ts +6 -3
  487. package/src/actions/getBlock.ts +7 -7
  488. package/src/actions/getBlockCount.ts +4 -1
  489. package/src/actions/getBlockStats.ts +5 -7
  490. package/src/actions/getUTXOTransaction.ts +5 -7
  491. package/src/actions/sendUTXOTransaction.ts +4 -1
  492. package/src/actions/signPsbt.ts +5 -2
  493. package/src/actions/waitForTransaction.ts +9 -7
  494. package/src/actions/watchBlockNumber.ts +5 -2
  495. package/src/chains/bitcoin.ts +1 -1
  496. package/src/chains/defineChain.ts +14 -0
  497. package/src/clients/decorators/public.ts +62 -0
  498. package/src/clients/decorators/wallet.ts +37 -0
  499. package/src/errors/address.ts +16 -0
  500. package/src/errors/base.ts +85 -0
  501. package/src/errors/block.ts +24 -0
  502. package/src/errors/config.ts +102 -0
  503. package/src/errors/provider.ts +11 -0
  504. package/src/errors/request.ts +134 -0
  505. package/src/errors/rpc.ts +77 -0
  506. package/src/errors/transaction.ts +67 -0
  507. package/src/errors/transport.ts +15 -0
  508. package/src/errors/utils.ts +6 -0
  509. package/src/factories/createClient.ts +199 -0
  510. package/src/factories/createTransport.ts +93 -0
  511. package/src/index.ts +114 -13
  512. package/src/transports/custom.ts +56 -0
  513. package/src/transports/fallback.ts +332 -0
  514. package/src/transports/getHttpRpcClient.ts +28 -4
  515. package/src/transports/http.ts +176 -0
  516. package/src/transports/types.ts +38 -5
  517. package/src/transports/utxo.ts +6 -9
  518. package/src/types/account.ts +10 -0
  519. package/src/types/actions.ts +38 -0
  520. package/src/types/address.ts +1 -0
  521. package/src/types/base.ts +0 -0
  522. package/src/types/block.ts +19 -0
  523. package/src/types/chain.ts +72 -0
  524. package/src/types/client.ts +108 -0
  525. package/src/types/hash.ts +1 -0
  526. package/src/types/request.ts +87 -0
  527. package/src/types/rpc.ts +37 -0
  528. package/src/types/storage.ts +44 -0
  529. package/src/types/transport.ts +54 -0
  530. package/src/types/utils.ts +131 -0
  531. package/src/utils/buildRequest.ts +145 -0
  532. package/src/utils/converter.ts +25 -0
  533. package/src/utils/createBatchScheduler.ts +116 -0
  534. package/src/utils/deepEqual.ts +62 -0
  535. package/src/utils/getAction.ts +45 -0
  536. package/src/utils/getUTXOAddress.ts +4 -3
  537. package/src/utils/isUTXOAddress.ts +2 -1
  538. package/src/utils/lru.ts +35 -0
  539. package/src/utils/observe.ts +1 -1
  540. package/src/utils/parseAccount.ts +14 -0
  541. package/src/utils/stringify.ts +13 -0
  542. package/src/utils/uid.ts +14 -0
  543. package/src/utils/wait.ts +3 -0
  544. package/src/utils/withDedupe.ts +25 -0
  545. package/src/utils/withResolvers.ts +19 -0
  546. package/src/utils/withRetry.ts +60 -0
  547. package/src/utils/withTimeout.ts +47 -0
  548. package/src/version.ts +1 -0
  549. package/tsconfig.json +2 -1
  550. package/dist/cjs/clients/types.d.ts +0 -27
  551. package/dist/cjs/clients/types.js.map +0 -1
  552. package/dist/cjs/decorators/UTXOAPIActions.d.ts +0 -6
  553. package/dist/cjs/decorators/UTXOAPIActions.js +0 -10
  554. package/dist/cjs/decorators/UTXOAPIActions.js.map +0 -1
  555. package/dist/cjs/decorators/UTXOActions.d.ts +0 -10
  556. package/dist/cjs/decorators/UTXOActions.js +0 -14
  557. package/dist/cjs/decorators/UTXOActions.js.map +0 -1
  558. package/dist/esm/clients/types.d.ts +0 -43
  559. package/dist/esm/clients/types.js +0 -2
  560. package/dist/esm/clients/types.js.map +0 -1
  561. package/dist/esm/decorators/UTXOAPIActions.d.ts +0 -6
  562. package/dist/esm/decorators/UTXOAPIActions.js +0 -7
  563. package/dist/esm/decorators/UTXOAPIActions.js.map +0 -1
  564. package/dist/esm/decorators/UTXOActions.d.ts +0 -10
  565. package/dist/esm/decorators/UTXOActions.js +0 -11
  566. package/dist/esm/decorators/UTXOActions.js.map +0 -1
  567. package/dist/types/clients/types.d.ts +0 -44
  568. package/dist/types/clients/types.d.ts.map +0 -1
  569. package/dist/types/decorators/UTXOAPIActions.d.ts +0 -7
  570. package/dist/types/decorators/UTXOAPIActions.d.ts.map +0 -1
  571. package/dist/types/decorators/UTXOActions.d.ts +0 -11
  572. package/dist/types/decorators/UTXOActions.d.ts.map +0 -1
  573. package/src/clients/types.ts +0 -48
  574. package/src/decorators/UTXOAPIActions.ts +0 -20
  575. package/src/decorators/UTXOActions.ts +0 -37
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Specifies a particular block in the blockchain.
3
+ *
4
+ * - `"latest"`: the latest proposed block
5
+ * - `"earliest"`: the earliest/genesis block – lowest numbered block the client has available
6
+ * - `"pending"`: pending state/transactions – next block built by the client on top
7
+ * of unsafe and containing the set of transactions usually taken from local mempool
8
+ * - `"safe"`: the latest safe head block – the most recent block that is safe from
9
+ * re-orgs under honest majority and certain synchronicity assumptions
10
+ * - `"finalized"`: the latest finalized block – the most recent crypto-economically secure block;
11
+ * cannot be re-orged outside of manual intervention driven by community coordination
12
+ *
13
+ * Using `pending`, while allowed, is not advised, as it may lead
14
+ * to internally inconsistent results. Use of `latest` is safe and will not
15
+ * lead to inconsistent results. Depending on the backing RPC networks caching system,
16
+ * the usage of `pending` may lead to inconsistencies as a result of an
17
+ * overly aggressive cache system. This may cause downstream errors/invalid states.
18
+ */
19
+ export type BlockTag = 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
@@ -0,0 +1,72 @@
1
+ export type Chain<
2
+ formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
3
+ custom extends Record<string, unknown> | undefined =
4
+ | Record<string, unknown>
5
+ | undefined,
6
+ > = {
7
+ /** Collection of block explorers */
8
+ blockExplorers?:
9
+ | {
10
+ [key: string]: ChainBlockExplorer
11
+ default: ChainBlockExplorer
12
+ }
13
+ | undefined
14
+ /** ID in number form */
15
+ id: number
16
+ /** Human-readable name */
17
+ name: string
18
+ /** Collection of RPC endpoints */
19
+ rpcUrls: {
20
+ [key: string]: ChainRpcUrls
21
+ default: ChainRpcUrls
22
+ }
23
+ /** Flag for test networks */
24
+ testnet?: boolean | undefined
25
+ } & ChainConfig<formatters, custom>
26
+
27
+ export type ChainConfig<
28
+ formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
29
+ custom extends Record<string, unknown> | undefined =
30
+ | Record<string, unknown>
31
+ | undefined,
32
+ > = {
33
+ /** Custom chain data. */
34
+ custom?: custom | undefined
35
+ /** Modifies how data is formatted and typed (e.g. blocks and transactions) */
36
+ formatters?: formatters | undefined
37
+ }
38
+
39
+ /////////////////////////////////////////////////////////////////////
40
+ // Formatters
41
+ /////////////////////////////////////////////////////////////////////
42
+
43
+ export type ChainFormatters = {
44
+ /** Modifies how the Block structure is formatted & typed. */
45
+ block?: ChainFormatter<'block'> | undefined
46
+ /** Modifies how the Transaction structure is formatted & typed. */
47
+ transaction?: ChainFormatter<'transaction'> | undefined
48
+ /** Modifies how the TransactionReceipt structure is formatted & typed. */
49
+ transactionReceipt?: ChainFormatter<'transactionReceipt'> | undefined
50
+ /** Modifies how the TransactionRequest structure is formatted & typed. */
51
+ transactionRequest?: ChainFormatter<'transactionRequest'> | undefined
52
+ }
53
+
54
+ export type ChainFormatter<type extends string = string> = {
55
+ format: (args: any) => any
56
+ type: type
57
+ }
58
+
59
+ /////////////////////////////////////////////////////////////////////
60
+ // Constants
61
+ /////////////////////////////////////////////////////////////////////
62
+
63
+ type ChainBlockExplorer = {
64
+ name: string
65
+ url: string
66
+ apiUrl?: string | undefined
67
+ }
68
+
69
+ type ChainRpcUrls = {
70
+ http: readonly string[]
71
+ webSocket?: readonly string[] | undefined
72
+ }
@@ -0,0 +1,108 @@
1
+ import type { ErrorType } from '../errors/utils.js'
2
+
3
+ import type { Account } from './account.js'
4
+ import type { Address } from './address.js'
5
+ import type { Chain } from './chain.js'
6
+ import type { BtcRpcRequestFn, RpcSchema } from './request.js'
7
+ import type { BitcoinRpcMethods } from './rpc.js'
8
+ import type { Transport } from './transport.js'
9
+ import type { Prettify } from './utils.js'
10
+
11
+ export type ClientConfig<
12
+ transport extends Transport = Transport,
13
+ chain extends Chain | undefined = Chain | undefined,
14
+ accountOrAddress extends Account | Address | undefined =
15
+ | Account
16
+ | Address
17
+ | undefined,
18
+ rpcSchema extends RpcSchema | undefined = undefined,
19
+ > = {
20
+ /** The Account to use for the Client. This will be used for Actions that require an account as an argument. */
21
+ account?: accountOrAddress | Account | Address | undefined
22
+ /**
23
+ * Time (in ms) that cached data will remain in memory.
24
+ * @default 4_000
25
+ */
26
+ cacheTime?: number | undefined
27
+ /** Chain for the client. */
28
+ chain?: Chain | undefined | chain
29
+ /** A key for the client. */
30
+ key?: string | undefined
31
+ /** A name for the client. */
32
+ name?: string | undefined
33
+ /**
34
+ * Frequency (in ms) for polling enabled actions & events.
35
+ * @default 4_000
36
+ */
37
+ pollingInterval?: number | undefined
38
+ /**
39
+ * Typed JSON-RPC schema for the client.
40
+ */
41
+ rpcSchema?: rpcSchema | undefined
42
+ /** The RPC transport */
43
+ transport: transport
44
+ /** The type of client. */
45
+ type?: string | undefined
46
+ }
47
+
48
+ // TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.
49
+ // Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.
50
+ export type Client<
51
+ transport extends Transport = Transport,
52
+ chain extends Chain | undefined = Chain | undefined,
53
+ account extends Account | undefined = Account | undefined,
54
+ rpcSchema extends RpcSchema | undefined = undefined,
55
+ extended extends Extended | undefined = Extended | undefined,
56
+ > = Client_Base<transport, chain, account, rpcSchema> &
57
+ (extended extends Extended ? extended : unknown) & {
58
+ extend: <const client extends Extended>(
59
+ fn: (
60
+ client: Client<transport, chain, account, rpcSchema, extended>
61
+ ) => client
62
+ ) => Client<
63
+ transport,
64
+ chain,
65
+ account,
66
+ rpcSchema,
67
+ Prettify<client> & (extended extends Extended ? extended : unknown)
68
+ >
69
+ }
70
+
71
+ type Client_Base<
72
+ transport extends Transport = Transport,
73
+ chain extends Chain | undefined = Chain | undefined,
74
+ account extends Account | undefined = Account | undefined,
75
+ rpcSchema extends RpcSchema | undefined = undefined,
76
+ > = {
77
+ /** The Account of the Client. */
78
+ account: account
79
+ /** Time (in ms) that cached data will remain in memory. */
80
+ cacheTime: number
81
+ /** Chain for the client. */
82
+ chain: chain
83
+ /** A key for the client. */
84
+ key: string
85
+ /** A name for the client. */
86
+ name: string
87
+ /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
88
+ pollingInterval: number
89
+ /** Request function wrapped with friendly error handling */
90
+ request: BtcRpcRequestFn<
91
+ rpcSchema extends undefined ? BitcoinRpcMethods : rpcSchema
92
+ >
93
+ /** The RPC transport */
94
+ transport: ReturnType<transport>['config'] & ReturnType<transport>['value']
95
+ /** The type of client. */
96
+ type: string
97
+ /** A unique ID for the client. */
98
+ uid: string
99
+ }
100
+
101
+ type Extended = Prettify<
102
+ // disallow redefining base properties
103
+ { [_ in keyof Client_Base]?: undefined } & {
104
+ [key: string]: unknown
105
+ }
106
+ >
107
+
108
+ export type CreateClientErrorType = ErrorType
@@ -0,0 +1 @@
1
+ export type Hash = `0x${string}`
@@ -0,0 +1,87 @@
1
+ import type { ErrorType } from '../errors/utils.js'
2
+ import type { OneOf } from './utils.js'
3
+
4
+ export type RpcSchema = readonly {
5
+ Method: string
6
+ Parameters?: unknown | undefined
7
+ ReturnType: unknown
8
+ }[]
9
+
10
+ export type RpcSchemaOverride = Omit<RpcSchema[number], 'Method'>
11
+
12
+ type DerivedRpcSchema<rpcSchema extends RpcSchema | undefined> =
13
+ rpcSchema extends RpcSchema ? rpcSchema : never
14
+
15
+ export type RpcParameters<rpcSchema extends RpcSchema | undefined = undefined> =
16
+ rpcSchema extends RpcSchema
17
+ ? {
18
+ [K in keyof rpcSchema]: rpcSchema[K] extends RpcSchema[number]
19
+ ? {
20
+ method: rpcSchema[K]['Method']
21
+ params: rpcSchema[K]['Parameters']
22
+ }
23
+ : never
24
+ }[number]
25
+ : {
26
+ method: string
27
+ params?: unknown | undefined
28
+ }
29
+
30
+ export type BtcRpcRequestOptions = {
31
+ /** Deduplicate in-flight requests. */
32
+ dedupe?: boolean | undefined
33
+ /** Methods to include or exclude from executing RPC requests. */
34
+ methods?:
35
+ | OneOf<
36
+ | {
37
+ include?: string[] | undefined
38
+ }
39
+ | {
40
+ exclude?: string[] | undefined
41
+ }
42
+ >
43
+ | undefined
44
+ /** The base delay (in ms) between retries. */
45
+ retryDelay?: number | undefined
46
+ /** The max number of times to retry. */
47
+ retryCount?: number | undefined
48
+ /** Unique identifier for the request. */
49
+ uid?: string | undefined
50
+ }
51
+
52
+ export type BtcRpcRequestFn<
53
+ rpcSchema extends RpcSchema | undefined = undefined,
54
+ raw extends boolean = false,
55
+ > = <
56
+ _parameters extends RpcParameters<
57
+ DerivedRpcSchema<rpcSchema>
58
+ > = RpcParameters<DerivedRpcSchema<rpcSchema>>,
59
+ _returnType = DerivedRpcSchema<rpcSchema> extends RpcSchema
60
+ ? raw extends true
61
+ ? OneOf<
62
+ | {
63
+ result: Extract<
64
+ DerivedRpcSchema<rpcSchema>[number],
65
+ { Method: _parameters['method'] }
66
+ >['ReturnType']
67
+ }
68
+ | { error: ErrorType }
69
+ >
70
+ : Extract<
71
+ DerivedRpcSchema<rpcSchema>[number],
72
+ { Method: _parameters['method'] }
73
+ >['ReturnType']
74
+ : raw extends true
75
+ ? OneOf<
76
+ | {
77
+ result: unknown
78
+ }
79
+ | {
80
+ error: ErrorType
81
+ }
82
+ >
83
+ : unknown,
84
+ >(
85
+ args: _parameters,
86
+ options?: BtcRpcRequestOptions | undefined
87
+ ) => Promise<_returnType>
@@ -0,0 +1,37 @@
1
+ export type RpcRequest = {
2
+ jsonrpc?: '2.0' | undefined
3
+ method: string
4
+ params?: any | undefined
5
+ id?: number | undefined
6
+ }
7
+
8
+ export type RpcResponse<result = any, error = any> = {
9
+ jsonrpc: `${number}`
10
+ id: number
11
+ } & (SuccessResult<result> | ErrorResult<error>)
12
+
13
+ type SuccessResult<result> = {
14
+ method?: undefined
15
+ result: result
16
+ error?: undefined
17
+ }
18
+ type ErrorResult<error> = {
19
+ method?: undefined
20
+ result?: undefined
21
+ error: error
22
+ }
23
+
24
+ export type BitcoinRpcMethods = [...WalletRpcSchema]
25
+
26
+ export type WalletRpcSchema = [
27
+ {
28
+ Method: 'getAddressInfo'
29
+ Parameters?: undefined
30
+ ReturnType: string
31
+ },
32
+ {
33
+ Method: 'getBalance'
34
+ Parameters?: undefined
35
+ ReturnType: bigint
36
+ },
37
+ ]
@@ -0,0 +1,44 @@
1
+ import type { Compute } from './utils.js'
2
+
3
+ export type StorageItemMap = {
4
+ recentConnectorId: string
5
+ state: any
6
+ }
7
+
8
+ export type Storage<
9
+ itemMap extends Record<string, unknown> = Record<string, unknown>,
10
+ ///
11
+ storageItemMap extends StorageItemMap = StorageItemMap & itemMap,
12
+ > = {
13
+ key: string
14
+ getItem<
15
+ key extends keyof storageItemMap,
16
+ value extends storageItemMap[key],
17
+ defaultValue extends value | null | undefined,
18
+ >(
19
+ key: key,
20
+ defaultValue?: defaultValue | undefined
21
+ ):
22
+ | (defaultValue extends null ? value | null : value)
23
+ | Promise<defaultValue extends null ? value | null : value>
24
+ setItem<
25
+ key extends keyof storageItemMap,
26
+ value extends storageItemMap[key] | null,
27
+ >(key: key, value: value): void | Promise<void>
28
+ removeItem(key: keyof storageItemMap): void | Promise<void>
29
+ }
30
+
31
+ export type BaseStorage = {
32
+ getItem(
33
+ key: string
34
+ ): string | null | undefined | Promise<string | null | undefined>
35
+ setItem(key: string, value: string): void | Promise<void>
36
+ removeItem(key: string): void | Promise<void>
37
+ }
38
+
39
+ export type CreateStorageParameters = {
40
+ deserialize?: (<type>(value: string) => type | unknown) | undefined
41
+ key?: string | undefined
42
+ serialize?: (<type>(value: type | any) => string) | undefined
43
+ storage?: Compute<BaseStorage> | undefined
44
+ }
@@ -0,0 +1,54 @@
1
+ import type { ErrorType } from '../errors/utils.js'
2
+ import type { Chain } from './chain.js'
3
+ import type { BtcRpcRequestFn, RpcSchema } from './request.js'
4
+ import type { OneOf } from './utils.js'
5
+
6
+ export type TransportConfig<
7
+ type extends string = string,
8
+ rpcRequestFn extends BtcRpcRequestFn = BtcRpcRequestFn,
9
+ > = {
10
+ /** The name of the transport. */
11
+ name: string
12
+ /** The key of the transport. */
13
+ key: string
14
+ /** Methods to include or exclude from executing RPC requests. */
15
+ methods?:
16
+ | OneOf<
17
+ | {
18
+ include?: string[] | undefined
19
+ }
20
+ | {
21
+ exclude?: string[] | undefined
22
+ }
23
+ >
24
+ | undefined
25
+ /** The JSON-RPC request function that matches the EIP-1193 request spec. */
26
+ request: rpcRequestFn
27
+ /** The base delay (in ms) between retries. */
28
+ retryDelay?: number | undefined
29
+ /** The max number of times to retry. */
30
+ retryCount?: number | undefined
31
+ /** The timeout (in ms) for requests. */
32
+ timeout?: number | undefined
33
+ /** The type of the transport. */
34
+ type: type
35
+ }
36
+
37
+ export type Transport<
38
+ type extends string = string,
39
+ rpcAttributes = Record<string, any>,
40
+ rpcRequestFn extends BtcRpcRequestFn = BtcRpcRequestFn<RpcSchema>,
41
+ > = <chain extends Chain | undefined = Chain>({
42
+ chain,
43
+ }: {
44
+ chain?: chain | undefined
45
+ pollingInterval?: number | undefined
46
+ retryCount?: TransportConfig['retryCount'] | undefined
47
+ timeout?: TransportConfig['timeout'] | undefined
48
+ }) => {
49
+ config: TransportConfig<type>
50
+ request: rpcRequestFn
51
+ value?: rpcAttributes | undefined
52
+ }
53
+
54
+ export type CreateTransportErrorType = ErrorType
@@ -0,0 +1,131 @@
1
+ /** Combines members of an intersection into a readable type. */
2
+ // https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
3
+ export type Compute<type> = { [key in keyof type]: type[key] } & unknown
4
+
5
+ /**
6
+ * Makes all properties of an object optional.
7
+ *
8
+ * Compatible with [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes).
9
+ */
10
+ export type ExactPartial<type> = {
11
+ [key in keyof type]?: type[key] | undefined
12
+ }
13
+
14
+ /** Checks if {@link type} can be narrowed further than {@link type2} */
15
+ export type IsNarrowable<type, type2> = IsUnknown<type> extends true
16
+ ? false
17
+ : undefined extends type
18
+ ? false
19
+ : IsNever<
20
+ (type extends type2 ? true : false) &
21
+ (type2 extends type ? false : true)
22
+ > extends true
23
+ ? false
24
+ : true
25
+
26
+ /**
27
+ * @internal
28
+ * Checks if {@link type} is `never`
29
+ */
30
+ export type IsNever<type> = [type] extends [never] ? true : false
31
+
32
+ /**
33
+ * @internal
34
+ * Checks if {@link type} is `unknown`
35
+ */
36
+ export type IsUnknown<type> = unknown extends type ? true : false
37
+
38
+ /** Merges two object types into new type */
39
+ export type Merge<obj1, obj2> = Compute<
40
+ LooseOmit<obj1, keyof obj2 extends infer key extends string ? key : never> &
41
+ obj2
42
+ >
43
+
44
+ /** Removes `readonly` from all properties of an object. */
45
+ export type Mutable<type extends object> = {
46
+ -readonly [key in keyof type]: type[key]
47
+ }
48
+
49
+ /** Strict version of built-in Omit type */
50
+ export type StrictOmit<type, keys extends keyof type> = Pick<
51
+ type,
52
+ Exclude<keyof type, keys>
53
+ >
54
+
55
+ /** Makes objects destructurable. */
56
+ export type OneOf<
57
+ union extends object,
58
+ ///
59
+ keys extends KeyofUnion<union> = KeyofUnion<union>,
60
+ > = union extends infer Item
61
+ ? Compute<Item & { [K in Exclude<keys, keyof Item>]?: undefined }>
62
+ : never
63
+ type KeyofUnion<type> = type extends type ? keyof type : never
64
+
65
+ /** Makes {@link key} optional in {@link type} while preserving type inference. */
66
+ // s/o trpc (https://github.com/trpc/trpc/blob/main/packages/server/src/types.ts#L6)
67
+ export type PartialBy<type, key extends keyof type> = ExactPartial<
68
+ Pick<type, key>
69
+ > &
70
+ StrictOmit<type, key>
71
+
72
+ /* Removes `undefined` from object property */
73
+ export type RemoveUndefined<type> = {
74
+ [key in keyof type]: NonNullable<type[key]>
75
+ }
76
+
77
+ ///////////////////////////////////////////////////////////////////////////
78
+ // Loose types
79
+
80
+ /** Loose version of {@link StrictOmit} */
81
+ export type LooseOmit<type, keys extends string> = Pick<
82
+ type,
83
+ Exclude<keyof type, keys>
84
+ >
85
+
86
+ ///////////////////////////////////////////////////////////////////////////
87
+ // Union types
88
+
89
+ export type UnionCompute<type> = type extends object ? Compute<type> : type
90
+
91
+ export type UnionLooseOmit<type, keys extends string> = type extends any
92
+ ? LooseOmit<type, keys>
93
+ : never
94
+
95
+ export type UnionStrictOmit<type, keys extends keyof type> = type extends any
96
+ ? StrictOmit<type, keys>
97
+ : never
98
+
99
+ export type UnionExactPartial<type> = type extends object
100
+ ? ExactPartial<type>
101
+ : type
102
+
103
+ /**
104
+ * @description Combines members of an intersection into a readable type.
105
+ *
106
+ * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
107
+ * @example
108
+ * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
109
+ * => { a: string, b: string, c: number, d: bigint }
110
+ */
111
+ export type Prettify<T> = {
112
+ [K in keyof T]: T[K]
113
+ } & {}
114
+
115
+ /**
116
+ * @description Assigns the properties of U onto T.
117
+ *
118
+ * @example
119
+ * Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
120
+ * => { a: undefined, b: number, c: boolean }
121
+ */
122
+ export type Assign<T, U> = Assign_<T, U> & U
123
+ type Assign_<T, U> = {
124
+ [K in keyof T as K extends keyof U
125
+ ? U[K] extends void
126
+ ? never
127
+ : K
128
+ : K]: K extends keyof U ? U[K] : T[K]
129
+ }
130
+
131
+ export type MaybePromise<T> = T | Promise<T>