@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
package/README.md ADDED
@@ -0,0 +1,1529 @@
1
+ # Telescope 🔭
2
+
3
+ <p align="center">
4
+ <img width="280" src="https://user-images.githubusercontent.com/545047/175660665-5cbde84b-0928-4e59-ab56-be6adb2f3a7e.png"/>
5
+ </p>
6
+
7
+ <p align="center" width="100%">
8
+ <a href="https://github.com/hyperweb-io/telescope/actions/workflows/run-tests.yaml">
9
+ <img height="20" src="https://github.com/hyperweb-io/telescope/actions/workflows/run-tests.yaml/badge.svg" />
10
+ </a>
11
+ <a href="https://github.com/hyperweb-io/lib-count">
12
+ <img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fhyperweb-io%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Ftelescope%2Ftotal.json"/>
13
+ </a>
14
+ <a href="https://github.com/hyperweb-io/lib-count">
15
+ <img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fhyperweb-io%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Ftelescope%2Fmonthly.json"/>
16
+ </a>
17
+ <br />
18
+ <a href="https://github.com/hyperweb-io/telescope/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
19
+ <a href="https://github.com/hyperweb-io/telescope/blob/main/LICENSE-Apache"><img height="20" src="https://img.shields.io/badge/license-Apache-blue.svg"/></a>
20
+ <a href="https://www.npmjs.com/package/@hyperweb/telescope"><img height="20" src="https://img.shields.io/github/package-json/v/hyperweb-io/telescope?filename=packages%2Ftelescope%2Fpackage.json"/></a>
21
+ </p>
22
+
23
+ <p align="center">
24
+ <img src="https://user-images.githubusercontent.com/545047/178129981-5a7d18ed-d2b5-4d85-b828-ca084d38501e.png"/>
25
+ </p>
26
+
27
+ Telescope serves as the TypeScript Companion for CosmJS, used to generate developer-friendly TypeScript libraries for Cosmos blockchains. As a TypeScript transpiler for Cosmos Protobufs, akin to a "babel for the Cosmos", simply point to your protobuffer files and create full-typed libraries for teams to build dApps on your blockchain.
28
+
29
+ The following blockchain libraries (generated by Telescope) are available via npm
30
+
31
+ * [osmojs](https://www.npmjs.com/package/osmojs)
32
+ * [dydx](https://www.npmjs.com/package/@dydxprotocol/v4-client-js)
33
+ * [stargazejs](https://www.npmjs.com/package/stargazejs)
34
+ * [juno-network](https://www.npmjs.com/package/juno-network)
35
+ * [stridejs](https://www.npmjs.com/package/stridejs)
36
+ * [injectivejs](https://www.npmjs.com/package/injectivejs)
37
+ * [quicksilverjs](https://www.npmjs.com/package/quicksilverjs)
38
+
39
+ 🎥 [Checkout our video course](https://cosmology.zone/learn/telescope) to learn how to use `telescope`!
40
+
41
+ ## Table of contents
42
+
43
+ - [Telescope 🔭](#telescope-)
44
+ - [Table of contents](#table-of-contents)
45
+ - [Quickstart](#quickstart)
46
+ - [Generate](#generate)
47
+ - [Add Protobufs](#add-protobufs)
48
+ - [Transpile](#transpile)
49
+ - [Transpile with CLI](#transpile-with-cli)
50
+ - [Build](#build)
51
+ - [Publishing](#publishing)
52
+ - [Usage](#usage)
53
+ - [Programatic Usage](#programatic-usage)
54
+ - [Options](#options)
55
+ - [Amino Encoding](#amino-encoding)
56
+ - [Implemented Interface Options](#implemented-interface-options)
57
+ - [Prototypes Options](#prototypes-options)
58
+ - [Prototypes Methods](#prototypes-methods)
59
+ - [Enums Options](#enums-options)
60
+ - [LCD Client Options](#lcd-client-options)
61
+ - [RPC Client Options](#rpc-client-options)
62
+ - [Helper Functions](#helper-functions)
63
+ - [Stargate Client Options](#stargate-client-options)
64
+ - [State Management](#state-management)
65
+ - [React Query](#react-query)
66
+ - [Mobx](#mobx)
67
+ - [Pinia](#pinia)
68
+ - [Vue Query](#vue-query)
69
+ - [Typings and Formating](#typings-and-formating)
70
+ - [Protobuf parser](#protobuf-parser)
71
+ - [Typescript Disabling](#typescript-disabling)
72
+ - [ESLint Disabling](#eslint-disabling)
73
+ - [Bundle](#bundle)
74
+ - [Output](#output)
75
+ - [Types](#types)
76
+ - [Timestamp](#timestamp)
77
+ - [Duration](#duration)
78
+ - [Composing Messages](#composing-messages)
79
+ - [Calculating Fees](#calculating-fees)
80
+ - [Stargate Clients](#stargate-clients)
81
+ - [Creating Signers](#creating-signers)
82
+ - [Amino Signer](#amino-signer)
83
+ - [Proto Signer](#proto-signer)
84
+ - [Broadcasting messages](#broadcasting-messages)
85
+ - [LCD Clients](#lcd-clients)
86
+ - [LCD Clients Classes](#lcd-clients-classes)
87
+ - [RPC Clients](#rpc-clients)
88
+ - [Tendermint Client](#tendermint-client)
89
+ - [gRPC-web Client](#grpc-web-client)
90
+ - [gRPC-gateway Client](#grpc-gateway-client)
91
+ - [RPC Client Classes](#rpc-client-classes)
92
+ - [Instant RPC Methods](#instant-rpc-methods)
93
+ - [Manually registering types](#manually-registering-types)
94
+ - [JSON Patch Protos](#json-patch-protos)
95
+ - [CosmWasm](#cosmwasm)
96
+ - [Helper Functions Configuration](#helper-functions-configuration)
97
+ - [Pattern Matching Priority:](#pattern-matching-priority)
98
+ - [Generated Output Examples:](#generated-output-examples)
99
+ - [Notes:](#notes)
100
+ - [Dependencies](#dependencies)
101
+ - [Troubleshooting](#troubleshooting)
102
+ - [Create React App](#create-react-app)
103
+ - [Babel](#babel)
104
+ - [Developing](#developing)
105
+ - [Sponsors](#sponsors)
106
+ - [Stack](#interchain-javascript-stack-️)
107
+ - [Credits](#credits)
108
+ - [Disclaimer](#disclaimer)
109
+
110
+ ## Quickstart
111
+
112
+ Follow the instructions below to generate a new Typescript package that you can publish to npm. You can also follow the video: https://youtu.be/iQf6p65fbdY
113
+
114
+ `create-interchain-app`
115
+ ```sh
116
+ npm install -g create-interchain-app
117
+ ```
118
+
119
+
120
+ ### Generate
121
+
122
+ Use the [`create-interchain-app`](https://github.com/hyperweb-io/create-interchain-app/) command to create a new package from the `telescope` boilerplate.
123
+
124
+ ```sh
125
+ cia --boilerplate telescope
126
+ ```
127
+
128
+ Then, you'll navigate into `./your-project/packages/telescope` package for the next steps.
129
+
130
+ If some required options are missing, it will prompt to ask for the info.
131
+
132
+ For detailed cli `generate` commands, please check our docs and learn directories.
133
+
134
+ ### Download protos
135
+
136
+ The old ` telescope install ` command has been deprecated
137
+
138
+ You can use our script to download protos by using `download-protos`command in the boilerplate.
139
+
140
+ ```sh
141
+ yarn download-protos
142
+ ```
143
+
144
+ You should now see some repos cloned in `./git-modules` and proto files generated in `./protos`. These are the proto files downloaded according to your config.
145
+
146
+ For detailed cli `download` commands, please check our docs and learn directories.
147
+
148
+ ### Transpile
149
+
150
+ To create the Typescript files for your chain, run the `yarn codegen` command inside of the package.
151
+
152
+ ```
153
+ yarn codegen
154
+ ```
155
+
156
+ ### Build
157
+
158
+ Finally, run `install` and `build` to generate the JS and types for publishing your module to npm.
159
+
160
+ ```sh
161
+ yarn build
162
+ ```
163
+
164
+ ### Publishing
165
+
166
+ Now you should have code inside of your `./src` folder, ready for publshing. If you used the `create-interchain-app` boilerplate, use `lerna` to publish (and/or read the README in the boilerplate for instructions), or run `npm publish` from your repository.
167
+
168
+ # Usage
169
+
170
+ ## Advanced Install
171
+ The methods below are all the options you can use to install and use Telescope
172
+
173
+ ### Telescope CLI
174
+ Install telescope
175
+ ```sh
176
+ npm install -g @hyperweb/telescope
177
+ ```
178
+ The steps by order are: generate, download and transpile.
179
+
180
+ 1.Generate a package with the telescope CLI:
181
+
182
+ Use and follow the default prompt:
183
+ ```sh
184
+ telescope generate
185
+ ```
186
+
187
+ Or advanced cli option by your choice:
188
+ ```sh
189
+ telescope generate --access public --userfullname "Your Name" --useremail "your@email.com" --module-desc "Your module description" --username "your-username" --license MIT --module-name "your-module" --chain-name cosmos --use-npm-scoped
190
+ ```
191
+
192
+ Available options:
193
+ - `--userfullname`: Your full name
194
+ - `--useremail`: Your email
195
+ - `--module-desc`: Module description
196
+ - `--username`: GitHub username
197
+ - `--module-name`: Module name
198
+ - `--chain-name`: Chain name
199
+ - `--access`: Package access (`public` or `private`)
200
+ - `--use-npm-scoped`: Use npm scoped package (only works with `--access public`)
201
+ - `--license`: License type
202
+
203
+ 2.Download protocol buffer files:
204
+ ```sh
205
+ telescope download
206
+ ```
207
+
208
+ This will clone repositories into `./git-modules` and generate proto files in `./protos`.
209
+
210
+ Download with a config file:
211
+ ```sh
212
+ telescope download --config ./protod.config.json --out ./git-modules
213
+ ```
214
+
215
+ protod.config.json example:
216
+ ```json
217
+ {
218
+ "repos": [
219
+ { "owner": "cosmos", "repo": "cosmos-sdk", "branch": "release/v0.50.x" },
220
+ { "owner": "cosmos", "repo": "ibc-go" },
221
+ ],
222
+ "protoDirMapping": {
223
+ "gogo/protobuf/master": ".",
224
+ "googleapis/googleapis/master": ".",
225
+ "protocolbuffers/protobuf/main": "src"
226
+ },
227
+ "outDir": "protos",
228
+ "ssh": true,
229
+ "tempRepoDir": "git-modules",
230
+ "targets": [
231
+ "cosmos/**/*.proto",
232
+ "cosmwasm/**/*.proto",
233
+ "ibc/**/*.proto",
234
+ ]
235
+ }
236
+ ```
237
+
238
+ Download from a specific repo:
239
+ ```sh
240
+ telescope download --git-repo owner/repository --targets cosmos/auth/v1beta1/auth.proto
241
+ ```
242
+
243
+ 3. Transpile (Generate TypeScript code from proto files):
244
+ Use default telescope option:
245
+ ```sh
246
+ telescope transpile
247
+ ```
248
+
249
+ Use customized telescope option:
250
+ ```sh
251
+ telescope transpile --config telescope-config.json
252
+ ```
253
+
254
+ telescope-config.json exmaple:
255
+ ```json
256
+ {
257
+ "protoDirs": [
258
+ "./protos/"
259
+ ],
260
+ "outPath": "./codegen/",
261
+ "options": {
262
+ "classesUseArrowFunctions": true,
263
+ "env": "v-next",
264
+ "useInterchainJs": true,
265
+ "useSDKTypes": false,
266
+ "prototypes": {
267
+ "enableRegistryLoader": false,
268
+ "enableMessageComposer": false,
269
+ "enabled": true,
270
+ "parser": {
271
+ "keepCase": false
272
+ },
273
+ "methods": {
274
+ "fromJSON": false,
275
+ "toJSON": false,
276
+ "encode": true,
277
+ "decode": true,
278
+ "fromPartial": true,
279
+ "toAmino": true,
280
+ "fromAmino": true,
281
+ "fromProto": false,
282
+ "toProto": false,
283
+ "fromProtoMsg": false,
284
+ "toProtoMsg": false,
285
+ "toAminoMsg": true,
286
+ "fromAminoMsg": true
287
+ },
288
+ "addTypeUrlToDecoders": false,
289
+ "addTypeUrlToObjects": true,
290
+ "addAminoTypeToObjects": true,
291
+ "typingsFormat": {
292
+ "duration": "duration",
293
+ "timestamp": "date",
294
+ "useExact": false,
295
+ "useDeepPartial": true,
296
+ "num64": "bigint",
297
+ "customTypes": {
298
+ "useCosmosSDKDec": true,
299
+ "useEnhancedDecimal": false
300
+ },
301
+ "useTelescopeGeneratedType": true,
302
+ "autoFixUndefinedEnumDefault": true
303
+ }
304
+ },
305
+ "bundle": {
306
+ "enabled": false
307
+ },
308
+ "stargateClients": {
309
+ "enabled": false
310
+ },
311
+ "lcdClients": {
312
+ "enabled": false
313
+ },
314
+ "rpcClients": {
315
+ "enabled": false
316
+ },
317
+ "helperFunctions": {
318
+ "enabled": true,
319
+ "useGlobalDecoderRegistry": true,
320
+ "hooks": {
321
+ "react": true,
322
+ "vue": false
323
+ }
324
+ },
325
+ "interfaces": {
326
+ "enabled": true,
327
+ "useGlobalDecoderRegistry": true,
328
+ "registerAllDecodersToGlobal": false,
329
+ "useUnionTypes": true
330
+ },
331
+ "aminoEncoding": {
332
+ "enabled": true,
333
+ "useLegacyInlineEncoding": false,
334
+ "disableMsgTypes": false,
335
+ "useProtoOptionality": true,
336
+ "customTypes": {
337
+ "useCosmosSDKDec": true
338
+ }
339
+ }
340
+ }
341
+ }
342
+ ```
343
+
344
+ ### CIA
345
+ Please follow the video: https://youtu.be/iQf6p65fbdY
346
+ Or [Go to Quickstart](#quickstart)
347
+
348
+ ### CCA
349
+ First, install `create-cosmos-app`
350
+
351
+ ```sh
352
+ npm install -g create-cosmos-app
353
+ ```
354
+
355
+ Use the [`create-cosmos-app`](https://github.com/hyperweb-io/create-cosmos-app/) command to create a new package from the `telescope` boilerplate.
356
+
357
+ ```sh
358
+ cca --boilerplate telescope
359
+ ```
360
+
361
+ Then, you'll navigate into `./your-project/packages/telescope` package for the next steps.
362
+
363
+ Install dependency and use cli to download the protos you want.
364
+ ```sh
365
+ yarn install
366
+ telescope download --config ./your.config.json
367
+ ```
368
+
369
+ To create the Typescript files for your chain, run the `yarn codegen` command inside of the package.
370
+
371
+ ```sh
372
+ yarn codegen
373
+ ```
374
+
375
+ ### Manual install
376
+ If you want to use telescope in your own project.
377
+
378
+ Run the command in ./your-project
379
+ ```sh
380
+ yarn add --dev @hyperweb/telescope
381
+ ```
382
+ Install helpers and cosmjs [dependencies listed here](#dependencies)
383
+
384
+ We recommand to use [Go to Programatic Usage](#programatic-usage)
385
+
386
+ You can also use [Go to Telescope Cli](#telescope-cli)
387
+ To be noted for cli command, add 'npx' or 'yarn' prefix when you use it within your project. For instance: 'yarn telescope generate', 'npx telescope download', etc.
388
+
389
+ ### Programatic Usage
390
+
391
+ First add telescope to your `devDependencies`:
392
+
393
+ ```sh
394
+ yarn add --dev @hyperweb/telescope
395
+ ```
396
+
397
+ Install helpers and cosmjs [dependencies listed here](#dependencies)
398
+
399
+ Download command example:
400
+ ```js
401
+ import downloadProtos from '@hyperweb/telescope/main/commands/download'
402
+
403
+ const config = {
404
+ repos: [
405
+ { owner: "cosmos", repo: "cosmos-sdk", branch: "release/v0.50.x" },
406
+ { owner: "cosmos", repo: "ibc-go" },
407
+ ],
408
+ protoDirMapping: {
409
+ "gogo/protobuf/master": ".",
410
+ "googleapis/googleapis/master": ".",
411
+ "protocolbuffers/protobuf/main": "src"
412
+ },
413
+ outDir: "protos",
414
+ ssh: false,
415
+ tempRepoDir: "git-modules",
416
+ targets: [
417
+ "cosmos/**/*.proto",
418
+ "ibc/**/*.proto",
419
+ ]
420
+ };
421
+
422
+ downloadProtos(config)
423
+ .then(() => console.log('✅ Proto download completed'))
424
+ // @ts-ignore
425
+ .catch((error) => {
426
+ console.error('❌ Proto download failed:', error);
427
+ process.exit(1);
428
+ });
429
+ ```
430
+
431
+ Transpile command example:
432
+ ```js
433
+ import { join } from 'path';
434
+ import telescope from '@hyperweb/telescope';
435
+ import { sync as rimraf } from 'rimraf';
436
+
437
+ const protoDirs = [join(__dirname, '/../proto')];
438
+ const outPath = join(__dirname, '../src');
439
+ rimraf(outPath);
440
+
441
+ telescope({
442
+ protoDirs,
443
+ outPath,
444
+
445
+ // all options are totally optional ;)
446
+ options: {
447
+ aminoEncoding: {
448
+ enabled: true
449
+ },
450
+ lcdClients: {
451
+ enabled: false
452
+ },
453
+ rpcClients: {
454
+ enabled: false,
455
+ camelCase: true
456
+ },
457
+
458
+ // you can scope options to certain packages:
459
+ packages: {
460
+ nebula: {
461
+ prototypes: {
462
+ typingsFormat: {
463
+ useExact: false
464
+ }
465
+ }
466
+ },
467
+ akash: {
468
+ stargateClients: {
469
+ enabled: true,
470
+ includeCosmosDefaultTypes: false
471
+ },
472
+ prototypes: {
473
+ typingsFormat: {
474
+ useExact: false
475
+ }
476
+ }
477
+ }
478
+ }
479
+ }
480
+ }).then(() => {
481
+ console.log('✨ all done!');
482
+ }).catch(e => {
483
+ console.error(e);
484
+ process.exit(1);
485
+ })
486
+ ```
487
+
488
+ ## Options
489
+
490
+ ### Amino Encoding
491
+
492
+ | option | description | defaults |
493
+ | ------------------------------ | -------------------------------------------------------------- | ---------- |
494
+ | `aminoEncoding.enabled` | generate amino types and amino converters | `true` |
495
+ | `aminoEncoding.omitEmptyTags` | An array of strings that determines whether a field should be omitted when serialized to JSON. If the array includes "omitempty", any field with the "omitempty" option in either gogoproto.jsontag or cosmos_proto.json_tag will be omitted. If the array includes "dont_omitempty", the field will be omitted or not based on the value of "(amino.dont_omitempty)": if it's null or false, the field will be omitted; if it's true, the field will not be omitted. | `["omitempty", "dont_omitempty"]` |
496
+ | `aminoEncoding.disableMsgTypes` | disable generating AminoMsg types | `false` |
497
+ | `aminoEncoding.casingFn` | set the amino-casing function for a project | `snake()` |
498
+ | `aminoEncoding.exceptions` | set specific aminoType name exceptions | see code |
499
+ | `aminoEncoding.typeUrlToAmino` | create functions for aminoType name exceptions | `undefined`|
500
+ | `aminoEncoding.useLegacyInlineEncoding` | @deprecated. To use legacy inline encoding instead of using v2 recursive encoding | `false`|
501
+ | `aminoEncoding.useRecursiveV2encoding` | this's been removed. See useLegacyInlineEncoding instead. | |
502
+ | `aminoEncoding.legacy.useNullHandling` | handle null case when generating legacy amino converters(those in tx.amino.ts) | |
503
+ | `aminoEncoding.legacy.useOmitEmpty` | handle omit empty or not when generating legacy amino converters(those in tx.amino.ts) | |
504
+
505
+ ### Implemented Interface Options
506
+
507
+ | option | description | defaults |
508
+ | ----------------------------------------- | -------------------------------------------------------------- | ---------- |
509
+ | `interfaces.enabled` | enables converters convert between Any type and specific implemented interfaces. | `true` |
510
+ | `interfaces.useGlobalDecoderRegistry` | enables GlobalDecoderRegistry and related functions. Highly recommended to enable when dealing with fields with 'accepted_interface' option. Please see 'packages/telescope/__tests__/impl-interfaces.test.ts' for usage. | `false` |
511
+ | `interfaces.useUseInterfacesParams` | decides if add `useInterfaces` argument to `decode` and `toAmino` functions. | `false` |
512
+ | `interfaces.useByDefault` | decides if interface decoders are used by default (default for `useInterfaces` argument to `decode` and `toAmino` functions). | `true` |
513
+ | `interfaces.useByDefaultRpc` | decides if interface decoders are used by default by the RPC clients. | `true` |
514
+ | `interfaces.useUnionTypes` | Generate Any type as union types(TextProposal \| RegisterIncentiveProposal) instead of intersection types(TextProposal & RegisterIncentiveProposal). | `false` |
515
+
516
+ ### Prototypes Options
517
+
518
+ | option | description | defaults |
519
+ | ----------------------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
520
+ | `prototypes.enabled` | enables the generation of proto encoding methods | `true` |
521
+ | `prototypes.includePackageVar` | export a `protoPackage` variable to indicate package name | `false` |
522
+ | `prototypes.includes.packages` | include a set of packages when transpilation. (if a package both meet include and exclude, it'll be excluded) | `undefined` |
523
+ | `prototypes.includes.protos` | include a set of proto files when transpilation. (if a proto both meet include and exclude, it'll be excluded) | `undefined` |
524
+ | `prototypes.excluded.packages` | exclude a set of packages from transpilation | `undefined` |
525
+ | `prototypes.excluded.protos` | try to exclude a set of proto files from transpilation. if files inside the list are dependencies to other files, they'll be still transpiled. | `undefined` |
526
+ | `prototypes.excluded.hardProtos` | exclude a set of proto files from transpilation. Files in this list will be excluded no matter it is a dependency to other files or not. | `undefined` |
527
+ | `prototypes.fieldDefaultIsOptional` | boolean value representing default optionality of field | `false` |
528
+ | `prototypes.useOptionalNullable` | use `(gogoproto.nullable)` values in determining optionality | `true` |
529
+ | `prototypes.allowUndefinedTypes` | boolean value allowing `Type`s to be `undefined` | `false` |
530
+ | `prototypes.allowEncodeDefaultScalars` | boolean value allowing encoders encoding default values of scalar types. e.g. empty string, 0 or false | `false` |
531
+ | `prototypes.isScalarDefaultToNullable` | Determines whether scalar types are nullable by default when gogoproto.nullable is not specified. If set to true, scalar types will be nullable; if false, they will be required | `false` |
532
+ | `prototypes.enforceNullCheck` | Determines whether to enforce checking required scalar fields not null or undefined during encoding | `false` |
533
+ | `prototypes.optionalQueryParams` | boolean value setting queryParams to be optional | `false` |
534
+ | `prototypes.optionalPageRequests` | boolean value setting `PageRequest` fields to optional | `false` |
535
+ | `prototypes.addTypeUrlToDecoders` | add $typeUrl field to generated interfaces | `true` |
536
+ | `prototypes.addAminoTypeToObjects` | add aminoType field to generated Decoders | `false` |
537
+ | `prototypes.addTypeUrlToObjects` | add typeUrl field to generated Decoders | `true` |
538
+ | `prototypes.enableRegistryLoader` | generate Registry loader to *.registry.ts files | `true` |
539
+ | `prototypes.enableMessageComposer` | generate MessageComposer to *.registry.ts files | `true` |
540
+ | `prototypes.patch` | An object mapping filenames to an array of `Operation` to be applied as patches to proto files during generation. See [JSON Patch Protos](#json-patch-protos) | `undefined` |
541
+
542
+ ### Prototypes Methods
543
+
544
+ | option | description | defaults|
545
+ | ---------------------------------- | ----------------------------------------------------------------- | ------- |
546
+ | `prototypes.methods.encode` | boolean to enable `encode` method on proto objects | `true` |
547
+ | `prototypes.methods.decode` | boolean to enable `decode` method on proto objects | `true` |
548
+ | `prototypes.methods.fromJSON` | boolean to enable `fromJSON` method on proto objects | `true` |
549
+ | `prototypes.methods.toJSON` | boolean to enable `toJSON` method on proto objects | `true` |
550
+ | `prototypes.methods.fromPartial` | boolean to enable `fromPartial` method on proto objects | `true` |
551
+ | `prototypes.methods.fromSDK` | boolean to enable `fromSDK` method on proto objects | `false` |
552
+ | `prototypes.methods.toSDK` | boolean to enable `toSDK` method on proto objects | `false` |
553
+
554
+ ### Enums Options
555
+
556
+ | option | description | defaults |
557
+ | ------------------------------------- | --------------------------------------------------------------- | ---------- |
558
+ | `enums.useCustomNames` | Enables the usage of custom names for enums if specified through proto options or annotations, allowing for more descriptive or project-specific naming conventions. | `false` |
559
+
560
+
561
+ ### LCD Client Options
562
+
563
+ | option | description | defaults |
564
+ | ------------------------------ | -------------------------------------------------------------- | ---------- |
565
+ | `lcdClients.enabled` | generate LCD clients that can query proto `Query` messages | `true` |
566
+ | `lcdClients.bundle` | will generate factory bundle aggregate of all LCD Clients | `true` |
567
+ | `lcdClients.scoped` | will generate factory of scoped LCD Clients | `undefined`|
568
+ | `lcdClients.scopedIsExclusive` | will allow both scoped bundles and all RPC Clients | `true` |
569
+
570
+ See [LCD Clients](#lcd-clients) for more info.
571
+
572
+ ### RPC Client Options
573
+
574
+ | option | description | defaults |
575
+ | ------------------------------ | ---------------------------------------------------------------------- | ----------------------------- |
576
+ | `rpcClients.type` | will generate this type of RPC client (`tendermint`, `gRPC-web`, `gRPC`)| `tendermint` |
577
+ | `rpcClients.enabled` | generate RPC clients that can interact with proto messages | `true` |
578
+ | `rpcClients.bundle` | will generate factory bundle aggregate of all RPC Clients | `true` |
579
+ | `rpcClients.camelCase` | use camel-case for RPC methods when generating RPC clients | `true` |
580
+ | `rpcClients.scoped` | will generate factory of scoped RPC Clients | `undefined` |
581
+ | `rpcClients.scopedIsExclusive` | will allow both scoped bundles and all RPC Clients | `true` |
582
+ | `rpcClients.enabledServices` | which services to enable | [`Msg`,`Query`,`Service`] |
583
+ | `rpcClients.instantOps` | will generate instant rpc operations in the file `service-ops.ts` under root folder, which contains customized classes having selected rpc methods | `undefined` |
584
+ | `rpcClients.useConnectComet` | will use connectComet function to get a tendermint client | `undefined` |
585
+ | `rpcClients.useMakeClient` | allow user to pass a query client resolver to create query client in createRPCQueryClient function | `undefined` |
586
+ | `rpcClients.serviceImplement` | assign implement type of rpc methods, `Query` or `Tx`, by setting patterns under service types. | `undefined` |
587
+ `rpcClients.clientStyle.useUpdatedClientStyle` | The default value is `false`, which sets the generated client to use the legacy style. Setting it to `true` applies the updated style and activates the remaining options in clientStyle. | `false`
588
+ | `rpcClients.clientStyle.type` | A string array containing possible values: `all-client`, `sdk-module-client`, and `custom-client`. The value `all-client` generates an all-module-client file. The value `sdk-module-client` generates a client for the module specified by the `sdkModuleClientOption`. The value `custom-client` generates a customized client as specified by `customClientOption` | `undefined`
589
+ `rpcClients.clientStyle.customClientOption.name` | assign the client name like `{name}AminoConverters`, `get{name}SigningClient` etc | `undefined`
590
+ | `rpcClients.clientStyle.customClientOption.fileName` | assign the file name of generated client in root directory | `undefined`
591
+ | `rpcClients.clientStyle.customClientOption.include.patterns` | determine which proto files will be imported for the current client such as `cosmos.gov.v1beta1.**` | `undefined`
592
+
593
+ See [RPC Clients](#rpc-clients) for more info.
594
+
595
+ ### Helper Functions
596
+
597
+
598
+ | Option | Description | Defaults |
599
+ | --------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------- |
600
+ | `helperFunctions.enabled` | Enable the generation of helper function files `.func.ts` | `false` |
601
+ | `helperFunctions.hooks` | Generates hooks selected alongside helper functions | `{ react: false, vue: false }` |
602
+ | `helperFunctions.include.serviceTypes`| Specifies which types of services to include (`Query`, `Msg`). `undefined` includes all types. | `undefined` |
603
+ | `helperFunctions.include.patterns` | Array of glob patterns patterns (e.g., `"**"`, `"cosmos.bank.v1beta1.bala*"`, etc.) to match specific proto services. | `undefined` |
604
+ | `helperFunctions.nameMappers` | Configuration object for customizing function names and prefixes | `{}` |
605
+ | `helperFunctions.nameMappers.All.funcBody` | Maps method names to a new name for all services. | `"unchanged"` |
606
+ | `helperFunctions.nameMappers.All.hookPrefix` | Prefix for the hooks. | `"use"` |
607
+ | `helperFunctions.nameMappers.Query.funcBody` | Maps method names to a new name for `Query` services. | `"get"` |
608
+ | `helperFunctions.nameMappers.Query.hookPrefix` | Prefix for the hooks for `Query` services. | `"use"` |
609
+ | `helperFunctions.nameMappers.Msg.funcBody` | Maps method names to a new name for `Msg` services. | `"unchanged"` |
610
+ | `helperFunctions.nameMappers.Msg.hookPrefix` | Prefix for the hooks for `Msg` services. | `"use"` |
611
+
612
+ See [Helper Functions Configuration](#helper-functions-configuration) for more info.
613
+
614
+ ### Stargate Client Options
615
+
616
+ | option | description | defaults |
617
+ | -------------------------------------------- | -------------------------------------------------------------- | ---------|
618
+ | `stargateClients.includeCosmosDefaultTypes` | if true, will include the cosmjs defaults with stargate clients | `true` (except cosmos package) |
619
+ | `stargateClients.addGetTxRpc` | if true, will add getSigningTxRpc to clients in namespaces | false |
620
+
621
+ ### State Management
622
+
623
+ #### React Query
624
+
625
+ | option | description | defaults |
626
+ | -------------------------------- | ---------------------------------------------------------------------- | ---------|
627
+ | `reactQuery.enabled` | if true, will create react hooks that use `@tanstack/react-query` hooks | `false` |
628
+ | `reactQuery.needExtraQueryKey` | if true, users can input extra react query key to some customized hooks. e.g.['rpcEndpoint', 'yourExtraKey'] | `false` |
629
+ | `reactQuery.include.protos` | if set, will create the hooks on matched proto filenames or patterns using minimatch | `[]` |
630
+ | `reactQuery.include.packages` | if set, will create the hooks on matched packages files using minimatch | `[]` |
631
+ | `reactQuery.include.patterns` | if set, will create the hooks on matched patterns of files using minimatch(deprecated in favor of packages and protos have been supported minimatch) | `[]` |
632
+ | `reactQuery.instantExport.include.patterns` | if set, will expose instant hooks on matched patterns of packages + method(e.g. cosmos.bank.v1beta1.useBalance) using minimatch. If there're duplicated method names in multiple packages without setting `reactQuery.instantExport.nameMapping`, one duplicated name will created like: useCosmosBankV1beta1Balance | `[]` |
633
+ | `reactQuery.instantExport.nameMapping` | map an alias to a package + method in case of better naming of duplicated method names. (e.g. useBankBalance: cosmos.bank.v1beta1.useBalance) Customized hook name is set in front of pkg+method, by doing this we can prevent duplicate alias. | `{}` |
634
+
635
+ #### Mobx
636
+
637
+ | option | description | defaults |
638
+ | -------------------------------- | ---------------------------------------------------------------------- | ---------|
639
+ | `mobx.enabled` | if true, will create mobx stores that use `mobx` | `false` |
640
+ | `mobx.include.protos` | if set, will create the mobx stores on matched proto filenames or patterns using minimatch | `[]` |
641
+ | `mobx.include.packages` | if set, will create the mobx stores on matched packages files using minimatch | `[]` |
642
+ | `mobx.include.patterns` | if set, will create the mobx stores on matched patterns of proto files using minimatch(deprecated in favor of packages and protos have been supported minimatch) | `[]` |
643
+
644
+ #### Pinia
645
+
646
+ | option | description | defaults |
647
+ | -------------------------------- | ---------------------------------------------------------------------- | ---------|
648
+ | `pinia.enabled` | if true, will create pinia stores that use `pinia` | `false` |
649
+ | `mobx.include.protos` | if set, will create the pinia stores on matched proto filenames or patterns using minimatch | `[]` |
650
+ | `mobx.include.packages` | if set, will create the pinia stores on matched packages files using minimatch | `[]` |
651
+ | `mobx.include.patterns` | if set, will create the pinia stores on matched patterns of proto files using minimatch(deprecated in favor of packages and protos have been supported minimatch) | `[]` |
652
+
653
+ #### Vue Query
654
+ | option | description | defaults |
655
+ | -------------------------------- | ---------------------------------------------------------------------- | ---------|
656
+ | `vueQuery.enabled` | if true, will create vue composables that use `@tanstack/vue-query` composables | `false` |
657
+ | `vueQuery.include.protos` | if set, will create the composables on matched proto filenames or patterns using minimatch | `[]` |
658
+ | `vueQuery.include.packages` | if set, will create the composables on matched packages files using minimatch | `[]` |
659
+
660
+ ### Typings and Formating
661
+
662
+ | option | description | defaults |
663
+ | ----------------------------------------- | -------------------------------------------------------------- | --------- |
664
+ | `prototypes.typingsFormat.customTypes.useCosmosSDKDec` | enable handling "prototypes.typingsFormat.customTypes.useCosmosSDKDec" proto custom type. Used to show decimal fields with the custom type correctly. Highly recommend set to true. | `true` |
665
+ | `prototypes.typingsFormat.customTypes.useEnhancedDecimal` | To use patched decimal other then decimal from @cosmjs/math | `false` |
666
+ | `prototypes.typingsFormat.customTypes.base64Lib` | To use endo/base64 methods | `undefined` |
667
+ | `prototypes.typingsFormat.num64` | 'long' or 'bigint', the way of generating int64 proto types, set to 'bigint' to enable using more stable built-in type | `bigint` |
668
+ | `prototypes.typingsFormat.useTelescopeGeneratedType` | Discard GeneratedType from cosmjs, use TelescopeGeneratedType instead inside *.registry.ts files | `false` |
669
+ | `prototypes.typingsFormat.useDeepPartial` | defaults to true, but if disabled uses the `Partial` TS type | `false` |
670
+ | `prototypes.typingsFormat.useExact` | defaults to false, but if enabled uses the `Exact` TS type | `false` |
671
+ | `prototypes.typingsFormat.toJsonUnknown` | defaults to true, but if disabled uses the `JsonSafe` for `toJSON` methods | `true` |
672
+ | `prototypes.typingsFormat.timestamp` | use either `date` or `timestamp` for `Timestamp` proto type | "date" |
673
+ | `prototypes.typingsFormat.duration` | use either `duration` or `string` for `Duration` proto type | "duration"|
674
+ | `prototypes.typingsFormat.setDefaultEnumToUnrecognized` | false: enum empty value would be 0, true: -1(value for enum unrecognized) |true|
675
+ | `prototypes.typingsFormat.setDefaultCustomTypesToUndefined` | true: Timestamp,Duration,Any,Coin empty value would be undefined., false: using fromPartial to get an empty obj |false|
676
+ | `prototypes.typingsFormat.autoFixUndefinedEnumDefault` | the default value of an enum field would be: 1(proto2); 0(proto3); But in some rare cases, those default values are not existing. By enabling this, the default value will be automatically fixed with the smallest value inside the enum. |false|
677
+
678
+ ### Protobuf parser
679
+
680
+ | option | description | defaults |
681
+ | ----------------------------------------- | -------------------------------------------------------------- | --------- |
682
+ | `prototypes.parser.keepCase` | passes `keepCase` to protobuf `parse()` to keep original casing | `true` |
683
+ | `prototypes.parser.alternateCommentMode` | passes `alternateCommentMode` to protobuf `parse()` method | `true` |
684
+ | `prototypes.parser.preferTrailingComment` | passes `preferTrailingComment` to protobuf `parse()` method | `false` |
685
+
686
+ ### Typescript Disabling
687
+
688
+ | option | description | defaults |
689
+ | -------------------------------------------- | -------------------------------------------------------------- | ---------|
690
+ | `tsDisable.disableAll` | if true, will include `//@ts-nocheck` on every output file | `false` |
691
+ | `tsDisable.patterns` | if set, will include `//@ts-nocheck` on matched patterns | `[]` |
692
+ | `tsDisable.files` | if set, will include `//@ts-nocheck` on matched files | `[]` |
693
+
694
+ ### ESLint Disabling
695
+
696
+ | option | description | defaults |
697
+ | -------------------------------------------- | ---------------------------------------------------------------- | ---------|
698
+ | `eslintDisable.disableAll` | if true, will include `/* eslint-disable */` on every output file | `false` |
699
+ | `eslintDisable.patterns` | if set, will include `/* eslint-disable */` on matched patterns | `[]` |
700
+ | `eslintDisable.files` | if set, will include `/* eslint-disable */` on matched files | `[]` |
701
+
702
+ ### Bundle
703
+
704
+ | option | description | defaults |
705
+ | ------------------------------ | -------------------------------------------------------------- | ---------- |
706
+ | `bundle.enabled` | bundle all files into a scoped index file | `true` |
707
+ > **Warning:** This option is not recommended. It will generate a bundle file that exports all the types and functions under one namespace. This will make the bundle file very large and hard to maintain. e.g. using `cosmos.bank.v1beta1.MsgSend` might be intuitive, but it will also include `cosmos.gov.v1beta1.*` and other types in the final bundle file. So use this option with caution.
708
+
709
+ ### Output
710
+
711
+ | option | description | defaults |
712
+ | ------------------------------ | ----------------------------------------------------------------- | ---------- |
713
+ | `env` | 'default' or 'v-next', set to 'v-next' to enable yet to release features | `default` |
714
+ | `removeUnusedImports` | removes unused imports | `true` |
715
+ | `classesUseArrowFunctions` | classes use arrow functions instead of `bind()`ing in constructors | `false` |
716
+ | `includeExternalHelpers` | exports a few helpers functions in `extern.ts` | `false` |
717
+ | `restoreImportExtension` | restore extensions of imported paths. e.g: '.js'. null means no ext | `null` |
718
+
719
+ ## Types
720
+
721
+ ### Timestamp
722
+
723
+ The representation of `google.protobuf.Timestamp` is configurable by the `prototypes.typingsFormat.timestamp` option.
724
+
725
+ | Protobuf type | Default/`date='date'` | `date='timestamp'` |
726
+ | --------------------------- | ---------------------- | ----------------------------------|
727
+ | `google.protobuf.Timestamp` | `Date` | `{ seconds: Long, nanos: number }`|
728
+
729
+ TODO
730
+
731
+ * [ ] add `date='string'` option
732
+
733
+ ### Duration
734
+
735
+ The representation of `google.protobuf.Duration` is configurable by the `prototypes.typingsFormat.duration` option.
736
+
737
+ | Protobuf type | Default/`duration='duration'` | `duration='string'` | |
738
+ | --------------------------- | ---------------------- | ------------------------------------ | ---------------- |
739
+ | `google.protobuf.Duration` | `{ seconds: Long, nanos: number }` | `string` | |
740
+
741
+ ## Composing Messages
742
+
743
+ This example shows messages from the `osmojs`, which was built with Telescope.
744
+
745
+ Import the `osmosis` object from `osmojs`. In this case, we're show the messages available from the `osmosis.gamm.v1beta1` module:
746
+
747
+ ```js
748
+ import { osmosis } from 'osmojs';
749
+
750
+ const {
751
+ joinPool,
752
+ exitPool,
753
+ exitSwapExternAmountOut,
754
+ exitSwapShareAmountIn,
755
+ joinSwapExternAmountIn,
756
+ joinSwapShareAmountOut,
757
+ swapExactAmountIn,
758
+ swapExactAmountOut
759
+ } = osmosis.gamm.v1beta1.MessageComposer.withTypeUrl;
760
+ ```
761
+
762
+ Now you can construct messages. If you use vscode or another typescript-enabled IDE, you should also be able to use `ctrl+space` to see auto-completion of the fields required for the message.
763
+
764
+ ```js
765
+ import { coin } from '@cosmjs/amino';
766
+
767
+ const msg = swapExactAmountIn({
768
+ sender,
769
+ routes,
770
+ tokenIn: coin(amount, denom),
771
+ tokenOutMinAmount
772
+ });
773
+ ```
774
+
775
+ ## Calculating Fees
776
+
777
+ Make sure to create a `fee` object in addition to your message.
778
+
779
+ ```js
780
+ import { coins } from '@cosmjs/amino';
781
+
782
+ const fee = {
783
+ amount: coins(0, 'uosmo'),
784
+ gas: '250000'
785
+ }
786
+ ```
787
+
788
+ if you are broadcasting multiple messages in a batch, you should `simulate` your tx and estimate the fee
789
+
790
+ ```js
791
+ import { Dec, IntPretty } from '@keplr-wallet/unit';
792
+
793
+ const gasEstimated = await stargateClient.simulate(address, msgs, memo);
794
+ const fee = {
795
+ amount: coins(0, 'uosmo'),
796
+ gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3)))
797
+ .maxDecimals(0)
798
+ .locale(false)
799
+ .toString()
800
+ };
801
+ ```
802
+
803
+ ## Stargate Clients
804
+
805
+ Every module gets their own signing client. This example demonstrates for the `osmosis` module.
806
+
807
+ Use `getSigningOsmosisClient` to get your `SigningStargateClient`, with the Osmosis proto/amino messages full-loaded. No need to manually add amino types, just require and initialize the client:
808
+
809
+ ```js
810
+ import { getSigningOsmosisClient } from 'osmojs';
811
+
812
+ const client = await getSigningOsmosisClient({
813
+ rpcEndpoint,
814
+ signer // OfflineSigner
815
+ });
816
+ ```
817
+
818
+ ## Creating Signers
819
+
820
+ To broadcast messages, you'll want to use either [keplr](https://docs.keplr.app/api/cosmjs.html) or an `OfflineSigner` from `cosmjs` using mnemonics.
821
+
822
+ ### Amino Signer
823
+
824
+ Likely you'll want to use the Amino, so unless you need proto, you should use this one:
825
+
826
+ ```js
827
+ import { getOfflineSigner as getOfflineSignerAmino } from 'cosmjs-utils';
828
+ ```
829
+
830
+ ### Proto Signer
831
+
832
+ ```js
833
+ import { getOfflineSigner as getOfflineSignerProto } from 'cosmjs-utils';
834
+ ```
835
+
836
+ WARNING: NOT RECOMMENDED TO USE PLAIN-TEXT MNEMONICS. Please take care of your security and use best practices such as AES encryption and/or methods from 12factor applications.
837
+
838
+ ```js
839
+ import { chains } from 'chain-registry';
840
+
841
+ const mnemonic =
842
+ 'unfold client turtle either pilot stock floor glow toward bullet car science';
843
+ const chain = chains.find(({ chain_name }) => chain_name === 'osmosis');
844
+ const signer = await getOfflineSigner({
845
+ mnemonic,
846
+ chain
847
+ });
848
+ ```
849
+
850
+ ## Broadcasting messages
851
+
852
+ Now that you have your `client`, you can broadcast messages:
853
+
854
+ ```js
855
+ import { signAndBroadcast } from '@osmosnauts/helpers';
856
+
857
+ const res = await signAndBroadcast({
858
+ client, // SigningStargateClient
859
+ chainId: 'osmosis-1', // use 'osmo-test-4' for testnet
860
+ address,
861
+ msgs: [msg],
862
+ fee,
863
+ memo: ''
864
+ });
865
+ ```
866
+
867
+ ## LCD Clients
868
+
869
+ For querying data via REST endpoints, you can use LCD Clients. For a better developer experience, you can generate a factory of scoped bundles of all LCD Clients with the `lcdClients` option.
870
+
871
+ ```ts
872
+ const options: TelescopeOptions = {
873
+ lcdClients: {
874
+ enabled: true,
875
+ },
876
+ };
877
+ ```
878
+
879
+ If you use the `lcdClients.scoped` array, you can scope to only the modules of your interest.
880
+
881
+ ```ts
882
+ const options: TelescopeOptions = {
883
+ lcdClients: {
884
+ enabled: true,
885
+ scoped: [
886
+ {
887
+ dir: 'osmosis',
888
+ filename: 'custom-lcd-client.ts',
889
+ packages: [
890
+ 'cosmos.bank.v1beta1',
891
+ 'cosmos.gov.v1beta1',
892
+ 'osmosis.gamm.v1beta1'
893
+ ],
894
+ addToBundle: true,
895
+ methodName: 'createCustomLCDClient'
896
+ },
897
+ {
898
+ dir: 'evmos',
899
+ filename: 'custom-lcd-client.ts',
900
+ packages: [
901
+ 'cosmos.bank.v1beta1',
902
+ 'cosmos.gov.v1beta1',
903
+ 'evmos.erc20.v1'
904
+ ],
905
+ addToBundle: true,
906
+ methodName: 'createEvmosLCDClient'
907
+ }
908
+ ]
909
+ }
910
+ };
911
+ ```
912
+
913
+ This will generate a nice helper in the `ClientFactory`, which you can then use to query multiple modules from a single object:
914
+
915
+ ```js
916
+ import { osmosis } from './codegen';
917
+
918
+ const main = async () => {
919
+ const client = await osmosis.ClientFactory.createLCDClient({ restEndpoint: REST_ENDPOINT });
920
+
921
+ // now you can query the modules
922
+ const pool = await client.osmosis.gamm.v1beta1.pool({ poolId: "1" });
923
+ const balance = await client.cosmos.bank.v1beta1.allBalances({ address: 'osmo1addresshere' });
924
+ };
925
+ ```
926
+
927
+ ## LCD Clients Classes
928
+
929
+ If you want to instantiate a single client, for any module that has a `Query` type, there will be a `LCDQueryClient` object:
930
+
931
+ ```js
932
+ import { osmosis } from "osmojs";
933
+
934
+ export const main = async () => {
935
+ const requestClient = new LCDClient({ restEndpoint: REST_ENDPOINT });
936
+ const client = new osmosis.gamm.v1beta1.LCDQueryClient({ requestClient });
937
+ const pools = await client.pools();
938
+ console.log(pools);
939
+ };
940
+
941
+ main().then(() => {
942
+ console.log('all done')
943
+ })
944
+ ```
945
+
946
+ ## RPC Clients
947
+
948
+ ### Tendermint Client
949
+
950
+ For querying data via RPC endpoints, you can use RPC Clients. For a better developer experience, you can generate a factory of scoped bundles of all RPC Clients with the `rpcClients` option.
951
+
952
+ ```ts
953
+ const options: TelescopeOptions = {
954
+ rpcClients: {
955
+ type: 'tendermint',
956
+ enabled: true,
957
+ camelCase: true
958
+ }
959
+ };
960
+ ```
961
+
962
+ If you use the `rpcClients.scoped` array, you can scope to only the modules of your interest. `gRPC-web` and `gRPC-gateway` work the same way with this option.
963
+
964
+ ```ts
965
+ const options: TelescopeOptions = {
966
+ rpcClients: {
967
+ enabled: true,
968
+ camelCase: true,
969
+ scoped: [
970
+ {
971
+ dir: 'osmosis',
972
+ filename: 'osmosis-rpc-client.ts',
973
+ packages: [
974
+ 'cosmos.bank.v1beta1',
975
+ 'cosmos.gov.v1beta1',
976
+ 'osmosis.gamm.v1beta1'
977
+ ],
978
+ addToBundle: true,
979
+ methodNameQuery: 'createRPCQueryClient',
980
+ methodNameTx: 'createRPCTxClient'
981
+ }
982
+ ]
983
+ }
984
+ };
985
+ ```
986
+
987
+ This will generate helpers `createRPCQueryClient` and `createRPCTxClient` in the `ClientFactory`, which you can then use to query multiple modules from a single object:
988
+
989
+ ```js
990
+ import { osmosis } from './codegen';
991
+
992
+ const main = async () => {
993
+ const client = await osmosis.ClientFactory.createRPCQueryClient({ rpcEndpoint });
994
+
995
+ // now you can query the modules
996
+ const pool = await client.osmosis.gamm.v1beta1.pool({ poolId: "1" });
997
+ const balance = await client.cosmos.bank.v1beta1.allBalances({ address: 'osmo1addresshere' });
998
+ };
999
+ ```
1000
+
1001
+ ### gRPC-web Client
1002
+
1003
+ For querying data via gRPC-web endpoints, you can use gRPC-web Clients. For a better developer experience, you can generate a factory of scoped bundles of all gRPC-web Clients with the `rpcClients` option.
1004
+
1005
+ ```ts
1006
+ const options: TelescopeOptions = {
1007
+ rpcClients: {
1008
+ type: 'grpc-web',
1009
+ enabled: true,
1010
+ camelCase: true
1011
+ }
1012
+ };
1013
+ ```
1014
+
1015
+ This will generate helpers `createGrpcWebClient` and `createGrpcMsgClient` in the `ClientFactory`, which you can then use to query multiple modules from a single object, if you need an example with scaffold and broadcast msg you can refer to the example below in `grpc-gateway`:
1016
+
1017
+ ```js
1018
+ import { osmosis } from './codegen';
1019
+
1020
+ const main = async () => {
1021
+ const client = await osmosis.ClientFactory.createGrpcWebClient({ endpoint });
1022
+
1023
+ // now you can query the modules
1024
+ const pool = await client.osmosis.gamm.v1beta1.pool({ poolId: "1" });
1025
+ const balance = await client.cosmos.bank.v1beta1.allBalances({ address: 'osmo1addresshere' });
1026
+ };
1027
+ ```
1028
+
1029
+ ### gRPC-gateway Client
1030
+
1031
+ For querying data via gRPC-web endpoints, you can use gRPC-web Clients. For a better developer experience, you can generate a factory of scoped bundles of all gRPC-web Clients with the `rpcClients` option.
1032
+
1033
+ ```ts
1034
+ const options: TelescopeOptions = {
1035
+ rpcClients: {
1036
+ type: 'grpc-gateway',
1037
+ enabled: true,
1038
+ camelCase: true
1039
+ }
1040
+ };
1041
+ ```
1042
+
1043
+ This will generate helpers `createGrpcGateWayClient` in the `ClientFactory`, which you can then use to query multiple modules from a single object:
1044
+
1045
+ ```js
1046
+ import { osmosis } from './codegen';
1047
+
1048
+ const main = async () => {
1049
+ // endpoint here is lcd endpoint
1050
+ const client = await osmosis.ClientFactory.createGrpcGateWayClient({ endpoint });
1051
+
1052
+ // now you can query the modules
1053
+ const pool = await client.osmosis.gamm.v1beta1.pool({ poolId: "1" });
1054
+ const balance = await client.cosmos.bank.v1beta1.allBalances({ address: 'osmo1addresshere' });
1055
+ };
1056
+ ```
1057
+
1058
+ Below will be an example of scaffold a `grant` Proto Msg for grpc-web and grpc-gateway and then broadcast it.
1059
+
1060
+ ```js
1061
+ const { grant } = cosmos.authz.v1beta1.MessageComposer.withTypeUrl;
1062
+ const msg = grant({
1063
+ granter: 'granter_address',
1064
+ grantee: 'grantee_address',
1065
+ grant: {
1066
+ authorization: StakeAuthorization.toProtoMsg({
1067
+ maxTokens: {
1068
+ denom: 'uosmo',
1069
+ amount: '100000000'
1070
+ },
1071
+ authorizationType: AuthorizationType.AUTHORIZATION_TYPE_DELEGATE
1072
+ }),
1073
+ expiration: new Date(Date.now() + 60 * 60 * 24 * 7)
1074
+ }})
1075
+
1076
+ const signed_tx = await signClient.sign('granter_address', [msg], fee, 'telescope: grant', signerData);
1077
+ const txRawBytes = Uint8Array.from(TxRaw.encode(signed_tx).finish());
1078
+
1079
+ const res = await client.cosmos.tx.v1beta1.broadcastTx({
1080
+ txBytes: txRawBytes,
1081
+ mode: BroadcastMode.BROADCAST_MODE_BLOCK
1082
+ })
1083
+
1084
+ console.log(res);
1085
+ ```
1086
+
1087
+ ## RPC Client Classes
1088
+
1089
+ If you want to instantiate a single client, you can generate RPC classes with the `rpcClients` option;
1090
+
1091
+ For any module that has a `Msg`, `Query` or `Service` type, a
1092
+
1093
+ ```js
1094
+ import { osmosis, cosmos } from 'osmojs';
1095
+
1096
+ const MsgClient = osmosis.gamm.v1beta1.MsgClientImpl;
1097
+ const QueryClient = osmosis.gamm.v1beta1.QueryClientImpl;
1098
+ const ServiceClient = cosmos.base.tendermint.v1beta1.ServiceClientImpl;
1099
+ ```
1100
+
1101
+ Here is an example of making a query if you want to use the RPC client classes manually:
1102
+
1103
+ ```js
1104
+ import { osmosis } from "osmojs";
1105
+ import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate";
1106
+ import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
1107
+
1108
+ export const main = async () => {
1109
+ const tmClient = await Tendermint34Client.connect(RPC_ENDPOINT);
1110
+ const QueryClientImpl = osmosis.gamm.v1beta1.QueryClientImpl;
1111
+ const client = new QueryClient(tmClient);
1112
+ const rpc = createProtobufRpcClient(client);
1113
+ const queryService = new QueryClientImpl(rpc);
1114
+ const pools = await queryService.pools({})
1115
+ console.log(pools);
1116
+ };
1117
+
1118
+ main().then(() => {
1119
+ console.log('all done')
1120
+ })
1121
+ ```
1122
+
1123
+ ## Instant RPC Methods
1124
+
1125
+ Using instantOps option to expose instant RPC methods.
1126
+
1127
+ For example, for this config:
1128
+ ```js
1129
+ {
1130
+ instantOps: [
1131
+ {
1132
+ className: "OsmosisClaim",
1133
+ include: {
1134
+ patterns: ["osmosis.**.*claim*"],
1135
+ },
1136
+ },
1137
+ {
1138
+ className: "CosmosAuthAccount",
1139
+ include: {
1140
+ patterns: [
1141
+ "cosmos.auth.**.*account*",
1142
+ "cosmos.auth.**.*Account*",
1143
+ "cosmos.gov.v1beta1.**",
1144
+ ],
1145
+ },
1146
+ nameMapping: {
1147
+ // name mapping rule for both Msg and Query methods.
1148
+ // moduleAccounts will be renamed to authModuleAccounts in generated class.
1149
+ All: {
1150
+ authModuleAccounts: "cosmos.auth.v1beta1.moduleAccounts",
1151
+ },
1152
+ // name mapping rule for Msg methods.
1153
+ Msg: {
1154
+ // deposit method under Msg will be renamed to txDeposit in generated class. While deposit method under Query will remain the same.
1155
+ txDeposit: "cosmos.gov.v1beta1.deposit",
1156
+ // Same for vote method.
1157
+ txVote: "cosmos.gov.v1beta1.vote",
1158
+ },
1159
+ },
1160
+ },
1161
+ ],
1162
+ }
1163
+ ```
1164
+
1165
+ There'll be an extra file generated in the root folder called service-ops.ts:
1166
+ ```js
1167
+ export interface OsmosisClaim extends _OsmosisClaimV1beta1Queryrpc.OsmosisClaim {}
1168
+ export class OsmosisClaim {
1169
+ rpc: TxRpc;
1170
+ init(rpc: TxRpc) {
1171
+ this.rpc = rpc;
1172
+ this.claimRecord = _OsmosisClaimV1beta1Queryrpc.createClientImpl(rpc).claimRecord;
1173
+ this.claimableForAction = _OsmosisClaimV1beta1Queryrpc.createClientImpl(rpc).claimableForAction;
1174
+ }
1175
+ }
1176
+ export interface CosmosAuthAccount extends _CosmosAuthV1beta1Queryrpc.CosmosAuthAccount, _CosmosGovV1beta1Queryrpc.CosmosAuthAccount, _CosmosGovV1beta1Txrpc.CosmosAuthAccount {}
1177
+ export class CosmosAuthAccount {
1178
+ rpc: TxRpc;
1179
+ init(rpc: TxRpc) {
1180
+ this.rpc = rpc;
1181
+ this.accounts = _CosmosAuthV1beta1Queryrpc.createClientImpl(rpc).accounts;
1182
+ this.account = _CosmosAuthV1beta1Queryrpc.createClientImpl(rpc).account;
1183
+
1184
+ // moduleAccounts has been renamed to authModuleAccounts as the nameMapping in settings.
1185
+ this.authModuleAccounts = _CosmosAuthV1beta1Queryrpc.createClientImpl(rpc).moduleAccounts;
1186
+
1187
+ this.proposal = _CosmosGovV1beta1Queryrpc.createClientImpl(rpc).proposal;
1188
+ this.proposals = _CosmosGovV1beta1Queryrpc.createClientImpl(rpc).proposals;
1189
+
1190
+ // vote under Query remains the same.
1191
+ this.vote = _CosmosGovV1beta1Queryrpc.createClientImpl(rpc).vote;
1192
+
1193
+ this.votes = _CosmosGovV1beta1Queryrpc.createClientImpl(rpc).votes;
1194
+ this.params = _CosmosGovV1beta1Queryrpc.createClientImpl(rpc).params;
1195
+
1196
+ // deposit under Query remains the same.
1197
+ this.deposit = _CosmosGovV1beta1Queryrpc.createClientImpl(rpc).deposit;
1198
+
1199
+ this.deposits = _CosmosGovV1beta1Queryrpc.createClientImpl(rpc).deposits;
1200
+ this.tallyResult = _CosmosGovV1beta1Queryrpc.createClientImpl(rpc).tallyResult;
1201
+ this.submitProposal = _CosmosGovV1beta1Txrpc.createClientImpl(rpc).submitProposal;
1202
+
1203
+ //same as txDeposite for vote here.
1204
+ this.txVote = _CosmosGovV1beta1Txrpc.createClientImpl(rpc).vote;
1205
+
1206
+ this.voteWeighted = _CosmosGovV1beta1Txrpc.createClientImpl(rpc).voteWeighted;
1207
+
1208
+ // deposit method under Msg will be renamed to txDeposit in generated class. While deposit method under Query will remain the same.
1209
+ this.txDeposit = _CosmosGovV1beta1Txrpc.createClientImpl(rpc).deposit;
1210
+ }
1211
+ }
1212
+ ```
1213
+
1214
+ ## Client Style Methods
1215
+
1216
+ Use client style to define the client file generated according to the config
1217
+
1218
+ For example, for this config:
1219
+ ```js
1220
+ clientStyle: {
1221
+ useUpdatedClientStyle: true,
1222
+ type: ['all-client', 'sdk-module-client', 'custom-client'],
1223
+ customClientOption: [
1224
+ {
1225
+ name: "custom",
1226
+ fileName: "custom-client.ts",
1227
+ include: {
1228
+ patterns: [
1229
+ "cosmos.gov.v1beta1*",
1230
+ "cosmos.gov.v1*",
1231
+ "ibc.core.channel.*",
1232
+ ],
1233
+ },
1234
+ },
1235
+ ],
1236
+ sdkModuleClientOption: [
1237
+ 'akash',
1238
+ 'osmosis',
1239
+ 'cosmos',
1240
+ ],
1241
+ },
1242
+ ```
1243
+
1244
+ There'll be client files (`all-module-client.ts`, `akash-sdk-module-client.ts`, `osmosis-sdk-module-client.ts`, `cosmos-sdk-module-client.ts`, `custom-client.ts`) generated in the root directory according to the setting.<br>
1245
+ The `all-module-client.ts` file consolidates all proto imports into one file and exports them as a single client.<br>
1246
+ All sdk module client files will be identical to the legacy `client.ts` files generated in each module directory, except they will be located in the root directory. <br>
1247
+ The custom client imports proto files based on `include.patterns`, allowing protos to originate from different modules.<br>
1248
+ For example the custom-client.ts will be like:
1249
+ ```ts
1250
+ export const cosmosIbcAminoConverters = {
1251
+ ...cosmosGovV1TxAmino.AminoConverter,
1252
+ ...cosmosGovV1beta1TxAmino.AminoConverter,
1253
+ ...ibcCoreChannelV1TxAmino.AminoConverter
1254
+ };
1255
+ export const cosmosIbcProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...cosmosGovV1TxRegistry.registry, ...cosmosGovV1beta1TxRegistry.registry, ...ibcCoreChannelV1TxRegistry.registry];
1256
+ export const getCosmosIbcSigningClientOptions = ({
1257
+ defaultTypes = defaultRegistryTypes
1258
+ }: {
1259
+ ...
1260
+ };
1261
+ export const getCosmosIbcSigningClient = async ({
1262
+ rpcEndpoint,
1263
+ signer,
1264
+ defaultTypes = defaultRegistryTypes
1265
+ }: {
1266
+ rpcEndpoint: string | HttpEndpoint;
1267
+ signer: OfflineSigner;
1268
+ defaultTypes?: ReadonlyArray<[string, GeneratedType]>;
1269
+ }) => {
1270
+ ...
1271
+ };
1272
+ ```
1273
+
1274
+ ## Manually registering types
1275
+
1276
+ This example is with `osmosis` module in `osmojs`, but it is the same pattern for any module.
1277
+
1278
+ NOTE: this is using `@cosmjs/stargate@0.28.4`
1279
+
1280
+ ```js
1281
+ import {
1282
+ AminoTypes,
1283
+ SigningStargateClient
1284
+ } from '@cosmjs/stargate';
1285
+ import { Registry } from '@cosmjs/proto-signing';
1286
+ import { defaultRegistryTypes } from '@cosmjs/stargate';
1287
+ import { OfflineSigner } from '@cosmjs/proto-signing'
1288
+ import { osmosis } from 'osmojs';
1289
+
1290
+ export const getCustomSigningClient = async ({ rpcEndpoint, signer }: { rpcEndpoint: string, signer: OfflineSigner }) => {
1291
+ // registry
1292
+ const registry = new Registry(defaultRegistryTypes);
1293
+
1294
+ // aminotypes
1295
+ const aminoTypes = new AminoTypes({
1296
+ ...osmosis.gamm.v1beta1.AminoConverter,
1297
+ ...osmosis.lockup.AminoConverter,
1298
+ ...osmosis.superfluid.AminoConverter
1299
+ });
1300
+
1301
+ // load the
1302
+ osmosis.gamm.v1beta1.load(registry);
1303
+ osmosis.lockup.load(registry);
1304
+ osmosis.superfluid.load(registry);
1305
+
1306
+ const client = await SigningStargateClient.connectWithSigner(
1307
+ rpcEndpoint,
1308
+ signer,
1309
+ { registry, aminoTypes }
1310
+ );
1311
+
1312
+ return client;
1313
+ };
1314
+ ```
1315
+
1316
+ ## JSON Patch Protos
1317
+
1318
+ The `prototypes.patch` configuration within the options object allows for dynamic modifications to protobuf definitions during code generation. This feature is designed to apply specific changes to proto files without altering the original source. By using JSON Patch operations such as `replace` and `add`, developers can customize the generated output to better fit project requirements when upstream SDK PRs are lagging or not in production.
1319
+
1320
+ Patches are specified as arrays of `Operation`s, where each operation is defined by:
1321
+ - `op`: The operation type (`add` or `replace`).
1322
+ - `path`: The JSON path to the target field, optionally prefixed with `@` to denote paths derived automatically from the package name, simplifying navigation within the proto file's structure.
1323
+ - `value`: The new value to be set at the target location specified by the path.
1324
+
1325
+ Here is how these patches can be defined within the prototypes configuration:
1326
+
1327
+ ```json
1328
+ {
1329
+ "prototypes": {
1330
+ "patch": {
1331
+ "cosmwasm/wasm/v1/types.proto": [
1332
+ {
1333
+ "op": "replace",
1334
+ "path": "@/AccessType/valuesOptions/ACCESS_TYPE_UNSPECIFIED/(gogoproto.enumvalue_customname)",
1335
+ "value": "UnspecifiedAccess"
1336
+ },
1337
+ {
1338
+ "op": "replace",
1339
+ "path": "@/AccessType/valuesOptions/ACCESS_TYPE_NOBODY/(gogoproto.enumvalue_customname)",
1340
+ "value": "NobodyAccess"
1341
+ },
1342
+ {
1343
+ "op": "add",
1344
+ "path": "@/AccessType/values/ACCESS_TYPE_SUPER_FUN",
1345
+ "value": 4
1346
+ },
1347
+ {
1348
+ "op": "add",
1349
+ "path": "@/AccessType/valuesOptions/ACCESS_TYPE_SUPER_FUN",
1350
+ "value": {
1351
+ "(gogoproto.enumvalue_customname)": "SuperFunAccessType"
1352
+ }
1353
+ }
1354
+ ]
1355
+ }
1356
+ }
1357
+ }
1358
+ ```
1359
+
1360
+
1361
+ ## CosmWasm
1362
+
1363
+ Generate TypeScript SDKs for your CosmWasm smart contracts by using the `cosmwasm` option on `TelescopeOptions`. The `cosmwasm` option is actually a direct reference to the `TSBuilderInput` object, for the most up-to-date documentation, visit [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen).
1364
+
1365
+ ```ts
1366
+ import { TSBuilderInput } from '@cosmwasm/ts-codegen';
1367
+ const options: TelescopeOptions = {
1368
+ cosmwasm: {
1369
+ contracts: [
1370
+ {
1371
+ name: 'SG721',
1372
+ dir: './path/to/sg721/schema'
1373
+ },
1374
+ {
1375
+ name: 'Minter',
1376
+ dir: './path/to/Minter/schema'
1377
+ }
1378
+ ],
1379
+ outPath: './path/to/code/src/'
1380
+ }
1381
+ };
1382
+ ```
1383
+
1384
+
1385
+ ## Helper Functions Configuration
1386
+ The nameMappers object supports three service types: All, Query, and Msg. Each pattern within these categories can specify:
1387
+ ```js
1388
+ {
1389
+ "pattern": {
1390
+ funcBody: (ctx: AliasNameMappersContext) => string, // Function to transform the method name
1391
+ hookPrefix?: string // Prefix for the hook function (default: "use")
1392
+ }
1393
+ }
1394
+ ```
1395
+
1396
+ ```js
1397
+ const options: TelescopeOptions = {
1398
+ helperFunctions: {
1399
+ enabled: true,
1400
+ genCustomHooks: {
1401
+ react: true,
1402
+ vue: true
1403
+ },
1404
+ include: {
1405
+ patterns: ["cosmos.gov.v1beta1.**", "cosmos.bank.v1beta1.*Send*"],
1406
+ },
1407
+ nameMappers: {
1408
+ All: {
1409
+ "cosmos.gov.v1beta1.*Vote*": {
1410
+ funcBody: (ctx) => `helper${ctx.name}`,
1411
+ hookPrefix: "use",
1412
+ },
1413
+ },
1414
+ Query: {
1415
+ "cosmos.gov.v1beta1.*Deposits*": {
1416
+ funcBody: (ctx) => `goOver${ctx.name}`,
1417
+ },
1418
+ },
1419
+ Msg: {
1420
+ "cosmos.gov.v1beta1.*VoteWeighted*": {
1421
+ funcBody: (ctx) => `lets${ctx.name}`,
1422
+ hookPrefix: "useTx",
1423
+ },
1424
+ },
1425
+ },
1426
+ },
1427
+ };
1428
+
1429
+ ```
1430
+ ### Pattern Matching Priority:
1431
+ 1. Service-specific patterns (`Query`, `Msg`) take precedence over `All` patterns
1432
+ 2. More specific patterns take precedence over general patterns
1433
+ 3. Patterns are case-sensitive
1434
+ ### Generated Output Examples:
1435
+ - For a method named `VoteWeighted`:
1436
+ - Default: `createVoteWeighted` and `useVoteWeighted`
1437
+ - With custom mapping: `constructLetsVoteWeighted` and `useTxLetsVoteWeighted`
1438
+ ### Notes:
1439
+ - Patterns support glob-style matching (e.g., `**`, `*`)
1440
+ - Each service type can have its own naming conventions
1441
+ - Custom prefixes are optional; defaults will be used if not specified
1442
+ - Function body transformations can be customized using the funcBody property
1443
+
1444
+
1445
+ ## Dependencies
1446
+
1447
+ If you don't use the boilerplate, you will need to manually install
1448
+
1449
+ * `@cosmjs/amino`
1450
+ * `@cosmjs/proto-signing`
1451
+ * `@cosmjs/stargate`
1452
+ * `@cosmjs/tendermint-rpc`
1453
+
1454
+ ```sh
1455
+ yarn add @cosmjs/amino @cosmjs/proto-signing @cosmjs/stargate @cosmjs/tendermint-rpc
1456
+ ```
1457
+
1458
+ If you use the LCD Client generation, you'll need to add
1459
+
1460
+ * `@cosmology/lcd`
1461
+
1462
+ ```sh
1463
+ yarn add @cosmology/lcd
1464
+ ```
1465
+
1466
+ ## Troubleshooting
1467
+
1468
+ ### Create React App
1469
+
1470
+ CRA requires that you update Webpack configurations:
1471
+
1472
+ <https://github.com/cosmos/cosmjs/blob/656e02374898afe755e980e93390591b4b65fd86/README.md#webpack-configs>
1473
+
1474
+ Here is an example of a `config-overrides.js`:
1475
+
1476
+ <https://github.com/pyramation/osmosis-ui/blob/main/config-overrides.js>
1477
+
1478
+ ### Babel
1479
+
1480
+ This should not be an issue, but if you experience problems with syntax or are not using `preset-env`, you may need these babel plugins:
1481
+
1482
+ * [babel-plugin-proposal-numeric-separator](https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator)
1483
+ * [babel-plugin-proposal-optional-chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining)
1484
+ * [babel-plugin-proposal-nullish-coalescing-operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator)
1485
+
1486
+ ## Developing
1487
+
1488
+ See our [documentation](https://github.com/hyperweb-io/telescope/blob/main/docs/README.md) for how to contribute and develop Telescope.
1489
+
1490
+ ## Sponsors
1491
+
1492
+ Kudos to our sponsors:
1493
+
1494
+ * [Osmosis](https://osmosis.zone) funded the creation of Telescope.
1495
+
1496
+ ## Interchain JavaScript Stack ⚛️
1497
+
1498
+ A unified toolkit for building applications and smart contracts in the Interchain ecosystem
1499
+
1500
+ | Category | Tools | Description |
1501
+ |----------------------|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
1502
+ | **Chain Information** | [**Chain Registry**](https://github.com/hyperweb-io/chain-registry), [**Utils**](https://www.npmjs.com/package/@chain-registry/utils), [**Client**](https://www.npmjs.com/package/@chain-registry/client) | Everything from token symbols, logos, and IBC denominations for all assets you want to support in your application. |
1503
+ | **Wallet Connectors**| [**Interchain Kit**](https://github.com/hyperweb-io/interchain-kit)<sup>beta</sup>, [**Cosmos Kit**](https://github.com/hyperweb-io/cosmos-kit) | Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface. |
1504
+ | **Signing Clients** | [**InterchainJS**](https://github.com/hyperweb-io/interchainjs)<sup>beta</sup>, [**CosmJS**](https://github.com/cosmos/cosmjs) | A single, universal signing interface for any network |
1505
+ | **SDK Clients** | [**Telescope**](https://github.com/hyperweb-io/telescope) | Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules. |
1506
+ | **Starter Kits** | [**Create Interchain App**](https://github.com/hyperweb-io/create-interchain-app)<sup>beta</sup> | Set up a modern Interchain app by running one command. |
1507
+ | **UI Kits** | [**Interchain UI**](https://github.com/hyperweb-io/interchain-ui) | The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit. |
1508
+ | **Testing Frameworks** | [**Starship**](https://github.com/hyperweb-io/starship) | Unified Testing and Development for the Interchain. |
1509
+ | **TypeScript Smart Contracts** | [**Create Hyperweb App**](https://github.com/hyperweb-io/create-hyperweb-app) | Build and deploy full-stack blockchain applications with TypeScript |
1510
+ | **CosmWasm Contracts** | [**CosmWasm TS Codegen**](https://github.com/CosmWasm/ts-codegen) | Convert your CosmWasm smart contracts into dev-friendly TypeScript classes. |
1511
+
1512
+ ## Credits
1513
+
1514
+ 🛠 Built by Hyperweb (formerly Cosmology) — if you like our tools, please checkout and contribute to [our github ⚛️](https://github.com/hyperweb-io)
1515
+
1516
+ Thanks to these engineers, teams and projects for inspiring Telescope:
1517
+
1518
+ * [@webmaster128](https://github.com/webmaster128)
1519
+ * [@assafmo](https://github.com/assafmo)
1520
+ * [osmosis-frontend](https://github.com/osmosis-labs/osmosis-frontend)
1521
+ * [cosmjs](https://github.com/cosmos/cosmjs)
1522
+ * [ts-proto](https://github.com/stephenh/ts-proto)
1523
+ * [keplr-wallet](https://github.com/chainapsis/keplr-wallet)
1524
+
1525
+ ## Disclaimer
1526
+
1527
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
1528
+
1529
+ No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.