wasm-ast-types 0.0.3 → 0.0.6
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 +0 -1
- package/main/wasm.js +12 -4
- package/main/wasm.spec.js +5 -2
- package/module/wasm.js +12 -4
- package/module/wasm.spec.js +5 -2
- package/package.json +2 -2
package/README.md
CHANGED
package/main/wasm.js
CHANGED
@@ -213,13 +213,20 @@ var createExecuteClass = function createExecuteClass(className, implementsClassN
|
|
213
213
|
var methods = execMsg.oneOf.map(function (schema) {
|
214
214
|
return createWasmExecMethod(schema);
|
215
215
|
});
|
216
|
+
var blockStmt = [];
|
217
|
+
|
218
|
+
if (extendsClassName) {
|
219
|
+
blockStmt.push( // super()
|
220
|
+
t.expressionStatement(t.callExpression(t["super"](), [t.identifier('client'), t.identifier('contractAddress')])));
|
221
|
+
}
|
222
|
+
|
223
|
+
[].push.apply(blockStmt, [// client/contract set
|
224
|
+
t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('client'))), t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.identifier('contractAddress')))].concat((0, _toConsumableArray2["default"])(bindings)));
|
216
225
|
return t.exportNamedDeclaration((0, _utils.classDeclaration)(className, [// client
|
217
226
|
(0, _utils.classProperty)('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), // sender
|
218
227
|
(0, _utils.classProperty)('sender', t.tsTypeAnnotation(t.tsStringKeyword())), // contractAddress
|
219
228
|
(0, _utils.classProperty)('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword())), // constructor
|
220
|
-
t.classMethod('constructor', t.identifier('constructor'), [(0, _utils.typedIdentifier)('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), (0, _utils.typedIdentifier)('sender', t.tsTypeAnnotation(t.tsStringKeyword())), (0, _utils.typedIdentifier)('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword()))], t.blockStatement([
|
221
|
-
t.expressionStatement(t.callExpression(t["super"](), [t.identifier('client'), t.identifier('contractAddress')])), // client/contract set
|
222
|
-
t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('client'))), t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.identifier('contractAddress')))].concat((0, _toConsumableArray2["default"])(bindings))))].concat((0, _toConsumableArray2["default"])(methods)), [t.tSExpressionWithTypeArguments(t.identifier(implementsClassName))], t.identifier(extendsClassName)));
|
229
|
+
t.classMethod('constructor', t.identifier('constructor'), [(0, _utils.typedIdentifier)('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), (0, _utils.typedIdentifier)('sender', t.tsTypeAnnotation(t.tsStringKeyword())), (0, _utils.typedIdentifier)('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword()))], t.blockStatement(blockStmt))].concat((0, _toConsumableArray2["default"])(methods)), [t.tSExpressionWithTypeArguments(t.identifier(implementsClassName))], extendsClassName ? t.identifier(extendsClassName) : null));
|
223
230
|
};
|
224
231
|
|
225
232
|
exports.createExecuteClass = createExecuteClass;
|
@@ -236,7 +243,8 @@ var createExecuteInterface = function createExecuteInterface(className, extendsC
|
|
236
243
|
});
|
237
244
|
return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(t.tsFunctionType(null, (0, _toConsumableArray2["default"])(params), (0, _utils.promiseTypeAnnotation)('ExecuteResult'))));
|
238
245
|
});
|
239
|
-
|
246
|
+
var extendsAst = extendsClassName ? [t.tSExpressionWithTypeArguments(t.identifier(extendsClassName))] : [];
|
247
|
+
return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, extendsAst, t.tSInterfaceBody([// contract address
|
240
248
|
t.tSPropertySignature(t.identifier('contractAddress'), t.tsTypeAnnotation(t.tsStringKeyword())), // contract address
|
241
249
|
t.tSPropertySignature(t.identifier('sender'), t.tsTypeAnnotation(t.tsStringKeyword()))].concat((0, _toConsumableArray2["default"])(methods)))));
|
242
250
|
};
|
package/main/wasm.spec.js
CHANGED
@@ -79,8 +79,11 @@ it('query classes', function () {
|
|
79
79
|
it('execute classes', function () {
|
80
80
|
expectCode((0, _wasm.createExecuteClass)('SG721Client', 'SG721Instance', 'SG721QueryClient', _execute_msg_for__empty["default"]));
|
81
81
|
});
|
82
|
-
it('execute
|
83
|
-
expectCode((0, _wasm.
|
82
|
+
it('execute classes no extends', function () {
|
83
|
+
expectCode((0, _wasm.createExecuteClass)('SG721Client', 'SG721Instance', null, _execute_msg_for__empty["default"]));
|
84
|
+
});
|
85
|
+
it('execute interfaces no extends', function () {
|
86
|
+
expectCode((0, _wasm.createExecuteInterface)('SG721Instance', null, _execute_msg_for__empty["default"]));
|
84
87
|
});
|
85
88
|
it('query interfaces', function () {
|
86
89
|
expectCode((0, _wasm.createQueryInterface)('SG721ReadOnlyInstance', _query_msg["default"]));
|
package/module/wasm.js
CHANGED
@@ -166,13 +166,20 @@ export const createExecuteClass = (className, implementsClassName, extendsClassN
|
|
166
166
|
const methods = execMsg.oneOf.map(schema => {
|
167
167
|
return createWasmExecMethod(schema);
|
168
168
|
});
|
169
|
+
const blockStmt = [];
|
170
|
+
|
171
|
+
if (extendsClassName) {
|
172
|
+
blockStmt.push( // super()
|
173
|
+
t.expressionStatement(t.callExpression(t.super(), [t.identifier('client'), t.identifier('contractAddress')])));
|
174
|
+
}
|
175
|
+
|
176
|
+
[].push.apply(blockStmt, [// client/contract set
|
177
|
+
t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('client'))), t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.identifier('contractAddress'))), ...bindings]);
|
169
178
|
return t.exportNamedDeclaration(classDeclaration(className, [// client
|
170
179
|
classProperty('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), // sender
|
171
180
|
classProperty('sender', t.tsTypeAnnotation(t.tsStringKeyword())), // contractAddress
|
172
181
|
classProperty('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword())), // constructor
|
173
|
-
t.classMethod('constructor', t.identifier('constructor'), [typedIdentifier('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), typedIdentifier('sender', t.tsTypeAnnotation(t.tsStringKeyword())), typedIdentifier('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword()))], t.blockStatement([
|
174
|
-
t.expressionStatement(t.callExpression(t.super(), [t.identifier('client'), t.identifier('contractAddress')])), // client/contract set
|
175
|
-
t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('client'))), t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.identifier('contractAddress'))), ...bindings])), ...methods], [t.tSExpressionWithTypeArguments(t.identifier(implementsClassName))], t.identifier(extendsClassName)));
|
182
|
+
t.classMethod('constructor', t.identifier('constructor'), [typedIdentifier('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), typedIdentifier('sender', t.tsTypeAnnotation(t.tsStringKeyword())), typedIdentifier('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword()))], t.blockStatement(blockStmt)), ...methods], [t.tSExpressionWithTypeArguments(t.identifier(implementsClassName))], extendsClassName ? t.identifier(extendsClassName) : null));
|
176
183
|
};
|
177
184
|
export const createExecuteInterface = (className, extendsClassName, execMsg) => {
|
178
185
|
const methods = execMsg.oneOf.map(jsonschema => {
|
@@ -184,7 +191,8 @@ export const createExecuteInterface = (className, extendsClassName, execMsg) =>
|
|
184
191
|
});
|
185
192
|
return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(t.tsFunctionType(null, [...params], promiseTypeAnnotation('ExecuteResult'))));
|
186
193
|
});
|
187
|
-
|
194
|
+
const extendsAst = extendsClassName ? [t.tSExpressionWithTypeArguments(t.identifier(extendsClassName))] : [];
|
195
|
+
return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, extendsAst, t.tSInterfaceBody([// contract address
|
188
196
|
t.tSPropertySignature(t.identifier('contractAddress'), t.tsTypeAnnotation(t.tsStringKeyword())), // contract address
|
189
197
|
t.tSPropertySignature(t.identifier('sender'), t.tsTypeAnnotation(t.tsStringKeyword())), ...methods])));
|
190
198
|
};
|
package/module/wasm.spec.js
CHANGED
@@ -61,8 +61,11 @@ it('query classes', () => {
|
|
61
61
|
it('execute classes', () => {
|
62
62
|
expectCode(createExecuteClass('SG721Client', 'SG721Instance', 'SG721QueryClient', execute_msg));
|
63
63
|
});
|
64
|
-
it('execute
|
65
|
-
expectCode(
|
64
|
+
it('execute classes no extends', () => {
|
65
|
+
expectCode(createExecuteClass('SG721Client', 'SG721Instance', null, execute_msg));
|
66
|
+
});
|
67
|
+
it('execute interfaces no extends', () => {
|
68
|
+
expectCode(createExecuteInterface('SG721Instance', null, execute_msg));
|
66
69
|
});
|
67
70
|
it('query interfaces', () => {
|
68
71
|
expectCode(createQueryInterface('SG721ReadOnlyInstance', query_msg));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "wasm-ast-types",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.6",
|
4
4
|
"description": "CosmWasm TypeScript AST generation",
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
6
6
|
"homepage": "https://github.com/pyramation/cosmscript/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": "bedb5d4d98b2779746909450960862ce4b7aa7f4"
|
89
89
|
}
|