wasm-ast-types 0.0.8 → 0.0.11
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/main/index.js +0 -13
- package/main/utils.spec.js +7 -1
- package/main/wasm.js +50 -30
- package/module/index.js +0 -1
- package/module/utils.spec.js +6 -0
- package/module/wasm.js +35 -21
- package/package.json +2 -2
- package/main/types.js +0 -4
- package/module/types.js +0 -3
package/main/index.js
CHANGED
@@ -4,19 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
|
7
|
-
var _types = require("./types");
|
8
|
-
|
9
|
-
Object.keys(_types).forEach(function (key) {
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
11
|
-
if (key in exports && exports[key] === _types[key]) return;
|
12
|
-
Object.defineProperty(exports, key, {
|
13
|
-
enumerable: true,
|
14
|
-
get: function get() {
|
15
|
-
return _types[key];
|
16
|
-
}
|
17
|
-
});
|
18
|
-
});
|
19
|
-
|
20
7
|
var _utils = require("./utils");
|
21
8
|
|
22
9
|
Object.keys(_utils).forEach(function (key) {
|
package/main/utils.spec.js
CHANGED
@@ -103,4 +103,10 @@ it('mutation classes', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PUR
|
|
103
103
|
}
|
104
104
|
}
|
105
105
|
}, _callee4);
|
106
|
-
})));
|
106
|
+
})));
|
107
|
+
it('object parms', function () {
|
108
|
+
var obj = t.objectPattern([t.objectProperty(t.identifier('includeExpired'), t.identifier('includeExpired'), false, true), t.objectProperty(t.identifier('tokenId'), t.identifier('tokenId'), false, true)]);
|
109
|
+
obj.typeAnnotation = t.tsTypeAnnotation(t.tsTypeLiteral([t.tsPropertySignature(t.identifier('includeExpired'), t.tsTypeAnnotation(t.tsBooleanKeyword())), t.tsPropertySignature(t.identifier('tokenId'), t.tsTypeAnnotation(t.tsStringKeyword()))]));
|
110
|
+
expectCode(t.program([t.expressionStatement(t.assignmentExpression('=', t.identifier('ownerOf'), (0, _utils.arrowFunctionExpression)([obj], t.blockStatement([// body
|
111
|
+
], []), t.tsTypeAnnotation(t.tsTypeReference(t.identifier('Promise'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier('OwnerOfResponse'))]))))))]));
|
112
|
+
});
|
package/main/wasm.js
CHANGED
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
8
8
|
value: true
|
9
9
|
});
|
10
|
-
exports.propertySignature = exports.createWasmQueryMethod = exports.createWasmExecMethod = exports.createTypeOrInterface = exports.createTypeInterface = exports.createQueryInterface = exports.createQueryClass = exports.createExecuteInterface = exports.createExecuteClass = void 0;
|
10
|
+
exports.propertySignature = exports.createWasmQueryMethod = exports.createWasmExecMethod = exports.createTypedObjectParams = exports.createTypeOrInterface = exports.createTypeInterface = exports.createQueryInterface = exports.createQueryClass = exports.createPropertyFunctionWithObjectParams = exports.createExecuteInterface = exports.createExecuteClass = void 0;
|
11
11
|
|
12
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
13
13
|
|
@@ -152,16 +152,13 @@ var createWasmQueryMethod = function createWasmQueryMethod(jsonschema) {
|
|
152
152
|
var underscoreName = Object.keys(jsonschema.properties)[0];
|
153
153
|
var methodName = (0, _case.camel)(underscoreName);
|
154
154
|
var responseType = (0, _case.pascal)("".concat(methodName, "Response"));
|
155
|
-
var properties = (_jsonschema$propertie = jsonschema.properties[underscoreName].properties) !== null && _jsonschema$propertie !== void 0 ? _jsonschema$propertie : {};
|
156
|
-
|
157
|
-
var params = Object.keys(properties).map(function (prop) {
|
158
|
-
return getProperty(jsonschema.properties[underscoreName], prop);
|
159
|
-
});
|
155
|
+
var properties = (_jsonschema$propertie = jsonschema.properties[underscoreName].properties) !== null && _jsonschema$propertie !== void 0 ? _jsonschema$propertie : {};
|
156
|
+
var obj = createTypedObjectParams(jsonschema.properties[underscoreName]);
|
160
157
|
var args = Object.keys(properties).map(function (prop) {
|
161
158
|
return t.objectProperty(t.identifier(prop), t.identifier((0, _case.camel)(prop)), false, true);
|
162
159
|
});
|
163
160
|
var actionArg = t.objectProperty(t.identifier(underscoreName), t.objectExpression(args));
|
164
|
-
return t.classProperty(t.identifier(methodName), (0, _utils.arrowFunctionExpression)(
|
161
|
+
return t.classProperty(t.identifier(methodName), (0, _utils.arrowFunctionExpression)(obj ? [obj] : [], t.blockStatement([t.returnStatement(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('queryContractSmart')), [t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.objectExpression([actionArg])]))]), t.tsTypeAnnotation(t.tsTypeReference(t.identifier('Promise'), t.tsTypeParameterInstantiation([t.tSTypeReference(t.identifier(responseType))]))), true));
|
165
162
|
};
|
166
163
|
|
167
164
|
exports.createWasmQueryMethod = createWasmQueryMethod;
|
@@ -191,13 +188,12 @@ var createWasmExecMethod = function createWasmExecMethod(jsonschema) {
|
|
191
188
|
var underscoreName = Object.keys(jsonschema.properties)[0];
|
192
189
|
var methodName = (0, _case.camel)(underscoreName);
|
193
190
|
var properties = (_jsonschema$propertie2 = jsonschema.properties[underscoreName].properties) !== null && _jsonschema$propertie2 !== void 0 ? _jsonschema$propertie2 : {};
|
194
|
-
var
|
195
|
-
return getProperty(jsonschema.properties[underscoreName], prop);
|
196
|
-
});
|
191
|
+
var obj = createTypedObjectParams(jsonschema.properties[underscoreName]);
|
197
192
|
var args = Object.keys(properties).map(function (prop) {
|
198
193
|
return t.objectProperty(t.identifier(prop), t.identifier((0, _case.camel)(prop)), false, prop === (0, _case.camel)(prop));
|
199
194
|
});
|
200
|
-
return t.classProperty(t.identifier(methodName), (0, _utils.arrowFunctionExpression)(
|
195
|
+
return t.classProperty(t.identifier(methodName), (0, _utils.arrowFunctionExpression)(obj ? [// props
|
196
|
+
obj] : [], t.blockStatement([t.returnStatement(t.awaitExpression(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('execute')), [t.memberExpression(t.thisExpression(), t.identifier('sender')), t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.objectExpression([t.objectProperty(t.identifier(underscoreName), t.objectExpression((0, _toConsumableArray2["default"])(args)))]), t.stringLiteral('auto')])))]), // return type
|
201
197
|
t.tsTypeAnnotation(t.tsTypeReference(t.identifier('Promise'), t.tsTypeParameterInstantiation([t.tSTypeReference(t.identifier('ExecuteResult'))]))), true));
|
202
198
|
};
|
203
199
|
|
@@ -233,15 +229,9 @@ exports.createExecuteClass = createExecuteClass;
|
|
233
229
|
|
234
230
|
var createExecuteInterface = function createExecuteInterface(className, extendsClassName, execMsg) {
|
235
231
|
var methods = execMsg.oneOf.map(function (jsonschema) {
|
236
|
-
var _jsonschema$propertie3;
|
237
|
-
|
238
232
|
var underscoreName = Object.keys(jsonschema.properties)[0];
|
239
233
|
var methodName = (0, _case.camel)(underscoreName);
|
240
|
-
|
241
|
-
var params = Object.keys(properties).map(function (prop) {
|
242
|
-
return getProperty(jsonschema.properties[underscoreName], prop);
|
243
|
-
});
|
244
|
-
return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(t.tsFunctionType(null, (0, _toConsumableArray2["default"])(params), (0, _utils.promiseTypeAnnotation)('ExecuteResult'))));
|
234
|
+
return createPropertyFunctionWithObjectParams(methodName, 'ExecuteResult', jsonschema.properties[underscoreName]);
|
245
235
|
});
|
246
236
|
var extendsAst = extendsClassName ? [t.tSExpressionWithTypeArguments(t.identifier(extendsClassName))] : [];
|
247
237
|
return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, extendsAst, t.tSInterfaceBody([// contract address
|
@@ -251,18 +241,48 @@ var createExecuteInterface = function createExecuteInterface(className, extendsC
|
|
251
241
|
|
252
242
|
exports.createExecuteInterface = createExecuteInterface;
|
253
243
|
|
244
|
+
var createTypedObjectParams = function createTypedObjectParams(jsonschema) {
|
245
|
+
var _jsonschema$propertie3;
|
246
|
+
|
247
|
+
var camelize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
248
|
+
var keys = Object.keys((_jsonschema$propertie3 = jsonschema.properties) !== null && _jsonschema$propertie3 !== void 0 ? _jsonschema$propertie3 : {});
|
249
|
+
if (!keys.length) return;
|
250
|
+
var typedParams = keys.map(function (prop) {
|
251
|
+
var _getPropertyType2 = getPropertyType(jsonschema, prop),
|
252
|
+
type = _getPropertyType2.type,
|
253
|
+
optional = _getPropertyType2.optional;
|
254
|
+
|
255
|
+
return t.tsPropertySignature(camelize ? t.identifier((0, _case.camel)(prop)) : t.identifier(prop), t.tsTypeAnnotation(type));
|
256
|
+
});
|
257
|
+
var params = keys.map(function (prop) {
|
258
|
+
return t.objectProperty(camelize ? t.identifier((0, _case.camel)(prop)) : t.identifier(prop), camelize ? t.identifier((0, _case.camel)(prop)) : t.identifier(prop), false, true);
|
259
|
+
});
|
260
|
+
var obj = t.objectPattern((0, _toConsumableArray2["default"])(params));
|
261
|
+
obj.typeAnnotation = t.tsTypeAnnotation(t.tsTypeLiteral((0, _toConsumableArray2["default"])(typedParams)));
|
262
|
+
return obj;
|
263
|
+
};
|
264
|
+
|
265
|
+
exports.createTypedObjectParams = createTypedObjectParams;
|
266
|
+
|
267
|
+
var createPropertyFunctionWithObjectParams = function createPropertyFunctionWithObjectParams(methodName, responseType, jsonschema) {
|
268
|
+
var obj = createTypedObjectParams(jsonschema);
|
269
|
+
var func = {
|
270
|
+
type: 'TSFunctionType',
|
271
|
+
typeAnnotation: (0, _utils.promiseTypeAnnotation)(responseType),
|
272
|
+
parameters: obj ? [obj] : []
|
273
|
+
};
|
274
|
+
return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(func));
|
275
|
+
};
|
276
|
+
|
277
|
+
exports.createPropertyFunctionWithObjectParams = createPropertyFunctionWithObjectParams;
|
278
|
+
|
254
279
|
var createQueryInterface = function createQueryInterface(className, queryMsg) {
|
255
280
|
var methods = queryMsg.oneOf.map(function (jsonschema) {
|
256
|
-
var _jsonschema$propertie4;
|
257
|
-
|
258
281
|
var underscoreName = Object.keys(jsonschema.properties)[0];
|
259
282
|
var methodName = (0, _case.camel)(underscoreName);
|
260
283
|
var responseType = (0, _case.pascal)("".concat(methodName, "Response"));
|
261
|
-
var
|
262
|
-
|
263
|
-
return getProperty(jsonschema.properties[underscoreName], prop);
|
264
|
-
});
|
265
|
-
return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(t.tsFunctionType(null, (0, _toConsumableArray2["default"])(params), (0, _utils.promiseTypeAnnotation)(responseType))));
|
284
|
+
var obj = createTypedObjectParams(jsonschema.properties[underscoreName]);
|
285
|
+
return createPropertyFunctionWithObjectParams(methodName, responseType, jsonschema.properties[underscoreName]);
|
266
286
|
});
|
267
287
|
return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, [], t.tSInterfaceBody([t.tSPropertySignature(t.identifier('contractAddress'), t.tsTypeAnnotation(t.tsStringKeyword()))].concat((0, _toConsumableArray2["default"])(methods)))));
|
268
288
|
};
|
@@ -286,16 +306,16 @@ var propertySignature = function propertySignature(name, typeAnnotation) {
|
|
286
306
|
exports.propertySignature = propertySignature;
|
287
307
|
|
288
308
|
var createTypeOrInterface = function createTypeOrInterface(Type, jsonschema) {
|
289
|
-
var _jsonschema$
|
309
|
+
var _jsonschema$propertie4;
|
290
310
|
|
291
311
|
if (jsonschema.type !== 'object') {
|
292
312
|
return t.exportNamedDeclaration(t.tsTypeAliasDeclaration(t.identifier(Type), null, getType(jsonschema.type)));
|
293
313
|
}
|
294
314
|
|
295
|
-
var props = Object.keys((_jsonschema$
|
296
|
-
var
|
297
|
-
type =
|
298
|
-
optional =
|
315
|
+
var props = Object.keys((_jsonschema$propertie4 = jsonschema.properties) !== null && _jsonschema$propertie4 !== void 0 ? _jsonschema$propertie4 : {}).map(function (prop) {
|
316
|
+
var _getPropertyType3 = getPropertyType(jsonschema, prop),
|
317
|
+
type = _getPropertyType3.type,
|
318
|
+
optional = _getPropertyType3.optional;
|
299
319
|
|
300
320
|
return propertySignature((0, _case.camel)(prop), t.tsTypeAnnotation(type), optional);
|
301
321
|
});
|
package/module/index.js
CHANGED
package/module/utils.spec.js
CHANGED
@@ -44,4 +44,10 @@ it('mutation classes', async () => {
|
|
44
44
|
t.classProperty(t.identifier('mint'), arrowFunctionExpression([// props
|
45
45
|
typedIdentifier('sender', t.tsTypeAnnotation(t.tsStringKeyword())), typedIdentifier('tokenId', t.tsTypeAnnotation(t.tsStringKeyword())), typedIdentifier('owner', t.tsTypeAnnotation(t.tsStringKeyword())), typedIdentifier('token_uri', t.tsTypeAnnotation(t.tsStringKeyword()))], t.blockStatement([t.returnStatement(t.awaitExpression(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('execute')), [t.identifier('sender'), t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.objectExpression([t.objectProperty(t.identifier('mint'), t.objectExpression([t.objectProperty(t.identifier('token_id'), t.identifier('tokenId')), t.objectProperty(t.identifier('owner'), t.identifier('owner')), t.objectProperty(t.identifier('token_uri'), t.identifier('token_uri')), t.objectProperty(t.identifier('expression'), t.objectExpression([]))]))]), t.stringLiteral('auto')])))]), // return type
|
46
46
|
t.tsTypeAnnotation(t.tsTypeReference(t.identifier('Promise'), t.tsTypeParameterInstantiation([t.tSTypeReference(t.identifier('ExecuteResult'))]))), true))], [t.tSExpressionWithTypeArguments(t.identifier('SG721ReadOnlyInstance'))], t.identifier('SG721QueryClient')))]));
|
47
|
+
});
|
48
|
+
it('object parms', () => {
|
49
|
+
const obj = t.objectPattern([t.objectProperty(t.identifier('includeExpired'), t.identifier('includeExpired'), false, true), t.objectProperty(t.identifier('tokenId'), t.identifier('tokenId'), false, true)]);
|
50
|
+
obj.typeAnnotation = t.tsTypeAnnotation(t.tsTypeLiteral([t.tsPropertySignature(t.identifier('includeExpired'), t.tsTypeAnnotation(t.tsBooleanKeyword())), t.tsPropertySignature(t.identifier('tokenId'), t.tsTypeAnnotation(t.tsStringKeyword()))]));
|
51
|
+
expectCode(t.program([t.expressionStatement(t.assignmentExpression('=', t.identifier('ownerOf'), arrowFunctionExpression([obj], t.blockStatement([// body
|
52
|
+
], []), t.tsTypeAnnotation(t.tsTypeReference(t.identifier('Promise'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier('OwnerOfResponse'))]))))))]));
|
47
53
|
});
|
package/module/wasm.js
CHANGED
@@ -123,16 +123,13 @@ export const createWasmQueryMethod = jsonschema => {
|
|
123
123
|
const underscoreName = Object.keys(jsonschema.properties)[0];
|
124
124
|
const methodName = camel(underscoreName);
|
125
125
|
const responseType = pascal(`${methodName}Response`);
|
126
|
-
const properties = jsonschema.properties[underscoreName].properties ?? {};
|
127
|
-
|
128
|
-
const params = Object.keys(properties).map(prop => {
|
129
|
-
return getProperty(jsonschema.properties[underscoreName], prop);
|
130
|
-
});
|
126
|
+
const properties = jsonschema.properties[underscoreName].properties ?? {};
|
127
|
+
const obj = createTypedObjectParams(jsonschema.properties[underscoreName]);
|
131
128
|
const args = Object.keys(properties).map(prop => {
|
132
129
|
return t.objectProperty(t.identifier(prop), t.identifier(camel(prop)), false, true);
|
133
130
|
});
|
134
131
|
const actionArg = t.objectProperty(t.identifier(underscoreName), t.objectExpression(args));
|
135
|
-
return t.classProperty(t.identifier(methodName), arrowFunctionExpression(
|
132
|
+
return t.classProperty(t.identifier(methodName), arrowFunctionExpression(obj ? [obj] : [], t.blockStatement([t.returnStatement(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('queryContractSmart')), [t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.objectExpression([actionArg])]))]), t.tsTypeAnnotation(t.tsTypeReference(t.identifier('Promise'), t.tsTypeParameterInstantiation([t.tSTypeReference(t.identifier(responseType))]))), true));
|
136
133
|
};
|
137
134
|
export const createQueryClass = (className, implementsClassName, queryMsg) => {
|
138
135
|
const propertyNames = queryMsg.oneOf.map(method => Object.keys(method.properties)?.[0]).filter(Boolean);
|
@@ -150,14 +147,12 @@ export const createWasmExecMethod = jsonschema => {
|
|
150
147
|
const underscoreName = Object.keys(jsonschema.properties)[0];
|
151
148
|
const methodName = camel(underscoreName);
|
152
149
|
const properties = jsonschema.properties[underscoreName].properties ?? {};
|
153
|
-
const
|
154
|
-
return getProperty(jsonschema.properties[underscoreName], prop);
|
155
|
-
});
|
150
|
+
const obj = createTypedObjectParams(jsonschema.properties[underscoreName]);
|
156
151
|
const args = Object.keys(properties).map(prop => {
|
157
152
|
return t.objectProperty(t.identifier(prop), t.identifier(camel(prop)), false, prop === camel(prop));
|
158
153
|
});
|
159
|
-
return t.classProperty(t.identifier(methodName), arrowFunctionExpression([// props
|
160
|
-
|
154
|
+
return t.classProperty(t.identifier(methodName), arrowFunctionExpression(obj ? [// props
|
155
|
+
obj] : [], t.blockStatement([t.returnStatement(t.awaitExpression(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('execute')), [t.memberExpression(t.thisExpression(), t.identifier('sender')), t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.objectExpression([t.objectProperty(t.identifier(underscoreName), t.objectExpression([...args]))]), t.stringLiteral('auto')])))]), // return type
|
161
156
|
t.tsTypeAnnotation(t.tsTypeReference(t.identifier('Promise'), t.tsTypeParameterInstantiation([t.tSTypeReference(t.identifier('ExecuteResult'))]))), true));
|
162
157
|
};
|
163
158
|
export const createExecuteClass = (className, implementsClassName, extendsClassName, execMsg) => {
|
@@ -185,27 +180,46 @@ export const createExecuteInterface = (className, extendsClassName, execMsg) =>
|
|
185
180
|
const methods = execMsg.oneOf.map(jsonschema => {
|
186
181
|
const underscoreName = Object.keys(jsonschema.properties)[0];
|
187
182
|
const methodName = camel(underscoreName);
|
188
|
-
|
189
|
-
const params = Object.keys(properties).map(prop => {
|
190
|
-
return getProperty(jsonschema.properties[underscoreName], prop);
|
191
|
-
});
|
192
|
-
return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(t.tsFunctionType(null, [...params], promiseTypeAnnotation('ExecuteResult'))));
|
183
|
+
return createPropertyFunctionWithObjectParams(methodName, 'ExecuteResult', jsonschema.properties[underscoreName]);
|
193
184
|
});
|
194
185
|
const extendsAst = extendsClassName ? [t.tSExpressionWithTypeArguments(t.identifier(extendsClassName))] : [];
|
195
186
|
return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, extendsAst, t.tSInterfaceBody([// contract address
|
196
187
|
t.tSPropertySignature(t.identifier('contractAddress'), t.tsTypeAnnotation(t.tsStringKeyword())), // contract address
|
197
188
|
t.tSPropertySignature(t.identifier('sender'), t.tsTypeAnnotation(t.tsStringKeyword())), ...methods])));
|
198
189
|
};
|
190
|
+
export const createTypedObjectParams = (jsonschema, camelize = true) => {
|
191
|
+
const keys = Object.keys(jsonschema.properties ?? {});
|
192
|
+
if (!keys.length) return;
|
193
|
+
const typedParams = keys.map(prop => {
|
194
|
+
const {
|
195
|
+
type,
|
196
|
+
optional
|
197
|
+
} = getPropertyType(jsonschema, prop);
|
198
|
+
return t.tsPropertySignature(camelize ? t.identifier(camel(prop)) : t.identifier(prop), t.tsTypeAnnotation(type));
|
199
|
+
});
|
200
|
+
const params = keys.map(prop => {
|
201
|
+
return t.objectProperty(camelize ? t.identifier(camel(prop)) : t.identifier(prop), camelize ? t.identifier(camel(prop)) : t.identifier(prop), false, true);
|
202
|
+
});
|
203
|
+
const obj = t.objectPattern([...params]);
|
204
|
+
obj.typeAnnotation = t.tsTypeAnnotation(t.tsTypeLiteral([...typedParams]));
|
205
|
+
return obj;
|
206
|
+
};
|
207
|
+
export const createPropertyFunctionWithObjectParams = (methodName, responseType, jsonschema) => {
|
208
|
+
const obj = createTypedObjectParams(jsonschema);
|
209
|
+
const func = {
|
210
|
+
type: 'TSFunctionType',
|
211
|
+
typeAnnotation: promiseTypeAnnotation(responseType),
|
212
|
+
parameters: obj ? [obj] : []
|
213
|
+
};
|
214
|
+
return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(func));
|
215
|
+
};
|
199
216
|
export const createQueryInterface = (className, queryMsg) => {
|
200
217
|
const methods = queryMsg.oneOf.map(jsonschema => {
|
201
218
|
const underscoreName = Object.keys(jsonschema.properties)[0];
|
202
219
|
const methodName = camel(underscoreName);
|
203
220
|
const responseType = pascal(`${methodName}Response`);
|
204
|
-
const
|
205
|
-
|
206
|
-
return getProperty(jsonschema.properties[underscoreName], prop);
|
207
|
-
});
|
208
|
-
return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(t.tsFunctionType(null, [...params], promiseTypeAnnotation(responseType))));
|
221
|
+
const obj = createTypedObjectParams(jsonschema.properties[underscoreName]);
|
222
|
+
return createPropertyFunctionWithObjectParams(methodName, responseType, jsonschema.properties[underscoreName]);
|
209
223
|
});
|
210
224
|
return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, [], t.tSInterfaceBody([t.tSPropertySignature(t.identifier('contractAddress'), t.tsTypeAnnotation(t.tsStringKeyword())), ...methods])));
|
211
225
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "wasm-ast-types",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.11",
|
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",
|
@@ -85,5 +85,5 @@
|
|
85
85
|
"ast-stringify": "0.1.0",
|
86
86
|
"case": "1.6.3"
|
87
87
|
},
|
88
|
-
"gitHead": "
|
88
|
+
"gitHead": "972a1b8c212c531cd23d7f15ba8944841e938ba9"
|
89
89
|
}
|
package/main/types.js
DELETED
package/module/types.js
DELETED