@hyperweb/telescope 1.17.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +30 -16
  2. package/main/commands/transpile.js +23 -16
  3. package/main/generators/create-bundle.js +41 -9
  4. package/main/generators/customize-utils.js +0 -1
  5. package/main/helpers/helper-func-types-interface.js +7 -7
  6. package/main/helpers/helper-func-types.js +7 -7
  7. package/main/helpers/react-query-hooks-icjs.js +5 -5
  8. package/main/helpers/react-query-hooks.js +5 -5
  9. package/main/helpers/types-helper.js +4 -38
  10. package/main/helpers/vue-query-hooks.js +4 -4
  11. package/main/protod/recursive.js +10 -1
  12. package/main/utils/index.js +0 -1
  13. package/module/commands/transpile.js +23 -16
  14. package/module/generators/create-bundle.js +41 -9
  15. package/module/generators/customize-utils.js +0 -1
  16. package/module/helpers/helper-func-types-interface.js +7 -7
  17. package/module/helpers/helper-func-types.js +7 -7
  18. package/module/helpers/react-query-hooks-icjs.js +5 -5
  19. package/module/helpers/react-query-hooks.js +5 -5
  20. package/module/helpers/types-helper.js +4 -38
  21. package/module/helpers/vue-query-hooks.js +4 -4
  22. package/module/protod/recursive.js +10 -1
  23. package/module/utils/index.js +0 -1
  24. package/package.json +6 -6
  25. package/src/commands/transpile.ts +23 -16
  26. package/src/generators/create-bundle.ts +51 -9
  27. package/src/generators/customize-utils.ts +0 -2
  28. package/src/helpers/helper-func-types-interface.ts +7 -7
  29. package/src/helpers/helper-func-types.ts +7 -7
  30. package/src/helpers/react-query-hooks-icjs.ts +5 -5
  31. package/src/helpers/react-query-hooks.ts +5 -5
  32. package/src/helpers/types-helper.ts +4 -38
  33. package/src/helpers/vue-query-hooks.ts +4 -4
  34. package/src/protod/recursive.ts +11 -1
  35. package/src/utils/index.ts +0 -1
@@ -1,10 +1,35 @@
1
1
  import { exportAllFromRelPath, exportTypesWithAlias, recursiveModuleBundle, } from "@cosmology/ast";
2
2
  import { duplicateImportPathsWithExt, makeAliasName, makeAliasNameWithPackageAtEnd, } from "@cosmology/utils";
3
+ /**
4
+ * Process noAlias configuration to create a map of names to their first package
5
+ * This ensures that only the first occurrence of a name skips aliasing
6
+ */
7
+ const processNoAliasConfig = (noAlias) => {
8
+ if (!noAlias || noAlias.length === 0) {
9
+ return new Map();
10
+ }
11
+ const nameToFirstPackage = new Map();
12
+ for (const entry of noAlias) {
13
+ if (!nameToFirstPackage.has(entry.name)) {
14
+ nameToFirstPackage.set(entry.name, entry.package);
15
+ }
16
+ }
17
+ return nameToFirstPackage;
18
+ };
19
+ /**
20
+ * Check if a package/name combination should skip aliasing
21
+ */
22
+ const shouldSkipAlias = (pkg, name, nameToFirstPackage) => {
23
+ const firstPackage = nameToFirstPackage.get(name);
24
+ return firstPackage === pkg;
25
+ };
3
26
  export const plugin = (builder, bundler) => {
4
27
  if (!builder.options.bundle.enabled) {
5
28
  return;
6
29
  }
7
30
  let prog = [];
31
+ // Process noAlias configuration once at the beginning
32
+ const nameToFirstPackage = processNoAliasConfig(builder.options.bundle.noAlias);
8
33
  if (builder.options.bundle.type === "namespace") {
9
34
  const importPaths = duplicateImportPathsWithExt(bundler.bundle.importPaths, builder.options.restoreImportExtension);
10
35
  // [x] bundle
@@ -41,17 +66,24 @@ export const plugin = (builder, bundler) => {
41
66
  const duplicatedType = duplicatedTypeNames.find((type) => type === identifier);
42
67
  if (duplicatedType) {
43
68
  let alias;
44
- if (exportObj.isHelperFunc) {
45
- alias = makeAliasNameWithPackageAtEnd({
46
- package: exportObj.pkg,
47
- name: identifier,
48
- });
69
+ // Check if this package/name combination should skip aliasing
70
+ if (shouldSkipAlias(exportObj.pkg, identifier, nameToFirstPackage)) {
71
+ alias = identifier; // Use original name, no alias
49
72
  }
50
73
  else {
51
- alias = makeAliasName({
52
- package: exportObj.pkg,
53
- name: identifier,
54
- });
74
+ // Generate alias as usual
75
+ if (exportObj.isHelperFunc) {
76
+ alias = makeAliasNameWithPackageAtEnd({
77
+ package: exportObj.pkg,
78
+ name: identifier,
79
+ });
80
+ }
81
+ else {
82
+ alias = makeAliasName({
83
+ package: exportObj.pkg,
84
+ name: identifier,
85
+ });
86
+ }
55
87
  }
56
88
  return { name: identifier, alias: alias };
57
89
  }
@@ -10,7 +10,6 @@ export const plugin = (builder) => {
10
10
  UTILS.toBase64 = '@interchainjs/encoding';
11
11
  UTILS.toUtf8 = '@interchainjs/encoding';
12
12
  UTILS.Decimal = '@interchainjs/math';
13
- UTILS.DeliverTxResponse = '@interchainjs/types';
14
13
  }
15
14
  if (builder.options.prototypes.typingsFormat.customTypes.useEnhancedDecimal ===
16
15
  true) {
@@ -1,12 +1,12 @@
1
1
  export const getHelperFuncTypesForInterface = (options) => {
2
2
  return `
3
3
  import { HttpEndpoint } from "@interchainjs/types";
4
- import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
5
- import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
6
- import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
7
- import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
8
- import { toConverters, toEncoders } from "@interchainjs/cosmos";
9
- import { ISigningClient } from "@interchainjs/cosmos";` : ''}
4
+ import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";
5
+ import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";
6
+ import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";
7
+ import { TelescopeGeneratedCodec, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";
8
+ import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
9
+ import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";
10
10
 
11
11
  export interface QueryBuilderOptions<TReq, TRes> {
12
12
  encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
@@ -58,7 +58,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
58
58
  message: TMsg | TMsg[],
59
59
  fee: StdFee | 'auto',
60
60
  memo: string
61
- ): Promise<DeliverTxResponse> => {
61
+ ): Promise<any> => {
62
62
  if (!client) throw new Error("SigningClient is not initialized");
63
63
 
64
64
  //register all related encoders and converters
@@ -1,12 +1,12 @@
1
1
  export const getHelperFuncTypes = (options) => {
2
2
  return `
3
3
  import { HttpEndpoint } from "@interchainjs/types";
4
- import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
5
- import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
6
- import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
7
- import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
8
- import { toConverters, toEncoders } from "@interchainjs/cosmos";
9
- import { ISigningClient } from "@interchainjs/cosmos";` : ''}
4
+ import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";
5
+ import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";
6
+ import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";
7
+ import { TelescopeGeneratedCodec, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";
8
+ import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
9
+ import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";
10
10
 
11
11
  export interface QueryBuilderOptions<TReq, TRes> {
12
12
  encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
@@ -51,7 +51,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
51
51
  message: TMsg | TMsg[],
52
52
  fee: StdFee | 'auto',
53
53
  memo: string
54
- ): Promise<DeliverTxResponse> => {
54
+ ): Promise<any> => {
55
55
  if (!client) throw new Error("SigningClient is not initialized");
56
56
 
57
57
  //register all related encoders and converters
@@ -12,7 +12,7 @@ import {
12
12
  import { ISigningClient, isISigningClient } from "@interchainjs/cosmos";
13
13
  import {
14
14
  StdFee,
15
- DeliverTxResponse,
15
+
16
16
  } from './types${options.restoreImportExtension ?? ""}'
17
17
  import {
18
18
  useQuery,
@@ -173,7 +173,7 @@ export interface UseMutationBuilderOptions<TMsg> {
173
173
  message: TMsg | TMsg[],
174
174
  fee: StdFee | 'auto',
175
175
  memo: string
176
- ) => Promise<DeliverTxResponse>,
176
+ ) => Promise<any>,
177
177
  }
178
178
 
179
179
  const getSigningClientFromCache = (
@@ -189,7 +189,7 @@ export function buildUseMutation<TMsg, TError>(opts: UseMutationBuilderOptions<T
189
189
  return ({
190
190
  options,
191
191
  clientResolver
192
- }: ReactMutationParams<DeliverTxResponse, TError, ITxArgs<TMsg>>) => {
192
+ }: ReactMutationParams<any, TError, ITxArgs<TMsg>>) => {
193
193
  const queryClient = useQueryClient({
194
194
  context: options?.context
195
195
  });
@@ -209,9 +209,9 @@ export function buildUseMutation<TMsg, TError>(opts: UseMutationBuilderOptions<T
209
209
  signingClientResolver = cachedClient || (!isCacheResolver(clientResolver) ? clientResolver : undefined);
210
210
  }
211
211
 
212
- return useMutation<DeliverTxResponse, Error, ITxArgs<TMsg>>(
212
+ return useMutation<any, Error, ITxArgs<TMsg>>(
213
213
  (reqData: ITxArgs<TMsg>) => opts.builderMutationFn(signingClientResolver!, reqData.signerAddress, reqData.message, reqData.fee, reqData.memo),
214
- options as Omit<UseMutationOptions<DeliverTxResponse, Error, ITxArgs<TMsg>, unknown>, "mutationFn">
214
+ options as Omit<UseMutationOptions<any, Error, ITxArgs<TMsg>, unknown>, "mutationFn">
215
215
  );
216
216
  };
217
217
  }
@@ -9,7 +9,7 @@ import {
9
9
  } from './helpers${options.restoreImportExtension ?? ""}'
10
10
  import {
11
11
  StdFee,
12
- DeliverTxResponse,
12
+
13
13
  } from './types${options.restoreImportExtension ?? ""}'
14
14
  import {
15
15
  ITxArgs,
@@ -206,7 +206,7 @@ export interface UseMutationBuilderOptions<TMsg> {
206
206
  message: TMsg | TMsg[],
207
207
  fee: StdFee | 'auto',
208
208
  memo: string
209
- ) => Promise<DeliverTxResponse>,
209
+ ) => Promise<any>,
210
210
  }
211
211
 
212
212
  const getSigningClientFromCache = (
@@ -222,7 +222,7 @@ export function buildUseMutation<TMsg, TError>(opts: UseMutationBuilderOptions<T
222
222
  return ({
223
223
  options,
224
224
  clientResolver
225
- }: ReactMutationParams<DeliverTxResponse, TError, ITxArgs<TMsg>>) => {
225
+ }: ReactMutationParams<any, TError, ITxArgs<TMsg>>) => {
226
226
  const queryClient = useQueryClient({
227
227
  context: options?.context
228
228
  });
@@ -244,9 +244,9 @@ export function buildUseMutation<TMsg, TError>(opts: UseMutationBuilderOptions<T
244
244
 
245
245
  const mutationFn = opts.builderMutationFn(signingClientResolver);
246
246
 
247
- return useMutation<DeliverTxResponse, Error, ITxArgs<TMsg>>(
247
+ return useMutation<any, Error, ITxArgs<TMsg>>(
248
248
  (reqData: ITxArgs<TMsg>) => mutationFn(reqData.signerAddress, reqData.message, reqData.fee, reqData.memo),
249
- options as Omit<UseMutationOptions<DeliverTxResponse, Error, ITxArgs<TMsg>, unknown>, "mutationFn">
249
+ options as Omit<UseMutationOptions<any, Error, ITxArgs<TMsg>, unknown>, "mutationFn">
250
250
  );
251
251
  };
252
252
  }
@@ -5,9 +5,9 @@ ${options.useInterchainJs ? '' : `import { OfflineSigner } from "@cosmjs/proto-s
5
5
  import { HttpEndpoint } from "${options.useInterchainJs ? "@interchainjs/types" : "@cosmjs/tendermint-rpc"}";
6
6
  ${options.useInterchainJs ? `
7
7
 
8
- import { DeliverTxResponse, Event, Attribute } from "@interchainjs/types";
8
+ import { Event, Attribute } from "@interchainjs/types";
9
+
9
10
 
10
- export { DeliverTxResponse }
11
11
 
12
12
  ` : ''}
13
13
  export type ProtoMsg = Omit<Any, "typeUrl"> & { typeUrl: any };
@@ -102,41 +102,7 @@ export interface Event {
102
102
  attributes: readonly Attribute[];
103
103
  }
104
104
 
105
- /**
106
- * The response after successfully broadcasting a transaction.
107
- * Success or failure refer to the execution result.
108
- */
109
- export interface DeliverTxResponse {
110
- height: number;
111
- /** The position of the transaction within the block. This is a 0-based index. */
112
- txIndex: number;
113
- /** Error code. The transaction suceeded if and only if code is 0. */
114
- code: number;
115
- transactionHash: string;
116
- events: readonly Event[];
117
- /**
118
- * A string-based log document.
119
- *
120
- * This currently seems to merge attributes of multiple events into one event per type
121
- * (https://github.com/tendermint/tendermint/issues/9595). You might want to use the \`events\`
122
- * field instead.
123
- */
124
- rawLog?: string;
125
- /** @deprecated Use \`msgResponses\` instead. */
126
- data?: readonly MsgData[];
127
- /**
128
- * The message responses of the [TxMsgData](https://github.com/cosmos/cosmos-sdk/blob/v0.46.3/proto/cosmos/base/abci/v1beta1/abci.proto#L128-L140)
129
- * as \`Any\`s.
130
- * This field is an empty list for chains running Cosmos SDK < 0.46.
131
- */
132
- msgResponses: Array<{
133
- typeUrl: string;
134
- value: Uint8Array;
135
- }>;
136
- gasUsed: bigint;
137
- gasWanted: bigint;
138
- origin?: any;
139
- }
105
+
140
106
  `}
141
107
  export interface TxRpc {
142
108
  request(
@@ -149,7 +115,7 @@ export interface TxRpc {
149
115
  messages: EncodeObject[],
150
116
  fee: StdFee | "auto" | number,
151
117
  memo: string
152
- ): Promise<DeliverTxResponse>;
118
+ ): Promise<any>;
153
119
  }
154
120
  ${options.useInterchainJs ? '' : `
155
121
  export interface SigningClientParams {
@@ -14,7 +14,7 @@ import {
14
14
  import { ISigningClient, isISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";
15
15
  import {
16
16
  StdFee,
17
- DeliverTxResponse,
17
+
18
18
  } from './types${options.restoreImportExtension ?? ""}'
19
19
  import {
20
20
  useQuery,
@@ -174,7 +174,7 @@ export interface UseMutationBuilderOptions<TMsg> {
174
174
  message: TMsg | TMsg[],
175
175
  fee: StdFee | 'auto',
176
176
  memo: string
177
- ) => Promise<DeliverTxResponse>;
177
+ ) => Promise<any>;
178
178
  }
179
179
 
180
180
  export function buildUseVueMutation<TMsg, TError>(
@@ -183,7 +183,7 @@ export function buildUseVueMutation<TMsg, TError>(
183
183
  return function useBuiltMutation({
184
184
  options,
185
185
  clientResolver,
186
- }: VueMutationParams<DeliverTxResponse, TError, ITxArgs<TMsg>>) {
186
+ }: VueMutationParams<any, TError, ITxArgs<TMsg>>) {
187
187
  const queryClient = useQueryClient();
188
188
 
189
189
  let signingClientResolver: ISigningClient | undefined;
@@ -203,7 +203,7 @@ export function buildUseVueMutation<TMsg, TError>(
203
203
  clientResolver = clientResolver;
204
204
  }
205
205
 
206
- return useMutation<DeliverTxResponse, TError, ITxArgs<TMsg>>(
206
+ return useMutation<any, TError, ITxArgs<TMsg>>(
207
207
  {
208
208
  mutationFn: (reqData: ITxArgs<TMsg>) =>
209
209
  opts.builderMutationFn(
@@ -61,6 +61,13 @@ export async function clone({ owner, repo, branch, gitModulesDir: outDir, protoD
61
61
  }));
62
62
  return clonedResult;
63
63
  }
64
+ function sanitizeProtoContent(content) {
65
+ // Remove any standalone semicolon lines that could be introduced upstream
66
+ // e.g., a line that only contains ';' or whitespace + ';'
67
+ const lines = content.split(/\r?\n/);
68
+ const sanitized = lines.filter((line) => !/^\s*;\s*$/.test(line));
69
+ return sanitized.join("\n");
70
+ }
64
71
  export function extractProto({ sources, targets, outDir }) {
65
72
  const extractProtoFiles = extractProtoFromDirs({
66
73
  targets,
@@ -70,7 +77,9 @@ export function extractProto({ sources, targets, outDir }) {
70
77
  const targetFile = join(outDir, target);
71
78
  const deepTargetDir = dirname(targetFile);
72
79
  makeDir(deepTargetDir);
73
- fs.copyFileSync(sourceFile, targetFile);
80
+ const raw = fs.readFileSync(sourceFile, "utf8");
81
+ const sanitized = sanitizeProtoContent(raw);
82
+ fs.writeFileSync(targetFile, sanitized, "utf8");
74
83
  console.info(`Copied ${target} from ${sourceFile.replace(target, "")}`);
75
84
  });
76
85
  }
@@ -58,7 +58,6 @@ export const UTILS = {
58
58
  TxRpc: '__types__',
59
59
  BroadcastTxReq: '__types__',
60
60
  BroadcastTxRes: '__types__',
61
- DeliverTxResponse: '__types__',
62
61
  EncodeObject: '__types__',
63
62
  SigningClientParams: '__types__',
64
63
  grpc: '@improbable-eng/grpc-web',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperweb/telescope",
3
- "version": "1.17.3",
3
+ "version": "2.0.0",
4
4
  "description": "A TypeScript Transpiler for Cosmos Protobufs",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/hyperweb-io/telescope/tree/master/packages/telescope#readme",
@@ -90,10 +90,10 @@
90
90
  "@babel/parser": "^7.23.6",
91
91
  "@babel/traverse": "7.23.6",
92
92
  "@babel/types": "7.23.6",
93
- "@cosmology/ast": "^1.12.1",
94
- "@cosmology/proto-parser": "^1.11.1",
95
- "@cosmology/types": "^1.13.1",
96
- "@cosmology/utils": "^1.11.1",
93
+ "@cosmology/ast": "^2.0.0",
94
+ "@cosmology/proto-parser": "^2.0.0",
95
+ "@cosmology/types": "^2.0.0",
96
+ "@cosmology/utils": "^2.0.0",
97
97
  "@cosmwasm/ts-codegen": "0.35.7",
98
98
  "@types/parse-package-name": "0.1.0",
99
99
  "case": "1.6.3",
@@ -111,5 +111,5 @@
111
111
  "rimraf": "5.0.0",
112
112
  "yaml": "^2.3.4"
113
113
  },
114
- "gitHead": "a8d5404c05996b49916a64f05586e771d87629dd"
114
+ "gitHead": "2e79a382622c3753bdb352cb4b1effb5e57b3c9b"
115
115
  }
@@ -27,10 +27,11 @@ export default async (argv: {
27
27
  } else {
28
28
  options = {
29
29
  // global options (can be overridden through plugins)
30
+ useInterchainJs: true,
30
31
  interfaces: {
31
- enabled: false,
32
- useByDefault: false,
33
- useUnionTypes: false,
32
+ enabled: true,
33
+ useByDefault: true,
34
+ useUnionTypes: true,
34
35
  },
35
36
 
36
37
  prototypes: {
@@ -53,37 +54,43 @@ export default async (argv: {
53
54
  addTypeUrlToDecoders: true,
54
55
 
55
56
  typingsFormat: {
56
- duration: 'duration',
57
- timestamp: 'date',
58
- useExact: false,
59
- useDeepPartial: false,
60
- num64: 'bigint',
61
57
  customTypes: {
62
- useCosmosSDKDec: true
63
- }
58
+ useCosmosSDKDec: true,
59
+ },
60
+ num64: "bigint",
61
+ useDeepPartial: false,
62
+ useExact: false,
63
+ toJsonUnknown: false,
64
+ timestamp: "date",
65
+ duration: "duration",
66
+ updatedDuration: false,
67
+ useTelescopeGeneratedType: true,
68
+ setDefaultEnumToUnrecognized: true,
69
+ autoFixUndefinedEnumDefault: false,
64
70
  },
65
71
  },
66
72
 
67
73
  bundle: {
68
- enabled: true
74
+ enabled: true,
75
+ type: "namespace",
69
76
  },
70
77
 
71
78
  stargateClients: {
72
- enabled: true,
79
+ enabled: false,
73
80
  includeCosmosDefaultTypes: true
74
81
  },
75
82
 
76
83
  aminoEncoding: {
77
84
  enabled: true,
85
+ useLegacyInlineEncoding: false,
78
86
  },
79
87
 
80
88
  lcdClients: {
81
- enabled: true
89
+ enabled: false
82
90
  },
83
91
 
84
92
  rpcClients: {
85
- enabled: true,
86
- camelCase: true
93
+ enabled: false,
87
94
  }
88
95
  }
89
96
 
@@ -95,7 +102,7 @@ export default async (argv: {
95
102
  type: 'path',
96
103
  name: 'protoDirs',
97
104
  message: 'where is the proto directory?',
98
- default: './proto'
105
+ default: './protos'
99
106
  },
100
107
  {
101
108
  _: true,
@@ -11,6 +11,38 @@ import {
11
11
  makeAliasNameWithPackageAtEnd,
12
12
  } from "@cosmology/utils";
13
13
 
14
+ /**
15
+ * Process noAlias configuration to create a map of names to their first package
16
+ * This ensures that only the first occurrence of a name skips aliasing
17
+ */
18
+ const processNoAliasConfig = (noAlias?: Array<{ package: string; name: string }>) => {
19
+ if (!noAlias || noAlias.length === 0) {
20
+ return new Map<string, string>();
21
+ }
22
+
23
+ const nameToFirstPackage = new Map<string, string>();
24
+
25
+ for (const entry of noAlias) {
26
+ if (!nameToFirstPackage.has(entry.name)) {
27
+ nameToFirstPackage.set(entry.name, entry.package);
28
+ }
29
+ }
30
+
31
+ return nameToFirstPackage;
32
+ };
33
+
34
+ /**
35
+ * Check if a package/name combination should skip aliasing
36
+ */
37
+ const shouldSkipAlias = (
38
+ pkg: string,
39
+ name: string,
40
+ nameToFirstPackage: Map<string, string>
41
+ ): boolean => {
42
+ const firstPackage = nameToFirstPackage.get(name);
43
+ return firstPackage === pkg;
44
+ };
45
+
14
46
  export const plugin = (builder: TelescopeBuilder, bundler: Bundler) => {
15
47
  if (!builder.options.bundle.enabled) {
16
48
  return;
@@ -18,6 +50,9 @@ export const plugin = (builder: TelescopeBuilder, bundler: Bundler) => {
18
50
 
19
51
  let prog = [];
20
52
 
53
+ // Process noAlias configuration once at the beginning
54
+ const nameToFirstPackage = processNoAliasConfig((builder.options.bundle as any).noAlias);
55
+
21
56
  if (builder.options.bundle.type === "namespace") {
22
57
  const importPaths = duplicateImportPathsWithExt(
23
58
  bundler.bundle.importPaths,
@@ -67,16 +102,23 @@ export const plugin = (builder: TelescopeBuilder, bundler: Bundler) => {
67
102
  );
68
103
  if (duplicatedType) {
69
104
  let alias: string;
70
- if (exportObj.isHelperFunc) {
71
- alias = makeAliasNameWithPackageAtEnd({
72
- package: exportObj.pkg,
73
- name: identifier,
74
- });
105
+
106
+ // Check if this package/name combination should skip aliasing
107
+ if (shouldSkipAlias(exportObj.pkg, identifier, nameToFirstPackage)) {
108
+ alias = identifier; // Use original name, no alias
75
109
  } else {
76
- alias = makeAliasName({
77
- package: exportObj.pkg,
78
- name: identifier,
79
- });
110
+ // Generate alias as usual
111
+ if (exportObj.isHelperFunc) {
112
+ alias = makeAliasNameWithPackageAtEnd({
113
+ package: exportObj.pkg,
114
+ name: identifier,
115
+ });
116
+ } else {
117
+ alias = makeAliasName({
118
+ package: exportObj.pkg,
119
+ name: identifier,
120
+ });
121
+ }
80
122
  }
81
123
  return { name: identifier, alias: alias };
82
124
  }
@@ -14,8 +14,6 @@ export const plugin = (builder: TelescopeBuilder) => {
14
14
  UTILS.toUtf8 = '@interchainjs/encoding';
15
15
 
16
16
  UTILS.Decimal = '@interchainjs/math';
17
-
18
- UTILS.DeliverTxResponse = '@interchainjs/types';
19
17
  }
20
18
 
21
19
  if (
@@ -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 ?? ""}";${!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
- import { toConverters, toEncoders } from "@interchainjs/cosmos";
11
- import { ISigningClient } from "@interchainjs/cosmos";` : ''}
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, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";
10
+ import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
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
@@ -60,7 +60,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
60
60
  message: TMsg | TMsg[],
61
61
  fee: StdFee | 'auto',
62
62
  memo: string
63
- ): Promise<DeliverTxResponse> => {
63
+ ): Promise<any> => {
64
64
  if (!client) throw new Error("SigningClient is not initialized");
65
65
 
66
66
  //register all related encoders and converters
@@ -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 ?? ""}";${!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
- import { toConverters, toEncoders } from "@interchainjs/cosmos";
11
- import { ISigningClient } from "@interchainjs/cosmos";` : ''}
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, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";
10
+ import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
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
@@ -53,7 +53,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
53
53
  message: TMsg | TMsg[],
54
54
  fee: StdFee | 'auto',
55
55
  memo: string
56
- ): Promise<DeliverTxResponse> => {
56
+ ): Promise<any> => {
57
57
  if (!client) throw new Error("SigningClient is not initialized");
58
58
 
59
59
  //register all related encoders and converters
@@ -14,7 +14,7 @@ import {
14
14
  import { ISigningClient, isISigningClient } from "@interchainjs/cosmos";
15
15
  import {
16
16
  StdFee,
17
- DeliverTxResponse,
17
+
18
18
  } from './types${options.restoreImportExtension ?? ""}'
19
19
  import {
20
20
  useQuery,
@@ -177,7 +177,7 @@ export interface UseMutationBuilderOptions<TMsg> {
177
177
  message: TMsg | TMsg[],
178
178
  fee: StdFee | 'auto',
179
179
  memo: string
180
- ) => Promise<DeliverTxResponse>,
180
+ ) => Promise<any>,
181
181
  }
182
182
 
183
183
  const getSigningClientFromCache = (
@@ -193,7 +193,7 @@ export function buildUseMutation<TMsg, TError>(opts: UseMutationBuilderOptions<T
193
193
  return ({
194
194
  options,
195
195
  clientResolver
196
- }: ReactMutationParams<DeliverTxResponse, TError, ITxArgs<TMsg>>) => {
196
+ }: ReactMutationParams<any, TError, ITxArgs<TMsg>>) => {
197
197
  const queryClient = useQueryClient({
198
198
  context: options?.context
199
199
  });
@@ -213,9 +213,9 @@ export function buildUseMutation<TMsg, TError>(opts: UseMutationBuilderOptions<T
213
213
  signingClientResolver = cachedClient || (!isCacheResolver(clientResolver) ? clientResolver : undefined);
214
214
  }
215
215
 
216
- return useMutation<DeliverTxResponse, Error, ITxArgs<TMsg>>(
216
+ return useMutation<any, Error, ITxArgs<TMsg>>(
217
217
  (reqData: ITxArgs<TMsg>) => opts.builderMutationFn(signingClientResolver!, reqData.signerAddress, reqData.message, reqData.fee, reqData.memo),
218
- options as Omit<UseMutationOptions<DeliverTxResponse, Error, ITxArgs<TMsg>, unknown>, "mutationFn">
218
+ options as Omit<UseMutationOptions<any, Error, ITxArgs<TMsg>, unknown>, "mutationFn">
219
219
  );
220
220
  };
221
221
  }