@hyperweb/telescope 2.1.0 → 2.2.1

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 (448) hide show
  1. package/README.md +13 -13
  2. package/{main/bundle.js → bundle.js} +17 -7
  3. package/{types/commands → commands}/download.d.ts +2 -2
  4. package/{main/commands → commands}/download.js +17 -7
  5. package/{main/commands → commands}/generate.js +17 -7
  6. package/{main/commands → commands}/transpile.js +17 -7
  7. package/esm/build.d.ts +41 -0
  8. package/esm/builder.d.ts +50 -0
  9. package/esm/bundle.d.ts +30 -0
  10. package/esm/bundler.d.ts +31 -0
  11. package/esm/commands/download.d.ts +5 -0
  12. package/esm/commands/generate.d.ts +2 -0
  13. package/esm/commands/transpile.d.ts +4 -0
  14. package/{module → esm}/generators/create-helpers.js +2 -1
  15. package/{module → esm}/generators/create-index.js +2 -2
  16. package/{module → esm}/generators/create-sdk-module-stargate-clients.js +1 -1
  17. package/{module → esm}/generators/create-stargate-clients.js +1 -1
  18. package/{types → esm}/utils/index.d.ts +1 -1
  19. package/generators/create-aggregated-lcd-client.d.ts +2 -0
  20. package/generators/create-amino-converters.d.ts +3 -0
  21. package/generators/create-bundle.d.ts +3 -0
  22. package/generators/create-helpers.d.ts +2 -0
  23. package/{main/generators → generators}/create-helpers.js +4 -6
  24. package/generators/create-index.d.ts +2 -0
  25. package/{main/generators → generators}/create-index.js +21 -11
  26. package/generators/create-lcd-client-all.d.ts +3 -0
  27. package/{main/generators → generators}/create-lcd-client-all.js +17 -7
  28. package/generators/create-lcd-client-scoped.d.ts +3 -0
  29. package/{main/generators → generators}/create-lcd-client-scoped.js +17 -7
  30. package/generators/create-lcd-clients.d.ts +3 -0
  31. package/generators/create-mcp-server.d.ts +3 -0
  32. package/generators/create-mobx-bundle.d.ts +2 -0
  33. package/{main/generators → generators}/create-mobx-bundle.js +17 -7
  34. package/generators/create-msg-funcs.d.ts +3 -0
  35. package/generators/create-pinia-store-bundle.d.ts +2 -0
  36. package/{main/generators → generators}/create-pinia-store-bundle.js +17 -7
  37. package/generators/create-pinia-store.d.ts +3 -0
  38. package/generators/create-query-funcs.d.ts +3 -0
  39. package/generators/create-react-query-bundle.d.ts +2 -0
  40. package/{main/generators → generators}/create-react-query-bundle.js +17 -7
  41. package/generators/create-registries.d.ts +3 -0
  42. package/generators/create-root-readme.d.ts +2 -0
  43. package/generators/create-rpc-msg-client-all.d.ts +3 -0
  44. package/{main/generators → generators}/create-rpc-msg-client-all.js +17 -7
  45. package/generators/create-rpc-msg-client-scoped.d.ts +3 -0
  46. package/{main/generators → generators}/create-rpc-msg-client-scoped.js +17 -7
  47. package/generators/create-rpc-msg-clients.d.ts +3 -0
  48. package/generators/create-rpc-ops-bundle.d.ts +2 -0
  49. package/{main/generators → generators}/create-rpc-ops-bundle.js +17 -7
  50. package/generators/create-rpc-query-client-all.d.ts +3 -0
  51. package/{main/generators → generators}/create-rpc-query-client-all.js +17 -7
  52. package/generators/create-rpc-query-client-scoped.d.ts +3 -0
  53. package/{main/generators → generators}/create-rpc-query-client-scoped.js +17 -7
  54. package/generators/create-rpc-query-clients.d.ts +3 -0
  55. package/generators/create-sdk-module-stargate-clients.d.ts +3 -0
  56. package/{main/generators → generators}/create-sdk-module-stargate-clients.js +1 -1
  57. package/generators/create-stargate-clients.d.ts +3 -0
  58. package/{main/generators → generators}/create-stargate-clients.js +1 -1
  59. package/generators/create-types.d.ts +3 -0
  60. package/{main/generators → generators}/create-types.js +17 -7
  61. package/generators/customize-utils.d.ts +2 -0
  62. package/helpers/__test__/internalTimestamp.d.ts +21 -0
  63. package/{main/helpers → helpers}/__test__/internalTimestamp.js +4 -5
  64. package/helpers/__test__/internalTimestampBigint.d.ts +20 -0
  65. package/{main/helpers → helpers}/__test__/internalTimestampBigint.js +4 -5
  66. package/helpers/binary-coder.d.ts +2 -0
  67. package/helpers/decimals.d.ts +1 -0
  68. package/helpers/external-comet.d.ts +1 -0
  69. package/helpers/external-icjs.d.ts +1 -0
  70. package/helpers/external.d.ts +1 -0
  71. package/helpers/grpc-gateway.d.ts +1 -0
  72. package/helpers/grpc-web.d.ts +1 -0
  73. package/helpers/helper-func-types-interface.d.ts +2 -0
  74. package/helpers/helper-func-types.d.ts +2 -0
  75. package/helpers/internal-for-bigint.d.ts +2 -0
  76. package/helpers/internal.d.ts +2 -0
  77. package/helpers/json-safe.d.ts +1 -0
  78. package/helpers/mobx.d.ts +1 -0
  79. package/helpers/pinia-endpoint.d.ts +1 -0
  80. package/helpers/react-query-hooks-icjs.d.ts +2 -0
  81. package/helpers/react-query-hooks.d.ts +2 -0
  82. package/helpers/react-query.d.ts +2 -0
  83. package/{types/helpers/vue-query.d.ts → helpers/registry-helper.d.ts} +1 -1
  84. package/helpers/types-helper.d.ts +2 -0
  85. package/helpers/utf8-helper.d.ts +1 -0
  86. package/helpers/varint.d.ts +1 -0
  87. package/helpers/vue-query-hooks.d.ts +2 -0
  88. package/imports.d.ts +17 -0
  89. package/{main/imports.js → imports.js} +17 -7
  90. package/index.d.ts +6 -0
  91. package/package.json +30 -48
  92. package/parse.d.ts +15 -0
  93. package/prompt.d.ts +3 -0
  94. package/protod/bufbuild.d.ts +6 -0
  95. package/{main/protod → protod}/bufbuild.js +5 -6
  96. package/protod/config.d.ts +7 -0
  97. package/protod/git-repo.d.ts +11 -0
  98. package/protod/recursive.d.ts +4 -0
  99. package/{main/protod → protod}/recursive.js +3 -4
  100. package/protod/types.d.ts +49 -0
  101. package/protod/utils.d.ts +11 -0
  102. package/{main/protod → protod}/utils.js +8 -9
  103. package/types.d.ts +43 -0
  104. package/utils/common-create-bundle.d.ts +18 -0
  105. package/utils/files.d.ts +5 -0
  106. package/{main/utils → utils}/files.js +19 -9
  107. package/utils/index.d.ts +16 -0
  108. package/utils/unused.d.ts +5 -0
  109. package/{main/utils → utils}/unused.js +17 -7
  110. package/main/cli.js +0 -52
  111. package/main/cmds.js +0 -16
  112. package/main/contracts/generate.js +0 -31
  113. package/main/contracts/install.js +0 -107
  114. package/main/contracts/message-composer.js +0 -31
  115. package/main/contracts/react-query.js +0 -31
  116. package/main/contracts/recoil.js +0 -31
  117. package/main/file.js +0 -20
  118. package/main/generators/create-cosmwasm-bundle.js +0 -15
  119. package/main/telescope.js +0 -10
  120. package/main/utils/contracts.js +0 -39
  121. package/module/cli.js +0 -25
  122. package/module/cmds.js +0 -10
  123. package/module/contracts/generate.js +0 -29
  124. package/module/contracts/install.js +0 -105
  125. package/module/contracts/message-composer.js +0 -29
  126. package/module/contracts/react-query.js +0 -29
  127. package/module/contracts/recoil.js +0 -29
  128. package/module/file.js +0 -18
  129. package/module/generators/create-cosmwasm-bundle.js +0 -11
  130. package/module/telescope.js +0 -8
  131. package/module/utils/contracts.js +0 -33
  132. package/src/build.ts +0 -255
  133. package/src/builder.ts +0 -292
  134. package/src/bundle.ts +0 -160
  135. package/src/bundler.ts +0 -153
  136. package/src/cli.js +0 -31
  137. package/src/cmds.js +0 -11
  138. package/src/commands/download.ts +0 -120
  139. package/src/commands/generate.ts +0 -156
  140. package/src/commands/install.ts +0 -154
  141. package/src/commands/transpile.ts +0 -205
  142. package/src/file.js +0 -20
  143. package/src/generators/create-aggregated-lcd-client.ts +0 -133
  144. package/src/generators/create-all-stargate-clients.ts +0 -121
  145. package/src/generators/create-amino-converters.ts +0 -62
  146. package/src/generators/create-bundle.ts +0 -143
  147. package/src/generators/create-custom-stargate-clients.ts +0 -128
  148. package/src/generators/create-helpers.ts +0 -209
  149. package/src/generators/create-index.ts +0 -72
  150. package/src/generators/create-lcd-client-all.ts +0 -139
  151. package/src/generators/create-lcd-client-scoped.ts +0 -109
  152. package/src/generators/create-lcd-clients.ts +0 -108
  153. package/src/generators/create-mcp-server.ts +0 -1774
  154. package/src/generators/create-mobx-bundle.ts +0 -31
  155. package/src/generators/create-msg-funcs.ts +0 -219
  156. package/src/generators/create-pinia-store-bundle.ts +0 -35
  157. package/src/generators/create-pinia-store.ts +0 -121
  158. package/src/generators/create-query-funcs.ts +0 -224
  159. package/src/generators/create-react-query-bundle.ts +0 -111
  160. package/src/generators/create-registries.ts +0 -70
  161. package/src/generators/create-root-readme.ts +0 -403
  162. package/src/generators/create-rpc-msg-client-all.ts +0 -167
  163. package/src/generators/create-rpc-msg-client-scoped.ts +0 -147
  164. package/src/generators/create-rpc-msg-clients.ts +0 -165
  165. package/src/generators/create-rpc-ops-bundle.ts +0 -155
  166. package/src/generators/create-rpc-query-client-all.ts +0 -173
  167. package/src/generators/create-rpc-query-client-scoped.ts +0 -142
  168. package/src/generators/create-rpc-query-clients.ts +0 -304
  169. package/src/generators/create-sdk-module-stargate-clients.ts +0 -120
  170. package/src/generators/create-stargate-clients.ts +0 -123
  171. package/src/generators/create-types.ts +0 -236
  172. package/src/generators/customize-utils.ts +0 -52
  173. package/src/helpers/__test__/internalTimestamp.test.ts +0 -79
  174. package/src/helpers/__test__/internalTimestamp.ts +0 -58
  175. package/src/helpers/__test__/internalTimestampBigint.test.ts +0 -78
  176. package/src/helpers/__test__/internalTimestampBigint.ts +0 -58
  177. package/src/helpers/binary-coder.ts +0 -533
  178. package/src/helpers/decimals.ts +0 -108
  179. package/src/helpers/external-comet.ts +0 -49
  180. package/src/helpers/external-icjs.ts +0 -43
  181. package/src/helpers/external.ts +0 -28
  182. package/src/helpers/grpc-gateway.ts +0 -345
  183. package/src/helpers/grpc-web.ts +0 -11
  184. package/src/helpers/helper-func-types-interface.ts +0 -104
  185. package/src/helpers/helper-func-types.ts +0 -91
  186. package/src/helpers/internal-for-bigint.ts +0 -259
  187. package/src/helpers/internal.ts +0 -241
  188. package/src/helpers/json-safe.ts +0 -11
  189. package/src/helpers/mobx.ts +0 -77
  190. package/src/helpers/pinia-endpoint.ts +0 -17
  191. package/src/helpers/react-query-hooks-icjs.ts +0 -223
  192. package/src/helpers/react-query-hooks.ts +0 -266
  193. package/src/helpers/react-query.ts +0 -101
  194. package/src/helpers/registry-helper.ts +0 -227
  195. package/src/helpers/types-helper.ts +0 -169
  196. package/src/helpers/utf8-helper.ts +0 -143
  197. package/src/helpers/varint.ts +0 -483
  198. package/src/helpers/vue-query-hooks.ts +0 -224
  199. package/src/imports.ts +0 -499
  200. package/src/index.ts +0 -12
  201. package/src/parse.ts +0 -243
  202. package/src/prompt.js +0 -65
  203. package/src/protod/bufbuild.spec.ts +0 -80
  204. package/src/protod/bufbuild.ts +0 -95
  205. package/src/protod/config.ts +0 -30
  206. package/src/protod/git-repo.ts +0 -74
  207. package/src/protod/recursive.spec.ts +0 -164
  208. package/src/protod/recursive.ts +0 -190
  209. package/src/protod/test-data/.protod.config.json +0 -42
  210. package/src/protod/test-data/buf.lock +0 -23
  211. package/src/protod/test-data/buf.yaml +0 -25
  212. package/src/protod/test-data/buf2.yaml +0 -20
  213. package/src/protod/test-data/cosmos/buf.lock +0 -23
  214. package/src/protod/test-data/cosmos/crypto/secp256k1/keys.proto +0 -38
  215. package/src/protod/test-data/model.proto +0 -101
  216. package/src/protod/types.ts +0 -55
  217. package/src/protod/utils.spec.ts +0 -68
  218. package/src/protod/utils.ts +0 -90
  219. package/src/telescope.js +0 -9
  220. package/src/types.ts +0 -46
  221. package/src/utils/common-create-bundle.ts +0 -62
  222. package/src/utils/files.ts +0 -145
  223. package/src/utils/index.ts +0 -149
  224. package/src/utils/unused.ts +0 -52
  225. package/types/cli.d.ts +0 -1
  226. package/types/cmds.d.ts +0 -10
  227. package/types/contracts/generate.d.ts +0 -2
  228. package/types/contracts/message-composer.d.ts +0 -2
  229. package/types/contracts/react-query.d.ts +0 -2
  230. package/types/contracts/recoil.d.ts +0 -2
  231. package/types/file.d.ts +0 -2
  232. package/types/generators/create-cosmwasm-bundle.d.ts +0 -2
  233. package/types/generators/create-unified-stargate-clients.d.ts +0 -3
  234. package/types/helpers/generated-type.d.ts +0 -1
  235. package/types/helpers/internalForBigInt.d.ts +0 -1
  236. package/types/helpers/types.d.ts +0 -1
  237. package/types/protod/proto-download.d.ts +0 -2
  238. package/types/telescope.d.ts +0 -2
  239. package/types/utils/contracts.d.ts +0 -6
  240. /package/{types/build.d.ts → build.d.ts} +0 -0
  241. /package/{main/build.js → build.js} +0 -0
  242. /package/{types/builder.d.ts → builder.d.ts} +0 -0
  243. /package/{main/builder.js → builder.js} +0 -0
  244. /package/{types/bundle.d.ts → bundle.d.ts} +0 -0
  245. /package/{types/bundler.d.ts → bundler.d.ts} +0 -0
  246. /package/{main/bundler.js → bundler.js} +0 -0
  247. /package/{types/commands → commands}/generate.d.ts +0 -0
  248. /package/{types/commands → commands}/install.d.ts +0 -0
  249. /package/{main/commands → commands}/install.js +0 -0
  250. /package/{types/commands → commands}/transpile.d.ts +0 -0
  251. /package/{module → esm}/build.js +0 -0
  252. /package/{module → esm}/builder.js +0 -0
  253. /package/{module → esm}/bundle.js +0 -0
  254. /package/{module → esm}/bundler.js +0 -0
  255. /package/{module → esm}/commands/download.js +0 -0
  256. /package/{module → esm}/commands/generate.js +0 -0
  257. /package/{types/contracts → esm/commands}/install.d.ts +0 -0
  258. /package/{module → esm}/commands/install.js +0 -0
  259. /package/{module → esm}/commands/transpile.js +0 -0
  260. /package/{types → esm}/generators/create-aggregated-lcd-client.d.ts +0 -0
  261. /package/{module → esm}/generators/create-aggregated-lcd-client.js +0 -0
  262. /package/{types → esm}/generators/create-all-stargate-clients.d.ts +0 -0
  263. /package/{module → esm}/generators/create-all-stargate-clients.js +0 -0
  264. /package/{types → esm}/generators/create-amino-converters.d.ts +0 -0
  265. /package/{module → esm}/generators/create-amino-converters.js +0 -0
  266. /package/{types → esm}/generators/create-bundle.d.ts +0 -0
  267. /package/{module → esm}/generators/create-bundle.js +0 -0
  268. /package/{types → esm}/generators/create-custom-stargate-clients.d.ts +0 -0
  269. /package/{module → esm}/generators/create-custom-stargate-clients.js +0 -0
  270. /package/{types → esm}/generators/create-helpers.d.ts +0 -0
  271. /package/{types → esm}/generators/create-index.d.ts +0 -0
  272. /package/{types → esm}/generators/create-lcd-client-all.d.ts +0 -0
  273. /package/{module → esm}/generators/create-lcd-client-all.js +0 -0
  274. /package/{types → esm}/generators/create-lcd-client-scoped.d.ts +0 -0
  275. /package/{module → esm}/generators/create-lcd-client-scoped.js +0 -0
  276. /package/{types → esm}/generators/create-lcd-clients.d.ts +0 -0
  277. /package/{module → esm}/generators/create-lcd-clients.js +0 -0
  278. /package/{types → esm}/generators/create-mcp-server.d.ts +0 -0
  279. /package/{module → esm}/generators/create-mcp-server.js +0 -0
  280. /package/{types → esm}/generators/create-mobx-bundle.d.ts +0 -0
  281. /package/{module → esm}/generators/create-mobx-bundle.js +0 -0
  282. /package/{types → esm}/generators/create-msg-funcs.d.ts +0 -0
  283. /package/{module → esm}/generators/create-msg-funcs.js +0 -0
  284. /package/{types → esm}/generators/create-pinia-store-bundle.d.ts +0 -0
  285. /package/{module → esm}/generators/create-pinia-store-bundle.js +0 -0
  286. /package/{types → esm}/generators/create-pinia-store.d.ts +0 -0
  287. /package/{module → esm}/generators/create-pinia-store.js +0 -0
  288. /package/{types → esm}/generators/create-query-funcs.d.ts +0 -0
  289. /package/{module → esm}/generators/create-query-funcs.js +0 -0
  290. /package/{types → esm}/generators/create-react-query-bundle.d.ts +0 -0
  291. /package/{module → esm}/generators/create-react-query-bundle.js +0 -0
  292. /package/{types → esm}/generators/create-registries.d.ts +0 -0
  293. /package/{module → esm}/generators/create-registries.js +0 -0
  294. /package/{types → esm}/generators/create-root-readme.d.ts +0 -0
  295. /package/{module → esm}/generators/create-root-readme.js +0 -0
  296. /package/{types → esm}/generators/create-rpc-msg-client-all.d.ts +0 -0
  297. /package/{module → esm}/generators/create-rpc-msg-client-all.js +0 -0
  298. /package/{types → esm}/generators/create-rpc-msg-client-scoped.d.ts +0 -0
  299. /package/{module → esm}/generators/create-rpc-msg-client-scoped.js +0 -0
  300. /package/{types → esm}/generators/create-rpc-msg-clients.d.ts +0 -0
  301. /package/{module → esm}/generators/create-rpc-msg-clients.js +0 -0
  302. /package/{types → esm}/generators/create-rpc-ops-bundle.d.ts +0 -0
  303. /package/{module → esm}/generators/create-rpc-ops-bundle.js +0 -0
  304. /package/{types → esm}/generators/create-rpc-query-client-all.d.ts +0 -0
  305. /package/{module → esm}/generators/create-rpc-query-client-all.js +0 -0
  306. /package/{types → esm}/generators/create-rpc-query-client-scoped.d.ts +0 -0
  307. /package/{module → esm}/generators/create-rpc-query-client-scoped.js +0 -0
  308. /package/{types → esm}/generators/create-rpc-query-clients.d.ts +0 -0
  309. /package/{module → esm}/generators/create-rpc-query-clients.js +0 -0
  310. /package/{types → esm}/generators/create-sdk-module-stargate-clients.d.ts +0 -0
  311. /package/{types → esm}/generators/create-stargate-clients.d.ts +0 -0
  312. /package/{types → esm}/generators/create-types.d.ts +0 -0
  313. /package/{module → esm}/generators/create-types.js +0 -0
  314. /package/{types → esm}/generators/customize-utils.d.ts +0 -0
  315. /package/{module → esm}/generators/customize-utils.js +0 -0
  316. /package/{types → esm}/helpers/__test__/internalTimestamp.d.ts +0 -0
  317. /package/{module → esm}/helpers/__test__/internalTimestamp.js +0 -0
  318. /package/{types → esm}/helpers/__test__/internalTimestampBigint.d.ts +0 -0
  319. /package/{module → esm}/helpers/__test__/internalTimestampBigint.js +0 -0
  320. /package/{types → esm}/helpers/binary-coder.d.ts +0 -0
  321. /package/{module → esm}/helpers/binary-coder.js +0 -0
  322. /package/{types → esm}/helpers/decimals.d.ts +0 -0
  323. /package/{module → esm}/helpers/decimals.js +0 -0
  324. /package/{types → esm}/helpers/external-comet.d.ts +0 -0
  325. /package/{module → esm}/helpers/external-comet.js +0 -0
  326. /package/{types → esm}/helpers/external-icjs.d.ts +0 -0
  327. /package/{module → esm}/helpers/external-icjs.js +0 -0
  328. /package/{types → esm}/helpers/external.d.ts +0 -0
  329. /package/{module → esm}/helpers/external.js +0 -0
  330. /package/{types → esm}/helpers/grpc-gateway.d.ts +0 -0
  331. /package/{module → esm}/helpers/grpc-gateway.js +0 -0
  332. /package/{types → esm}/helpers/grpc-web.d.ts +0 -0
  333. /package/{module → esm}/helpers/grpc-web.js +0 -0
  334. /package/{types → esm}/helpers/helper-func-types-interface.d.ts +0 -0
  335. /package/{module → esm}/helpers/helper-func-types-interface.js +0 -0
  336. /package/{types → esm}/helpers/helper-func-types.d.ts +0 -0
  337. /package/{module → esm}/helpers/helper-func-types.js +0 -0
  338. /package/{types → esm}/helpers/index.d.ts +0 -0
  339. /package/{module → esm}/helpers/index.js +0 -0
  340. /package/{types → esm}/helpers/internal-for-bigint.d.ts +0 -0
  341. /package/{module → esm}/helpers/internal-for-bigint.js +0 -0
  342. /package/{types → esm}/helpers/internal.d.ts +0 -0
  343. /package/{module → esm}/helpers/internal.js +0 -0
  344. /package/{types → esm}/helpers/json-safe.d.ts +0 -0
  345. /package/{module → esm}/helpers/json-safe.js +0 -0
  346. /package/{types → esm}/helpers/mobx.d.ts +0 -0
  347. /package/{module → esm}/helpers/mobx.js +0 -0
  348. /package/{types → esm}/helpers/pinia-endpoint.d.ts +0 -0
  349. /package/{module → esm}/helpers/pinia-endpoint.js +0 -0
  350. /package/{types → esm}/helpers/react-query-hooks-icjs.d.ts +0 -0
  351. /package/{module → esm}/helpers/react-query-hooks-icjs.js +0 -0
  352. /package/{types → esm}/helpers/react-query-hooks.d.ts +0 -0
  353. /package/{module → esm}/helpers/react-query-hooks.js +0 -0
  354. /package/{types → esm}/helpers/react-query.d.ts +0 -0
  355. /package/{module → esm}/helpers/react-query.js +0 -0
  356. /package/{types → esm}/helpers/registry-helper.d.ts +0 -0
  357. /package/{module → esm}/helpers/registry-helper.js +0 -0
  358. /package/{types → esm}/helpers/types-helper.d.ts +0 -0
  359. /package/{module → esm}/helpers/types-helper.js +0 -0
  360. /package/{types → esm}/helpers/utf8-helper.d.ts +0 -0
  361. /package/{module → esm}/helpers/utf8-helper.js +0 -0
  362. /package/{types → esm}/helpers/varint.d.ts +0 -0
  363. /package/{module → esm}/helpers/varint.js +0 -0
  364. /package/{types → esm}/helpers/vue-query-hooks.d.ts +0 -0
  365. /package/{module → esm}/helpers/vue-query-hooks.js +0 -0
  366. /package/{types → esm}/imports.d.ts +0 -0
  367. /package/{module → esm}/imports.js +0 -0
  368. /package/{types → esm}/index.d.ts +0 -0
  369. /package/{module → esm}/index.js +0 -0
  370. /package/{types → esm}/parse.d.ts +0 -0
  371. /package/{module → esm}/parse.js +0 -0
  372. /package/{types → esm}/prompt.d.ts +0 -0
  373. /package/{module → esm}/prompt.js +0 -0
  374. /package/{types → esm}/protod/bufbuild.d.ts +0 -0
  375. /package/{module → esm}/protod/bufbuild.js +0 -0
  376. /package/{types → esm}/protod/config.d.ts +0 -0
  377. /package/{module → esm}/protod/config.js +0 -0
  378. /package/{types → esm}/protod/git-repo.d.ts +0 -0
  379. /package/{module → esm}/protod/git-repo.js +0 -0
  380. /package/{types → esm}/protod/index.d.ts +0 -0
  381. /package/{module → esm}/protod/index.js +0 -0
  382. /package/{types → esm}/protod/recursive.d.ts +0 -0
  383. /package/{module → esm}/protod/recursive.js +0 -0
  384. /package/{types → esm}/protod/types.d.ts +0 -0
  385. /package/{module → esm}/protod/types.js +0 -0
  386. /package/{types → esm}/protod/utils.d.ts +0 -0
  387. /package/{module → esm}/protod/utils.js +0 -0
  388. /package/{types → esm}/types.d.ts +0 -0
  389. /package/{module → esm}/types.js +0 -0
  390. /package/{types → esm}/utils/common-create-bundle.d.ts +0 -0
  391. /package/{module → esm}/utils/common-create-bundle.js +0 -0
  392. /package/{types → esm}/utils/files.d.ts +0 -0
  393. /package/{module → esm}/utils/files.js +0 -0
  394. /package/{module → esm}/utils/index.js +0 -0
  395. /package/{types → esm}/utils/unused.d.ts +0 -0
  396. /package/{module → esm}/utils/unused.js +0 -0
  397. /package/{main/generators → generators}/create-aggregated-lcd-client.js +0 -0
  398. /package/{types/generators/create-combined-stargate-clients.d.ts → generators/create-all-stargate-clients.d.ts} +0 -0
  399. /package/{main/generators → generators}/create-all-stargate-clients.js +0 -0
  400. /package/{main/generators → generators}/create-amino-converters.js +0 -0
  401. /package/{main/generators → generators}/create-bundle.js +0 -0
  402. /package/{types/generators/create-scoped-stargate-clients.d.ts → generators/create-custom-stargate-clients.d.ts} +0 -0
  403. /package/{main/generators → generators}/create-custom-stargate-clients.js +0 -0
  404. /package/{main/generators → generators}/create-lcd-clients.js +0 -0
  405. /package/{main/generators → generators}/create-mcp-server.js +0 -0
  406. /package/{main/generators → generators}/create-msg-funcs.js +0 -0
  407. /package/{main/generators → generators}/create-pinia-store.js +0 -0
  408. /package/{main/generators → generators}/create-query-funcs.js +0 -0
  409. /package/{main/generators → generators}/create-registries.js +0 -0
  410. /package/{main/generators → generators}/create-root-readme.js +0 -0
  411. /package/{main/generators → generators}/create-rpc-msg-clients.js +0 -0
  412. /package/{main/generators → generators}/create-rpc-query-clients.js +0 -0
  413. /package/{main/generators → generators}/customize-utils.js +0 -0
  414. /package/{main/helpers → helpers}/binary-coder.js +0 -0
  415. /package/{main/helpers → helpers}/decimals.js +0 -0
  416. /package/{main/helpers → helpers}/external-comet.js +0 -0
  417. /package/{main/helpers → helpers}/external-icjs.js +0 -0
  418. /package/{main/helpers → helpers}/external.js +0 -0
  419. /package/{main/helpers → helpers}/grpc-gateway.js +0 -0
  420. /package/{main/helpers → helpers}/grpc-web.js +0 -0
  421. /package/{main/helpers → helpers}/helper-func-types-interface.js +0 -0
  422. /package/{main/helpers → helpers}/helper-func-types.js +0 -0
  423. /package/{src/helpers/index.ts → helpers/index.d.ts} +0 -0
  424. /package/{main/helpers → helpers}/index.js +0 -0
  425. /package/{main/helpers → helpers}/internal-for-bigint.js +0 -0
  426. /package/{main/helpers → helpers}/internal.js +0 -0
  427. /package/{main/helpers → helpers}/json-safe.js +0 -0
  428. /package/{main/helpers → helpers}/mobx.js +0 -0
  429. /package/{main/helpers → helpers}/pinia-endpoint.js +0 -0
  430. /package/{main/helpers → helpers}/react-query-hooks-icjs.js +0 -0
  431. /package/{main/helpers → helpers}/react-query-hooks.js +0 -0
  432. /package/{main/helpers → helpers}/react-query.js +0 -0
  433. /package/{main/helpers → helpers}/registry-helper.js +0 -0
  434. /package/{main/helpers → helpers}/types-helper.js +0 -0
  435. /package/{main/helpers → helpers}/utf8-helper.js +0 -0
  436. /package/{main/helpers → helpers}/varint.js +0 -0
  437. /package/{main/helpers → helpers}/vue-query-hooks.js +0 -0
  438. /package/{main/index.js → index.js} +0 -0
  439. /package/{main/parse.js → parse.js} +0 -0
  440. /package/{main/prompt.js → prompt.js} +0 -0
  441. /package/{main/protod → protod}/config.js +0 -0
  442. /package/{main/protod → protod}/git-repo.js +0 -0
  443. /package/{src/protod/index.ts → protod/index.d.ts} +0 -0
  444. /package/{main/protod → protod}/index.js +0 -0
  445. /package/{main/protod → protod}/types.js +0 -0
  446. /package/{main/types.js → types.js} +0 -0
  447. /package/{main/utils → utils}/common-create-bundle.js +0 -0
  448. /package/{main/utils → utils}/index.js +0 -0
@@ -1,1774 +0,0 @@
1
- import { TelescopeBuilder } from '../builder';
2
- import { Bundler } from '../bundler';
3
- import { writeFileSync, mkdirSync, cpSync, existsSync } from 'fs';
4
- import { join, dirname, basename } from 'path';
5
-
6
- export const plugin = (
7
- builder: TelescopeBuilder,
8
- bundler: Bundler
9
- ) => {
10
- // Early return if MCP server is not enabled
11
- if (!builder.options.mcpServer?.enabled) {
12
- return;
13
- }
14
-
15
- // Use the output directory name instead of bundle base
16
- const outputDirName = basename(builder.outPath);
17
- const packageName = outputDirName || bundler.bundle.base;
18
- const parentDir = dirname(builder.outPath);
19
- const mcpServerPath = join(parentDir, `${packageName}-mcp`);
20
-
21
- // Ensure MCP server directory exists
22
- mkdirSync(mcpServerPath, { recursive: true });
23
- mkdirSync(join(mcpServerPath, 'src'), { recursive: true });
24
- mkdirSync(join(mcpServerPath, 'src', 'prompts'), { recursive: true });
25
- mkdirSync(join(mcpServerPath, 'src', `${packageName}-examples`), { recursive: true });
26
-
27
- // Generate package.json for MCP server
28
- const packageJson = generateMcpPackageJson(packageName);
29
- writeFileSync(
30
- join(mcpServerPath, 'package.json'),
31
- JSON.stringify(packageJson, null, 2)
32
- );
33
-
34
- // Generate main MCP server file
35
- const indexContent = `#!/usr/bin/env node
36
-
37
- import { readFileSync } from 'node:fs';
38
- import { dirname, resolve } from 'node:path';
39
- import { fileURLToPath } from 'node:url';
40
-
41
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
42
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
43
- import { z } from 'zod';
44
-
45
- // Get package.json version
46
- const __filename = fileURLToPath(import.meta.url);
47
- const __dirname = dirname(__filename);
48
- const packageJson = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf8'));
49
- const VERSION = packageJson.version;
50
-
51
- async function main() {
52
- const server = new McpServer({
53
- name: '${packageName} MCP Server',
54
- version: VERSION,
55
- });
56
-
57
- // Add prompts for AI agents
58
- server.prompt(
59
- 'codegen-usage',
60
- 'Guide for using telescope generated code',
61
- async () => {
62
- const promptPath = resolve(__dirname, 'prompts/codegen-usage.md');
63
- const content = readFileSync(promptPath, 'utf-8');
64
- return {
65
- messages: [{
66
- role: 'user',
67
- content: {
68
- type: 'text',
69
- text: content
70
- }
71
- }]
72
- };
73
- }
74
- );
75
-
76
- server.prompt(
77
- 'agent-guidelines',
78
- 'Guidelines for MCP agents using ${packageName}',
79
- async () => {
80
- const promptPath = resolve(__dirname, 'prompts/agent-guidelines.md');
81
- const content = readFileSync(promptPath, 'utf-8');
82
- return {
83
- messages: [{
84
- role: 'user',
85
- content: {
86
- type: 'text',
87
- text: content
88
- }
89
- }]
90
- };
91
- }
92
- );
93
-
94
- // Register blockchain function generator tool
95
- server.tool(
96
- 'use-${packageName}',
97
- 'Analyzes requests and provides step-by-step implementation guidance for custom blockchain functions using telescope examples as reference',
98
- {
99
- task: z.string().describe('The blockchain task to implement (e.g., "get balance", "check staking rewards", "query validators")').optional(),
100
- chainName: z.string().describe('The blockchain name (e.g., cosmos, osmosis, injective)').optional(),
101
- functionType: z.enum(['query', 'transaction', 'react-hook', 'utility']).describe('Type of function to create').optional(),
102
- customRequirements: z.string().describe('Any specific requirements or modifications needed').optional()
103
- },
104
- async (args) => {
105
- try {
106
- const { task = 'get account balance', chainName = 'cosmos', functionType = 'query', customRequirements } = args;
107
-
108
- // Read available examples
109
- const examplesPath = resolve(__dirname, '${packageName}-examples');
110
- let availableExamples: string[] = [];
111
-
112
- try {
113
- const fs = await import('fs');
114
- availableExamples = fs.readdirSync(examplesPath)
115
- .filter(file => file.endsWith('.ts'))
116
- .map(file => file.replace('.ts', ''));
117
- } catch (error) {
118
- // If examples directory doesn't exist, provide default list
119
- availableExamples = [
120
- 'config-example', 'useBalance', 'useBalanceFunc', 'getBalance',
121
- 'useAssets', 'useStakingData', 'useValidators', 'useVoting',
122
- 'useVotingData', 'useContractInfo', 'useQueryContract',
123
- 'useCodeDetails', 'useMyContracts', 'useGrants', 'useSendData',
124
- 'useTotalAssets', 'useBalanceReact'
125
- ];
126
- }
127
-
128
- const examplesList = availableExamples.map(example => \`- **\${example}.ts**: Reference implementation\`).join('\\n');
129
-
130
- const relevantExamples = getRelevantExamples(task, availableExamples)
131
- .map(example => \`- **\${example}**: \${getExampleDescription(example)}\`)
132
- .join('\\n');
133
-
134
- const codeBlockStart = '\`\`\`';
135
- const codeBlockEnd = '\`\`\`';
136
-
137
- const response = [
138
- '# Blockchain Function Generator',
139
- '',
140
- \`## Task: \${task}\`,
141
- \`## Chain: \${chainName}\`,
142
- \`## Function Type: \${functionType}\`,
143
- customRequirements ? \`## Custom Requirements: \${customRequirements}\` : '',
144
- '',
145
- '## Instructions for Implementation',
146
- '',
147
- '### Step 1: Review Available Examples',
148
- \`The following example files are available in \\\`src/${packageName}-examples/\\\`:\`,
149
- '',
150
- examplesList,
151
- '',
152
- '### Step 2: Identify Relevant Examples',
153
- \`Based on your task "\${task}", you should primarily reference:\`,
154
- '',
155
- relevantExamples,
156
- '',
157
- '### Step 3: Implementation Pattern',
158
- '',
159
- \`**For Query Functions (\${functionType === 'query' ? 'SELECTED' : 'Available'}):**\`,
160
- \`\${codeBlockStart}typescript\`,
161
- "import { getBalance } from '${packageName}/cosmos/bank/v1beta1/query.rpc.func';",
162
- '',
163
- 'export const customQueryFunction = async (params: QueryParams) => {',
164
- \` const rpcEndpoint = 'https://\${chainName}-rpc.quickapi.com:443';\`,
165
- ' ',
166
- ' try {',
167
- ' const result = await getBalance(rpcEndpoint, params);',
168
- ' return {',
169
- ' success: true,',
170
- ' data: result,',
171
- ' };',
172
- ' } catch (error) {',
173
- ' return {',
174
- ' success: false,',
175
- ' error: (error as Error).message,',
176
- ' };',
177
- ' }',
178
- '};',
179
- codeBlockEnd,
180
- '',
181
- \`**For React Hooks (\${functionType === 'react-hook' ? 'SELECTED' : 'Available'}):**\`,
182
- \`\${codeBlockStart}typescript\`,
183
- "import { useGetBalance } from '${packageName}/cosmos/bank/v1beta1/query.rpc.react';",
184
- "import { defaultContext } from '@tanstack/react-query';",
185
- '',
186
- 'export const useCustomHook = (params: HookParams) => {',
187
- \` const rpcEndpoint = 'https://\${chainName}-rpc.quickapi.com:443';\`,
188
- ' ',
189
- ' return useGetBalance({',
190
- ' request: params,',
191
- ' options: {',
192
- ' enabled: !!params.address,',
193
- ' context: defaultContext,',
194
- ' },',
195
- ' clientResolver: rpcEndpoint,',
196
- ' });',
197
- '};',
198
- codeBlockEnd,
199
- '',
200
- '### Step 4: Configuration Setup',
201
- 'Always include proper chain configuration. Reference \`config-example.ts\`:',
202
- '',
203
- \`\${codeBlockStart}typescript\`,
204
- 'import { assetLists, chains } from "@chain-registry/v2";',
205
- '',
206
- \`export const targetChainName = '\${chainName}';\`,
207
- \`export const rpcEndpoint = 'https://\${chainName}-rpc.quickapi.com:443';\`,
208
- 'export const chain = chains.find((chain) => chain.chainName === targetChainName);',
209
- 'export const assetList = assetLists.find((assetList) => assetList.chainName === targetChainName);',
210
- codeBlockEnd,
211
- '',
212
- '### Step 5: Error Handling & Best Practices',
213
- '- Always wrap async calls in try-catch blocks',
214
- '- Validate input parameters before making requests',
215
- '- Handle network timeouts and connection errors',
216
- '- Convert base units to human-readable amounts (uatom → ATOM)',
217
- '- Include proper TypeScript types',
218
- '',
219
- '### Step 6: Testing Your Function',
220
- \`\${codeBlockStart}typescript\`,
221
- '// Example usage',
222
- 'const result = await customQueryFunction({',
223
- " address: 'cosmos1...',",
224
- " denom: 'uatom'",
225
- '});',
226
- '',
227
- 'if (result.success) {',
228
- " console.log('Result:', result.data);",
229
- '} else {',
230
- " console.error('Error:', result.error);",
231
- '}',
232
- codeBlockEnd,
233
- '',
234
- '## Additional Resources',
235
- '',
236
- \`- **Full codebase reference**: \\\`src/${packageName}/\\\` directory contains all generated types and functions\`,
237
- \`- **Configuration examples**: \\\`src/${packageName}-examples/config-example.ts\\\`\`,
238
- '- **Chain registry data**: \`src/prompts/chains.json\`',
239
- '- **Usage guidelines**: Use the \`codegen-usage\` and \`agent-guidelines\` prompts for detailed instructions',
240
- '',
241
- '## Next Steps',
242
- '',
243
- '1. Review the suggested example files above',
244
- '2. Copy and modify the relevant pattern for your use case',
245
- '3. Test your implementation with proper error handling',
246
- '4. Ensure proper TypeScript types are used',
247
- '',
248
- \`The examples in \\\`${packageName}-examples/\\\` are production-ready patterns that you can adapt for any blockchain task.\`
249
- ].filter(line => line !== '').join('\\n');
250
-
251
- return {
252
- content: [{
253
- type: "text",
254
- text: response
255
- }]
256
- };
257
-
258
- } catch (error) {
259
- return {
260
- content: [{
261
- type: "text",
262
- text: \`Error generating blockchain function guidance: \${(error as Error).message}\`
263
- }]
264
- };
265
- }
266
- }
267
- );
268
-
269
- const transport = new StdioServerTransport();
270
- await server.connect(transport);
271
- console.log('${packageName} MCP server started on stdio');
272
- }
273
-
274
- // Helper functions for example recommendations
275
- function getRelevantExamples(task: string, availableExamples: string[]): string[] {
276
- const taskLower = task.toLowerCase();
277
- const relevantExamples: string[] = [];
278
-
279
- // Balance-related tasks
280
- if (taskLower.includes('balance')) {
281
- relevantExamples.push('useBalance', 'useBalanceFunc', 'getBalance');
282
- if (taskLower.includes('react')) {
283
- relevantExamples.push('useBalanceReact');
284
- }
285
- }
286
-
287
- // Staking-related tasks
288
- if (taskLower.includes('staking') || taskLower.includes('delegate') || taskLower.includes('validator')) {
289
- relevantExamples.push('useStakingData', 'useValidators');
290
- }
291
-
292
- // Governance/voting tasks
293
- if (taskLower.includes('voting') || taskLower.includes('proposal') || taskLower.includes('governance')) {
294
- relevantExamples.push('useVoting', 'useVotingData');
295
- }
296
-
297
- // Assets/portfolio tasks
298
- if (taskLower.includes('asset') || taskLower.includes('portfolio') || taskLower.includes('total')) {
299
- relevantExamples.push('useAssets', 'useTotalAssets');
300
- }
301
-
302
- // Contract-related tasks
303
- if (taskLower.includes('contract') || taskLower.includes('cosmwasm')) {
304
- relevantExamples.push('useContractInfo', 'useQueryContract', 'useCodeDetails', 'useMyContracts');
305
- }
306
-
307
- // Transaction/sending tasks
308
- if (taskLower.includes('send') || taskLower.includes('transaction') || taskLower.includes('transfer')) {
309
- relevantExamples.push('useSendData', 'getBalance');
310
- }
311
-
312
- // Authorization tasks
313
- if (taskLower.includes('grant') || taskLower.includes('authorization') || taskLower.includes('authz')) {
314
- relevantExamples.push('useGrants');
315
- }
316
-
317
- // Always include config as it's fundamental
318
- relevantExamples.unshift('config-example');
319
-
320
- // Remove duplicates and ensure examples exist
321
- return [...new Set(relevantExamples)].filter(example =>
322
- availableExamples.includes(example)
323
- );
324
- }
325
-
326
- function getExampleDescription(example: string): string {
327
- const descriptions: Record<string, string> = {
328
- 'config-example': 'Chain configuration and RPC endpoints setup',
329
- 'useBalance': 'React hook for querying account balance',
330
- 'useBalanceFunc': 'Direct function for balance queries',
331
- 'useBalanceReact': 'React hook with BigNumber for balance queries',
332
- 'getBalance': 'Basic balance query with transaction examples',
333
- 'useAssets': 'Query all token balances for an account',
334
- 'useStakingData': 'Comprehensive staking information (delegations, rewards, validators)',
335
- 'useValidators': 'Query active validators with sorting',
336
- 'useVoting': 'Active governance proposals in voting period',
337
- 'useVotingData': 'All governance proposals with categorization',
338
- 'useContractInfo': 'Smart contract information queries',
339
- 'useQueryContract': 'Execute smart contract queries',
340
- 'useCodeDetails': 'Contract code information and metadata',
341
- 'useMyContracts': 'Contracts created by specific address',
342
- 'useGrants': 'Authorization grants (granter/grantee)',
343
- 'useSendData': 'Prepare transaction data for token transfers',
344
- 'useTotalAssets': 'Portfolio summary with total asset calculations'
345
- };
346
-
347
- return descriptions[example] || 'Blockchain utility function';
348
- }
349
-
350
- main().catch((error) => {
351
- console.error('Fatal error in main()', error);
352
- process.exit(1);
353
- });
354
- `;
355
-
356
- writeFileSync(
357
- join(mcpServerPath, 'src', 'index.ts'),
358
- indexContent
359
- );
360
-
361
-
362
-
363
- // Generate TypeScript configuration
364
- const tsConfig = generateTsConfig(packageName);
365
- writeFileSync(
366
- join(mcpServerPath, 'tsconfig.json'),
367
- JSON.stringify(tsConfig, null, 2)
368
- );
369
-
370
- // Generate README
371
- const readme = generateReadme(packageName);
372
- writeFileSync(
373
- join(mcpServerPath, 'README.md'),
374
- readme
375
- );
376
-
377
- // Generate comprehensive prompts and guidelines
378
- generateComprehensivePrompts(mcpServerPath, packageName);
379
-
380
- // Generate telescope examples
381
- generateTelescopeExamples(mcpServerPath, packageName);
382
-
383
- // Copy entire telescope generated codebase for AI reference (excluded from build)
384
- copyTelescopeCodebase(builder, mcpServerPath, packageName);
385
- };
386
-
387
- function generateMcpPackageJson(packageName: string) {
388
-
389
- return {
390
- name: `${packageName}-mcp`,
391
- version: "0.1.0",
392
- description: `MCP server for ${packageName} blockchain interactions`,
393
- main: "dist/index.js",
394
- type: "module",
395
- bin: {
396
- [`${packageName}-mcp-server`]: "./dist/index.js"
397
- },
398
- scripts: {
399
- build: "rimraf dist && tsc",
400
- clean: "rimraf dist",
401
- test: "vitest",
402
- inspector: "npm run build && npm exec @modelcontextprotocol/inspector node dist/index.js",
403
- format: "biome check --write",
404
- lint: "biome check"
405
- },
406
- dependencies: {
407
- "@modelcontextprotocol/sdk": "^1.7.0",
408
- "zod": "^3.24.2"
409
- },
410
- devDependencies: {
411
- "@biomejs/biome": "1.9.4",
412
- "@types/node": "^22.13.10",
413
- "rimraf": "^6.0.1",
414
- "typescript": "^5.8.2",
415
- "vitest": "^3.1.1"
416
- },
417
- files: ["dist"],
418
- publishConfig: {
419
- access: "public"
420
- }
421
- };
422
- }
423
-
424
-
425
- function generateTsConfig(packageName: string) {
426
- return {
427
- compilerOptions: {
428
- target: "ES2022",
429
- module: "ESNext",
430
- moduleResolution: "node",
431
- outDir: "./dist",
432
- rootDir: "./src",
433
- strict: true,
434
- esModuleInterop: true,
435
- skipLibCheck: true,
436
- forceConsistentCasingInFileNames: true,
437
- declaration: true,
438
- declarationMap: true,
439
- sourceMap: true,
440
- allowSyntheticDefaultImports: true,
441
- resolveJsonModule: true
442
- },
443
- include: ["src/**/*"],
444
- exclude: ["node_modules", "dist", `src/${packageName}/**/*`, `src/${packageName}-examples/**/*`]
445
- };
446
- }
447
-
448
- function generateReadme(packageName: string) {
449
-
450
- return `# ${packageName.charAt(0).toUpperCase() + packageName.slice(1)} MCP Server
451
-
452
- This MCP server provides AI agents with the \`use-${packageName}\` tool to create custom blockchain functions using telescope examples as reference.
453
-
454
- ## Installation
455
-
456
- \`\`\`bash
457
- cd ${packageName}-mcp
458
- npm install
459
- npm run build
460
- \`\`\`
461
-
462
- ## Usage with AI Agents
463
-
464
- Add this configuration to your AI agent's MCP settings:
465
-
466
- \`\`\`json
467
- {
468
- "mcpServers": {
469
- "${packageName}-mcp-server": {
470
- "command": "node",
471
- "args": ["/path/to/${packageName}-mcp/dist/index.js"]
472
- }
473
- }
474
- }
475
- \`\`\`
476
-
477
- ## Available Features
478
-
479
- This MCP server provides:
480
-
481
- - **Function Generator Tool**: Single tool (\`use-${packageName}\`) that analyzes requests and provides step-by-step implementation guidance
482
- - **Telescope Codebase Reference**: Complete telescope-generated code in \`src/${packageName}/\` as primary reference
483
- - **Production Examples**: Reference implementations in \`src/${packageName}-examples/\` showing real-world patterns
484
- - **AI Guidance**: Contextual prompts to help agents understand blockchain development patterns
485
-
486
- ## How It Works
487
-
488
- The function generator tool:
489
-
490
- 1. **Analyzes your request** (task, chain, function type, custom requirements)
491
- 2. **Finds relevant examples** from \`${packageName}-examples/\` directory
492
- 3. **Provides implementation patterns** using \`${packageName}/\` codebase as primary reference
493
- 4. **Shows proper imports** and configuration with error handling
494
-
495
- ## Development
496
-
497
- \`\`\`bash
498
- npm run build # Build the server
499
- npm run inspector # Run MCP inspector for testing
500
- npm run clean # Clean dist directory
501
- \`\`\`
502
-
503
- ## Extending Examples
504
-
505
- You can enhance the AI agent's knowledge by adding more examples to the \`${packageName}-examples/\` directory. The function generator automatically scans this directory, so new examples are immediately available for reference.
506
-
507
- ## Directory Structure
508
-
509
- \`\`\`
510
- ${packageName}-mcp/
511
- ├── src/
512
- │ ├── ${packageName}/ # 📚 Telescope generated code (primary reference, excluded from build)
513
- │ │ ├── cosmos/ # Full cosmos SDK modules
514
- │ │ │ ├── bank/ # Balance queries, transfers
515
- │ │ │ ├── staking/ # Validator operations
516
- │ │ │ └── ... # Other cosmos modules
517
- │ │ ├── osmosis/ # Osmosis DEX functionality
518
- │ │ ├── ibc/ # Inter-blockchain communication
519
- │ │ └── index.ts # Main exports
520
- │ ├── ${packageName}-examples/ # 📖 Production examples (excluded from build)
521
- │ │ ├── config-example.ts # Chain configuration setup
522
- │ │ ├── useBalance.ts # Balance query React hooks
523
- │ │ ├── useBalanceFunc.ts # Direct balance functions
524
- │ │ ├── getBalance.ts # Balance queries with examples
525
- │ │ ├── useAssets.ts # Multi-token balance queries
526
- │ │ ├── useStakingData.ts # Staking and delegation info
527
- │ │ ├── useValidators.ts # Validator queries
528
- │ │ ├── useVoting.ts # Governance proposals
529
- │ │ ├── useContractInfo.ts # Smart contract queries
530
- │ │ ├── useMyContracts.ts # User's contract list
531
- │ │ ├── useGrants.ts # Authorization grants
532
- │ │ └── useSendData.ts # Transaction preparation
533
- │ ├── prompts/ # 🤖 Agent instruction files
534
- │ │ ├── codegen-usage.md # Implementation guide for agents
535
- │ │ ├── agent-guidelines.md # Best practices for agents
536
- │ │ └── chains.json # Chain registry data
537
- │ └── index.ts # MCP server with function generator tool
538
- ├── dist/ # Compiled JavaScript (excludes ${packageName}/ and ${packageName}-examples/)
539
- └── package.json
540
- \`\`\`
541
-
542
- **Key Points:**
543
- - \`src/${packageName}/\` contains the complete telescope-generated codebase as the **primary reference**
544
- - \`src/${packageName}-examples/\` contains **production examples** for patterns and logic reference
545
- - Both directories are excluded from TypeScript build but available for AI agents to read
546
- - Examples may contain compilation errors - focus on logic and patterns, not direct copying
547
-
548
- Generated by [Telescope](https://github.com/hyperweb-io/telescope) 🔭
549
- `;
550
- }
551
-
552
- function copyTelescopeCodebase(builder: TelescopeBuilder, mcpServerPath: string, packageName: string) {
553
- const sourcePath = builder.outPath;
554
- const destPath = join(mcpServerPath, 'src', packageName);
555
-
556
- // Copy the entire telescope generated directory
557
- if (existsSync(sourcePath)) {
558
- // Skip copy if destination already exists (avoids Windows file permission issues)
559
- if (existsSync(destPath)) {
560
- console.log(`Telescope codebase already exists at ${destPath}, skipping copy to avoid Windows file permission issues`);
561
- return;
562
- }
563
-
564
- console.log(`Copying telescope codebase from ${sourcePath} to ${destPath}`);
565
-
566
- // Ensure parent directory exists
567
- mkdirSync(dirname(destPath), { recursive: true });
568
-
569
- // Copy without removing destination first
570
- try {
571
- cpSync(sourcePath, destPath, { recursive: true, force: true });
572
- } catch (error) {
573
- console.warn(`Warning: Could not copy telescope codebase: ${error}`);
574
- console.log('MCP server will still function, but AI agents will have limited code references');
575
- // Don't throw error - let MCP server generation continue
576
- }
577
- } else {
578
- console.warn(`Source path ${sourcePath} does not exist, skipping telescope codebase copy`);
579
- }
580
- }
581
-
582
- // Removed retry logic - no longer needed since we skip copy if destination exists
583
-
584
-
585
-
586
- function generateComprehensivePrompts(mcpServerPath: string, packageName: string) {
587
- // Generate codegen-usage.md with our updated content
588
- const codegenUsageContent = `# Codegen Usage Guide
589
-
590
- ## Overview
591
- This guide provides instructions for MCP agents on how to use the telescope generated code when implementing the \`use-${packageName}\` tool.
592
-
593
- ## Understanding the Structure
594
-
595
- ### Primary Reference: \`src/${packageName}/\` Directory
596
- This is your **main reference** for understanding the complete telescope-generated codebase. It contains:
597
-
598
- - **Complete type definitions** for all blockchain modules
599
- - **Client implementations** for queries and transactions
600
- - **Generated interfaces** from protobuf definitions
601
- - **All available methods** and their signatures
602
-
603
- **Key files to understand**:
604
- - \`src/${packageName}/index.ts\` - Main exports and available modules
605
- - \`src/${packageName}/cosmos/\` - Cosmos SDK modules (bank, staking, gov, etc.)
606
- - \`src/${packageName}/osmosis/\` - Osmosis-specific modules
607
- - \`src/${packageName}/ibc/\` - Inter-blockchain communication
608
- - \`src/${packageName}/README.md\` - Comprehensive documentation
609
-
610
- ### Production Examples: \`src/${packageName}-examples/\` Directory
611
- Use these as **implementation patterns** and **logic reference**:
612
-
613
- - **Real production code** showing how to use telescope functions
614
- - **Best practices** for error handling and data processing
615
- - **Complete workflows** for common blockchain operations
616
-
617
- **⚠️ Important**: These examples may contain import/compilation errors since they reference the main codebase. **Focus on the logic and patterns** rather than copying code directly.
618
-
619
- ## Using the MCP Tool
620
-
621
- ### Single Tool: \`use-${packageName}\`
622
- This MCP server provides one tool that generates implementation guidance by:
623
-
624
- 1. **Analyzing your request** (task, chain, function type)
625
- 2. **Finding relevant examples** from \`${packageName}-examples/\`
626
- 3. **Providing step-by-step guidance** using telescope patterns
627
- 4. **Showing proper imports** and configuration
628
-
629
- ## Implementation Approach
630
-
631
- ### Step 1: Understand Telescope Structure
632
- When implementing a function, first explore \`src/${packageName}/\` to understand:
633
-
634
- \`\`\`typescript
635
- // Example: For balance queries, look at:
636
- // src/${packageName}/cosmos/bank/v1beta1/query.ts - Type definitions
637
- // src/${packageName}/cosmos/bank/v1beta1/query.rpc.Query.ts - Query client
638
- // src/${packageName}/cosmos/bank/v1beta1/query.rpc.func.ts - Direct functions
639
- // src/${packageName}/cosmos/bank/v1beta1/query.rpc.react.ts - React hooks
640
- \`\`\`
641
-
642
- ### Step 2: Reference Production Examples
643
- Look at \`${packageName}-examples/\` for implementation patterns:
644
-
645
- \`\`\`typescript
646
- // Example: useBalance.ts shows the pattern for:
647
- // - Proper imports from telescope
648
- // - Error handling approaches
649
- // - Data transformation logic
650
- // - Integration with React Query
651
-
652
- // Focus on UNDERSTANDING the logic:
653
- // - How RPC endpoints are configured
654
- // - How parameters are validated
655
- // - How responses are processed
656
- // - How errors are handled
657
- \`\`\`
658
-
659
- ### Step 3: Generate Your Implementation
660
- Use the patterns from both directories to create your function:
661
-
662
- \`\`\`typescript
663
- // Your implementation should:
664
- // 1. Use proper imports from the telescope codebase
665
- // 2. Follow error handling patterns from examples
666
- // 3. Include proper TypeScript types
667
- // 4. Handle edge cases shown in examples
668
- \`\`\`
669
-
670
- ## Category of Functions in Telescope
671
-
672
- ### 1. **query.rpc.func.ts** - Direct Function Calls
673
- - Server-side operations
674
- - Node.js scripts
675
- - Direct blockchain queries
676
-
677
- ### 2. **query.rpc.react.ts** - React Hooks
678
- - Frontend applications
679
- - Automatic caching and refetching
680
- - Loading states and error handling
681
-
682
- ### 3. **tx.rpc.func.ts** - Transaction Functions
683
- - Broadcasting transactions
684
- - Message composition
685
-
686
- ### 4. **tx.rpc.react.ts** - Transaction Hooks
687
- - Transaction broadcasting in React
688
- - Transaction state management
689
-
690
- ## Chain Configuration Pattern
691
-
692
- Always reference \`config-example.ts\` for proper setup:
693
-
694
- \`\`\`typescript
695
- import { assetLists, chains } from "@chain-registry/v2";
696
-
697
- export const targetChainName = 'cosmos';
698
- export const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
699
- export const chain = chains.find((chain) => chain.chainName === targetChainName);
700
- export const assetList = assetLists.find((assetList) => assetList.chainName === targetChainName);
701
- \`\`\`
702
-
703
- ## Important Guidelines
704
-
705
- ### When Using Examples
706
- - **Study the logic**, don't copy/paste directly
707
- - **Understand the patterns** for imports and usage
708
- - **Learn from error handling** approaches
709
- - **Adapt the structure** to your specific needs
710
-
711
- ### When Using Telescope Codebase
712
- - **Browse the generated files** to understand available methods
713
- - **Check type definitions** for proper parameter structures
714
- - **Look at client implementations** for usage patterns
715
- - **Reference documentation** in README.md files
716
-
717
- ### Best Practices
718
- 1. Always include comprehensive error handling
719
- 2. Validate input parameters before making calls
720
- 3. Convert base units to human-readable amounts when needed
721
- 4. Use proper TypeScript types from telescope
722
- 5. Test your implementations thoroughly
723
- `;
724
-
725
- writeFileSync(join(mcpServerPath, 'src', 'prompts', 'codegen-usage.md'), codegenUsageContent);
726
-
727
- // Generate agent-guidelines.md
728
- const agentGuidelinesContent = `# MCP Agent Guidelines
729
-
730
- ## Overview
731
- These guidelines help MCP agents provide helpful, accurate, and safe blockchain interactions using the ${packageName} library.
732
-
733
- ## General Principles
734
-
735
- ### 1. Safety First
736
- - **Never expose private keys or mnemonics**
737
- - **Always validate addresses before operations**
738
- - **Warn users about irreversible operations**
739
- - **Explain risks (slashing, unbonding periods, etc.)**
740
-
741
- ### 2. User-Friendly Communication
742
- - **Convert base units to human-readable amounts** (uatom → ATOM)
743
- - **Use clear, non-technical language when possible**
744
- - **Provide context for blockchain-specific concepts**
745
- - **Show approximate USD values when helpful**
746
-
747
- ### 3. Accuracy and Reliability
748
- - **Always handle errors gracefully**
749
- - **Provide accurate information about fees and timing**
750
- - **Double-check calculations and conversions**
751
- - **Verify data freshness and warn about stale data**
752
-
753
- ## Response Patterns
754
-
755
- ### When User Asks About Balances
756
- \`\`\`
757
- ✅ Good Response:
758
- "You have 12.5 ATOM (12,500,000 uatom) in your wallet. This is worth approximately $150 USD at current prices. You also have 0.05 ATOM available to pay for transaction fees."
759
-
760
- ❌ Poor Response:
761
- "Balance: 12500000"
762
- \`\`\`
763
-
764
- ## Data Formatting Guidelines
765
-
766
- ### Amounts
767
- Always convert from base units:
768
- \`\`\`typescript
769
- // Good
770
- const atomAmount = parseInt(balance.amount) / 1_000_000;
771
- return \`$\{atomAmount} ATOM\`;
772
-
773
- // Bad
774
- return \`$\{balance.amount} uatom\`;
775
- \`\`\`
776
-
777
- ### Addresses
778
- Abbreviate long addresses for readability:
779
- \`\`\`typescript
780
- const formatAddress = (addr: string) => {
781
- return \`$\{addr.slice(0, 10)}...$\{addr.slice(-4)}\`;
782
- };
783
- // cosmos1abc123...xyz9
784
- \`\`\`
785
-
786
- ## Security Guidelines
787
-
788
- ### Address Validation
789
- \`\`\`typescript
790
- const validateCosmosAddress = (address: string): boolean => {
791
- return address.startsWith('cosmos1') && address.length === 45;
792
- };
793
- \`\`\`
794
-
795
- ### Amount Validation
796
- \`\`\`typescript
797
- const validateAmount = (amount: string): boolean => {
798
- const num = parseFloat(amount);
799
- return !isNaN(num) && num > 0 && num < 1e15; // Reasonable limits
800
- };
801
- \`\`\`
802
- `;
803
-
804
- writeFileSync(join(mcpServerPath, 'src', 'prompts', 'agent-guidelines.md'), agentGuidelinesContent);
805
-
806
- // Copy chains.json from chain-registry (this is a large static file)
807
- const chainsJsonContent = `[
808
- {
809
- "$schema": "../chain.schema.json",
810
- "chainName": "cosmos",
811
- "status": "live",
812
- "networkType": "mainnet",
813
- "prettyName": "Cosmos Hub",
814
- "chainId": "cosmoshub-4",
815
- "bech32Prefix": "cosmos",
816
- "daemonName": "gaiad",
817
- "nodeHome": "$HOME/.gaia",
818
- "slip44": 118,
819
- "apis": {
820
- "rpc": [
821
- {
822
- "address": "https://cosmos-rpc.quickapi.com:443"
823
- }
824
- ],
825
- "rest": [
826
- {
827
- "address": "https://cosmos-rest.quickapi.com:443"
828
- }
829
- ]
830
- }
831
- },
832
- {
833
- "chainName": "osmosis",
834
- "status": "live",
835
- "networkType": "mainnet",
836
- "prettyName": "Osmosis",
837
- "chainId": "osmosis-1",
838
- "bech32Prefix": "osmo",
839
- "daemonName": "osmosisd",
840
- "nodeHome": "$HOME/.osmosisd",
841
- "slip44": 118,
842
- "apis": {
843
- "rpc": [
844
- {
845
- "address": "https://osmosis-rpc.quickapi.com:443"
846
- }
847
- ],
848
- "rest": [
849
- {
850
- "address": "https://osmosis-rest.quickapi.com:443"
851
- }
852
- ]
853
- }
854
- },
855
- {
856
- "chainName": "injective",
857
- "status": "live",
858
- "networkType": "mainnet",
859
- "prettyName": "Injective",
860
- "chainId": "injective-1",
861
- "bech32Prefix": "inj",
862
- "daemonName": "injectived",
863
- "nodeHome": "$HOME/.injectived",
864
- "slip44": 60,
865
- "apis": {
866
- "rpc": [
867
- {
868
- "address": "https://injective-rpc.quickapi.com:443"
869
- }
870
- ],
871
- "rest": [
872
- {
873
- "address": "https://injective-rest.quickapi.com:443"
874
- }
875
- ]
876
- }
877
- }
878
- ]`;
879
-
880
- writeFileSync(join(mcpServerPath, 'src', 'prompts', 'chains.json'), chainsJsonContent);
881
- }
882
-
883
- function generateTelescopeExamples(mcpServerPath: string, packageName: string) {
884
- const exampleFiles = [
885
- {
886
- name: 'config-example.ts',
887
- content: `import { assetLists, chains } from "@chain-registry/v2";
888
-
889
- /**
890
- * Chain configuration example
891
- * mainnet: 'cosmos'
892
- * testnet: 'cosmoshub-testnet'
893
- * mainnet rpc: 'https://cosmos-rpc.quickapi.com:443'
894
- * testnet rpc: 'https://rpc.testnet.cosmos.network:443'
895
- */
896
- export const targetChainName = 'cosmos';
897
- export const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
898
- export const chain = chains.find((chain) => chain.chainName === targetChainName);
899
- export const assetList = assetLists.find((assetList) => assetList.chainName === targetChainName);
900
- `
901
- },
902
- {
903
- name: 'useBalance.ts',
904
- content: `import { useChain } from '@interchain-kit/react';
905
- import { defaultContext } from '@tanstack/react-query';
906
- import { useGetBalance } from '${packageName}/cosmos/bank/v1beta1/query.rpc.react';
907
-
908
- export const useBalance = (
909
- chainName: string,
910
- enabled: boolean = true,
911
- displayDenom?: string
912
- ) => {
913
- const { address, assetList } = useChain(chainName);
914
-
915
- let denom = assetList?.assets[0].base!;
916
- for (const asset of assetList?.assets || []) {
917
- if (asset.display.toLowerCase() === displayDenom?.toLowerCase()) {
918
- denom = asset.base;
919
- break;
920
- }
921
- }
922
-
923
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443'; // Use dynamic endpoint
924
-
925
- const isReady = !!address && !!rpcEndpoint;
926
-
927
- const balanceQuery = useGetBalance({
928
- request: {
929
- denom,
930
- address: address || '',
931
- },
932
- options: {
933
- enabled: isReady && enabled,
934
- select: ({ balance }) => balance,
935
- context: defaultContext,
936
- },
937
- clientResolver: rpcEndpoint,
938
- customizedQueryKey: ['balance', address, denom],
939
- });
940
-
941
- return {
942
- balance: balanceQuery.data,
943
- isLoading: balanceQuery.isFetching,
944
- };
945
- };
946
- `
947
- },
948
- {
949
- name: 'useBalanceReact.ts',
950
- content: `import { useGetBalance } from '${packageName}/cosmos/bank/v1beta1/query.rpc.react';
951
- import { defaultRpcEndpoint as rpcEndpoint } from '@/config';
952
- import BigNumber from 'bignumber.js';
953
- import { defaultAssetList } from '@/config';
954
- import { defaultContext } from '@tanstack/react-query';
955
-
956
- export default function useBalance({ address }: { address: string }) {
957
- const coin = defaultAssetList?.assets[0];
958
-
959
- const denom = coin!.base!;
960
-
961
- const COIN_DISPLAY_EXPONENT = coin!.denomUnits.find(
962
- (unit) => unit.denom === coin!.display
963
- )?.exponent as number;
964
-
965
- const {
966
- data: balance,
967
- isSuccess: isBalanceLoaded,
968
- isLoading: isFetchingBalance,
969
- refetch: refetchBalance,
970
- } = useGetBalance({
971
- request: {
972
- address: address || '',
973
- denom,
974
- },
975
- options: {
976
- context: defaultContext,
977
- enabled: !!address,
978
- select: ({ balance }) =>
979
- new BigNumber(balance?.amount ?? 0).multipliedBy(
980
- 10 ** -COIN_DISPLAY_EXPONENT
981
- ),
982
- staleTime: 0,
983
- },
984
- clientResolver: rpcEndpoint,
985
- });
986
-
987
- return {
988
- balance,
989
- isBalanceLoaded,
990
- isFetchingBalance,
991
- refetchBalance,
992
- };
993
- }
994
- `
995
- },
996
- {
997
- name: 'useBalanceFunc.ts',
998
- content: `import { getBalance } from '${packageName}/cosmos/bank/v1beta1/query.rpc.func';
999
- import { defaultRpcEndpoint } from '@/config';
1000
-
1001
- export const useBalanceFunc = async (address: string, denom: string) => {
1002
- try {
1003
- const { balance } = await getBalance(defaultRpcEndpoint, {
1004
- address,
1005
- denom,
1006
- });
1007
-
1008
- return {
1009
- balance: balance?.amount || '0',
1010
- denom: balance?.denom || denom,
1011
- };
1012
- } catch (error) {
1013
- console.error('Error fetching balance:', error);
1014
- return {
1015
- balance: '0',
1016
- denom,
1017
- };
1018
- }
1019
- };
1020
- `
1021
- },
1022
- {
1023
- name: 'getBalance.ts',
1024
- content: `import { getBalance } from '${packageName}/cosmos/bank/v1beta1/query.rpc.func';
1025
- import { send } from '${packageName}/cosmos/bank/v1beta1/tx.rpc.func';
1026
- import { MsgSend } from '${packageName}/cosmos/bank/v1beta1/tx';
1027
-
1028
- const main = async () => {
1029
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1030
- const denom = 'uatom';
1031
- const address = 'cosmos1...'; // Your address here
1032
-
1033
- // Query balance
1034
- const { balance } = await getBalance(rpcEndpoint, {
1035
- address,
1036
- denom,
1037
- });
1038
-
1039
- console.log(\`Balance: \${balance?.amount} \${denom}\`);
1040
-
1041
- // Example: Send transaction (requires signer setup)
1042
- /*
1043
- const fee = {
1044
- amount: [{ denom, amount: '5000' }],
1045
- gas: '200000',
1046
- };
1047
-
1048
- const token = {
1049
- amount: '1000000',
1050
- denom,
1051
- };
1052
-
1053
- const msg = MsgSend.fromPartial({
1054
- fromAddress: address,
1055
- toAddress: 'cosmos1recipient...',
1056
- amount: [token],
1057
- });
1058
-
1059
- // const tx = await send(signer, address, msg, fee, 'Payment');
1060
- */
1061
- };
1062
-
1063
- main().catch(console.error);
1064
- `
1065
- },
1066
- {
1067
- name: 'useAssets.ts',
1068
- content: `import { useMemo } from 'react';
1069
- import { useChain } from '@interchain-kit/react';
1070
- import { defaultContext } from '@tanstack/react-query';
1071
- import BigNumber from 'bignumber.js';
1072
- import { useGetAllBalances } from '${packageName}/cosmos/bank/v1beta1/query.rpc.react';
1073
- import { Coin } from '${packageName}/types';
1074
-
1075
- export const useAssets = (chainName: string) => {
1076
- const { address } = useChain(chainName);
1077
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1078
-
1079
- const isReady = !!address && !!rpcEndpoint;
1080
-
1081
- const allBalancesQuery = useGetAllBalances({
1082
- request: {
1083
- address: address || '',
1084
- pagination: {
1085
- key: new Uint8Array(),
1086
- offset: 0n,
1087
- limit: 100n,
1088
- countTotal: true,
1089
- reverse: false,
1090
- },
1091
- resolveDenom: false,
1092
- },
1093
- options: {
1094
- enabled: isReady,
1095
- select: ({ balances }) => balances || [],
1096
- context: defaultContext,
1097
- },
1098
- clientResolver: rpcEndpoint,
1099
- customizedQueryKey: ['allBalances', address],
1100
- });
1101
-
1102
- const data = useMemo(() => {
1103
- if (!allBalancesQuery.data) return;
1104
-
1105
- const assets = allBalancesQuery.data.map(({ amount, denom }) => ({
1106
- symbol: denom.toUpperCase(),
1107
- displayAmount: new BigNumber(amount).dividedBy(1e6).toString(),
1108
- amount,
1109
- denom,
1110
- }));
1111
-
1112
- return { assets };
1113
- }, [allBalancesQuery.data]);
1114
-
1115
- return {
1116
- data,
1117
- isLoading: allBalancesQuery.isLoading,
1118
- refetch: allBalancesQuery.refetch
1119
- };
1120
- };
1121
- `
1122
- },
1123
- {
1124
- name: 'useStakingData.ts',
1125
- content: `import { useMemo } from 'react';
1126
- import { useChain } from '@interchain-kit/react';
1127
- import BigNumber from 'bignumber.js';
1128
- import {
1129
- BondStatus,
1130
- bondStatusToJSON,
1131
- } from '${packageName}/cosmos/staking/v1beta1/staking';
1132
- import { useGetBalance } from '${packageName}/cosmos/bank/v1beta1/query.rpc.react';
1133
- import {
1134
- useGetDelegatorValidators,
1135
- useGetDelegatorDelegations,
1136
- useGetValidators,
1137
- useGetParams as useStakingParams,
1138
- useGetPool,
1139
- } from '${packageName}/cosmos/staking/v1beta1/query.rpc.react';
1140
- import {
1141
- useGetDelegationTotalRewards,
1142
- useGetParams as useDistributionParams,
1143
- } from '${packageName}/cosmos/distribution/v1beta1/query.rpc.react';
1144
- import { useGetAnnualProvisions } from '${packageName}/cosmos/mint/v1beta1/query.rpc.react';
1145
- import { defaultContext } from '@tanstack/react-query';
1146
-
1147
- export const useStakingData = (chainName: string) => {
1148
- const { address, assetList } = useChain(chainName);
1149
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1150
-
1151
- const coin = assetList?.assets[0];
1152
- const denom = coin?.base || 'uatom';
1153
-
1154
- const isDataQueryEnabled = !!address && !!rpcEndpoint;
1155
-
1156
- const balanceQuery = useGetBalance({
1157
- request: {
1158
- address: address || '',
1159
- denom,
1160
- },
1161
- options: {
1162
- context: defaultContext,
1163
- enabled: isDataQueryEnabled,
1164
- select: ({ balance }) => balance?.amount || '0',
1165
- refetchOnMount: 'always',
1166
- },
1167
- clientResolver: rpcEndpoint,
1168
- });
1169
-
1170
- const validatorsQuery = useGetValidators({
1171
- request: {
1172
- status: bondStatusToJSON(BondStatus.BOND_STATUS_BONDED),
1173
- pagination: {
1174
- key: new Uint8Array(),
1175
- offset: 0n,
1176
- limit: 200n,
1177
- countTotal: true,
1178
- reverse: false,
1179
- },
1180
- },
1181
- options: {
1182
- context: defaultContext,
1183
- enabled: isDataQueryEnabled,
1184
- select: ({ validators }) => {
1185
- return validators.sort((a, b) =>
1186
- new BigNumber(b.tokens).minus(a.tokens).toNumber(),
1187
- );
1188
- },
1189
- },
1190
- clientResolver: rpcEndpoint,
1191
- customizedQueryKey: ['validators', chainName],
1192
- });
1193
-
1194
- const delegationsQuery = useGetDelegatorDelegations({
1195
- request: {
1196
- delegatorAddr: address || '',
1197
- pagination: {
1198
- key: new Uint8Array(),
1199
- offset: 0n,
1200
- limit: 100n,
1201
- countTotal: true,
1202
- reverse: false,
1203
- },
1204
- },
1205
- options: {
1206
- context: defaultContext,
1207
- enabled: isDataQueryEnabled,
1208
- select: ({ delegationResponses }) => delegationResponses,
1209
- },
1210
- clientResolver: rpcEndpoint,
1211
- });
1212
-
1213
- const rewardsQuery = useGetDelegationTotalRewards({
1214
- request: {
1215
- delegatorAddress: address || '',
1216
- },
1217
- options: {
1218
- context: defaultContext,
1219
- enabled: isDataQueryEnabled,
1220
- select: (data) => data,
1221
- },
1222
- clientResolver: rpcEndpoint,
1223
- });
1224
-
1225
- const allQueries = {
1226
- balance: balanceQuery,
1227
- validators: validatorsQuery,
1228
- delegations: delegationsQuery,
1229
- rewards: rewardsQuery,
1230
- };
1231
-
1232
- const isLoading = Object.values(allQueries).some(
1233
- ({ isLoading }) => isLoading,
1234
- );
1235
-
1236
- const data = useMemo(() => {
1237
- if (isLoading) return;
1238
-
1239
- return {
1240
- balance: balanceQuery.data,
1241
- validators: validatorsQuery.data,
1242
- delegations: delegationsQuery.data,
1243
- rewards: rewardsQuery.data,
1244
- };
1245
- }, [isLoading, balanceQuery.data, validatorsQuery.data, delegationsQuery.data, rewardsQuery.data]);
1246
-
1247
- const refetch = () => {
1248
- Object.values(allQueries).forEach((query) => query.refetch());
1249
- };
1250
-
1251
- return { data, isLoading, refetch };
1252
- };
1253
- `
1254
- },
1255
- {
1256
- name: 'useValidators.ts',
1257
- content: `import { useMemo } from 'react';
1258
- import { BondStatus, bondStatusToJSON } from '${packageName}/cosmos/staking/v1beta1/staking';
1259
- import { useGetValidators } from '${packageName}/cosmos/staking/v1beta1/query.rpc.react';
1260
- import { defaultContext } from '@tanstack/react-query';
1261
- import BigNumber from 'bignumber.js';
1262
-
1263
- export const useValidators = (chainName: string) => {
1264
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1265
-
1266
- const validatorsQuery = useGetValidators({
1267
- request: {
1268
- status: bondStatusToJSON(BondStatus.BOND_STATUS_BONDED),
1269
- pagination: {
1270
- key: new Uint8Array(),
1271
- offset: 0n,
1272
- limit: 200n,
1273
- countTotal: true,
1274
- reverse: false,
1275
- },
1276
- },
1277
- options: {
1278
- context: defaultContext,
1279
- enabled: !!rpcEndpoint,
1280
- select: ({ validators }) => {
1281
- return validators
1282
- .sort((a, b) => new BigNumber(b.tokens).minus(a.tokens).toNumber())
1283
- .map((validator) => ({
1284
- operatorAddress: validator.operatorAddress,
1285
- moniker: validator.description?.moniker || '',
1286
- tokens: validator.tokens,
1287
- delegatorShares: validator.delegatorShares,
1288
- commission: validator.commission?.commissionRates?.rate || '0',
1289
- status: validator.status,
1290
- jailed: validator.jailed,
1291
- }));
1292
- },
1293
- },
1294
- clientResolver: rpcEndpoint,
1295
- customizedQueryKey: ['validators', chainName],
1296
- });
1297
-
1298
- return {
1299
- data: validatorsQuery.data,
1300
- isLoading: validatorsQuery.isLoading,
1301
- refetch: validatorsQuery.refetch,
1302
- };
1303
- };
1304
- `
1305
- },
1306
- {
1307
- name: 'useVoting.ts',
1308
- content: `import { useMemo } from 'react';
1309
- import { useGetProposals } from '${packageName}/cosmos/gov/v1beta1/query.rpc.react';
1310
- import { ProposalStatus, proposalStatusToJSON } from '${packageName}/cosmos/gov/v1beta1/gov';
1311
- import { defaultContext } from '@tanstack/react-query';
1312
-
1313
- export const useVoting = (chainName: string) => {
1314
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1315
-
1316
- const proposalsQuery = useGetProposals({
1317
- request: {
1318
- proposalStatus: proposalStatusToJSON(ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD),
1319
- voter: '',
1320
- depositor: '',
1321
- pagination: {
1322
- key: new Uint8Array(),
1323
- offset: 0n,
1324
- limit: 50n,
1325
- countTotal: true,
1326
- reverse: true,
1327
- },
1328
- },
1329
- options: {
1330
- context: defaultContext,
1331
- enabled: !!rpcEndpoint,
1332
- select: ({ proposals }) => proposals,
1333
- },
1334
- clientResolver: rpcEndpoint,
1335
- customizedQueryKey: ['proposals', chainName],
1336
- });
1337
-
1338
- const data = useMemo(() => {
1339
- if (!proposalsQuery.data) return;
1340
-
1341
- return {
1342
- proposals: proposalsQuery.data.map((proposal) => ({
1343
- proposalId: proposal.proposalId.toString(),
1344
- title: proposal.content?.title || '',
1345
- description: proposal.content?.description || '',
1346
- status: proposal.status,
1347
- submitTime: proposal.submitTime,
1348
- votingStartTime: proposal.votingStartTime,
1349
- votingEndTime: proposal.votingEndTime,
1350
- })),
1351
- };
1352
- }, [proposalsQuery.data]);
1353
-
1354
- return {
1355
- data,
1356
- isLoading: proposalsQuery.isLoading,
1357
- refetch: proposalsQuery.refetch,
1358
- };
1359
- };
1360
- `
1361
- },
1362
- {
1363
- name: 'useVotingData.ts',
1364
- content: `import { useMemo } from 'react';
1365
- import { useChain } from '@interchain-kit/react';
1366
- import {
1367
- useGetProposals,
1368
- useGetVote,
1369
- useGetTallyResult,
1370
- } from '${packageName}/cosmos/gov/v1beta1/query.rpc.react';
1371
- import { ProposalStatus, proposalStatusToJSON } from '${packageName}/cosmos/gov/v1beta1/gov';
1372
- import { defaultContext } from '@tanstack/react-query';
1373
-
1374
- export const useVotingData = (chainName: string) => {
1375
- const { address } = useChain(chainName);
1376
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1377
-
1378
- const isEnabled = !!rpcEndpoint;
1379
-
1380
- const proposalsQuery = useGetProposals({
1381
- request: {
1382
- proposalStatus: proposalStatusToJSON(ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED),
1383
- voter: '',
1384
- depositor: '',
1385
- pagination: {
1386
- key: new Uint8Array(),
1387
- offset: 0n,
1388
- limit: 100n,
1389
- countTotal: true,
1390
- reverse: true,
1391
- },
1392
- },
1393
- options: {
1394
- context: defaultContext,
1395
- enabled: isEnabled,
1396
- select: ({ proposals }) => proposals,
1397
- },
1398
- clientResolver: rpcEndpoint,
1399
- customizedQueryKey: ['allProposals', chainName],
1400
- });
1401
-
1402
- const activeProposals = useMemo(() => {
1403
- return proposalsQuery.data?.filter(
1404
- (proposal) => proposal.status === ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD
1405
- ) || [];
1406
- }, [proposalsQuery.data]);
1407
-
1408
- const data = useMemo(() => {
1409
- if (!proposalsQuery.data) return;
1410
-
1411
- const categorized = {
1412
- active: activeProposals,
1413
- passed: proposalsQuery.data.filter(
1414
- (p) => p.status === ProposalStatus.PROPOSAL_STATUS_PASSED
1415
- ),
1416
- rejected: proposalsQuery.data.filter(
1417
- (p) => p.status === ProposalStatus.PROPOSAL_STATUS_REJECTED
1418
- ),
1419
- failed: proposalsQuery.data.filter(
1420
- (p) => p.status === ProposalStatus.PROPOSAL_STATUS_FAILED
1421
- ),
1422
- };
1423
-
1424
- return {
1425
- proposals: proposalsQuery.data,
1426
- categorized,
1427
- activeCount: categorized.active.length,
1428
- };
1429
- }, [proposalsQuery.data, activeProposals]);
1430
-
1431
- return {
1432
- data,
1433
- isLoading: proposalsQuery.isLoading,
1434
- refetch: proposalsQuery.refetch,
1435
- };
1436
- };
1437
- `
1438
- },
1439
- {
1440
- name: 'useContractInfo.ts',
1441
- content: `import { defaultContext } from '@tanstack/react-query';
1442
- import { useGetContractInfo } from '${packageName}/cosmwasm/wasm/v1/query.rpc.react';
1443
-
1444
- export const useContractInfo = ({
1445
- contractAddress,
1446
- enabled = true,
1447
- }: {
1448
- contractAddress: string;
1449
- enabled?: boolean;
1450
- }) => {
1451
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1452
-
1453
- return useGetContractInfo({
1454
- request: {
1455
- address: contractAddress,
1456
- },
1457
- options: {
1458
- enabled: !!contractAddress && !!rpcEndpoint && enabled,
1459
- context: defaultContext,
1460
- },
1461
- clientResolver: rpcEndpoint,
1462
- });
1463
- };
1464
- `
1465
- },
1466
- {
1467
- name: 'useQueryContract.ts',
1468
- content: `import { defaultContext } from '@tanstack/react-query';
1469
- import { useGetSmartContractState } from '${packageName}/cosmwasm/wasm/v1/query.rpc.react';
1470
-
1471
- export const useQueryContract = ({
1472
- contractAddress,
1473
- queryMsg,
1474
- enabled = true,
1475
- }: {
1476
- contractAddress: string;
1477
- queryMsg: object;
1478
- enabled?: boolean;
1479
- }) => {
1480
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1481
-
1482
- return useGetSmartContractState({
1483
- request: {
1484
- address: contractAddress,
1485
- queryData: new TextEncoder().encode(JSON.stringify(queryMsg)),
1486
- },
1487
- options: {
1488
- enabled: !!contractAddress && !!queryMsg && !!rpcEndpoint && enabled,
1489
- context: defaultContext,
1490
- select: ({ data }) => {
1491
- if (data) {
1492
- return JSON.parse(new TextDecoder().decode(data));
1493
- }
1494
- return null;
1495
- },
1496
- },
1497
- clientResolver: rpcEndpoint,
1498
- });
1499
- };
1500
- `
1501
- },
1502
- {
1503
- name: 'useCodeDetails.ts',
1504
- content: `import { defaultContext } from '@tanstack/react-query';
1505
- import { useGetCode } from '${packageName}/cosmwasm/wasm/v1/query.rpc.react';
1506
-
1507
- export const useCodeDetails = ({
1508
- codeId,
1509
- enabled = true,
1510
- }: {
1511
- codeId: string | number;
1512
- enabled?: boolean;
1513
- }) => {
1514
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1515
-
1516
- return useGetCode({
1517
- request: {
1518
- codeId: BigInt(codeId),
1519
- },
1520
- options: {
1521
- enabled: !!codeId && !!rpcEndpoint && enabled,
1522
- context: defaultContext,
1523
- },
1524
- clientResolver: rpcEndpoint,
1525
- });
1526
- };
1527
- `
1528
- },
1529
- {
1530
- name: 'useMyContracts.ts',
1531
- content: `import { useMemo } from 'react';
1532
- import { useChain } from '@interchain-kit/react';
1533
- import { useGetContractsByCreator } from '${packageName}/cosmwasm/wasm/v1/query.rpc.react';
1534
- import { defaultContext } from '@tanstack/react-query';
1535
-
1536
- export const useMyContracts = (chainName: string) => {
1537
- const { address } = useChain(chainName);
1538
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1539
-
1540
- const contractsQuery = useGetContractsByCreator({
1541
- request: {
1542
- creatorAddress: address || '',
1543
- pagination: {
1544
- key: new Uint8Array(),
1545
- offset: 0n,
1546
- limit: 100n,
1547
- countTotal: true,
1548
- reverse: false,
1549
- },
1550
- },
1551
- options: {
1552
- enabled: !!address && !!rpcEndpoint,
1553
- context: defaultContext,
1554
- select: ({ contractAddresses }) => contractAddresses,
1555
- },
1556
- clientResolver: rpcEndpoint,
1557
- });
1558
-
1559
- const data = useMemo(() => {
1560
- if (!contractsQuery.data) return;
1561
-
1562
- return {
1563
- contracts: contractsQuery.data.map((address) => ({
1564
- address,
1565
- label: \`Contract \${address.slice(0, 8)}...\`,
1566
- })),
1567
- count: contractsQuery.data.length,
1568
- };
1569
- }, [contractsQuery.data]);
1570
-
1571
- return {
1572
- data,
1573
- isLoading: contractsQuery.isLoading,
1574
- refetch: contractsQuery.refetch,
1575
- };
1576
- };
1577
- `
1578
- },
1579
- {
1580
- name: 'useGrants.ts',
1581
- content: `import { useMemo } from 'react';
1582
- import { useChain } from '@interchain-kit/react';
1583
- import { useGetGranterGrants, useGetGranteeGrants } from '${packageName}/cosmos/authz/v1beta1/query.rpc.react';
1584
- import { defaultContext } from '@tanstack/react-query';
1585
-
1586
- export const useGrants = (chainName: string) => {
1587
- const { address } = useChain(chainName);
1588
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1589
-
1590
- const granterQuery = useGetGranterGrants({
1591
- request: {
1592
- granter: address || '',
1593
- pagination: {
1594
- key: new Uint8Array(),
1595
- offset: 0n,
1596
- limit: 100n,
1597
- countTotal: true,
1598
- reverse: false,
1599
- },
1600
- },
1601
- options: {
1602
- enabled: !!address && !!rpcEndpoint,
1603
- context: defaultContext,
1604
- select: ({ grants }) => grants,
1605
- },
1606
- clientResolver: rpcEndpoint,
1607
- });
1608
-
1609
- const granteeQuery = useGetGranteeGrants({
1610
- request: {
1611
- grantee: address || '',
1612
- pagination: {
1613
- key: new Uint8Array(),
1614
- offset: 0n,
1615
- limit: 100n,
1616
- countTotal: true,
1617
- reverse: false,
1618
- },
1619
- },
1620
- options: {
1621
- enabled: !!address && !!rpcEndpoint,
1622
- context: defaultContext,
1623
- select: ({ grants }) => grants,
1624
- },
1625
- clientResolver: rpcEndpoint,
1626
- });
1627
-
1628
- const data = useMemo(() => {
1629
- return {
1630
- granterGrants: granterQuery.data || [],
1631
- granteeGrants: granteeQuery.data || [],
1632
- };
1633
- }, [granterQuery.data, granteeQuery.data]);
1634
-
1635
- const isLoading = granterQuery.isLoading || granteeQuery.isLoading;
1636
-
1637
- return {
1638
- data,
1639
- isLoading,
1640
- refetch: () => {
1641
- granterQuery.refetch();
1642
- granteeQuery.refetch();
1643
- },
1644
- };
1645
- };
1646
- `
1647
- },
1648
- {
1649
- name: 'useSendData.ts',
1650
- content: `import { useMemo } from 'react';
1651
- import { useChain } from '@interchain-kit/react';
1652
- import { useGetBalance } from '${packageName}/cosmos/bank/v1beta1/query.rpc.react';
1653
- import { defaultContext } from '@tanstack/react-query';
1654
- import BigNumber from 'bignumber.js';
1655
-
1656
- export const useSendData = (chainName: string) => {
1657
- const { address, assetList } = useChain(chainName);
1658
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1659
-
1660
- const coin = assetList?.assets[0];
1661
- const denom = coin?.base || 'uatom';
1662
- const exponent = coin?.denomUnits?.find(unit => unit.denom === coin.display)?.exponent || 6;
1663
-
1664
- const balanceQuery = useGetBalance({
1665
- request: {
1666
- address: address || '',
1667
- denom,
1668
- },
1669
- options: {
1670
- enabled: !!address && !!rpcEndpoint,
1671
- context: defaultContext,
1672
- select: ({ balance }) => {
1673
- const amount = balance?.amount || '0';
1674
- const displayAmount = new BigNumber(amount).dividedBy(Math.pow(10, exponent));
1675
- return {
1676
- amount,
1677
- displayAmount: displayAmount.toString(),
1678
- denom: balance?.denom || denom,
1679
- };
1680
- },
1681
- },
1682
- clientResolver: rpcEndpoint,
1683
- });
1684
-
1685
- const data = useMemo(() => {
1686
- if (!balanceQuery.data) return;
1687
-
1688
- return {
1689
- balance: balanceQuery.data,
1690
- canSend: new BigNumber(balanceQuery.data.amount).isGreaterThan(0),
1691
- fee: {
1692
- amount: '5000',
1693
- displayAmount: new BigNumber('5000').dividedBy(Math.pow(10, exponent)).toString(),
1694
- denom,
1695
- },
1696
- };
1697
- }, [balanceQuery.data, denom, exponent]);
1698
-
1699
- return {
1700
- data,
1701
- isLoading: balanceQuery.isLoading,
1702
- refetch: balanceQuery.refetch,
1703
- };
1704
- };
1705
- `
1706
- },
1707
- {
1708
- name: 'useTotalAssets.ts',
1709
- content: `import { useMemo } from 'react';
1710
- import { useChain } from '@interchain-kit/react';
1711
- import { useGetAllBalances } from '${packageName}/cosmos/bank/v1beta1/query.rpc.react';
1712
- import { defaultContext } from '@tanstack/react-query';
1713
- import BigNumber from 'bignumber.js';
1714
-
1715
- export const getPagination = (limit: bigint) => ({
1716
- key: new Uint8Array(),
1717
- offset: 0n,
1718
- limit,
1719
- countTotal: true,
1720
- reverse: false,
1721
- });
1722
-
1723
- export const useTotalAssets = (chainName: string) => {
1724
- const { address, assetList } = useChain(chainName);
1725
- const rpcEndpoint = 'https://cosmos-rpc.quickapi.com:443';
1726
-
1727
- const allBalancesQuery = useGetAllBalances({
1728
- request: {
1729
- address: address || '',
1730
- pagination: getPagination(100n),
1731
- resolveDenom: false,
1732
- },
1733
- options: {
1734
- enabled: !!address && !!rpcEndpoint,
1735
- select: ({ balances }) => balances || [],
1736
- context: defaultContext,
1737
- },
1738
- clientResolver: rpcEndpoint,
1739
- customizedQueryKey: ['totalAssets', address],
1740
- });
1741
-
1742
- const data = useMemo(() => {
1743
- if (!allBalancesQuery.data) return;
1744
-
1745
- const totalValue = allBalancesQuery.data.reduce((sum, balance) => {
1746
- return sum.plus(balance.amount);
1747
- }, new BigNumber(0));
1748
-
1749
- return {
1750
- balances: allBalancesQuery.data,
1751
- totalCount: allBalancesQuery.data.length,
1752
- totalValue: totalValue.toString(),
1753
- nonZeroBalances: allBalancesQuery.data.filter(
1754
- balance => new BigNumber(balance.amount).isGreaterThan(0)
1755
- ),
1756
- };
1757
- }, [allBalancesQuery.data]);
1758
-
1759
- return {
1760
- data,
1761
- isLoading: allBalancesQuery.isLoading,
1762
- refetch: allBalancesQuery.refetch,
1763
- };
1764
- };
1765
- `
1766
- }
1767
- ];
1768
-
1769
- // Write all example files
1770
- exampleFiles.forEach(({ name, content }) => {
1771
- writeFileSync(join(mcpServerPath, 'src', `${packageName}-examples`, name), content);
1772
- });
1773
- }
1774
-