@cosmwasm/ts-codegen 1.6.0 → 1.7.1
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 +13 -31
- package/esm/generators/create-helpers.js +1 -1
- package/esm/plugins/provider-bundle.js +1 -1
- package/esm/plugins/provider.js +1 -1
- package/generators/create-helpers.js +1 -1
- package/package.json +3 -3
- package/plugins/provider-bundle.js +1 -1
- package/plugins/provider.js +1 -1
package/README.md
CHANGED
@@ -36,11 +36,10 @@ The quickest and easiest way to interact with CosmWasm Contracts. `@cosmwasm/ts-
|
|
36
36
|
- [Recoil](#recoil)
|
37
37
|
- [Message Composer](#message-composer)
|
38
38
|
- [Message Builder](#message-builder)
|
39
|
-
- [Use Contracts
|
39
|
+
- [Use Contracts Hook](#use-contracts-hooks-usage)
|
40
40
|
- [Bundles](#bundles)
|
41
41
|
- [CLI Usage and Examples](#cli-usage-and-examples)
|
42
42
|
- [Advanced Usage](#advanced-usage)
|
43
|
-
- [Example Output](#example-output)
|
44
43
|
- [JSON Schema](#json-schema)
|
45
44
|
- [JSON Schema Generation](#json-schema-generation)
|
46
45
|
- [Exporting Schemas](#exporting-schemas)
|
@@ -98,7 +97,7 @@ codegen({
|
|
98
97
|
messageBuilder: {
|
99
98
|
enabled: false
|
100
99
|
},
|
101
|
-
|
100
|
+
useContractsHook: {
|
102
101
|
enabled: false
|
103
102
|
}
|
104
103
|
}
|
@@ -191,11 +190,20 @@ Generate raw message jsons for use in your application with the `message-builder
|
|
191
190
|
| `messageBuilder.enabled` | enable the messageBuilder plugin |
|
192
191
|
|
193
192
|
|
194
|
-
###
|
193
|
+
### `useContracts` Hook
|
194
|
+
|
195
|
+
Generates `useContracts` hook to easily access contracts, already equipped with a signing client
|
195
196
|
|
196
197
|
| option | description |
|
197
198
|
| -------------------------------- | --------------------------------------- |
|
198
|
-
| `
|
199
|
+
| `useContractsHook.enabled` | enable the `useContracts` plugin |
|
200
|
+
|
201
|
+
#### Example Output
|
202
|
+
|
203
|
+
- [Provider](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/builder/bundler_test/contracts/Factory.provider.ts)
|
204
|
+
- [Contract Providers](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/builder/bundler_test/contracts/contractContextProviders.ts)
|
205
|
+
- [Contract Context](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/builder/bundler_test/contracts/contracts-context.tsx)
|
206
|
+
- [Context Base](https://github.com/CosmWasm/ts-codegen/blob/main/__output__/builder/bundler_test/contracts/contractContextBase.ts)
|
199
207
|
|
200
208
|
#### Use Contracts Provider Usage
|
201
209
|
|
@@ -524,32 +532,6 @@ import {
|
|
524
532
|
generateMessageComposer
|
525
533
|
} from '@cosmwasm/ts-codegen';
|
526
534
|
```
|
527
|
-
### Example Output
|
528
|
-
|
529
|
-
- `cosmwasm-ts-codegen generate --typesOnly`
|
530
|
-
|
531
|
-
https://gist.github.com/pyramation/107d4e8e30dc5eb3ffc07bc3000f4dd0
|
532
|
-
|
533
|
-
- `cosmwasm-ts-codegen generate --plugin client`
|
534
|
-
|
535
|
-
https://gist.github.com/pyramation/30508678b7563e286f06ccc5ac384817
|
536
|
-
|
537
|
-
- `cosmwasm-ts-codegen generate --plugin react-query`
|
538
|
-
|
539
|
-
https://gist.github.com/pyramation/70aef28fd3af0ee164f7711704d3dfc0
|
540
|
-
|
541
|
-
- `cosmwasm-ts-codegen generate --plugin recoil`
|
542
|
-
|
543
|
-
https://gist.github.com/pyramation/a9520ccf131177b1841e02a97d7d3731
|
544
|
-
|
545
|
-
- `cosmwasm-ts-codegen generate --plugin message-composer`
|
546
|
-
|
547
|
-
https://gist.github.com/pyramation/43320e8b952751a0bd5a77dbc5b601f4
|
548
|
-
|
549
|
-
- `cosmwasm-ts-codegen generate --plugin message-builder`
|
550
|
-
|
551
|
-
https://gist.github.com/adairrr/b394e62beb9856b0351883f776650f26
|
552
|
-
|
553
535
|
|
554
536
|
### JSON Schema
|
555
537
|
|
@@ -25,7 +25,7 @@ const write = (outPath, file, content, varname) => {
|
|
25
25
|
};
|
26
26
|
export const createHelpers = (input, builderContext) => {
|
27
27
|
const files = [];
|
28
|
-
if (input.options?.
|
28
|
+
if (input.options?.useContractsHook?.enabled &&
|
29
29
|
Object.keys(builderContext.providers)?.length) {
|
30
30
|
const useShorthandCtor = input.options?.useShorthandCtor;
|
31
31
|
files.push(write(input.outPath, "contractContextBase.ts", useShorthandCtor
|
@@ -18,7 +18,7 @@ export class ContractsProviderBundlePlugin extends BuilderPluginBase {
|
|
18
18
|
return new RenderContext(contract, options, this.builder.builderContext);
|
19
19
|
}
|
20
20
|
async doRender(name, context) {
|
21
|
-
if (!this.option?.
|
21
|
+
if (!this.option?.useContractsHook?.enabled) {
|
22
22
|
return;
|
23
23
|
}
|
24
24
|
const providerInfos = context.getProviderInfos();
|
package/esm/plugins/provider.js
CHANGED
@@ -17,7 +17,7 @@ export class ContractsContextProviderPlugin extends BuilderPluginBase {
|
|
17
17
|
return new RenderContext(contract, options, this.builder.builderContext);
|
18
18
|
}
|
19
19
|
async doRender(name, context) {
|
20
|
-
if (!this.option?.
|
20
|
+
if (!this.option?.useContractsHook?.enabled) {
|
21
21
|
return;
|
22
22
|
}
|
23
23
|
const providerInfo = context.getProviderInfos()[name];
|
@@ -28,7 +28,7 @@ const write = (outPath, file, content, varname) => {
|
|
28
28
|
};
|
29
29
|
const createHelpers = (input, builderContext) => {
|
30
30
|
const files = [];
|
31
|
-
if (input.options?.
|
31
|
+
if (input.options?.useContractsHook?.enabled &&
|
32
32
|
Object.keys(builderContext.providers)?.length) {
|
33
33
|
const useShorthandCtor = input.options?.useShorthandCtor;
|
34
34
|
files.push(write(input.outPath, "contractContextBase.ts", useShorthandCtor
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cosmwasm/ts-codegen",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.7.1",
|
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",
|
@@ -57,7 +57,7 @@
|
|
57
57
|
"parse-package-name": "1.0.0",
|
58
58
|
"rimraf": "3.0.2",
|
59
59
|
"shelljs": "0.8.5",
|
60
|
-
"wasm-ast-types": "^1.
|
60
|
+
"wasm-ast-types": "^1.4.0"
|
61
61
|
},
|
62
62
|
"keywords": [
|
63
63
|
"cosmwasm",
|
@@ -65,5 +65,5 @@
|
|
65
65
|
"smart contracts",
|
66
66
|
"codegen"
|
67
67
|
],
|
68
|
-
"gitHead": "
|
68
|
+
"gitHead": "2c659f60a394582089a11bd4f3711f623c64a908"
|
69
69
|
}
|
@@ -44,7 +44,7 @@ class ContractsProviderBundlePlugin extends plugin_base_1.BuilderPluginBase {
|
|
44
44
|
return new wasm_ast_types_1.RenderContext(contract, options, this.builder.builderContext);
|
45
45
|
}
|
46
46
|
async doRender(name, context) {
|
47
|
-
if (!this.option?.
|
47
|
+
if (!this.option?.useContractsHook?.enabled) {
|
48
48
|
return;
|
49
49
|
}
|
50
50
|
const providerInfos = context.getProviderInfos();
|
package/plugins/provider.js
CHANGED
@@ -45,7 +45,7 @@ class ContractsContextProviderPlugin extends plugin_base_1.BuilderPluginBase {
|
|
45
45
|
return new wasm_ast_types_1.RenderContext(contract, options, this.builder.builderContext);
|
46
46
|
}
|
47
47
|
async doRender(name, context) {
|
48
|
-
if (!this.option?.
|
48
|
+
if (!this.option?.useContractsHook?.enabled) {
|
49
49
|
return;
|
50
50
|
}
|
51
51
|
const providerInfo = context.getProviderInfos()[name];
|