@hyperweb/telescope 1.15.2 → 1.17.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 (35) hide show
  1. package/README.md +5 -5
  2. package/main/generators/create-combined-stargate-clients.js +99 -0
  3. package/main/generators/create-helpers.js +15 -8
  4. package/main/generators/create-mcp-server.js +153 -279
  5. package/main/generators/create-root-readme.js +1 -1
  6. package/main/helpers/external-icjs.js +29 -19
  7. package/main/helpers/generated-type.js +24 -0
  8. package/main/helpers/helper-func-types-interface.js +8 -8
  9. package/main/helpers/helper-func-types.js +8 -8
  10. package/main/helpers/internalForBigInt.js +248 -0
  11. package/main/helpers/types.js +24 -0
  12. package/main/helpers/vue-query.js +91 -0
  13. package/main/protod/proto-download.js +57 -0
  14. package/module/generators/create-combined-stargate-clients.js +95 -0
  15. package/module/generators/create-helpers.js +15 -8
  16. package/module/generators/create-mcp-server.js +153 -279
  17. package/module/generators/create-root-readme.js +1 -1
  18. package/module/helpers/external-icjs.js +29 -19
  19. package/module/helpers/generated-type.js +21 -0
  20. package/module/helpers/helper-func-types-interface.js +8 -8
  21. package/module/helpers/helper-func-types.js +8 -8
  22. package/module/helpers/internalForBigInt.js +245 -0
  23. package/module/helpers/types.js +21 -0
  24. package/module/helpers/vue-query.js +87 -0
  25. package/module/protod/proto-download.js +55 -0
  26. package/module/telescope.js +0 -0
  27. package/package.json +6 -6
  28. package/src/generators/create-helpers.ts +29 -16
  29. package/src/generators/create-mcp-server.ts +154 -282
  30. package/src/generators/create-root-readme.ts +1 -1
  31. package/src/helpers/external-icjs.ts +29 -19
  32. package/src/helpers/helper-func-types-interface.ts +8 -8
  33. package/src/helpers/helper-func-types.ts +8 -8
  34. package/types/codegen/cosmos/orm/module/v1alpha1/module.d.ts +43 -0
  35. package/types/helpers/external-icjs.d.ts +1 -1
@@ -1,33 +1,43 @@
1
1
  export const externalIcJs = `
2
2
  import { HttpEndpoint } from "@interchainjs/types";
3
- import {
4
- createQueryRpc,
5
- } from '@interchainjs/utils';
6
3
  import { Rpc } from "./helpers";
4
+ import { ClientOptions, createCosmosQueryClient } from "@interchainjs/cosmos";
7
5
 
8
6
  const _rpcClients: Record<string, Rpc> = {};
9
7
 
10
8
  export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
11
- if (typeof rpcEndpoint === 'string') {
12
- return rpcEndpoint;
13
- } else if (!!rpcEndpoint) {
14
- //@ts-ignore
15
- return rpcEndpoint.url;
16
- }
9
+ if (typeof rpcEndpoint === 'string') {
10
+ return rpcEndpoint;
11
+ } else if (!!rpcEndpoint) {
12
+ //@ts-ignore
13
+ return rpcEndpoint.url;
14
+ }
17
15
  }
18
16
 
19
17
  export const getRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {
20
- const key = getRpcEndpointKey(rpcEndpoint);
21
- if (!key) return;
22
- if (_rpcClients.hasOwnProperty(key)) {
23
- return _rpcClients[key];
24
- }
25
- const rpc = await createRpcClient(rpcEndpoint);
26
- _rpcClients[key] = rpc;
27
- return rpc;
18
+ const key = getRpcEndpointKey(rpcEndpoint);
19
+ if (!key) return;
20
+ if (_rpcClients.hasOwnProperty(key)) {
21
+ return _rpcClients[key];
22
+ }
23
+ const rpc = await createRpcClient(rpcEndpoint);
24
+ _rpcClients[key] = rpc;
25
+ return rpc;
28
26
  }
29
27
 
30
- export const createRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {
31
- return createQueryRpc(rpcEndpoint)
28
+ export const createRpcClient = async (rpcEndpoint: string | HttpEndpoint,
29
+ options?: ClientOptions
30
+ ) => {
31
+ if (typeof rpcEndpoint === 'string') {
32
+ return createCosmosQueryClient(rpcEndpoint, options);
33
+ } else {
34
+ const endpointStr = rpcEndpoint.url;
35
+ const clientOptions = {
36
+ ...options,
37
+ headers: rpcEndpoint.headers
38
+ };
39
+
40
+ return createCosmosQueryClient(endpointStr, clientOptions);
41
+ }
32
42
  }
33
43
  `;
@@ -3,12 +3,12 @@ import { TelescopeOptions } from "@cosmology/types";
3
3
  export const getHelperFuncTypesForInterface = (options: TelescopeOptions) => {
4
4
  return `
5
5
  import { HttpEndpoint } from "@interchainjs/types";
6
- import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";
7
- import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";
8
- import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";
9
- import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";
6
+ import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
7
+ import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
8
+ import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
9
+ import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
10
10
  import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
11
- import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";
11
+ import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";` : ''}
12
12
 
13
13
  export interface QueryBuilderOptions<TReq, TRes> {
14
14
  encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
@@ -27,7 +27,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
27
27
  if(isRpc(client)) {
28
28
  rpc = client;
29
29
  } else {
30
- rpc = client ? await getRpcClient(client) : undefined;
30
+ rpc = ${options.isGeneratingCosmosTypes ? 'undefined' : 'client ? await getRpcClient(client) : undefined'};
31
31
  }
32
32
 
33
33
  if (!rpc) throw new Error("Query Rpc is not initialized");
@@ -38,7 +38,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
38
38
  };
39
39
  }
40
40
 
41
- export interface ITxArgs<TMsg> {
41
+ ${!options.isGeneratingCosmosTypes ? `export interface ITxArgs<TMsg> {
42
42
  signerAddress: string;
43
43
  message: TMsg | TMsg[];
44
44
  fee: StdFee | 'auto';
@@ -78,7 +78,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
78
78
  }];
79
79
  return client.signAndBroadcast!(signerAddress, data, fee, memo);
80
80
  };
81
- }
81
+ }` : ''}
82
82
 
83
83
  export interface Encoder {
84
84
  typeUrl: string;
@@ -3,12 +3,12 @@ import { TelescopeOptions } from "@cosmology/types";
3
3
  export const getHelperFuncTypes = (options: TelescopeOptions) => {
4
4
  return `
5
5
  import { HttpEndpoint } from "@interchainjs/types";
6
- import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";
7
- import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";
8
- import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";
9
- import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";
6
+ import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
7
+ import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
8
+ import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
9
+ import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
10
10
  import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
11
- import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";
11
+ import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";` : ''}
12
12
 
13
13
  export interface QueryBuilderOptions<TReq, TRes> {
14
14
  encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
@@ -24,7 +24,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
24
24
  if(isRpc(client)) {
25
25
  rpc = client;
26
26
  } else {
27
- rpc = client ? await getRpcClient(client) : undefined;
27
+ rpc = ${options.isGeneratingCosmosTypes ? 'undefined' : 'client ? await getRpcClient(client) : undefined'};
28
28
  }
29
29
 
30
30
  if (!rpc) throw new Error("Query Rpc is not initialized");
@@ -35,7 +35,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
35
35
  };
36
36
  }
37
37
 
38
- export interface ITxArgs<TMsg> {
38
+ ${!options.isGeneratingCosmosTypes ? `export interface ITxArgs<TMsg> {
39
39
  signerAddress: string;
40
40
  message: TMsg | TMsg[];
41
41
  fee: StdFee | 'auto';
@@ -71,7 +71,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
71
71
  }];
72
72
  return client.signAndBroadcast!(signerAddress, data, fee, memo);
73
73
  };
74
- }
74
+ }` : ''}
75
75
 
76
76
  export interface Encoder {
77
77
  typeUrl: string;
@@ -0,0 +1,43 @@
1
+ import { BinaryReader } from "../../../../binary";
2
+ /**
3
+ * Module defines the ORM module which adds providers to the app container for
4
+ * module-scoped DB's. In the future it may provide gRPC services for interacting
5
+ * with ORM data.
6
+ */
7
+ export interface Module {
8
+ }
9
+ export interface ModuleProtoMsg {
10
+ typeUrl: "/cosmos.orm.module.v1alpha1.Module";
11
+ value: Uint8Array;
12
+ }
13
+ /**
14
+ * Module defines the ORM module which adds providers to the app container for
15
+ * module-scoped DB's. In the future it may provide gRPC services for interacting
16
+ * with ORM data.
17
+ */
18
+ export interface ModuleAmino {
19
+ }
20
+ export interface ModuleAminoMsg {
21
+ type: "cosmos-sdk/Module";
22
+ value: ModuleAmino;
23
+ }
24
+ /**
25
+ * Module defines the ORM module which adds providers to the app container for
26
+ * module-scoped DB's. In the future it may provide gRPC services for interacting
27
+ * with ORM data.
28
+ */
29
+ export interface ModuleSDKType {
30
+ }
31
+ export declare const Module: {
32
+ typeUrl: string;
33
+ encode(_: Module, writer?: BinaryWriter): BinaryWriter;
34
+ decode(input: BinaryReader | Uint8Array, length?: number): Module;
35
+ fromPartial(_: Partial<Module>): Module;
36
+ fromAmino(_: ModuleAmino): Module;
37
+ toAmino(_: Module): ModuleAmino;
38
+ fromAminoMsg(object: ModuleAminoMsg): Module;
39
+ toAminoMsg(message: Module): ModuleAminoMsg;
40
+ fromProtoMsg(message: ModuleProtoMsg): Module;
41
+ toProto(message: Module): Uint8Array;
42
+ toProtoMsg(message: Module): ModuleProtoMsg;
43
+ };
@@ -1 +1 @@
1
- export declare const externalIcJs = "\nimport { HttpEndpoint } from \"@interchainjs/types\";\nimport {\n createQueryRpc,\n} from '@interchainjs/utils';\nimport { Rpc } from \"./helpers\";\n\nconst _rpcClients: Record<string, Rpc> = {};\n\nexport const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {\n if (typeof rpcEndpoint === 'string') {\n return rpcEndpoint;\n } else if (!!rpcEndpoint) {\n //@ts-ignore\n return rpcEndpoint.url;\n }\n}\n\nexport const getRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {\n const key = getRpcEndpointKey(rpcEndpoint);\n if (!key) return;\n if (_rpcClients.hasOwnProperty(key)) {\n return _rpcClients[key];\n }\n const rpc = await createRpcClient(rpcEndpoint);\n _rpcClients[key] = rpc;\n return rpc;\n}\n\nexport const createRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {\n return createQueryRpc(rpcEndpoint)\n}\n";
1
+ export declare const externalIcJs = "\nimport { HttpEndpoint } from \"@interchainjs/types\";\nimport { Rpc } from \"./helpers\";\nimport { ClientOptions, createCosmosQueryClient } from \"@interchainjs/cosmos\";\n\nconst _rpcClients: Record<string, Rpc> = {};\n\nexport const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {\n if (typeof rpcEndpoint === 'string') {\n return rpcEndpoint;\n } else if (!!rpcEndpoint) {\n //@ts-ignore\n return rpcEndpoint.url;\n }\n}\n\nexport const getRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {\n const key = getRpcEndpointKey(rpcEndpoint);\n if (!key) return;\n if (_rpcClients.hasOwnProperty(key)) {\n return _rpcClients[key];\n }\n const rpc = await createRpcClient(rpcEndpoint);\n _rpcClients[key] = rpc;\n return rpc;\n}\n\nexport const createRpcClient = async (rpcEndpoint: string | HttpEndpoint,\n options?: ClientOptions\n) => {\n if (typeof rpcEndpoint === 'string') {\n return createCosmosQueryClient(rpcEndpoint, options);\n } else {\n const endpointStr = rpcEndpoint.url;\n const clientOptions = {\n ...options,\n headers: rpcEndpoint.headers\n };\n\n return createCosmosQueryClient(endpointStr, clientOptions);\n }\n}\n";