@hyperweb/telescope 2.0.4 → 2.1.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.
- package/README.md +5 -5
- package/module/telescope.js +0 -0
- package/package.json +8 -8
- package/main/generators/create-combined-stargate-clients.js +0 -99
- package/main/helpers/generated-type.js +0 -24
- package/main/helpers/internalForBigInt.js +0 -248
- package/main/helpers/types.js +0 -24
- package/main/helpers/vue-query.js +0 -91
- package/main/protod/proto-download.js +0 -57
- package/module/generators/create-combined-stargate-clients.js +0 -95
- package/module/helpers/generated-type.js +0 -21
- package/module/helpers/internalForBigInt.js +0 -245
- package/module/helpers/types.js +0 -21
- package/module/helpers/vue-query.js +0 -87
- package/module/protod/proto-download.js +0 -55
- package/types/codegen/cosmos/orm/module/v1alpha1/module.d.ts +0 -43
package/README.md
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
<a href="https://github.com/hyperweb-io/telescope/actions/workflows/run-tests.yaml">
|
|
12
12
|
<img height="20" src="https://github.com/hyperweb-io/telescope/actions/workflows/run-tests.yaml/badge.svg" />
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://github.com/
|
|
15
|
-
<img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%
|
|
14
|
+
<a href="https://github.com/constructive-io/lib-count">
|
|
15
|
+
<img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fconstructive-io%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Ftelescope%2Ftotal.json"/>
|
|
16
16
|
</a>
|
|
17
|
-
<a href="https://github.com/
|
|
18
|
-
<img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%
|
|
17
|
+
<a href="https://github.com/constructive-io/lib-count">
|
|
18
|
+
<img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fconstructive-io%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Ftelescope%2Fmonthly.json"/>
|
|
19
19
|
</a>
|
|
20
20
|
<br />
|
|
21
21
|
<a href="https://github.com/hyperweb-io/telescope/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
|
|
@@ -1563,7 +1563,7 @@ A unified toolkit for building applications and smart contracts in the Interchai
|
|
|
1563
1563
|
|
|
1564
1564
|
## Credits
|
|
1565
1565
|
|
|
1566
|
-
🛠 Built by [
|
|
1566
|
+
🛠 Built by the [Constructive](https://constructive.io) team — makers of [Hyperweb](https://hyperweb.io)
|
|
1567
1567
|
|
|
1568
1568
|
|
|
1569
1569
|
Thanks to these engineers, teams and projects for inspiring Telescope:
|
package/module/telescope.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperweb/telescope",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A TypeScript Transpiler for Cosmos Protobufs",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"homepage": "https://github.com/hyperweb-io/telescope/tree/master/packages/telescope#readme",
|
|
7
|
-
"license": "
|
|
7
|
+
"license": "MIT",
|
|
8
8
|
"main": "main/index.js",
|
|
9
9
|
"module": "module/index.js",
|
|
10
10
|
"typings": "types/index.d.ts",
|
|
@@ -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": "^2.0
|
|
94
|
-
"@cosmology/proto-parser": "^2.0
|
|
95
|
-
"@cosmology/types": "^2.0
|
|
96
|
-
"@cosmology/utils": "^2.0
|
|
93
|
+
"@cosmology/ast": "^2.1.0",
|
|
94
|
+
"@cosmology/proto-parser": "^2.1.0",
|
|
95
|
+
"@cosmology/types": "^2.1.0",
|
|
96
|
+
"@cosmology/utils": "^2.1.0",
|
|
97
97
|
"@types/parse-package-name": "0.1.0",
|
|
98
98
|
"case": "1.6.3",
|
|
99
99
|
"dargs": "7.0.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"rimraf": "5.0.0",
|
|
111
111
|
"yaml": "^2.3.4"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "405b79c604bfa4abbad4ab47ebfa28c70e2740aa"
|
|
114
114
|
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.plugin = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const ast_1 = require("@cosmology/ast");
|
|
6
|
-
const case_1 = require("case");
|
|
7
|
-
const utils_1 = require("@cosmology/utils");
|
|
8
|
-
const imports_1 = require("../imports");
|
|
9
|
-
const files_1 = require("../utils/files");
|
|
10
|
-
const plugin = (builder, allRegistries, allConverters) => {
|
|
11
|
-
builder.options.rpcClients.combinedClient.map((currentClient) => {
|
|
12
|
-
if (!allRegistries || !allRegistries.length) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const registryImports = [];
|
|
16
|
-
const converterImports = [];
|
|
17
|
-
const clientFile = currentClient.fileName;
|
|
18
|
-
const ctxRef = {
|
|
19
|
-
absolute: '/',
|
|
20
|
-
filename: '/',
|
|
21
|
-
proto: {
|
|
22
|
-
imports: [],
|
|
23
|
-
package: currentClient.name,
|
|
24
|
-
root: {},
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const ctx = new ast_1.GenericParseContext(ctxRef, null, builder.options);
|
|
28
|
-
const registryVariables = [];
|
|
29
|
-
const converterVariables = [];
|
|
30
|
-
const filteredRegistries = allRegistries.filter(item => (0, utils_1.isPackageIncluded)(item.package, currentClient.include.patterns));
|
|
31
|
-
filteredRegistries.forEach(registry => {
|
|
32
|
-
let rel = (0, path_1.relative)((0, path_1.dirname)(clientFile), registry.localname);
|
|
33
|
-
if (!rel.startsWith('.'))
|
|
34
|
-
rel = `./${rel}`;
|
|
35
|
-
rel = (0, utils_1.toPosixPath)(rel);
|
|
36
|
-
const variable = (0, utils_1.variableSlug)(registry.localname);
|
|
37
|
-
registryVariables.push(variable);
|
|
38
|
-
registryImports.push((0, ast_1.importNamespace)(variable, rel));
|
|
39
|
-
});
|
|
40
|
-
const filteredConverters = allConverters.filter(item => (0, utils_1.isPackageIncluded)(item.package, currentClient.include.patterns));
|
|
41
|
-
filteredConverters.forEach(converter => {
|
|
42
|
-
let rel = (0, path_1.relative)((0, path_1.dirname)(clientFile), converter.localname);
|
|
43
|
-
if (!rel.startsWith('.'))
|
|
44
|
-
rel = `./${rel}`;
|
|
45
|
-
rel = (0, utils_1.toPosixPath)(rel);
|
|
46
|
-
const variable = (0, utils_1.variableSlug)(converter.localname);
|
|
47
|
-
converterVariables.push(variable);
|
|
48
|
-
converterImports.push((0, ast_1.importNamespace)(variable, rel));
|
|
49
|
-
});
|
|
50
|
-
const name = 'get' + (0, case_1.pascal)(currentClient.name + 'SigningClient');
|
|
51
|
-
const txRpcName = 'get' + (0, case_1.pascal)(currentClient.name + 'SigningTxRpc');
|
|
52
|
-
const prefix = (0, case_1.camel)(currentClient.name);
|
|
53
|
-
const aminos = (0, ast_1.createStargateClientAminoRegistry)({
|
|
54
|
-
context: ctx,
|
|
55
|
-
aminos: converterVariables,
|
|
56
|
-
aminoConverters: prefix + 'AminoConverters'
|
|
57
|
-
});
|
|
58
|
-
const protos = (0, ast_1.createStargateClientProtoRegistry)({
|
|
59
|
-
context: ctx,
|
|
60
|
-
registries: registryVariables,
|
|
61
|
-
protoTypeRegistry: prefix + 'ProtoRegistry'
|
|
62
|
-
});
|
|
63
|
-
const clientOptions = (0, ast_1.createStargateClientOptions)({
|
|
64
|
-
context: ctx,
|
|
65
|
-
name: name + 'Options',
|
|
66
|
-
protoTypeRegistry: prefix + 'ProtoRegistry',
|
|
67
|
-
aminoConverters: prefix + 'AminoConverters'
|
|
68
|
-
});
|
|
69
|
-
const clientBody = (0, ast_1.createStargateClient)({
|
|
70
|
-
context: ctx,
|
|
71
|
-
name,
|
|
72
|
-
options: name + 'Options',
|
|
73
|
-
});
|
|
74
|
-
let getTxRpc;
|
|
75
|
-
if (ctx.pluginValue("stargateClients.addGetTxRpc")) {
|
|
76
|
-
getTxRpc = (0, ast_1.createGetTxRpc)(ctx, txRpcName, name);
|
|
77
|
-
}
|
|
78
|
-
const imports = (0, imports_1.buildAllImportsFromGenericContext)(ctx, clientFile);
|
|
79
|
-
let importDecls = [...imports, ...registryImports, ...converterImports];
|
|
80
|
-
importDecls = (0, utils_1.duplicateImportPathsWithExt)(importDecls, builder.options.restoreImportExtension);
|
|
81
|
-
let cProg = importDecls
|
|
82
|
-
.concat(aminos)
|
|
83
|
-
.concat(protos)
|
|
84
|
-
.concat(clientOptions)
|
|
85
|
-
.concat(clientBody);
|
|
86
|
-
// replace all backslash path for windows
|
|
87
|
-
for (let i = 0; i < cProg.length; i++) {
|
|
88
|
-
if (cProg[i].source?.value) {
|
|
89
|
-
cProg[i].source.value = (0, utils_1.toPosixPath)(cProg[i].source?.value);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (getTxRpc) {
|
|
93
|
-
cProg = cProg.concat(getTxRpc);
|
|
94
|
-
}
|
|
95
|
-
const clientOutFile = (0, path_1.join)(builder.outPath, clientFile);
|
|
96
|
-
(0, files_1.writeAstToFile)(builder.outPath, builder.options, cProg, clientOutFile);
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
exports.plugin = plugin;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generatedType = void 0;
|
|
4
|
-
exports.generatedType = `import { BinaryReader, BinaryWriter } from "../../../binary";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A type generated by Telescope 1.0.
|
|
8
|
-
*/
|
|
9
|
-
export interface TelescopeGeneratedType {
|
|
10
|
-
readonly typeUrl: string;
|
|
11
|
-
readonly encode: (
|
|
12
|
-
message:
|
|
13
|
-
| any
|
|
14
|
-
| {
|
|
15
|
-
[k: string]: any;
|
|
16
|
-
},
|
|
17
|
-
writer?: BinaryWriter
|
|
18
|
-
) => BinaryWriter;
|
|
19
|
-
readonly decode: (input: BinaryReader | Uint8Array, length?: number) => any;
|
|
20
|
-
readonly fromPartial: (object: any) => any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type GeneratedType = TelescopeGeneratedType;
|
|
24
|
-
`;
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.internalForBigInt = void 0;
|
|
4
|
-
exports.internalForBigInt = `
|
|
5
|
-
declare var self: any | undefined;
|
|
6
|
-
declare var window: any | undefined;
|
|
7
|
-
declare var global: any | undefined;
|
|
8
|
-
var globalThis: any = (() => {
|
|
9
|
-
if (typeof globalThis !== 'undefined') return globalThis;
|
|
10
|
-
if (typeof self !== 'undefined') return self;
|
|
11
|
-
if (typeof window !== 'undefined') return window;
|
|
12
|
-
if (typeof global !== 'undefined') return global;
|
|
13
|
-
throw 'Unable to locate global object';
|
|
14
|
-
})();
|
|
15
|
-
|
|
16
|
-
const atob: (b64: string) => string =
|
|
17
|
-
globalThis.atob ||
|
|
18
|
-
((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
|
|
19
|
-
|
|
20
|
-
export function bytesFromBase64(b64: string): Uint8Array {
|
|
21
|
-
const bin = atob(b64);
|
|
22
|
-
const arr = new Uint8Array(bin.length);
|
|
23
|
-
for (let i = 0; i < bin.length; ++i) {
|
|
24
|
-
arr[i] = bin.charCodeAt(i);
|
|
25
|
-
}
|
|
26
|
-
return arr;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const btoa: (bin: string) => string =
|
|
30
|
-
globalThis.btoa ||
|
|
31
|
-
((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
|
|
32
|
-
|
|
33
|
-
export function base64FromBytes(arr: Uint8Array): string {
|
|
34
|
-
const bin: string[] = [];
|
|
35
|
-
arr.forEach((byte) => {
|
|
36
|
-
bin.push(String.fromCharCode(byte));
|
|
37
|
-
});
|
|
38
|
-
return btoa(bin.join(''));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface AminoHeight {
|
|
42
|
-
readonly revision_number?: string;
|
|
43
|
-
readonly revision_height?: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function omitDefault<T extends string | number | bigint>(
|
|
47
|
-
input: T
|
|
48
|
-
): T | undefined {
|
|
49
|
-
if (typeof input === 'string') {
|
|
50
|
-
return input === '' ? undefined : input;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (typeof input === 'number') {
|
|
54
|
-
return input === 0 ? undefined : input;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (typeof input === 'bigint') {
|
|
58
|
-
return input === BigInt(0) ? undefined : input;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
throw new Error(\`Got unsupported type \${typeof input}\`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
interface Duration {
|
|
65
|
-
/**
|
|
66
|
-
* Signed seconds of the span of time. Must be from -315,576,000,000
|
|
67
|
-
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
|
68
|
-
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
|
69
|
-
*/
|
|
70
|
-
seconds: bigint;
|
|
71
|
-
/**
|
|
72
|
-
* Signed fractions of a second at nanosecond resolution of the span
|
|
73
|
-
* of time. Durations less than one second are represented with a 0
|
|
74
|
-
* \`seconds\` field and a positive or negative \`nanos\` field. For durations
|
|
75
|
-
* of one second or more, a non-zero value for the \`nanos\` field must be
|
|
76
|
-
* of the same sign as the \`seconds\` field. Must be from -999,999,999
|
|
77
|
-
* to +999,999,999 inclusive.
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
nanos: number;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function toDuration(duration: string): Duration {
|
|
84
|
-
return {
|
|
85
|
-
seconds: BigInt(Math.floor(parseInt(duration) / 1000000000)),
|
|
86
|
-
nanos: parseInt(duration) % 1000000000
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function fromDuration(duration: Duration): string {
|
|
91
|
-
return (
|
|
92
|
-
parseInt(duration.seconds.toString()) * 1000000000 +
|
|
93
|
-
duration.nanos
|
|
94
|
-
).toString();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function isSet(value: any): boolean {
|
|
98
|
-
return value !== null && value !== undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function isObject(value: any): boolean {
|
|
102
|
-
return typeof value === 'object' && value !== null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface PageRequest {
|
|
106
|
-
key: Uint8Array;
|
|
107
|
-
offset: bigint;
|
|
108
|
-
limit: bigint;
|
|
109
|
-
countTotal: boolean;
|
|
110
|
-
reverse: boolean;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface PageRequestParams {
|
|
114
|
-
'pagination.key'?: string;
|
|
115
|
-
'pagination.offset'?: string;
|
|
116
|
-
'pagination.limit'?: string;
|
|
117
|
-
'pagination.count_total'?: boolean;
|
|
118
|
-
'pagination.reverse'?: boolean;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface Params {
|
|
122
|
-
params: PageRequestParams;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export const setPaginationParams = (
|
|
126
|
-
options: Params,
|
|
127
|
-
pagination?: PageRequest
|
|
128
|
-
) => {
|
|
129
|
-
if (!pagination) {
|
|
130
|
-
return options;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (typeof pagination?.countTotal !== 'undefined') {
|
|
134
|
-
options.params['pagination.count_total'] = pagination.countTotal;
|
|
135
|
-
}
|
|
136
|
-
if (typeof pagination?.key !== 'undefined') {
|
|
137
|
-
// String to Uint8Array
|
|
138
|
-
// let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
|
|
139
|
-
|
|
140
|
-
// Uint8Array to String
|
|
141
|
-
options.params['pagination.key'] = Buffer.from(pagination.key).toString(
|
|
142
|
-
'base64'
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
if (typeof pagination?.limit !== 'undefined') {
|
|
146
|
-
options.params['pagination.limit'] = pagination.limit.toString();
|
|
147
|
-
}
|
|
148
|
-
if (typeof pagination?.offset !== 'undefined') {
|
|
149
|
-
options.params['pagination.offset'] = pagination.offset.toString();
|
|
150
|
-
}
|
|
151
|
-
if (typeof pagination?.reverse !== 'undefined') {
|
|
152
|
-
options.params['pagination.reverse'] = pagination.reverse;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return options;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
type Builtin =
|
|
159
|
-
| Date
|
|
160
|
-
| Function
|
|
161
|
-
| Uint8Array
|
|
162
|
-
| string
|
|
163
|
-
| number
|
|
164
|
-
| bigint
|
|
165
|
-
| boolean
|
|
166
|
-
| undefined;
|
|
167
|
-
|
|
168
|
-
export type DeepPartial<T> = T extends Builtin
|
|
169
|
-
? T
|
|
170
|
-
: T extends Array<infer U>
|
|
171
|
-
? Array<DeepPartial<U>>
|
|
172
|
-
: T extends ReadonlyArray<infer U>
|
|
173
|
-
? ReadonlyArray<DeepPartial<U>>
|
|
174
|
-
: T extends {}
|
|
175
|
-
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
176
|
-
: Partial<T>;
|
|
177
|
-
|
|
178
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
179
|
-
export type Exact<P, I extends P> = P extends Builtin
|
|
180
|
-
? P
|
|
181
|
-
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
|
|
182
|
-
Exclude<keyof I, KeysOfUnion<P>>,
|
|
183
|
-
never
|
|
184
|
-
>;
|
|
185
|
-
|
|
186
|
-
export interface Rpc {
|
|
187
|
-
request(
|
|
188
|
-
service: string,
|
|
189
|
-
method: string,
|
|
190
|
-
data: Uint8Array
|
|
191
|
-
): Promise<Uint8Array>;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
interface Timestamp {
|
|
195
|
-
/**
|
|
196
|
-
* Represents seconds of UTC time since Unix epoch
|
|
197
|
-
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
198
|
-
* 9999-12-31T23:59:59Z inclusive.
|
|
199
|
-
*/
|
|
200
|
-
seconds: bigint;
|
|
201
|
-
/**
|
|
202
|
-
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
203
|
-
* second values with fractions must still have non-negative nanos values
|
|
204
|
-
* that count forward in time. Must be from 0 to 999,999,999
|
|
205
|
-
* inclusive.
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
nanos: number;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export function toTimestamp(date: Date): Timestamp {
|
|
212
|
-
const seconds = numberToLong(date.getTime() / 1_000);
|
|
213
|
-
const nanos = (date.getTime() % 1000) * 1000000;
|
|
214
|
-
return {
|
|
215
|
-
seconds,
|
|
216
|
-
nanos
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export function fromTimestamp(t: Timestamp): Date {
|
|
221
|
-
let millis = Number(t.seconds) * 1000;
|
|
222
|
-
millis += t.nanos / 1000000;
|
|
223
|
-
return new Date(millis);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const timestampFromJSON = (object: any): Timestamp => {
|
|
227
|
-
return {
|
|
228
|
-
seconds: isSet(object.seconds)
|
|
229
|
-
? BigInt(object.seconds.toString())
|
|
230
|
-
: BigInt(0),
|
|
231
|
-
nanos: isSet(object.nanos) ? Number(object.nanos) : 0
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
export function fromJsonTimestamp(o: any): Timestamp {
|
|
236
|
-
if (o instanceof Date) {
|
|
237
|
-
return toTimestamp(o);
|
|
238
|
-
} else if (typeof o === 'string') {
|
|
239
|
-
return toTimestamp(new Date(o));
|
|
240
|
-
} else {
|
|
241
|
-
return timestampFromJSON(o);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function numberToLong(number: number) {
|
|
246
|
-
return BigInt(Math.trunc(number));
|
|
247
|
-
}
|
|
248
|
-
`;
|
package/main/helpers/types.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.types = void 0;
|
|
4
|
-
exports.types = `import { BinaryReader, BinaryWriter } from "../../../binary";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A type generated by Telescope 1.0.
|
|
8
|
-
*/
|
|
9
|
-
export interface TelescopeGeneratedType {
|
|
10
|
-
readonly typeUrl: string;
|
|
11
|
-
readonly encode: (
|
|
12
|
-
message:
|
|
13
|
-
| any
|
|
14
|
-
| {
|
|
15
|
-
[k: string]: any;
|
|
16
|
-
},
|
|
17
|
-
writer?: BinaryWriter
|
|
18
|
-
) => BinaryWriter;
|
|
19
|
-
readonly decode: (input: BinaryReader | Uint8Array, length?: number) => any;
|
|
20
|
-
readonly fromPartial: (object: any) => any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type GeneratedType = TelescopeGeneratedType;
|
|
24
|
-
`;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVueQueryHelper = void 0;
|
|
4
|
-
const getVueQueryHelper = (options) => {
|
|
5
|
-
return `import { getRpcClient } from './extern${options.restoreImportExtension ?? ""}'
|
|
6
|
-
import {
|
|
7
|
-
useQuery,
|
|
8
|
-
UseQueryOptions,
|
|
9
|
-
} from '@tanstack/vue-query';
|
|
10
|
-
import { Ref, isRef } from 'vue'
|
|
11
|
-
|
|
12
|
-
import { HttpEndpoint, ProtobufRpcClient } from '@cosmjs/stargate';
|
|
13
|
-
${options.rpcClients.useConnectComet
|
|
14
|
-
? "import { CometClient, connectComet, Tendermint34Client, Tendermint37Client } from '@cosmjs/tendermint-rpc';"
|
|
15
|
-
: "import { Tendermint34Client } from '@cosmjs/tendermint-rpc';"}
|
|
16
|
-
|
|
17
|
-
export interface VueQueryParams<TResponse, TData = TResponse> {
|
|
18
|
-
options?: Omit<UseQueryOptions<TData, Error, TData>, 'queryKey'>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface UseRpcClientQuery<TData> extends VueQueryParams<ProtobufRpcClient, TData> {
|
|
22
|
-
rpcEndpoint: Ref<string | HttpEndpoint>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface UseRpcEndpointQuery<TData> extends VueQueryParams<string | HttpEndpoint, TData> {
|
|
26
|
-
getter: () => Promise<string | HttpEndpoint>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const useRpcEndpoint = <TData = string | HttpEndpoint>({
|
|
30
|
-
getter,
|
|
31
|
-
options,
|
|
32
|
-
}: UseRpcEndpointQuery<TData>) => {
|
|
33
|
-
return useQuery<string | HttpEndpoint, Error, TData>({
|
|
34
|
-
queryKey: ['rpcEndpoint', getter],
|
|
35
|
-
queryFn: async () => {
|
|
36
|
-
return await getter();
|
|
37
|
-
},
|
|
38
|
-
...options
|
|
39
|
-
})
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const useRpcClient = <TData = ProtobufRpcClient>({
|
|
43
|
-
rpcEndpoint,
|
|
44
|
-
options,
|
|
45
|
-
}: UseRpcClientQuery<TData>) => {
|
|
46
|
-
let params = {
|
|
47
|
-
queryKey: ['rpcClient', rpcEndpoint],
|
|
48
|
-
queryFn: async () => {
|
|
49
|
-
return await getRpcClient(rpcEndpoint.value);
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
if (options && !isRef(options)) {
|
|
53
|
-
params = {
|
|
54
|
-
...options,
|
|
55
|
-
...params,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return useQuery<ProtobufRpcClient | undefined, Error, TData>(params);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
${options.rpcClients.useConnectComet
|
|
62
|
-
? "interface UseTendermintClient extends VueQueryParams<Tendermint34Client | Tendermint37Client | CometClient> {"
|
|
63
|
-
: "interface UseTendermintClient extends VueQueryParams<Tendermint34Client> {"}
|
|
64
|
-
rpcEndpoint: Ref<string | HttpEndpoint>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Hook that uses vue-query to cache a connected tendermint client.
|
|
69
|
-
*/
|
|
70
|
-
export const useTendermintClient = ({
|
|
71
|
-
rpcEndpoint,
|
|
72
|
-
options,
|
|
73
|
-
}: UseTendermintClient) => {
|
|
74
|
-
${options.rpcClients.useConnectComet
|
|
75
|
-
? " const { data: client } = useQuery<Tendermint34Client | Tendermint37Client | CometClient, Error, Tendermint34Client | Tendermint37Client | CometClient>("
|
|
76
|
-
: " const { data: client } = useQuery<Tendermint34Client, Error, Tendermint34Client>({"}
|
|
77
|
-
queryKey: ['client', 'tendermint', rpcEndpoint],
|
|
78
|
-
queryFn: () => ${options.rpcClients.useConnectComet
|
|
79
|
-
? "connectComet(rpcEndpoint.value),"
|
|
80
|
-
: "Tendermint34Client.connect(rpcEndpoint.value),"}
|
|
81
|
-
// allow overriding
|
|
82
|
-
throwOnError: (e) => {
|
|
83
|
-
throw new Error(\`Failed to connect to \${rpcEndpoint}\` + '\\n' + e)
|
|
84
|
-
},
|
|
85
|
-
...options,
|
|
86
|
-
})
|
|
87
|
-
return { client }
|
|
88
|
-
};
|
|
89
|
-
`;
|
|
90
|
-
};
|
|
91
|
-
exports.getVueQueryHelper = getVueQueryHelper;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const recursive_1 = require("./recursive");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
async function run() {
|
|
7
|
-
const argv = process.argv.slice(2);
|
|
8
|
-
const gitRepoIndex = argv.findIndex((arg) => arg === "--git-repo");
|
|
9
|
-
if (gitRepoIndex === -1) {
|
|
10
|
-
process.stderr.write("`git-repo` is not specified");
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
13
|
-
const [owner, repo] = argv[gitRepoIndex + 1]?.split("/");
|
|
14
|
-
if (!owner || !repo) {
|
|
15
|
-
process.stderr.write("wrong `git-repo` format (i.e. <owner>/<repository>).");
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
const targetsIndex = argv.findIndex((arg) => arg === "--targets");
|
|
19
|
-
if (targetsIndex === -1) {
|
|
20
|
-
process.stdout.write("`targets` is not specified");
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
const targets = argv[targetsIndex + 1]?.split(",");
|
|
24
|
-
if (!targets || targets.length === 0) {
|
|
25
|
-
process.stderr.write("wrong `targets` format (i.e. <**/*.proto>,<**/*.proto>,<**/*.proto>).");
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
const outDirIndex = argv.findIndex((arg) => arg === "--out");
|
|
29
|
-
if (outDirIndex === -1) {
|
|
30
|
-
process.stdout.write("`out` is not specified, downloading to `proto` folder by default.\n");
|
|
31
|
-
}
|
|
32
|
-
const outDir = outDirIndex !== -1 ? argv[outDirIndex + 1] : "./proto";
|
|
33
|
-
const omitCloneIndex = argv.findIndex((arg) => arg === "--omit-clone");
|
|
34
|
-
let omitClone = false;
|
|
35
|
-
if (omitCloneIndex !== -1 && argv[omitCloneIndex + 1] === "true") {
|
|
36
|
-
omitClone = true;
|
|
37
|
-
}
|
|
38
|
-
if (omitCloneIndex !== -1 &&
|
|
39
|
-
typeof argv[omitCloneIndex + 1] === "undefined") {
|
|
40
|
-
omitClone = true;
|
|
41
|
-
}
|
|
42
|
-
(0, utils_1.removeFolder)("git-modules");
|
|
43
|
-
const result = await (0, recursive_1.clone)({
|
|
44
|
-
owner,
|
|
45
|
-
repo,
|
|
46
|
-
outDir: "./git-modules",
|
|
47
|
-
});
|
|
48
|
-
if (result) {
|
|
49
|
-
(0, utils_1.removeFolder)(outDir);
|
|
50
|
-
(0, recursive_1.extractProto)({
|
|
51
|
-
sources: result,
|
|
52
|
-
targets,
|
|
53
|
-
outDir,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
run();
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { join, dirname, relative } from 'path';
|
|
2
|
-
import { importNamespace, GenericParseContext, createStargateClient, createStargateClientOptions, createStargateClientProtoRegistry, createStargateClientAminoRegistry, createGetTxRpc } from '@cosmology/ast';
|
|
3
|
-
import { camel, pascal } from 'case';
|
|
4
|
-
import { duplicateImportPathsWithExt, variableSlug, toPosixPath, isPackageIncluded } from '@cosmology/utils';
|
|
5
|
-
import { buildAllImportsFromGenericContext } from '../imports';
|
|
6
|
-
import { writeAstToFile } from '../utils/files';
|
|
7
|
-
export const plugin = (builder, allRegistries, allConverters) => {
|
|
8
|
-
builder.options.rpcClients.combinedClient.map((currentClient) => {
|
|
9
|
-
if (!allRegistries || !allRegistries.length) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const registryImports = [];
|
|
13
|
-
const converterImports = [];
|
|
14
|
-
const clientFile = currentClient.fileName;
|
|
15
|
-
const ctxRef = {
|
|
16
|
-
absolute: '/',
|
|
17
|
-
filename: '/',
|
|
18
|
-
proto: {
|
|
19
|
-
imports: [],
|
|
20
|
-
package: currentClient.name,
|
|
21
|
-
root: {},
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const ctx = new GenericParseContext(ctxRef, null, builder.options);
|
|
25
|
-
const registryVariables = [];
|
|
26
|
-
const converterVariables = [];
|
|
27
|
-
const filteredRegistries = allRegistries.filter(item => isPackageIncluded(item.package, currentClient.include.patterns));
|
|
28
|
-
filteredRegistries.forEach(registry => {
|
|
29
|
-
let rel = relative(dirname(clientFile), registry.localname);
|
|
30
|
-
if (!rel.startsWith('.'))
|
|
31
|
-
rel = `./${rel}`;
|
|
32
|
-
rel = toPosixPath(rel);
|
|
33
|
-
const variable = variableSlug(registry.localname);
|
|
34
|
-
registryVariables.push(variable);
|
|
35
|
-
registryImports.push(importNamespace(variable, rel));
|
|
36
|
-
});
|
|
37
|
-
const filteredConverters = allConverters.filter(item => isPackageIncluded(item.package, currentClient.include.patterns));
|
|
38
|
-
filteredConverters.forEach(converter => {
|
|
39
|
-
let rel = relative(dirname(clientFile), converter.localname);
|
|
40
|
-
if (!rel.startsWith('.'))
|
|
41
|
-
rel = `./${rel}`;
|
|
42
|
-
rel = toPosixPath(rel);
|
|
43
|
-
const variable = variableSlug(converter.localname);
|
|
44
|
-
converterVariables.push(variable);
|
|
45
|
-
converterImports.push(importNamespace(variable, rel));
|
|
46
|
-
});
|
|
47
|
-
const name = 'get' + pascal(currentClient.name + 'SigningClient');
|
|
48
|
-
const txRpcName = 'get' + pascal(currentClient.name + 'SigningTxRpc');
|
|
49
|
-
const prefix = camel(currentClient.name);
|
|
50
|
-
const aminos = createStargateClientAminoRegistry({
|
|
51
|
-
context: ctx,
|
|
52
|
-
aminos: converterVariables,
|
|
53
|
-
aminoConverters: prefix + 'AminoConverters'
|
|
54
|
-
});
|
|
55
|
-
const protos = createStargateClientProtoRegistry({
|
|
56
|
-
context: ctx,
|
|
57
|
-
registries: registryVariables,
|
|
58
|
-
protoTypeRegistry: prefix + 'ProtoRegistry'
|
|
59
|
-
});
|
|
60
|
-
const clientOptions = createStargateClientOptions({
|
|
61
|
-
context: ctx,
|
|
62
|
-
name: name + 'Options',
|
|
63
|
-
protoTypeRegistry: prefix + 'ProtoRegistry',
|
|
64
|
-
aminoConverters: prefix + 'AminoConverters'
|
|
65
|
-
});
|
|
66
|
-
const clientBody = createStargateClient({
|
|
67
|
-
context: ctx,
|
|
68
|
-
name,
|
|
69
|
-
options: name + 'Options',
|
|
70
|
-
});
|
|
71
|
-
let getTxRpc;
|
|
72
|
-
if (ctx.pluginValue("stargateClients.addGetTxRpc")) {
|
|
73
|
-
getTxRpc = createGetTxRpc(ctx, txRpcName, name);
|
|
74
|
-
}
|
|
75
|
-
const imports = buildAllImportsFromGenericContext(ctx, clientFile);
|
|
76
|
-
let importDecls = [...imports, ...registryImports, ...converterImports];
|
|
77
|
-
importDecls = duplicateImportPathsWithExt(importDecls, builder.options.restoreImportExtension);
|
|
78
|
-
let cProg = importDecls
|
|
79
|
-
.concat(aminos)
|
|
80
|
-
.concat(protos)
|
|
81
|
-
.concat(clientOptions)
|
|
82
|
-
.concat(clientBody);
|
|
83
|
-
// replace all backslash path for windows
|
|
84
|
-
for (let i = 0; i < cProg.length; i++) {
|
|
85
|
-
if (cProg[i].source?.value) {
|
|
86
|
-
cProg[i].source.value = toPosixPath(cProg[i].source?.value);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (getTxRpc) {
|
|
90
|
-
cProg = cProg.concat(getTxRpc);
|
|
91
|
-
}
|
|
92
|
-
const clientOutFile = join(builder.outPath, clientFile);
|
|
93
|
-
writeAstToFile(builder.outPath, builder.options, cProg, clientOutFile);
|
|
94
|
-
});
|
|
95
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const generatedType = `import { BinaryReader, BinaryWriter } from "../../../binary";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A type generated by Telescope 1.0.
|
|
5
|
-
*/
|
|
6
|
-
export interface TelescopeGeneratedType {
|
|
7
|
-
readonly typeUrl: string;
|
|
8
|
-
readonly encode: (
|
|
9
|
-
message:
|
|
10
|
-
| any
|
|
11
|
-
| {
|
|
12
|
-
[k: string]: any;
|
|
13
|
-
},
|
|
14
|
-
writer?: BinaryWriter
|
|
15
|
-
) => BinaryWriter;
|
|
16
|
-
readonly decode: (input: BinaryReader | Uint8Array, length?: number) => any;
|
|
17
|
-
readonly fromPartial: (object: any) => any;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type GeneratedType = TelescopeGeneratedType;
|
|
21
|
-
`;
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
export const internalForBigInt = `
|
|
2
|
-
declare var self: any | undefined;
|
|
3
|
-
declare var window: any | undefined;
|
|
4
|
-
declare var global: any | undefined;
|
|
5
|
-
var globalThis: any = (() => {
|
|
6
|
-
if (typeof globalThis !== 'undefined') return globalThis;
|
|
7
|
-
if (typeof self !== 'undefined') return self;
|
|
8
|
-
if (typeof window !== 'undefined') return window;
|
|
9
|
-
if (typeof global !== 'undefined') return global;
|
|
10
|
-
throw 'Unable to locate global object';
|
|
11
|
-
})();
|
|
12
|
-
|
|
13
|
-
const atob: (b64: string) => string =
|
|
14
|
-
globalThis.atob ||
|
|
15
|
-
((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
|
|
16
|
-
|
|
17
|
-
export function bytesFromBase64(b64: string): Uint8Array {
|
|
18
|
-
const bin = atob(b64);
|
|
19
|
-
const arr = new Uint8Array(bin.length);
|
|
20
|
-
for (let i = 0; i < bin.length; ++i) {
|
|
21
|
-
arr[i] = bin.charCodeAt(i);
|
|
22
|
-
}
|
|
23
|
-
return arr;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const btoa: (bin: string) => string =
|
|
27
|
-
globalThis.btoa ||
|
|
28
|
-
((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
|
|
29
|
-
|
|
30
|
-
export function base64FromBytes(arr: Uint8Array): string {
|
|
31
|
-
const bin: string[] = [];
|
|
32
|
-
arr.forEach((byte) => {
|
|
33
|
-
bin.push(String.fromCharCode(byte));
|
|
34
|
-
});
|
|
35
|
-
return btoa(bin.join(''));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface AminoHeight {
|
|
39
|
-
readonly revision_number?: string;
|
|
40
|
-
readonly revision_height?: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function omitDefault<T extends string | number | bigint>(
|
|
44
|
-
input: T
|
|
45
|
-
): T | undefined {
|
|
46
|
-
if (typeof input === 'string') {
|
|
47
|
-
return input === '' ? undefined : input;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (typeof input === 'number') {
|
|
51
|
-
return input === 0 ? undefined : input;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (typeof input === 'bigint') {
|
|
55
|
-
return input === BigInt(0) ? undefined : input;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
throw new Error(\`Got unsupported type \${typeof input}\`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface Duration {
|
|
62
|
-
/**
|
|
63
|
-
* Signed seconds of the span of time. Must be from -315,576,000,000
|
|
64
|
-
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
|
65
|
-
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
|
66
|
-
*/
|
|
67
|
-
seconds: bigint;
|
|
68
|
-
/**
|
|
69
|
-
* Signed fractions of a second at nanosecond resolution of the span
|
|
70
|
-
* of time. Durations less than one second are represented with a 0
|
|
71
|
-
* \`seconds\` field and a positive or negative \`nanos\` field. For durations
|
|
72
|
-
* of one second or more, a non-zero value for the \`nanos\` field must be
|
|
73
|
-
* of the same sign as the \`seconds\` field. Must be from -999,999,999
|
|
74
|
-
* to +999,999,999 inclusive.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
nanos: number;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function toDuration(duration: string): Duration {
|
|
81
|
-
return {
|
|
82
|
-
seconds: BigInt(Math.floor(parseInt(duration) / 1000000000)),
|
|
83
|
-
nanos: parseInt(duration) % 1000000000
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function fromDuration(duration: Duration): string {
|
|
88
|
-
return (
|
|
89
|
-
parseInt(duration.seconds.toString()) * 1000000000 +
|
|
90
|
-
duration.nanos
|
|
91
|
-
).toString();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function isSet(value: any): boolean {
|
|
95
|
-
return value !== null && value !== undefined;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function isObject(value: any): boolean {
|
|
99
|
-
return typeof value === 'object' && value !== null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface PageRequest {
|
|
103
|
-
key: Uint8Array;
|
|
104
|
-
offset: bigint;
|
|
105
|
-
limit: bigint;
|
|
106
|
-
countTotal: boolean;
|
|
107
|
-
reverse: boolean;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface PageRequestParams {
|
|
111
|
-
'pagination.key'?: string;
|
|
112
|
-
'pagination.offset'?: string;
|
|
113
|
-
'pagination.limit'?: string;
|
|
114
|
-
'pagination.count_total'?: boolean;
|
|
115
|
-
'pagination.reverse'?: boolean;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface Params {
|
|
119
|
-
params: PageRequestParams;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export const setPaginationParams = (
|
|
123
|
-
options: Params,
|
|
124
|
-
pagination?: PageRequest
|
|
125
|
-
) => {
|
|
126
|
-
if (!pagination) {
|
|
127
|
-
return options;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (typeof pagination?.countTotal !== 'undefined') {
|
|
131
|
-
options.params['pagination.count_total'] = pagination.countTotal;
|
|
132
|
-
}
|
|
133
|
-
if (typeof pagination?.key !== 'undefined') {
|
|
134
|
-
// String to Uint8Array
|
|
135
|
-
// let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
|
|
136
|
-
|
|
137
|
-
// Uint8Array to String
|
|
138
|
-
options.params['pagination.key'] = Buffer.from(pagination.key).toString(
|
|
139
|
-
'base64'
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
if (typeof pagination?.limit !== 'undefined') {
|
|
143
|
-
options.params['pagination.limit'] = pagination.limit.toString();
|
|
144
|
-
}
|
|
145
|
-
if (typeof pagination?.offset !== 'undefined') {
|
|
146
|
-
options.params['pagination.offset'] = pagination.offset.toString();
|
|
147
|
-
}
|
|
148
|
-
if (typeof pagination?.reverse !== 'undefined') {
|
|
149
|
-
options.params['pagination.reverse'] = pagination.reverse;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return options;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
type Builtin =
|
|
156
|
-
| Date
|
|
157
|
-
| Function
|
|
158
|
-
| Uint8Array
|
|
159
|
-
| string
|
|
160
|
-
| number
|
|
161
|
-
| bigint
|
|
162
|
-
| boolean
|
|
163
|
-
| undefined;
|
|
164
|
-
|
|
165
|
-
export type DeepPartial<T> = T extends Builtin
|
|
166
|
-
? T
|
|
167
|
-
: T extends Array<infer U>
|
|
168
|
-
? Array<DeepPartial<U>>
|
|
169
|
-
: T extends ReadonlyArray<infer U>
|
|
170
|
-
? ReadonlyArray<DeepPartial<U>>
|
|
171
|
-
: T extends {}
|
|
172
|
-
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
173
|
-
: Partial<T>;
|
|
174
|
-
|
|
175
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
176
|
-
export type Exact<P, I extends P> = P extends Builtin
|
|
177
|
-
? P
|
|
178
|
-
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
|
|
179
|
-
Exclude<keyof I, KeysOfUnion<P>>,
|
|
180
|
-
never
|
|
181
|
-
>;
|
|
182
|
-
|
|
183
|
-
export interface Rpc {
|
|
184
|
-
request(
|
|
185
|
-
service: string,
|
|
186
|
-
method: string,
|
|
187
|
-
data: Uint8Array
|
|
188
|
-
): Promise<Uint8Array>;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
interface Timestamp {
|
|
192
|
-
/**
|
|
193
|
-
* Represents seconds of UTC time since Unix epoch
|
|
194
|
-
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
195
|
-
* 9999-12-31T23:59:59Z inclusive.
|
|
196
|
-
*/
|
|
197
|
-
seconds: bigint;
|
|
198
|
-
/**
|
|
199
|
-
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
200
|
-
* second values with fractions must still have non-negative nanos values
|
|
201
|
-
* that count forward in time. Must be from 0 to 999,999,999
|
|
202
|
-
* inclusive.
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
|
-
nanos: number;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export function toTimestamp(date: Date): Timestamp {
|
|
209
|
-
const seconds = numberToLong(date.getTime() / 1_000);
|
|
210
|
-
const nanos = (date.getTime() % 1000) * 1000000;
|
|
211
|
-
return {
|
|
212
|
-
seconds,
|
|
213
|
-
nanos
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export function fromTimestamp(t: Timestamp): Date {
|
|
218
|
-
let millis = Number(t.seconds) * 1000;
|
|
219
|
-
millis += t.nanos / 1000000;
|
|
220
|
-
return new Date(millis);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const timestampFromJSON = (object: any): Timestamp => {
|
|
224
|
-
return {
|
|
225
|
-
seconds: isSet(object.seconds)
|
|
226
|
-
? BigInt(object.seconds.toString())
|
|
227
|
-
: BigInt(0),
|
|
228
|
-
nanos: isSet(object.nanos) ? Number(object.nanos) : 0
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
export function fromJsonTimestamp(o: any): Timestamp {
|
|
233
|
-
if (o instanceof Date) {
|
|
234
|
-
return toTimestamp(o);
|
|
235
|
-
} else if (typeof o === 'string') {
|
|
236
|
-
return toTimestamp(new Date(o));
|
|
237
|
-
} else {
|
|
238
|
-
return timestampFromJSON(o);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function numberToLong(number: number) {
|
|
243
|
-
return BigInt(Math.trunc(number));
|
|
244
|
-
}
|
|
245
|
-
`;
|
package/module/helpers/types.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const types = `import { BinaryReader, BinaryWriter } from "../../../binary";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A type generated by Telescope 1.0.
|
|
5
|
-
*/
|
|
6
|
-
export interface TelescopeGeneratedType {
|
|
7
|
-
readonly typeUrl: string;
|
|
8
|
-
readonly encode: (
|
|
9
|
-
message:
|
|
10
|
-
| any
|
|
11
|
-
| {
|
|
12
|
-
[k: string]: any;
|
|
13
|
-
},
|
|
14
|
-
writer?: BinaryWriter
|
|
15
|
-
) => BinaryWriter;
|
|
16
|
-
readonly decode: (input: BinaryReader | Uint8Array, length?: number) => any;
|
|
17
|
-
readonly fromPartial: (object: any) => any;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type GeneratedType = TelescopeGeneratedType;
|
|
21
|
-
`;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
export const getVueQueryHelper = (options) => {
|
|
2
|
-
return `import { getRpcClient } from './extern${options.restoreImportExtension ?? ""}'
|
|
3
|
-
import {
|
|
4
|
-
useQuery,
|
|
5
|
-
UseQueryOptions,
|
|
6
|
-
} from '@tanstack/vue-query';
|
|
7
|
-
import { Ref, isRef } from 'vue'
|
|
8
|
-
|
|
9
|
-
import { HttpEndpoint, ProtobufRpcClient } from '@cosmjs/stargate';
|
|
10
|
-
${options.rpcClients.useConnectComet
|
|
11
|
-
? "import { CometClient, connectComet, Tendermint34Client, Tendermint37Client } from '@cosmjs/tendermint-rpc';"
|
|
12
|
-
: "import { Tendermint34Client } from '@cosmjs/tendermint-rpc';"}
|
|
13
|
-
|
|
14
|
-
export interface VueQueryParams<TResponse, TData = TResponse> {
|
|
15
|
-
options?: Omit<UseQueryOptions<TData, Error, TData>, 'queryKey'>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface UseRpcClientQuery<TData> extends VueQueryParams<ProtobufRpcClient, TData> {
|
|
19
|
-
rpcEndpoint: Ref<string | HttpEndpoint>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface UseRpcEndpointQuery<TData> extends VueQueryParams<string | HttpEndpoint, TData> {
|
|
23
|
-
getter: () => Promise<string | HttpEndpoint>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const useRpcEndpoint = <TData = string | HttpEndpoint>({
|
|
27
|
-
getter,
|
|
28
|
-
options,
|
|
29
|
-
}: UseRpcEndpointQuery<TData>) => {
|
|
30
|
-
return useQuery<string | HttpEndpoint, Error, TData>({
|
|
31
|
-
queryKey: ['rpcEndpoint', getter],
|
|
32
|
-
queryFn: async () => {
|
|
33
|
-
return await getter();
|
|
34
|
-
},
|
|
35
|
-
...options
|
|
36
|
-
})
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const useRpcClient = <TData = ProtobufRpcClient>({
|
|
40
|
-
rpcEndpoint,
|
|
41
|
-
options,
|
|
42
|
-
}: UseRpcClientQuery<TData>) => {
|
|
43
|
-
let params = {
|
|
44
|
-
queryKey: ['rpcClient', rpcEndpoint],
|
|
45
|
-
queryFn: async () => {
|
|
46
|
-
return await getRpcClient(rpcEndpoint.value);
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
if (options && !isRef(options)) {
|
|
50
|
-
params = {
|
|
51
|
-
...options,
|
|
52
|
-
...params,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return useQuery<ProtobufRpcClient | undefined, Error, TData>(params);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
${options.rpcClients.useConnectComet
|
|
59
|
-
? "interface UseTendermintClient extends VueQueryParams<Tendermint34Client | Tendermint37Client | CometClient> {"
|
|
60
|
-
: "interface UseTendermintClient extends VueQueryParams<Tendermint34Client> {"}
|
|
61
|
-
rpcEndpoint: Ref<string | HttpEndpoint>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Hook that uses vue-query to cache a connected tendermint client.
|
|
66
|
-
*/
|
|
67
|
-
export const useTendermintClient = ({
|
|
68
|
-
rpcEndpoint,
|
|
69
|
-
options,
|
|
70
|
-
}: UseTendermintClient) => {
|
|
71
|
-
${options.rpcClients.useConnectComet
|
|
72
|
-
? " const { data: client } = useQuery<Tendermint34Client | Tendermint37Client | CometClient, Error, Tendermint34Client | Tendermint37Client | CometClient>("
|
|
73
|
-
: " const { data: client } = useQuery<Tendermint34Client, Error, Tendermint34Client>({"}
|
|
74
|
-
queryKey: ['client', 'tendermint', rpcEndpoint],
|
|
75
|
-
queryFn: () => ${options.rpcClients.useConnectComet
|
|
76
|
-
? "connectComet(rpcEndpoint.value),"
|
|
77
|
-
: "Tendermint34Client.connect(rpcEndpoint.value),"}
|
|
78
|
-
// allow overriding
|
|
79
|
-
throwOnError: (e) => {
|
|
80
|
-
throw new Error(\`Failed to connect to \${rpcEndpoint}\` + '\\n' + e)
|
|
81
|
-
},
|
|
82
|
-
...options,
|
|
83
|
-
})
|
|
84
|
-
return { client }
|
|
85
|
-
};
|
|
86
|
-
`;
|
|
87
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { clone, extractProto } from "./recursive";
|
|
3
|
-
import { removeFolder } from "./utils";
|
|
4
|
-
async function run() {
|
|
5
|
-
const argv = process.argv.slice(2);
|
|
6
|
-
const gitRepoIndex = argv.findIndex((arg) => arg === "--git-repo");
|
|
7
|
-
if (gitRepoIndex === -1) {
|
|
8
|
-
process.stderr.write("`git-repo` is not specified");
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
11
|
-
const [owner, repo] = argv[gitRepoIndex + 1]?.split("/");
|
|
12
|
-
if (!owner || !repo) {
|
|
13
|
-
process.stderr.write("wrong `git-repo` format (i.e. <owner>/<repository>).");
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
const targetsIndex = argv.findIndex((arg) => arg === "--targets");
|
|
17
|
-
if (targetsIndex === -1) {
|
|
18
|
-
process.stdout.write("`targets` is not specified");
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
const targets = argv[targetsIndex + 1]?.split(",");
|
|
22
|
-
if (!targets || targets.length === 0) {
|
|
23
|
-
process.stderr.write("wrong `targets` format (i.e. <**/*.proto>,<**/*.proto>,<**/*.proto>).");
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
const outDirIndex = argv.findIndex((arg) => arg === "--out");
|
|
27
|
-
if (outDirIndex === -1) {
|
|
28
|
-
process.stdout.write("`out` is not specified, downloading to `proto` folder by default.\n");
|
|
29
|
-
}
|
|
30
|
-
const outDir = outDirIndex !== -1 ? argv[outDirIndex + 1] : "./proto";
|
|
31
|
-
const omitCloneIndex = argv.findIndex((arg) => arg === "--omit-clone");
|
|
32
|
-
let omitClone = false;
|
|
33
|
-
if (omitCloneIndex !== -1 && argv[omitCloneIndex + 1] === "true") {
|
|
34
|
-
omitClone = true;
|
|
35
|
-
}
|
|
36
|
-
if (omitCloneIndex !== -1 &&
|
|
37
|
-
typeof argv[omitCloneIndex + 1] === "undefined") {
|
|
38
|
-
omitClone = true;
|
|
39
|
-
}
|
|
40
|
-
removeFolder("git-modules");
|
|
41
|
-
const result = await clone({
|
|
42
|
-
owner,
|
|
43
|
-
repo,
|
|
44
|
-
outDir: "./git-modules",
|
|
45
|
-
});
|
|
46
|
-
if (result) {
|
|
47
|
-
removeFolder(outDir);
|
|
48
|
-
extractProto({
|
|
49
|
-
sources: result,
|
|
50
|
-
targets,
|
|
51
|
-
outDir,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
run();
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
};
|