wasm-ast-types 0.11.3 → 0.13.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.
Files changed (55) hide show
  1. package/main/client/test/ts-client.issue-71.test.js +103 -0
  2. package/main/context/context.js +2 -1
  3. package/main/utils/types.js +20 -7
  4. package/module/client/test/ts-client.issue-71.test.js +21 -0
  5. package/module/context/context.js +2 -1
  6. package/module/utils/types.js +20 -7
  7. package/package.json +5 -3
  8. package/src/client/client.ts +665 -0
  9. package/src/client/index.ts +1 -0
  10. package/src/client/test/__snapshots__/ts-client.account-nfts.spec.ts.snap +497 -0
  11. package/src/client/test/__snapshots__/ts-client.arrays-ref.spec.ts.snap +452 -0
  12. package/src/client/test/__snapshots__/ts-client.arrays.spec.ts.snap +101 -0
  13. package/src/client/test/__snapshots__/ts-client.cw-named-groups.test.ts.snap +141 -0
  14. package/src/client/test/__snapshots__/ts-client.cw-proposal-single.test.ts.snap +341 -0
  15. package/src/client/test/__snapshots__/ts-client.empty-enums.spec.ts.snap +20 -0
  16. package/src/client/test/__snapshots__/ts-client.issue-71.test.ts.snap +432 -0
  17. package/src/client/test/__snapshots__/ts-client.issues.test.ts.snap +984 -0
  18. package/src/client/test/__snapshots__/ts-client.sg721.spec.ts.snap +350 -0
  19. package/src/client/test/__snapshots__/ts-client.spec.ts.snap +723 -0
  20. package/src/client/test/__snapshots__/ts-client.vectis.spec.ts.snap +337 -0
  21. package/src/client/test/ts-client.account-nfts.spec.ts +55 -0
  22. package/src/client/test/ts-client.arrays-ref.spec.ts +48 -0
  23. package/src/client/test/ts-client.arrays.spec.ts +58 -0
  24. package/src/client/test/ts-client.cw-named-groups.test.ts +48 -0
  25. package/src/client/test/ts-client.cw-proposal-single.test.ts +50 -0
  26. package/src/client/test/ts-client.empty-enums.spec.ts +28 -0
  27. package/src/client/test/ts-client.issue-71.test.ts +51 -0
  28. package/src/client/test/ts-client.issues.test.ts +52 -0
  29. package/src/client/test/ts-client.sg721.spec.ts +46 -0
  30. package/src/client/test/ts-client.spec.ts +166 -0
  31. package/src/client/test/ts-client.vectis.spec.ts +97 -0
  32. package/src/context/context.ts +134 -0
  33. package/src/context/imports.ts +126 -0
  34. package/src/context/index.ts +2 -0
  35. package/src/index.ts +7 -0
  36. package/src/message-composer/__snapshots__/message-composer.spec.ts.snap +271 -0
  37. package/src/message-composer/index.ts +1 -0
  38. package/src/message-composer/message-composer.spec.ts +25 -0
  39. package/src/message-composer/message-composer.ts +305 -0
  40. package/src/react-query/__snapshots__/react-query.spec.ts.snap +913 -0
  41. package/src/react-query/index.ts +1 -0
  42. package/src/react-query/react-query.spec.ts +75 -0
  43. package/src/react-query/react-query.ts +913 -0
  44. package/src/recoil/__snapshots__/recoil.spec.ts.snap +203 -0
  45. package/src/recoil/index.ts +1 -0
  46. package/src/recoil/recoil.spec.ts +38 -0
  47. package/src/recoil/recoil.ts +307 -0
  48. package/src/types.ts +44 -0
  49. package/src/utils/__snapshots__/babel.spec.ts.snap +75 -0
  50. package/src/utils/babel.spec.ts +511 -0
  51. package/src/utils/babel.ts +315 -0
  52. package/src/utils/index.ts +2 -0
  53. package/src/utils/types.ts +459 -0
  54. package/types/client/client.d.ts +1 -1
  55. package/types/context/context.d.ts +1 -0
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
6
+
7
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
+
9
+ var _testUtils = require("../../../test-utils");
10
+
11
+ var _client = require("../client");
12
+
13
+ var _jestInCase = _interopRequireDefault(require("jest-in-case"));
14
+
15
+ var contracts = (0, _testUtils.globContracts)('issues/71');
16
+ (0, _jestInCase["default"])('execute_msg_for__empty', /*#__PURE__*/function () {
17
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(opts) {
18
+ var ctx;
19
+ return _regenerator["default"].wrap(function _callee$(_context) {
20
+ while (1) {
21
+ switch (_context.prev = _context.next) {
22
+ case 0:
23
+ ctx = (0, _testUtils.makeContext)(opts.content);
24
+ (0, _testUtils.expectCode)((0, _client.createTypeInterface)(ctx, opts.content));
25
+
26
+ case 2:
27
+ case "end":
28
+ return _context.stop();
29
+ }
30
+ }
31
+ }, _callee);
32
+ }));
33
+
34
+ return function (_x) {
35
+ return _ref.apply(this, arguments);
36
+ };
37
+ }(), contracts);
38
+ (0, _jestInCase["default"])('query classes', /*#__PURE__*/function () {
39
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(opts) {
40
+ var ctx;
41
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
42
+ while (1) {
43
+ switch (_context2.prev = _context2.next) {
44
+ case 0:
45
+ ctx = (0, _testUtils.makeContext)(opts.content);
46
+ (0, _testUtils.expectCode)((0, _client.createQueryClass)(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', opts.content));
47
+
48
+ case 2:
49
+ case "end":
50
+ return _context2.stop();
51
+ }
52
+ }
53
+ }, _callee2);
54
+ }));
55
+
56
+ return function (_x2) {
57
+ return _ref2.apply(this, arguments);
58
+ };
59
+ }(), contracts);
60
+ (0, _jestInCase["default"])('execute class', /*#__PURE__*/function () {
61
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(opts) {
62
+ var ctx;
63
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
64
+ while (1) {
65
+ switch (_context3.prev = _context3.next) {
66
+ case 0:
67
+ ctx = (0, _testUtils.makeContext)(opts.content);
68
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(ctx, 'SG721Client', 'SG721Instance', null, opts.content));
69
+
70
+ case 2:
71
+ case "end":
72
+ return _context3.stop();
73
+ }
74
+ }
75
+ }, _callee3);
76
+ }));
77
+
78
+ return function (_x3) {
79
+ return _ref3.apply(this, arguments);
80
+ };
81
+ }(), contracts);
82
+ (0, _jestInCase["default"])('execute interface', /*#__PURE__*/function () {
83
+ var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(opts) {
84
+ var ctx;
85
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
86
+ while (1) {
87
+ switch (_context4.prev = _context4.next) {
88
+ case 0:
89
+ ctx = (0, _testUtils.makeContext)(opts.content);
90
+ (0, _testUtils.expectCode)((0, _client.createExecuteInterface)(ctx, 'SG721Instance', null, opts.content));
91
+
92
+ case 2:
93
+ case "end":
94
+ return _context4.stop();
95
+ }
96
+ }
97
+ }, _callee4);
98
+ }));
99
+
100
+ return function (_x4) {
101
+ return _ref4.apply(this, arguments);
102
+ };
103
+ }(), contracts);
@@ -28,7 +28,8 @@ var defaultOptions = {
28
28
  aliasExecuteMsg: false
29
29
  },
30
30
  client: {
31
- enabled: true
31
+ enabled: true,
32
+ execExtendsQuery: true
32
33
  },
33
34
  recoil: {
34
35
  enabled: false
@@ -188,16 +188,29 @@ var getTypeInfo = function getTypeInfo(info) {
188
188
  }
189
189
 
190
190
  if (_nullableType === 'array' && (0, _typeof2["default"])(info.items) === 'object' && !Array.isArray(info.items)) {
191
- var _detect = detectType(info.items.type);
191
+ if (info.items.type) {
192
+ var _detect = detectType(info.items.type);
192
193
 
193
- if (_detect.type === 'array') {
194
- // wen recursion?
195
- type = t.tsArrayType(getArrayTypeFromItems(info.items));
194
+ if (_detect.type === 'array') {
195
+ // wen recursion?
196
+ type = t.tsArrayType(getArrayTypeFromItems(info.items));
197
+ } else {
198
+ type = t.tsArrayType(getType(_detect.type));
199
+ }
200
+
201
+ optional = _detect.optional;
202
+ } else if (info.items.$ref) {
203
+ type = getArrayTypeFromRef(info.items.$ref); // } else if (info.items.title) {
204
+ // type = t.tsArrayType(
205
+ // t.tsTypeReference(
206
+ // t.identifier(info.items.title)
207
+ // )
208
+ // );
209
+ } else if (info.items.type) {
210
+ type = getArrayTypeFromItems(info.items);
196
211
  } else {
197
- type = t.tsArrayType(getType(_detect.type));
212
+ throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
198
213
  }
199
-
200
- optional = _detect.optional;
201
214
  } else {
202
215
  var _detect2 = detectType(_nullableType);
203
216
 
@@ -0,0 +1,21 @@
1
+ import { globContracts, makeContext } from '../../../test-utils';
2
+ import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
3
+ import { expectCode } from '../../../test-utils';
4
+ import cases from 'jest-in-case';
5
+ const contracts = globContracts('issues/71');
6
+ cases('execute_msg_for__empty', async opts => {
7
+ const ctx = makeContext(opts.content);
8
+ expectCode(createTypeInterface(ctx, opts.content));
9
+ }, contracts);
10
+ cases('query classes', async opts => {
11
+ const ctx = makeContext(opts.content);
12
+ expectCode(createQueryClass(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', opts.content));
13
+ }, contracts);
14
+ cases('execute class', async opts => {
15
+ const ctx = makeContext(opts.content);
16
+ expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', null, opts.content));
17
+ }, contracts);
18
+ cases('execute interface', async opts => {
19
+ const ctx = makeContext(opts.content);
20
+ expectCode(createExecuteInterface(ctx, 'SG721Instance', null, opts.content));
21
+ }, contracts);
@@ -14,7 +14,8 @@ export const defaultOptions = {
14
14
  aliasExecuteMsg: false
15
15
  },
16
16
  client: {
17
- enabled: true
17
+ enabled: true,
18
+ execExtendsQuery: true
18
19
  },
19
20
  recoil: {
20
21
  enabled: false
@@ -146,16 +146,29 @@ export const getTypeInfo = info => {
146
146
  }
147
147
 
148
148
  if (nullableType === 'array' && typeof info.items === 'object' && !Array.isArray(info.items)) {
149
- const detect = detectType(info.items.type);
149
+ if (info.items.type) {
150
+ const detect = detectType(info.items.type);
150
151
 
151
- if (detect.type === 'array') {
152
- // wen recursion?
153
- type = t.tsArrayType(getArrayTypeFromItems(info.items));
152
+ if (detect.type === 'array') {
153
+ // wen recursion?
154
+ type = t.tsArrayType(getArrayTypeFromItems(info.items));
155
+ } else {
156
+ type = t.tsArrayType(getType(detect.type));
157
+ }
158
+
159
+ optional = detect.optional;
160
+ } else if (info.items.$ref) {
161
+ type = getArrayTypeFromRef(info.items.$ref); // } else if (info.items.title) {
162
+ // type = t.tsArrayType(
163
+ // t.tsTypeReference(
164
+ // t.identifier(info.items.title)
165
+ // )
166
+ // );
167
+ } else if (info.items.type) {
168
+ type = getArrayTypeFromItems(info.items);
154
169
  } else {
155
- type = t.tsArrayType(getType(detect.type));
170
+ throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
156
171
  }
157
-
158
- optional = detect.optional;
159
172
  } else {
160
173
  const detect = detectType(nullableType);
161
174
  optional = detect.optional;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasm-ast-types",
3
- "version": "0.11.3",
3
+ "version": "0.13.0",
4
4
  "description": "CosmWasm TypeScript AST generation",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/pyramation/cosmwasm-typescript-gen/tree/master/packages/wasm-ast-types#readme",
@@ -15,13 +15,15 @@
15
15
  "files": [
16
16
  "types",
17
17
  "main",
18
+ "src",
18
19
  "module"
19
20
  ],
20
21
  "scripts": {
21
22
  "build:main": "cross-env BABEL_ENV=production babel src --out-dir main --delete-dir-on-start --extensions \".tsx,.ts,.js\"",
22
23
  "build:module": "cross-env MODULE=true babel src --out-dir module --delete-dir-on-start --extensions \".tsx,.ts,.js\"",
23
- "build": "npm run build:module && npm run build:main",
24
24
  "build:ts": "tsc --project ./tsconfig.json",
25
+ "build": "npm run build:module && npm run build:main",
26
+ "buidl": "npm run build && npm run build:ts",
25
27
  "prepare": "npm run build",
26
28
  "lint": "eslint .",
27
29
  "format": "eslint . --fix",
@@ -86,5 +88,5 @@
86
88
  "case": "1.6.3",
87
89
  "deepmerge": "4.2.2"
88
90
  },
89
- "gitHead": "b7fc988703af9305db47b3259f7e2a95db4665ba"
91
+ "gitHead": "e46828bd476d30465a35a8021e611938abf89846"
90
92
  }