@hyperweb/telescope 1.15.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 (382) hide show
  1. package/README.md +1529 -0
  2. package/main/build.js +183 -0
  3. package/main/builder.js +229 -0
  4. package/main/bundle.js +162 -0
  5. package/main/bundler.js +100 -0
  6. package/main/cli.js +71 -0
  7. package/main/cmds.js +28 -0
  8. package/main/commands/download.js +122 -0
  9. package/main/commands/generate.js +151 -0
  10. package/main/commands/install.js +143 -0
  11. package/main/commands/transpile.js +197 -0
  12. package/main/contracts/generate.js +31 -0
  13. package/main/contracts/install.js +107 -0
  14. package/main/contracts/message-composer.js +31 -0
  15. package/main/contracts/react-query.js +31 -0
  16. package/main/contracts/recoil.js +31 -0
  17. package/main/file.js +20 -0
  18. package/main/generators/create-aggregated-lcd-client.js +87 -0
  19. package/main/generators/create-all-stargate-clients.js +96 -0
  20. package/main/generators/create-amino-converters.js +43 -0
  21. package/main/generators/create-bundle.js +83 -0
  22. package/main/generators/create-cosmwasm-bundle.js +15 -0
  23. package/main/generators/create-custom-stargate-clients.js +100 -0
  24. package/main/generators/create-helpers.js +119 -0
  25. package/main/generators/create-index.js +75 -0
  26. package/main/generators/create-lcd-client-all.js +116 -0
  27. package/main/generators/create-lcd-client-scoped.js +89 -0
  28. package/main/generators/create-lcd-clients.js +78 -0
  29. package/main/generators/create-mcp-server.js +1853 -0
  30. package/main/generators/create-mobx-bundle.js +52 -0
  31. package/main/generators/create-msg-funcs.js +132 -0
  32. package/main/generators/create-pinia-store-bundle.js +50 -0
  33. package/main/generators/create-pinia-store.js +90 -0
  34. package/main/generators/create-query-funcs.js +133 -0
  35. package/main/generators/create-react-query-bundle.js +103 -0
  36. package/main/generators/create-registries.js +49 -0
  37. package/main/generators/create-root-readme.js +259 -0
  38. package/main/generators/create-rpc-msg-client-all.js +135 -0
  39. package/main/generators/create-rpc-msg-client-scoped.js +114 -0
  40. package/main/generators/create-rpc-msg-clients.js +116 -0
  41. package/main/generators/create-rpc-ops-bundle.js +119 -0
  42. package/main/generators/create-rpc-query-client-all.js +137 -0
  43. package/main/generators/create-rpc-query-client-scoped.js +110 -0
  44. package/main/generators/create-rpc-query-clients.js +198 -0
  45. package/main/generators/create-sdk-module-stargate-clients.js +95 -0
  46. package/main/generators/create-stargate-clients.js +96 -0
  47. package/main/generators/create-types.js +164 -0
  48. package/main/generators/customize-utils.js +50 -0
  49. package/main/helpers/__test__/internalTimestamp.js +49 -0
  50. package/main/helpers/__test__/internalTimestampBigint.js +45 -0
  51. package/main/helpers/binary-coder.js +535 -0
  52. package/main/helpers/decimals.js +111 -0
  53. package/main/helpers/external-comet.js +52 -0
  54. package/main/helpers/external-icjs.js +36 -0
  55. package/main/helpers/external.js +31 -0
  56. package/main/helpers/grpc-gateway.js +348 -0
  57. package/main/helpers/grpc-web.js +14 -0
  58. package/main/helpers/helper-func-types-interface.js +106 -0
  59. package/main/helpers/helper-func-types.js +93 -0
  60. package/main/helpers/index.js +38 -0
  61. package/main/helpers/internal-for-bigint.js +259 -0
  62. package/main/helpers/internal.js +240 -0
  63. package/main/helpers/json-safe.js +12 -0
  64. package/main/helpers/mobx.js +80 -0
  65. package/main/helpers/pinia-endpoint.js +20 -0
  66. package/main/helpers/react-query-hooks-icjs.js +223 -0
  67. package/main/helpers/react-query-hooks.js +258 -0
  68. package/main/helpers/react-query.js +93 -0
  69. package/main/helpers/registry-helper.js +229 -0
  70. package/main/helpers/types-helper.js +165 -0
  71. package/main/helpers/utf8-helper.js +146 -0
  72. package/main/helpers/varint.js +486 -0
  73. package/main/helpers/vue-query-hooks.js +226 -0
  74. package/main/imports.js +416 -0
  75. package/main/index.js +24 -0
  76. package/main/parse.js +194 -0
  77. package/main/prompt.js +64 -0
  78. package/main/protod/bufbuild.js +87 -0
  79. package/main/protod/config.js +30 -0
  80. package/main/protod/git-repo.js +58 -0
  81. package/main/protod/index.js +17 -0
  82. package/main/protod/recursive.js +134 -0
  83. package/main/protod/types.js +2 -0
  84. package/main/protod/utils.js +91 -0
  85. package/main/telescope.js +10 -0
  86. package/main/types.js +2 -0
  87. package/main/utils/common-create-bundle.js +29 -0
  88. package/main/utils/contracts.js +39 -0
  89. package/main/utils/files.js +138 -0
  90. package/main/utils/index.js +163 -0
  91. package/main/utils/unused.js +73 -0
  92. package/module/build.js +176 -0
  93. package/module/builder.js +222 -0
  94. package/module/bundle.js +128 -0
  95. package/module/bundler.js +96 -0
  96. package/module/cli.js +44 -0
  97. package/module/cmds.js +22 -0
  98. package/module/commands/download.js +94 -0
  99. package/module/commands/generate.js +123 -0
  100. package/module/commands/install.js +141 -0
  101. package/module/commands/transpile.js +169 -0
  102. package/module/contracts/generate.js +29 -0
  103. package/module/contracts/install.js +105 -0
  104. package/module/contracts/message-composer.js +29 -0
  105. package/module/contracts/react-query.js +29 -0
  106. package/module/contracts/recoil.js +29 -0
  107. package/module/file.js +18 -0
  108. package/module/generators/create-aggregated-lcd-client.js +83 -0
  109. package/module/generators/create-all-stargate-clients.js +92 -0
  110. package/module/generators/create-amino-converters.js +39 -0
  111. package/module/generators/create-bundle.js +79 -0
  112. package/module/generators/create-cosmwasm-bundle.js +11 -0
  113. package/module/generators/create-custom-stargate-clients.js +96 -0
  114. package/module/generators/create-helpers.js +112 -0
  115. package/module/generators/create-index.js +45 -0
  116. package/module/generators/create-lcd-client-all.js +89 -0
  117. package/module/generators/create-lcd-client-scoped.js +62 -0
  118. package/module/generators/create-lcd-clients.js +74 -0
  119. package/module/generators/create-mcp-server.js +1849 -0
  120. package/module/generators/create-mobx-bundle.js +25 -0
  121. package/module/generators/create-msg-funcs.js +128 -0
  122. package/module/generators/create-pinia-store-bundle.js +23 -0
  123. package/module/generators/create-pinia-store.js +86 -0
  124. package/module/generators/create-query-funcs.js +129 -0
  125. package/module/generators/create-react-query-bundle.js +76 -0
  126. package/module/generators/create-registries.js +45 -0
  127. package/module/generators/create-root-readme.js +255 -0
  128. package/module/generators/create-rpc-msg-client-all.js +108 -0
  129. package/module/generators/create-rpc-msg-client-scoped.js +87 -0
  130. package/module/generators/create-rpc-msg-clients.js +112 -0
  131. package/module/generators/create-rpc-ops-bundle.js +92 -0
  132. package/module/generators/create-rpc-query-client-all.js +110 -0
  133. package/module/generators/create-rpc-query-client-scoped.js +83 -0
  134. package/module/generators/create-rpc-query-clients.js +198 -0
  135. package/module/generators/create-sdk-module-stargate-clients.js +91 -0
  136. package/module/generators/create-stargate-clients.js +92 -0
  137. package/module/generators/create-types.js +137 -0
  138. package/module/generators/customize-utils.js +46 -0
  139. package/module/helpers/__test__/internalTimestamp.js +39 -0
  140. package/module/helpers/__test__/internalTimestampBigint.js +38 -0
  141. package/module/helpers/binary-coder.js +531 -0
  142. package/module/helpers/decimals.js +108 -0
  143. package/module/helpers/external-comet.js +49 -0
  144. package/module/helpers/external-icjs.js +33 -0
  145. package/module/helpers/external.js +28 -0
  146. package/module/helpers/grpc-gateway.js +345 -0
  147. package/module/helpers/grpc-web.js +11 -0
  148. package/module/helpers/helper-func-types-interface.js +102 -0
  149. package/module/helpers/helper-func-types.js +89 -0
  150. package/module/helpers/index.js +22 -0
  151. package/module/helpers/internal-for-bigint.js +255 -0
  152. package/module/helpers/internal.js +236 -0
  153. package/module/helpers/json-safe.js +9 -0
  154. package/module/helpers/mobx.js +77 -0
  155. package/module/helpers/pinia-endpoint.js +17 -0
  156. package/module/helpers/react-query-hooks-icjs.js +219 -0
  157. package/module/helpers/react-query-hooks.js +254 -0
  158. package/module/helpers/react-query.js +89 -0
  159. package/module/helpers/registry-helper.js +225 -0
  160. package/module/helpers/types-helper.js +161 -0
  161. package/module/helpers/utf8-helper.js +143 -0
  162. package/module/helpers/varint.js +483 -0
  163. package/module/helpers/vue-query-hooks.js +222 -0
  164. package/module/imports.js +382 -0
  165. package/module/index.js +8 -0
  166. package/module/parse.js +185 -0
  167. package/module/prompt.js +58 -0
  168. package/module/protod/bufbuild.js +76 -0
  169. package/module/protod/config.js +27 -0
  170. package/module/protod/git-repo.js +54 -0
  171. package/module/protod/index.js +1 -0
  172. package/module/protod/recursive.js +125 -0
  173. package/module/protod/types.js +1 -0
  174. package/module/protod/utils.js +77 -0
  175. package/module/telescope.js +8 -0
  176. package/module/types.js +1 -0
  177. package/module/utils/common-create-bundle.js +25 -0
  178. package/module/utils/contracts.js +33 -0
  179. package/module/utils/files.js +106 -0
  180. package/module/utils/index.js +143 -0
  181. package/module/utils/unused.js +47 -0
  182. package/package.json +115 -0
  183. package/src/build.ts +255 -0
  184. package/src/builder.ts +302 -0
  185. package/src/bundle.ts +160 -0
  186. package/src/bundler.ts +153 -0
  187. package/src/cli.js +51 -0
  188. package/src/cmds.js +25 -0
  189. package/src/commands/download.ts +120 -0
  190. package/src/commands/generate.ts +156 -0
  191. package/src/commands/install.ts +154 -0
  192. package/src/commands/transpile.ts +198 -0
  193. package/src/contracts/generate.ts +33 -0
  194. package/src/contracts/install.ts +118 -0
  195. package/src/contracts/message-composer.ts +34 -0
  196. package/src/contracts/react-query.ts +33 -0
  197. package/src/contracts/recoil.ts +32 -0
  198. package/src/file.js +20 -0
  199. package/src/generators/create-aggregated-lcd-client.ts +133 -0
  200. package/src/generators/create-all-stargate-clients.ts +121 -0
  201. package/src/generators/create-amino-converters.ts +62 -0
  202. package/src/generators/create-bundle.ts +97 -0
  203. package/src/generators/create-cosmwasm-bundle.ts +17 -0
  204. package/src/generators/create-custom-stargate-clients.ts +128 -0
  205. package/src/generators/create-helpers.ts +196 -0
  206. package/src/generators/create-index.ts +72 -0
  207. package/src/generators/create-lcd-client-all.ts +139 -0
  208. package/src/generators/create-lcd-client-scoped.ts +109 -0
  209. package/src/generators/create-lcd-clients.ts +108 -0
  210. package/src/generators/create-mcp-server.ts +1902 -0
  211. package/src/generators/create-mobx-bundle.ts +31 -0
  212. package/src/generators/create-msg-funcs.ts +219 -0
  213. package/src/generators/create-pinia-store-bundle.ts +35 -0
  214. package/src/generators/create-pinia-store.ts +121 -0
  215. package/src/generators/create-query-funcs.ts +224 -0
  216. package/src/generators/create-react-query-bundle.ts +111 -0
  217. package/src/generators/create-registries.ts +70 -0
  218. package/src/generators/create-root-readme.ts +316 -0
  219. package/src/generators/create-rpc-msg-client-all.ts +167 -0
  220. package/src/generators/create-rpc-msg-client-scoped.ts +147 -0
  221. package/src/generators/create-rpc-msg-clients.ts +165 -0
  222. package/src/generators/create-rpc-ops-bundle.ts +155 -0
  223. package/src/generators/create-rpc-query-client-all.ts +173 -0
  224. package/src/generators/create-rpc-query-client-scoped.ts +142 -0
  225. package/src/generators/create-rpc-query-clients.ts +304 -0
  226. package/src/generators/create-sdk-module-stargate-clients.ts +120 -0
  227. package/src/generators/create-stargate-clients.ts +123 -0
  228. package/src/generators/create-types.ts +236 -0
  229. package/src/generators/customize-utils.ts +54 -0
  230. package/src/helpers/__test__/internalTimestamp.test.ts +79 -0
  231. package/src/helpers/__test__/internalTimestamp.ts +58 -0
  232. package/src/helpers/__test__/internalTimestampBigint.test.ts +78 -0
  233. package/src/helpers/__test__/internalTimestampBigint.ts +58 -0
  234. package/src/helpers/binary-coder.ts +533 -0
  235. package/src/helpers/decimals.ts +108 -0
  236. package/src/helpers/external-comet.ts +49 -0
  237. package/src/helpers/external-icjs.ts +33 -0
  238. package/src/helpers/external.ts +28 -0
  239. package/src/helpers/grpc-gateway.ts +345 -0
  240. package/src/helpers/grpc-web.ts +11 -0
  241. package/src/helpers/helper-func-types-interface.ts +104 -0
  242. package/src/helpers/helper-func-types.ts +91 -0
  243. package/src/helpers/index.ts +22 -0
  244. package/src/helpers/internal-for-bigint.ts +257 -0
  245. package/src/helpers/internal.ts +238 -0
  246. package/src/helpers/json-safe.ts +11 -0
  247. package/src/helpers/mobx.ts +77 -0
  248. package/src/helpers/pinia-endpoint.ts +17 -0
  249. package/src/helpers/react-query-hooks-icjs.ts +223 -0
  250. package/src/helpers/react-query-hooks.ts +266 -0
  251. package/src/helpers/react-query.ts +101 -0
  252. package/src/helpers/registry-helper.ts +227 -0
  253. package/src/helpers/types-helper.ts +169 -0
  254. package/src/helpers/utf8-helper.ts +143 -0
  255. package/src/helpers/varint.ts +483 -0
  256. package/src/helpers/vue-query-hooks.ts +224 -0
  257. package/src/imports.ts +499 -0
  258. package/src/index.ts +12 -0
  259. package/src/parse.ts +243 -0
  260. package/src/prompt.js +65 -0
  261. package/src/protod/bufbuild.spec.ts +80 -0
  262. package/src/protod/bufbuild.ts +95 -0
  263. package/src/protod/config.ts +30 -0
  264. package/src/protod/git-repo.ts +74 -0
  265. package/src/protod/index.ts +1 -0
  266. package/src/protod/recursive.spec.ts +164 -0
  267. package/src/protod/recursive.ts +180 -0
  268. package/src/protod/test-data/.protod.config.json +42 -0
  269. package/src/protod/test-data/buf.lock +23 -0
  270. package/src/protod/test-data/buf.yaml +25 -0
  271. package/src/protod/test-data/buf2.yaml +20 -0
  272. package/src/protod/test-data/cosmos/buf.lock +23 -0
  273. package/src/protod/test-data/cosmos/crypto/secp256k1/keys.proto +38 -0
  274. package/src/protod/test-data/model.proto +101 -0
  275. package/src/protod/types.ts +55 -0
  276. package/src/protod/utils.spec.ts +68 -0
  277. package/src/protod/utils.ts +90 -0
  278. package/src/telescope.js +9 -0
  279. package/src/types.ts +46 -0
  280. package/src/utils/common-create-bundle.ts +62 -0
  281. package/src/utils/contracts.ts +37 -0
  282. package/src/utils/files.ts +145 -0
  283. package/src/utils/index.ts +150 -0
  284. package/src/utils/unused.ts +52 -0
  285. package/types/build.d.ts +41 -0
  286. package/types/builder.d.ts +50 -0
  287. package/types/bundle.d.ts +30 -0
  288. package/types/bundler.d.ts +31 -0
  289. package/types/cli.d.ts +1 -0
  290. package/types/cmds.d.ts +11 -0
  291. package/types/commands/download.d.ts +5 -0
  292. package/types/commands/generate.d.ts +2 -0
  293. package/types/commands/install.d.ts +2 -0
  294. package/types/commands/transpile.d.ts +4 -0
  295. package/types/contracts/generate.d.ts +2 -0
  296. package/types/contracts/install.d.ts +2 -0
  297. package/types/contracts/message-composer.d.ts +2 -0
  298. package/types/contracts/react-query.d.ts +2 -0
  299. package/types/contracts/recoil.d.ts +2 -0
  300. package/types/file.d.ts +2 -0
  301. package/types/generators/create-aggregated-lcd-client.d.ts +2 -0
  302. package/types/generators/create-all-stargate-clients.d.ts +3 -0
  303. package/types/generators/create-amino-converters.d.ts +3 -0
  304. package/types/generators/create-bundle.d.ts +3 -0
  305. package/types/generators/create-combined-stargate-clients.d.ts +3 -0
  306. package/types/generators/create-cosmwasm-bundle.d.ts +2 -0
  307. package/types/generators/create-custom-stargate-clients.d.ts +3 -0
  308. package/types/generators/create-helpers.d.ts +2 -0
  309. package/types/generators/create-index.d.ts +2 -0
  310. package/types/generators/create-lcd-client-all.d.ts +3 -0
  311. package/types/generators/create-lcd-client-scoped.d.ts +3 -0
  312. package/types/generators/create-lcd-clients.d.ts +3 -0
  313. package/types/generators/create-mcp-server.d.ts +3 -0
  314. package/types/generators/create-mobx-bundle.d.ts +2 -0
  315. package/types/generators/create-msg-funcs.d.ts +3 -0
  316. package/types/generators/create-pinia-store-bundle.d.ts +2 -0
  317. package/types/generators/create-pinia-store.d.ts +3 -0
  318. package/types/generators/create-query-funcs.d.ts +3 -0
  319. package/types/generators/create-react-query-bundle.d.ts +2 -0
  320. package/types/generators/create-registries.d.ts +3 -0
  321. package/types/generators/create-root-readme.d.ts +2 -0
  322. package/types/generators/create-rpc-msg-client-all.d.ts +3 -0
  323. package/types/generators/create-rpc-msg-client-scoped.d.ts +3 -0
  324. package/types/generators/create-rpc-msg-clients.d.ts +3 -0
  325. package/types/generators/create-rpc-ops-bundle.d.ts +2 -0
  326. package/types/generators/create-rpc-query-client-all.d.ts +3 -0
  327. package/types/generators/create-rpc-query-client-scoped.d.ts +3 -0
  328. package/types/generators/create-rpc-query-clients.d.ts +3 -0
  329. package/types/generators/create-scoped-stargate-clients.d.ts +3 -0
  330. package/types/generators/create-sdk-module-stargate-clients.d.ts +3 -0
  331. package/types/generators/create-stargate-clients.d.ts +3 -0
  332. package/types/generators/create-types.d.ts +3 -0
  333. package/types/generators/create-unified-stargate-clients.d.ts +3 -0
  334. package/types/generators/customize-utils.d.ts +2 -0
  335. package/types/helpers/__test__/internalTimestamp.d.ts +21 -0
  336. package/types/helpers/__test__/internalTimestampBigint.d.ts +20 -0
  337. package/types/helpers/binary-coder.d.ts +2 -0
  338. package/types/helpers/decimals.d.ts +1 -0
  339. package/types/helpers/external-comet.d.ts +1 -0
  340. package/types/helpers/external-icjs.d.ts +1 -0
  341. package/types/helpers/external.d.ts +1 -0
  342. package/types/helpers/generated-type.d.ts +1 -0
  343. package/types/helpers/grpc-gateway.d.ts +1 -0
  344. package/types/helpers/grpc-web.d.ts +1 -0
  345. package/types/helpers/helper-func-types-interface.d.ts +2 -0
  346. package/types/helpers/helper-func-types.d.ts +2 -0
  347. package/types/helpers/index.d.ts +22 -0
  348. package/types/helpers/internal-for-bigint.d.ts +2 -0
  349. package/types/helpers/internal.d.ts +2 -0
  350. package/types/helpers/internalForBigInt.d.ts +1 -0
  351. package/types/helpers/json-safe.d.ts +1 -0
  352. package/types/helpers/mobx.d.ts +1 -0
  353. package/types/helpers/pinia-endpoint.d.ts +1 -0
  354. package/types/helpers/react-query-hooks-icjs.d.ts +2 -0
  355. package/types/helpers/react-query-hooks.d.ts +2 -0
  356. package/types/helpers/react-query.d.ts +2 -0
  357. package/types/helpers/registry-helper.d.ts +2 -0
  358. package/types/helpers/types-helper.d.ts +2 -0
  359. package/types/helpers/types.d.ts +1 -0
  360. package/types/helpers/utf8-helper.d.ts +1 -0
  361. package/types/helpers/varint.d.ts +1 -0
  362. package/types/helpers/vue-query-hooks.d.ts +2 -0
  363. package/types/helpers/vue-query.d.ts +2 -0
  364. package/types/imports.d.ts +17 -0
  365. package/types/index.d.ts +6 -0
  366. package/types/parse.d.ts +15 -0
  367. package/types/prompt.d.ts +3 -0
  368. package/types/protod/bufbuild.d.ts +6 -0
  369. package/types/protod/config.d.ts +7 -0
  370. package/types/protod/git-repo.d.ts +11 -0
  371. package/types/protod/index.d.ts +1 -0
  372. package/types/protod/proto-download.d.ts +2 -0
  373. package/types/protod/recursive.d.ts +4 -0
  374. package/types/protod/types.d.ts +49 -0
  375. package/types/protod/utils.d.ts +11 -0
  376. package/types/telescope.d.ts +2 -0
  377. package/types/types.d.ts +43 -0
  378. package/types/utils/common-create-bundle.d.ts +18 -0
  379. package/types/utils/contracts.d.ts +6 -0
  380. package/types/utils/files.d.ts +5 -0
  381. package/types/utils/index.d.ts +16 -0
  382. package/types/utils/unused.d.ts +5 -0
@@ -0,0 +1,255 @@
1
+ export const getHelperForBigint = (options) => {
2
+ return `
3
+ declare var self: any | undefined;
4
+ declare var window: any | undefined;
5
+ declare var global: any | undefined;
6
+ var globalThis: any = (() => {
7
+ if (typeof globalThis !== 'undefined') return globalThis;
8
+ if (typeof self !== 'undefined') return self;
9
+ if (typeof window !== 'undefined') return window;
10
+ if (typeof global !== 'undefined') return global;
11
+ throw 'Unable to locate global object';
12
+ })();
13
+
14
+ const atob: (b64: string) => string =
15
+ globalThis.atob ||
16
+ ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
17
+
18
+ export function bytesFromBase64(b64: string): Uint8Array {
19
+ const bin = atob(b64);
20
+ const arr = new Uint8Array(bin.length);
21
+ for (let i = 0; i < bin.length; ++i) {
22
+ arr[i] = bin.charCodeAt(i);
23
+ }
24
+ return arr;
25
+ }
26
+
27
+ const btoa: (bin: string) => string =
28
+ globalThis.btoa ||
29
+ ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
30
+
31
+ export function base64FromBytes(arr: Uint8Array): string {
32
+ const bin: string[] = [];
33
+ arr.forEach((byte) => {
34
+ bin.push(String.fromCharCode(byte));
35
+ });
36
+ return btoa(bin.join(''));
37
+ }
38
+
39
+ export interface AminoHeight {
40
+ readonly revision_number?: string;
41
+ readonly revision_height?: string;
42
+ }
43
+
44
+ export function omitDefault<T extends string | number | bigint | boolean>(
45
+ input: T
46
+ ): T | undefined {
47
+ if (typeof input === 'string') {
48
+ return input === '' ? undefined : input;
49
+ }
50
+
51
+ if (typeof input === 'number') {
52
+ return input === 0 ? undefined : input;
53
+ }
54
+
55
+ if (typeof input === "boolean"){
56
+ return input === false ? undefined : input;
57
+ }
58
+
59
+ if (typeof input === 'bigint') {
60
+ return input === BigInt(0) ? undefined : input;
61
+ }
62
+
63
+ throw new Error(\`Got unsupported type \${typeof input}\`);
64
+ }
65
+
66
+ interface Duration {
67
+ /**
68
+ * Signed seconds of the span of time. Must be from -315,576,000,000
69
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
70
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
71
+ */
72
+ seconds: bigint;
73
+ /**
74
+ * Signed fractions of a second at nanosecond resolution of the span
75
+ * of time. Durations less than one second are represented with a 0
76
+ * \`seconds\` field and a positive or negative \`nanos\` field. For durations
77
+ * of one second or more, a non-zero value for the \`nanos\` field must be
78
+ * of the same sign as the \`seconds\` field. Must be from -999,999,999
79
+ * to +999,999,999 inclusive.
80
+ */
81
+
82
+ nanos: number;
83
+ }
84
+
85
+ export function toDuration(duration: string): Duration {
86
+ return {
87
+ seconds: BigInt(Math.floor(parseInt(duration) / 1000000000)),
88
+ nanos: parseInt(duration) % 1000000000
89
+ };
90
+ }
91
+
92
+ export function fromDuration(duration: Duration): string {
93
+ return (
94
+ parseInt(duration.seconds.toString()) * 1000000000 +
95
+ duration.nanos
96
+ ).toString();
97
+ }
98
+
99
+ export function isSet(value: any): boolean {
100
+ return value !== null && value !== undefined;
101
+ }
102
+
103
+ export function isObject(value: any): boolean {
104
+ return typeof value === 'object' && value !== null;
105
+ }
106
+
107
+ export interface PageRequest {
108
+ key: Uint8Array;
109
+ offset: bigint;
110
+ limit: bigint;
111
+ countTotal: boolean;
112
+ reverse: boolean;
113
+ }
114
+
115
+ export interface PageRequestParams {
116
+ 'pagination.key'?: string;
117
+ 'pagination.offset'?: string;
118
+ 'pagination.limit'?: string;
119
+ 'pagination.count_total'?: boolean;
120
+ 'pagination.reverse'?: boolean;
121
+ }
122
+
123
+ export interface Params {
124
+ params: PageRequestParams;
125
+ }
126
+
127
+ export const setPaginationParams = (
128
+ options: Params,
129
+ pagination?: PageRequest
130
+ ) => {
131
+ if (!pagination) {
132
+ return options;
133
+ }
134
+
135
+ if (typeof pagination?.countTotal !== 'undefined') {
136
+ options.params['pagination.count_total'] = pagination.countTotal;
137
+ }
138
+ if (typeof pagination?.key !== 'undefined') {
139
+ // String to Uint8Array
140
+ // let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
141
+
142
+ // Uint8Array to String
143
+ options.params['pagination.key'] = Buffer.from(pagination.key).toString(
144
+ 'base64'
145
+ );
146
+ }
147
+ if (typeof pagination?.limit !== 'undefined') {
148
+ options.params['pagination.limit'] = pagination.limit.toString();
149
+ }
150
+ if (typeof pagination?.offset !== 'undefined') {
151
+ options.params['pagination.offset'] = pagination.offset.toString();
152
+ }
153
+ if (typeof pagination?.reverse !== 'undefined') {
154
+ options.params['pagination.reverse'] = pagination.reverse;
155
+ }
156
+
157
+ return options;
158
+ };
159
+
160
+ type Builtin =
161
+ | Date
162
+ | Function
163
+ | Uint8Array
164
+ | string
165
+ | number
166
+ | bigint
167
+ | boolean
168
+ | undefined;
169
+
170
+ export type DeepPartial<T> = T extends Builtin
171
+ ? T
172
+ : T extends Array<infer U>
173
+ ? Array<DeepPartial<U>>
174
+ : T extends ReadonlyArray<infer U>
175
+ ? ReadonlyArray<DeepPartial<U>>
176
+ : T extends {}
177
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
178
+ : Partial<T>;
179
+
180
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
181
+ export type Exact<P, I extends P> = P extends Builtin
182
+ ? P
183
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
184
+ Exclude<keyof I, KeysOfUnion<P>>,
185
+ never
186
+ >;
187
+
188
+ export interface Rpc {
189
+ request(
190
+ service: string,
191
+ method: string,
192
+ data: Uint8Array
193
+ ): Promise<Uint8Array>;
194
+ }
195
+
196
+ export function isRpc(rpc: unknown): rpc is Rpc {
197
+ return rpc !== null && rpc !== undefined && typeof (rpc as Rpc).request === 'function';
198
+ }
199
+
200
+ interface Timestamp {
201
+ /**
202
+ * Represents seconds of UTC time since Unix epoch
203
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
204
+ * 9999-12-31T23:59:59Z inclusive.
205
+ */
206
+ seconds: bigint;
207
+ /**
208
+ * Non-negative fractions of a second at nanosecond resolution. Negative
209
+ * second values with fractions must still have non-negative nanos values
210
+ * that count forward in time. Must be from 0 to 999,999,999
211
+ * inclusive.
212
+ */
213
+
214
+ nanos: number;
215
+ }
216
+
217
+ export function toTimestamp(date: Date): Timestamp {
218
+ const seconds = numberToLong(date.getTime() / 1_000);
219
+ const nanos = (date.getTime() % 1000) * 1000000;
220
+ return {
221
+ seconds,
222
+ nanos
223
+ };
224
+ }
225
+
226
+ export function fromTimestamp(t: Timestamp): Date {
227
+ let millis = Number(t.seconds) * 1000;
228
+ millis += t.nanos / 1000000;
229
+ return new Date(millis);
230
+ }
231
+
232
+ const timestampFromJSON = (object: any): Timestamp => {
233
+ return {
234
+ seconds: isSet(object.seconds)
235
+ ? BigInt(object.seconds.toString())
236
+ : BigInt(0),
237
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0
238
+ };
239
+ };
240
+
241
+ export function fromJsonTimestamp(o: any): Timestamp {
242
+ if (o instanceof Date) {
243
+ return toTimestamp(o);
244
+ } else if (typeof o === 'string') {
245
+ return toTimestamp(new Date(o));
246
+ } else {
247
+ return timestampFromJSON(o);
248
+ }
249
+ }
250
+
251
+ function numberToLong(number: number) {
252
+ return BigInt(Math.trunc(number));
253
+ }
254
+ `;
255
+ };
@@ -0,0 +1,236 @@
1
+ export const getHelper = (options) => {
2
+ return `import * as _m0 from "protobufjs/minimal";
3
+ import Long from 'long';
4
+
5
+ // @ts-ignore
6
+ if (_m0.util.Long !== Long) {
7
+ _m0.util.Long = (Long as any);
8
+
9
+ _m0.configure();
10
+ }
11
+
12
+ export { Long };
13
+
14
+ declare var self: any | undefined;
15
+ declare var window: any | undefined;
16
+ declare var global: any | undefined;
17
+ var globalThis: any = (() => {
18
+ if (typeof globalThis !== 'undefined') return globalThis;
19
+ if (typeof self !== 'undefined') return self;
20
+ if (typeof window !== 'undefined') return window;
21
+ if (typeof global !== 'undefined') return global;
22
+ throw 'Unable to locate global object';
23
+ })();
24
+
25
+ const atob: (b64: string) => string =
26
+ globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
27
+
28
+ export function bytesFromBase64(b64: string): Uint8Array {
29
+ const bin = atob(b64);
30
+ const arr = new Uint8Array(bin.length);
31
+ for (let i = 0; i < bin.length; ++i) {
32
+ arr[i] = bin.charCodeAt(i);
33
+ }
34
+ return arr;
35
+ }
36
+
37
+ const btoa: (bin: string) => string =
38
+ globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
39
+
40
+ export function base64FromBytes(arr: Uint8Array): string {
41
+ const bin: string[] = [];
42
+ arr.forEach((byte) => {
43
+ bin.push(String.fromCharCode(byte));
44
+ });
45
+ return btoa(bin.join(''));
46
+ }
47
+
48
+ export interface AminoHeight {
49
+ readonly revision_number?: string;
50
+ readonly revision_height?: string;
51
+ };
52
+
53
+ export function omitDefault<T extends string | number | Long | boolean>(input: T): T | undefined {
54
+ if (typeof input === "string") {
55
+ return input === "" ? undefined : input;
56
+ }
57
+
58
+ if (typeof input === "number") {
59
+ return input === 0 ? undefined : input;
60
+ }
61
+
62
+ if (typeof input === "boolean"){
63
+ return input === false ? undefined : input;
64
+ }
65
+
66
+ if (Long.isLong(input)) {
67
+ return (input as Long).isZero() ? undefined : input;
68
+ }
69
+
70
+ throw new Error(\`Got unsupported type \${typeof input}\`);
71
+ };
72
+
73
+ interface Duration {
74
+ /**
75
+ * Signed seconds of the span of time. Must be from -315,576,000,000
76
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
77
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
78
+ */
79
+ seconds: Long;
80
+ /**
81
+ * Signed fractions of a second at nanosecond resolution of the span
82
+ * of time. Durations less than one second are represented with a 0
83
+ * \`seconds\` field and a positive or negative \`nanos\` field. For durations
84
+ * of one second or more, a non-zero value for the \`nanos\` field must be
85
+ * of the same sign as the \`seconds\` field. Must be from -999,999,999
86
+ * to +999,999,999 inclusive.
87
+ */
88
+
89
+ nanos: number;
90
+ }
91
+
92
+ export function toDuration(duration: string): Duration {
93
+ return {
94
+ seconds: Long.fromNumber(Math.floor(parseInt(duration) / 1000000000)),
95
+ nanos: parseInt(duration) % 1000000000
96
+ };
97
+ };
98
+
99
+ export function fromDuration(duration: Duration): string {
100
+ return (parseInt(duration.seconds.toString()) * 1000000000 + duration.nanos).toString();
101
+ };
102
+
103
+ export function isSet(value: any): boolean {
104
+ return value !== null && value !== undefined;
105
+ };
106
+
107
+ export function isObject(value: any): boolean {
108
+ return typeof value === 'object' && value !== null;
109
+ };
110
+
111
+ export interface PageRequest {
112
+ key: Uint8Array;
113
+ offset: Long;
114
+ limit: Long;
115
+ countTotal: boolean;
116
+ reverse: boolean;
117
+ };
118
+
119
+ export interface PageRequestParams {
120
+ "pagination.key"?: string;
121
+ "pagination.offset"?: string;
122
+ "pagination.limit"?: string;
123
+ "pagination.count_total"?: boolean;
124
+ "pagination.reverse"?: boolean;
125
+ };
126
+
127
+ export interface Params {
128
+ params: PageRequestParams;
129
+ };
130
+
131
+ export const setPaginationParams = (options: Params, pagination?: PageRequest) => {
132
+
133
+ if (!pagination) {
134
+ return options;
135
+ }
136
+
137
+ if (typeof pagination?.countTotal !== "undefined") {
138
+ options.params['pagination.count_total'] = pagination.countTotal;
139
+ }
140
+ if (typeof pagination?.key !== "undefined") {
141
+ // String to Uint8Array
142
+ // let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
143
+
144
+ // Uint8Array to String
145
+ options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
146
+ }
147
+ if (typeof pagination?.limit !== "undefined") {
148
+ options.params["pagination.limit"] = pagination.limit.toString()
149
+ }
150
+ if (typeof pagination?.offset !== "undefined") {
151
+ options.params["pagination.offset"] = pagination.offset.toString()
152
+ }
153
+ if (typeof pagination?.reverse !== "undefined") {
154
+ options.params['pagination.reverse'] = pagination.reverse;
155
+ }
156
+
157
+ return options;
158
+ };
159
+
160
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
161
+
162
+ export type DeepPartial<T> = T extends Builtin
163
+ ? T
164
+ : T extends Long
165
+ ? string | number | Long
166
+ : T extends Array<infer U>
167
+ ? Array<DeepPartial<U>>
168
+ : T extends ReadonlyArray<infer U>
169
+ ? ReadonlyArray<DeepPartial<U>>
170
+ : T extends {}
171
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
172
+ : Partial<T>;
173
+
174
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
175
+ export type Exact<P, I extends P> = P extends Builtin
176
+ ? P
177
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
178
+
179
+ export interface Rpc {
180
+ request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
181
+ };
182
+
183
+ interface Timestamp {
184
+ /**
185
+ * Represents seconds of UTC time since Unix epoch
186
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
187
+ * 9999-12-31T23:59:59Z inclusive.
188
+ */
189
+ seconds: Long;
190
+ /**
191
+ * Non-negative fractions of a second at nanosecond resolution. Negative
192
+ * second values with fractions must still have non-negative nanos values
193
+ * that count forward in time. Must be from 0 to 999,999,999
194
+ * inclusive.
195
+ */
196
+
197
+ nanos: number;
198
+ }
199
+
200
+ export function toTimestamp(date: Date): Timestamp {
201
+ const seconds = numberToLong(date.getTime() / 1_000);
202
+ const nanos = date.getTime() % 1000 * 1000000;
203
+ return {
204
+ seconds,
205
+ nanos
206
+ };
207
+ };
208
+
209
+ export function fromTimestamp(t: Timestamp): Date {
210
+ let millis = t.seconds.toNumber() * 1000;
211
+ millis += t.nanos / 1000000;
212
+ return new Date(millis);
213
+ };
214
+
215
+ const timestampFromJSON = (object: any): Timestamp => {
216
+ return {
217
+ seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO,
218
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
219
+ };
220
+ }
221
+
222
+ export function fromJsonTimestamp(o: any): Timestamp {
223
+ if (o instanceof Date) {
224
+ return toTimestamp(o);
225
+ } else if (typeof o === "string") {
226
+ return toTimestamp(new Date(o));
227
+ } else {
228
+ return timestampFromJSON(o);
229
+ }
230
+ }
231
+
232
+ function numberToLong(number: number) {
233
+ return Long.fromNumber(number);
234
+ }
235
+ `;
236
+ };
@@ -0,0 +1,9 @@
1
+ export const jsonSafe = `
2
+ export type JsonSafe<T> = T extends Uint8Array | bigint | Date
3
+ ? string
4
+ : T extends Array<infer U>
5
+ ? Array<JsonSafe<U>>
6
+ : T extends object
7
+ ? { [K in keyof T]: JsonSafe<T[K]> }
8
+ : T;
9
+ `;
@@ -0,0 +1,77 @@
1
+ export const mobx = `
2
+ import {
3
+ makeAutoObservable,
4
+ runInAction
5
+ } from 'mobx';
6
+
7
+ import { QueryStatus } from '@tanstack/react-query';
8
+
9
+ export interface MobxResponse<T> {
10
+ data: T | undefined;
11
+ isSuccess: boolean;
12
+ isLoading: boolean;
13
+ refetch: () => Promise<void>;
14
+ }
15
+
16
+ export class QueryStore<Request, Response> {
17
+ state?: QueryStatus;
18
+ request?: Request;
19
+ response?: Response;
20
+ fetchFunc?: (request: Request) => Promise<Response>;
21
+
22
+ constructor(fetchFunc?: (request: Request) => Promise<Response>) {
23
+ this.fetchFunc = fetchFunc;
24
+ makeAutoObservable(this)
25
+ }
26
+
27
+ get isLoading() {
28
+ return this.state === 'loading';
29
+ }
30
+
31
+ get isSuccess() {
32
+ return this.state === 'success';
33
+ }
34
+
35
+ refetch = async (): Promise<void> => {
36
+ runInAction(() => {
37
+ this.response = void 0;
38
+ this.state = 'loading';
39
+ });
40
+ try {
41
+ if (!this.fetchFunc)
42
+ throw new Error(
43
+ 'Query Service not initialized or request function not implemented'
44
+ );
45
+ if (!this.request) throw new Error('Request not provided');
46
+ const response = await this.fetchFunc(this.request);
47
+ runInAction(() => {
48
+ this.response = response;
49
+ this.state = 'success';
50
+ });
51
+ console.log(
52
+ '%cquery.rpc.Query.ts line:572 this.state',
53
+ 'color: #007acc;',
54
+ this.state,
55
+ this.response
56
+ );
57
+ } catch (e) {
58
+ console.error(e);
59
+ runInAction(() => {
60
+ this.state = 'error';
61
+ });
62
+ }
63
+ }
64
+
65
+ getData(request?: Request): MobxResponse<Response> {
66
+ runInAction(() => {
67
+ this.request = request;
68
+ });
69
+ return {
70
+ data: this.response,
71
+ isSuccess: this.isSuccess,
72
+ isLoading: this.isLoading,
73
+ refetch: this.refetch,
74
+ };
75
+ }
76
+ }
77
+ `;
@@ -0,0 +1,17 @@
1
+ export const pinia = `
2
+ import { defineStore } from "pinia";
3
+ import type { LCDClient } from '@cosmology/lcd';
4
+
5
+ export const useEndpoint = defineStore('pinia.endpoint', {
6
+ state: () => {
7
+ return {
8
+ restClient: {} as LCDClient,
9
+ }
10
+ },
11
+ actions: {
12
+ setRestClient(client: LCDClient) {
13
+ this.restClient = client
14
+ }
15
+ }
16
+ })
17
+ `;