@hyperweb/telescope 1.17.0 → 1.17.2
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.
- package/main/generators/create-helpers.js +15 -8
- package/main/helpers/helper-func-types-interface.js +8 -8
- package/main/helpers/helper-func-types.js +8 -8
- package/main/helpers/internal-for-bigint.js +4 -3
- package/main/helpers/internal.js +4 -2
- package/module/generators/create-helpers.js +15 -8
- package/module/helpers/helper-func-types-interface.js +8 -8
- package/module/helpers/helper-func-types.js +8 -8
- package/module/helpers/internal-for-bigint.js +4 -3
- package/module/helpers/internal.js +4 -2
- package/package.json +6 -6
- package/src/generators/create-helpers.ts +29 -16
- package/src/helpers/helper-func-types-interface.ts +8 -8
- package/src/helpers/helper-func-types.ts +8 -8
- package/src/helpers/internal-for-bigint.ts +4 -2
- package/src/helpers/internal.ts +4 -1
|
@@ -26,22 +26,27 @@ const plugin = (builder) => {
|
|
|
26
26
|
? (0, helpers_1.getHelperForBigint)(builder.options)
|
|
27
27
|
: (0, helpers_1.getHelper)(builder.options));
|
|
28
28
|
// should be exported
|
|
29
|
-
if (builder.options.
|
|
30
|
-
builder.options.
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (!builder.options.isGeneratingCosmosTypes &&
|
|
30
|
+
(builder.options.stargateClients.addGetTxRpc ||
|
|
31
|
+
builder.options.includeExternalHelpers ||
|
|
32
|
+
builder.options.reactQuery?.enabled ||
|
|
33
|
+
builder.options?.helperFunctions?.enabled)) {
|
|
33
34
|
// also react-query needs these...
|
|
34
35
|
builder.files.push("extern.ts");
|
|
35
36
|
if (builder.options?.helperFunctions?.enabled) {
|
|
36
37
|
write(builder, "extern.ts", helpers_1.externalIcJs);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
|
-
write(builder, "extern.ts", builder.options.rpcClients?.useConnectComet ||
|
|
40
|
+
write(builder, "extern.ts", builder.options.rpcClients?.useConnectComet ||
|
|
41
|
+
builder.options.rpcClients?.useMakeClient
|
|
42
|
+
? helpers_1.externalComet
|
|
43
|
+
: helpers_1.external);
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
if (builder.options.helperFunctions?.enabled) {
|
|
43
47
|
builder.files.push("helper-func-types.ts");
|
|
44
|
-
if (builder.options.interfaces?.enabled &&
|
|
48
|
+
if (builder.options.interfaces?.enabled &&
|
|
49
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry) {
|
|
45
50
|
write(builder, "helper-func-types.ts", (0, helpers_1.getHelperFuncTypesForInterface)(builder.options));
|
|
46
51
|
}
|
|
47
52
|
else {
|
|
@@ -105,13 +110,15 @@ const plugin = (builder) => {
|
|
|
105
110
|
}
|
|
106
111
|
if (builder.options.prototypes?.typingsFormat?.useTelescopeGeneratedType ||
|
|
107
112
|
(builder.options.interfaces?.enabled &&
|
|
108
|
-
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
113
|
+
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
114
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry)) ||
|
|
109
115
|
builder.options.helperFunctions?.enabled) {
|
|
110
116
|
builder.files.push("types.ts");
|
|
111
117
|
write(builder, "types.ts", (0, helpers_1.getTypesHelper)(builder.options));
|
|
112
118
|
}
|
|
113
119
|
if (builder.options.interfaces?.enabled &&
|
|
114
|
-
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
120
|
+
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
121
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry)) {
|
|
115
122
|
builder.files.push("registry.ts");
|
|
116
123
|
write(builder, "registry.ts", (0, helpers_1.getRegistryHelper)(builder.options));
|
|
117
124
|
}
|
|
@@ -4,12 +4,12 @@ exports.getHelperFuncTypesForInterface = void 0;
|
|
|
4
4
|
const getHelperFuncTypesForInterface = (options) => {
|
|
5
5
|
return `
|
|
6
6
|
import { HttpEndpoint } from "@interchainjs/types";
|
|
7
|
-
import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}"
|
|
8
|
-
import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}"
|
|
9
|
-
import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}"
|
|
10
|
-
import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}"
|
|
7
|
+
import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
|
|
8
|
+
import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
|
|
9
|
+
import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
|
|
10
|
+
import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
|
|
11
11
|
import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
|
|
12
|
-
import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}"
|
|
12
|
+
import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";` : ''}
|
|
13
13
|
|
|
14
14
|
export interface QueryBuilderOptions<TReq, TRes> {
|
|
15
15
|
encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
|
|
@@ -28,7 +28,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
|
|
|
28
28
|
if(isRpc(client)) {
|
|
29
29
|
rpc = client;
|
|
30
30
|
} else {
|
|
31
|
-
rpc = client ? await getRpcClient(client) : undefined;
|
|
31
|
+
rpc = ${options.isGeneratingCosmosTypes ? 'undefined' : 'client ? await getRpcClient(client) : undefined'};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (!rpc) throw new Error("Query Rpc is not initialized");
|
|
@@ -39,7 +39,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export interface ITxArgs<TMsg> {
|
|
42
|
+
${!options.isGeneratingCosmosTypes ? `export interface ITxArgs<TMsg> {
|
|
43
43
|
signerAddress: string;
|
|
44
44
|
message: TMsg | TMsg[];
|
|
45
45
|
fee: StdFee | 'auto';
|
|
@@ -79,7 +79,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
|
|
|
79
79
|
}];
|
|
80
80
|
return client.signAndBroadcast!(signerAddress, data, fee, memo);
|
|
81
81
|
};
|
|
82
|
-
}
|
|
82
|
+
}` : ''}
|
|
83
83
|
|
|
84
84
|
export interface Encoder {
|
|
85
85
|
typeUrl: string;
|
|
@@ -4,12 +4,12 @@ exports.getHelperFuncTypes = void 0;
|
|
|
4
4
|
const getHelperFuncTypes = (options) => {
|
|
5
5
|
return `
|
|
6
6
|
import { HttpEndpoint } from "@interchainjs/types";
|
|
7
|
-
import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}"
|
|
8
|
-
import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}"
|
|
9
|
-
import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}"
|
|
10
|
-
import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}"
|
|
7
|
+
import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
|
|
8
|
+
import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
|
|
9
|
+
import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
|
|
10
|
+
import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
|
|
11
11
|
import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
|
|
12
|
-
import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}"
|
|
12
|
+
import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";` : ''}
|
|
13
13
|
|
|
14
14
|
export interface QueryBuilderOptions<TReq, TRes> {
|
|
15
15
|
encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
|
|
@@ -25,7 +25,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
|
|
|
25
25
|
if(isRpc(client)) {
|
|
26
26
|
rpc = client;
|
|
27
27
|
} else {
|
|
28
|
-
rpc = client ? await getRpcClient(client) : undefined;
|
|
28
|
+
rpc = ${options.isGeneratingCosmosTypes ? 'undefined' : 'client ? await getRpcClient(client) : undefined'};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (!rpc) throw new Error("Query Rpc is not initialized");
|
|
@@ -36,7 +36,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export interface ITxArgs<TMsg> {
|
|
39
|
+
${!options.isGeneratingCosmosTypes ? `export interface ITxArgs<TMsg> {
|
|
40
40
|
signerAddress: string;
|
|
41
41
|
message: TMsg | TMsg[];
|
|
42
42
|
fee: StdFee | 'auto';
|
|
@@ -72,7 +72,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
|
|
|
72
72
|
}];
|
|
73
73
|
return client.signAndBroadcast!(signerAddress, data, fee, memo);
|
|
74
74
|
};
|
|
75
|
-
}
|
|
75
|
+
}` : ''}
|
|
76
76
|
|
|
77
77
|
export interface Encoder {
|
|
78
78
|
typeUrl: string;
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getHelperForBigint = void 0;
|
|
4
4
|
const getHelperForBigint = (options) => {
|
|
5
|
-
return
|
|
6
|
-
|
|
5
|
+
return `${options.useInterchainJs ?
|
|
6
|
+
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding/base64\';' :
|
|
7
|
+
`declare var self: any | undefined;
|
|
7
8
|
declare var window: any | undefined;
|
|
8
9
|
declare var global: any | undefined;
|
|
9
10
|
var globalThis: any = (() => {
|
|
@@ -37,7 +38,7 @@ export function base64FromBytes(arr: Uint8Array): string {
|
|
|
37
38
|
bin.push(String.fromCharCode(byte));
|
|
38
39
|
});
|
|
39
40
|
return btoa(bin.join(''));
|
|
40
|
-
}
|
|
41
|
+
}`}
|
|
41
42
|
|
|
42
43
|
export interface AminoHeight {
|
|
43
44
|
readonly revision_number?: string;
|
package/main/helpers/internal.js
CHANGED
|
@@ -14,7 +14,9 @@ if (_m0.util.Long !== Long) {
|
|
|
14
14
|
|
|
15
15
|
export { Long };
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
${options.useInterchainJs ?
|
|
18
|
+
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding/base64\';' :
|
|
19
|
+
`declare var self: any | undefined;
|
|
18
20
|
declare var window: any | undefined;
|
|
19
21
|
declare var global: any | undefined;
|
|
20
22
|
var globalThis: any = (() => {
|
|
@@ -46,7 +48,7 @@ export function base64FromBytes(arr: Uint8Array): string {
|
|
|
46
48
|
bin.push(String.fromCharCode(byte));
|
|
47
49
|
});
|
|
48
50
|
return btoa(bin.join(''));
|
|
49
|
-
}
|
|
51
|
+
}`}
|
|
50
52
|
|
|
51
53
|
export interface AminoHeight {
|
|
52
54
|
readonly revision_number?: string;
|
|
@@ -20,22 +20,27 @@ export const plugin = (builder) => {
|
|
|
20
20
|
? getHelperForBigint(builder.options)
|
|
21
21
|
: getHelper(builder.options));
|
|
22
22
|
// should be exported
|
|
23
|
-
if (builder.options.
|
|
24
|
-
builder.options.
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (!builder.options.isGeneratingCosmosTypes &&
|
|
24
|
+
(builder.options.stargateClients.addGetTxRpc ||
|
|
25
|
+
builder.options.includeExternalHelpers ||
|
|
26
|
+
builder.options.reactQuery?.enabled ||
|
|
27
|
+
builder.options?.helperFunctions?.enabled)) {
|
|
27
28
|
// also react-query needs these...
|
|
28
29
|
builder.files.push("extern.ts");
|
|
29
30
|
if (builder.options?.helperFunctions?.enabled) {
|
|
30
31
|
write(builder, "extern.ts", externalIcJs);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
write(builder, "extern.ts", builder.options.rpcClients?.useConnectComet ||
|
|
34
|
+
write(builder, "extern.ts", builder.options.rpcClients?.useConnectComet ||
|
|
35
|
+
builder.options.rpcClients?.useMakeClient
|
|
36
|
+
? externalComet
|
|
37
|
+
: external);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
if (builder.options.helperFunctions?.enabled) {
|
|
37
41
|
builder.files.push("helper-func-types.ts");
|
|
38
|
-
if (builder.options.interfaces?.enabled &&
|
|
42
|
+
if (builder.options.interfaces?.enabled &&
|
|
43
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry) {
|
|
39
44
|
write(builder, "helper-func-types.ts", getHelperFuncTypesForInterface(builder.options));
|
|
40
45
|
}
|
|
41
46
|
else {
|
|
@@ -99,13 +104,15 @@ export const plugin = (builder) => {
|
|
|
99
104
|
}
|
|
100
105
|
if (builder.options.prototypes?.typingsFormat?.useTelescopeGeneratedType ||
|
|
101
106
|
(builder.options.interfaces?.enabled &&
|
|
102
|
-
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
107
|
+
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
108
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry)) ||
|
|
103
109
|
builder.options.helperFunctions?.enabled) {
|
|
104
110
|
builder.files.push("types.ts");
|
|
105
111
|
write(builder, "types.ts", getTypesHelper(builder.options));
|
|
106
112
|
}
|
|
107
113
|
if (builder.options.interfaces?.enabled &&
|
|
108
|
-
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
114
|
+
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
115
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry)) {
|
|
109
116
|
builder.files.push("registry.ts");
|
|
110
117
|
write(builder, "registry.ts", getRegistryHelper(builder.options));
|
|
111
118
|
}
|
|
@@ -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 ?? ""}"
|
|
5
|
-
import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}"
|
|
6
|
-
import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}"
|
|
7
|
-
import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}"
|
|
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
8
|
import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
|
|
9
|
-
import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}"
|
|
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
|
|
@@ -25,7 +25,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
|
|
|
25
25
|
if(isRpc(client)) {
|
|
26
26
|
rpc = client;
|
|
27
27
|
} else {
|
|
28
|
-
rpc = client ? await getRpcClient(client) : undefined;
|
|
28
|
+
rpc = ${options.isGeneratingCosmosTypes ? 'undefined' : 'client ? await getRpcClient(client) : undefined'};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (!rpc) throw new Error("Query Rpc is not initialized");
|
|
@@ -36,7 +36,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export interface ITxArgs<TMsg> {
|
|
39
|
+
${!options.isGeneratingCosmosTypes ? `export interface ITxArgs<TMsg> {
|
|
40
40
|
signerAddress: string;
|
|
41
41
|
message: TMsg | TMsg[];
|
|
42
42
|
fee: StdFee | 'auto';
|
|
@@ -76,7 +76,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
|
|
|
76
76
|
}];
|
|
77
77
|
return client.signAndBroadcast!(signerAddress, data, fee, memo);
|
|
78
78
|
};
|
|
79
|
-
}
|
|
79
|
+
}` : ''}
|
|
80
80
|
|
|
81
81
|
export interface Encoder {
|
|
82
82
|
typeUrl: string;
|
|
@@ -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 ?? ""}"
|
|
5
|
-
import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}"
|
|
6
|
-
import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}"
|
|
7
|
-
import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}"
|
|
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
8
|
import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
|
|
9
|
-
import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}"
|
|
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
|
|
@@ -22,7 +22,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
|
|
|
22
22
|
if(isRpc(client)) {
|
|
23
23
|
rpc = client;
|
|
24
24
|
} else {
|
|
25
|
-
rpc = client ? await getRpcClient(client) : undefined;
|
|
25
|
+
rpc = ${options.isGeneratingCosmosTypes ? 'undefined' : 'client ? await getRpcClient(client) : undefined'};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (!rpc) throw new Error("Query Rpc is not initialized");
|
|
@@ -33,7 +33,7 @@ export function buildQuery<TReq, TRes>(opts: QueryBuilderOptions<TReq, TRes>) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export interface ITxArgs<TMsg> {
|
|
36
|
+
${!options.isGeneratingCosmosTypes ? `export interface ITxArgs<TMsg> {
|
|
37
37
|
signerAddress: string;
|
|
38
38
|
message: TMsg | TMsg[];
|
|
39
39
|
fee: StdFee | 'auto';
|
|
@@ -69,7 +69,7 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
|
|
|
69
69
|
}];
|
|
70
70
|
return client.signAndBroadcast!(signerAddress, data, fee, memo);
|
|
71
71
|
};
|
|
72
|
-
}
|
|
72
|
+
}` : ''}
|
|
73
73
|
|
|
74
74
|
export interface Encoder {
|
|
75
75
|
typeUrl: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const getHelperForBigint = (options) => {
|
|
2
|
-
return
|
|
3
|
-
|
|
2
|
+
return `${options.useInterchainJs ?
|
|
3
|
+
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding/base64\';' :
|
|
4
|
+
`declare var self: any | undefined;
|
|
4
5
|
declare var window: any | undefined;
|
|
5
6
|
declare var global: any | undefined;
|
|
6
7
|
var globalThis: any = (() => {
|
|
@@ -34,7 +35,7 @@ export function base64FromBytes(arr: Uint8Array): string {
|
|
|
34
35
|
bin.push(String.fromCharCode(byte));
|
|
35
36
|
});
|
|
36
37
|
return btoa(bin.join(''));
|
|
37
|
-
}
|
|
38
|
+
}`}
|
|
38
39
|
|
|
39
40
|
export interface AminoHeight {
|
|
40
41
|
readonly revision_number?: string;
|
|
@@ -11,7 +11,9 @@ if (_m0.util.Long !== Long) {
|
|
|
11
11
|
|
|
12
12
|
export { Long };
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
${options.useInterchainJs ?
|
|
15
|
+
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding/base64\';' :
|
|
16
|
+
`declare var self: any | undefined;
|
|
15
17
|
declare var window: any | undefined;
|
|
16
18
|
declare var global: any | undefined;
|
|
17
19
|
var globalThis: any = (() => {
|
|
@@ -43,7 +45,7 @@ export function base64FromBytes(arr: Uint8Array): string {
|
|
|
43
45
|
bin.push(String.fromCharCode(byte));
|
|
44
46
|
});
|
|
45
47
|
return btoa(bin.join(''));
|
|
46
|
-
}
|
|
48
|
+
}`}
|
|
47
49
|
|
|
48
50
|
export interface AminoHeight {
|
|
49
51
|
readonly revision_number?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperweb/telescope",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.2",
|
|
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.
|
|
94
|
-
"@cosmology/proto-parser": "^1.11.
|
|
95
|
-
"@cosmology/types": "^1.13.
|
|
96
|
-
"@cosmology/utils": "^1.11.
|
|
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",
|
|
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": "
|
|
114
|
+
"gitHead": "40a4298beb51c0a2f7bfb5d44c53c5c49d121632"
|
|
115
115
|
}
|
|
@@ -62,10 +62,11 @@ export const plugin = (builder: TelescopeBuilder) => {
|
|
|
62
62
|
|
|
63
63
|
// should be exported
|
|
64
64
|
if (
|
|
65
|
-
builder.options.
|
|
66
|
-
builder.options.
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
!builder.options.isGeneratingCosmosTypes &&
|
|
66
|
+
(builder.options.stargateClients.addGetTxRpc ||
|
|
67
|
+
builder.options.includeExternalHelpers ||
|
|
68
|
+
builder.options.reactQuery?.enabled ||
|
|
69
|
+
builder.options?.helperFunctions?.enabled)
|
|
69
70
|
) {
|
|
70
71
|
// also react-query needs these...
|
|
71
72
|
builder.files.push("extern.ts");
|
|
@@ -76,17 +77,31 @@ export const plugin = (builder: TelescopeBuilder) => {
|
|
|
76
77
|
write(
|
|
77
78
|
builder,
|
|
78
79
|
"extern.ts",
|
|
79
|
-
builder.options.rpcClients?.useConnectComet ||
|
|
80
|
+
builder.options.rpcClients?.useConnectComet ||
|
|
81
|
+
builder.options.rpcClients?.useMakeClient
|
|
82
|
+
? externalComet
|
|
83
|
+
: external
|
|
80
84
|
);
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
if (builder.options.helperFunctions?.enabled) {
|
|
85
89
|
builder.files.push("helper-func-types.ts");
|
|
86
|
-
if (
|
|
87
|
-
|
|
90
|
+
if (
|
|
91
|
+
builder.options.interfaces?.enabled &&
|
|
92
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry
|
|
93
|
+
) {
|
|
94
|
+
write(
|
|
95
|
+
builder,
|
|
96
|
+
"helper-func-types.ts",
|
|
97
|
+
getHelperFuncTypesForInterface(builder.options)
|
|
98
|
+
);
|
|
88
99
|
} else {
|
|
89
|
-
write(
|
|
100
|
+
write(
|
|
101
|
+
builder,
|
|
102
|
+
"helper-func-types.ts",
|
|
103
|
+
getHelperFuncTypes(builder.options)
|
|
104
|
+
);
|
|
90
105
|
}
|
|
91
106
|
}
|
|
92
107
|
|
|
@@ -121,15 +136,11 @@ export const plugin = (builder: TelescopeBuilder) => {
|
|
|
121
136
|
|
|
122
137
|
if (
|
|
123
138
|
builder.options?.helperFunctions?.enabled &&
|
|
124
|
-
|
|
139
|
+
builder.options?.helperFunctions?.hooks?.vue
|
|
125
140
|
) {
|
|
126
141
|
builder.files.push("vue-query.ts");
|
|
127
142
|
|
|
128
|
-
write(
|
|
129
|
-
builder,
|
|
130
|
-
"vue-query.ts",
|
|
131
|
-
getVueQueryHelperHooks(builder.options)
|
|
132
|
-
);
|
|
143
|
+
write(builder, "vue-query.ts", getVueQueryHelperHooks(builder.options));
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
if (builder.options.mobx?.enabled) {
|
|
@@ -179,7 +190,8 @@ export const plugin = (builder: TelescopeBuilder) => {
|
|
|
179
190
|
if (
|
|
180
191
|
builder.options.prototypes?.typingsFormat?.useTelescopeGeneratedType ||
|
|
181
192
|
(builder.options.interfaces?.enabled &&
|
|
182
|
-
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
193
|
+
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
194
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry)) ||
|
|
183
195
|
builder.options.helperFunctions?.enabled
|
|
184
196
|
) {
|
|
185
197
|
builder.files.push("types.ts");
|
|
@@ -188,7 +200,8 @@ export const plugin = (builder: TelescopeBuilder) => {
|
|
|
188
200
|
|
|
189
201
|
if (
|
|
190
202
|
builder.options.interfaces?.enabled &&
|
|
191
|
-
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
203
|
+
(builder.options.interfaces?.useGlobalDecoderRegistry ||
|
|
204
|
+
builder.options.helperFunctions?.useGlobalDecoderRegistry)
|
|
192
205
|
) {
|
|
193
206
|
builder.files.push("registry.ts");
|
|
194
207
|
write(builder, "registry.ts", getRegistryHelper(builder.options));
|
|
@@ -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;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TelescopeOptions } from "@cosmology/types";
|
|
2
2
|
|
|
3
3
|
export const getHelperForBigint = (options: TelescopeOptions) => {
|
|
4
|
-
return
|
|
5
|
-
|
|
4
|
+
return `${options.useInterchainJs ?
|
|
5
|
+
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding/base64\';' :
|
|
6
|
+
`declare var self: any | undefined;
|
|
6
7
|
declare var window: any | undefined;
|
|
7
8
|
declare var global: any | undefined;
|
|
8
9
|
var globalThis: any = (() => {
|
|
@@ -36,6 +37,7 @@ export function base64FromBytes(arr: Uint8Array): string {
|
|
|
36
37
|
bin.push(String.fromCharCode(byte));
|
|
37
38
|
});
|
|
38
39
|
return btoa(bin.join(''));
|
|
40
|
+
}`
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export interface AminoHeight {
|
package/src/helpers/internal.ts
CHANGED
|
@@ -13,7 +13,9 @@ if (_m0.util.Long !== Long) {
|
|
|
13
13
|
|
|
14
14
|
export { Long };
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
${options.useInterchainJs ?
|
|
17
|
+
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding/base64\';' :
|
|
18
|
+
`declare var self: any | undefined;
|
|
17
19
|
declare var window: any | undefined;
|
|
18
20
|
declare var global: any | undefined;
|
|
19
21
|
var globalThis: any = (() => {
|
|
@@ -45,6 +47,7 @@ export function base64FromBytes(arr: Uint8Array): string {
|
|
|
45
47
|
bin.push(String.fromCharCode(byte));
|
|
46
48
|
});
|
|
47
49
|
return btoa(bin.join(''));
|
|
50
|
+
}`
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
export interface AminoHeight {
|