wasm-ast-types 0.8.1 → 0.10.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 (39) hide show
  1. package/main/client/client.js +2 -2
  2. package/main/client/test/ts-client.arrays-ref.spec.js +1 -3
  3. package/main/client/test/ts-client.arrays.spec.js +1 -3
  4. package/main/client/test/ts-client.cw-named-groups.test.js +1 -3
  5. package/main/client/test/ts-client.cw-proposal-single.test.js +4 -6
  6. package/main/client/test/ts-client.empty-enums.spec.js +1 -3
  7. package/main/client/test/ts-client.issues.test.js +103 -0
  8. package/main/client/test/ts-client.sg721.spec.js +1 -3
  9. package/main/client/test/ts-client.spec.js +17 -19
  10. package/main/client/test/ts-client.vectis.spec.js +9 -11
  11. package/main/context/context.js +27 -5
  12. package/main/message-composer/message-composer.spec.js +2 -4
  13. package/main/react-query/react-query.js +106 -28
  14. package/main/react-query/react-query.spec.js +5 -7
  15. package/main/recoil/recoil.js +3 -3
  16. package/main/recoil/recoil.spec.js +2 -4
  17. package/main/utils/types.js +13 -1
  18. package/module/client/client.js +4 -4
  19. package/module/client/test/ts-client.arrays-ref.spec.js +2 -3
  20. package/module/client/test/ts-client.arrays.spec.js +2 -3
  21. package/module/client/test/ts-client.cw-named-groups.test.js +2 -3
  22. package/module/client/test/ts-client.cw-proposal-single.test.js +5 -6
  23. package/module/client/test/ts-client.empty-enums.spec.js +2 -3
  24. package/module/client/test/ts-client.issues.test.js +21 -0
  25. package/module/client/test/ts-client.sg721.spec.js +2 -3
  26. package/module/client/test/ts-client.spec.js +18 -19
  27. package/module/client/test/ts-client.vectis.spec.js +10 -11
  28. package/module/context/context.js +25 -4
  29. package/module/message-composer/message-composer.spec.js +3 -4
  30. package/module/react-query/react-query.js +99 -20
  31. package/module/react-query/react-query.spec.js +6 -7
  32. package/module/recoil/recoil.js +4 -4
  33. package/module/recoil/recoil.spec.js +3 -4
  34. package/module/utils/types.js +7 -1
  35. package/package.json +2 -2
  36. package/types/context/context.d.ts +26 -3
  37. package/types/react-query/react-query.d.ts +3 -2
  38. package/types/recoil/recoil.d.ts +1 -1
  39. package/types/utils/types.d.ts +1 -0
@@ -34,17 +34,38 @@ var createReactQueryHooks = function createReactQueryHooks(_ref) {
34
34
  QueryClient = _ref.QueryClient;
35
35
  var options = context.options.reactQuery;
36
36
  var genericQueryInterfaceName = "".concat((0, _case.pascal)(contractName), "ReactQuery");
37
- var body = [createReactQueryHookGenericInterface({
37
+ var underscoreNames = (0, _utils.getMessageProperties)(queryMsg).map(function (schema) {
38
+ return Object.keys(schema.properties)[0];
39
+ });
40
+ var body = [];
41
+ var queryKeysName = "".concat((0, _case.camel)(contractName), "QueryKeys");
42
+
43
+ if (options.queryKeys) {
44
+ body.push(createReactQueryKeys({
45
+ context: context,
46
+ queryKeysName: queryKeysName,
47
+ camelContractName: (0, _case.camel)(contractName),
48
+ underscoreNames: underscoreNames
49
+ }));
50
+ }
51
+
52
+ body.push(createReactQueryHookGenericInterface({
38
53
  context: context,
39
54
  QueryClient: QueryClient,
40
55
  genericQueryInterfaceName: genericQueryInterfaceName
41
- })];
56
+ }));
42
57
  body.push.apply(body, (0, _toConsumableArray2["default"])((0, _utils.getMessageProperties)(queryMsg).reduce(function (m, schema) {
43
- var underscoreName = Object.keys(schema.properties)[0];
44
- var methodName = (0, _case.camel)(underscoreName);
45
- var hookParamsTypeName = "".concat((0, _case.pascal)(contractName)).concat((0, _case.pascal)(methodName), "Query");
46
- var hookName = "use".concat(hookParamsTypeName);
47
- var responseType = (0, _case.pascal)("".concat(methodName, "Response"));
58
+ // list_voters
59
+ var underscoreName = Object.keys(schema.properties)[0]; // listVoters
60
+
61
+ var methodName = (0, _case.camel)(underscoreName); // Cw3FlexMultisigListVotersQuery
62
+
63
+ var hookParamsTypeName = "".concat((0, _case.pascal)(contractName)).concat((0, _case.pascal)(methodName), "Query"); // useCw3FlexMultisigListVotersQuery
64
+
65
+ var hookName = "use".concat(hookParamsTypeName); // listVotersResponse
66
+
67
+ var responseType = (0, _types2.getResponseType)(context, underscoreName); // cw3FlexMultisigListVoters
68
+
48
69
  var getterKey = (0, _case.camel)("".concat(contractName).concat((0, _case.pascal)(methodName)));
49
70
  var jsonschema = schema.properties[underscoreName];
50
71
  return [createReactQueryHookInterface({
@@ -59,6 +80,7 @@ var createReactQueryHooks = function createReactQueryHooks(_ref) {
59
80
  methodName: methodName,
60
81
  hookName: hookName,
61
82
  hookParamsTypeName: hookParamsTypeName,
83
+ queryKeysName: queryKeysName,
62
84
  responseType: responseType,
63
85
  hookKeyName: getterKey,
64
86
  jsonschema: jsonschema
@@ -77,6 +99,7 @@ var createReactQueryHook = function createReactQueryHook(_ref2) {
77
99
  hookParamsTypeName = _ref2.hookParamsTypeName,
78
100
  responseType = _ref2.responseType,
79
101
  hookKeyName = _ref2.hookKeyName,
102
+ queryKeysName = _ref2.queryKeysName,
80
103
  methodName = _ref2.methodName,
81
104
  jsonschema = _ref2.jsonschema;
82
105
  context.addUtil('useQuery');
@@ -97,10 +120,20 @@ var createReactQueryHook = function createReactQueryHook(_ref2) {
97
120
  props = ['client', 'args', 'options'];
98
121
  }
99
122
 
100
- return t.exportNamedDeclaration(t.functionDeclaration(t.identifier(hookName), [(0, _utils.tsObjectPattern)((0, _toConsumableArray2["default"])(props.map(function (prop) {
123
+ var selectResponseGenericTypeName = 'TData';
124
+ var queryFunctionDeclaration = t.functionDeclaration(t.identifier(hookName), [(0, _utils.tsObjectPattern)((0, _toConsumableArray2["default"])(props.map(function (prop) {
101
125
  return t.objectProperty(t.identifier(prop), t.identifier(prop), false, true);
102
- })), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName))))], t.blockStatement([t.returnStatement((0, _utils.callExpression)(t.identifier('useQuery'), [t.arrayExpression(generateUseQueryQueryKey(hookKeyName, props, options.optionalClient)), t.arrowFunctionExpression([], (0, _babel.optionalConditionalExpression)(t.identifier('client'), t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), t.callExpression(t.memberExpression(t.identifier('Promise'), t.identifier('reject')), [t.newExpression(t.identifier('Error'), [t.stringLiteral('Invalid client')])]), options.optionalClient), false), options.optionalClient ? t.objectExpression([t.spreadElement(t.identifier('options')), t.objectProperty(t.identifier('enabled'), t.logicalExpression('&&', t.unaryExpression('!', t.unaryExpression('!', t.identifier('client'))), t.conditionalExpression( // explicitly check for undefined
103
- t.binaryExpression('!=', t.optionalMemberExpression(t.identifier('options'), t.identifier('enabled'), false, true), t.identifier('undefined')), t.memberExpression(t.identifier('options'), t.identifier('enabled')), t.booleanLiteral(true))))]) : t.identifier('options')], t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(responseType)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))])))])));
126
+ })), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(selectResponseGenericTypeName))]))))], t.blockStatement([t.returnStatement((0, _utils.callExpression)(t.identifier('useQuery'), [generateUseQueryQueryKey({
127
+ hookKeyName: hookKeyName,
128
+ queryKeysName: queryKeysName,
129
+ methodName: methodName,
130
+ props: props,
131
+ options: options
132
+ }), t.arrowFunctionExpression([], (0, _babel.optionalConditionalExpression)(t.identifier('client'), t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), t.callExpression(t.memberExpression(t.identifier('Promise'), t.identifier('reject')), [t.newExpression(t.identifier('Error'), [t.stringLiteral('Invalid client')])]), options.optionalClient), false), options.optionalClient ? t.objectExpression([t.spreadElement(t.identifier('options')), t.objectProperty(t.identifier('enabled'), t.logicalExpression('&&', t.unaryExpression('!', t.unaryExpression('!', t.identifier('client'))), t.conditionalExpression( // explicitly check for undefined
133
+ t.binaryExpression('!=', t.optionalMemberExpression(t.identifier('options'), t.identifier('enabled'), false, true), t.identifier('undefined')), t.memberExpression(t.identifier('options'), t.identifier('enabled')), t.booleanLiteral(true))))]) : t.identifier('options')], t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(selectResponseGenericTypeName))])))])); // Add the TData type parameters
134
+
135
+ queryFunctionDeclaration.typeParameters = t.tsTypeParameterDeclaration([t.tsTypeParameter(undefined, t.tSTypeReference(t.identifier(responseType)), selectResponseGenericTypeName)]);
136
+ return t.exportNamedDeclaration(queryFunctionDeclaration);
104
137
  };
105
138
 
106
139
  exports.createReactQueryHook = createReactQueryHook;
@@ -237,25 +270,52 @@ var createReactQueryMutationHook = function createReactQueryMutationHook(_ref5)
237
270
 
238
271
  exports.createReactQueryMutationHook = createReactQueryMutationHook;
239
272
 
240
- function createReactQueryHookGenericInterface(_ref6) {
273
+ function createReactQueryKeys(_ref6) {
241
274
  var context = _ref6.context,
242
- QueryClient = _ref6.QueryClient,
243
- genericQueryInterfaceName = _ref6.genericQueryInterfaceName;
275
+ queryKeysName = _ref6.queryKeysName,
276
+ camelContractName = _ref6.camelContractName,
277
+ underscoreNames = _ref6.underscoreNames;
244
278
  var options = context.options.reactQuery;
245
- var genericTypeName = 'TResponse';
246
- context.addUtil('UseQueryOptions');
247
- var typedUseQueryOptions = t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(genericTypeName)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(genericTypeName)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))]));
248
- var body = [(0, _utils.tsPropertySignature)(t.identifier('client'), t.tsTypeAnnotation(options.optionalClient ? t.tsUnionType([t.tsTypeReference(t.identifier(QueryClient)), t.tsUndefinedKeyword()]) : t.tsTypeReference(t.identifier(QueryClient))), false), (0, _utils.tsPropertySignature)(t.identifier('options'), t.tsTypeAnnotation(options.version === 'v4' ? t.tSIntersectionType([(0, _babel.omitTypeReference)(typedUseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'"), t.tSTypeLiteral([t.tsPropertySignature(t.identifier('initialData?'), t.tsTypeAnnotation(t.tsUndefinedKeyword()))])]) : typedUseQueryOptions), true)];
249
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(genericQueryInterfaceName), t.tsTypeParameterDeclaration([t.tsTypeParameter(undefined, undefined, genericTypeName)]), [], t.tSInterfaceBody(body)));
279
+ var contractAddressTypeAnnotation = t.tsTypeAnnotation(options.optionalClient ? t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()]) : t.tSStringKeyword());
280
+ return t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(t.identifier(queryKeysName), t.objectExpression([// 1: contract
281
+ t.objectProperty(t.identifier('contract'), t.tSAsExpression(t.arrayExpression([t.objectExpression([t.objectProperty(t.identifier('contract'), t.stringLiteral(camelContractName))])]), t.tSTypeReference(t.identifier('const')))), // 2: address
282
+ t.objectProperty(t.identifier('address'), t.arrowFunctionExpression([(0, _utils.identifier)('contractAddress', contractAddressTypeAnnotation)], t.tSAsExpression(t.arrayExpression([t.objectExpression([// 1
283
+ t.spreadElement(t.memberExpression(t.memberExpression(t.identifier(queryKeysName), t.identifier('contract')), t.numericLiteral(0), true // computed
284
+ )), t.objectProperty(t.identifier('address'), t.identifier('contractAddress'))])]), t.tSTypeReference(t.identifier('const')))))].concat((0, _toConsumableArray2["default"])(underscoreNames.map(function (underscoreMethodName) {
285
+ return t.objectProperty( // key id is the camel method name
286
+ t.identifier((0, _case.camel)(underscoreMethodName)), t.arrowFunctionExpression([(0, _utils.identifier)('contractAddress', contractAddressTypeAnnotation), (0, _utils.identifier)('args', // Record<string, unknown>
287
+ t.tSTypeAnnotation(t.tsTypeReference(t.identifier('Record'), t.tsTypeParameterInstantiation([t.tsStringKeyword(), t.tsUnknownKeyword()]))), true // optional
288
+ )], t.tSAsExpression(t.arrayExpression([t.objectExpression([//...cw3FlexMultisigQueryKeys.address(contractAddress)[0]
289
+ t.spreadElement(t.memberExpression(t.callExpression(t.memberExpression(t.identifier(queryKeysName), t.identifier('address')), [t.identifier('contractAddress')]), t.numericLiteral(0), true // computed
290
+ )), // method: list_voters
291
+ t.objectProperty(t.identifier('method'), t.stringLiteral(underscoreMethodName)), // args
292
+ (0, _babel.shorthandProperty)('args')])]), t.tSTypeReference(t.identifier('const')))));
293
+ })))))]));
250
294
  }
251
295
 
252
- var createReactQueryHookInterface = function createReactQueryHookInterface(_ref7) {
296
+ function createReactQueryHookGenericInterface(_ref7) {
253
297
  var context = _ref7.context,
254
298
  QueryClient = _ref7.QueryClient,
255
- hookParamsTypeName = _ref7.hookParamsTypeName,
256
- queryInterfaceName = _ref7.queryInterfaceName,
257
- responseType = _ref7.responseType,
258
- jsonschema = _ref7.jsonschema;
299
+ genericQueryInterfaceName = _ref7.genericQueryInterfaceName;
300
+ var options = context.options.reactQuery;
301
+ var genericResponseTypeName = 'TResponse';
302
+ var genericSelectResponseTypeName = 'TData';
303
+ context.addUtil('UseQueryOptions'); // UseQueryOptions<TResponse, Error, TData>,
304
+
305
+ var typedUseQueryOptions = t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(genericResponseTypeName)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(genericSelectResponseTypeName))]));
306
+ var body = [(0, _utils.tsPropertySignature)(t.identifier('client'), t.tsTypeAnnotation(options.optionalClient ? t.tsUnionType([t.tsTypeReference(t.identifier(QueryClient)), t.tsUndefinedKeyword()]) : t.tsTypeReference(t.identifier(QueryClient))), false), (0, _utils.tsPropertySignature)(t.identifier('options'), t.tsTypeAnnotation(options.version === 'v4' ? t.tSIntersectionType([(0, _babel.omitTypeReference)(typedUseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'"), t.tSTypeLiteral([t.tsPropertySignature(t.identifier('initialData?'), t.tsTypeAnnotation(t.tsUndefinedKeyword()))])]) : typedUseQueryOptions), true)];
307
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(genericQueryInterfaceName), t.tsTypeParameterDeclaration([// 1: TResponse
308
+ t.tsTypeParameter(undefined, undefined, genericResponseTypeName), // 2: TData
309
+ t.tsTypeParameter(undefined, t.tSTypeReference(t.identifier(genericResponseTypeName)), genericSelectResponseTypeName)]), [], t.tSInterfaceBody(body)));
310
+ }
311
+
312
+ var createReactQueryHookInterface = function createReactQueryHookInterface(_ref8) {
313
+ var context = _ref8.context,
314
+ QueryClient = _ref8.QueryClient,
315
+ hookParamsTypeName = _ref8.hookParamsTypeName,
316
+ queryInterfaceName = _ref8.queryInterfaceName,
317
+ responseType = _ref8.responseType,
318
+ jsonschema = _ref8.jsonschema;
259
319
  // merge the user options with the defaults
260
320
  var options = context.options.reactQuery;
261
321
  var body = [];
@@ -266,7 +326,9 @@ var createReactQueryHookInterface = function createReactQueryHookInterface(_ref7
266
326
  t.tsTypeLiteral(props))));
267
327
  }
268
328
 
269
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), null, [t.tSExpressionWithTypeArguments(t.identifier(queryInterfaceName), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType))]))], t.tsInterfaceBody(body)));
329
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), t.tsTypeParameterDeclaration([t.tSTypeParameter(undefined, undefined, 'TData')]), [t.tSExpressionWithTypeArguments(t.identifier(queryInterfaceName), t.tsTypeParameterInstantiation([// 1: response
330
+ t.tsTypeReference(t.identifier(responseType)), // 2: select generic
331
+ t.tSTypeReference(t.identifier('TData'))]))], t.tsInterfaceBody(body)));
270
332
  };
271
333
 
272
334
  exports.createReactQueryHookInterface = createReactQueryHookInterface;
@@ -285,12 +347,28 @@ var getProps = function getProps(context, jsonschema) {
285
347
  });
286
348
  };
287
349
 
288
- var generateUseQueryQueryKey = function generateUseQueryQueryKey(hookKeyName, props, optionalClient) {
289
- var queryKey = [t.stringLiteral(hookKeyName), t.optionalMemberExpression(t.identifier('client'), t.identifier('contractAddress'), false, optionalClient)];
350
+ var generateUseQueryQueryKey = function generateUseQueryQueryKey(_ref9) {
351
+ var hookKeyName = _ref9.hookKeyName,
352
+ queryKeysName = _ref9.queryKeysName,
353
+ methodName = _ref9.methodName,
354
+ props = _ref9.props,
355
+ options = _ref9.options;
356
+ var optionalClient = options.optionalClient,
357
+ queryKeys = options.queryKeys;
358
+ var hasArgs = props.includes('args');
359
+ var contractAddressExpression = t.optionalMemberExpression(t.identifier('client'), t.identifier('contractAddress'), false, optionalClient);
360
+
361
+ if (queryKeys) {
362
+ var callArgs = [contractAddressExpression];
363
+ if (hasArgs) callArgs.push(t.identifier('args'));
364
+ return t.callExpression(t.memberExpression(t.identifier(queryKeysName), t.identifier((0, _case.camel)(methodName))), callArgs);
365
+ }
366
+
367
+ var queryKey = [t.stringLiteral(hookKeyName), contractAddressExpression];
290
368
 
291
- if (props.includes('args')) {
369
+ if (hasArgs) {
292
370
  queryKey.push(t.callExpression(t.memberExpression(t.identifier('JSON'), t.identifier('stringify')), [t.identifier('args')]));
293
371
  }
294
372
 
295
- return queryKey;
373
+ return t.arrayExpression(queryKey);
296
374
  };
@@ -10,8 +10,6 @@ var _query_msg = _interopRequireDefault(require("../../../../__fixtures__/basic/
10
10
 
11
11
  var _execute_msg_for__empty = _interopRequireDefault(require("../../../../__fixtures__/basic/execute_msg_for__empty.json"));
12
12
 
13
- var _context = require("../context");
14
-
15
13
  var _reactQuery = require("./react-query");
16
14
 
17
15
  var _testUtils = require("../../test-utils");
@@ -20,8 +18,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
20
18
 
21
19
  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; }
22
20
 
23
- var execCtx = new _context.RenderContext(_execute_msg_for__empty["default"]);
24
- var queryCtx = new _context.RenderContext(_query_msg["default"]);
21
+ var execCtx = (0, _testUtils.makeContext)(_execute_msg_for__empty["default"]);
22
+ var queryCtx = (0, _testUtils.makeContext)(_query_msg["default"]);
25
23
  it('createReactQueryHooks', function () {
26
24
  (0, _testUtils.expectCode)(t.program((0, _reactQuery.createReactQueryHooks)({
27
25
  context: queryCtx,
@@ -30,7 +28,7 @@ it('createReactQueryHooks', function () {
30
28
  QueryClient: 'Sg721QueryClient'
31
29
  })));
32
30
  (0, _testUtils.expectCode)(t.program((0, _reactQuery.createReactQueryHooks)({
33
- context: new _context.RenderContext(_query_msg["default"], {
31
+ context: (0, _testUtils.makeContext)(_query_msg["default"], {
34
32
  reactQuery: {
35
33
  optionalClient: true
36
34
  }
@@ -40,7 +38,7 @@ it('createReactQueryHooks', function () {
40
38
  QueryClient: 'Sg721QueryClient'
41
39
  })));
42
40
  (0, _testUtils.expectCode)(t.program((0, _reactQuery.createReactQueryHooks)({
43
- context: new _context.RenderContext(_query_msg["default"], {
41
+ context: (0, _testUtils.makeContext)(_query_msg["default"], {
44
42
  reactQuery: {
45
43
  version: 'v4'
46
44
  }
@@ -50,7 +48,7 @@ it('createReactQueryHooks', function () {
50
48
  QueryClient: 'Sg721QueryClient'
51
49
  })));
52
50
  (0, _testUtils.expectCode)(t.program((0, _reactQuery.createReactQueryHooks)({
53
- context: new _context.RenderContext(_query_msg["default"], {
51
+ context: (0, _testUtils.makeContext)(_query_msg["default"], {
54
52
  reactQuery: {
55
53
  optionalClient: true,
56
54
  version: 'v4'
@@ -17,10 +17,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
17
17
 
18
18
  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; }
19
19
 
20
- var createRecoilSelector = function createRecoilSelector(context, keyPrefix, QueryClient, methodName) {
20
+ var createRecoilSelector = function createRecoilSelector(context, keyPrefix, QueryClient, methodName, responseType) {
21
21
  context.addUtil('selectorFamily');
22
22
  var selectorName = (0, _case.camel)("".concat(methodName, "Selector"));
23
- var responseType = (0, _case.pascal)("".concat(methodName, "Response"));
24
23
  var getterKey = (0, _case.camel)("".concat(keyPrefix).concat((0, _case.pascal)(methodName)));
25
24
  return t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(t.identifier(selectorName), (0, _utils.callExpression)(t.identifier('selectorFamily'), [t.objectExpression([t.objectProperty(t.identifier('key'), t.stringLiteral(getterKey)), t.objectProperty(t.identifier('get'), t.arrowFunctionExpression([t.objectPattern([t.objectProperty(t.identifier('params'), t.identifier('params'), false, true), t.restElement(t.identifier('queryClientParams'))])], t.arrowFunctionExpression([t.objectPattern([t.objectProperty(t.identifier('get'), t.identifier('get'), false, true)])], t.blockStatement([t.variableDeclaration('const', [t.variableDeclarator(t.identifier('client'), t.callExpression(t.identifier('get'), [t.callExpression(t.identifier('queryClient'), [t.identifier('queryClientParams')])]))]), t.returnStatement(t.awaitExpression(t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), [t.spreadElement(t.identifier('params'))])))]), true)))])], t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType)), t.tsIntersectionType([t.tsTypeReference(t.identifier('QueryClientParams')), t.tsTypeLiteral([t.tsPropertySignature(t.identifier('params'), t.tsTypeAnnotation(t.tsTypeReference(t.identifier('Parameters'), t.tsTypeParameterInstantiation([t.tsIndexedAccessType(t.tsTypeReference(t.identifier(QueryClient)), t.tsLiteralType(t.stringLiteral(methodName)))]))))])])])))]));
26
25
  };
@@ -31,7 +30,8 @@ var createRecoilSelectors = function createRecoilSelectors(context, keyPrefix, Q
31
30
  return (0, _utils.getMessageProperties)(queryMsg).map(function (schema) {
32
31
  var underscoreName = Object.keys(schema.properties)[0];
33
32
  var methodName = (0, _case.camel)(underscoreName);
34
- return createRecoilSelector(context, keyPrefix, QueryClient, methodName);
33
+ var responseType = (0, _utils.getResponseType)(context, underscoreName);
34
+ return createRecoilSelector(context, keyPrefix, QueryClient, methodName, responseType);
35
35
  });
36
36
  };
37
37
 
@@ -10,17 +10,15 @@ var _query_msg = _interopRequireDefault(require("../../../../__fixtures__/basic/
10
10
 
11
11
  var _recoil = require("./recoil");
12
12
 
13
- var _context = require("../context");
14
-
15
13
  var _testUtils = require("../../test-utils");
16
14
 
17
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
16
 
19
17
  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; }
20
18
 
21
- var ctx = new _context.RenderContext(_query_msg["default"]);
19
+ var ctx = (0, _testUtils.makeContext)(_query_msg["default"]);
22
20
  it('selector', function () {
23
- (0, _testUtils.expectCode)((0, _recoil.createRecoilSelector)(ctx, 'SG721', 'SG721QueryClient', 'governanceModules'));
21
+ (0, _testUtils.expectCode)((0, _recoil.createRecoilSelector)(ctx, 'SG721', 'SG721QueryClient', 'governanceModules', 'GovernanceModulesResponse'));
24
22
  });
25
23
  it('selectors', function () {
26
24
  (0, _testUtils.expectCode)(t.program((0, _recoil.createRecoilSelectors)(ctx, 'SG721', 'SG721QueryClient', _query_msg["default"])));
@@ -9,7 +9,9 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports.getParamsTypeAnnotation = exports.createTypedObjectParams = void 0;
11
11
  exports.getPropertySignatureFromProp = getPropertySignatureFromProp;
12
- exports.getTypeFromRef = exports.getType = exports.getPropertyType = void 0;
12
+ exports.getPropertyType = void 0;
13
+ exports.getResponseType = getResponseType;
14
+ exports.getTypeFromRef = exports.getType = void 0;
13
15
 
14
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
17
 
@@ -27,6 +29,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
27
29
 
28
30
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
29
31
 
32
+ function getResponseType(context, underscoreName) {
33
+ var _context$contract$res, _context$contract, _context$contract$res2, _context$contract$res3;
34
+
35
+ var methodName = (0, _case.camel)(underscoreName);
36
+ return (0, _case.pascal)((_context$contract$res = (_context$contract = context.contract) === null || _context$contract === void 0 ? void 0 : (_context$contract$res2 = _context$contract.responses) === null || _context$contract$res2 === void 0 ? void 0 : (_context$contract$res3 = _context$contract$res2[underscoreName]) === null || _context$contract$res3 === void 0 ? void 0 : _context$contract$res3.title) !== null && _context$contract$res !== void 0 ? _context$contract$res : // after v1.1 is adopted, we can deprecate this and require the above response
37
+ "".concat(methodName, "Response"));
38
+ }
39
+
40
+ ;
41
+
30
42
  var getTypeStrFromRef = function getTypeStrFromRef($ref) {
31
43
  if ($ref !== null && $ref !== void 0 && $ref.startsWith('#/definitions/')) {
32
44
  return $ref.replace('#/definitions/', '');
@@ -1,14 +1,14 @@
1
1
  import * as t from '@babel/types';
2
- import { camel, pascal } from 'case';
2
+ import { camel } from 'case';
3
3
  import { bindMethod, typedIdentifier, promiseTypeAnnotation, classDeclaration, classProperty, arrowFunctionExpression, getMessageProperties } from '../utils';
4
- import { getPropertyType, getType, createTypedObjectParams } from '../utils/types';
4
+ import { getPropertyType, getType, createTypedObjectParams, getResponseType } from '../utils/types';
5
5
  import { identifier, propertySignature } from '../utils/babel';
6
6
  export const CONSTANT_EXEC_PARAMS = [t.assignmentPattern(identifier('fee', t.tsTypeAnnotation(t.tsUnionType([t.tSNumberKeyword(), t.tsTypeReference(t.identifier('StdFee')), t.tsLiteralType(t.stringLiteral('auto'))])), false), t.stringLiteral('auto')), identifier('memo', t.tsTypeAnnotation(t.tsStringKeyword()), true), identifier('funds', t.tsTypeAnnotation(t.tsArrayType(t.tsTypeReference(t.identifier('Coin')))), true)];
7
7
  export const FIXED_EXECUTE_PARAMS = [identifier('fee', t.tsTypeAnnotation(t.tsUnionType([t.tsNumberKeyword(), t.tsTypeReference(t.identifier('StdFee')), t.tsLiteralType(t.stringLiteral('auto'))])), true), identifier('memo', t.tsTypeAnnotation(t.tsStringKeyword()), true), identifier('funds', t.tsTypeAnnotation(t.tsArrayType(t.tsTypeReference(t.identifier('Coin')))), true)];
8
8
  export const createWasmQueryMethod = (context, jsonschema) => {
9
9
  const underscoreName = Object.keys(jsonschema.properties)[0];
10
10
  const methodName = camel(underscoreName);
11
- const responseType = pascal(`${methodName}Response`);
11
+ const responseType = getResponseType(context, underscoreName);
12
12
  const obj = createTypedObjectParams(context, jsonschema.properties[underscoreName]);
13
13
  const args = getWasmMethodArgs(context, jsonschema.properties[underscoreName]);
14
14
  const actionArg = t.objectProperty(t.identifier(underscoreName), t.objectExpression(args));
@@ -113,7 +113,7 @@ export const createQueryInterface = (context, className, queryMsg) => {
113
113
  const methods = getMessageProperties(queryMsg).map(jsonschema => {
114
114
  const underscoreName = Object.keys(jsonschema.properties)[0];
115
115
  const methodName = camel(underscoreName);
116
- const responseType = pascal(`${methodName}Response`);
116
+ const responseType = getResponseType(context, underscoreName);
117
117
  return createPropertyFunctionWithObjectParams(context, methodName, responseType, jsonschema.properties[underscoreName]);
118
118
  });
119
119
  return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, [], t.tSInterfaceBody([t.tSPropertySignature(t.identifier('contractAddress'), t.tsTypeAnnotation(t.tsStringKeyword())), ...methods])));
@@ -1,8 +1,7 @@
1
1
  import message from '../../../../../__fixtures__/misc/schema/arrays-ref.json';
2
2
  import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
3
- import { RenderContext } from '../../context';
4
- import { expectCode } from '../../../test-utils';
5
- const ctx = new RenderContext(message);
3
+ import { expectCode, makeContext } from '../../../test-utils';
4
+ const ctx = makeContext(message);
6
5
  it('execute_msg_for__empty', () => {
7
6
  expectCode(createTypeInterface(ctx, message));
8
7
  });
@@ -1,8 +1,7 @@
1
1
  import message from '../../../../../__fixtures__/misc/schema/arrays.json';
2
2
  import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
3
- import { RenderContext } from '../../context';
4
- import { expectCode } from '../../../test-utils';
5
- const ctx = new RenderContext(message);
3
+ import { expectCode, makeContext } from '../../../test-utils';
4
+ const ctx = makeContext(message);
6
5
  it('execute_msg_for__empty', () => {
7
6
  expectCode(createTypeInterface(ctx, message));
8
7
  });
@@ -1,8 +1,7 @@
1
1
  import execute_msg from '../../../../../__fixtures__/daodao/cw-named-groups/execute_msg.json';
2
2
  import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
3
- import { RenderContext } from '../../context';
4
- import { expectCode } from '../../../test-utils';
5
- const ctx = new RenderContext(execute_msg);
3
+ import { expectCode, makeContext } from '../../../test-utils';
4
+ const ctx = makeContext(execute_msg);
6
5
  it('execute_msg', () => {
7
6
  expectCode(createTypeInterface(ctx, execute_msg));
8
7
  });
@@ -1,21 +1,20 @@
1
1
  import execute_msg from '../../../../../__fixtures__/daodao/cw-proposal-single/execute_msg.json';
2
2
  import query_msg from '../../../../../__fixtures__/daodao/cw-proposal-single/query_msg.json';
3
3
  import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
4
- import { RenderContext } from '../../context';
5
- import { expectCode } from '../../../test-utils';
4
+ import { expectCode, makeContext } from '../../../test-utils';
6
5
  it('execute_msg_for', () => {
7
- const ctx = new RenderContext(execute_msg);
6
+ const ctx = makeContext(execute_msg);
8
7
  expectCode(createTypeInterface(ctx, execute_msg));
9
8
  });
10
9
  it('query classes', () => {
11
- const ctx = new RenderContext(query_msg);
10
+ const ctx = makeContext(query_msg);
12
11
  expectCode(createQueryClass(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', query_msg));
13
12
  });
14
13
  it('execute classes array types', () => {
15
- const ctx = new RenderContext(execute_msg);
14
+ const ctx = makeContext(execute_msg);
16
15
  expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', null, execute_msg));
17
16
  });
18
17
  it('execute interfaces no extends', () => {
19
- const ctx = new RenderContext(execute_msg);
18
+ const ctx = makeContext(execute_msg);
20
19
  expectCode(createExecuteInterface(ctx, 'SG721Instance', null, execute_msg));
21
20
  });
@@ -1,8 +1,7 @@
1
1
  import query_msg from '../../../../../__fixtures__/daodao/cw-admin-factory/query_msg.json';
2
2
  import { createQueryClass, createQueryInterface } from '../client';
3
- import { RenderContext } from '../../context';
4
- import { expectCode } from '../../../test-utils';
5
- const ctx = new RenderContext(query_msg);
3
+ import { expectCode, makeContext } from '../../../test-utils';
4
+ const ctx = makeContext(query_msg);
6
5
  it('query classes', () => {
7
6
  expectCode(createQueryClass(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', query_msg));
8
7
  });
@@ -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/55');
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);
@@ -1,8 +1,7 @@
1
1
  import execute_msg_for__empty from '../../../../../__fixtures__/sg721/execute_msg_for__empty.json';
2
2
  import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
3
- import { RenderContext } from '../../context';
4
- import { expectCode } from '../../../test-utils';
5
- const ctx = new RenderContext(execute_msg_for__empty);
3
+ import { expectCode, makeContext } from '../../../test-utils';
4
+ const ctx = makeContext(execute_msg_for__empty);
6
5
  it('execute_msg_for__empty', () => {
7
6
  expectCode(createTypeInterface(ctx, execute_msg_for__empty));
8
7
  });
@@ -13,73 +13,72 @@ import operators_response from '../../../../../__fixtures__/basic/operators_resp
13
13
  import owner_of_response from '../../../../../__fixtures__/basic/owner_of_response.json';
14
14
  import tokens_response from '../../../../../__fixtures__/basic/tokens_response.json';
15
15
  import { createQueryClass, createQueryInterface, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
16
- import { RenderContext } from '../../context';
17
- import { expectCode } from '../../../test-utils';
16
+ import { expectCode, makeContext } from '../../../test-utils';
18
17
  it('approval_response', () => {
19
- const ctx = new RenderContext(approval_response);
18
+ const ctx = makeContext(approval_response);
20
19
  expectCode(createTypeInterface(ctx, approval_response));
21
20
  });
22
21
  it('all_nft_info_response', () => {
23
- const ctx = new RenderContext(all_nft_info_response);
22
+ const ctx = makeContext(all_nft_info_response);
24
23
  expectCode(createTypeInterface(ctx, all_nft_info_response));
25
24
  });
26
25
  it('approvals_response', () => {
27
- const ctx = new RenderContext(approvals_response);
26
+ const ctx = makeContext(approvals_response);
28
27
  expectCode(createTypeInterface(ctx, approvals_response));
29
28
  });
30
29
  it('collection_info_response', () => {
31
- const ctx = new RenderContext(collection_info_response);
30
+ const ctx = makeContext(collection_info_response);
32
31
  expectCode(createTypeInterface(ctx, collection_info_response));
33
32
  });
34
33
  it('contract_info_response', () => {
35
- const ctx = new RenderContext(contract_info_response);
34
+ const ctx = makeContext(contract_info_response);
36
35
  expectCode(createTypeInterface(ctx, contract_info_response));
37
36
  });
38
37
  it('instantiate_msg', () => {
39
- const ctx = new RenderContext(instantiate_msg);
38
+ const ctx = makeContext(instantiate_msg);
40
39
  expectCode(createTypeInterface(ctx, instantiate_msg));
41
40
  });
42
41
  it('nft_info_response', () => {
43
- const ctx = new RenderContext(nft_info_response);
42
+ const ctx = makeContext(nft_info_response);
44
43
  expectCode(createTypeInterface(ctx, nft_info_response));
45
44
  });
46
45
  it('num_tokens_response', () => {
47
- const ctx = new RenderContext(num_tokens_response);
46
+ const ctx = makeContext(num_tokens_response);
48
47
  expectCode(createTypeInterface(ctx, num_tokens_response));
49
48
  });
50
49
  it('operators_response', () => {
51
- const ctx = new RenderContext(operators_response);
50
+ const ctx = makeContext(operators_response);
52
51
  expectCode(createTypeInterface(ctx, operators_response));
53
52
  });
54
53
  it('owner_of_response', () => {
55
- const ctx = new RenderContext(owner_of_response);
54
+ const ctx = makeContext(owner_of_response);
56
55
  expectCode(createTypeInterface(ctx, owner_of_response));
57
56
  });
58
57
  it('tokens_response', () => {
59
- const ctx = new RenderContext(tokens_response);
58
+ const ctx = makeContext(tokens_response);
60
59
  expectCode(createTypeInterface(ctx, tokens_response));
61
60
  });
62
61
  it('query classes', () => {
63
- const ctx = new RenderContext(query_msg);
62
+ const ctx = makeContext(query_msg);
64
63
  expectCode(createQueryClass(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', query_msg));
65
64
  });
66
65
  it('execute classes', () => {
67
- const ctx = new RenderContext(execute_msg);
66
+ const ctx = makeContext(execute_msg);
68
67
  expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', 'SG721QueryClient', execute_msg));
69
68
  });
70
69
  it('execute classes no extends', () => {
71
- const ctx = new RenderContext(execute_msg);
70
+ const ctx = makeContext(execute_msg);
72
71
  expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', null, execute_msg));
73
72
  });
74
73
  it('execute classes array types', () => {
75
- const ctx = new RenderContext(execute_msg_named_groups);
74
+ const ctx = makeContext(execute_msg_named_groups);
76
75
  expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', null, execute_msg_named_groups));
77
76
  });
78
77
  it('execute interfaces no extends', () => {
79
- const ctx = new RenderContext(execute_msg);
78
+ const ctx = makeContext(execute_msg);
80
79
  expectCode(createExecuteInterface(ctx, 'SG721Instance', null, execute_msg));
81
80
  });
82
81
  it('query interfaces', () => {
83
- const ctx = new RenderContext(query_msg);
82
+ const ctx = makeContext(query_msg);
84
83
  expectCode(createQueryInterface(ctx, 'SG721ReadOnlyInstance', query_msg));
85
84
  });
@@ -4,41 +4,40 @@ import can_execute_relay_response from '../../../../../__fixtures__/vectis/govec
4
4
  import info_response from '../../../../../__fixtures__/vectis/govec/info_response.json';
5
5
  import relay_transaction from '../../../../../__fixtures__/vectis/govec/relay_transaction.json';
6
6
  import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
7
- import { RenderContext } from '../../context';
8
- import { expectCode } from '../../../test-utils';
7
+ import { expectCode, makeContext } from '../../../test-utils';
9
8
  it('cosmos_msg_for__empty', () => {
10
- const ctx = new RenderContext(cosmos_msg_for__empty);
9
+ const ctx = makeContext(cosmos_msg_for__empty);
11
10
  expectCode(createTypeInterface(ctx, cosmos_msg_for__empty));
12
11
  });
13
12
  it('execute_msg_for__empty', () => {
14
- const ctx = new RenderContext(execute_msg_for__empty);
13
+ const ctx = makeContext(execute_msg_for__empty);
15
14
  expectCode(createTypeInterface(ctx, execute_msg_for__empty));
16
15
  });
17
16
  it('can_execute_relay_response', () => {
18
- const ctx = new RenderContext(can_execute_relay_response);
17
+ const ctx = makeContext(can_execute_relay_response);
19
18
  expectCode(createTypeInterface(ctx, can_execute_relay_response));
20
19
  });
21
20
  it('info_response', () => {
22
- const ctx = new RenderContext(info_response);
21
+ const ctx = makeContext(info_response);
23
22
  expectCode(createTypeInterface(ctx, info_response));
24
23
  });
25
24
  it('relay_transaction', () => {
26
- const ctx = new RenderContext(relay_transaction);
25
+ const ctx = makeContext(relay_transaction);
27
26
  expectCode(createTypeInterface(ctx, relay_transaction));
28
27
  });
29
28
  it('query classes', () => {
30
- const ctx = new RenderContext(cosmos_msg_for__empty);
29
+ const ctx = makeContext(cosmos_msg_for__empty);
31
30
  expectCode(createQueryClass(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', cosmos_msg_for__empty));
32
31
  });
33
32
  it('query classes', () => {
34
- const ctx = new RenderContext(execute_msg_for__empty);
33
+ const ctx = makeContext(execute_msg_for__empty);
35
34
  expectCode(createQueryClass(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', execute_msg_for__empty));
36
35
  });
37
36
  it('execute classes array types', () => {
38
- const ctx = new RenderContext(execute_msg_for__empty);
37
+ const ctx = makeContext(execute_msg_for__empty);
39
38
  expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', null, execute_msg_for__empty));
40
39
  });
41
40
  it('execute interfaces no extends', () => {
42
- const ctx = new RenderContext(execute_msg_for__empty);
41
+ const ctx = makeContext(execute_msg_for__empty);
43
42
  expectCode(createExecuteInterface(ctx, 'SG721Instance', null, execute_msg_for__empty));
44
43
  });