@gnolang/tm2-js-client 1.3.3 → 2.0.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 (316) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.cjs +12 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.mjs +12 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.cjs +14 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.mjs +14 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.cjs +9 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.mjs +9 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.cjs +16 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.mjs +11 -0
  10. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  11. package/dist/index.cjs +92 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.cts +23 -0
  14. package/dist/index.d.cts.map +1 -0
  15. package/dist/index.d.mts +23 -0
  16. package/dist/index.d.mts.map +1 -0
  17. package/dist/index.mjs +22 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/proto/google/protobuf/any.cjs +84 -0
  20. package/dist/proto/google/protobuf/any.cjs.map +1 -0
  21. package/dist/proto/google/protobuf/any.d.cts +141 -0
  22. package/dist/proto/google/protobuf/any.d.cts.map +1 -0
  23. package/dist/proto/google/protobuf/any.d.mts +141 -0
  24. package/dist/proto/google/protobuf/any.d.mts.map +1 -0
  25. package/dist/proto/google/protobuf/any.mjs +83 -0
  26. package/dist/proto/google/protobuf/any.mjs.map +1 -0
  27. package/dist/proto/index.cjs +2 -0
  28. package/dist/proto/index.d.cts +2 -0
  29. package/dist/proto/index.d.mts +2 -0
  30. package/dist/proto/index.mjs +3 -0
  31. package/dist/proto/tm2/abci.cjs +182 -0
  32. package/dist/proto/tm2/abci.cjs.map +1 -0
  33. package/dist/proto/tm2/abci.d.cts +33 -0
  34. package/dist/proto/tm2/abci.d.cts.map +1 -0
  35. package/dist/proto/tm2/abci.d.mts +33 -0
  36. package/dist/proto/tm2/abci.d.mts.map +1 -0
  37. package/dist/proto/tm2/abci.mjs +181 -0
  38. package/dist/proto/tm2/abci.mjs.map +1 -0
  39. package/dist/proto/tm2/tx.cjs +263 -0
  40. package/dist/proto/tm2/tx.cjs.map +1 -0
  41. package/dist/proto/tm2/tx.d.cts +49 -0
  42. package/dist/proto/tm2/tx.d.cts.map +1 -0
  43. package/dist/proto/tm2/tx.d.mts +49 -0
  44. package/dist/proto/tm2/tx.d.mts.map +1 -0
  45. package/dist/proto/tm2/tx.mjs +258 -0
  46. package/dist/proto/tm2/tx.mjs.map +1 -0
  47. package/dist/provider/endpoints.cjs +43 -0
  48. package/dist/provider/endpoints.cjs.map +1 -0
  49. package/dist/provider/endpoints.d.cts +33 -0
  50. package/dist/provider/endpoints.d.cts.map +1 -0
  51. package/dist/provider/endpoints.d.mts +33 -0
  52. package/dist/provider/endpoints.d.mts.map +1 -0
  53. package/dist/provider/endpoints.mjs +39 -0
  54. package/dist/provider/endpoints.mjs.map +1 -0
  55. package/dist/provider/errors/errors.cjs +122 -0
  56. package/dist/provider/errors/errors.cjs.map +1 -0
  57. package/dist/provider/errors/errors.d.cts +62 -0
  58. package/dist/provider/errors/errors.d.cts.map +1 -0
  59. package/dist/provider/errors/errors.d.mts +62 -0
  60. package/dist/provider/errors/errors.d.mts.map +1 -0
  61. package/dist/provider/errors/errors.mjs +104 -0
  62. package/dist/provider/errors/errors.mjs.map +1 -0
  63. package/dist/provider/errors/messages.cjs +40 -0
  64. package/dist/provider/errors/messages.cjs.map +1 -0
  65. package/dist/provider/errors/messages.mjs +23 -0
  66. package/dist/provider/errors/messages.mjs.map +1 -0
  67. package/dist/provider/index.cjs +12 -0
  68. package/dist/provider/index.d.cts +11 -0
  69. package/dist/provider/index.d.mts +11 -0
  70. package/dist/provider/index.mjs +13 -0
  71. package/dist/provider/jsonrpc/index.cjs +1 -0
  72. package/dist/provider/jsonrpc/index.d.cts +1 -0
  73. package/dist/provider/jsonrpc/index.d.mts +1 -0
  74. package/dist/provider/jsonrpc/index.mjs +2 -0
  75. package/dist/provider/jsonrpc/jsonrpc.cjs +20 -0
  76. package/dist/provider/jsonrpc/jsonrpc.cjs.map +1 -0
  77. package/dist/provider/jsonrpc/jsonrpc.d.cts +16 -0
  78. package/dist/provider/jsonrpc/jsonrpc.d.cts.map +1 -0
  79. package/dist/provider/jsonrpc/jsonrpc.d.mts +16 -0
  80. package/dist/provider/jsonrpc/jsonrpc.d.mts.map +1 -0
  81. package/dist/provider/jsonrpc/jsonrpc.mjs +19 -0
  82. package/dist/provider/jsonrpc/jsonrpc.mjs.map +1 -0
  83. package/dist/provider/provider.cjs +130 -0
  84. package/dist/provider/provider.cjs.map +1 -0
  85. package/dist/provider/provider.d.cts +130 -0
  86. package/dist/provider/provider.d.cts.map +1 -0
  87. package/dist/provider/provider.d.mts +130 -0
  88. package/dist/provider/provider.d.mts.map +1 -0
  89. package/dist/provider/provider.mjs +130 -0
  90. package/dist/provider/provider.mjs.map +1 -0
  91. package/dist/provider/types/abci.cjs +6 -0
  92. package/dist/provider/types/abci.cjs.map +1 -0
  93. package/dist/provider/types/abci.d.cts +42 -0
  94. package/dist/provider/types/abci.d.cts.map +1 -0
  95. package/dist/provider/types/abci.d.mts +42 -0
  96. package/dist/provider/types/abci.d.mts.map +1 -0
  97. package/dist/provider/types/abci.mjs +6 -0
  98. package/dist/provider/types/abci.mjs.map +1 -0
  99. package/dist/provider/types/common.d.cts +186 -0
  100. package/dist/provider/types/common.d.cts.map +1 -0
  101. package/dist/provider/types/common.d.mts +186 -0
  102. package/dist/provider/types/common.d.mts.map +1 -0
  103. package/dist/provider/types/jsonrpc.d.cts +30 -0
  104. package/dist/provider/types/jsonrpc.d.cts.map +1 -0
  105. package/dist/provider/types/jsonrpc.d.mts +30 -0
  106. package/dist/provider/types/jsonrpc.d.mts.map +1 -0
  107. package/dist/provider/utility/adapters.cjs +241 -0
  108. package/dist/provider/utility/adapters.cjs.map +1 -0
  109. package/dist/provider/utility/adapters.d.cts +19 -0
  110. package/dist/provider/utility/adapters.d.cts.map +1 -0
  111. package/dist/provider/utility/adapters.d.mts +19 -0
  112. package/dist/provider/utility/adapters.d.mts.map +1 -0
  113. package/dist/provider/utility/adapters.mjs +231 -0
  114. package/dist/provider/utility/adapters.mjs.map +1 -0
  115. package/dist/provider/utility/errors.utility.cjs +38 -0
  116. package/dist/provider/utility/errors.utility.cjs.map +1 -0
  117. package/dist/provider/utility/errors.utility.mjs +38 -0
  118. package/dist/provider/utility/errors.utility.mjs.map +1 -0
  119. package/dist/provider/utility/index.cjs +3 -0
  120. package/dist/provider/utility/index.d.cts +3 -0
  121. package/dist/provider/utility/index.d.mts +3 -0
  122. package/dist/provider/utility/index.mjs +4 -0
  123. package/dist/provider/utility/provider.utility.cjs +122 -0
  124. package/dist/provider/utility/provider.utility.cjs.map +1 -0
  125. package/{bin/provider/utility/provider.utility.d.ts → dist/provider/utility/provider.utility.d.cts} +15 -10
  126. package/dist/provider/utility/provider.utility.d.cts.map +1 -0
  127. package/dist/provider/utility/provider.utility.d.mts +45 -0
  128. package/dist/provider/utility/provider.utility.d.mts.map +1 -0
  129. package/dist/provider/utility/provider.utility.mjs +116 -0
  130. package/dist/provider/utility/provider.utility.mjs.map +1 -0
  131. package/dist/provider/utility/requests.utility.cjs +75 -0
  132. package/dist/provider/utility/requests.utility.cjs.map +1 -0
  133. package/dist/provider/utility/requests.utility.d.cts +40 -0
  134. package/dist/provider/utility/requests.utility.d.cts.map +1 -0
  135. package/dist/provider/utility/requests.utility.d.mts +40 -0
  136. package/dist/provider/utility/requests.utility.d.mts.map +1 -0
  137. package/dist/provider/utility/requests.utility.mjs +68 -0
  138. package/dist/provider/utility/requests.utility.mjs.map +1 -0
  139. package/dist/provider/websocket/index.cjs +1 -0
  140. package/dist/provider/websocket/index.d.cts +1 -0
  141. package/dist/provider/websocket/index.d.mts +1 -0
  142. package/dist/provider/websocket/index.mjs +2 -0
  143. package/dist/provider/websocket/ws.cjs +27 -0
  144. package/dist/provider/websocket/ws.cjs.map +1 -0
  145. package/dist/provider/websocket/ws.d.cts +21 -0
  146. package/dist/provider/websocket/ws.d.cts.map +1 -0
  147. package/dist/provider/websocket/ws.d.mts +21 -0
  148. package/dist/provider/websocket/ws.d.mts.map +1 -0
  149. package/dist/provider/websocket/ws.mjs +26 -0
  150. package/dist/provider/websocket/ws.mjs.map +1 -0
  151. package/dist/services/index.cjs +1 -0
  152. package/dist/services/index.d.cts +2 -0
  153. package/dist/services/index.d.mts +2 -0
  154. package/dist/services/index.mjs +2 -0
  155. package/dist/services/rest/restService.cjs +16 -0
  156. package/dist/services/rest/restService.cjs.map +1 -0
  157. package/dist/services/rest/restService.d.cts +9 -0
  158. package/dist/services/rest/restService.d.cts.map +1 -0
  159. package/dist/services/rest/restService.d.mts +9 -0
  160. package/dist/services/rest/restService.d.mts.map +1 -0
  161. package/dist/services/rest/restService.mjs +14 -0
  162. package/dist/services/rest/restService.mjs.map +1 -0
  163. package/dist/services/rest/restService.types.d.cts +11 -0
  164. package/dist/services/rest/restService.types.d.cts.map +1 -0
  165. package/dist/services/rest/restService.types.d.mts +11 -0
  166. package/dist/services/rest/restService.types.d.mts.map +1 -0
  167. package/dist/wallet/index.cjs +8 -0
  168. package/dist/wallet/index.d.cts +7 -0
  169. package/dist/wallet/index.d.mts +7 -0
  170. package/dist/wallet/index.mjs +9 -0
  171. package/dist/wallet/key/index.cjs +1 -0
  172. package/dist/wallet/key/index.mjs +2 -0
  173. package/dist/wallet/key/key.cjs +46 -0
  174. package/dist/wallet/key/key.cjs.map +1 -0
  175. package/dist/wallet/key/key.d.cts +26 -0
  176. package/dist/wallet/key/key.d.cts.map +1 -0
  177. package/dist/wallet/key/key.d.mts +26 -0
  178. package/dist/wallet/key/key.d.mts.map +1 -0
  179. package/dist/wallet/key/key.mjs +45 -0
  180. package/dist/wallet/key/key.mjs.map +1 -0
  181. package/dist/wallet/ledger/index.cjs +1 -0
  182. package/dist/wallet/ledger/index.d.cts +1 -0
  183. package/dist/wallet/ledger/index.d.mts +1 -0
  184. package/dist/wallet/ledger/index.mjs +2 -0
  185. package/dist/wallet/ledger/ledger.cjs +49 -0
  186. package/dist/wallet/ledger/ledger.cjs.map +1 -0
  187. package/dist/wallet/ledger/ledger.d.cts +27 -0
  188. package/dist/wallet/ledger/ledger.d.cts.map +1 -0
  189. package/dist/wallet/ledger/ledger.d.mts +27 -0
  190. package/dist/wallet/ledger/ledger.d.mts.map +1 -0
  191. package/dist/wallet/ledger/ledger.mjs +48 -0
  192. package/dist/wallet/ledger/ledger.mjs.map +1 -0
  193. package/dist/wallet/signer.d.cts +33 -0
  194. package/dist/wallet/signer.d.cts.map +1 -0
  195. package/dist/wallet/signer.d.mts +33 -0
  196. package/dist/wallet/signer.d.mts.map +1 -0
  197. package/dist/wallet/types/sign.cjs +6 -0
  198. package/dist/wallet/types/sign.cjs.map +1 -0
  199. package/dist/wallet/types/sign.d.cts +20 -0
  200. package/dist/wallet/types/sign.d.cts.map +1 -0
  201. package/dist/wallet/types/sign.d.mts +20 -0
  202. package/dist/wallet/types/sign.d.mts.map +1 -0
  203. package/dist/wallet/types/sign.mjs +6 -0
  204. package/dist/wallet/types/sign.mjs.map +1 -0
  205. package/dist/wallet/types/wallet.d.cts +9 -0
  206. package/dist/wallet/types/wallet.d.cts.map +1 -0
  207. package/dist/wallet/types/wallet.d.mts +9 -0
  208. package/dist/wallet/types/wallet.d.mts.map +1 -0
  209. package/dist/wallet/utility/index.cjs +1 -0
  210. package/dist/wallet/utility/index.d.cts +1 -0
  211. package/dist/wallet/utility/index.d.mts +1 -0
  212. package/dist/wallet/utility/index.mjs +2 -0
  213. package/dist/wallet/utility/utility.cjs +83 -0
  214. package/dist/wallet/utility/utility.cjs.map +1 -0
  215. package/dist/wallet/utility/utility.d.cts +42 -0
  216. package/dist/wallet/utility/utility.d.cts.map +1 -0
  217. package/dist/wallet/utility/utility.d.mts +42 -0
  218. package/dist/wallet/utility/utility.d.mts.map +1 -0
  219. package/dist/wallet/utility/utility.mjs +75 -0
  220. package/dist/wallet/utility/utility.mjs.map +1 -0
  221. package/dist/wallet/wallet.cjs +223 -0
  222. package/dist/wallet/wallet.cjs.map +1 -0
  223. package/dist/wallet/wallet.d.cts +113 -0
  224. package/dist/wallet/wallet.d.cts.map +1 -0
  225. package/dist/wallet/wallet.d.mts +113 -0
  226. package/dist/wallet/wallet.d.mts.map +1 -0
  227. package/dist/wallet/wallet.mjs +222 -0
  228. package/dist/wallet/wallet.mjs.map +1 -0
  229. package/package.json +57 -38
  230. package/bin/index.d.ts +0 -4
  231. package/bin/index.js +0 -20
  232. package/bin/proto/google/protobuf/any.d.ts +0 -145
  233. package/bin/proto/google/protobuf/any.js +0 -113
  234. package/bin/proto/index.d.ts +0 -2
  235. package/bin/proto/index.js +0 -20
  236. package/bin/proto/tm2/abci.d.ts +0 -37
  237. package/bin/proto/tm2/abci.js +0 -277
  238. package/bin/proto/tm2/multisig.d.ts +0 -43
  239. package/bin/proto/tm2/multisig.js +0 -322
  240. package/bin/proto/tm2/multisig.test.d.ts +0 -1
  241. package/bin/proto/tm2/multisig.test.js +0 -63
  242. package/bin/proto/tm2/tx.d.ts +0 -52
  243. package/bin/proto/tm2/tx.js +0 -360
  244. package/bin/provider/endpoints.d.ts +0 -29
  245. package/bin/provider/endpoints.js +0 -37
  246. package/bin/provider/errors/errors.d.ts +0 -59
  247. package/bin/provider/errors/errors.js +0 -173
  248. package/bin/provider/errors/index.d.ts +0 -1
  249. package/bin/provider/errors/index.js +0 -17
  250. package/bin/provider/errors/messages.d.ts +0 -19
  251. package/bin/provider/errors/messages.js +0 -41
  252. package/bin/provider/index.d.ts +0 -7
  253. package/bin/provider/index.js +0 -23
  254. package/bin/provider/jsonrpc/index.d.ts +0 -1
  255. package/bin/provider/jsonrpc/index.js +0 -17
  256. package/bin/provider/jsonrpc/jsonrpc.d.ts +0 -31
  257. package/bin/provider/jsonrpc/jsonrpc.js +0 -327
  258. package/bin/provider/jsonrpc/jsonrpc.test.d.ts +0 -1
  259. package/bin/provider/jsonrpc/jsonrpc.test.js +0 -488
  260. package/bin/provider/provider.d.ts +0 -98
  261. package/bin/provider/provider.js +0 -2
  262. package/bin/provider/types/abci.d.ts +0 -39
  263. package/bin/provider/types/abci.js +0 -4
  264. package/bin/provider/types/common.d.ts +0 -184
  265. package/bin/provider/types/common.js +0 -3
  266. package/bin/provider/types/index.d.ts +0 -3
  267. package/bin/provider/types/index.js +0 -19
  268. package/bin/provider/types/jsonrpc.d.ts +0 -26
  269. package/bin/provider/types/jsonrpc.js +0 -2
  270. package/bin/provider/utility/errors.utility.d.ts +0 -11
  271. package/bin/provider/utility/errors.utility.js +0 -56
  272. package/bin/provider/utility/index.d.ts +0 -2
  273. package/bin/provider/utility/index.js +0 -18
  274. package/bin/provider/utility/provider.utility.js +0 -244
  275. package/bin/provider/utility/requests.utility.d.ts +0 -35
  276. package/bin/provider/utility/requests.utility.js +0 -80
  277. package/bin/provider/websocket/index.d.ts +0 -1
  278. package/bin/provider/websocket/index.js +0 -17
  279. package/bin/provider/websocket/ws.d.ts +0 -58
  280. package/bin/provider/websocket/ws.js +0 -415
  281. package/bin/provider/websocket/ws.test.d.ts +0 -1
  282. package/bin/provider/websocket/ws.test.js +0 -648
  283. package/bin/services/index.d.ts +0 -2
  284. package/bin/services/index.js +0 -18
  285. package/bin/services/rest/restService.d.ts +0 -4
  286. package/bin/services/rest/restService.js +0 -72
  287. package/bin/services/rest/restService.types.d.ts +0 -6
  288. package/bin/services/rest/restService.types.js +0 -2
  289. package/bin/wallet/index.d.ts +0 -6
  290. package/bin/wallet/index.js +0 -22
  291. package/bin/wallet/key/index.d.ts +0 -1
  292. package/bin/wallet/key/index.js +0 -17
  293. package/bin/wallet/key/key.d.ts +0 -21
  294. package/bin/wallet/key/key.js +0 -102
  295. package/bin/wallet/key/key.test.d.ts +0 -1
  296. package/bin/wallet/key/key.test.js +0 -121
  297. package/bin/wallet/ledger/index.d.ts +0 -1
  298. package/bin/wallet/ledger/index.js +0 -17
  299. package/bin/wallet/ledger/ledger.d.ts +0 -22
  300. package/bin/wallet/ledger/ledger.js +0 -109
  301. package/bin/wallet/signer.d.ts +0 -29
  302. package/bin/wallet/signer.js +0 -2
  303. package/bin/wallet/types/index.d.ts +0 -2
  304. package/bin/wallet/types/index.js +0 -18
  305. package/bin/wallet/types/sign.d.ts +0 -16
  306. package/bin/wallet/types/sign.js +0 -4
  307. package/bin/wallet/types/wallet.d.ts +0 -5
  308. package/bin/wallet/types/wallet.js +0 -2
  309. package/bin/wallet/utility/index.d.ts +0 -1
  310. package/bin/wallet/utility/index.js +0 -17
  311. package/bin/wallet/utility/utility.d.ts +0 -36
  312. package/bin/wallet/utility/utility.js +0 -117
  313. package/bin/wallet/wallet.d.ts +0 -106
  314. package/bin/wallet/wallet.js +0 -361
  315. package/bin/wallet/wallet.test.d.ts +0 -1
  316. package/bin/wallet/wallet.test.js +0 -423
@@ -1,33 +1,35 @@
1
- import { Tx } from '../../proto';
2
- import { ResponseDeliverTx } from '../../proto/tm2/abci';
3
- import { Provider } from '../provider';
4
- import { ABCIAccount, ABCIResponse } from '../types';
1
+ import { Tx } from "../../proto/tm2/tx.cjs";
2
+ import { ABCIAccount, ABCIResponse } from "../types/abci.cjs";
3
+ import { Provider } from "../provider.cjs";
4
+ import { ResponseDeliverTx } from "../../proto/tm2/abci.cjs";
5
+
6
+ //#region src/provider/utility/provider.utility.d.ts
5
7
  /**
6
8
  * Extracts the specific balance denomination from the ABCI response
7
9
  * @param {string | null} abciData the base64-encoded ABCI data
8
10
  * @param {string} denomination the required denomination
9
11
  */
10
- export declare const extractBalanceFromResponse: (abciData: string | null, denomination: string) => number;
12
+ declare const extractBalanceFromResponse: (abciData: string | null, denomination: string) => number;
11
13
  /**
12
14
  * Extracts the account sequence from the ABCI response
13
15
  * @param {string | null} abciData the base64-encoded ABCI data
14
16
  */
15
- export declare const extractSequenceFromResponse: (abciData: string | null) => number;
17
+ declare const extractSequenceFromResponse: (abciData: string | null) => number;
16
18
  /**
17
19
  * Extracts the account number from the ABCI response
18
20
  * @param {string | null} abciData the base64-encoded ABCI data
19
21
  */
20
- export declare const extractAccountNumberFromResponse: (abciData: string | null) => number;
22
+ declare const extractAccountNumberFromResponse: (abciData: string | null) => number;
21
23
  /**
22
24
  * Extracts the account from the ABCI response
23
25
  * @param {string | null} abciData the base64-encoded ABCI data
24
26
  */
25
- export declare const extractAccountFromResponse: (abciData: string | null) => ABCIAccount;
27
+ declare const extractAccountFromResponse: (abciData: string | null) => ABCIAccount;
26
28
  /**
27
29
  * Extracts the simulate transaction response from the ABCI response value
28
30
  * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message
29
31
  */
30
- export declare const extractSimulateFromResponse: (abciResponse: ABCIResponse | null) => ResponseDeliverTx;
32
+ declare const extractSimulateFromResponse: (abciResponse: ABCIResponse | null) => ResponseDeliverTx;
31
33
  /**
32
34
  * Waits for the transaction to be committed to a block in the chain
33
35
  * of the specified provider. This helper does a search for incoming blocks
@@ -37,4 +39,7 @@ export declare const extractSimulateFromResponse: (abciResponse: ABCIResponse |
37
39
  * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain
38
40
  * @param {number} [timeout=15000] the timeout in MS for the search
39
41
  */
40
- export declare const waitForTransaction: (provider: Provider, hash: string, fromHeight?: number, timeout?: number) => Promise<Tx>;
42
+ declare const waitForTransaction: (provider: Provider, hash: string, fromHeight?: number, timeout?: number) => Promise<Tx>;
43
+ //#endregion
44
+ export { extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, waitForTransaction };
45
+ //# sourceMappingURL=provider.utility.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.utility.d.cts","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"mappings":";;;;;;;;;AA+BA;;cAAa,0BAAA,GACX,QAAA,iBACA,YAAA;;;AAkCF;;cAAa,2BAAA,GACX,QAAA;;;AA0BF;;cAAa,gCAAA,GACX,QAAA;;;AAwBF;;cAAa,0BAAA,GACX,QAAA,oBACC,WAAA;;;AAuBH;;cAAa,2BAAA,GACX,YAAA,EAAc,YAAA,YACb,iBAAA;;;;;;;AAmCH;;;cAAa,kBAAA,GACX,QAAA,EAAU,QAAA,EACV,IAAA,UACA,UAAA,WACA,OAAA,cACC,OAAA,CAAQ,EAAA"}
@@ -0,0 +1,45 @@
1
+ import { Tx } from "../../proto/tm2/tx.mjs";
2
+ import { ABCIAccount, ABCIResponse } from "../types/abci.mjs";
3
+ import { Provider } from "../provider.mjs";
4
+ import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
5
+
6
+ //#region src/provider/utility/provider.utility.d.ts
7
+ /**
8
+ * Extracts the specific balance denomination from the ABCI response
9
+ * @param {string | null} abciData the base64-encoded ABCI data
10
+ * @param {string} denomination the required denomination
11
+ */
12
+ declare const extractBalanceFromResponse: (abciData: string | null, denomination: string) => number;
13
+ /**
14
+ * Extracts the account sequence from the ABCI response
15
+ * @param {string | null} abciData the base64-encoded ABCI data
16
+ */
17
+ declare const extractSequenceFromResponse: (abciData: string | null) => number;
18
+ /**
19
+ * Extracts the account number from the ABCI response
20
+ * @param {string | null} abciData the base64-encoded ABCI data
21
+ */
22
+ declare const extractAccountNumberFromResponse: (abciData: string | null) => number;
23
+ /**
24
+ * Extracts the account from the ABCI response
25
+ * @param {string | null} abciData the base64-encoded ABCI data
26
+ */
27
+ declare const extractAccountFromResponse: (abciData: string | null) => ABCIAccount;
28
+ /**
29
+ * Extracts the simulate transaction response from the ABCI response value
30
+ * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message
31
+ */
32
+ declare const extractSimulateFromResponse: (abciResponse: ABCIResponse | null) => ResponseDeliverTx;
33
+ /**
34
+ * Waits for the transaction to be committed to a block in the chain
35
+ * of the specified provider. This helper does a search for incoming blocks
36
+ * and checks if a transaction
37
+ * @param {Provider} provider the provider instance
38
+ * @param {string} hash the base64-encoded hash of the transaction
39
+ * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain
40
+ * @param {number} [timeout=15000] the timeout in MS for the search
41
+ */
42
+ declare const waitForTransaction: (provider: Provider, hash: string, fromHeight?: number, timeout?: number) => Promise<Tx>;
43
+ //#endregion
44
+ export { extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, waitForTransaction };
45
+ //# sourceMappingURL=provider.utility.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.utility.d.mts","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"mappings":";;;;;;;;;AA+BA;;cAAa,0BAAA,GACX,QAAA,iBACA,YAAA;;;AAkCF;;cAAa,2BAAA,GACX,QAAA;;;AA0BF;;cAAa,gCAAA,GACX,QAAA;;;AAwBF;;cAAa,0BAAA,GACX,QAAA,oBACC,WAAA;;;AAuBH;;cAAa,2BAAA,GACX,YAAA,EAAc,YAAA,YACb,iBAAA;;;;;;;AAmCH;;;cAAa,kBAAA,GACX,QAAA,EAAU,QAAA,EACV,IAAA,UACA,UAAA,WACA,OAAA,cACC,OAAA,CAAQ,EAAA"}
@@ -0,0 +1,116 @@
1
+ import { Tx } from "../../proto/tm2/tx.mjs";
2
+ import "../../proto/index.mjs";
3
+ import { ABCIErrorKey } from "../types/abci.mjs";
4
+ import { constructRequestError } from "./errors.utility.mjs";
5
+ import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
6
+ import { base64ToUint8Array, parseABCI, parseProto, uint8ArrayToBase64 } from "./requests.utility.mjs";
7
+ import { sha256 } from "@cosmjs/crypto";
8
+ //#region src/provider/utility/provider.utility.ts
9
+ /**
10
+ * Extracts the specific balance denomination from the ABCI response
11
+ * @param {string | null} abciData the base64-encoded ABCI data
12
+ * @param {string} denomination the required denomination
13
+ */
14
+ const extractBalanceFromResponse = (abciData, denomination) => {
15
+ if (!abciData) return 0;
16
+ const balances = Buffer.from(abciData, "base64").toString().replace(/"/gi, "").split(",");
17
+ if (balances.length < 1) return 0;
18
+ const pattern = new RegExp(`^(\\d+)${denomination}$`);
19
+ for (const balance of balances) {
20
+ const match = balance.match(pattern);
21
+ if (match) return parseInt(match[1], 10);
22
+ }
23
+ return 0;
24
+ };
25
+ /**
26
+ * Extracts the account sequence from the ABCI response
27
+ * @param {string | null} abciData the base64-encoded ABCI data
28
+ */
29
+ const extractSequenceFromResponse = (abciData) => {
30
+ if (!abciData) return 0;
31
+ try {
32
+ const account = parseABCI(abciData);
33
+ return parseInt(account.BaseAccount.sequence, 10);
34
+ } catch (_e) {}
35
+ return 0;
36
+ };
37
+ /**
38
+ * Extracts the account number from the ABCI response
39
+ * @param {string | null} abciData the base64-encoded ABCI data
40
+ */
41
+ const extractAccountNumberFromResponse = (abciData) => {
42
+ if (!abciData) throw new Error("account is not initialized");
43
+ try {
44
+ const account = parseABCI(abciData);
45
+ return parseInt(account.BaseAccount.account_number, 10);
46
+ } catch (e) {
47
+ throw new Error("account is not initialized", { cause: e });
48
+ }
49
+ };
50
+ /**
51
+ * Extracts the account from the ABCI response
52
+ * @param {string | null} abciData the base64-encoded ABCI data
53
+ */
54
+ const extractAccountFromResponse = (abciData) => {
55
+ if (!abciData) throw new Error("account is not initialized");
56
+ try {
57
+ return parseABCI(abciData);
58
+ } catch (e) {
59
+ throw new Error("account is not initialized", { cause: e });
60
+ }
61
+ };
62
+ /**
63
+ * Extracts the simulate transaction response from the ABCI response value
64
+ * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message
65
+ */
66
+ const extractSimulateFromResponse = (abciResponse) => {
67
+ if (!abciResponse) throw new Error("abci data is not initialized");
68
+ const error = abciResponse.response?.ResponseBase?.Error;
69
+ if (error && error["@type"]) throw constructRequestError(error[ABCIErrorKey]);
70
+ const value = abciResponse.response.Value;
71
+ if (!value) throw new Error("abci data is not initialized");
72
+ try {
73
+ return parseProto(value, ResponseDeliverTx.decode);
74
+ } catch (e) {
75
+ throw new Error("unable to parse simulate response", { cause: e });
76
+ }
77
+ };
78
+ /**
79
+ * Waits for the transaction to be committed to a block in the chain
80
+ * of the specified provider. This helper does a search for incoming blocks
81
+ * and checks if a transaction
82
+ * @param {Provider} provider the provider instance
83
+ * @param {string} hash the base64-encoded hash of the transaction
84
+ * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain
85
+ * @param {number} [timeout=15000] the timeout in MS for the search
86
+ */
87
+ const waitForTransaction = async (provider, hash, fromHeight, timeout) => {
88
+ let currentHeight = fromHeight ? fromHeight : await provider.getBlockNumber();
89
+ return new Promise((resolve, reject) => {
90
+ const exitTimeout = timeout ? timeout : 15e3;
91
+ const fetchInterval = setInterval(async () => {
92
+ const latestHeight = await provider.getBlockNumber();
93
+ if (latestHeight < currentHeight) return;
94
+ for (let blockNum = currentHeight; blockNum <= latestHeight; blockNum++) {
95
+ const block = await provider.getBlock(blockNum);
96
+ if (!block.block.data.txs || block.block.data.txs.length == 0) continue;
97
+ for (const tx of block.block.data.txs) {
98
+ const txRaw = base64ToUint8Array(tx);
99
+ if (uint8ArrayToBase64(sha256(txRaw)) == hash) {
100
+ clearInterval(fetchInterval);
101
+ resolve(Tx.decode(txRaw));
102
+ }
103
+ }
104
+ }
105
+ currentHeight = latestHeight + 1;
106
+ }, 1e3);
107
+ setTimeout(() => {
108
+ clearInterval(fetchInterval);
109
+ reject("transaction fetch timeout");
110
+ }, exitTimeout);
111
+ });
112
+ };
113
+ //#endregion
114
+ export { extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, waitForTransaction };
115
+
116
+ //# sourceMappingURL=provider.utility.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.utility.mjs","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"sourcesContent":["import {\n sha256,\n} from \"@cosmjs/crypto\";\n\nimport {\n Tx,\n} from \"../../proto/index.js\";\nimport {\n ResponseDeliverTx,\n} from \"../../proto/tm2/abci.js\";\nimport {\n Provider,\n} from \"../provider.js\";\nimport {\n ABCIAccount, ABCIErrorKey, ABCIResponse, BlockInfo,\n} from \"../types/index.js\";\nimport {\n constructRequestError,\n} from \"./errors.utility.js\";\nimport {\n base64ToUint8Array,\n parseABCI,\n parseProto,\n uint8ArrayToBase64,\n} from \"./requests.utility.js\";\n\n/**\n * Extracts the specific balance denomination from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n * @param {string} denomination the required denomination\n */\nexport const extractBalanceFromResponse = (\n abciData: string | null,\n denomination: string,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n // Extract the balances\n const balancesRaw = Buffer.from(abciData, \"base64\")\n .toString()\n .replace(/\"/gi, \"\");\n\n // Find the correct balance denomination\n const balances: string[] = balancesRaw.split(\",\");\n if (balances.length < 1) {\n return 0;\n }\n\n // Find the correct denomination\n const pattern = new RegExp(`^(\\\\d+)${denomination}$`);\n for (const balance of balances) {\n const match = balance.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n\n return 0;\n};\n\n/**\n * Extracts the account sequence from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractSequenceFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.sequence, 10);\n }\n catch (_e) {\n // unused case\n }\n\n // Account not initialized,\n // return default value (0)\n return 0;\n};\n\n/**\n * Extracts the account number from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountNumberFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.account_number, 10);\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the account from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountFromResponse = (\n abciData: string | null,\n): ABCIAccount => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return account;\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the simulate transaction response from the ABCI response value\n * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message\n */\nexport const extractSimulateFromResponse = (\n abciResponse: ABCIResponse | null,\n): ResponseDeliverTx => {\n // Make sure the response is initialized\n if (!abciResponse) {\n throw new Error(\"abci data is not initialized\");\n }\n\n const error = abciResponse.response?.ResponseBase?.Error;\n if (error && error[ABCIErrorKey]) {\n throw constructRequestError(error[ABCIErrorKey]);\n }\n\n const value = abciResponse.response.Value;\n if (!value) {\n throw new Error(\"abci data is not initialized\");\n }\n\n try {\n return parseProto(value, ResponseDeliverTx.decode);\n }\n catch (e) {\n throw new Error(\"unable to parse simulate response\", {\n cause: e,\n });\n }\n};\n\n/**\n * Waits for the transaction to be committed to a block in the chain\n * of the specified provider. This helper does a search for incoming blocks\n * and checks if a transaction\n * @param {Provider} provider the provider instance\n * @param {string} hash the base64-encoded hash of the transaction\n * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain\n * @param {number} [timeout=15000] the timeout in MS for the search\n */\nexport const waitForTransaction = async (\n provider: Provider,\n hash: string,\n fromHeight?: number,\n timeout?: number,\n): Promise<Tx> => {\n // Fetch the starting point\n let currentHeight = fromHeight\n ? fromHeight\n : await provider.getBlockNumber();\n\n return new Promise((resolve, reject) => {\n const exitTimeout = timeout ? timeout : 15000;\n\n const fetchInterval = setInterval(async () => {\n // Fetch the latest block height\n const latestHeight = await provider.getBlockNumber();\n\n if (latestHeight < currentHeight) {\n // No need to parse older blocks\n return;\n }\n\n for (let blockNum = currentHeight; blockNum <= latestHeight; blockNum++) {\n // Fetch the block from the chain\n const block: BlockInfo = await provider.getBlock(blockNum);\n\n // Check if there are any transactions at all in the block\n if (!block.block.data.txs || block.block.data.txs.length == 0) {\n continue;\n }\n\n // Find the transaction among the block transactions\n for (const tx of block.block.data.txs) {\n // Decode the base-64 transaction\n const txRaw = base64ToUint8Array(tx);\n\n // Calculate the transaction hash\n const txHash = sha256(txRaw);\n\n if (uint8ArrayToBase64(txHash) == hash) {\n // Clear the interval\n clearInterval(fetchInterval);\n\n // Decode the transaction from amino\n resolve(Tx.decode(txRaw));\n }\n }\n }\n\n currentHeight = latestHeight + 1;\n }, 1000);\n\n setTimeout(() => {\n // Clear the fetch interval\n clearInterval(fetchInterval);\n\n reject(\"transaction fetch timeout\");\n }, exitTimeout);\n });\n};\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAa,8BACX,UACA,iBACW;AAEX,KAAI,CAAC,SACH,QAAO;CAST,MAAM,WALc,OAAO,KAAK,UAAU,SAAS,CAChD,UAAU,CACV,QAAQ,OAAO,GAAG,CAGkB,MAAM,IAAI;AACjD,KAAI,SAAS,SAAS,EACpB,QAAO;CAIT,MAAM,UAAU,IAAI,OAAO,UAAU,aAAa,GAAG;AACrD,MAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,QAAQ,MAAM,QAAQ;AACpC,MAAI,MACF,QAAO,SAAS,MAAM,IAAI,GAAG;;AAIjC,QAAO;;;;;;AAOT,MAAa,+BACX,aACW;AAEX,KAAI,CAAC,SACH,QAAO;AAGT,KAAI;EAEF,MAAM,UAAuB,UAAuB,SAAS;AAE7D,SAAO,SAAS,QAAQ,YAAY,UAAU,GAAG;UAE5C,IAAI;AAMX,QAAO;;;;;;AAOT,MAAa,oCACX,aACW;AAEX,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,KAAI;EAEF,MAAM,UAAuB,UAAuB,SAAS;AAE7D,SAAO,SAAS,QAAQ,YAAY,gBAAgB,GAAG;UAElD,GAAG;AACR,QAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,GACR,CAAC;;;;;;;AAQN,MAAa,8BACX,aACgB;AAEhB,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,KAAI;AAIF,SAF6B,UAAuB,SAAS;UAIxD,GAAG;AACR,QAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,GACR,CAAC;;;;;;;AAQN,MAAa,+BACX,iBACsB;AAEtB,KAAI,CAAC,aACH,OAAM,IAAI,MAAM,+BAA+B;CAGjD,MAAM,QAAQ,aAAa,UAAU,cAAc;AACnD,KAAI,SAAS,MAAA,SACX,OAAM,sBAAsB,MAAM,cAAc;CAGlD,MAAM,QAAQ,aAAa,SAAS;AACpC,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,+BAA+B;AAGjD,KAAI;AACF,SAAO,WAAW,OAAO,kBAAkB,OAAO;UAE7C,GAAG;AACR,QAAM,IAAI,MAAM,qCAAqC,EACnD,OAAO,GACR,CAAC;;;;;;;;;;;;AAaN,MAAa,qBAAqB,OAChC,UACA,MACA,YACA,YACgB;CAEhB,IAAI,gBAAgB,aAChB,aACA,MAAM,SAAS,gBAAgB;AAEnC,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,cAAc,UAAU,UAAU;EAExC,MAAM,gBAAgB,YAAY,YAAY;GAE5C,MAAM,eAAe,MAAM,SAAS,gBAAgB;AAEpD,OAAI,eAAe,cAEjB;AAGF,QAAK,IAAI,WAAW,eAAe,YAAY,cAAc,YAAY;IAEvE,MAAM,QAAmB,MAAM,SAAS,SAAS,SAAS;AAG1D,QAAI,CAAC,MAAM,MAAM,KAAK,OAAO,MAAM,MAAM,KAAK,IAAI,UAAU,EAC1D;AAIF,SAAK,MAAM,MAAM,MAAM,MAAM,KAAK,KAAK;KAErC,MAAM,QAAQ,mBAAmB,GAAG;AAKpC,SAAI,mBAFW,OAAO,MAAM,CAEE,IAAI,MAAM;AAEtC,oBAAc,cAAc;AAG5B,cAAQ,GAAG,OAAO,MAAM,CAAC;;;;AAK/B,mBAAgB,eAAe;KAC9B,IAAK;AAER,mBAAiB;AAEf,iBAAc,cAAc;AAE5B,UAAO,4BAA4B;KAClC,YAAY;GACf"}
@@ -0,0 +1,75 @@
1
+ require("../../_virtual/_rolldown/runtime.cjs");
2
+ let uuid = require("uuid");
3
+ //#region src/provider/utility/requests.utility.ts
4
+ const standardVersion = "2.0";
5
+ /**
6
+ * Creates a new JSON-RPC 2.0 request
7
+ * @param {string} method the requested method
8
+ * @param {unknown[]} [params] the requested params, if any
9
+ */
10
+ const newRequest = (method, params) => {
11
+ return {
12
+ id: (0, uuid.v4)(),
13
+ jsonrpc: standardVersion,
14
+ method,
15
+ params
16
+ };
17
+ };
18
+ /**
19
+ * Creates a new JSON-RPC 2.0 response
20
+ * @param {Result} result the response result, if any
21
+ * @param {RPCError} error the response error, if any
22
+ */
23
+ const newResponse = (result, error) => {
24
+ return {
25
+ id: (0, uuid.v4)(),
26
+ jsonrpc: standardVersion,
27
+ result,
28
+ error
29
+ };
30
+ };
31
+ /**
32
+ * Parses the base64 encoded ABCI JSON into a concrete type
33
+ * @param {string} data the base64-encoded JSON
34
+ */
35
+ const parseABCI = (data) => {
36
+ const jsonData = Buffer.from(data, "base64").toString();
37
+ const parsedData = JSON.parse(jsonData);
38
+ if (!parsedData) throw new Error("unable to parse JSON response");
39
+ return parsedData;
40
+ };
41
+ const parseProto = (data, decodeFn) => {
42
+ return decodeFn(Buffer.from(data, "base64"));
43
+ };
44
+ /**
45
+ * Converts a string into base64 representation
46
+ * @param {string} str the raw string
47
+ */
48
+ const stringToBase64 = (str) => {
49
+ return Buffer.from(str, "utf-8").toString("base64");
50
+ };
51
+ /**
52
+ * Converts a base64 string into a Uint8Array representation
53
+ * @param {string} str the base64-encoded string
54
+ */
55
+ const base64ToUint8Array = (str) => {
56
+ const buffer = Buffer.from(str, "base64");
57
+ return new Uint8Array(buffer);
58
+ };
59
+ /**
60
+ * Converts a Uint8Array into base64 representation
61
+ * @param {Uint8Array} data the Uint8Array to be encoded
62
+ */
63
+ const uint8ArrayToBase64 = (data) => {
64
+ return Buffer.from(data).toString("base64");
65
+ };
66
+ //#endregion
67
+ exports.base64ToUint8Array = base64ToUint8Array;
68
+ exports.newRequest = newRequest;
69
+ exports.newResponse = newResponse;
70
+ exports.parseABCI = parseABCI;
71
+ exports.parseProto = parseProto;
72
+ exports.stringToBase64 = stringToBase64;
73
+ exports.uint8ArrayToBase64 = uint8ArrayToBase64;
74
+
75
+ //# sourceMappingURL=requests.utility.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.utility.cjs","names":[],"sources":["../../../src/provider/utility/requests.utility.ts"],"sourcesContent":["import {\n BinaryReader,\n} from \"@bufbuild/protobuf/wire\";\nimport {\n v4 as uuidv4,\n} from \"uuid\";\n\nimport {\n RPCError, RPCRequest, RPCResponse,\n} from \"../types/index.js\";\n\n// The version of the supported JSON-RPC protocol\nconst standardVersion = \"2.0\";\n\n/**\n * Creates a new JSON-RPC 2.0 request\n * @param {string} method the requested method\n * @param {unknown[]} [params] the requested params, if any\n */\nexport const newRequest = (method: string, params?: unknown[]): RPCRequest => {\n return {\n // the ID of the request is not that relevant for this helper method;\n // for finer ID control, instantiate the request object directly\n id: uuidv4(),\n jsonrpc: standardVersion,\n method: method,\n params: params,\n };\n};\n\n/**\n * Creates a new JSON-RPC 2.0 response\n * @param {Result} result the response result, if any\n * @param {RPCError} error the response error, if any\n */\nexport const newResponse = <Result>(\n result?: Result,\n error?: RPCError,\n): RPCResponse<Result> => {\n return {\n id: uuidv4(),\n jsonrpc: standardVersion,\n result: result,\n error: error,\n };\n};\n\n/**\n * Parses the base64 encoded ABCI JSON into a concrete type\n * @param {string} data the base64-encoded JSON\n */\nexport const parseABCI = <Result>(data: string): Result => {\n const jsonData: string = Buffer.from(data, \"base64\").toString();\n const parsedData: Result | null = JSON.parse(jsonData);\n\n if (!parsedData) {\n throw new Error(\"unable to parse JSON response\");\n }\n\n return parsedData;\n};\n\nexport const parseProto = <T>(\n data: string,\n decodeFn: (input: BinaryReader | Uint8Array, length?: number) => T,\n) => {\n const protoData = decodeFn(Buffer.from(data, \"base64\"));\n\n return protoData;\n};\n\n/**\n * Converts a string into base64 representation\n * @param {string} str the raw string\n */\nexport const stringToBase64 = (str: string): string => {\n const buffer = Buffer.from(str, \"utf-8\");\n\n return buffer.toString(\"base64\");\n};\n\n/**\n * Converts a base64 string into a Uint8Array representation\n * @param {string} str the base64-encoded string\n */\nexport const base64ToUint8Array = (str: string): Uint8Array => {\n const buffer = Buffer.from(str, \"base64\");\n\n return new Uint8Array(buffer);\n};\n\n/**\n * Converts a Uint8Array into base64 representation\n * @param {Uint8Array} data the Uint8Array to be encoded\n */\nexport const uint8ArrayToBase64 = (data: Uint8Array): string => {\n return Buffer.from(data).toString(\"base64\");\n};\n"],"mappings":";;;AAYA,MAAM,kBAAkB;;;;;;AAOxB,MAAa,cAAc,QAAgB,WAAmC;AAC5E,QAAO;EAGL,KAAA,GAAA,KAAA,KAAY;EACZ,SAAS;EACD;EACA;EACT;;;;;;;AAQH,MAAa,eACX,QACA,UACwB;AACxB,QAAO;EACL,KAAA,GAAA,KAAA,KAAY;EACZ,SAAS;EACD;EACD;EACR;;;;;;AAOH,MAAa,aAAqB,SAAyB;CACzD,MAAM,WAAmB,OAAO,KAAK,MAAM,SAAS,CAAC,UAAU;CAC/D,MAAM,aAA4B,KAAK,MAAM,SAAS;AAEtD,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,gCAAgC;AAGlD,QAAO;;AAGT,MAAa,cACX,MACA,aACG;AAGH,QAFkB,SAAS,OAAO,KAAK,MAAM,SAAS,CAAC;;;;;;AASzD,MAAa,kBAAkB,QAAwB;AAGrD,QAFe,OAAO,KAAK,KAAK,QAAQ,CAE1B,SAAS,SAAS;;;;;;AAOlC,MAAa,sBAAsB,QAA4B;CAC7D,MAAM,SAAS,OAAO,KAAK,KAAK,SAAS;AAEzC,QAAO,IAAI,WAAW,OAAO;;;;;;AAO/B,MAAa,sBAAsB,SAA6B;AAC9D,QAAO,OAAO,KAAK,KAAK,CAAC,SAAS,SAAS"}
@@ -0,0 +1,40 @@
1
+ import { RPCError, RPCRequest, RPCResponse } from "../types/jsonrpc.cjs";
2
+ import { BinaryReader } from "@bufbuild/protobuf/wire";
3
+
4
+ //#region src/provider/utility/requests.utility.d.ts
5
+ /**
6
+ * Creates a new JSON-RPC 2.0 request
7
+ * @param {string} method the requested method
8
+ * @param {unknown[]} [params] the requested params, if any
9
+ */
10
+ declare const newRequest: (method: string, params?: unknown[]) => RPCRequest;
11
+ /**
12
+ * Creates a new JSON-RPC 2.0 response
13
+ * @param {Result} result the response result, if any
14
+ * @param {RPCError} error the response error, if any
15
+ */
16
+ declare const newResponse: <Result>(result?: Result, error?: RPCError) => RPCResponse<Result>;
17
+ /**
18
+ * Parses the base64 encoded ABCI JSON into a concrete type
19
+ * @param {string} data the base64-encoded JSON
20
+ */
21
+ declare const parseABCI: <Result>(data: string) => Result;
22
+ declare const parseProto: <T>(data: string, decodeFn: (input: BinaryReader | Uint8Array, length?: number) => T) => T;
23
+ /**
24
+ * Converts a string into base64 representation
25
+ * @param {string} str the raw string
26
+ */
27
+ declare const stringToBase64: (str: string) => string;
28
+ /**
29
+ * Converts a base64 string into a Uint8Array representation
30
+ * @param {string} str the base64-encoded string
31
+ */
32
+ declare const base64ToUint8Array: (str: string) => Uint8Array;
33
+ /**
34
+ * Converts a Uint8Array into base64 representation
35
+ * @param {Uint8Array} data the Uint8Array to be encoded
36
+ */
37
+ declare const uint8ArrayToBase64: (data: Uint8Array) => string;
38
+ //#endregion
39
+ export { base64ToUint8Array, newRequest, newResponse, parseABCI, parseProto, stringToBase64, uint8ArrayToBase64 };
40
+ //# sourceMappingURL=requests.utility.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.utility.d.cts","names":[],"sources":["../../../src/provider/utility/requests.utility.ts"],"mappings":";;;;;;AAmBA;;;cAAa,UAAA,GAAc,MAAA,UAAgB,MAAA,iBAAqB,UAAA;;;;;;cAgBnD,WAAA,WACX,MAAA,GAAS,MAAA,EACT,KAAA,GAAQ,QAAA,KACP,WAAA,CAAY,MAAA;;;;;cAaF,SAAA,WAAqB,IAAA,aAAe,MAAA;AAAA,cAWpC,UAAA,MACX,IAAA,UACA,QAAA,GAAW,KAAA,EAAO,YAAA,GAAe,UAAA,EAAY,MAAA,cAAoB,CAAA,KAAC,CAAA;;;;;cAWvD,cAAA,GAAkB,GAAA;;;;;cAUlB,kBAAA,GAAsB,GAAA,aAAc,UAAA;;AAlCjD;;;cA4Ca,kBAAA,GAAsB,IAAA,EAAM,UAAA"}
@@ -0,0 +1,40 @@
1
+ import { RPCError, RPCRequest, RPCResponse } from "../types/jsonrpc.mjs";
2
+ import { BinaryReader } from "@bufbuild/protobuf/wire";
3
+
4
+ //#region src/provider/utility/requests.utility.d.ts
5
+ /**
6
+ * Creates a new JSON-RPC 2.0 request
7
+ * @param {string} method the requested method
8
+ * @param {unknown[]} [params] the requested params, if any
9
+ */
10
+ declare const newRequest: (method: string, params?: unknown[]) => RPCRequest;
11
+ /**
12
+ * Creates a new JSON-RPC 2.0 response
13
+ * @param {Result} result the response result, if any
14
+ * @param {RPCError} error the response error, if any
15
+ */
16
+ declare const newResponse: <Result>(result?: Result, error?: RPCError) => RPCResponse<Result>;
17
+ /**
18
+ * Parses the base64 encoded ABCI JSON into a concrete type
19
+ * @param {string} data the base64-encoded JSON
20
+ */
21
+ declare const parseABCI: <Result>(data: string) => Result;
22
+ declare const parseProto: <T>(data: string, decodeFn: (input: BinaryReader | Uint8Array, length?: number) => T) => T;
23
+ /**
24
+ * Converts a string into base64 representation
25
+ * @param {string} str the raw string
26
+ */
27
+ declare const stringToBase64: (str: string) => string;
28
+ /**
29
+ * Converts a base64 string into a Uint8Array representation
30
+ * @param {string} str the base64-encoded string
31
+ */
32
+ declare const base64ToUint8Array: (str: string) => Uint8Array;
33
+ /**
34
+ * Converts a Uint8Array into base64 representation
35
+ * @param {Uint8Array} data the Uint8Array to be encoded
36
+ */
37
+ declare const uint8ArrayToBase64: (data: Uint8Array) => string;
38
+ //#endregion
39
+ export { base64ToUint8Array, newRequest, newResponse, parseABCI, parseProto, stringToBase64, uint8ArrayToBase64 };
40
+ //# sourceMappingURL=requests.utility.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.utility.d.mts","names":[],"sources":["../../../src/provider/utility/requests.utility.ts"],"mappings":";;;;;;AAmBA;;;cAAa,UAAA,GAAc,MAAA,UAAgB,MAAA,iBAAqB,UAAA;;;;;;cAgBnD,WAAA,WACX,MAAA,GAAS,MAAA,EACT,KAAA,GAAQ,QAAA,KACP,WAAA,CAAY,MAAA;;;;;cAaF,SAAA,WAAqB,IAAA,aAAe,MAAA;AAAA,cAWpC,UAAA,MACX,IAAA,UACA,QAAA,GAAW,KAAA,EAAO,YAAA,GAAe,UAAA,EAAY,MAAA,cAAoB,CAAA,KAAC,CAAA;;;;;cAWvD,cAAA,GAAkB,GAAA;;;;;cAUlB,kBAAA,GAAsB,GAAA,aAAc,UAAA;;AAlCjD;;;cA4Ca,kBAAA,GAAsB,IAAA,EAAM,UAAA"}
@@ -0,0 +1,68 @@
1
+ import { v4 } from "uuid";
2
+ //#region src/provider/utility/requests.utility.ts
3
+ const standardVersion = "2.0";
4
+ /**
5
+ * Creates a new JSON-RPC 2.0 request
6
+ * @param {string} method the requested method
7
+ * @param {unknown[]} [params] the requested params, if any
8
+ */
9
+ const newRequest = (method, params) => {
10
+ return {
11
+ id: v4(),
12
+ jsonrpc: standardVersion,
13
+ method,
14
+ params
15
+ };
16
+ };
17
+ /**
18
+ * Creates a new JSON-RPC 2.0 response
19
+ * @param {Result} result the response result, if any
20
+ * @param {RPCError} error the response error, if any
21
+ */
22
+ const newResponse = (result, error) => {
23
+ return {
24
+ id: v4(),
25
+ jsonrpc: standardVersion,
26
+ result,
27
+ error
28
+ };
29
+ };
30
+ /**
31
+ * Parses the base64 encoded ABCI JSON into a concrete type
32
+ * @param {string} data the base64-encoded JSON
33
+ */
34
+ const parseABCI = (data) => {
35
+ const jsonData = Buffer.from(data, "base64").toString();
36
+ const parsedData = JSON.parse(jsonData);
37
+ if (!parsedData) throw new Error("unable to parse JSON response");
38
+ return parsedData;
39
+ };
40
+ const parseProto = (data, decodeFn) => {
41
+ return decodeFn(Buffer.from(data, "base64"));
42
+ };
43
+ /**
44
+ * Converts a string into base64 representation
45
+ * @param {string} str the raw string
46
+ */
47
+ const stringToBase64 = (str) => {
48
+ return Buffer.from(str, "utf-8").toString("base64");
49
+ };
50
+ /**
51
+ * Converts a base64 string into a Uint8Array representation
52
+ * @param {string} str the base64-encoded string
53
+ */
54
+ const base64ToUint8Array = (str) => {
55
+ const buffer = Buffer.from(str, "base64");
56
+ return new Uint8Array(buffer);
57
+ };
58
+ /**
59
+ * Converts a Uint8Array into base64 representation
60
+ * @param {Uint8Array} data the Uint8Array to be encoded
61
+ */
62
+ const uint8ArrayToBase64 = (data) => {
63
+ return Buffer.from(data).toString("base64");
64
+ };
65
+ //#endregion
66
+ export { base64ToUint8Array, newRequest, newResponse, parseABCI, parseProto, stringToBase64, uint8ArrayToBase64 };
67
+
68
+ //# sourceMappingURL=requests.utility.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.utility.mjs","names":["uuidv4"],"sources":["../../../src/provider/utility/requests.utility.ts"],"sourcesContent":["import {\n BinaryReader,\n} from \"@bufbuild/protobuf/wire\";\nimport {\n v4 as uuidv4,\n} from \"uuid\";\n\nimport {\n RPCError, RPCRequest, RPCResponse,\n} from \"../types/index.js\";\n\n// The version of the supported JSON-RPC protocol\nconst standardVersion = \"2.0\";\n\n/**\n * Creates a new JSON-RPC 2.0 request\n * @param {string} method the requested method\n * @param {unknown[]} [params] the requested params, if any\n */\nexport const newRequest = (method: string, params?: unknown[]): RPCRequest => {\n return {\n // the ID of the request is not that relevant for this helper method;\n // for finer ID control, instantiate the request object directly\n id: uuidv4(),\n jsonrpc: standardVersion,\n method: method,\n params: params,\n };\n};\n\n/**\n * Creates a new JSON-RPC 2.0 response\n * @param {Result} result the response result, if any\n * @param {RPCError} error the response error, if any\n */\nexport const newResponse = <Result>(\n result?: Result,\n error?: RPCError,\n): RPCResponse<Result> => {\n return {\n id: uuidv4(),\n jsonrpc: standardVersion,\n result: result,\n error: error,\n };\n};\n\n/**\n * Parses the base64 encoded ABCI JSON into a concrete type\n * @param {string} data the base64-encoded JSON\n */\nexport const parseABCI = <Result>(data: string): Result => {\n const jsonData: string = Buffer.from(data, \"base64\").toString();\n const parsedData: Result | null = JSON.parse(jsonData);\n\n if (!parsedData) {\n throw new Error(\"unable to parse JSON response\");\n }\n\n return parsedData;\n};\n\nexport const parseProto = <T>(\n data: string,\n decodeFn: (input: BinaryReader | Uint8Array, length?: number) => T,\n) => {\n const protoData = decodeFn(Buffer.from(data, \"base64\"));\n\n return protoData;\n};\n\n/**\n * Converts a string into base64 representation\n * @param {string} str the raw string\n */\nexport const stringToBase64 = (str: string): string => {\n const buffer = Buffer.from(str, \"utf-8\");\n\n return buffer.toString(\"base64\");\n};\n\n/**\n * Converts a base64 string into a Uint8Array representation\n * @param {string} str the base64-encoded string\n */\nexport const base64ToUint8Array = (str: string): Uint8Array => {\n const buffer = Buffer.from(str, \"base64\");\n\n return new Uint8Array(buffer);\n};\n\n/**\n * Converts a Uint8Array into base64 representation\n * @param {Uint8Array} data the Uint8Array to be encoded\n */\nexport const uint8ArrayToBase64 = (data: Uint8Array): string => {\n return Buffer.from(data).toString(\"base64\");\n};\n"],"mappings":";;AAYA,MAAM,kBAAkB;;;;;;AAOxB,MAAa,cAAc,QAAgB,WAAmC;AAC5E,QAAO;EAGL,IAAIA,IAAQ;EACZ,SAAS;EACD;EACA;EACT;;;;;;;AAQH,MAAa,eACX,QACA,UACwB;AACxB,QAAO;EACL,IAAIA,IAAQ;EACZ,SAAS;EACD;EACD;EACR;;;;;;AAOH,MAAa,aAAqB,SAAyB;CACzD,MAAM,WAAmB,OAAO,KAAK,MAAM,SAAS,CAAC,UAAU;CAC/D,MAAM,aAA4B,KAAK,MAAM,SAAS;AAEtD,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,gCAAgC;AAGlD,QAAO;;AAGT,MAAa,cACX,MACA,aACG;AAGH,QAFkB,SAAS,OAAO,KAAK,MAAM,SAAS,CAAC;;;;;;AASzD,MAAa,kBAAkB,QAAwB;AAGrD,QAFe,OAAO,KAAK,KAAK,QAAQ,CAE1B,SAAS,SAAS;;;;;;AAOlC,MAAa,sBAAsB,QAA4B;CAC7D,MAAM,SAAS,OAAO,KAAK,KAAK,SAAS;AAEzC,QAAO,IAAI,WAAW,OAAO;;;;;;AAO/B,MAAa,sBAAsB,SAA6B;AAC9D,QAAO,OAAO,KAAK,KAAK,CAAC,SAAS,SAAS"}
@@ -0,0 +1 @@
1
+ require("./ws.cjs");
@@ -0,0 +1 @@
1
+ import { WSProvider } from "./ws.cjs";
@@ -0,0 +1 @@
1
+ import { WSProvider } from "./ws.mjs";
@@ -0,0 +1,2 @@
1
+ import "./ws.mjs";
2
+ export {};
@@ -0,0 +1,27 @@
1
+ require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_provider = require("../provider.cjs");
3
+ let _gnolang_tm2_rpc = require("@gnolang/tm2-rpc");
4
+ //#region src/provider/websocket/ws.ts
5
+ /**
6
+ * Provider based on WS JSON-RPC requests
7
+ */
8
+ var WSProvider = class WSProvider extends require_provider.BaseTm2Provider {
9
+ /**
10
+ * Creates a new instance of the {@link WSProvider}
11
+ * @param {string} baseURL the WS URL of the node
12
+ */
13
+ static async create(baseURL) {
14
+ return new WSProvider(await _gnolang_tm2_rpc.Tm2Client.connect(baseURL));
15
+ }
16
+ /**
17
+ * Closes the WS connection. Required when done working
18
+ * with the WS provider
19
+ */
20
+ closeConnection() {
21
+ this.client.disconnect();
22
+ }
23
+ };
24
+ //#endregion
25
+ exports.WSProvider = WSProvider;
26
+
27
+ //# sourceMappingURL=ws.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.cjs","names":["BaseTm2Provider","Tm2Client"],"sources":["../../../src/provider/websocket/ws.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n BaseTm2Provider,\n} from \"../provider.js\";\n\n/**\n * Provider based on WS JSON-RPC requests\n */\nexport class WSProvider extends BaseTm2Provider {\n /**\n * Creates a new instance of the {@link WSProvider}\n * @param {string} baseURL the WS URL of the node\n */\n static async create(baseURL: string): Promise<WSProvider> {\n const client = await Tm2Client.connect(baseURL);\n return new WSProvider(client);\n }\n\n /**\n * Closes the WS connection. Required when done working\n * with the WS provider\n */\n closeConnection() {\n this.client.disconnect();\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAa,aAAb,MAAa,mBAAmBA,iBAAAA,gBAAgB;;;;;CAK9C,aAAa,OAAO,SAAsC;AAExD,SAAO,IAAI,WADI,MAAMC,iBAAAA,UAAU,QAAQ,QAAQ,CAClB;;;;;;CAO/B,kBAAkB;AAChB,OAAK,OAAO,YAAY"}
@@ -0,0 +1,21 @@
1
+ import { BaseTm2Provider } from "../provider.cjs";
2
+
3
+ //#region src/provider/websocket/ws.d.ts
4
+ /**
5
+ * Provider based on WS JSON-RPC requests
6
+ */
7
+ declare class WSProvider extends BaseTm2Provider {
8
+ /**
9
+ * Creates a new instance of the {@link WSProvider}
10
+ * @param {string} baseURL the WS URL of the node
11
+ */
12
+ static create(baseURL: string): Promise<WSProvider>;
13
+ /**
14
+ * Closes the WS connection. Required when done working
15
+ * with the WS provider
16
+ */
17
+ closeConnection(): void;
18
+ }
19
+ //#endregion
20
+ export { WSProvider };
21
+ //# sourceMappingURL=ws.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.d.cts","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"mappings":";;;;;AAWA;cAAa,UAAA,SAAmB,eAAA;;;;;SAKjB,MAAA,CAAO,OAAA,WAAkB,OAAA,CAAQ,UAAA;EALD;;;;EAc7C,eAAA,CAAA;AAAA"}
@@ -0,0 +1,21 @@
1
+ import { BaseTm2Provider } from "../provider.mjs";
2
+
3
+ //#region src/provider/websocket/ws.d.ts
4
+ /**
5
+ * Provider based on WS JSON-RPC requests
6
+ */
7
+ declare class WSProvider extends BaseTm2Provider {
8
+ /**
9
+ * Creates a new instance of the {@link WSProvider}
10
+ * @param {string} baseURL the WS URL of the node
11
+ */
12
+ static create(baseURL: string): Promise<WSProvider>;
13
+ /**
14
+ * Closes the WS connection. Required when done working
15
+ * with the WS provider
16
+ */
17
+ closeConnection(): void;
18
+ }
19
+ //#endregion
20
+ export { WSProvider };
21
+ //# sourceMappingURL=ws.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.d.mts","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"mappings":";;;;;AAWA;cAAa,UAAA,SAAmB,eAAA;;;;;SAKjB,MAAA,CAAO,OAAA,WAAkB,OAAA,CAAQ,UAAA;EALD;;;;EAc7C,eAAA,CAAA;AAAA"}
@@ -0,0 +1,26 @@
1
+ import { BaseTm2Provider } from "../provider.mjs";
2
+ import { Tm2Client } from "@gnolang/tm2-rpc";
3
+ //#region src/provider/websocket/ws.ts
4
+ /**
5
+ * Provider based on WS JSON-RPC requests
6
+ */
7
+ var WSProvider = class WSProvider extends BaseTm2Provider {
8
+ /**
9
+ * Creates a new instance of the {@link WSProvider}
10
+ * @param {string} baseURL the WS URL of the node
11
+ */
12
+ static async create(baseURL) {
13
+ return new WSProvider(await Tm2Client.connect(baseURL));
14
+ }
15
+ /**
16
+ * Closes the WS connection. Required when done working
17
+ * with the WS provider
18
+ */
19
+ closeConnection() {
20
+ this.client.disconnect();
21
+ }
22
+ };
23
+ //#endregion
24
+ export { WSProvider };
25
+
26
+ //# sourceMappingURL=ws.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.mjs","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n BaseTm2Provider,\n} from \"../provider.js\";\n\n/**\n * Provider based on WS JSON-RPC requests\n */\nexport class WSProvider extends BaseTm2Provider {\n /**\n * Creates a new instance of the {@link WSProvider}\n * @param {string} baseURL the WS URL of the node\n */\n static async create(baseURL: string): Promise<WSProvider> {\n const client = await Tm2Client.connect(baseURL);\n return new WSProvider(client);\n }\n\n /**\n * Closes the WS connection. Required when done working\n * with the WS provider\n */\n closeConnection() {\n this.client.disconnect();\n }\n}\n"],"mappings":";;;;;;AAWA,IAAa,aAAb,MAAa,mBAAmB,gBAAgB;;;;;CAK9C,aAAa,OAAO,SAAsC;AAExD,SAAO,IAAI,WADI,MAAM,UAAU,QAAQ,QAAQ,CAClB;;;;;;CAO/B,kBAAkB;AAChB,OAAK,OAAO,YAAY"}
@@ -0,0 +1 @@
1
+ require("./rest/restService.cjs");
@@ -0,0 +1,2 @@
1
+ import { RequestParams } from "./rest/restService.types.cjs";
2
+ import { RestService } from "./rest/restService.cjs";
@@ -0,0 +1,2 @@
1
+ import { RequestParams } from "./rest/restService.types.mjs";
2
+ import { RestService } from "./rest/restService.mjs";
@@ -0,0 +1,2 @@
1
+ import "./rest/restService.mjs";
2
+ export {};