wasm-ast-types 0.0.4 → 0.0.5

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/wasm.js CHANGED
@@ -219,7 +219,7 @@ var createExecuteClass = function createExecuteClass(className, implementsClassN
219
219
  (0, _utils.classProperty)('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword())), // constructor
220
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([// super()
221
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)));
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))], extendsClassName ? t.identifier(extendsClassName) : null));
223
223
  };
224
224
 
225
225
  exports.createExecuteClass = createExecuteClass;
@@ -236,7 +236,8 @@ var createExecuteInterface = function createExecuteInterface(className, extendsC
236
236
  });
237
237
  return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(t.tsFunctionType(null, (0, _toConsumableArray2["default"])(params), (0, _utils.promiseTypeAnnotation)('ExecuteResult'))));
238
238
  });
239
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, [t.tSExpressionWithTypeArguments(t.identifier(extendsClassName))], t.tSInterfaceBody([// contract address
239
+ var extendsAst = extendsClassName ? [t.tSExpressionWithTypeArguments(t.identifier(extendsClassName))] : [];
240
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, extendsAst, t.tSInterfaceBody([// contract address
240
241
  t.tSPropertySignature(t.identifier('contractAddress'), t.tsTypeAnnotation(t.tsStringKeyword())), // contract address
241
242
  t.tSPropertySignature(t.identifier('sender'), t.tsTypeAnnotation(t.tsStringKeyword()))].concat((0, _toConsumableArray2["default"])(methods)))));
242
243
  };
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 interfaces', function () {
83
- expectCode((0, _wasm.createExecuteInterface)('SG721Instance', 'SG721ReadOnlyInstance', _execute_msg_for__empty["default"]));
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
@@ -172,7 +172,7 @@ export const createExecuteClass = (className, implementsClassName, extendsClassN
172
172
  classProperty('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword())), // constructor
173
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([// super()
174
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)));
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))], extendsClassName ? t.identifier(extendsClassName) : null));
176
176
  };
177
177
  export const createExecuteInterface = (className, extendsClassName, execMsg) => {
178
178
  const methods = execMsg.oneOf.map(jsonschema => {
@@ -184,7 +184,8 @@ export const createExecuteInterface = (className, extendsClassName, execMsg) =>
184
184
  });
185
185
  return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(t.tsFunctionType(null, [...params], promiseTypeAnnotation('ExecuteResult'))));
186
186
  });
187
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, [t.tSExpressionWithTypeArguments(t.identifier(extendsClassName))], t.tSInterfaceBody([// contract address
187
+ const extendsAst = extendsClassName ? [t.tSExpressionWithTypeArguments(t.identifier(extendsClassName))] : [];
188
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(className), null, extendsAst, t.tSInterfaceBody([// contract address
188
189
  t.tSPropertySignature(t.identifier('contractAddress'), t.tsTypeAnnotation(t.tsStringKeyword())), // contract address
189
190
  t.tSPropertySignature(t.identifier('sender'), t.tsTypeAnnotation(t.tsStringKeyword())), ...methods])));
190
191
  };
@@ -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 interfaces', () => {
65
- expectCode(createExecuteInterface('SG721Instance', 'SG721ReadOnlyInstance', execute_msg));
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.4",
3
+ "version": "0.0.5",
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": "e2b5cd65b9caf2cc9f916533bc78dded5ea32b40"
88
+ "gitHead": "a326d6904c01635ce0eeedd31a600e515392dc80"
89
89
  }