@kontor/kontor-sdk 1.0.0-alpha.13 → 1.0.0-alpha.15

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 (288) hide show
  1. package/dist/cjs/sdk/actions/kontor/public/{build-compose-call.js → build-compose-query.js} +8 -9
  2. package/dist/cjs/sdk/actions/kontor/public/build-compose-query.js.map +1 -0
  3. package/dist/cjs/sdk/actions/kontor/public/{build-instruction.js → build-instruction-query.js} +11 -16
  4. package/dist/cjs/sdk/actions/kontor/public/build-instruction-query.js.map +1 -0
  5. package/dist/cjs/sdk/actions/kontor/public/{call-proc.js → call-compose.js} +7 -9
  6. package/dist/cjs/sdk/actions/kontor/public/call-compose.js.map +1 -0
  7. package/dist/cjs/sdk/actions/kontor/public/proc-contract.js +8 -5
  8. package/dist/cjs/sdk/actions/kontor/public/proc-contract.js.map +1 -1
  9. package/dist/cjs/sdk/actions/kontor/wallet/sign-reveal.js +1 -1
  10. package/dist/cjs/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -1
  11. package/dist/cjs/sdk/clients/decorators/kontor/public.js +6 -6
  12. package/dist/cjs/sdk/clients/decorators/kontor/public.js.map +1 -1
  13. package/dist/cjs/sdk/contracts/wits.js.map +1 -1
  14. package/dist/cjs/sdk/types/kontor.js +28 -0
  15. package/dist/cjs/sdk/types/kontor.js.map +1 -1
  16. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  17. package/dist/{src/sdk/actions/kontor/public/build-compose-call.js → esm/sdk/actions/kontor/public/build-compose-query.js} +2 -2
  18. package/dist/esm/sdk/actions/kontor/public/build-compose-query.js.map +1 -0
  19. package/dist/{src/sdk/actions/kontor/public/build-instruction.js → esm/sdk/actions/kontor/public/build-instruction-query.js} +1 -2
  20. package/dist/esm/sdk/actions/kontor/public/build-instruction-query.js.map +1 -0
  21. package/dist/esm/sdk/actions/kontor/public/{call-proc.js → call-compose.js} +7 -8
  22. package/dist/esm/sdk/actions/kontor/public/call-compose.js.map +1 -0
  23. package/dist/esm/sdk/actions/kontor/public/proc-contract.js +8 -5
  24. package/dist/esm/sdk/actions/kontor/public/proc-contract.js.map +1 -1
  25. package/dist/esm/sdk/actions/kontor/wallet/sign-reveal.js +4 -6
  26. package/dist/esm/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -1
  27. package/dist/esm/sdk/clients/decorators/kontor/public.js +6 -6
  28. package/dist/esm/sdk/clients/decorators/kontor/public.js.map +1 -1
  29. package/dist/esm/sdk/contracts/wits.js.map +1 -1
  30. package/dist/esm/sdk/types/kontor.js +27 -1
  31. package/dist/esm/sdk/types/kontor.js.map +1 -1
  32. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  33. package/dist/src/exports/index.test.js +10 -0
  34. package/dist/src/exports/index.test.js.map +1 -0
  35. package/dist/src/sdk/accounts/hd-key-to-account.js +20 -0
  36. package/dist/src/sdk/accounts/hd-key-to-account.js.map +1 -0
  37. package/dist/src/sdk/accounts/mnemonic-to-account.js +16 -0
  38. package/dist/src/sdk/accounts/mnemonic-to-account.js.map +1 -0
  39. package/dist/src/sdk/accounts/mnemonic-to-account.test.js +96 -0
  40. package/dist/src/sdk/accounts/mnemonic-to-account.test.js.map +1 -0
  41. package/dist/src/sdk/accounts/to-local-account.js +28 -0
  42. package/dist/src/sdk/accounts/to-local-account.js.map +1 -0
  43. package/dist/src/sdk/accounts/types.js +2 -0
  44. package/dist/src/sdk/accounts/types.js.map +1 -0
  45. package/dist/src/sdk/accounts/utils/parse-account.js +10 -0
  46. package/dist/src/sdk/accounts/utils/parse-account.js.map +1 -0
  47. package/dist/src/sdk/accounts/utils/public-key-to-p2tr-payment.js +14 -0
  48. package/dist/src/sdk/accounts/utils/public-key-to-p2tr-payment.js.map +1 -0
  49. package/dist/src/sdk/accounts/utils/sign-psbt.js +17 -0
  50. package/dist/src/sdk/accounts/utils/sign-psbt.js.map +1 -0
  51. package/dist/src/sdk/actions/kontor/wallet/sign-commit.js +34 -0
  52. package/dist/src/sdk/actions/kontor/wallet/sign-commit.js.map +1 -0
  53. package/dist/src/sdk/actions/public/send-raw-transaction.js +7 -0
  54. package/dist/src/sdk/actions/public/send-raw-transaction.js.map +1 -0
  55. package/dist/src/sdk/actions/public/test-mempool-accept.js +20 -0
  56. package/dist/src/sdk/actions/public/test-mempool-accept.js.map +1 -0
  57. package/dist/src/sdk/chains/definitions/index.js +2 -0
  58. package/dist/src/sdk/chains/definitions/index.js.map +1 -0
  59. package/dist/src/sdk/chains/definitions/signet.js +36 -0
  60. package/dist/src/sdk/chains/definitions/signet.js.map +1 -0
  61. package/dist/src/sdk/clients/base/create-rpc-client.test.js +145 -0
  62. package/dist/src/sdk/clients/base/create-rpc-client.test.js.map +1 -0
  63. package/dist/src/sdk/clients/create-public-client.test.js +113 -0
  64. package/dist/src/sdk/clients/create-public-client.test.js.map +1 -0
  65. package/dist/src/sdk/clients/decorators/kontor/wallet.js +13 -0
  66. package/dist/src/sdk/clients/decorators/kontor/wallet.js.map +1 -0
  67. package/dist/src/sdk/clients/decorators/public.js +9 -0
  68. package/dist/src/sdk/clients/decorators/public.js.map +1 -0
  69. package/dist/src/sdk/clients/decorators/wallet.js +9 -0
  70. package/dist/src/sdk/clients/decorators/wallet.js.map +1 -0
  71. package/dist/src/sdk/clients/kontor/create-public-client.test.js +44 -0
  72. package/dist/src/sdk/clients/kontor/create-public-client.test.js.map +1 -0
  73. package/dist/src/sdk/clients/kontor/create-wallet-client.js +14 -0
  74. package/dist/src/sdk/clients/kontor/create-wallet-client.js.map +1 -0
  75. package/dist/src/sdk/clients/transports/create-http-transport.js +25 -0
  76. package/dist/src/sdk/clients/transports/create-http-transport.js.map +1 -0
  77. package/dist/src/sdk/clients/transports/create-rpc-transport.test.js +58 -0
  78. package/dist/src/sdk/clients/transports/create-rpc-transport.test.js.map +1 -0
  79. package/dist/src/sdk/clients/transports/custom.js +14 -0
  80. package/dist/src/sdk/clients/transports/custom.js.map +1 -0
  81. package/dist/src/sdk/clients/transports/http-rpc.js +84 -0
  82. package/dist/src/sdk/clients/transports/http-rpc.js.map +1 -0
  83. package/dist/src/sdk/clients/transports/http-rpc.test.js +147 -0
  84. package/dist/src/sdk/clients/transports/http-rpc.test.js.map +1 -0
  85. package/dist/src/sdk/clients/transports/http.js +45 -0
  86. package/dist/src/sdk/clients/transports/http.js.map +1 -0
  87. package/dist/src/sdk/errors/address.js +13 -0
  88. package/dist/src/sdk/errors/address.js.map +1 -0
  89. package/dist/src/sdk/errors/base.js +92 -0
  90. package/dist/src/sdk/errors/base.js.map +1 -0
  91. package/dist/src/sdk/errors/request.js +100 -0
  92. package/dist/src/sdk/errors/request.js.map +1 -0
  93. package/dist/src/sdk/errors/rpc.js +30 -0
  94. package/dist/src/sdk/errors/rpc.js.map +1 -0
  95. package/dist/src/sdk/errors/transport.js +10 -0
  96. package/dist/src/sdk/errors/transport.js.map +1 -0
  97. package/dist/src/sdk/errors/utils.js +2 -0
  98. package/dist/src/sdk/errors/utils.js.map +1 -0
  99. package/dist/src/sdk/errors/version.js +2 -0
  100. package/dist/src/sdk/errors/version.js.map +1 -0
  101. package/dist/src/sdk/errors/wit.js +19 -0
  102. package/dist/src/sdk/errors/wit.js.map +1 -0
  103. package/dist/src/sdk/types/account.js +2 -0
  104. package/dist/src/sdk/types/account.js.map +1 -0
  105. package/dist/src/sdk/types/btc-rpc.js +2 -0
  106. package/dist/src/sdk/types/btc-rpc.js.map +1 -0
  107. package/dist/src/sdk/types/contract.test-d.js +35 -0
  108. package/dist/src/sdk/types/contract.test-d.js.map +1 -0
  109. package/dist/src/sdk/types/http-schema.test-d.js +133 -0
  110. package/dist/src/sdk/types/http-schema.test-d.js.map +1 -0
  111. package/dist/src/sdk/types/misc.js +2 -0
  112. package/dist/src/sdk/types/misc.js.map +1 -0
  113. package/dist/src/sdk/types/rpc.js +19 -0
  114. package/dist/src/sdk/types/rpc.js.map +1 -0
  115. package/dist/src/sdk/types/utils.js +2 -0
  116. package/dist/src/sdk/types/utils.js.map +1 -0
  117. package/dist/src/sdk/types/wbip001.js +3 -0
  118. package/dist/src/sdk/types/wbip001.js.map +1 -0
  119. package/dist/src/sdk/utils/build-http-request.js +55 -0
  120. package/dist/src/sdk/utils/build-http-request.js.map +1 -0
  121. package/dist/src/sdk/utils/build-request.js +35 -0
  122. package/dist/src/sdk/utils/build-request.js.map +1 -0
  123. package/dist/src/sdk/utils/build-rpc-request.js +84 -0
  124. package/dist/src/sdk/utils/build-rpc-request.js.map +1 -0
  125. package/dist/src/sdk/utils/encoding/to-hex.js +23 -0
  126. package/dist/src/sdk/utils/encoding/to-hex.js.map +1 -0
  127. package/dist/src/sdk/utils/get-action.js +27 -0
  128. package/dist/src/sdk/utils/get-action.js.map +1 -0
  129. package/dist/src/sdk/utils/http.js +137 -0
  130. package/dist/src/sdk/utils/http.js.map +1 -0
  131. package/dist/src/sdk/utils/lru.js +35 -0
  132. package/dist/src/sdk/utils/lru.js.map +1 -0
  133. package/dist/src/sdk/utils/promise/create-batch-scheduler.js +49 -0
  134. package/dist/src/sdk/utils/promise/create-batch-scheduler.js.map +1 -0
  135. package/dist/src/sdk/utils/promise/with-dedupe.js +14 -0
  136. package/dist/src/sdk/utils/promise/with-dedupe.js.map +1 -0
  137. package/dist/src/sdk/utils/promise/with-resolvers.js +10 -0
  138. package/dist/src/sdk/utils/promise/with-resolvers.js.map +1 -0
  139. package/dist/src/sdk/utils/promise/with-retry.js +25 -0
  140. package/dist/src/sdk/utils/promise/with-retry.js.map +1 -0
  141. package/dist/src/sdk/utils/promise/with-timeout.js +30 -0
  142. package/dist/src/sdk/utils/promise/with-timeout.js.map +1 -0
  143. package/dist/src/sdk/utils/rpc/http.js +86 -0
  144. package/dist/src/sdk/utils/rpc/http.js.map +1 -0
  145. package/dist/src/sdk/utils/rpc/id.js +13 -0
  146. package/dist/src/sdk/utils/rpc/id.js.map +1 -0
  147. package/dist/src/sdk/utils/stringify.js +5 -0
  148. package/dist/src/sdk/utils/stringify.js.map +1 -0
  149. package/dist/src/sdk/utils/uid.js +14 -0
  150. package/dist/src/sdk/utils/uid.js.map +1 -0
  151. package/dist/src/sdk/utils/wait.js +4 -0
  152. package/dist/src/sdk/utils/wait.js.map +1 -0
  153. package/dist/src/sdk/utils/wit/codecs/decimal.js +165 -0
  154. package/dist/src/sdk/utils/wit/codecs/decimal.js.map +1 -0
  155. package/dist/src/sdk/utils/wit/codecs/enum.js +104 -0
  156. package/dist/src/sdk/utils/wit/codecs/enum.js.map +1 -0
  157. package/dist/src/sdk/utils/wit/codecs/integer.js +167 -0
  158. package/dist/src/sdk/utils/wit/codecs/integer.js.map +1 -0
  159. package/dist/src/sdk/utils/wit/codecs/list.js +117 -0
  160. package/dist/src/sdk/utils/wit/codecs/list.js.map +1 -0
  161. package/dist/src/sdk/utils/wit/codecs/option.js +91 -0
  162. package/dist/src/sdk/utils/wit/codecs/option.js.map +1 -0
  163. package/dist/src/sdk/utils/wit/codecs/string.js +27 -0
  164. package/dist/src/sdk/utils/wit/codecs/string.js.map +1 -0
  165. package/dist/src/sdk/utils/wit/codecs/types.js +45 -0
  166. package/dist/src/sdk/utils/wit/codecs/types.js.map +1 -0
  167. package/dist/src/sdk/utils/wit/codecs/unit.js +22 -0
  168. package/dist/src/sdk/utils/wit/codecs/unit.js.map +1 -0
  169. package/dist/src/sdk/utils/wit/decode-function-result.js +36 -0
  170. package/dist/src/sdk/utils/wit/decode-function-result.js.map +1 -0
  171. package/dist/src/sdk/utils/wit/decode-wit-parameter.js +286 -0
  172. package/dist/src/sdk/utils/wit/decode-wit-parameter.js.map +1 -0
  173. package/dist/src/sdk/utils/wit/decode-wit-parameter.test.js +75 -0
  174. package/dist/src/sdk/utils/wit/decode-wit-parameter.test.js.map +1 -0
  175. package/dist/src/sdk/utils/wit/encode-function-data.js +17 -0
  176. package/dist/src/sdk/utils/wit/encode-function-data.js.map +1 -0
  177. package/dist/src/sdk/utils/wit/encode-function-data.test-d.js +21 -0
  178. package/dist/src/sdk/utils/wit/encode-function-data.test-d.js.map +1 -0
  179. package/dist/src/sdk/utils/wit/encode-function-data.test.js +91 -0
  180. package/dist/src/sdk/utils/wit/encode-function-data.test.js.map +1 -0
  181. package/dist/src/sdk/utils/wit/encode-wit-parameters.js +250 -0
  182. package/dist/src/sdk/utils/wit/encode-wit-parameters.js.map +1 -0
  183. package/dist/src/sdk/utils/wit/encode-wit-parameters.test.js +62 -0
  184. package/dist/src/sdk/utils/wit/encode-wit-parameters.test.js.map +1 -0
  185. package/dist/src/sdk/utils/wit/get-wit-item.js +15 -0
  186. package/dist/src/sdk/utils/wit/get-wit-item.js.map +1 -0
  187. package/dist/src/sdk/utils/wit/get-wit-item.test.js +118 -0
  188. package/dist/src/sdk/utils/wit/get-wit-item.test.js.map +1 -0
  189. package/dist/src/sdk/utils/wit/prepare-encode-function-data.js +24 -0
  190. package/dist/src/sdk/utils/wit/prepare-encode-function-data.js.map +1 -0
  191. package/dist/src/wit/error.js +59 -0
  192. package/dist/src/wit/error.js.map +1 -0
  193. package/dist/src/wit/narrow.js +14 -0
  194. package/dist/src/wit/narrow.js.map +1 -0
  195. package/dist/src/wit/regex.js +6 -0
  196. package/dist/src/wit/regex.js.map +1 -0
  197. package/dist/src/wit/register.js +2 -0
  198. package/dist/src/wit/register.js.map +1 -0
  199. package/dist/src/wit/type-utils.js +2 -0
  200. package/dist/src/wit/type-utils.js.map +1 -0
  201. package/dist/src/wit/utils.js +2 -0
  202. package/dist/src/wit/utils.js.map +1 -0
  203. package/dist/src/wit/utils.test-d.js +16 -0
  204. package/dist/src/wit/utils.test-d.js.map +1 -0
  205. package/dist/src/wit/version.js +2 -0
  206. package/dist/src/wit/version.js.map +1 -0
  207. package/dist/src/wit/wit-parser/core/errors/signature.js +42 -0
  208. package/dist/src/wit/wit-parser/core/errors/signature.js.map +1 -0
  209. package/dist/src/wit/wit-parser/core/errors/splitParameters.js +18 -0
  210. package/dist/src/wit/wit-parser/core/errors/splitParameters.js.map +1 -0
  211. package/dist/src/wit/wit-parser/core/errors/wit-parameter.js +29 -0
  212. package/dist/src/wit/wit-parser/core/errors/wit-parameter.js.map +1 -0
  213. package/dist/src/wit/wit-parser/core/records.js +73 -0
  214. package/dist/src/wit/wit-parser/core/records.js.map +1 -0
  215. package/dist/src/wit/wit-parser/core/records.test.js +53 -0
  216. package/dist/src/wit/wit-parser/core/records.test.js.map +1 -0
  217. package/dist/src/wit/wit-parser/core/signatures.js +32 -0
  218. package/dist/src/wit/wit-parser/core/signatures.js.map +1 -0
  219. package/dist/src/wit/wit-parser/core/signatures.test.js +54 -0
  220. package/dist/src/wit/wit-parser/core/signatures.test.js.map +1 -0
  221. package/dist/src/wit/wit-parser/core/types/records.js +2 -0
  222. package/dist/src/wit/wit-parser/core/types/records.js.map +1 -0
  223. package/dist/src/wit/wit-parser/core/types/records.test-d.js +19 -0
  224. package/dist/src/wit/wit-parser/core/types/records.test-d.js.map +1 -0
  225. package/dist/src/wit/wit-parser/core/types/signatures.js +3 -0
  226. package/dist/src/wit/wit-parser/core/types/signatures.js.map +1 -0
  227. package/dist/src/wit/wit-parser/core/types/signatures.test-d.js +18 -0
  228. package/dist/src/wit/wit-parser/core/types/signatures.test-d.js.map +1 -0
  229. package/dist/src/wit/wit-parser/core/types/utils.js +2 -0
  230. package/dist/src/wit/wit-parser/core/types/utils.js.map +1 -0
  231. package/dist/src/wit/wit-parser/core/types/utils.test-d.js +138 -0
  232. package/dist/src/wit/wit-parser/core/types/utils.test-d.js.map +1 -0
  233. package/dist/src/wit/wit-parser/core/utils.js +212 -0
  234. package/dist/src/wit/wit-parser/core/utils.js.map +1 -0
  235. package/dist/src/wit/wit-parser/core/utils.test.js +302 -0
  236. package/dist/src/wit/wit-parser/core/utils.test.js.map +1 -0
  237. package/dist/src/wit/wit-parser/parse-wit-parameter.js +26 -0
  238. package/dist/src/wit/wit-parser/parse-wit-parameter.js.map +1 -0
  239. package/dist/src/wit/wit-parser/parse-wit-parameter.test.js +77 -0
  240. package/dist/src/wit/wit-parser/parse-wit-parameter.test.js.map +1 -0
  241. package/dist/src/wit/wit-parser/parse-wit.js +16 -0
  242. package/dist/src/wit/wit-parser/parse-wit.js.map +1 -0
  243. package/dist/src/wit/wit-parser/parse-wit.test.js +78 -0
  244. package/dist/src/wit/wit-parser/parse-wit.test.js.map +1 -0
  245. package/dist/src/wit/wit.js +2 -0
  246. package/dist/src/wit/wit.js.map +1 -0
  247. package/dist/src/wit/wit.test.js +6 -0
  248. package/dist/src/wit/wit.test.js.map +1 -0
  249. package/dist/test/globalSetup.js +14 -0
  250. package/dist/test/globalSetup.js.map +1 -0
  251. package/dist/test/src/wits.js +21 -0
  252. package/dist/test/src/wits.js.map +1 -0
  253. package/dist/tsconfig.tsbuildinfo +1 -1
  254. package/dist/types/sdk/actions/kontor/public/build-compose-query.d.ts +16 -0
  255. package/dist/types/sdk/actions/kontor/public/build-compose-query.d.ts.map +1 -0
  256. package/dist/types/sdk/actions/kontor/public/build-instruction-query.d.ts +25 -0
  257. package/dist/types/sdk/actions/kontor/public/build-instruction-query.d.ts.map +1 -0
  258. package/dist/types/sdk/actions/kontor/public/call-compose.d.ts +20 -0
  259. package/dist/types/sdk/actions/kontor/public/call-compose.d.ts.map +1 -0
  260. package/dist/types/sdk/actions/kontor/public/proc-contract.d.ts +2 -2
  261. package/dist/types/sdk/actions/kontor/public/proc-contract.d.ts.map +1 -1
  262. package/dist/types/sdk/actions/kontor/wallet/sign-reveal.d.ts.map +1 -1
  263. package/dist/types/sdk/clients/decorators/kontor/public.d.ts +6 -6
  264. package/dist/types/sdk/clients/decorators/kontor/public.d.ts.map +1 -1
  265. package/dist/types/sdk/contracts/wits.d.ts +6 -5
  266. package/dist/types/sdk/contracts/wits.d.ts.map +1 -1
  267. package/dist/types/sdk/types/kontor.d.ts +15 -1
  268. package/dist/types/sdk/types/kontor.d.ts.map +1 -1
  269. package/package.json +1 -1
  270. package/src/sdk/actions/kontor/public/build-compose-query.ts +1 -1
  271. package/dist/cjs/sdk/actions/kontor/public/build-compose-call.js.map +0 -1
  272. package/dist/cjs/sdk/actions/kontor/public/build-instruction.js.map +0 -1
  273. package/dist/cjs/sdk/actions/kontor/public/call-proc.js.map +0 -1
  274. package/dist/esm/sdk/actions/kontor/public/build-compose-call.js +0 -31
  275. package/dist/esm/sdk/actions/kontor/public/build-compose-call.js.map +0 -1
  276. package/dist/esm/sdk/actions/kontor/public/build-instruction.js +0 -49
  277. package/dist/esm/sdk/actions/kontor/public/build-instruction.js.map +0 -1
  278. package/dist/esm/sdk/actions/kontor/public/call-proc.js.map +0 -1
  279. package/dist/src/sdk/actions/kontor/public/build-compose-call.js.map +0 -1
  280. package/dist/src/sdk/actions/kontor/public/build-instruction.js.map +0 -1
  281. package/dist/src/sdk/actions/kontor/public/call-proc.js +0 -43
  282. package/dist/src/sdk/actions/kontor/public/call-proc.js.map +0 -1
  283. package/dist/types/sdk/actions/kontor/public/build-compose-call.d.ts +0 -21
  284. package/dist/types/sdk/actions/kontor/public/build-compose-call.d.ts.map +0 -1
  285. package/dist/types/sdk/actions/kontor/public/build-instruction.d.ts +0 -17
  286. package/dist/types/sdk/actions/kontor/public/build-instruction.d.ts.map +0 -1
  287. package/dist/types/sdk/actions/kontor/public/call-proc.d.ts +0 -23
  288. package/dist/types/sdk/actions/kontor/public/call-proc.d.ts.map +0 -1
@@ -0,0 +1,113 @@
1
+ import { assertType, expect, test, vi } from "vitest";
2
+ import { createPublicClient } from "./create-public-client.js";
3
+ import { createRpcTransport } from "./transports/create-rpc-transport.js";
4
+ import { signet } from "../chains/definitions/signet.js";
5
+ const mockTransport = () => createRpcTransport({
6
+ key: "mock",
7
+ name: "Mock Transport",
8
+ request: vi.fn(() => null),
9
+ type: "mock",
10
+ });
11
+ test("creates", () => {
12
+ const { uid, ...client } = createPublicClient({
13
+ transport: mockTransport,
14
+ });
15
+ assertType(client.request);
16
+ expect(uid).toBeDefined();
17
+ expect(client).toMatchInlineSnapshot(`
18
+ {
19
+ "account": undefined,
20
+ "cacheTime": 4000,
21
+ "chain": undefined,
22
+ "extend": [Function],
23
+ "key": "btc-rpc",
24
+ "name": "BTC-RPC Client",
25
+ "pollingInterval": 4000,
26
+ "request": [Function],
27
+ "sendRawTransaction": [Function],
28
+ "transport": {
29
+ "key": "mock",
30
+ "methods": undefined,
31
+ "name": "Mock Transport",
32
+ "request": [MockFunction],
33
+ "retryCount": 3,
34
+ "retryDelay": 150,
35
+ "timeout": undefined,
36
+ "type": "mock",
37
+ },
38
+ "type": "btc-rpc-client",
39
+ }
40
+ `);
41
+ });
42
+ test("with chain", () => {
43
+ const { uid, ...client } = createPublicClient({
44
+ transport: mockTransport,
45
+ chain: signet,
46
+ });
47
+ assertType(client.request);
48
+ expect(uid).toBeDefined();
49
+ expect(client).toMatchInlineSnapshot(`
50
+ {
51
+ "account": undefined,
52
+ "cacheTime": 4000,
53
+ "chain": {
54
+ "blockExplorers": {
55
+ "default": {
56
+ "apiUrl": "https://mempool.space/signet/api",
57
+ "name": "mempool.space",
58
+ "url": "https://mempool.space/signet",
59
+ },
60
+ },
61
+ "blockTime": 600000,
62
+ "contracts": {
63
+ "nativeToken": {
64
+ "blockHeight": 0,
65
+ "name": "token",
66
+ "txIndex": 0,
67
+ },
68
+ },
69
+ "fees": undefined,
70
+ "formatters": undefined,
71
+ "id": 0,
72
+ "name": "signet",
73
+ "nativeCurrency": {
74
+ "decimals": 18,
75
+ "name": "Kontor",
76
+ "symbol": "KOR",
77
+ },
78
+ "serializers": undefined,
79
+ "urls": {
80
+ "default": {
81
+ "bitcoinRpc": [
82
+ "https://signet.kontor.network:38332",
83
+ ],
84
+ "http": [
85
+ "https://signet.kontor.network:35000/api",
86
+ ],
87
+ "webSocket": [
88
+ "wss://signet.kontor.network:35000/ws",
89
+ ],
90
+ },
91
+ },
92
+ },
93
+ "extend": [Function],
94
+ "key": "btc-rpc",
95
+ "name": "BTC-RPC Client",
96
+ "pollingInterval": 4000,
97
+ "request": [Function],
98
+ "sendRawTransaction": [Function],
99
+ "transport": {
100
+ "key": "mock",
101
+ "methods": undefined,
102
+ "name": "Mock Transport",
103
+ "request": [MockFunction],
104
+ "retryCount": 3,
105
+ "retryDelay": 150,
106
+ "timeout": undefined,
107
+ "type": "mock",
108
+ },
109
+ "type": "btc-rpc-client",
110
+ }
111
+ `);
112
+ });
113
+ //# sourceMappingURL=create-public-client.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-public-client.test.js","sourceRoot":"","sources":["../../../../src/sdk/clients/create-public-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD,MAAM,aAAa,GAAG,GAAG,EAAE,CACzB,kBAAkB,CAAC;IACjB,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAQ;IACjC,IAAI,EAAE,MAAM;CACb,CAAC,CAAC;AAEL,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC5C,SAAS,EAAE,aAAa;KACzB,CAAC,CAAC;IAEH,UAAU,CAA6B,MAAM,CAAC,OAAO,CAAC,CAAC;IAEvD,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAE1B,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;GAuBpC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;IACtB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC5C,SAAS,EAAE,aAAa;QACxB,KAAK,EAAE,MAAM;KACd,CAAC,CAAC;IAEH,UAAU,CAA6B,MAAM,CAAC,OAAO,CAAC,CAAC;IAEvD,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAE1B,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DrC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { getAddresses, } from "../../../actions/wallet/get-addresses.js";
2
+ import { signPsbt, } from "../../../actions/wallet/sign-psbt.js";
3
+ import { signCommit, } from "../../../actions/kontor/wallet/sign-commit.js";
4
+ import { signReveal, } from "../../../actions/kontor/wallet/sign-reveal.js";
5
+ export function walletActions(client) {
6
+ return {
7
+ getAddresses: () => getAddresses(client),
8
+ signPsbt: (params) => signPsbt(client, params),
9
+ signCommit: (params) => signCommit(client, params),
10
+ signReveal: (params) => signReveal(client, params),
11
+ };
12
+ }
13
+ //# sourceMappingURL=wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../../../../src/sdk/clients/decorators/kontor/wallet.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,YAAY,GAEb,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACL,QAAQ,GAGT,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,UAAU,GAGX,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EACL,UAAU,GAGX,MAAM,+CAA+C,CAAC;AAkBvD,MAAM,UAAU,aAAa,CAK3B,MAAqD;IAErD,OAAO;QACL,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;QACxC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAC9C,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;QAClD,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;KACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { sendRawTransaction, } from "../../actions/public/send-raw-transaction.js";
2
+ import { testMempoolAccept, } from "../../actions/public/test-mempool-accept.js";
3
+ export function publicActions(client) {
4
+ return {
5
+ sendRawTransaction: (args) => sendRawTransaction(client, args),
6
+ testMempoolAccept: (args) => testMempoolAccept(client, args),
7
+ };
8
+ }
9
+ //# sourceMappingURL=public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/decorators/public.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,kBAAkB,GACnB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAGL,iBAAiB,GAClB,MAAM,6CAA6C,CAAC;AAmBrD,MAAM,UAAU,aAAa,CAK3B,MAA+C;IAE/C,OAAO;QACL,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC;QAC9D,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;KAC7D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { getAddresses, } from "../../actions/wallet/get-addresses.js";
2
+ import { signPsbt, } from "../../actions/wallet/sign-psbt.js";
3
+ export function walletActions(client) {
4
+ return {
5
+ getAddresses: () => getAddresses(client),
6
+ signPsbt: (params) => signPsbt(client, params),
7
+ };
8
+ }
9
+ //# sourceMappingURL=wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/decorators/wallet.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,YAAY,GAEb,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,QAAQ,GAGT,MAAM,mCAAmC,CAAC;AAY3C,MAAM,UAAU,aAAa,CAK3B,MAA+C;IAE/C,OAAO;QACL,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;QACxC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { expect, test } from "vitest";
2
+ import { createPublicClient } from "./create-public-client.js";
3
+ import { http } from "../transports/http.js";
4
+ test("creates", async () => {
5
+ const { uid, ...client } = createPublicClient({
6
+ transport: http("https://signet.kontor.network:35000/api"),
7
+ });
8
+ expect(client).toMatchInlineSnapshot(`
9
+ {
10
+ "account": undefined,
11
+ "buildComposeCall": [Function],
12
+ "buildInstruction": [Function],
13
+ "cacheTime": 4000,
14
+ "callProc": [Function],
15
+ "callView": [Function],
16
+ "chain": undefined,
17
+ "extend": [Function],
18
+ "key": "kontor-http",
19
+ "name": "KONTOR-HTTP Client",
20
+ "pollingInterval": 4000,
21
+ "procContract": [Function],
22
+ "request": [Function],
23
+ "transport": {
24
+ "fetchOptions": undefined,
25
+ "key": "http",
26
+ "name": "HTTP Transport",
27
+ "request": [Function],
28
+ "retryCount": 3,
29
+ "retryDelay": 150,
30
+ "timeout": 10000,
31
+ "type": "http",
32
+ "url": "https://signet.kontor.network:35000/api",
33
+ },
34
+ "type": "kontor-http-client",
35
+ "viewContract": [Function],
36
+ }
37
+ `);
38
+ const x = await client.callView({
39
+ contractAddress: "token_0_0",
40
+ wave: "balances()",
41
+ });
42
+ console.log({ x });
43
+ });
44
+ //# sourceMappingURL=create-public-client.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-public-client.test.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/kontor/create-public-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACzB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC5C,SAAS,EAAE,IAAI,CAAC,yCAAyC,CAAC;KAC3D,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BpC,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;QAC9B,eAAe,EAAE,WAAW;QAC5B,IAAI,EAAE,YAAY;KACnB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { createRpcClient, } from "../base/create-rpc-client.js";
2
+ import { walletActions, } from "../decorators/kontor/wallet.js";
3
+ export function createWalletClient(parameters) {
4
+ const { key = "btc-rpc", name = "BTC-RPC Client" } = parameters;
5
+ const client = createRpcClient({
6
+ ...parameters,
7
+ key,
8
+ name,
9
+ type: "btcRpcClient",
10
+ });
11
+ // TODO: fix any if possible
12
+ return client.extend(walletActions);
13
+ }
14
+ //# sourceMappingURL=create-wallet-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-wallet-client.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/kontor/create-wallet-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,eAAe,GAChB,MAAM,8BAA8B,CAAC;AAStC,OAAO,EACL,aAAa,GAEd,MAAM,gCAAgC,CAAC;AA6CxC,MAAM,UAAU,kBAAkB,CAShC,UAKC;IAOD,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,IAAI,GAAG,gBAAgB,EAAE,GAAG,UAAU,CAAC;IAChE,MAAM,MAAM,GAAG,eAAe,CAAC;QAC7B,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,cAAc;KACrB,CAAQ,CAAC;IAEV,4BAA4B;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,CAKjC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { uid as uid_ } from "../../utils/uid.js";
2
+ import { buildHttpRequest } from "../../utils/build-http-request.js";
3
+ export function createHttpTransport({ key, name, request, retryCount = 3, retryDelay = 150, timeout, type, }, value) {
4
+ const uid = uid_();
5
+ const wrappedRequest = buildHttpRequest(request, {
6
+ retryCount,
7
+ retryDelay,
8
+ uid,
9
+ });
10
+ return {
11
+ config: {
12
+ key,
13
+ name,
14
+ request,
15
+ retryCount,
16
+ retryDelay,
17
+ timeout,
18
+ type,
19
+ },
20
+ // Note: the *wrapped* one is exposed here.
21
+ request: wrappedRequest,
22
+ value,
23
+ };
24
+ }
25
+ //# sourceMappingURL=create-http-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-http-transport.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/transports/create-http-transport.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAyCrE,MAAM,UAAU,mBAAmB,CAKjC,EACE,GAAG,EACH,IAAI,EACJ,OAAO,EACP,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,GAAG,EAChB,OAAO,EACP,IAAI,GACiC,EACvC,KAAiC;IAEjC,MAAM,GAAG,GAAG,IAAI,EAAE,CAAC;IAEnB,MAAM,cAAc,GAAG,gBAAgB,CAAC,OAAO,EAAE;QAC/C,UAAU;QACV,UAAU;QACV,GAAG;KACJ,CAAC,CAAC;IAEH,OAAO;QACL,MAAM,EAAE;YACN,GAAG;YACH,IAAI;YACJ,OAAO;YACP,UAAU;YACV,UAAU;YACV,OAAO;YACP,IAAI;SACL;QACD,2CAA2C;QAC3C,OAAO,EAAE,cAA2B;QACpC,KAAK;KACN,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { assertType, expect, test, vi } from "vitest";
2
+ import { createRpcTransport } from "./create-rpc-transport.js";
3
+ test("default", () => {
4
+ const transport = createRpcTransport({
5
+ key: "mock",
6
+ name: "Mock Transport",
7
+ request: vi.fn(async () => null),
8
+ type: "mock",
9
+ });
10
+ assertType(transport.config.type);
11
+ expect(transport).toMatchInlineSnapshot(`
12
+ {
13
+ "config": {
14
+ "key": "mock",
15
+ "methods": undefined,
16
+ "name": "Mock Transport",
17
+ "request": [MockFunction],
18
+ "retryCount": 3,
19
+ "retryDelay": 150,
20
+ "timeout": undefined,
21
+ "type": "mock",
22
+ },
23
+ "request": [Function],
24
+ "value": undefined,
25
+ }
26
+ `);
27
+ });
28
+ test("value", () => {
29
+ const transport = createRpcTransport({
30
+ key: "mock",
31
+ name: "Mock Transport",
32
+ request: vi.fn(async () => null),
33
+ type: "mock",
34
+ }, {
35
+ foo: "bar",
36
+ baz: "foo",
37
+ });
38
+ expect(transport).toMatchInlineSnapshot(`
39
+ {
40
+ "config": {
41
+ "key": "mock",
42
+ "methods": undefined,
43
+ "name": "Mock Transport",
44
+ "request": [MockFunction],
45
+ "retryCount": 3,
46
+ "retryDelay": 150,
47
+ "timeout": undefined,
48
+ "type": "mock",
49
+ },
50
+ "request": [Function],
51
+ "value": {
52
+ "baz": "foo",
53
+ "foo": "bar",
54
+ },
55
+ }
56
+ `);
57
+ });
58
+ //# sourceMappingURL=create-rpc-transport.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-rpc-transport.test.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/transports/create-rpc-transport.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,SAAS,GAAG,kBAAkB,CAAC;QACnC,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAuC;QACtE,IAAI,EAAE,MAAM;KACb,CAAC,CAAC;IAEH,UAAU,CAAS,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE1C,MAAM,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;GAevC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;IACjB,MAAM,SAAS,GAAG,kBAAkB,CAClC;QACE,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAuC;QACtE,IAAI,EAAE,MAAM;KACb,EACD;QACE,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;KACX,CACF,CAAC;IAEF,MAAM,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;GAkBvC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { createRpcTransport, } from "./create-rpc-transport.js";
2
+ export function custom(provider, config = {}) {
3
+ const { key = "custom", methods, name = "Custom Provider", retryDelay, } = config;
4
+ return ({ retryCount: defaultRetryCount }) => createRpcTransport({
5
+ key,
6
+ methods,
7
+ name,
8
+ request: provider.request.bind(provider),
9
+ retryCount: config.retryCount ?? defaultRetryCount,
10
+ retryDelay,
11
+ type: "custom",
12
+ });
13
+ }
14
+ //# sourceMappingURL=custom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/transports/custom.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,kBAAkB,GAGnB,MAAM,2BAA2B,CAAC;AA0BnC,MAAM,UAAU,MAAM,CACpB,QAAkB,EAClB,SAAgC,EAAE;IAElC,MAAM,EACJ,GAAG,GAAG,QAAQ,EACd,OAAO,EACP,IAAI,GAAG,iBAAiB,EACxB,UAAU,GACX,GAAG,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAC3C,kBAAkB,CAAC;QACjB,GAAG;QACH,OAAO;QACP,IAAI;QACJ,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QACxC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,iBAAiB;QAClD,UAAU;QACV,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { RpcRequestError } from "../../errors/request.js";
2
+ import { UrlRequiredError, } from "../../errors/transport.js";
3
+ // import { createBatchScheduler } from '../../utils/promise/createBatchScheduler.js'
4
+ import { getHttpRpcClient, } from "../../utils/rpc/http.js";
5
+ import { createRpcTransport, } from "./create-rpc-transport.js";
6
+ /**
7
+ * @description Creates a HTTP transport that connects to a JSON-RPC API.
8
+ */
9
+ export function httpRpc(
10
+ /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
11
+ url, config = {}) {
12
+ const {
13
+ // batch,
14
+ fetchFn, fetchOptions, key = "http", methods, name = "HTTP JSON-RPC", onFetchRequest, onFetchResponse, retryDelay,
15
+ // raw,
16
+ } = config;
17
+ return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
18
+ // const { batchSize = 1000, wait = 0 } =
19
+ // typeof batch === "object" ? batch : {};
20
+ const retryCount = config.retryCount ?? retryCount_;
21
+ const timeout = timeout_ ?? config.timeout ?? 10_000;
22
+ const url_ = url || chain?.urls.default.bitcoinRpc[0];
23
+ if (!url_)
24
+ throw new UrlRequiredError();
25
+ const rpcClient = getHttpRpcClient(url_, {
26
+ fetchFn,
27
+ fetchOptions,
28
+ onRequest: onFetchRequest,
29
+ onResponse: onFetchResponse,
30
+ timeout,
31
+ });
32
+ return createRpcTransport({
33
+ key,
34
+ methods,
35
+ name,
36
+ async request({ method, params }) {
37
+ const body = { method, params };
38
+ // const { schedule } = createBatchScheduler({
39
+ // id: url_,
40
+ // wait,
41
+ // shouldSplitBatch(requests) {
42
+ // return requests.length > batchSize;
43
+ // },
44
+ // fn: (body: RpcRequest[]) =>
45
+ // rpcClient.request({
46
+ // body,
47
+ // }),
48
+ // sort: (a, b) => a.id - b.id,
49
+ // });
50
+ //
51
+ // const fn = async (body: RpcRequest) =>
52
+ // batch
53
+ // ? schedule(body)
54
+ // : [
55
+ // [
56
+ // await rpcClient.request({
57
+ // body,
58
+ // }),
59
+ // ];
60
+ // TODO: implement batching
61
+ const fn = async (body) => await rpcClient.request({
62
+ body,
63
+ });
64
+ const { error, result } = await fn(body);
65
+ // if (raw) return { error, result };
66
+ if (error)
67
+ throw new RpcRequestError({
68
+ body,
69
+ error,
70
+ url: url_,
71
+ });
72
+ return result;
73
+ },
74
+ retryCount,
75
+ retryDelay,
76
+ timeout,
77
+ type: "http-rpc",
78
+ }, {
79
+ fetchOptions,
80
+ url: url_,
81
+ });
82
+ };
83
+ }
84
+ //# sourceMappingURL=http-rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-rpc.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/transports/http-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,gBAAgB,GAEjB,MAAM,2BAA2B,CAAC;AAInC,qFAAqF;AACrF,OAAO,EACL,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,kBAAkB,GAGnB,MAAM,2BAA2B,CAAC;AAiEnC;;GAEG;AACH,MAAM,UAAU,OAAO;AAIrB,uEAAuE;AACvE,GAAwB,EACxB,SAA4C,EAAE;IAE9C,MAAM;IACJ,SAAS;IACT,OAAO,EACP,YAAY,EACZ,GAAG,GAAG,MAAM,EACZ,OAAO,EACP,IAAI,GAAG,eAAe,EACtB,cAAc,EACd,eAAe,EACf,UAAU;IACV,OAAO;MACR,GAAG,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC/D,yCAAyC;QACzC,4CAA4C;QAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,WAAW,CAAC;QACpD,MAAM,OAAO,GAAG,QAAQ,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC;QACrD,MAAM,IAAI,GAAG,GAAG,IAAI,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,gBAAgB,EAAE,CAAC;QAExC,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,EAAE;YACvC,OAAO;YACP,YAAY;YACZ,SAAS,EAAE,cAAc;YACzB,UAAU,EAAE,eAAe;YAC3B,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,kBAAkB,CACvB;YACE,GAAG;YACH,OAAO;YACP,IAAI;YACJ,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;gBAC9B,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEhC,8CAA8C;gBAC9C,cAAc;gBACd,UAAU;gBACV,iCAAiC;gBACjC,0CAA0C;gBAC1C,OAAO;gBACP,gCAAgC;gBAChC,0BAA0B;gBAC1B,cAAc;gBACd,UAAU;gBACV,iCAAiC;gBACjC,MAAM;gBACN,EAAE;gBACF,yCAAyC;gBACzC,QAAQ;gBACR,qBAAqB;gBACrB,QAAQ;gBACR,IAAI;gBACJ,8BAA8B;gBAC9B,YAAY;gBACZ,QAAQ;gBACR,KAAK;gBAEL,2BAA2B;gBAC3B,MAAM,EAAE,GAAG,KAAK,EAAE,IAAgB,EAAE,EAAE,CACpC,MAAM,SAAS,CAAC,OAAO,CAAC;oBACtB,IAAI;iBACL,CAAC,CAAC;gBAEL,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;gBAEzC,qCAAqC;gBACrC,IAAI,KAAK;oBACP,MAAM,IAAI,eAAe,CAAC;wBACxB,IAAI;wBACJ,KAAK;wBACL,GAAG,EAAE,IAAI;qBACV,CAAC,CAAC;gBACL,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,UAAU;YACV,UAAU;YACV,OAAO;YACP,IAAI,EAAE,UAAU;SACjB,EACD;YACE,YAAY;YACZ,GAAG,EAAE,IAAI;SACV,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,147 @@
1
+ import { assertType, describe, expect, test } from "vitest";
2
+ import { httpRpc } from "./http-rpc.js";
3
+ import { signet } from "../../chains/definitions/signet.js";
4
+ test("default", () => {
5
+ const transport = httpRpc("https://mockapi.com/rpc");
6
+ assertType(transport);
7
+ assertType(transport({}).config.type);
8
+ expect(transport({})).toMatchInlineSnapshot(`
9
+ {
10
+ "config": {
11
+ "key": "http",
12
+ "methods": undefined,
13
+ "name": "HTTP JSON-RPC",
14
+ "request": [Function],
15
+ "retryCount": 3,
16
+ "retryDelay": 150,
17
+ "timeout": 10000,
18
+ "type": "http-rpc",
19
+ },
20
+ "request": [Function],
21
+ "value": {
22
+ "fetchOptions": undefined,
23
+ "url": "https://mockapi.com/rpc",
24
+ },
25
+ }
26
+ `);
27
+ });
28
+ describe("config", () => {
29
+ test("key", () => {
30
+ const transport = httpRpc("https://mockapi.com/rpc", {
31
+ key: "mock",
32
+ })({});
33
+ expect(transport).toMatchInlineSnapshot(`
34
+ {
35
+ "config": {
36
+ "key": "mock",
37
+ "methods": undefined,
38
+ "name": "HTTP JSON-RPC",
39
+ "request": [Function],
40
+ "retryCount": 3,
41
+ "retryDelay": 150,
42
+ "timeout": 10000,
43
+ "type": "http-rpc",
44
+ },
45
+ "request": [Function],
46
+ "value": {
47
+ "fetchOptions": undefined,
48
+ "url": "https://mockapi.com/rpc",
49
+ },
50
+ }
51
+ `);
52
+ });
53
+ test("name", () => {
54
+ const transport = httpRpc("https://mockapi.com/rpc", {
55
+ name: "Mock Transport",
56
+ })({});
57
+ expect(transport).toMatchInlineSnapshot(`
58
+ {
59
+ "config": {
60
+ "key": "http",
61
+ "methods": undefined,
62
+ "name": "Mock Transport",
63
+ "request": [Function],
64
+ "retryCount": 3,
65
+ "retryDelay": 150,
66
+ "timeout": 10000,
67
+ "type": "http-rpc",
68
+ },
69
+ "request": [Function],
70
+ "value": {
71
+ "fetchOptions": undefined,
72
+ "url": "https://mockapi.com/rpc",
73
+ },
74
+ }
75
+ `);
76
+ });
77
+ test("url", () => {
78
+ const transport = httpRpc("https://mockapi.com/rpc")({});
79
+ expect(transport).toMatchInlineSnapshot(`
80
+ {
81
+ "config": {
82
+ "key": "http",
83
+ "methods": undefined,
84
+ "name": "HTTP JSON-RPC",
85
+ "request": [Function],
86
+ "retryCount": 3,
87
+ "retryDelay": 150,
88
+ "timeout": 10000,
89
+ "type": "http-rpc",
90
+ },
91
+ "request": [Function],
92
+ "value": {
93
+ "fetchOptions": undefined,
94
+ "url": "https://mockapi.com/rpc",
95
+ },
96
+ }
97
+ `);
98
+ });
99
+ test("fetchOptions", () => {
100
+ const transport = httpRpc("https://mockapi.com/rpc", {
101
+ fetchOptions: { headers: { Authorization: "wagmi" } },
102
+ })({});
103
+ expect(transport).toMatchInlineSnapshot(`
104
+ {
105
+ "config": {
106
+ "key": "http",
107
+ "methods": undefined,
108
+ "name": "HTTP JSON-RPC",
109
+ "request": [Function],
110
+ "retryCount": 3,
111
+ "retryDelay": 150,
112
+ "timeout": 10000,
113
+ "type": "http-rpc",
114
+ },
115
+ "request": [Function],
116
+ "value": {
117
+ "fetchOptions": {
118
+ "headers": {
119
+ "Authorization": "wagmi",
120
+ },
121
+ },
122
+ "url": "https://mockapi.com/rpc",
123
+ },
124
+ }
125
+ `);
126
+ });
127
+ });
128
+ describe("request", () => {
129
+ test("default", async () => {
130
+ const transport = httpRpc(undefined, {
131
+ key: "jsonRpc",
132
+ name: "JSON RPC",
133
+ fetchOptions: {
134
+ headers: {
135
+ Authorization: `Basic ${Buffer.from("rpc:rpc").toString("base64")}`,
136
+ },
137
+ },
138
+ })({
139
+ // TODO: probably a better idea to make calls against a local instance here
140
+ chain: {
141
+ ...signet,
142
+ },
143
+ });
144
+ expect(await transport.request({ method: "getblockchaininfo" })).toBeDefined();
145
+ });
146
+ });
147
+ //# sourceMappingURL=http-rpc.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-rpc.test.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/transports/http-rpc.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAyB,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,SAAS,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAErD,UAAU,CAAmB,SAAS,CAAC,CAAC;IACxC,UAAU,CAAa,SAAS,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAElD,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;GAkB3C,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;QACf,MAAM,SAAS,GAAG,OAAO,CAAC,yBAAyB,EAAE;YACnD,GAAG,EAAE,MAAM;SACZ,CAAC,CAAC,EAAE,CAAC,CAAC;QAEP,MAAM,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;KAkBvC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;QAChB,MAAM,SAAS,GAAG,OAAO,CAAC,yBAAyB,EAAE;YACnD,IAAI,EAAE,gBAAgB;SACvB,CAAC,CAAC,EAAE,CAAC,CAAC;QAEP,MAAM,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;KAkBvC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;QACf,MAAM,SAAS,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,EAAE,CAAC,CAAC;QAEzD,MAAM,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;KAkBvC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QACxB,MAAM,SAAS,GAAG,OAAO,CAAC,yBAAyB,EAAE;YACnD,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE;SACtD,CAAC,CAAC,EAAE,CAAC,CAAC;QAEP,MAAM,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;KAsBvC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACzB,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE;YACnC,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,UAAU;YAChB,YAAY,EAAE;gBACZ,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;iBACpE;aACF;SACF,CAAC,CAAC;YACD,2EAA2E;YAC3E,KAAK,EAAE;gBACL,GAAG,MAAM;aACV;SACF,CAAC,CAAC;QAEH,MAAM,CACJ,MAAM,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CACzD,CAAC,WAAW,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { UrlRequiredError, } from "../../errors/transport.js";
2
+ import { getHttpClient } from "../../utils/http.js";
3
+ import { createHttpTransport, } from "./create-http-transport.js";
4
+ export function http(url, config = {}) {
5
+ const { fetchFn, fetchOptions, key = "http", name = "HTTP Transport", onFetchRequest, onFetchResponse, retryDelay, } = config;
6
+ return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
7
+ const retryCount = config.retryCount ?? retryCount_;
8
+ const timeout = timeout_ ?? config.timeout ?? 10_000;
9
+ const url_ = url || chain?.urls.default.http[0];
10
+ if (!url_)
11
+ throw new UrlRequiredError();
12
+ console.log(url_);
13
+ const httpClient = getHttpClient(url_, {
14
+ fetchFn,
15
+ fetchOptions,
16
+ onRequest: onFetchRequest,
17
+ onResponse: onFetchResponse,
18
+ timeout,
19
+ });
20
+ return createHttpTransport({
21
+ key,
22
+ name,
23
+ async request({ route, method, path, query, body }) {
24
+ // TODO: unify BodyParams with other body type
25
+ const fn = async (route, method, body, path, query) => await httpClient.request({
26
+ route,
27
+ method,
28
+ body,
29
+ path,
30
+ query,
31
+ });
32
+ const result = await fn(route, method, body, path, query);
33
+ return result;
34
+ },
35
+ retryCount,
36
+ retryDelay,
37
+ timeout,
38
+ type: "http",
39
+ }, {
40
+ fetchOptions,
41
+ url: url_,
42
+ });
43
+ };
44
+ }
45
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/transports/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,aAAa,EAA0B,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAIL,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAkDpC,MAAM,UAAU,IAAI,CAClB,GAAwB,EACxB,SAA0C,EAAE;IAE5C,MAAM,EACJ,OAAO,EACP,YAAY,EACZ,GAAG,GAAG,MAAM,EACZ,IAAI,GAAG,gBAAgB,EACvB,cAAc,EACd,eAAe,EACf,UAAU,GACX,GAAG,MAAM,CAAC;IAEX,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC/D,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,WAAW,CAAC;QACpD,MAAM,OAAO,GAAG,QAAQ,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC;QACrD,MAAM,IAAI,GAAG,GAAG,IAAI,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,gBAAgB,EAAE,CAAC;QAExC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAElB,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,EAAE;YACrC,OAAO;YACP,YAAY;YACZ,SAAS,EAAE,cAAc;YACzB,UAAU,EAAE,eAAe;YAC3B,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,mBAAmB,CACxB;YACE,GAAG;YACH,IAAI;YACJ,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;gBAChD,8CAA8C;gBAC9C,MAAM,EAAE,GAAG,KAAK,EACd,KAAU,EACV,MAAW,EACX,IAAS,EACT,IAAS,EACT,KAAU,EACV,EAAE,CACF,MAAM,UAAU,CAAC,OAAO,CAAC;oBACvB,KAAK;oBACL,MAAM;oBACN,IAAI;oBACJ,IAAI;oBACJ,KAAK;iBACN,CAAC,CAAC;gBAEL,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;gBAE1D,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,UAAU;YACV,UAAU;YACV,OAAO;YACP,IAAI,EAAE,MAAe;SACtB,EACD;YACE,YAAY;YACZ,GAAG,EAAE,IAAI;SACV,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { BaseError } from "./base.js";
2
+ export class InvalidAddressError extends BaseError {
3
+ constructor({ address }) {
4
+ super(`Address "${address}" is invalid.`, {
5
+ metaMessages: [
6
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
7
+ "- Address must match its checksum counterpart.",
8
+ ],
9
+ name: "InvalidAddressError",
10
+ });
11
+ }
12
+ }
13
+ //# sourceMappingURL=address.js.map