@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,257 @@
1
+ import { TelescopeOptions } from "@cosmology/types";
2
+
3
+ export const getHelperForBigint = (options: TelescopeOptions) => {
4
+ return `
5
+ declare var self: any | undefined;
6
+ declare var window: any | undefined;
7
+ declare var global: any | undefined;
8
+ var globalThis: any = (() => {
9
+ if (typeof globalThis !== 'undefined') return globalThis;
10
+ if (typeof self !== 'undefined') return self;
11
+ if (typeof window !== 'undefined') return window;
12
+ if (typeof global !== 'undefined') return global;
13
+ throw 'Unable to locate global object';
14
+ })();
15
+
16
+ const atob: (b64: string) => string =
17
+ globalThis.atob ||
18
+ ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
19
+
20
+ export function bytesFromBase64(b64: string): Uint8Array {
21
+ const bin = atob(b64);
22
+ const arr = new Uint8Array(bin.length);
23
+ for (let i = 0; i < bin.length; ++i) {
24
+ arr[i] = bin.charCodeAt(i);
25
+ }
26
+ return arr;
27
+ }
28
+
29
+ const btoa: (bin: string) => string =
30
+ globalThis.btoa ||
31
+ ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
32
+
33
+ export function base64FromBytes(arr: Uint8Array): string {
34
+ const bin: string[] = [];
35
+ arr.forEach((byte) => {
36
+ bin.push(String.fromCharCode(byte));
37
+ });
38
+ return btoa(bin.join(''));
39
+ }
40
+
41
+ export interface AminoHeight {
42
+ readonly revision_number?: string;
43
+ readonly revision_height?: string;
44
+ }
45
+
46
+ export function omitDefault<T extends string | number | bigint | boolean>(
47
+ input: T
48
+ ): T | undefined {
49
+ if (typeof input === 'string') {
50
+ return input === '' ? undefined : input;
51
+ }
52
+
53
+ if (typeof input === 'number') {
54
+ return input === 0 ? undefined : input;
55
+ }
56
+
57
+ if (typeof input === "boolean"){
58
+ return input === false ? undefined : input;
59
+ }
60
+
61
+ if (typeof input === 'bigint') {
62
+ return input === BigInt(0) ? undefined : input;
63
+ }
64
+
65
+ throw new Error(\`Got unsupported type \${typeof input}\`);
66
+ }
67
+
68
+ interface Duration {
69
+ /**
70
+ * Signed seconds of the span of time. Must be from -315,576,000,000
71
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
72
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
73
+ */
74
+ seconds: bigint;
75
+ /**
76
+ * Signed fractions of a second at nanosecond resolution of the span
77
+ * of time. Durations less than one second are represented with a 0
78
+ * \`seconds\` field and a positive or negative \`nanos\` field. For durations
79
+ * of one second or more, a non-zero value for the \`nanos\` field must be
80
+ * of the same sign as the \`seconds\` field. Must be from -999,999,999
81
+ * to +999,999,999 inclusive.
82
+ */
83
+
84
+ nanos: number;
85
+ }
86
+
87
+ export function toDuration(duration: string): Duration {
88
+ return {
89
+ seconds: BigInt(Math.floor(parseInt(duration) / 1000000000)),
90
+ nanos: parseInt(duration) % 1000000000
91
+ };
92
+ }
93
+
94
+ export function fromDuration(duration: Duration): string {
95
+ return (
96
+ parseInt(duration.seconds.toString()) * 1000000000 +
97
+ duration.nanos
98
+ ).toString();
99
+ }
100
+
101
+ export function isSet(value: any): boolean {
102
+ return value !== null && value !== undefined;
103
+ }
104
+
105
+ export function isObject(value: any): boolean {
106
+ return typeof value === 'object' && value !== null;
107
+ }
108
+
109
+ export interface PageRequest {
110
+ key: Uint8Array;
111
+ offset: bigint;
112
+ limit: bigint;
113
+ countTotal: boolean;
114
+ reverse: boolean;
115
+ }
116
+
117
+ export interface PageRequestParams {
118
+ 'pagination.key'?: string;
119
+ 'pagination.offset'?: string;
120
+ 'pagination.limit'?: string;
121
+ 'pagination.count_total'?: boolean;
122
+ 'pagination.reverse'?: boolean;
123
+ }
124
+
125
+ export interface Params {
126
+ params: PageRequestParams;
127
+ }
128
+
129
+ export const setPaginationParams = (
130
+ options: Params,
131
+ 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(
146
+ 'base64'
147
+ );
148
+ }
149
+ if (typeof pagination?.limit !== 'undefined') {
150
+ options.params['pagination.limit'] = pagination.limit.toString();
151
+ }
152
+ if (typeof pagination?.offset !== 'undefined') {
153
+ options.params['pagination.offset'] = pagination.offset.toString();
154
+ }
155
+ if (typeof pagination?.reverse !== 'undefined') {
156
+ options.params['pagination.reverse'] = pagination.reverse;
157
+ }
158
+
159
+ return options;
160
+ };
161
+
162
+ type Builtin =
163
+ | Date
164
+ | Function
165
+ | Uint8Array
166
+ | string
167
+ | number
168
+ | bigint
169
+ | boolean
170
+ | undefined;
171
+
172
+ export type DeepPartial<T> = T extends Builtin
173
+ ? T
174
+ : T extends Array<infer U>
175
+ ? Array<DeepPartial<U>>
176
+ : T extends ReadonlyArray<infer U>
177
+ ? ReadonlyArray<DeepPartial<U>>
178
+ : T extends {}
179
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
180
+ : Partial<T>;
181
+
182
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
183
+ export type Exact<P, I extends P> = P extends Builtin
184
+ ? P
185
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
186
+ Exclude<keyof I, KeysOfUnion<P>>,
187
+ never
188
+ >;
189
+
190
+ export interface Rpc {
191
+ request(
192
+ service: string,
193
+ method: string,
194
+ data: Uint8Array
195
+ ): Promise<Uint8Array>;
196
+ }
197
+
198
+ export function isRpc(rpc: unknown): rpc is Rpc {
199
+ return rpc !== null && rpc !== undefined && typeof (rpc as Rpc).request === 'function';
200
+ }
201
+
202
+ interface Timestamp {
203
+ /**
204
+ * Represents seconds of UTC time since Unix epoch
205
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
206
+ * 9999-12-31T23:59:59Z inclusive.
207
+ */
208
+ seconds: bigint;
209
+ /**
210
+ * Non-negative fractions of a second at nanosecond resolution. Negative
211
+ * second values with fractions must still have non-negative nanos values
212
+ * that count forward in time. Must be from 0 to 999,999,999
213
+ * inclusive.
214
+ */
215
+
216
+ nanos: number;
217
+ }
218
+
219
+ export function toTimestamp(date: Date): Timestamp {
220
+ const seconds = numberToLong(date.getTime() / 1_000);
221
+ const nanos = (date.getTime() % 1000) * 1000000;
222
+ return {
223
+ seconds,
224
+ nanos
225
+ };
226
+ }
227
+
228
+ export function fromTimestamp(t: Timestamp): Date {
229
+ let millis = Number(t.seconds) * 1000;
230
+ millis += t.nanos / 1000000;
231
+ return new Date(millis);
232
+ }
233
+
234
+ const timestampFromJSON = (object: any): Timestamp => {
235
+ return {
236
+ seconds: isSet(object.seconds)
237
+ ? BigInt(object.seconds.toString())
238
+ : BigInt(0),
239
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0
240
+ };
241
+ };
242
+
243
+ export function fromJsonTimestamp(o: any): Timestamp {
244
+ if (o instanceof Date) {
245
+ return toTimestamp(o);
246
+ } else if (typeof o === 'string') {
247
+ return toTimestamp(new Date(o));
248
+ } else {
249
+ return timestampFromJSON(o);
250
+ }
251
+ }
252
+
253
+ function numberToLong(number: number) {
254
+ return BigInt(Math.trunc(number));
255
+ }
256
+ `;
257
+ };
@@ -0,0 +1,238 @@
1
+ import { TelescopeOptions } from "@cosmology/types";
2
+
3
+ export const getHelper = (options: TelescopeOptions) => {
4
+ return `import * as _m0 from "protobufjs/minimal";
5
+ import Long from 'long';
6
+
7
+ // @ts-ignore
8
+ if (_m0.util.Long !== Long) {
9
+ _m0.util.Long = (Long as any);
10
+
11
+ _m0.configure();
12
+ }
13
+
14
+ export { Long };
15
+
16
+ declare var self: any | undefined;
17
+ declare var window: any | undefined;
18
+ declare var global: any | undefined;
19
+ var globalThis: any = (() => {
20
+ if (typeof globalThis !== 'undefined') return globalThis;
21
+ if (typeof self !== 'undefined') return self;
22
+ if (typeof window !== 'undefined') return window;
23
+ if (typeof global !== 'undefined') return global;
24
+ throw 'Unable to locate global object';
25
+ })();
26
+
27
+ const atob: (b64: string) => string =
28
+ globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
29
+
30
+ export function bytesFromBase64(b64: string): Uint8Array {
31
+ const bin = atob(b64);
32
+ const arr = new Uint8Array(bin.length);
33
+ for (let i = 0; i < bin.length; ++i) {
34
+ arr[i] = bin.charCodeAt(i);
35
+ }
36
+ return arr;
37
+ }
38
+
39
+ const btoa: (bin: string) => string =
40
+ globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
41
+
42
+ export function base64FromBytes(arr: Uint8Array): string {
43
+ const bin: string[] = [];
44
+ arr.forEach((byte) => {
45
+ bin.push(String.fromCharCode(byte));
46
+ });
47
+ return btoa(bin.join(''));
48
+ }
49
+
50
+ export interface AminoHeight {
51
+ readonly revision_number?: string;
52
+ readonly revision_height?: string;
53
+ };
54
+
55
+ export function omitDefault<T extends string | number | Long | boolean>(input: T): T | undefined {
56
+ if (typeof input === "string") {
57
+ return input === "" ? undefined : input;
58
+ }
59
+
60
+ if (typeof input === "number") {
61
+ return input === 0 ? undefined : input;
62
+ }
63
+
64
+ if (typeof input === "boolean"){
65
+ return input === false ? undefined : input;
66
+ }
67
+
68
+ if (Long.isLong(input)) {
69
+ return (input as Long).isZero() ? undefined : input;
70
+ }
71
+
72
+ throw new Error(\`Got unsupported type \${typeof input}\`);
73
+ };
74
+
75
+ interface Duration {
76
+ /**
77
+ * Signed seconds of the span of time. Must be from -315,576,000,000
78
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
79
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
80
+ */
81
+ seconds: Long;
82
+ /**
83
+ * Signed fractions of a second at nanosecond resolution of the span
84
+ * of time. Durations less than one second are represented with a 0
85
+ * \`seconds\` field and a positive or negative \`nanos\` field. For durations
86
+ * of one second or more, a non-zero value for the \`nanos\` field must be
87
+ * of the same sign as the \`seconds\` field. Must be from -999,999,999
88
+ * to +999,999,999 inclusive.
89
+ */
90
+
91
+ nanos: number;
92
+ }
93
+
94
+ export function toDuration(duration: string): Duration {
95
+ return {
96
+ seconds: Long.fromNumber(Math.floor(parseInt(duration) / 1000000000)),
97
+ nanos: parseInt(duration) % 1000000000
98
+ };
99
+ };
100
+
101
+ export function fromDuration(duration: Duration): string {
102
+ return (parseInt(duration.seconds.toString()) * 1000000000 + duration.nanos).toString();
103
+ };
104
+
105
+ export function isSet(value: any): boolean {
106
+ return value !== null && value !== undefined;
107
+ };
108
+
109
+ export function isObject(value: any): boolean {
110
+ return typeof value === 'object' && value !== null;
111
+ };
112
+
113
+ export interface PageRequest {
114
+ key: Uint8Array;
115
+ offset: Long;
116
+ limit: Long;
117
+ countTotal: boolean;
118
+ reverse: boolean;
119
+ };
120
+
121
+ export interface PageRequestParams {
122
+ "pagination.key"?: string;
123
+ "pagination.offset"?: string;
124
+ "pagination.limit"?: string;
125
+ "pagination.count_total"?: boolean;
126
+ "pagination.reverse"?: boolean;
127
+ };
128
+
129
+ export interface Params {
130
+ params: PageRequestParams;
131
+ };
132
+
133
+ export const setPaginationParams = (options: Params, pagination?: PageRequest) => {
134
+
135
+ if (!pagination) {
136
+ return options;
137
+ }
138
+
139
+ if (typeof pagination?.countTotal !== "undefined") {
140
+ options.params['pagination.count_total'] = pagination.countTotal;
141
+ }
142
+ if (typeof pagination?.key !== "undefined") {
143
+ // String to Uint8Array
144
+ // let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
145
+
146
+ // Uint8Array to String
147
+ options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
148
+ }
149
+ if (typeof pagination?.limit !== "undefined") {
150
+ options.params["pagination.limit"] = pagination.limit.toString()
151
+ }
152
+ if (typeof pagination?.offset !== "undefined") {
153
+ options.params["pagination.offset"] = pagination.offset.toString()
154
+ }
155
+ if (typeof pagination?.reverse !== "undefined") {
156
+ options.params['pagination.reverse'] = pagination.reverse;
157
+ }
158
+
159
+ return options;
160
+ };
161
+
162
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
163
+
164
+ export type DeepPartial<T> = T extends Builtin
165
+ ? T
166
+ : T extends Long
167
+ ? string | number | Long
168
+ : T extends Array<infer U>
169
+ ? Array<DeepPartial<U>>
170
+ : T extends ReadonlyArray<infer U>
171
+ ? ReadonlyArray<DeepPartial<U>>
172
+ : T extends {}
173
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
174
+ : Partial<T>;
175
+
176
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
177
+ export type Exact<P, I extends P> = P extends Builtin
178
+ ? P
179
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
180
+
181
+ export interface Rpc {
182
+ request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
183
+ };
184
+
185
+ interface Timestamp {
186
+ /**
187
+ * Represents seconds of UTC time since Unix epoch
188
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
189
+ * 9999-12-31T23:59:59Z inclusive.
190
+ */
191
+ seconds: Long;
192
+ /**
193
+ * Non-negative fractions of a second at nanosecond resolution. Negative
194
+ * second values with fractions must still have non-negative nanos values
195
+ * that count forward in time. Must be from 0 to 999,999,999
196
+ * inclusive.
197
+ */
198
+
199
+ nanos: number;
200
+ }
201
+
202
+ export function toTimestamp(date: Date): Timestamp {
203
+ const seconds = numberToLong(date.getTime() / 1_000);
204
+ const nanos = date.getTime() % 1000 * 1000000;
205
+ return {
206
+ seconds,
207
+ nanos
208
+ };
209
+ };
210
+
211
+ export function fromTimestamp(t: Timestamp): Date {
212
+ let millis = t.seconds.toNumber() * 1000;
213
+ millis += t.nanos / 1000000;
214
+ return new Date(millis);
215
+ };
216
+
217
+ const timestampFromJSON = (object: any): Timestamp => {
218
+ return {
219
+ seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO,
220
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
221
+ };
222
+ }
223
+
224
+ export function fromJsonTimestamp(o: any): Timestamp {
225
+ if (o instanceof Date) {
226
+ return toTimestamp(o);
227
+ } else if (typeof o === "string") {
228
+ return toTimestamp(new Date(o));
229
+ } else {
230
+ return timestampFromJSON(o);
231
+ }
232
+ }
233
+
234
+ function numberToLong(number: number) {
235
+ return Long.fromNumber(number);
236
+ }
237
+ `;
238
+ }
@@ -0,0 +1,11 @@
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
+ `;
10
+
11
+
@@ -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
+ `;