@cosmwasm/ts-codegen 1.0.0 → 1.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 +104 -99
- package/esm/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +5 -16
- /package/esm/generators/{msg-builder.js → message-builder.js} +0 -0
- /package/generators/{msg-builder.d.ts → message-builder.d.ts} +0 -0
- /package/generators/{msg-builder.js → message-builder.js} +0 -0
package/README.md
CHANGED
@@ -18,7 +18,7 @@ Generate TypeScript SDKs for your CosmWasm smart contracts
|
|
18
18
|
|
19
19
|
|
20
20
|
```
|
21
|
-
npm install
|
21
|
+
npm install @cosmwasm/ts-codegen
|
22
22
|
```
|
23
23
|
|
24
24
|
The quickest and easiest way to interact with CosmWasm Contracts. `@cosmwasm/ts-codegen` converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.
|
@@ -28,7 +28,6 @@ The quickest and easiest way to interact with CosmWasm Contracts. `@cosmwasm/ts-
|
|
28
28
|
|
29
29
|
- [@cosmwasm/ts-codegen](#cosmwasmts-codegen)
|
30
30
|
- [Table of contents](#table-of-contents)
|
31
|
-
- [QuickStart](#quickstart)
|
32
31
|
- [Usage](#usage)
|
33
32
|
- [Programmatic Usage](#programmatic-usage)
|
34
33
|
- [Types](#types)
|
@@ -47,35 +46,9 @@ The quickest and easiest way to interact with CosmWasm Contracts. `@cosmwasm/ts-
|
|
47
46
|
- [Exporting Schemas](#exporting-schemas)
|
48
47
|
- [Developing](#developing)
|
49
48
|
- [Related](#related)
|
50
|
-
## Quickstart
|
51
|
-
|
52
|
-
Clone your project and `cd` into your contracts folder
|
53
|
-
|
54
|
-
```sh
|
55
|
-
git clone https://github.com/public-awesome/launchpad.git
|
56
|
-
cd launchpad/contracts/sg721-base/
|
57
|
-
```
|
58
|
-
|
59
|
-
Run `cosmwasm-ts-codegen` to generate your code.
|
60
|
-
|
61
|
-
```sh
|
62
|
-
cosmwasm-ts-codegen generate \
|
63
|
-
--plugin client \
|
64
|
-
--schema ./schema \
|
65
|
-
--out ./ts \
|
66
|
-
--name SG721 \
|
67
|
-
--no-bundle
|
68
|
-
```
|
69
|
-
|
70
|
-
The output will be in the folder specified by `--out`, enjoy!
|
71
49
|
|
72
50
|
## Usage
|
73
51
|
|
74
|
-
You can get started quickly using our `cli` by globally installing via npm:
|
75
|
-
|
76
|
-
```
|
77
|
-
npm install -g @cosmwasm/ts-codegen
|
78
|
-
```
|
79
52
|
### Programmatic Usage
|
80
53
|
|
81
54
|
For production usage, we recommend setting up a build script that uses the main entry point:
|
@@ -137,7 +110,7 @@ codegen({
|
|
137
110
|
|
138
111
|
Typescript types and interfaces are generated in separate files so they can be imported into various generated plugins.
|
139
112
|
|
140
|
-
[see example output code](https://
|
113
|
+
[see example output code](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/sg721/Sg721.types.ts)
|
141
114
|
|
142
115
|
#### Types Options
|
143
116
|
|
@@ -151,7 +124,7 @@ Typescript types and interfaces are generated in separate files so they can be i
|
|
151
124
|
|
152
125
|
The `client` plugin will generate TS client classes for your contracts. This option generates a `QueryClient` for queries as well as a `Client` for queries and mutations.
|
153
126
|
|
154
|
-
[see example output code](https://
|
127
|
+
[see example output code](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/sg721/Sg721.client.ts )
|
155
128
|
|
156
129
|
#### Client Options
|
157
130
|
|
@@ -161,20 +134,12 @@ The `client` plugin will generate TS client classes for your contracts. This opt
|
|
161
134
|
| `client.execExtendsQuery` | execute should extend query message clients |
|
162
135
|
| `client.noImplicitOverride` | should match your tsconfig noImplicitOverride option |
|
163
136
|
|
164
|
-
#### Client via CLI
|
165
137
|
|
166
|
-
```sh
|
167
|
-
cosmwasm-ts-codegen generate \
|
168
|
-
--plugin client
|
169
|
-
--schema ./schema \
|
170
|
-
--out ./ts \
|
171
|
-
--name MyContractName
|
172
|
-
```
|
173
138
|
### React Query
|
174
139
|
|
175
140
|
Generate [react-query v3](https://react-query-v3.tanstack.com/) or [react-query v4](https://tanstack.com/query/v4/) bindings for your contracts with the `react-query` command.
|
176
141
|
|
177
|
-
[see example output code](https://
|
142
|
+
[see example output code](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/sg721/Sg721.react-query.ts)
|
178
143
|
|
179
144
|
#### React Query Options
|
180
145
|
|
@@ -189,50 +154,11 @@ Generate [react-query v3](https://react-query-v3.tanstack.com/) or [react-query
|
|
189
154
|
| `reactQuery.camelize` | use camelCase style for property names |
|
190
155
|
|
191
156
|
|
192
|
-
#### React Query via CLI
|
193
|
-
|
194
|
-
Here is an example without optional client, using v3 for `react-query`, without mutations:
|
195
|
-
|
196
|
-
```sh
|
197
|
-
cosmwasm-ts-codegen generate \
|
198
|
-
--plugin client \
|
199
|
-
--plugin react-query \
|
200
|
-
--schema ./schema \
|
201
|
-
--out ./ts \
|
202
|
-
--name MyContractName \
|
203
|
-
--version v3 \
|
204
|
-
--no-optionalClient \
|
205
|
-
--no-mutations
|
206
|
-
```
|
207
|
-
|
208
|
-
Example with optional client, using v4, with mutations:
|
209
|
-
|
210
|
-
```sh
|
211
|
-
cosmwasm-ts-codegen generate \
|
212
|
-
--plugin react-query \
|
213
|
-
--schema ./schema \
|
214
|
-
--out ./ts \
|
215
|
-
--name MyContractName \
|
216
|
-
--optionalClient \
|
217
|
-
--version v4 \
|
218
|
-
--mutations
|
219
|
-
```
|
220
|
-
|
221
157
|
### Recoil
|
222
158
|
|
223
159
|
Generate [recoil](https://recoiljs.org/) bindings for your contracts with the `recoil` command.
|
224
160
|
|
225
|
-
[see example output code](https://
|
226
|
-
|
227
|
-
#### Recoil via CLI
|
228
|
-
|
229
|
-
```sh
|
230
|
-
cosmwasm-ts-codegen generate \
|
231
|
-
--plugin recoil \
|
232
|
-
--schema ./schema \
|
233
|
-
--out ./ts \
|
234
|
-
--name MyContractName
|
235
|
-
```
|
161
|
+
[see example output code](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/sg721/Sg721.recoil.ts)
|
236
162
|
|
237
163
|
#### Recoil Options
|
238
164
|
|
@@ -244,17 +170,8 @@ cosmwasm-ts-codegen generate \
|
|
244
170
|
|
245
171
|
Generate pure message objects with the proper `utf8` encoding and `typeUrl` configured that you can broadcast yourself via `cosmjs` with the `message-composer` command.
|
246
172
|
|
247
|
-
[see example output code](https://
|
173
|
+
[see example output code](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/sg721/Sg721.message-composer.ts)
|
248
174
|
|
249
|
-
#### Message Composer via CLI
|
250
|
-
|
251
|
-
```sh
|
252
|
-
cosmwasm-ts-codegen generate \
|
253
|
-
--plugin message-composer \
|
254
|
-
--schema ./schema \
|
255
|
-
--out ./ts \
|
256
|
-
--name MyContractName
|
257
|
-
```
|
258
175
|
#### Message Composer Options
|
259
176
|
|
260
177
|
| option | description |
|
@@ -265,17 +182,8 @@ cosmwasm-ts-codegen generate \
|
|
265
182
|
|
266
183
|
Generate raw message jsons for use in your application with the `message-builder` command.
|
267
184
|
|
268
|
-
[see example output code](https://
|
269
|
-
|
270
|
-
#### Message Builder via CLI
|
185
|
+
[see example output code](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/sg721/Sg721.message-builder.ts)
|
271
186
|
|
272
|
-
```sh
|
273
|
-
cosmwasm-ts-codegen generate \
|
274
|
-
--plugin message-builder \
|
275
|
-
--schema ./schema \
|
276
|
-
--out ./ts \
|
277
|
-
--name MyContractName
|
278
|
-
```
|
279
187
|
#### Message Builder Options
|
280
188
|
|
281
189
|
| option | description |
|
@@ -426,6 +334,32 @@ Without using shorthand constructor:
|
|
426
334
|
|
427
335
|
### CLI Usage and Examples
|
428
336
|
|
337
|
+
You can get started quickly using our `cli` by globally installing via npm:
|
338
|
+
|
339
|
+
```
|
340
|
+
npm install @cosmwasm/ts-codegen
|
341
|
+
```
|
342
|
+
|
343
|
+
Clone your project and `cd` into your contracts folder
|
344
|
+
|
345
|
+
```sh
|
346
|
+
git clone https://github.com/public-awesome/launchpad.git
|
347
|
+
cd launchpad/contracts/whitelists/
|
348
|
+
```
|
349
|
+
|
350
|
+
Run `cosmwasm-ts-codegen` to generate your code.
|
351
|
+
|
352
|
+
```sh
|
353
|
+
cosmwasm-ts-codegen generate \
|
354
|
+
--plugin client \
|
355
|
+
--schema ./schema \
|
356
|
+
--out ./ts \
|
357
|
+
--name Whitelist \
|
358
|
+
--no-bundle
|
359
|
+
```
|
360
|
+
|
361
|
+
The output will be in the folder specified by `--out`, enjoy!
|
362
|
+
|
429
363
|
#### Interactive prompt
|
430
364
|
|
431
365
|
The CLI is interactive, and if you don't specify an option, it will interactively prompt you.
|
@@ -506,6 +440,77 @@ cosmwasm-ts-codegen generate \
|
|
506
440
|
--name SG721
|
507
441
|
```
|
508
442
|
|
443
|
+
#### Client via CLI
|
444
|
+
|
445
|
+
```sh
|
446
|
+
cosmwasm-ts-codegen generate \
|
447
|
+
--plugin client
|
448
|
+
--schema ./schema \
|
449
|
+
--out ./ts \
|
450
|
+
--name MyContractName
|
451
|
+
```
|
452
|
+
|
453
|
+
|
454
|
+
#### React Query via CLI
|
455
|
+
|
456
|
+
Here is an example without optional client, using v3 for `react-query`, without mutations:
|
457
|
+
|
458
|
+
```sh
|
459
|
+
cosmwasm-ts-codegen generate \
|
460
|
+
--plugin client \
|
461
|
+
--plugin react-query \
|
462
|
+
--schema ./schema \
|
463
|
+
--out ./ts \
|
464
|
+
--name MyContractName \
|
465
|
+
--version v3 \
|
466
|
+
--no-optionalClient \
|
467
|
+
--no-mutations
|
468
|
+
```
|
469
|
+
|
470
|
+
Example with optional client, using v4, with mutations:
|
471
|
+
|
472
|
+
```sh
|
473
|
+
cosmwasm-ts-codegen generate \
|
474
|
+
--plugin react-query \
|
475
|
+
--schema ./schema \
|
476
|
+
--out ./ts \
|
477
|
+
--name MyContractName \
|
478
|
+
--optionalClient \
|
479
|
+
--version v4 \
|
480
|
+
--mutations
|
481
|
+
```
|
482
|
+
|
483
|
+
#### Recoil via CLI
|
484
|
+
|
485
|
+
```sh
|
486
|
+
cosmwasm-ts-codegen generate \
|
487
|
+
--plugin recoil \
|
488
|
+
--schema ./schema \
|
489
|
+
--out ./ts \
|
490
|
+
--name MyContractName
|
491
|
+
```
|
492
|
+
|
493
|
+
#### Message Composer via CLI
|
494
|
+
|
495
|
+
```sh
|
496
|
+
cosmwasm-ts-codegen generate \
|
497
|
+
--plugin message-composer \
|
498
|
+
--schema ./schema \
|
499
|
+
--out ./ts \
|
500
|
+
--name MyContractName
|
501
|
+
```
|
502
|
+
|
503
|
+
#### Message Builder via CLI
|
504
|
+
|
505
|
+
```sh
|
506
|
+
cosmwasm-ts-codegen generate \
|
507
|
+
--plugin message-builder \
|
508
|
+
--schema ./schema \
|
509
|
+
--out ./ts \
|
510
|
+
--name MyContractName
|
511
|
+
```
|
512
|
+
|
513
|
+
|
509
514
|
### Advanced Usage
|
510
515
|
|
511
516
|
for lower-level access, you can import the various plugins directly:
|
package/esm/index.js
CHANGED
@@ -2,6 +2,7 @@ import { TSBuilder } from './builder';
|
|
2
2
|
export { default as generateTypes } from './generators/types';
|
3
3
|
export { default as generateClient } from './generators/client';
|
4
4
|
export { default as generateMessageComposer } from './generators/message-composer';
|
5
|
+
export { default as generateMessageBuilder } from './generators/message-builder';
|
5
6
|
export { default as generateReactQuery } from './generators/react-query';
|
6
7
|
export { default as generateRecoil } from './generators/recoil';
|
7
8
|
export * from './utils';
|
package/index.d.ts
CHANGED
@@ -2,6 +2,7 @@ import { TSBuilderInput } from './builder';
|
|
2
2
|
export { default as generateTypes } from './generators/types';
|
3
3
|
export { default as generateClient } from './generators/client';
|
4
4
|
export { default as generateMessageComposer } from './generators/message-composer';
|
5
|
+
export { default as generateMessageBuilder } from './generators/message-builder';
|
5
6
|
export { default as generateReactQuery } from './generators/react-query';
|
6
7
|
export { default as generateRecoil } from './generators/recoil';
|
7
8
|
export * from './utils';
|
package/index.js
CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
18
|
};
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
-
exports.generateRecoil = exports.generateReactQuery = exports.generateMessageComposer = exports.generateClient = exports.generateTypes = void 0;
|
20
|
+
exports.generateRecoil = exports.generateReactQuery = exports.generateMessageBuilder = exports.generateMessageComposer = exports.generateClient = exports.generateTypes = void 0;
|
21
21
|
const builder_1 = require("./builder");
|
22
22
|
var types_1 = require("./generators/types");
|
23
23
|
Object.defineProperty(exports, "generateTypes", { enumerable: true, get: function () { return __importDefault(types_1).default; } });
|
@@ -25,6 +25,8 @@ var client_1 = require("./generators/client");
|
|
25
25
|
Object.defineProperty(exports, "generateClient", { enumerable: true, get: function () { return __importDefault(client_1).default; } });
|
26
26
|
var message_composer_1 = require("./generators/message-composer");
|
27
27
|
Object.defineProperty(exports, "generateMessageComposer", { enumerable: true, get: function () { return __importDefault(message_composer_1).default; } });
|
28
|
+
var message_builder_1 = require("./generators/message-builder");
|
29
|
+
Object.defineProperty(exports, "generateMessageBuilder", { enumerable: true, get: function () { return __importDefault(message_builder_1).default; } });
|
28
30
|
var react_query_1 = require("./generators/react-query");
|
29
31
|
Object.defineProperty(exports, "generateReactQuery", { enumerable: true, get: function () { return __importDefault(react_query_1).default; } });
|
30
32
|
var recoil_1 = require("./generators/recoil");
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cosmwasm/ts-codegen",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.1.0",
|
4
4
|
"description": "@cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.",
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
6
6
|
"homepage": "https://github.com/cosmwasm/ts-codegen",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"directory": "dist"
|
14
14
|
},
|
15
15
|
"bin": {
|
16
|
-
"cosmwasm-ts-codegen": "
|
16
|
+
"cosmwasm-ts-codegen": "ts-codegen.js"
|
17
17
|
},
|
18
18
|
"scripts": {
|
19
19
|
"copy": "copyfiles -f LICENSE-Apache LICENSE-MIT README.md package.json dist",
|
@@ -38,19 +38,8 @@
|
|
38
38
|
"ast-stringify": "0.1.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@babel/core": "7.18.10",
|
42
|
-
"@babel/generator": "7.18.12",
|
43
|
-
"@babel/parser": "7.18.11",
|
44
|
-
"@babel/plugin-proposal-class-properties": "7.18.6",
|
45
|
-
"@babel/plugin-proposal-export-default-from": "7.18.10",
|
46
|
-
"@babel/plugin-proposal-object-rest-spread": "7.18.9",
|
47
|
-
"@babel/plugin-transform-runtime": "7.18.10",
|
48
|
-
"@babel/preset-env": "7.18.10",
|
49
|
-
"@babel/preset-typescript": "^7.18.6",
|
50
|
-
"@babel/runtime": "^7.18.9",
|
51
|
-
"@babel/traverse": "7.18.11",
|
52
41
|
"@babel/types": "7.18.10",
|
53
|
-
"@cosmology/ts-codegen-types": "^1.
|
42
|
+
"@cosmology/ts-codegen-types": "^1.1.0",
|
54
43
|
"@pyramation/json-schema-to-typescript": " 11.0.4",
|
55
44
|
"@types/rimraf": "3.0.2",
|
56
45
|
"@types/shelljs": "0.8.15",
|
@@ -66,7 +55,7 @@
|
|
66
55
|
"parse-package-name": "1.0.0",
|
67
56
|
"rimraf": "3.0.2",
|
68
57
|
"shelljs": "0.8.5",
|
69
|
-
"wasm-ast-types": "^1.
|
58
|
+
"wasm-ast-types": "^1.1.0"
|
70
59
|
},
|
71
60
|
"keywords": [
|
72
61
|
"cosmwasm",
|
@@ -74,5 +63,5 @@
|
|
74
63
|
"smart contracts",
|
75
64
|
"codegen"
|
76
65
|
],
|
77
|
-
"gitHead": "
|
66
|
+
"gitHead": "f584b91783521be1dd42f0392dfbd73020321862"
|
78
67
|
}
|
File without changes
|
File without changes
|
File without changes
|