wasm-ast-types 0.1.4 → 0.2.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.
- package/main/index.js +13 -0
- package/main/react-query.js +113 -0
- package/main/react-query.spec.js +39 -0
- package/main/recoil.js +4 -10
- package/main/types.js +4 -0
- package/main/utils.js +34 -1
- package/main/wasm.js +10 -17
- package/module/index.js +2 -1
- package/module/react-query.js +82 -0
- package/module/react-query.spec.js +26 -0
- package/module/recoil.js +1 -8
- package/module/types.js +3 -0
- package/module/utils.js +21 -0
- package/module/wasm.js +3 -10
- package/package.json +2 -2
- package/types/index.d.ts +1 -0
- package/types/react-query.d.ts +20 -0
- package/types/recoil.d.ts +1 -8
- package/types/types.d.ts +14 -0
- package/types/utils.d.ts +7 -2
- package/types/wasm.d.ts +5 -16
package/main/index.js
CHANGED
@@ -41,4 +41,17 @@ Object.keys(_recoil).forEach(function (key) {
|
|
41
41
|
return _recoil[key];
|
42
42
|
}
|
43
43
|
});
|
44
|
+
});
|
45
|
+
|
46
|
+
var _reactQuery = require("./react-query");
|
47
|
+
|
48
|
+
Object.keys(_reactQuery).forEach(function (key) {
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
50
|
+
if (key in exports && exports[key] === _reactQuery[key]) return;
|
51
|
+
Object.defineProperty(exports, key, {
|
52
|
+
enumerable: true,
|
53
|
+
get: function get() {
|
54
|
+
return _reactQuery[key];
|
55
|
+
}
|
56
|
+
});
|
44
57
|
});
|
@@ -0,0 +1,113 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
+
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
exports.createReactQueryHooks = exports.createReactQueryHookInterface = exports.createReactQueryHook = void 0;
|
11
|
+
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
13
|
+
|
14
|
+
var t = _interopRequireWildcard(require("@babel/types"));
|
15
|
+
|
16
|
+
var _case = require("case");
|
17
|
+
|
18
|
+
var _utils = require("./utils");
|
19
|
+
|
20
|
+
var _wasm = require("./wasm");
|
21
|
+
|
22
|
+
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); }
|
23
|
+
|
24
|
+
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; }
|
25
|
+
|
26
|
+
var createReactQueryHooks = function createReactQueryHooks(queryMsg, contractName, QueryClient) {
|
27
|
+
return (0, _utils.getMessageProperties)(queryMsg).reduce(function (m, schema) {
|
28
|
+
var underscoreName = Object.keys(schema.properties)[0];
|
29
|
+
var methodName = (0, _case.camel)(underscoreName);
|
30
|
+
var hookName = "use".concat((0, _case.pascal)(contractName)).concat((0, _case.pascal)(methodName), "Query");
|
31
|
+
var hookParamsTypeName = "".concat((0, _case.pascal)(contractName)).concat((0, _case.pascal)(methodName), "Query");
|
32
|
+
var responseType = (0, _case.pascal)("".concat(methodName, "Response"));
|
33
|
+
var getterKey = (0, _case.camel)("".concat(contractName).concat((0, _case.pascal)(methodName)));
|
34
|
+
var jsonschema = schema.properties[underscoreName];
|
35
|
+
return [createReactQueryHookInterface({
|
36
|
+
hookParamsTypeName: hookParamsTypeName,
|
37
|
+
responseType: responseType,
|
38
|
+
QueryClient: QueryClient,
|
39
|
+
jsonschema: jsonschema
|
40
|
+
}), createReactQueryHook({
|
41
|
+
methodName: methodName,
|
42
|
+
hookName: hookName,
|
43
|
+
hookParamsTypeName: hookParamsTypeName,
|
44
|
+
responseType: responseType,
|
45
|
+
hookKeyName: getterKey,
|
46
|
+
jsonschema: jsonschema
|
47
|
+
})].concat((0, _toConsumableArray2["default"])(m));
|
48
|
+
}, []);
|
49
|
+
};
|
50
|
+
|
51
|
+
exports.createReactQueryHooks = createReactQueryHooks;
|
52
|
+
|
53
|
+
var createReactQueryHook = function createReactQueryHook(_ref) {
|
54
|
+
var _jsonschema$propertie;
|
55
|
+
|
56
|
+
var hookName = _ref.hookName,
|
57
|
+
hookParamsTypeName = _ref.hookParamsTypeName,
|
58
|
+
responseType = _ref.responseType,
|
59
|
+
hookKeyName = _ref.hookKeyName,
|
60
|
+
methodName = _ref.methodName,
|
61
|
+
jsonschema = _ref.jsonschema;
|
62
|
+
var keys = Object.keys((_jsonschema$propertie = jsonschema.properties) !== null && _jsonschema$propertie !== void 0 ? _jsonschema$propertie : {});
|
63
|
+
var args = [];
|
64
|
+
|
65
|
+
if (keys.length) {
|
66
|
+
args = [t.objectExpression((0, _toConsumableArray2["default"])(keys.map(function (prop) {
|
67
|
+
return t.objectProperty(t.identifier((0, _case.camel)(prop)), t.memberExpression(t.identifier('args'), t.identifier((0, _case.camel)(prop))));
|
68
|
+
})))];
|
69
|
+
}
|
70
|
+
|
71
|
+
var props = ['client', 'options'];
|
72
|
+
|
73
|
+
if (keys.length) {
|
74
|
+
props = ['client', 'args', 'options'];
|
75
|
+
}
|
76
|
+
|
77
|
+
return t.exportNamedDeclaration(t.functionDeclaration(t.identifier(hookName), [(0, _utils.tsObjectPattern)((0, _toConsumableArray2["default"])(props.map(function (prop) {
|
78
|
+
return t.objectProperty(t.identifier(prop), t.identifier(prop), false, true);
|
79
|
+
})), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName))))], t.blockStatement([t.returnStatement((0, _utils.callExpression)(t.identifier('useQuery'), [t.arrayExpression([t.stringLiteral(hookKeyName), t.memberExpression(t.identifier('client'), t.identifier('contractAddress'))]), t.arrowFunctionExpression([], t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), false), 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()])))])))])));
|
80
|
+
};
|
81
|
+
|
82
|
+
exports.createReactQueryHook = createReactQueryHook;
|
83
|
+
|
84
|
+
var createReactQueryHookInterface = function createReactQueryHookInterface(_ref2) {
|
85
|
+
var QueryClient = _ref2.QueryClient,
|
86
|
+
hookParamsTypeName = _ref2.hookParamsTypeName,
|
87
|
+
responseType = _ref2.responseType,
|
88
|
+
jsonschema = _ref2.jsonschema;
|
89
|
+
var body = [t.tsPropertySignature(t.identifier('client'), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(QueryClient)))), (0, _utils.tsPropertySignature)(t.identifier('options'), t.tsTypeAnnotation(t.tsTypeReference(t.identifier('UseQueryOptions'), 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()])))]))), true)];
|
90
|
+
var props = getProps(jsonschema, true);
|
91
|
+
|
92
|
+
if (props.length) {
|
93
|
+
body.push(t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation(t.tsTypeLiteral(props))));
|
94
|
+
}
|
95
|
+
|
96
|
+
return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), null, [], t.tsInterfaceBody(body)));
|
97
|
+
};
|
98
|
+
|
99
|
+
exports.createReactQueryHookInterface = createReactQueryHookInterface;
|
100
|
+
|
101
|
+
var getProps = function getProps(jsonschema, camelize) {
|
102
|
+
var _jsonschema$propertie2;
|
103
|
+
|
104
|
+
var keys = Object.keys((_jsonschema$propertie2 = jsonschema.properties) !== null && _jsonschema$propertie2 !== void 0 ? _jsonschema$propertie2 : {});
|
105
|
+
if (!keys.length) return [];
|
106
|
+
return keys.map(function (prop) {
|
107
|
+
var _getPropertyType = (0, _wasm.getPropertyType)(jsonschema, prop),
|
108
|
+
type = _getPropertyType.type,
|
109
|
+
optional = _getPropertyType.optional;
|
110
|
+
|
111
|
+
return (0, _wasm.propertySignature)(camelize ? (0, _case.camel)(prop) : prop, t.tsTypeAnnotation(type), optional);
|
112
|
+
});
|
113
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
+
|
7
|
+
var _generator = _interopRequireDefault(require("@babel/generator"));
|
8
|
+
|
9
|
+
var t = _interopRequireWildcard(require("@babel/types"));
|
10
|
+
|
11
|
+
var _query_msg = _interopRequireDefault(require("./__fixtures__/schema/query_msg.json"));
|
12
|
+
|
13
|
+
var _reactQuery = require("./react-query");
|
14
|
+
|
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); }
|
16
|
+
|
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; }
|
18
|
+
|
19
|
+
var expectCode = function expectCode(ast) {
|
20
|
+
expect((0, _generator["default"])(ast).code).toMatchSnapshot();
|
21
|
+
};
|
22
|
+
|
23
|
+
var printCode = function printCode(ast) {
|
24
|
+
console.log((0, _generator["default"])(ast).code);
|
25
|
+
}; // it('createReactQueryHook', () => {
|
26
|
+
// printCode(createReactQueryHook({
|
27
|
+
// methodName: 'allNftInfo',
|
28
|
+
// hookName: 'useSg721AllNftInfoQuery',
|
29
|
+
// hookParamsTypeName: 'Sg721CollectionInfoQuery',
|
30
|
+
// responseType: 'AllNftInfoResponse',
|
31
|
+
// hookKeyName: 'Sg721AllNftInfo'
|
32
|
+
// }))
|
33
|
+
// });
|
34
|
+
|
35
|
+
|
36
|
+
it('createReactQueryHooks', function () {
|
37
|
+
printCode(t.program((0, _reactQuery.createReactQueryHooks)(_query_msg["default"], 'Sg721', 'Sg721QueryClient')));
|
38
|
+
expectCode(t.program((0, _reactQuery.createReactQueryHooks)(_query_msg["default"], 'Sg721', 'Sg721QueryClient')));
|
39
|
+
});
|
package/main/recoil.js
CHANGED
@@ -11,7 +11,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
|
|
11
11
|
|
12
12
|
var _case = require("case");
|
13
13
|
|
14
|
-
var
|
14
|
+
var _utils = require("./utils");
|
15
15
|
|
16
16
|
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); }
|
17
17
|
|
@@ -30,12 +30,6 @@ var createWasmRecoilMethod = function createWasmRecoilMethod(jsonschema) {
|
|
30
30
|
|
31
31
|
exports.createWasmRecoilMethod = createWasmRecoilMethod;
|
32
32
|
|
33
|
-
var callExpression = function callExpression(callee, _arguments, typeParameters) {
|
34
|
-
var callExpr = t.callExpression(callee, _arguments);
|
35
|
-
callExpr.typeParameters = typeParameters;
|
36
|
-
return callExpr;
|
37
|
-
};
|
38
|
-
|
39
33
|
var createRecoilSelector = function createRecoilSelector(keyPrefix, QueryClient, methodName) {
|
40
34
|
// const propertyNames = getMessageProperties(queryMsg)
|
41
35
|
// .map(method => Object.keys(method.properties)?.[0])
|
@@ -45,14 +39,14 @@ var createRecoilSelector = function createRecoilSelector(keyPrefix, QueryClient,
|
|
45
39
|
var selectorName = (0, _case.camel)("".concat(methodName, "Selector"));
|
46
40
|
var responseType = (0, _case.pascal)("".concat(methodName, "Response"));
|
47
41
|
var getterKey = (0, _case.camel)("".concat(keyPrefix).concat((0, _case.pascal)(methodName)));
|
48
|
-
return t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(t.identifier(selectorName), 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.ifStatement(t.unaryExpression('!', t.identifier('client')), t.returnStatement(null), null), t.returnStatement(t.awaitExpression(t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), [// t.identifier('params')
|
42
|
+
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.ifStatement(t.unaryExpression('!', t.identifier('client')), t.returnStatement(null), null), t.returnStatement(t.awaitExpression(t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), [// t.identifier('params')
|
49
43
|
t.spreadElement(t.identifier('params'))])))]), true)))])], t.tsTypeParameterInstantiation([t.tsUnionType([t.tsTypeReference(t.identifier(responseType)), t.tsUndefinedKeyword()]), 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)))]))))])])])))]));
|
50
44
|
};
|
51
45
|
|
52
46
|
exports.createRecoilSelector = createRecoilSelector;
|
53
47
|
|
54
48
|
var createRecoilSelectors = function createRecoilSelectors(keyPrefix, QueryClient, queryMsg) {
|
55
|
-
return (0,
|
49
|
+
return (0, _utils.getMessageProperties)(queryMsg).map(function (schema) {
|
56
50
|
var underscoreName = Object.keys(schema.properties)[0];
|
57
51
|
var methodName = (0, _case.camel)(underscoreName);
|
58
52
|
return createRecoilSelector(keyPrefix, QueryClient, methodName);
|
@@ -92,7 +86,7 @@ exports.createRecoilQueryClientType = createRecoilQueryClientType;
|
|
92
86
|
|
93
87
|
var createRecoilQueryClient = function createRecoilQueryClient(keyPrefix, QueryClient) {
|
94
88
|
var getterKey = (0, _case.camel)("".concat(keyPrefix, 'QueryClient'));
|
95
|
-
return t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(t.identifier('queryClient'), 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('contractAddress'), t.identifier('contractAddress'), false, true)])], 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.identifier('cosmWasmClient')]))]), t.ifStatement(t.unaryExpression('!', t.identifier('client')), t.returnStatement(null), null), t.returnStatement(t.newExpression(t.identifier(QueryClient), [t.identifier('client'), t.identifier('contractAddress')]))]), false)))])], t.tsTypeParameterInstantiation([t.tsUnionType([t.tsTypeReference(t.identifier(QueryClient)), t.tsUndefinedKeyword()]), t.tsTypeReference(t.identifier('QueryClientParams'))])))]));
|
89
|
+
return t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(t.identifier('queryClient'), (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('contractAddress'), t.identifier('contractAddress'), false, true)])], 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.identifier('cosmWasmClient')]))]), t.ifStatement(t.unaryExpression('!', t.identifier('client')), t.returnStatement(null), null), t.returnStatement(t.newExpression(t.identifier(QueryClient), [t.identifier('client'), t.identifier('contractAddress')]))]), false)))])], t.tsTypeParameterInstantiation([t.tsUnionType([t.tsTypeReference(t.identifier(QueryClient)), t.tsUndefinedKeyword()]), t.tsTypeReference(t.identifier('QueryClientParams'))])))]));
|
96
90
|
};
|
97
91
|
|
98
92
|
exports.createRecoilQueryClient = createRecoilQueryClient;
|
package/main/types.js
ADDED
package/main/utils.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.typedIdentifier = exports.shorthandProperty = exports.recursiveNamespace = exports.promiseTypeAnnotation = exports.memberExpressionOrIdentifierSnake = exports.memberExpressionOrIdentifier = exports.importStmt = exports.importAminoMsg = exports.getFieldDimensionality = exports.classProperty = exports.classDeclaration = exports.bindMethod = exports.arrowFunctionExpression = exports.arrayTypeNDimensions = exports.FieldTypeAsts = void 0;
|
10
|
+
exports.typedIdentifier = exports.tsPropertySignature = exports.tsObjectPattern = exports.shorthandProperty = exports.recursiveNamespace = exports.promiseTypeAnnotation = exports.memberExpressionOrIdentifierSnake = exports.memberExpressionOrIdentifier = exports.importStmt = exports.importAminoMsg = exports.getMessageProperties = exports.getFieldDimensionality = exports.classProperty = exports.classDeclaration = exports.callExpression = exports.bindMethod = exports.arrowFunctionExpression = exports.arrayTypeNDimensions = exports.FieldTypeAsts = void 0;
|
11
11
|
|
12
12
|
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
|
13
13
|
|
@@ -21,6 +21,39 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
21
21
|
|
22
22
|
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; }
|
23
23
|
|
24
|
+
var getMessageProperties = function getMessageProperties(msg) {
|
25
|
+
if (msg.anyOf) return msg.anyOf;
|
26
|
+
if (msg.oneOf) return msg.oneOf;
|
27
|
+
if (msg.allOf) return msg.allOf;
|
28
|
+
return [];
|
29
|
+
};
|
30
|
+
|
31
|
+
exports.getMessageProperties = getMessageProperties;
|
32
|
+
|
33
|
+
var tsPropertySignature = function tsPropertySignature(key, typeAnnotation, optional) {
|
34
|
+
var obj = t.tsPropertySignature(key, typeAnnotation);
|
35
|
+
obj.optional = optional;
|
36
|
+
return obj;
|
37
|
+
};
|
38
|
+
|
39
|
+
exports.tsPropertySignature = tsPropertySignature;
|
40
|
+
|
41
|
+
var tsObjectPattern = function tsObjectPattern(properties, typeAnnotation) {
|
42
|
+
var obj = t.objectPattern(properties);
|
43
|
+
obj.typeAnnotation = typeAnnotation;
|
44
|
+
return obj;
|
45
|
+
};
|
46
|
+
|
47
|
+
exports.tsObjectPattern = tsObjectPattern;
|
48
|
+
|
49
|
+
var callExpression = function callExpression(callee, _arguments, typeParameters) {
|
50
|
+
var callExpr = t.callExpression(callee, _arguments);
|
51
|
+
callExpr.typeParameters = typeParameters;
|
52
|
+
return callExpr;
|
53
|
+
};
|
54
|
+
|
55
|
+
exports.callExpression = callExpression;
|
56
|
+
|
24
57
|
var bindMethod = function bindMethod(name) {
|
25
58
|
return t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier(name)), t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(name)), t.identifier('bind')), [t.thisExpression()])));
|
26
59
|
};
|
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.
|
10
|
+
exports.propertySignature = exports.getPropertyType = 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
|
|
@@ -23,19 +23,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
23
23
|
|
24
24
|
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; }
|
25
25
|
|
26
|
-
var getMessageProperties = function getMessageProperties(msg) {
|
27
|
-
if (msg.anyOf) return msg.anyOf;
|
28
|
-
if (msg.oneOf) return msg.oneOf;
|
29
|
-
if (msg.allOf) return msg.allOf;
|
30
|
-
return [];
|
31
|
-
};
|
32
|
-
|
33
|
-
exports.getMessageProperties = getMessageProperties;
|
34
|
-
|
35
26
|
var getTypeFromRef = function getTypeFromRef($ref) {
|
36
27
|
switch ($ref) {
|
37
28
|
case '#/definitions/Binary':
|
38
|
-
return t.tsTypeReference(t.identifier('
|
29
|
+
return t.tsTypeReference(t.identifier('Binary'));
|
39
30
|
|
40
31
|
case '#/definitions/Expiration':
|
41
32
|
return t.tsTypeReference(t.identifier('Expiration'));
|
@@ -151,6 +142,8 @@ var getPropertyType = function getPropertyType(schema, prop) {
|
|
151
142
|
};
|
152
143
|
};
|
153
144
|
|
145
|
+
exports.getPropertyType = getPropertyType;
|
146
|
+
|
154
147
|
var createWasmQueryMethod = function createWasmQueryMethod(jsonschema) {
|
155
148
|
var _jsonschema$propertie;
|
156
149
|
|
@@ -169,13 +162,13 @@ var createWasmQueryMethod = function createWasmQueryMethod(jsonschema) {
|
|
169
162
|
exports.createWasmQueryMethod = createWasmQueryMethod;
|
170
163
|
|
171
164
|
var createQueryClass = function createQueryClass(className, implementsClassName, queryMsg) {
|
172
|
-
var propertyNames = getMessageProperties(queryMsg).map(function (method) {
|
165
|
+
var propertyNames = (0, _utils.getMessageProperties)(queryMsg).map(function (method) {
|
173
166
|
var _Object$keys;
|
174
167
|
|
175
168
|
return (_Object$keys = Object.keys(method.properties)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
|
176
169
|
}).filter(Boolean);
|
177
170
|
var bindings = propertyNames.map(_case.camel).map(_utils.bindMethod);
|
178
|
-
var methods = getMessageProperties(queryMsg).map(function (schema) {
|
171
|
+
var methods = (0, _utils.getMessageProperties)(queryMsg).map(function (schema) {
|
179
172
|
return createWasmQueryMethod(schema);
|
180
173
|
});
|
181
174
|
return t.exportNamedDeclaration((0, _utils.classDeclaration)(className, [// client
|
@@ -205,13 +198,13 @@ var createWasmExecMethod = function createWasmExecMethod(jsonschema) {
|
|
205
198
|
exports.createWasmExecMethod = createWasmExecMethod;
|
206
199
|
|
207
200
|
var createExecuteClass = function createExecuteClass(className, implementsClassName, extendsClassName, execMsg) {
|
208
|
-
var propertyNames = getMessageProperties(execMsg).map(function (method) {
|
201
|
+
var propertyNames = (0, _utils.getMessageProperties)(execMsg).map(function (method) {
|
209
202
|
var _Object$keys2;
|
210
203
|
|
211
204
|
return (_Object$keys2 = Object.keys(method.properties)) === null || _Object$keys2 === void 0 ? void 0 : _Object$keys2[0];
|
212
205
|
}).filter(Boolean);
|
213
206
|
var bindings = propertyNames.map(_case.camel).map(_utils.bindMethod);
|
214
|
-
var methods = getMessageProperties(execMsg).map(function (schema) {
|
207
|
+
var methods = (0, _utils.getMessageProperties)(execMsg).map(function (schema) {
|
215
208
|
return createWasmExecMethod(schema);
|
216
209
|
});
|
217
210
|
var blockStmt = [];
|
@@ -233,7 +226,7 @@ var createExecuteClass = function createExecuteClass(className, implementsClassN
|
|
233
226
|
exports.createExecuteClass = createExecuteClass;
|
234
227
|
|
235
228
|
var createExecuteInterface = function createExecuteInterface(className, extendsClassName, execMsg) {
|
236
|
-
var methods = getMessageProperties(execMsg).map(function (jsonschema) {
|
229
|
+
var methods = (0, _utils.getMessageProperties)(execMsg).map(function (jsonschema) {
|
237
230
|
var underscoreName = Object.keys(jsonschema.properties)[0];
|
238
231
|
var methodName = (0, _case.camel)(underscoreName);
|
239
232
|
return createPropertyFunctionWithObjectParams(methodName, 'ExecuteResult', jsonschema.properties[underscoreName]);
|
@@ -302,7 +295,7 @@ var createPropertyFunctionWithObjectParams = function createPropertyFunctionWith
|
|
302
295
|
exports.createPropertyFunctionWithObjectParams = createPropertyFunctionWithObjectParams;
|
303
296
|
|
304
297
|
var createQueryInterface = function createQueryInterface(className, queryMsg) {
|
305
|
-
var methods = getMessageProperties(queryMsg).map(function (jsonschema) {
|
298
|
+
var methods = (0, _utils.getMessageProperties)(queryMsg).map(function (jsonschema) {
|
306
299
|
var underscoreName = Object.keys(jsonschema.properties)[0];
|
307
300
|
var methodName = (0, _case.camel)(underscoreName);
|
308
301
|
var responseType = (0, _case.pascal)("".concat(methodName, "Response"));
|
package/module/index.js
CHANGED
@@ -0,0 +1,82 @@
|
|
1
|
+
import * as t from '@babel/types';
|
2
|
+
import { camel, pascal } from 'case';
|
3
|
+
import { tsPropertySignature, tsObjectPattern, callExpression, getMessageProperties } from './utils';
|
4
|
+
import { propertySignature, getPropertyType } from './wasm';
|
5
|
+
export const createReactQueryHooks = (queryMsg, contractName, QueryClient) => {
|
6
|
+
return getMessageProperties(queryMsg).reduce((m, schema) => {
|
7
|
+
const underscoreName = Object.keys(schema.properties)[0];
|
8
|
+
const methodName = camel(underscoreName);
|
9
|
+
const hookName = `use${pascal(contractName)}${pascal(methodName)}Query`;
|
10
|
+
const hookParamsTypeName = `${pascal(contractName)}${pascal(methodName)}Query`;
|
11
|
+
const responseType = pascal(`${methodName}Response`);
|
12
|
+
const getterKey = camel(`${contractName}${pascal(methodName)}`);
|
13
|
+
const jsonschema = schema.properties[underscoreName];
|
14
|
+
return [createReactQueryHookInterface({
|
15
|
+
hookParamsTypeName,
|
16
|
+
responseType,
|
17
|
+
QueryClient,
|
18
|
+
jsonschema
|
19
|
+
}), createReactQueryHook({
|
20
|
+
methodName,
|
21
|
+
hookName,
|
22
|
+
hookParamsTypeName,
|
23
|
+
responseType,
|
24
|
+
hookKeyName: getterKey,
|
25
|
+
jsonschema
|
26
|
+
}), ...m];
|
27
|
+
}, []);
|
28
|
+
};
|
29
|
+
export const createReactQueryHook = ({
|
30
|
+
hookName,
|
31
|
+
hookParamsTypeName,
|
32
|
+
responseType,
|
33
|
+
hookKeyName,
|
34
|
+
methodName,
|
35
|
+
jsonschema
|
36
|
+
}) => {
|
37
|
+
const keys = Object.keys(jsonschema.properties ?? {});
|
38
|
+
let args = [];
|
39
|
+
|
40
|
+
if (keys.length) {
|
41
|
+
args = [t.objectExpression([...keys.map(prop => {
|
42
|
+
return t.objectProperty(t.identifier(camel(prop)), t.memberExpression(t.identifier('args'), t.identifier(camel(prop))));
|
43
|
+
})])];
|
44
|
+
}
|
45
|
+
|
46
|
+
let props = ['client', 'options'];
|
47
|
+
|
48
|
+
if (keys.length) {
|
49
|
+
props = ['client', 'args', 'options'];
|
50
|
+
}
|
51
|
+
|
52
|
+
return t.exportNamedDeclaration(t.functionDeclaration(t.identifier(hookName), [tsObjectPattern([...props.map(prop => {
|
53
|
+
return t.objectProperty(t.identifier(prop), t.identifier(prop), false, true);
|
54
|
+
})], t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName))))], t.blockStatement([t.returnStatement(callExpression(t.identifier('useQuery'), [t.arrayExpression([t.stringLiteral(hookKeyName), t.memberExpression(t.identifier('client'), t.identifier('contractAddress'))]), t.arrowFunctionExpression([], t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), false), 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()])))])))])));
|
55
|
+
};
|
56
|
+
export const createReactQueryHookInterface = ({
|
57
|
+
QueryClient,
|
58
|
+
hookParamsTypeName,
|
59
|
+
responseType,
|
60
|
+
jsonschema
|
61
|
+
}) => {
|
62
|
+
const body = [t.tsPropertySignature(t.identifier('client'), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(QueryClient)))), tsPropertySignature(t.identifier('options'), t.tsTypeAnnotation(t.tsTypeReference(t.identifier('UseQueryOptions'), 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()])))]))), true)];
|
63
|
+
const props = getProps(jsonschema, true);
|
64
|
+
|
65
|
+
if (props.length) {
|
66
|
+
body.push(t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation(t.tsTypeLiteral(props))));
|
67
|
+
}
|
68
|
+
|
69
|
+
return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), null, [], t.tsInterfaceBody(body)));
|
70
|
+
};
|
71
|
+
|
72
|
+
const getProps = (jsonschema, camelize) => {
|
73
|
+
const keys = Object.keys(jsonschema.properties ?? {});
|
74
|
+
if (!keys.length) return [];
|
75
|
+
return keys.map(prop => {
|
76
|
+
const {
|
77
|
+
type,
|
78
|
+
optional
|
79
|
+
} = getPropertyType(jsonschema, prop);
|
80
|
+
return propertySignature(camelize ? camel(prop) : prop, t.tsTypeAnnotation(type), optional);
|
81
|
+
});
|
82
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import generate from '@babel/generator';
|
2
|
+
import * as t from '@babel/types';
|
3
|
+
import query_msg from './__fixtures__/schema/query_msg.json';
|
4
|
+
import { createReactQueryHooks } from './react-query';
|
5
|
+
|
6
|
+
const expectCode = ast => {
|
7
|
+
expect(generate(ast).code).toMatchSnapshot();
|
8
|
+
};
|
9
|
+
|
10
|
+
const printCode = ast => {
|
11
|
+
console.log(generate(ast).code);
|
12
|
+
}; // it('createReactQueryHook', () => {
|
13
|
+
// printCode(createReactQueryHook({
|
14
|
+
// methodName: 'allNftInfo',
|
15
|
+
// hookName: 'useSg721AllNftInfoQuery',
|
16
|
+
// hookParamsTypeName: 'Sg721CollectionInfoQuery',
|
17
|
+
// responseType: 'AllNftInfoResponse',
|
18
|
+
// hookKeyName: 'Sg721AllNftInfo'
|
19
|
+
// }))
|
20
|
+
// });
|
21
|
+
|
22
|
+
|
23
|
+
it('createReactQueryHooks', () => {
|
24
|
+
printCode(t.program(createReactQueryHooks(query_msg, 'Sg721', 'Sg721QueryClient')));
|
25
|
+
expectCode(t.program(createReactQueryHooks(query_msg, 'Sg721', 'Sg721QueryClient')));
|
26
|
+
});
|
package/module/recoil.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as t from '@babel/types';
|
2
2
|
import { camel, pascal } from 'case';
|
3
|
-
import { getMessageProperties } from './
|
3
|
+
import { callExpression, getMessageProperties } from './utils';
|
4
4
|
export const createWasmRecoilMethod = jsonschema => {
|
5
5
|
const underscoreName = Object.keys(jsonschema.properties)[0];
|
6
6
|
const methodName = camel(underscoreName);
|
@@ -9,13 +9,6 @@ export const createWasmRecoilMethod = jsonschema => {
|
|
9
9
|
|
10
10
|
if (Object.keys(properties).length > 0) {} else {}
|
11
11
|
};
|
12
|
-
|
13
|
-
const callExpression = (callee, _arguments, typeParameters) => {
|
14
|
-
const callExpr = t.callExpression(callee, _arguments);
|
15
|
-
callExpr.typeParameters = typeParameters;
|
16
|
-
return callExpr;
|
17
|
-
};
|
18
|
-
|
19
12
|
export const createRecoilSelector = (keyPrefix, QueryClient, methodName) => {
|
20
13
|
// const propertyNames = getMessageProperties(queryMsg)
|
21
14
|
// .map(method => Object.keys(method.properties)?.[0])
|
package/module/types.js
ADDED
package/module/utils.js
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
import * as t from '@babel/types';
|
2
2
|
import { snake } from "case";
|
3
|
+
export const getMessageProperties = msg => {
|
4
|
+
if (msg.anyOf) return msg.anyOf;
|
5
|
+
if (msg.oneOf) return msg.oneOf;
|
6
|
+
if (msg.allOf) return msg.allOf;
|
7
|
+
return [];
|
8
|
+
};
|
9
|
+
export const tsPropertySignature = (key, typeAnnotation, optional) => {
|
10
|
+
const obj = t.tsPropertySignature(key, typeAnnotation);
|
11
|
+
obj.optional = optional;
|
12
|
+
return obj;
|
13
|
+
};
|
14
|
+
export const tsObjectPattern = (properties, typeAnnotation) => {
|
15
|
+
const obj = t.objectPattern(properties);
|
16
|
+
obj.typeAnnotation = typeAnnotation;
|
17
|
+
return obj;
|
18
|
+
};
|
19
|
+
export const callExpression = (callee, _arguments, typeParameters) => {
|
20
|
+
const callExpr = t.callExpression(callee, _arguments);
|
21
|
+
callExpr.typeParameters = typeParameters;
|
22
|
+
return callExpr;
|
23
|
+
};
|
3
24
|
export const bindMethod = name => {
|
4
25
|
return t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier(name)), t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(name)), t.identifier('bind')), [t.thisExpression()])));
|
5
26
|
};
|
package/module/wasm.js
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
import * as t from '@babel/types';
|
2
2
|
import { camel, pascal } from 'case';
|
3
|
-
import { bindMethod, typedIdentifier, promiseTypeAnnotation, classDeclaration, classProperty, arrowFunctionExpression } from './utils';
|
4
|
-
export const getMessageProperties = msg => {
|
5
|
-
if (msg.anyOf) return msg.anyOf;
|
6
|
-
if (msg.oneOf) return msg.oneOf;
|
7
|
-
if (msg.allOf) return msg.allOf;
|
8
|
-
return [];
|
9
|
-
};
|
3
|
+
import { bindMethod, typedIdentifier, promiseTypeAnnotation, classDeclaration, classProperty, arrowFunctionExpression, getMessageProperties } from './utils';
|
10
4
|
|
11
5
|
const getTypeFromRef = $ref => {
|
12
6
|
switch ($ref) {
|
13
7
|
case '#/definitions/Binary':
|
14
|
-
return t.tsTypeReference(t.identifier('
|
8
|
+
return t.tsTypeReference(t.identifier('Binary'));
|
15
9
|
|
16
10
|
case '#/definitions/Expiration':
|
17
11
|
return t.tsTypeReference(t.identifier('Expiration'));
|
@@ -49,7 +43,7 @@ const getType = type => {
|
|
49
43
|
}
|
50
44
|
};
|
51
45
|
|
52
|
-
const getPropertyType = (schema, prop) => {
|
46
|
+
export const getPropertyType = (schema, prop) => {
|
53
47
|
const props = schema.properties ?? {};
|
54
48
|
let info = props[prop];
|
55
49
|
let type = null;
|
@@ -120,7 +114,6 @@ const getPropertyType = (schema, prop) => {
|
|
120
114
|
optional
|
121
115
|
};
|
122
116
|
};
|
123
|
-
|
124
117
|
export const createWasmQueryMethod = jsonschema => {
|
125
118
|
const underscoreName = Object.keys(jsonschema.properties)[0];
|
126
119
|
const methodName = camel(underscoreName);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "wasm-ast-types",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.2.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",
|
@@ -85,5 +85,5 @@
|
|
85
85
|
"ast-stringify": "0.1.0",
|
86
86
|
"case": "1.6.3"
|
87
87
|
},
|
88
|
-
"gitHead": "
|
88
|
+
"gitHead": "93a3bca65ba5aec086efeb3ae85950a346ddf0ff"
|
89
89
|
}
|
package/types/index.d.ts
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
import * as t from '@babel/types';
|
2
|
+
import { QueryMsg } from './types';
|
3
|
+
interface ReactQueryHookQuery {
|
4
|
+
hookName: string;
|
5
|
+
hookParamsTypeName: string;
|
6
|
+
hookKeyName: string;
|
7
|
+
responseType: string;
|
8
|
+
methodName: string;
|
9
|
+
jsonschema: any;
|
10
|
+
}
|
11
|
+
export declare const createReactQueryHooks: (queryMsg: QueryMsg, contractName: string, QueryClient: string) => any;
|
12
|
+
export declare const createReactQueryHook: ({ hookName, hookParamsTypeName, responseType, hookKeyName, methodName, jsonschema }: ReactQueryHookQuery) => t.ExportNamedDeclaration;
|
13
|
+
interface ReactQueryHookQueryInterface {
|
14
|
+
QueryClient: string;
|
15
|
+
hookParamsTypeName: string;
|
16
|
+
responseType: string;
|
17
|
+
jsonschema: any;
|
18
|
+
}
|
19
|
+
export declare const createReactQueryHookInterface: ({ QueryClient, hookParamsTypeName, responseType, jsonschema }: ReactQueryHookQueryInterface) => t.ExportNamedDeclaration;
|
20
|
+
export {};
|
package/types/recoil.d.ts
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
import * as t from '@babel/types';
|
2
|
-
|
3
|
-
$schema: string;
|
4
|
-
title: "QueryMsg";
|
5
|
-
oneOf?: any;
|
6
|
-
allOf?: any;
|
7
|
-
anyOf?: any;
|
8
|
-
}
|
2
|
+
import { QueryMsg } from './types';
|
9
3
|
export declare const createWasmRecoilMethod: (jsonschema: any) => void;
|
10
4
|
export declare const createRecoilSelector: (keyPrefix: string, QueryClient: string, methodName: string) => t.ExportNamedDeclaration;
|
11
5
|
export declare const createRecoilSelectors: (keyPrefix: string, QueryClient: string, queryMsg: QueryMsg) => any;
|
@@ -34,4 +28,3 @@ export declare const createRecoilQueryClientType: () => {
|
|
34
28
|
};
|
35
29
|
};
|
36
30
|
export declare const createRecoilQueryClient: (keyPrefix: string, QueryClient: string) => t.ExportNamedDeclaration;
|
37
|
-
export {};
|
package/types/types.d.ts
CHANGED
@@ -8,3 +8,17 @@ export interface Interface {
|
|
8
8
|
name: string;
|
9
9
|
fields: Field[];
|
10
10
|
}
|
11
|
+
export interface QueryMsg {
|
12
|
+
$schema: string;
|
13
|
+
title: "QueryMsg";
|
14
|
+
oneOf?: any;
|
15
|
+
allOf?: any;
|
16
|
+
anyOf?: any;
|
17
|
+
}
|
18
|
+
export interface ExecuteMsg {
|
19
|
+
$schema: string;
|
20
|
+
title: "ExecuteMsg" | "ExecuteMsg_for_Empty";
|
21
|
+
oneOf?: any;
|
22
|
+
allOf?: any;
|
23
|
+
anyOf?: any;
|
24
|
+
}
|
package/types/utils.d.ts
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
import * as t from '@babel/types';
|
2
|
+
import { Field, QueryMsg } from './types';
|
2
3
|
import { TSTypeAnnotation, TSExpressionWithTypeArguments } from '@babel/types';
|
4
|
+
export declare const getMessageProperties: (msg: QueryMsg | ExecuteMsg) => any;
|
5
|
+
export declare const tsPropertySignature: (key: t.Expression, typeAnnotation: t.TSTypeAnnotation, optional: boolean) => t.TSPropertySignature;
|
6
|
+
export declare const tsObjectPattern: (properties: (t.RestElement | t.ObjectProperty)[], typeAnnotation: t.TSTypeAnnotation) => t.ObjectPattern;
|
7
|
+
export declare const callExpression: (callee: t.Expression | t.V8IntrinsicIdentifier, _arguments: (t.Expression | t.SpreadElement | t.ArgumentPlaceholder)[], typeParameters: t.TSTypeParameterInstantiation) => t.CallExpression;
|
3
8
|
export declare const bindMethod: (name: string) => t.ExpressionStatement;
|
4
9
|
export declare const typedIdentifier: (name: string, typeAnnotation: TSTypeAnnotation, optional?: boolean) => t.Identifier;
|
5
10
|
export declare const promiseTypeAnnotation: (name: any) => t.TSTypeAnnotation;
|
@@ -20,9 +25,9 @@ export declare const shorthandProperty: (prop: string) => t.ObjectProperty;
|
|
20
25
|
export declare const importStmt: (names: string[], path: string) => t.ImportDeclaration;
|
21
26
|
export declare const importAminoMsg: () => t.ImportDeclaration;
|
22
27
|
export declare const getFieldDimensionality: (field: Field) => {
|
23
|
-
typeName:
|
28
|
+
typeName: string;
|
24
29
|
dimensions: number;
|
25
|
-
isArray:
|
30
|
+
isArray: boolean;
|
26
31
|
};
|
27
32
|
export declare const memberExpressionOrIdentifier: (names: any) => any;
|
28
33
|
export declare const memberExpressionOrIdentifierSnake: (names: any) => any;
|
package/types/wasm.d.ts
CHANGED
@@ -1,19 +1,9 @@
|
|
1
1
|
import * as t from '@babel/types';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
anyOf?: any;
|
8
|
-
}
|
9
|
-
interface ExecuteMsg {
|
10
|
-
$schema: string;
|
11
|
-
title: "ExecuteMsg" | "ExecuteMsg_for_Empty";
|
12
|
-
oneOf?: any;
|
13
|
-
allOf?: any;
|
14
|
-
anyOf?: any;
|
15
|
-
}
|
16
|
-
export declare const getMessageProperties: (msg: QueryMsg | ExecuteMsg) => any;
|
2
|
+
import { QueryMsg, ExecuteMsg } from './types';
|
3
|
+
export declare const getPropertyType: (schema: any, prop: any) => {
|
4
|
+
type: any;
|
5
|
+
optional: any;
|
6
|
+
};
|
17
7
|
export declare const createWasmQueryMethod: (jsonschema: any) => t.ClassProperty;
|
18
8
|
export declare const createQueryClass: (className: string, implementsClassName: string, queryMsg: QueryMsg) => t.ExportNamedDeclaration;
|
19
9
|
export declare const createWasmExecMethod: (jsonschema: any) => t.ClassProperty;
|
@@ -30,4 +20,3 @@ export declare const createPropertyFunctionWithObjectParams: (methodName: string
|
|
30
20
|
export declare const createQueryInterface: (className: string, queryMsg: QueryMsg) => t.ExportNamedDeclaration;
|
31
21
|
export declare const createTypeOrInterface: (Type: string, jsonschema: any) => t.ExportNamedDeclaration;
|
32
22
|
export declare const createTypeInterface: (jsonschema: any) => t.ExportNamedDeclaration;
|
33
|
-
export {};
|