@cosmwasm/ts-codegen 0.14.2 → 0.15.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
@@ -47,8 +47,8 @@ The quickest and easiest way to interact with CosmWasm Contracts. `@cosmwasm/ts-
47
47
  Clone your project and `cd` into your contracts folder
48
48
 
49
49
  ```sh
50
- git clone git@github.com:public-awesome/stargaze-contracts.git
51
- cd stargaze-contracts/contracts/sg721/
50
+ git clone https://github.com/public-awesome/launchpad.git
51
+ cd launchpad/contracts/sg721-base/
52
52
  ```
53
53
 
54
54
  Run `cosmwasm-ts-codegen` to generate your code.
@@ -58,7 +58,8 @@ cosmwasm-ts-codegen generate \
58
58
  --plugin client \
59
59
  --schema ./schema \
60
60
  --out ./ts \
61
- --name SG721
61
+ --name SG721 \
62
+ --no-bundle
62
63
  ```
63
64
 
64
65
  The output will be in the folder specified by `--out`, enjoy!
@@ -404,7 +405,28 @@ cd contracts/sg721/
404
405
  cargo schema
405
406
  ```
406
407
  ### Exporting Schemas
407
- #### `cosmwasm_std` Examples
408
+ #### `cosmwasm v1.1` Example
409
+
410
+ Using the new `write_api` method, you can export schemas:
411
+
412
+ ```rs
413
+ use cosmwasm_schema::write_api;
414
+
415
+ pub use cw4::{AdminResponse, MemberListResponse, MemberResponse, TotalWeightResponse};
416
+ pub use cw4_group::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
417
+
418
+ fn main() {
419
+ write_api! {
420
+ instantiate: InstantiateMsg,
421
+ execute: ExecuteMsg,
422
+ query: QueryMsg,
423
+ }
424
+ }
425
+ ```
426
+
427
+ #### `cosmwasm_std` Example
428
+
429
+ Here is a legacy example:
408
430
 
409
431
  ```rs
410
432
  use cosmwasm_std::{Addr, CosmosMsg, Empty};
@@ -114,7 +114,7 @@ var TSBuilder = /*#__PURE__*/function () {
114
114
  key: "renderTypes",
115
115
  value: function () {
116
116
  var _renderTypes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(contract) {
117
- var _this$options$types, enabled, options, _yield$readSchemas, schemas, files;
117
+ var _this$options$types, enabled, options, contractInfo, files;
118
118
 
119
119
  return _regenerator["default"].wrap(function _callee$(_context) {
120
120
  while (1) {
@@ -136,16 +136,15 @@ var TSBuilder = /*#__PURE__*/function () {
136
136
  });
137
137
 
138
138
  case 5:
139
- _yield$readSchemas = _context.sent;
140
- schemas = _yield$readSchemas.schemas;
141
- _context.next = 9;
142
- return (0, _types["default"])(contract.name, schemas, this.outPath, options);
139
+ contractInfo = _context.sent;
140
+ _context.next = 8;
141
+ return (0, _types["default"])(contract.name, contractInfo, this.outPath, options);
143
142
 
144
- case 9:
143
+ case 8:
145
144
  files = _context.sent;
146
145
  [].push.apply(this.files, files);
147
146
 
148
- case 11:
147
+ case 10:
149
148
  case "end":
150
149
  return _context.stop();
151
150
  }
@@ -163,7 +162,7 @@ var TSBuilder = /*#__PURE__*/function () {
163
162
  key: "renderClient",
164
163
  value: function () {
165
164
  var _renderClient = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(contract) {
166
- var _this$options$client, enabled, options, _yield$readSchemas2, schemas, files;
165
+ var _this$options$client, enabled, options, contractInfo, files;
167
166
 
168
167
  return _regenerator["default"].wrap(function _callee2$(_context2) {
169
168
  while (1) {
@@ -185,16 +184,15 @@ var TSBuilder = /*#__PURE__*/function () {
185
184
  });
186
185
 
187
186
  case 5:
188
- _yield$readSchemas2 = _context2.sent;
189
- schemas = _yield$readSchemas2.schemas;
190
- _context2.next = 9;
191
- return (0, _client["default"])(contract.name, schemas, this.outPath, options);
187
+ contractInfo = _context2.sent;
188
+ _context2.next = 8;
189
+ return (0, _client["default"])(contract.name, contractInfo, this.outPath, options);
192
190
 
193
- case 9:
191
+ case 8:
194
192
  files = _context2.sent;
195
193
  [].push.apply(this.files, files);
196
194
 
197
- case 11:
195
+ case 10:
198
196
  case "end":
199
197
  return _context2.stop();
200
198
  }
@@ -212,7 +210,7 @@ var TSBuilder = /*#__PURE__*/function () {
212
210
  key: "renderRecoil",
213
211
  value: function () {
214
212
  var _renderRecoil = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(contract) {
215
- var _this$options$recoil, enabled, options, _yield$readSchemas3, schemas, files;
213
+ var _this$options$recoil, enabled, options, contractInfo, files;
216
214
 
217
215
  return _regenerator["default"].wrap(function _callee3$(_context3) {
218
216
  while (1) {
@@ -234,16 +232,15 @@ var TSBuilder = /*#__PURE__*/function () {
234
232
  });
235
233
 
236
234
  case 5:
237
- _yield$readSchemas3 = _context3.sent;
238
- schemas = _yield$readSchemas3.schemas;
239
- _context3.next = 9;
240
- return (0, _recoil["default"])(contract.name, schemas, this.outPath, options);
235
+ contractInfo = _context3.sent;
236
+ _context3.next = 8;
237
+ return (0, _recoil["default"])(contract.name, contractInfo, this.outPath, options);
241
238
 
242
- case 9:
239
+ case 8:
243
240
  files = _context3.sent;
244
241
  [].push.apply(this.files, files);
245
242
 
246
- case 11:
243
+ case 10:
247
244
  case "end":
248
245
  return _context3.stop();
249
246
  }
@@ -261,7 +258,7 @@ var TSBuilder = /*#__PURE__*/function () {
261
258
  key: "renderReactQuery",
262
259
  value: function () {
263
260
  var _renderReactQuery = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(contract) {
264
- var _this$options$reactQu, enabled, options, _yield$readSchemas4, schemas, files;
261
+ var _this$options$reactQu, enabled, options, contractInfo, files;
265
262
 
266
263
  return _regenerator["default"].wrap(function _callee4$(_context4) {
267
264
  while (1) {
@@ -283,16 +280,15 @@ var TSBuilder = /*#__PURE__*/function () {
283
280
  });
284
281
 
285
282
  case 5:
286
- _yield$readSchemas4 = _context4.sent;
287
- schemas = _yield$readSchemas4.schemas;
288
- _context4.next = 9;
289
- return (0, _reactQuery["default"])(contract.name, schemas, this.outPath, options);
283
+ contractInfo = _context4.sent;
284
+ _context4.next = 8;
285
+ return (0, _reactQuery["default"])(contract.name, contractInfo, this.outPath, options);
290
286
 
291
- case 9:
287
+ case 8:
292
288
  files = _context4.sent;
293
289
  [].push.apply(this.files, files);
294
290
 
295
- case 11:
291
+ case 10:
296
292
  case "end":
297
293
  return _context4.stop();
298
294
  }
@@ -310,7 +306,7 @@ var TSBuilder = /*#__PURE__*/function () {
310
306
  key: "renderMessageComposer",
311
307
  value: function () {
312
308
  var _renderMessageComposer = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(contract) {
313
- var _this$options$message, enabled, options, _yield$readSchemas5, schemas, files;
309
+ var _this$options$message, enabled, options, contractInfo, files;
314
310
 
315
311
  return _regenerator["default"].wrap(function _callee5$(_context5) {
316
312
  while (1) {
@@ -332,16 +328,15 @@ var TSBuilder = /*#__PURE__*/function () {
332
328
  });
333
329
 
334
330
  case 5:
335
- _yield$readSchemas5 = _context5.sent;
336
- schemas = _yield$readSchemas5.schemas;
337
- _context5.next = 9;
338
- return (0, _messageComposer["default"])(contract.name, schemas, this.outPath, options);
331
+ contractInfo = _context5.sent;
332
+ _context5.next = 8;
333
+ return (0, _messageComposer["default"])(contract.name, contractInfo, this.outPath, options);
339
334
 
340
- case 9:
335
+ case 8:
341
336
  files = _context5.sent;
342
337
  [].push.apply(this.files, files);
343
338
 
344
- case 11:
339
+ case 10:
345
340
  case "end":
346
341
  return _context5.stop();
347
342
  }
@@ -38,16 +38,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
38
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
39
 
40
40
  var _default = /*#__PURE__*/function () {
41
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, schemas, outPath, tsClientOptions) {
42
- var context, options, localname, TypesFile, QueryMsg, ExecuteMsg, typeHash, Client, Instance, QueryClient, ReadOnlyInstance, body, children, imports, code;
41
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, contractInfo, outPath, tsClientOptions) {
42
+ var schemas, context, localname, TypesFile, QueryMsg, ExecuteMsg, typeHash, Client, Instance, QueryClient, ReadOnlyInstance, body, children, imports, code;
43
43
  return _regenerator["default"].wrap(function _callee$(_context) {
44
44
  while (1) {
45
45
  switch (_context.prev = _context.next) {
46
46
  case 0:
47
- context = new w.RenderContext((0, _utils.getDefinitionSchema)(schemas), {
47
+ schemas = contractInfo.schemas;
48
+ context = new w.RenderContext(contractInfo, {
48
49
  client: tsClientOptions !== null && tsClientOptions !== void 0 ? tsClientOptions : {}
49
- });
50
- options = context.options.client;
50
+ }); // const options = context.options.client;
51
+
51
52
  localname = (0, _case.pascal)(name) + '.client.ts';
52
53
  TypesFile = (0, _case.pascal)(name) + '.types';
53
54
  QueryMsg = (0, _utils.findQueryMsg)(schemas);
@@ -38,16 +38,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
38
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
39
 
40
40
  var _default = /*#__PURE__*/function () {
41
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, schemas, outPath, messageComposerOptions) {
42
- var context, options, localname, TypesFile, ExecuteMsg, typeHash, body, children, TheClass, Interface, imports, code;
41
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, contractInfo, outPath, messageComposerOptions) {
42
+ var schemas, context, localname, TypesFile, ExecuteMsg, typeHash, body, children, TheClass, Interface, imports, code;
43
43
  return _regenerator["default"].wrap(function _callee$(_context) {
44
44
  while (1) {
45
45
  switch (_context.prev = _context.next) {
46
46
  case 0:
47
- context = new w.RenderContext((0, _utils.getDefinitionSchema)(schemas), {
47
+ schemas = contractInfo.schemas;
48
+ context = new w.RenderContext(contractInfo, {
48
49
  messageComposer: messageComposerOptions !== null && messageComposerOptions !== void 0 ? messageComposerOptions : {}
49
- });
50
- options = context.options.messageComposer;
50
+ }); // const options = context.options.messageComposer;
51
+
51
52
  localname = (0, _case.pascal)(name) + '.message-composer.ts';
52
53
  TypesFile = (0, _case.pascal)(name) + '.types';
53
54
  ExecuteMsg = (0, _utils.findExecuteMsg)(schemas);
@@ -38,13 +38,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
38
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
39
 
40
40
  var _default = /*#__PURE__*/function () {
41
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(contractName, schemas, outPath, reactQueryOptions) {
42
- var context, options, localname, ContractFile, TypesFile, QueryMsg, ExecuteMsg, typeHash, ExecuteClient, QueryClient, body, clientImports, shouldGenerateMutationHooks, imports, code;
41
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(contractName, contractInfo, outPath, reactQueryOptions) {
42
+ var schemas, context, options, localname, ContractFile, TypesFile, QueryMsg, ExecuteMsg, typeHash, ExecuteClient, QueryClient, body, clientImports, shouldGenerateMutationHooks, imports, code;
43
43
  return _regenerator["default"].wrap(function _callee$(_context) {
44
44
  while (1) {
45
45
  switch (_context.prev = _context.next) {
46
46
  case 0:
47
- context = new w.RenderContext((0, _utils.getDefinitionSchema)(schemas), {
47
+ schemas = contractInfo.schemas;
48
+ context = new w.RenderContext(contractInfo, {
48
49
  reactQuery: reactQueryOptions !== null && reactQueryOptions !== void 0 ? reactQueryOptions : {}
49
50
  });
50
51
  options = context.options.reactQuery;
@@ -53,10 +54,10 @@ var _default = /*#__PURE__*/function () {
53
54
  TypesFile = (0, _case.pascal)("".concat(contractName)) + '.types';
54
55
  QueryMsg = (0, _utils.findQueryMsg)(schemas);
55
56
  ExecuteMsg = (0, _utils.findExecuteMsg)(schemas);
56
- _context.next = 9;
57
+ _context.next = 10;
57
58
  return (0, _utils.findAndParseTypes)(schemas);
58
59
 
59
- case 9:
60
+ case 10:
60
61
  typeHash = _context.sent;
61
62
  ExecuteClient = (0, _case.pascal)("".concat(contractName, "Client"));
62
63
  QueryClient = (0, _case.pascal)("".concat(contractName, "QueryClient"));
@@ -108,7 +109,7 @@ var _default = /*#__PURE__*/function () {
108
109
  filename: (0, _path.join)(outPath, localname)
109
110
  }]);
110
111
 
111
- case 27:
112
+ case 28:
112
113
  case "end":
113
114
  return _context.stop();
114
115
  }
@@ -38,13 +38,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
38
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
39
 
40
40
  var _default = /*#__PURE__*/function () {
41
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, schemas, outPath, recoilOptions) {
42
- var context, options, localname, ContractFile, TypesFile, QueryMsg, typeHash, QueryClient, ReadOnlyInstance, body, imports, code;
41
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, contractInfo, outPath, recoilOptions) {
42
+ var schemas, context, options, localname, ContractFile, TypesFile, QueryMsg, typeHash, QueryClient, ReadOnlyInstance, body, imports, code;
43
43
  return _regenerator["default"].wrap(function _callee$(_context) {
44
44
  while (1) {
45
45
  switch (_context.prev = _context.next) {
46
46
  case 0:
47
- context = new w.RenderContext((0, _utils.getDefinitionSchema)(schemas), {
47
+ schemas = contractInfo.schemas;
48
+ context = new w.RenderContext(contractInfo, {
48
49
  recoil: recoilOptions !== null && recoilOptions !== void 0 ? recoilOptions : {}
49
50
  });
50
51
  options = context.options.recoil;
@@ -52,10 +53,10 @@ var _default = /*#__PURE__*/function () {
52
53
  ContractFile = (0, _case.pascal)(name) + '.client';
53
54
  TypesFile = (0, _case.pascal)(name) + '.types';
54
55
  QueryMsg = (0, _utils.findQueryMsg)(schemas);
55
- _context.next = 8;
56
+ _context.next = 9;
56
57
  return (0, _utils.findAndParseTypes)(schemas);
57
58
 
58
- case 8:
59
+ case 9:
59
60
  typeHash = _context.sent;
60
61
  QueryClient = null;
61
62
  ReadOnlyInstance = null;
@@ -87,7 +88,7 @@ var _default = /*#__PURE__*/function () {
87
88
  filename: (0, _path.join)(outPath, localname)
88
89
  }]);
89
90
 
90
- case 21:
91
+ case 22:
91
92
  case "end":
92
93
  return _context.stop();
93
94
  }
@@ -40,22 +40,23 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
40
40
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
41
 
42
42
  var _default = /*#__PURE__*/function () {
43
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, schemas, outPath, tsTypesOptions) {
44
- var context, options, localname, ExecuteMsg, typeHash, body, imports, code, filename;
43
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, contractInfo, outPath, tsTypesOptions) {
44
+ var schemas, context, options, localname, ExecuteMsg, typeHash, body, imports, code, filename;
45
45
  return _regenerator["default"].wrap(function _callee$(_context) {
46
46
  while (1) {
47
47
  switch (_context.prev = _context.next) {
48
48
  case 0:
49
- context = new _wasmAstTypes.RenderContext((0, _utils.getDefinitionSchema)(schemas), {
49
+ schemas = contractInfo.schemas;
50
+ context = new _wasmAstTypes.RenderContext(contractInfo, {
50
51
  types: tsTypesOptions !== null && tsTypesOptions !== void 0 ? tsTypesOptions : {}
51
52
  });
52
53
  options = context.options.types;
53
54
  localname = (0, _case.pascal)(name) + '.types.ts';
54
55
  ExecuteMsg = (0, _utils.findExecuteMsg)(schemas);
55
- _context.next = 6;
56
+ _context.next = 7;
56
57
  return (0, _utils.findAndParseTypes)(schemas);
57
58
 
58
- case 6:
59
+ case 7:
59
60
  typeHash = _context.sent;
60
61
  body = []; // TYPES
61
62
 
@@ -79,7 +80,7 @@ var _default = /*#__PURE__*/function () {
79
80
  filename: filename
80
81
  }]);
81
82
 
82
- case 16:
83
+ case 17:
83
84
  case "end":
84
85
  return _context.stop();
85
86
  }
@@ -5,12 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.readSchemas = exports.getDefinitionSchema = exports.findQueryMsg = exports.findExecuteMsg = exports.findAndParseTypes = void 0;
8
+ exports.readSchemas = exports.findQueryMsg = exports.findExecuteMsg = exports.findAndParseTypes = void 0;
9
9
 
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
11
 
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
13
 
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
14
16
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
17
 
16
18
  var _glob = require("glob");
@@ -27,7 +29,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
27
29
 
28
30
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
31
 
30
- ;
31
32
  ;
32
33
 
33
34
  var readSchemas = /*#__PURE__*/function () {
@@ -87,13 +88,14 @@ var readSchemas = /*#__PURE__*/function () {
87
88
 
88
89
  case 14:
89
90
  return _context.abrupt("return", {
90
- schemas: Object.values(fn({
91
+ schemas: [].concat((0, _toConsumableArray2["default"])(Object.values(fn({
91
92
  instantiate: instantiate,
92
93
  execute: execute,
93
94
  query: query,
94
95
  migrate: migrate,
95
96
  sudo: sudo
96
- })).filter(Boolean),
97
+ })).filter(Boolean)), (0, _toConsumableArray2["default"])(Object.values(fn(_objectSpread({}, responses))).filter(Boolean))),
98
+ responses: responses,
97
99
  idlObject: idlObject
98
100
  });
99
101
 
@@ -185,18 +187,4 @@ var findAndParseTypes = /*#__PURE__*/function () {
185
187
  };
186
188
  }();
187
189
 
188
- exports.findAndParseTypes = findAndParseTypes;
189
-
190
- var getDefinitionSchema = function getDefinitionSchema(schemas) {
191
- var aggregateSchema = {
192
- definitions: {//
193
- }
194
- };
195
- schemas.forEach(function (schema) {
196
- schema.definitions = schema.definitions || {};
197
- aggregateSchema.definitions = _objectSpread(_objectSpread({}, aggregateSchema.definitions), schema.definitions);
198
- });
199
- return aggregateSchema;
200
- };
201
-
202
- exports.getDefinitionSchema = getDefinitionSchema;
190
+ exports.findAndParseTypes = findAndParseTypes;
@@ -77,12 +77,10 @@ export class TSBuilder {
77
77
  options = _objectWithoutProperties(_this$options$types, _excluded);
78
78
 
79
79
  if (!enabled) return;
80
- const {
81
- schemas
82
- } = await readSchemas({
80
+ const contractInfo = await readSchemas({
83
81
  schemaDir: contract.dir
84
82
  });
85
- const files = await generateTypes(contract.name, schemas, this.outPath, options);
83
+ const files = await generateTypes(contract.name, contractInfo, this.outPath, options);
86
84
  [].push.apply(this.files, files);
87
85
  }
88
86
 
@@ -94,12 +92,10 @@ export class TSBuilder {
94
92
  options = _objectWithoutProperties(_this$options$client, _excluded2);
95
93
 
96
94
  if (!enabled) return;
97
- const {
98
- schemas
99
- } = await readSchemas({
95
+ const contractInfo = await readSchemas({
100
96
  schemaDir: contract.dir
101
97
  });
102
- const files = await generateClient(contract.name, schemas, this.outPath, options);
98
+ const files = await generateClient(contract.name, contractInfo, this.outPath, options);
103
99
  [].push.apply(this.files, files);
104
100
  }
105
101
 
@@ -111,12 +107,10 @@ export class TSBuilder {
111
107
  options = _objectWithoutProperties(_this$options$recoil, _excluded3);
112
108
 
113
109
  if (!enabled) return;
114
- const {
115
- schemas
116
- } = await readSchemas({
110
+ const contractInfo = await readSchemas({
117
111
  schemaDir: contract.dir
118
112
  });
119
- const files = await generateRecoil(contract.name, schemas, this.outPath, options);
113
+ const files = await generateRecoil(contract.name, contractInfo, this.outPath, options);
120
114
  [].push.apply(this.files, files);
121
115
  }
122
116
 
@@ -128,12 +122,10 @@ export class TSBuilder {
128
122
  options = _objectWithoutProperties(_this$options$reactQu, _excluded4);
129
123
 
130
124
  if (!enabled) return;
131
- const {
132
- schemas
133
- } = await readSchemas({
125
+ const contractInfo = await readSchemas({
134
126
  schemaDir: contract.dir
135
127
  });
136
- const files = await generateReactQuery(contract.name, schemas, this.outPath, options);
128
+ const files = await generateReactQuery(contract.name, contractInfo, this.outPath, options);
137
129
  [].push.apply(this.files, files);
138
130
  }
139
131
 
@@ -145,12 +137,10 @@ export class TSBuilder {
145
137
  options = _objectWithoutProperties(_this$options$message, _excluded5);
146
138
 
147
139
  if (!enabled) return;
148
- const {
149
- schemas
150
- } = await readSchemas({
140
+ const contractInfo = await readSchemas({
151
141
  schemaDir: contract.dir
152
142
  });
153
- const files = await generateMessageComposer(contract.name, schemas, this.outPath, options);
143
+ const files = await generateMessageComposer(contract.name, contractInfo, this.outPath, options);
154
144
  [].push.apply(this.files, files);
155
145
  }
156
146
 
@@ -7,13 +7,16 @@ import * as t from '@babel/types';
7
7
  import { writeFileSync } from 'fs';
8
8
  import generate from "@babel/generator";
9
9
  import { getMessageProperties } from "wasm-ast-types";
10
- import { findAndParseTypes, findExecuteMsg, findQueryMsg, getDefinitionSchema } from '../utils';
10
+ import { findAndParseTypes, findExecuteMsg, findQueryMsg } from '../utils';
11
11
  import { RenderContext } from "wasm-ast-types";
12
- export default (async (name, schemas, outPath, tsClientOptions) => {
13
- const context = new RenderContext(getDefinitionSchema(schemas), {
12
+ export default (async (name, contractInfo, outPath, tsClientOptions) => {
13
+ const {
14
+ schemas
15
+ } = contractInfo;
16
+ const context = new RenderContext(contractInfo, {
14
17
  client: tsClientOptions ?? {}
15
- });
16
- const options = context.options.client;
18
+ }); // const options = context.options.client;
19
+
17
20
  const localname = pascal(name) + '.client.ts';
18
21
  const TypesFile = pascal(name) + '.types';
19
22
  const QueryMsg = findQueryMsg(schemas);
@@ -7,13 +7,16 @@ import * as t from '@babel/types';
7
7
  import { writeFileSync } from 'fs';
8
8
  import generate from "@babel/generator";
9
9
  import { getMessageProperties } from "wasm-ast-types";
10
- import { findAndParseTypes, findExecuteMsg, getDefinitionSchema } from "../utils";
10
+ import { findAndParseTypes, findExecuteMsg } from "../utils";
11
11
  import { RenderContext } from "wasm-ast-types";
12
- export default (async (name, schemas, outPath, messageComposerOptions) => {
13
- const context = new RenderContext(getDefinitionSchema(schemas), {
12
+ export default (async (name, contractInfo, outPath, messageComposerOptions) => {
13
+ const {
14
+ schemas
15
+ } = contractInfo;
16
+ const context = new RenderContext(contractInfo, {
14
17
  messageComposer: messageComposerOptions ?? {}
15
- });
16
- const options = context.options.messageComposer;
18
+ }); // const options = context.options.messageComposer;
19
+
17
20
  const localname = pascal(name) + '.message-composer.ts';
18
21
  const TypesFile = pascal(name) + '.types';
19
22
  const ExecuteMsg = findExecuteMsg(schemas);
@@ -7,10 +7,13 @@ import { RenderContext } from 'wasm-ast-types';
7
7
  import * as t from '@babel/types';
8
8
  import { writeFileSync } from 'fs';
9
9
  import generate from "@babel/generator";
10
- import { findAndParseTypes, findExecuteMsg, findQueryMsg, getDefinitionSchema } from '../utils';
10
+ import { findAndParseTypes, findExecuteMsg, findQueryMsg } from '../utils';
11
11
  import { getMessageProperties } from "wasm-ast-types";
12
- export default (async (contractName, schemas, outPath, reactQueryOptions) => {
13
- const context = new RenderContext(getDefinitionSchema(schemas), {
12
+ export default (async (contractName, contractInfo, outPath, reactQueryOptions) => {
13
+ const {
14
+ schemas
15
+ } = contractInfo;
16
+ const context = new RenderContext(contractInfo, {
14
17
  reactQuery: reactQueryOptions ?? {}
15
18
  });
16
19
  const options = context.options.reactQuery;
@@ -6,10 +6,13 @@ import * as w from 'wasm-ast-types';
6
6
  import * as t from '@babel/types';
7
7
  import { writeFileSync } from 'fs';
8
8
  import generate from "@babel/generator";
9
- import { findAndParseTypes, findQueryMsg, getDefinitionSchema } from "../utils";
9
+ import { findAndParseTypes, findQueryMsg } from "../utils";
10
10
  import { RenderContext } from "wasm-ast-types";
11
- export default (async (name, schemas, outPath, recoilOptions) => {
12
- const context = new RenderContext(getDefinitionSchema(schemas), {
11
+ export default (async (name, contractInfo, outPath, recoilOptions) => {
12
+ const {
13
+ schemas
14
+ } = contractInfo;
15
+ const context = new RenderContext(contractInfo, {
13
16
  recoil: recoilOptions ?? {}
14
17
  });
15
18
  const options = context.options.recoil;
@@ -6,10 +6,13 @@ import * as t from '@babel/types';
6
6
  import { writeFileSync } from 'fs';
7
7
  import generate from "@babel/generator";
8
8
  import { clean } from "../utils/clean";
9
- import { findAndParseTypes, findExecuteMsg, getDefinitionSchema } from '../utils';
9
+ import { findAndParseTypes, findExecuteMsg } from '../utils';
10
10
  import { RenderContext } from "wasm-ast-types";
11
- export default (async (name, schemas, outPath, tsTypesOptions) => {
12
- const context = new RenderContext(getDefinitionSchema(schemas), {
11
+ export default (async (name, contractInfo, outPath, tsTypesOptions) => {
12
+ const {
13
+ schemas
14
+ } = contractInfo;
15
+ const context = new RenderContext(contractInfo, {
13
16
  types: tsTypesOptions ?? {}
14
17
  });
15
18
  const options = context.options.types;
@@ -10,7 +10,6 @@ import { cleanse } from './cleanse';
10
10
  import { compile } from '@pyramation/json-schema-to-typescript';
11
11
  import { parser } from './parse';
12
12
  ;
13
- ;
14
13
  export const readSchemas = async ({
15
14
  schemaDir,
16
15
  clean = true
@@ -57,13 +56,14 @@ export const readSchemas = async ({
57
56
 
58
57
 
59
58
  return {
60
- schemas: Object.values(fn({
59
+ schemas: [...Object.values(fn({
61
60
  instantiate,
62
61
  execute,
63
62
  query,
64
63
  migrate,
65
64
  sudo
66
- })).filter(Boolean),
65
+ })).filter(Boolean), ...Object.values(fn(_objectSpread({}, responses))).filter(Boolean)],
66
+ responses,
67
67
  idlObject
68
68
  };
69
69
  };
@@ -94,15 +94,4 @@ export const findAndParseTypes = async schemas => {
94
94
 
95
95
  const typeHash = parser(allTypes);
96
96
  return typeHash;
97
- };
98
- export const getDefinitionSchema = schemas => {
99
- const aggregateSchema = {
100
- definitions: {//
101
- }
102
- };
103
- schemas.forEach(schema => {
104
- schema.definitions = schema.definitions || {};
105
- aggregateSchema.definitions = _objectSpread(_objectSpread({}, aggregateSchema.definitions), schema.definitions);
106
- });
107
- return aggregateSchema;
108
97
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmwasm/ts-codegen",
3
- "version": "0.14.2",
3
+ "version": "0.15.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",
@@ -94,7 +94,7 @@
94
94
  "parse-package-name": "1.0.0",
95
95
  "rimraf": "3.0.2",
96
96
  "shelljs": "0.8.5",
97
- "wasm-ast-types": "^0.9.0"
97
+ "wasm-ast-types": "^0.10.0"
98
98
  },
99
- "gitHead": "f1b4bb730177be7342b0867c162cc7edf5ce3a29"
99
+ "gitHead": "94c5785d947e329df1cc9108cc33bb7a0c21af60"
100
100
  }
package/main/types.js DELETED
@@ -1 +0,0 @@
1
- "use strict";
package/module/types.js DELETED
@@ -1 +0,0 @@
1
- export {};