@cosmwasm/ts-codegen 0.18.0 → 0.20.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 CHANGED
@@ -10,6 +10,7 @@ Generate TypeScript SDKs for your CosmWasm smart contracts
10
10
  <a href="https://github.com/CosmWasm/ts-codegen/actions/workflows/run-tests.yaml">
11
11
  <img height="20" src="https://github.com/CosmWasm/ts-codegen/actions/workflows/run-tests.yaml/badge.svg" />
12
12
  </a>
13
+ <a href="https://www.npmjs.com/package/@cosmwasm/ts-codegen"><img height="20" src="https://img.shields.io/npm/dt/@cosmwasm/ts-codegen"></a>
13
14
  <a href="https://github.com/CosmWasm/ts-codegen/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
14
15
  <a href="https://github.com/CosmWasm/ts-codegen/blob/main/LICENSE-Apache"><img height="20" src="https://img.shields.io/badge/license-Apache-blue.svg"></a>
15
16
  <a href="https://www.npmjs.com/package/@cosmwasm/ts-codegen"><img height="20" src="https://img.shields.io/github/package-json/v/CosmWasm/ts-codegen?filename=packages%2Fts-codegen%2Fpackage.json"></a>
@@ -110,6 +111,7 @@ codegen({
110
111
  version: 'v4',
111
112
  mutations: true,
112
113
  queryKeys: true,
114
+ queryFactory: true,
113
115
  },
114
116
  recoil: {
115
117
  enabled: false
@@ -146,6 +148,7 @@ The `client` plugin will generate TS client classes for your contracts. This opt
146
148
  | option | description |
147
149
  | ----------------------------- | --------------------------------------------------- |
148
150
  | `client.enabled` | generate TS client classes for your contracts |
151
+ | `client.execExtendsQuery` | execute should extend query message clients |
149
152
 
150
153
  #### Client via CLI
151
154
 
@@ -169,6 +172,7 @@ Generate [react-query v3](https://react-query-v3.tanstack.com/) or [react-query
169
172
  | `reactQuery.enabled` | enable the react-query plugin |
170
173
  | `reactQuery.optionalClient` | allows contract client to be undefined as the component renders |
171
174
  | `reactQuery.queryKeys` | generates a const queryKeys object for use with invalidations and set values |
175
+ | `reactQuery.queryFactory` | generates a const queryFactory object for useQueries and prefetchQueries use |
172
176
  | `reactQuery.version` | `v4` uses `@tanstack/react-query` and `v3` uses `react-query` |
173
177
  | `reactQuery.mutations` | also generate mutations |
174
178
  | `reactQuery.camelize` | use camelCase style for property names |
@@ -17,7 +17,7 @@ var _index = _interopRequireDefault(require("../index"));
17
17
 
18
18
  var _default = /*#__PURE__*/function () {
19
19
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(argv) {
20
- var questions, _yield$prompt, schema, out, name, plugin, bundle, questions2, _yield$prompt2, optionalClient, version, queryKeys, questions3, _yield$prompt3, mutations, questions4, _yield$prompt4, bundleFile, bundleScope, options;
20
+ var questions, _yield$prompt, schema, out, name, plugin, bundle, questions2, _yield$prompt2, optionalClient, version, queryKeys, questions3, _yield$prompt3, mutations, queryFactoryQuestions, _yield$prompt4, queryFactory, questions4, _yield$prompt5, bundleFile, bundleScope, options;
21
21
 
22
22
  return _regenerator["default"].wrap(function _callee$(_context) {
23
23
  while (1) {
@@ -118,6 +118,25 @@ var _default = /*#__PURE__*/function () {
118
118
  case 25:
119
119
  _yield$prompt3 = _context.sent;
120
120
  mutations = _yield$prompt3.mutations;
121
+ queryFactoryQuestions = [];
122
+
123
+ if (queryKeys) {
124
+ [].push.apply(queryFactoryQuestions, [// Only can use queryFactory if queryKeys is enabled
125
+ {
126
+ type: 'confirm',
127
+ name: 'queryFactory',
128
+ message: 'queryFactory? ',
129
+ "default": false
130
+ }]);
131
+ }
132
+
133
+ ;
134
+ _context.next = 32;
135
+ return (0, _prompt.prompt)(queryFactoryQuestions, argv);
136
+
137
+ case 32:
138
+ _yield$prompt4 = _context.sent;
139
+ queryFactory = _yield$prompt4.queryFactory;
121
140
  ///////// END REACT QUERY
122
141
  ///////// BUNDLE
123
142
  questions4 = [];
@@ -137,13 +156,13 @@ var _default = /*#__PURE__*/function () {
137
156
  }
138
157
 
139
158
  ;
140
- _context.next = 32;
159
+ _context.next = 39;
141
160
  return (0, _prompt.prompt)(questions4, argv);
142
161
 
143
- case 32:
144
- _yield$prompt4 = _context.sent;
145
- bundleFile = _yield$prompt4.bundleFile;
146
- bundleScope = _yield$prompt4.bundleScope;
162
+ case 39:
163
+ _yield$prompt5 = _context.sent;
164
+ bundleFile = _yield$prompt5.bundleFile;
165
+ bundleScope = _yield$prompt5.bundleScope;
147
166
  ///////// END BUNDLE
148
167
  options = {
149
168
  types: {
@@ -157,7 +176,8 @@ var _default = /*#__PURE__*/function () {
157
176
  optionalClient: optionalClient,
158
177
  queryKeys: queryKeys,
159
178
  version: version,
160
- mutations: mutations
179
+ mutations: mutations,
180
+ queryFactory: queryFactory
161
181
  },
162
182
  recoil: {
163
183
  enabled: plugin.includes('recoil')
@@ -171,7 +191,7 @@ var _default = /*#__PURE__*/function () {
171
191
  bundleFile: bundleFile
172
192
  }
173
193
  };
174
- _context.next = 38;
194
+ _context.next = 45;
175
195
  return (0, _index["default"])({
176
196
  contracts: [{
177
197
  name: name,
@@ -181,7 +201,7 @@ var _default = /*#__PURE__*/function () {
181
201
  options: options
182
202
  });
183
203
 
184
- case 38:
204
+ case 45:
185
205
  case "end":
186
206
  return _context.stop();
187
207
  }
@@ -79,8 +79,8 @@ var _default = /*#__PURE__*/function () {
79
79
  if (children.length > 0) {
80
80
  Client = (0, _case.pascal)("".concat(name, "Client"));
81
81
  Instance = (0, _case.pascal)("".concat(name, "Interface"));
82
- body.push(w.createExecuteInterface(context, Instance, ReadOnlyInstance, ExecuteMsg));
83
- body.push(w.createExecuteClass(context, Client, Instance, QueryClient, ExecuteMsg));
82
+ body.push(w.createExecuteInterface(context, Instance, context.options.client.execExtendsQuery ? ReadOnlyInstance : null, ExecuteMsg));
83
+ body.push(w.createExecuteClass(context, Client, Instance, context.options.client.execExtendsQuery ? QueryClient : null, ExecuteMsg));
84
84
  }
85
85
  }
86
86
 
@@ -86,7 +86,23 @@ export default (async argv => {
86
86
  ;
87
87
  const {
88
88
  mutations
89
- } = await prompt(questions3, argv); ///////// END REACT QUERY
89
+ } = await prompt(questions3, argv);
90
+ const queryFactoryQuestions = [];
91
+
92
+ if (queryKeys) {
93
+ [].push.apply(queryFactoryQuestions, [// Only can use queryFactory if queryKeys is enabled
94
+ {
95
+ type: 'confirm',
96
+ name: 'queryFactory',
97
+ message: 'queryFactory? ',
98
+ default: false
99
+ }]);
100
+ }
101
+
102
+ ;
103
+ const {
104
+ queryFactory
105
+ } = await prompt(queryFactoryQuestions, argv); ///////// END REACT QUERY
90
106
  ///////// BUNDLE
91
107
 
92
108
  const questions4 = [];
@@ -123,7 +139,8 @@ export default (async argv => {
123
139
  optionalClient,
124
140
  queryKeys,
125
141
  version,
126
- mutations
142
+ mutations,
143
+ queryFactory
127
144
  },
128
145
  recoil: {
129
146
  enabled: plugin.includes('recoil')
@@ -43,8 +43,8 @@ export default (async (name, contractInfo, outPath, tsClientOptions) => {
43
43
  if (children.length > 0) {
44
44
  Client = pascal(`${name}Client`);
45
45
  Instance = pascal(`${name}Interface`);
46
- body.push(w.createExecuteInterface(context, Instance, ReadOnlyInstance, ExecuteMsg));
47
- body.push(w.createExecuteClass(context, Client, Instance, QueryClient, ExecuteMsg));
46
+ body.push(w.createExecuteInterface(context, Instance, context.options.client.execExtendsQuery ? ReadOnlyInstance : null, ExecuteMsg));
47
+ body.push(w.createExecuteClass(context, Client, Instance, context.options.client.execExtendsQuery ? QueryClient : null, ExecuteMsg));
48
48
  }
49
49
  }
50
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmwasm/ts-codegen",
3
- "version": "0.18.0",
3
+ "version": "0.20.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",
@@ -96,7 +96,7 @@
96
96
  "parse-package-name": "1.0.0",
97
97
  "rimraf": "3.0.2",
98
98
  "shelljs": "0.8.5",
99
- "wasm-ast-types": "^0.12.0"
99
+ "wasm-ast-types": "^0.14.0"
100
100
  },
101
- "gitHead": "59dcc054d241c6bf43d5a617b31c3cd5c4ecff6e"
101
+ "gitHead": "e58a660b6265fc94bdd11f311afe9fac11708c51"
102
102
  }
@@ -90,6 +90,20 @@ export default async (argv) => {
90
90
  ])
91
91
  };
92
92
  const { mutations } = await prompt(questions3, argv);
93
+
94
+ const queryFactoryQuestions = [];
95
+ if (queryKeys) {
96
+ [].push.apply(queryFactoryQuestions, [
97
+ // Only can use queryFactory if queryKeys is enabled
98
+ {
99
+ type: 'confirm',
100
+ name: 'queryFactory',
101
+ message: 'queryFactory? ',
102
+ default: false
103
+ }
104
+ ])
105
+ };
106
+ const { queryFactory } = await prompt(queryFactoryQuestions, argv);
93
107
  ///////// END REACT QUERY
94
108
 
95
109
  ///////// BUNDLE
@@ -128,7 +142,8 @@ export default async (argv) => {
128
142
  optionalClient,
129
143
  queryKeys,
130
144
  version,
131
- mutations
145
+ mutations,
146
+ queryFactory
132
147
  },
133
148
  recoil: {
134
149
  enabled: plugin.includes('recoil'),
@@ -66,16 +66,17 @@ export default async (
66
66
  w.createExecuteInterface(
67
67
  context,
68
68
  Instance,
69
- ReadOnlyInstance,
69
+ context.options.client.execExtendsQuery ? ReadOnlyInstance : null,
70
70
  ExecuteMsg
71
71
  )
72
72
  );
73
+
73
74
  body.push(
74
75
  w.createExecuteClass(
75
76
  context,
76
77
  Client,
77
78
  Instance,
78
- QueryClient,
79
+ context.options.client.execExtendsQuery ? QueryClient : null,
79
80
  ExecuteMsg
80
81
  )
81
82
  );