@hyperweb/telescope 2.0.1 → 2.0.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/README.md +4 -26
- package/main/builder.js +0 -10
- package/main/cli.js +0 -19
- package/main/cmds.js +1 -13
- package/module/builder.js +0 -10
- package/module/cli.js +0 -19
- package/module/cmds.js +0 -12
- package/module/telescope.js +0 -0
- package/package.json +6 -7
- package/src/builder.ts +2 -12
- package/src/cli.js +1 -21
- package/src/cmds.js +0 -14
- package/types/cmds.d.ts +0 -1
- 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/src/contracts/generate.ts +0 -33
- package/src/contracts/install.ts +0 -118
- package/src/contracts/message-composer.ts +0 -34
- package/src/contracts/react-query.ts +0 -33
- package/src/contracts/recoil.ts +0 -32
- package/src/generators/create-cosmwasm-bundle.ts +0 -17
- package/src/utils/contracts.ts +0 -37
- package/types/codegen/cosmos/orm/module/v1alpha1/module.d.ts +0 -43
|
@@ -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,33 +0,0 @@
|
|
|
1
|
-
import { prompt } from '../prompt';
|
|
2
|
-
import { generateClient } from '@cosmwasm/ts-codegen';
|
|
3
|
-
import { getContracts, getContractSchemata } from '../utils/contracts';
|
|
4
|
-
|
|
5
|
-
export default async (argv) => {
|
|
6
|
-
|
|
7
|
-
const contracts = getContracts();
|
|
8
|
-
|
|
9
|
-
const questions = [
|
|
10
|
-
{
|
|
11
|
-
_: true,
|
|
12
|
-
type: 'checkbox',
|
|
13
|
-
name: 'schema',
|
|
14
|
-
message: 'which directory contains the the Rust contracts?',
|
|
15
|
-
choices: contracts
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
_: true,
|
|
19
|
-
type: 'path',
|
|
20
|
-
name: 'out',
|
|
21
|
-
message: 'where is the output directory?',
|
|
22
|
-
default: './src/contracts'
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
let { schema, out } = await prompt(questions, argv);
|
|
27
|
-
if (!Array.isArray(schema)) schema = [schema];
|
|
28
|
-
|
|
29
|
-
const s = await getContractSchemata(schema, out, argv);
|
|
30
|
-
s.forEach(async ({ contractName, schemas, outPath }) => {
|
|
31
|
-
await generateClient(contractName, schemas, outPath);
|
|
32
|
-
});
|
|
33
|
-
};
|
package/src/contracts/install.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { resolve, join, dirname, basename, extname } from 'path';
|
|
2
|
-
import { crossGlob as glob } from '@cosmology/utils';
|
|
3
|
-
import { mkdirp } from 'mkdirp';
|
|
4
|
-
import { rimrafSync as rimraf } from 'rimraf';
|
|
5
|
-
import { exec } from 'shelljs';
|
|
6
|
-
import { prompt } from '../prompt';
|
|
7
|
-
import { parse } from 'parse-package-name';
|
|
8
|
-
import { tmpdir } from 'os';
|
|
9
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
10
|
-
|
|
11
|
-
const TMPDIR = tmpdir();
|
|
12
|
-
const rnd = () =>
|
|
13
|
-
Math.random().toString(36).substring(2, 15) +
|
|
14
|
-
Math.random().toString(36).substring(2, 15);
|
|
15
|
-
|
|
16
|
-
const getPackages = (names) => {
|
|
17
|
-
return names.map(pkg => {
|
|
18
|
-
const { name, version } = parse(pkg);
|
|
19
|
-
return `${name}@${version}`
|
|
20
|
-
}).join(' ');
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default async (argv) => {
|
|
24
|
-
|
|
25
|
-
// don't prompt if we got this...
|
|
26
|
-
if (argv._.length) {
|
|
27
|
-
argv.pkg = argv._;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// current dir/package
|
|
31
|
-
const cur = process.cwd();
|
|
32
|
-
let thisPackage;
|
|
33
|
-
try {
|
|
34
|
-
thisPackage = JSON.parse(readFileSync(join(cur, 'package.json'), 'utf-8'));
|
|
35
|
-
} catch (e) {
|
|
36
|
-
throw new Error('make sure you are inside of a telescope package!');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// what are we installing?
|
|
40
|
-
let { pkg } = await prompt([
|
|
41
|
-
{
|
|
42
|
-
type: 'checkbox',
|
|
43
|
-
name: 'pkg',
|
|
44
|
-
message:
|
|
45
|
-
'which chain contracts do you want to support?',
|
|
46
|
-
choices: [
|
|
47
|
-
'stargaze-base-factory',
|
|
48
|
-
'stargaze-base-minter',
|
|
49
|
-
'stargaze-sg721-base',
|
|
50
|
-
'stargaze-sg721-metdata-onchain',
|
|
51
|
-
'stargaze-sg721-nt',
|
|
52
|
-
'stargaze-splits',
|
|
53
|
-
'stargaze-vending-factory',
|
|
54
|
-
'stargaze-vending-minter',
|
|
55
|
-
'stargaze-whitelist',
|
|
56
|
-
'wasmswap',
|
|
57
|
-
].map(name => {
|
|
58
|
-
return {
|
|
59
|
-
name,
|
|
60
|
-
value: `@cosmjson/${name}`
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
], argv);
|
|
65
|
-
|
|
66
|
-
// install
|
|
67
|
-
if (!Array.isArray(pkg)) pkg = [pkg];
|
|
68
|
-
const tmp = join(TMPDIR, rnd());
|
|
69
|
-
mkdirp.sync(tmp);
|
|
70
|
-
process.chdir(tmp);
|
|
71
|
-
exec(`npm install ${getPackages(pkg)} --production --prefix ./smart-contracts`);
|
|
72
|
-
|
|
73
|
-
// protos
|
|
74
|
-
const pkgs = glob('./smart-contracts/**/package.json');
|
|
75
|
-
const cmds = pkgs
|
|
76
|
-
.filter((f) => { return f !== './smart-contracts/package.json' })
|
|
77
|
-
.map((f) => resolve(join(tmp, f)))
|
|
78
|
-
.map((conf) => {
|
|
79
|
-
const extDir = dirname(conf);
|
|
80
|
-
const dir = extDir.split('node_modules/')[1];
|
|
81
|
-
const dst = basename(dir);
|
|
82
|
-
|
|
83
|
-
const files = glob(`${extDir}/**/*`, { nodir: true });
|
|
84
|
-
files.forEach(f => {
|
|
85
|
-
if (extname(f) === '.json'
|
|
86
|
-
|| f === 'package.json'
|
|
87
|
-
|| /license/i.test(f)
|
|
88
|
-
|| /readme/i.test(f)) return;
|
|
89
|
-
rimraf(f);
|
|
90
|
-
});
|
|
91
|
-
return [extDir, resolve(join(cur, 'contracts', dst)), dir];
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// move protos
|
|
95
|
-
for (const [src, dst, pkg] of cmds) {
|
|
96
|
-
rimraf(dst);
|
|
97
|
-
console.log(`installing ${pkg}...`);
|
|
98
|
-
mkdirp.sync(dirname(dst));
|
|
99
|
-
exec(`mv ${src} ${dst}`);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// package
|
|
103
|
-
const packageInfo = JSON.parse(readFileSync('./smart-contracts/package.json', 'utf-8'));
|
|
104
|
-
const deps = packageInfo.dependencies ?? {};
|
|
105
|
-
thisPackage.devDependencies = thisPackage.devDependencies ?? {};
|
|
106
|
-
thisPackage.devDependencies = {
|
|
107
|
-
...thisPackage.devDependencies,
|
|
108
|
-
...deps
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
thisPackage.devDependencies = Object.fromEntries(Object.entries(thisPackage.devDependencies).sort());
|
|
112
|
-
|
|
113
|
-
writeFileSync(join(cur, 'package.json'), JSON.stringify(thisPackage, null, 2));
|
|
114
|
-
|
|
115
|
-
// cleanup
|
|
116
|
-
rimraf(tmp);
|
|
117
|
-
process.chdir(cur);
|
|
118
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { prompt } from '../prompt';
|
|
2
|
-
import { generateMessageComposer } from '@cosmwasm/ts-codegen';
|
|
3
|
-
import { getContracts, getContractSchemata } from '../utils/contracts';
|
|
4
|
-
|
|
5
|
-
export default async (argv) => {
|
|
6
|
-
|
|
7
|
-
const contracts = getContracts();
|
|
8
|
-
|
|
9
|
-
const questions = [
|
|
10
|
-
{
|
|
11
|
-
_: true,
|
|
12
|
-
type: 'checkbox',
|
|
13
|
-
name: 'schema',
|
|
14
|
-
message: 'which directory contains the the Rust contracts?',
|
|
15
|
-
choices: contracts
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
_: true,
|
|
19
|
-
type: 'path',
|
|
20
|
-
name: 'out',
|
|
21
|
-
message: 'where is the output directory?',
|
|
22
|
-
default: './src/contracts'
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
let { schema, out } = await prompt(questions, argv);
|
|
27
|
-
if (!Array.isArray(schema)) schema = [schema];
|
|
28
|
-
|
|
29
|
-
const s = await getContractSchemata(schema, out, argv);
|
|
30
|
-
s.forEach(async ({ contractName, schemas, outPath }) => {
|
|
31
|
-
await generateMessageComposer(contractName, schemas, outPath);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { prompt } from '../prompt';
|
|
2
|
-
import { generateReactQuery } from '@cosmwasm/ts-codegen';
|
|
3
|
-
import { getContracts, getContractSchemata } from '../utils/contracts';
|
|
4
|
-
|
|
5
|
-
export default async (argv) => {
|
|
6
|
-
const contracts = getContracts();
|
|
7
|
-
|
|
8
|
-
const questions = [
|
|
9
|
-
{
|
|
10
|
-
_: true,
|
|
11
|
-
type: 'checkbox',
|
|
12
|
-
name: 'schema',
|
|
13
|
-
message: 'which directory contains the the Rust contracts?',
|
|
14
|
-
choices: contracts
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
_: true,
|
|
18
|
-
type: 'path',
|
|
19
|
-
name: 'out',
|
|
20
|
-
message: 'where is the output directory?',
|
|
21
|
-
default: './src/contracts'
|
|
22
|
-
}
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
let { schema, out } = await prompt(questions, argv);
|
|
26
|
-
if (!Array.isArray(schema)) schema = [schema];
|
|
27
|
-
|
|
28
|
-
const s = await getContractSchemata(schema, out, argv);
|
|
29
|
-
s.forEach(async ({ contractName, schemas, outPath }) => {
|
|
30
|
-
await generateReactQuery(contractName, schemas, outPath);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
};
|
package/src/contracts/recoil.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { prompt } from '../prompt';
|
|
2
|
-
import { generateRecoil } from '@cosmwasm/ts-codegen';
|
|
3
|
-
import { getContracts, getContractSchemata } from '../utils/contracts';
|
|
4
|
-
|
|
5
|
-
export default async (argv) => {
|
|
6
|
-
const contracts = getContracts();
|
|
7
|
-
|
|
8
|
-
const questions = [
|
|
9
|
-
{
|
|
10
|
-
_: true,
|
|
11
|
-
type: 'checkbox',
|
|
12
|
-
name: 'schema',
|
|
13
|
-
message: 'which directory contains the the Rust contracts?',
|
|
14
|
-
choices: contracts
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
_: true,
|
|
18
|
-
type: 'path',
|
|
19
|
-
name: 'out',
|
|
20
|
-
message: 'where is the output directory?',
|
|
21
|
-
default: './src/contracts'
|
|
22
|
-
}
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
let { schema, out } = await prompt(questions, argv);
|
|
26
|
-
if (!Array.isArray(schema)) schema = [schema];
|
|
27
|
-
|
|
28
|
-
const s = await getContractSchemata(schema, out, argv);
|
|
29
|
-
s.forEach(async ({ contractName, schemas, outPath }) => {
|
|
30
|
-
await generateRecoil(contractName, schemas, outPath);
|
|
31
|
-
});
|
|
32
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { TelescopeBuilder } from '../builder';
|
|
2
|
-
import { TSBuilder } from '@cosmwasm/ts-codegen';
|
|
3
|
-
|
|
4
|
-
export const plugin = async (
|
|
5
|
-
builder: TelescopeBuilder
|
|
6
|
-
) => {
|
|
7
|
-
|
|
8
|
-
if (!builder.options.cosmwasm) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const input = builder.options.cosmwasm;
|
|
13
|
-
const cosmWasmBuilder = new TSBuilder(input);
|
|
14
|
-
await cosmWasmBuilder.build();
|
|
15
|
-
const file = input.options.bundle.bundleFile;
|
|
16
|
-
builder.files.push(file);
|
|
17
|
-
};
|