wasm-ast-types 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- package/main/client/test/ts-client.wager.spec.js +37 -0
- package/main/utils/types.js +7 -1
- package/module/client/test/ts-client.wager.spec.js +30 -0
- package/module/utils/types.js +7 -1
- package/package.json +2 -2
- package/src/client/test/__snapshots__/ts-client.wager.spec.ts.snap +54 -0
- package/src/client/test/ts-client.wager.spec.ts +53 -0
- package/src/utils/types.ts +8 -1
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _cwWager = _interopRequireDefault(require("../../../../../__fixtures__/wager/cw-wager.json"));
|
6
|
+
|
7
|
+
var _client = require("../client");
|
8
|
+
|
9
|
+
var _testUtils = require("../../../test-utils");
|
10
|
+
|
11
|
+
var queryCtx = (0, _testUtils.makeContext)(_cwWager["default"].query);
|
12
|
+
var executeCtx = (0, _testUtils.makeContext)(_cwWager["default"].execute);
|
13
|
+
it('query', function () {
|
14
|
+
(0, _testUtils.expectCode)((0, _client.createTypeInterface)(queryCtx, _cwWager["default"].query));
|
15
|
+
});
|
16
|
+
it('execute', function () {
|
17
|
+
(0, _testUtils.expectCode)((0, _client.createTypeInterface)(executeCtx, _cwWager["default"].execute));
|
18
|
+
});
|
19
|
+
it('query classes', function () {
|
20
|
+
(0, _testUtils.expectCode)((0, _client.createQueryClass)(queryCtx, 'WagerQueryClient', 'WagerReadOnlyInstance', _cwWager["default"].query));
|
21
|
+
}); // it('execute classes array types', () => {
|
22
|
+
// expectCode(createExecuteClass(
|
23
|
+
// ctx,
|
24
|
+
// 'SG721Client',
|
25
|
+
// 'SG721Instance',
|
26
|
+
// null,
|
27
|
+
// wagerJson
|
28
|
+
// ))
|
29
|
+
// });
|
30
|
+
// it('execute interfaces no extends', () => {
|
31
|
+
// expectCode(createExecuteInterface(
|
32
|
+
// ctx,
|
33
|
+
// 'SG721Instance',
|
34
|
+
// null,
|
35
|
+
// wagerJson
|
36
|
+
// ))
|
37
|
+
// });
|
package/main/utils/types.js
CHANGED
@@ -164,7 +164,13 @@ var getTypeInfo = function getTypeInfo(info) {
|
|
164
164
|
throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
|
165
165
|
}
|
166
166
|
} else {
|
167
|
-
|
167
|
+
if (Array.isArray(info.items)) {
|
168
|
+
type = getArrayTypeFromItems(info.items); // console.log(typeof info.items === 'object');
|
169
|
+
// console.log(Array.isArray(info.items));
|
170
|
+
// console.log(info);
|
171
|
+
} else {
|
172
|
+
throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
|
173
|
+
}
|
168
174
|
}
|
169
175
|
} else {
|
170
176
|
var detect = detectType(info.type);
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import wagerJson from '../../../../../__fixtures__/wager/cw-wager.json';
|
2
|
+
import { createQueryClass, createTypeInterface } from '../client';
|
3
|
+
import { expectCode, makeContext } from '../../../test-utils';
|
4
|
+
const queryCtx = makeContext(wagerJson.query);
|
5
|
+
const executeCtx = makeContext(wagerJson.execute);
|
6
|
+
it('query', () => {
|
7
|
+
expectCode(createTypeInterface(queryCtx, wagerJson.query));
|
8
|
+
});
|
9
|
+
it('execute', () => {
|
10
|
+
expectCode(createTypeInterface(executeCtx, wagerJson.execute));
|
11
|
+
});
|
12
|
+
it('query classes', () => {
|
13
|
+
expectCode(createQueryClass(queryCtx, 'WagerQueryClient', 'WagerReadOnlyInstance', wagerJson.query));
|
14
|
+
}); // it('execute classes array types', () => {
|
15
|
+
// expectCode(createExecuteClass(
|
16
|
+
// ctx,
|
17
|
+
// 'SG721Client',
|
18
|
+
// 'SG721Instance',
|
19
|
+
// null,
|
20
|
+
// wagerJson
|
21
|
+
// ))
|
22
|
+
// });
|
23
|
+
// it('execute interfaces no extends', () => {
|
24
|
+
// expectCode(createExecuteInterface(
|
25
|
+
// ctx,
|
26
|
+
// 'SG721Instance',
|
27
|
+
// null,
|
28
|
+
// wagerJson
|
29
|
+
// ))
|
30
|
+
// });
|
package/module/utils/types.js
CHANGED
@@ -124,7 +124,13 @@ export const getTypeInfo = info => {
|
|
124
124
|
throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
|
125
125
|
}
|
126
126
|
} else {
|
127
|
-
|
127
|
+
if (Array.isArray(info.items)) {
|
128
|
+
type = getArrayTypeFromItems(info.items); // console.log(typeof info.items === 'object');
|
129
|
+
// console.log(Array.isArray(info.items));
|
130
|
+
// console.log(info);
|
131
|
+
} else {
|
132
|
+
throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
|
133
|
+
}
|
128
134
|
}
|
129
135
|
} else {
|
130
136
|
const detect = detectType(info.type);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "wasm-ast-types",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.18.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",
|
@@ -88,5 +88,5 @@
|
|
88
88
|
"case": "1.6.3",
|
89
89
|
"deepmerge": "4.2.2"
|
90
90
|
},
|
91
|
-
"gitHead": "
|
91
|
+
"gitHead": "857ca4b9661677f7c1a72d0327fb327b0a318e33"
|
92
92
|
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`execute 1`] = `"export type ExecuteMsg = ExecuteMsg;"`;
|
4
|
+
|
5
|
+
exports[`query 1`] = `"export type QueryMsg = QueryMsg;"`;
|
6
|
+
|
7
|
+
exports[`query classes 1`] = `
|
8
|
+
"export class WagerQueryClient implements WagerReadOnlyInstance {
|
9
|
+
client: CosmWasmClient;
|
10
|
+
contractAddress: string;
|
11
|
+
|
12
|
+
constructor(client: CosmWasmClient, contractAddress: string) {
|
13
|
+
this.client = client;
|
14
|
+
this.contractAddress = contractAddress;
|
15
|
+
this.wagers = this.wagers.bind(this);
|
16
|
+
this.wager = this.wager.bind(this);
|
17
|
+
this.tokenStatus = this.tokenStatus.bind(this);
|
18
|
+
this.config = this.config.bind(this);
|
19
|
+
}
|
20
|
+
|
21
|
+
wagers = async (): Promise<WagersResponse> => {
|
22
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
23
|
+
wagers: {}
|
24
|
+
});
|
25
|
+
};
|
26
|
+
wager = async ({
|
27
|
+
token
|
28
|
+
}: {
|
29
|
+
token: Addr[][];
|
30
|
+
}): Promise<WagerResponse> => {
|
31
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
32
|
+
wager: {
|
33
|
+
token
|
34
|
+
}
|
35
|
+
});
|
36
|
+
};
|
37
|
+
tokenStatus = async ({
|
38
|
+
token
|
39
|
+
}: {
|
40
|
+
token: Addr[][];
|
41
|
+
}): Promise<TokenStatusResponse> => {
|
42
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
43
|
+
token_status: {
|
44
|
+
token
|
45
|
+
}
|
46
|
+
});
|
47
|
+
};
|
48
|
+
config = async (): Promise<ConfigResponse> => {
|
49
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
50
|
+
config: {}
|
51
|
+
});
|
52
|
+
};
|
53
|
+
}"
|
54
|
+
`;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import wagerJson from '../../../../../__fixtures__/wager/cw-wager.json';
|
2
|
+
import {
|
3
|
+
createQueryClass,
|
4
|
+
createExecuteClass,
|
5
|
+
createExecuteInterface,
|
6
|
+
createTypeInterface
|
7
|
+
} from '../client'
|
8
|
+
import { expectCode, makeContext } from '../../../test-utils';
|
9
|
+
|
10
|
+
const queryCtx = makeContext(wagerJson.query);
|
11
|
+
const executeCtx = makeContext(wagerJson.execute);
|
12
|
+
|
13
|
+
it('query', () => {
|
14
|
+
expectCode(createTypeInterface(
|
15
|
+
queryCtx,
|
16
|
+
wagerJson.query
|
17
|
+
))
|
18
|
+
})
|
19
|
+
|
20
|
+
it('execute', () => {
|
21
|
+
expectCode(createTypeInterface(
|
22
|
+
executeCtx,
|
23
|
+
wagerJson.execute
|
24
|
+
))
|
25
|
+
})
|
26
|
+
|
27
|
+
it('query classes', () => {
|
28
|
+
expectCode(createQueryClass(
|
29
|
+
queryCtx,
|
30
|
+
'WagerQueryClient',
|
31
|
+
'WagerReadOnlyInstance',
|
32
|
+
wagerJson.query
|
33
|
+
))
|
34
|
+
});
|
35
|
+
|
36
|
+
// it('execute classes array types', () => {
|
37
|
+
// expectCode(createExecuteClass(
|
38
|
+
// ctx,
|
39
|
+
// 'SG721Client',
|
40
|
+
// 'SG721Instance',
|
41
|
+
// null,
|
42
|
+
// wagerJson
|
43
|
+
// ))
|
44
|
+
// });
|
45
|
+
|
46
|
+
// it('execute interfaces no extends', () => {
|
47
|
+
// expectCode(createExecuteInterface(
|
48
|
+
// ctx,
|
49
|
+
// 'SG721Instance',
|
50
|
+
// null,
|
51
|
+
// wagerJson
|
52
|
+
// ))
|
53
|
+
// });
|
package/src/utils/types.ts
CHANGED
@@ -147,7 +147,14 @@ export const getTypeInfo = (info: JSONSchema) => {
|
|
147
147
|
throw new Error('[info.items] case not handled by transpiler. contact maintainers.')
|
148
148
|
}
|
149
149
|
} else {
|
150
|
-
|
150
|
+
if (Array.isArray(info.items)) {
|
151
|
+
type = getArrayTypeFromItems(info.items);
|
152
|
+
// console.log(typeof info.items === 'object');
|
153
|
+
// console.log(Array.isArray(info.items));
|
154
|
+
// console.log(info);
|
155
|
+
} else {
|
156
|
+
throw new Error('[info.items] case not handled by transpiler. contact maintainers.')
|
157
|
+
}
|
151
158
|
}
|
152
159
|
} else {
|
153
160
|
const detect = detectType(info.type);
|