wasm-ast-types 0.11.3 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/main/client/test/ts-client.issue-71.test.js +103 -0
- package/main/context/context.js +2 -1
- package/main/utils/types.js +20 -7
- package/module/client/test/ts-client.issue-71.test.js +21 -0
- package/module/context/context.js +2 -1
- package/module/utils/types.js +20 -7
- package/package.json +5 -3
- package/src/client/client.ts +665 -0
- package/src/client/index.ts +1 -0
- package/src/client/test/__snapshots__/ts-client.account-nfts.spec.ts.snap +497 -0
- package/src/client/test/__snapshots__/ts-client.arrays-ref.spec.ts.snap +452 -0
- package/src/client/test/__snapshots__/ts-client.arrays.spec.ts.snap +101 -0
- package/src/client/test/__snapshots__/ts-client.cw-named-groups.test.ts.snap +141 -0
- package/src/client/test/__snapshots__/ts-client.cw-proposal-single.test.ts.snap +341 -0
- package/src/client/test/__snapshots__/ts-client.empty-enums.spec.ts.snap +20 -0
- package/src/client/test/__snapshots__/ts-client.issue-71.test.ts.snap +432 -0
- package/src/client/test/__snapshots__/ts-client.issues.test.ts.snap +984 -0
- package/src/client/test/__snapshots__/ts-client.sg721.spec.ts.snap +350 -0
- package/src/client/test/__snapshots__/ts-client.spec.ts.snap +723 -0
- package/src/client/test/__snapshots__/ts-client.vectis.spec.ts.snap +337 -0
- package/src/client/test/ts-client.account-nfts.spec.ts +55 -0
- package/src/client/test/ts-client.arrays-ref.spec.ts +48 -0
- package/src/client/test/ts-client.arrays.spec.ts +58 -0
- package/src/client/test/ts-client.cw-named-groups.test.ts +48 -0
- package/src/client/test/ts-client.cw-proposal-single.test.ts +50 -0
- package/src/client/test/ts-client.empty-enums.spec.ts +28 -0
- package/src/client/test/ts-client.issue-71.test.ts +51 -0
- package/src/client/test/ts-client.issues.test.ts +52 -0
- package/src/client/test/ts-client.sg721.spec.ts +46 -0
- package/src/client/test/ts-client.spec.ts +166 -0
- package/src/client/test/ts-client.vectis.spec.ts +97 -0
- package/src/context/context.ts +134 -0
- package/src/context/imports.ts +126 -0
- package/src/context/index.ts +2 -0
- package/src/index.ts +7 -0
- package/src/message-composer/__snapshots__/message-composer.spec.ts.snap +271 -0
- package/src/message-composer/index.ts +1 -0
- package/src/message-composer/message-composer.spec.ts +25 -0
- package/src/message-composer/message-composer.ts +305 -0
- package/src/react-query/__snapshots__/react-query.spec.ts.snap +913 -0
- package/src/react-query/index.ts +1 -0
- package/src/react-query/react-query.spec.ts +75 -0
- package/src/react-query/react-query.ts +913 -0
- package/src/recoil/__snapshots__/recoil.spec.ts.snap +203 -0
- package/src/recoil/index.ts +1 -0
- package/src/recoil/recoil.spec.ts +38 -0
- package/src/recoil/recoil.ts +307 -0
- package/src/types.ts +44 -0
- package/src/utils/__snapshots__/babel.spec.ts.snap +75 -0
- package/src/utils/babel.spec.ts +511 -0
- package/src/utils/babel.ts +315 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/types.ts +459 -0
- package/types/client/client.d.ts +1 -1
- package/types/context/context.d.ts +1 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`client 1`] = `
|
4
|
+
"export const queryClient = selectorFamily<SG721QueryClient, QueryClientParams>({
|
5
|
+
key: \\"sG721QueryClient\\",
|
6
|
+
get: ({
|
7
|
+
contractAddress
|
8
|
+
}) => ({
|
9
|
+
get
|
10
|
+
}) => {
|
11
|
+
const client = get(cosmWasmClient);
|
12
|
+
return new SG721QueryClient(client, contractAddress);
|
13
|
+
}
|
14
|
+
});"
|
15
|
+
`;
|
16
|
+
|
17
|
+
exports[`selector 1`] = `
|
18
|
+
"export const governanceModulesSelector = selectorFamily<GovernanceModulesResponse, QueryClientParams & {
|
19
|
+
params: Parameters<SG721QueryClient[\\"governanceModules\\"]>;
|
20
|
+
}>({
|
21
|
+
key: \\"sG721GovernanceModules\\",
|
22
|
+
get: ({
|
23
|
+
params,
|
24
|
+
...queryClientParams
|
25
|
+
}) => async ({
|
26
|
+
get
|
27
|
+
}) => {
|
28
|
+
const client = get(queryClient(queryClientParams));
|
29
|
+
return await client.governanceModules(...params);
|
30
|
+
}
|
31
|
+
});"
|
32
|
+
`;
|
33
|
+
|
34
|
+
exports[`selectors 1`] = `
|
35
|
+
"export const ownerOfSelector = selectorFamily<OwnerOfResponse, QueryClientParams & {
|
36
|
+
params: Parameters<SG721QueryClient[\\"ownerOf\\"]>;
|
37
|
+
}>({
|
38
|
+
key: \\"sG721OwnerOf\\",
|
39
|
+
get: ({
|
40
|
+
params,
|
41
|
+
...queryClientParams
|
42
|
+
}) => async ({
|
43
|
+
get
|
44
|
+
}) => {
|
45
|
+
const client = get(queryClient(queryClientParams));
|
46
|
+
return await client.ownerOf(...params);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
export const approvalSelector = selectorFamily<ApprovalResponse, QueryClientParams & {
|
50
|
+
params: Parameters<SG721QueryClient[\\"approval\\"]>;
|
51
|
+
}>({
|
52
|
+
key: \\"sG721Approval\\",
|
53
|
+
get: ({
|
54
|
+
params,
|
55
|
+
...queryClientParams
|
56
|
+
}) => async ({
|
57
|
+
get
|
58
|
+
}) => {
|
59
|
+
const client = get(queryClient(queryClientParams));
|
60
|
+
return await client.approval(...params);
|
61
|
+
}
|
62
|
+
});
|
63
|
+
export const approvalsSelector = selectorFamily<ApprovalsResponse, QueryClientParams & {
|
64
|
+
params: Parameters<SG721QueryClient[\\"approvals\\"]>;
|
65
|
+
}>({
|
66
|
+
key: \\"sG721Approvals\\",
|
67
|
+
get: ({
|
68
|
+
params,
|
69
|
+
...queryClientParams
|
70
|
+
}) => async ({
|
71
|
+
get
|
72
|
+
}) => {
|
73
|
+
const client = get(queryClient(queryClientParams));
|
74
|
+
return await client.approvals(...params);
|
75
|
+
}
|
76
|
+
});
|
77
|
+
export const allOperatorsSelector = selectorFamily<AllOperatorsResponse, QueryClientParams & {
|
78
|
+
params: Parameters<SG721QueryClient[\\"allOperators\\"]>;
|
79
|
+
}>({
|
80
|
+
key: \\"sG721AllOperators\\",
|
81
|
+
get: ({
|
82
|
+
params,
|
83
|
+
...queryClientParams
|
84
|
+
}) => async ({
|
85
|
+
get
|
86
|
+
}) => {
|
87
|
+
const client = get(queryClient(queryClientParams));
|
88
|
+
return await client.allOperators(...params);
|
89
|
+
}
|
90
|
+
});
|
91
|
+
export const numTokensSelector = selectorFamily<NumTokensResponse, QueryClientParams & {
|
92
|
+
params: Parameters<SG721QueryClient[\\"numTokens\\"]>;
|
93
|
+
}>({
|
94
|
+
key: \\"sG721NumTokens\\",
|
95
|
+
get: ({
|
96
|
+
params,
|
97
|
+
...queryClientParams
|
98
|
+
}) => async ({
|
99
|
+
get
|
100
|
+
}) => {
|
101
|
+
const client = get(queryClient(queryClientParams));
|
102
|
+
return await client.numTokens(...params);
|
103
|
+
}
|
104
|
+
});
|
105
|
+
export const contractInfoSelector = selectorFamily<ContractInfoResponse, QueryClientParams & {
|
106
|
+
params: Parameters<SG721QueryClient[\\"contractInfo\\"]>;
|
107
|
+
}>({
|
108
|
+
key: \\"sG721ContractInfo\\",
|
109
|
+
get: ({
|
110
|
+
params,
|
111
|
+
...queryClientParams
|
112
|
+
}) => async ({
|
113
|
+
get
|
114
|
+
}) => {
|
115
|
+
const client = get(queryClient(queryClientParams));
|
116
|
+
return await client.contractInfo(...params);
|
117
|
+
}
|
118
|
+
});
|
119
|
+
export const nftInfoSelector = selectorFamily<NftInfoResponse, QueryClientParams & {
|
120
|
+
params: Parameters<SG721QueryClient[\\"nftInfo\\"]>;
|
121
|
+
}>({
|
122
|
+
key: \\"sG721NftInfo\\",
|
123
|
+
get: ({
|
124
|
+
params,
|
125
|
+
...queryClientParams
|
126
|
+
}) => async ({
|
127
|
+
get
|
128
|
+
}) => {
|
129
|
+
const client = get(queryClient(queryClientParams));
|
130
|
+
return await client.nftInfo(...params);
|
131
|
+
}
|
132
|
+
});
|
133
|
+
export const allNftInfoSelector = selectorFamily<AllNftInfoResponse, QueryClientParams & {
|
134
|
+
params: Parameters<SG721QueryClient[\\"allNftInfo\\"]>;
|
135
|
+
}>({
|
136
|
+
key: \\"sG721AllNftInfo\\",
|
137
|
+
get: ({
|
138
|
+
params,
|
139
|
+
...queryClientParams
|
140
|
+
}) => async ({
|
141
|
+
get
|
142
|
+
}) => {
|
143
|
+
const client = get(queryClient(queryClientParams));
|
144
|
+
return await client.allNftInfo(...params);
|
145
|
+
}
|
146
|
+
});
|
147
|
+
export const tokensSelector = selectorFamily<TokensResponse, QueryClientParams & {
|
148
|
+
params: Parameters<SG721QueryClient[\\"tokens\\"]>;
|
149
|
+
}>({
|
150
|
+
key: \\"sG721Tokens\\",
|
151
|
+
get: ({
|
152
|
+
params,
|
153
|
+
...queryClientParams
|
154
|
+
}) => async ({
|
155
|
+
get
|
156
|
+
}) => {
|
157
|
+
const client = get(queryClient(queryClientParams));
|
158
|
+
return await client.tokens(...params);
|
159
|
+
}
|
160
|
+
});
|
161
|
+
export const allTokensSelector = selectorFamily<AllTokensResponse, QueryClientParams & {
|
162
|
+
params: Parameters<SG721QueryClient[\\"allTokens\\"]>;
|
163
|
+
}>({
|
164
|
+
key: \\"sG721AllTokens\\",
|
165
|
+
get: ({
|
166
|
+
params,
|
167
|
+
...queryClientParams
|
168
|
+
}) => async ({
|
169
|
+
get
|
170
|
+
}) => {
|
171
|
+
const client = get(queryClient(queryClientParams));
|
172
|
+
return await client.allTokens(...params);
|
173
|
+
}
|
174
|
+
});
|
175
|
+
export const minterSelector = selectorFamily<MinterResponse, QueryClientParams & {
|
176
|
+
params: Parameters<SG721QueryClient[\\"minter\\"]>;
|
177
|
+
}>({
|
178
|
+
key: \\"sG721Minter\\",
|
179
|
+
get: ({
|
180
|
+
params,
|
181
|
+
...queryClientParams
|
182
|
+
}) => async ({
|
183
|
+
get
|
184
|
+
}) => {
|
185
|
+
const client = get(queryClient(queryClientParams));
|
186
|
+
return await client.minter(...params);
|
187
|
+
}
|
188
|
+
});
|
189
|
+
export const collectionInfoSelector = selectorFamily<CollectionInfoResponse, QueryClientParams & {
|
190
|
+
params: Parameters<SG721QueryClient[\\"collectionInfo\\"]>;
|
191
|
+
}>({
|
192
|
+
key: \\"sG721CollectionInfo\\",
|
193
|
+
get: ({
|
194
|
+
params,
|
195
|
+
...queryClientParams
|
196
|
+
}) => async ({
|
197
|
+
get
|
198
|
+
}) => {
|
199
|
+
const client = get(queryClient(queryClientParams));
|
200
|
+
return await client.collectionInfo(...params);
|
201
|
+
}
|
202
|
+
});"
|
203
|
+
`;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './recoil';
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import * as t from '@babel/types';
|
2
|
+
import query_msg from '../../../../__fixtures__/basic/query_msg.json';
|
3
|
+
import {
|
4
|
+
createRecoilSelector,
|
5
|
+
createRecoilSelectors,
|
6
|
+
createRecoilQueryClient,
|
7
|
+
} from './recoil';
|
8
|
+
import { RenderContext } from '../context';
|
9
|
+
import { expectCode, makeContext } from '../../test-utils';
|
10
|
+
|
11
|
+
const ctx = makeContext(query_msg);
|
12
|
+
|
13
|
+
it('selector', () => {
|
14
|
+
expectCode(createRecoilSelector(
|
15
|
+
ctx,
|
16
|
+
'SG721',
|
17
|
+
'SG721QueryClient',
|
18
|
+
'governanceModules',
|
19
|
+
'GovernanceModulesResponse'
|
20
|
+
))
|
21
|
+
});
|
22
|
+
|
23
|
+
it('selectors', () => {
|
24
|
+
expectCode(t.program(createRecoilSelectors(
|
25
|
+
ctx,
|
26
|
+
'SG721',
|
27
|
+
'SG721QueryClient',
|
28
|
+
query_msg
|
29
|
+
)))
|
30
|
+
});
|
31
|
+
|
32
|
+
it('client', () => {
|
33
|
+
expectCode(createRecoilQueryClient(
|
34
|
+
ctx,
|
35
|
+
'SG721',
|
36
|
+
'SG721QueryClient'
|
37
|
+
))
|
38
|
+
});
|
@@ -0,0 +1,307 @@
|
|
1
|
+
import * as t from '@babel/types';
|
2
|
+
import { camel, pascal } from 'case';
|
3
|
+
import {
|
4
|
+
callExpression,
|
5
|
+
getMessageProperties,
|
6
|
+
getResponseType
|
7
|
+
} from '../utils';
|
8
|
+
import { QueryMsg } from '../types';
|
9
|
+
import { RenderContext } from '../context';
|
10
|
+
|
11
|
+
export const createRecoilSelector = (
|
12
|
+
context: RenderContext,
|
13
|
+
keyPrefix: string,
|
14
|
+
QueryClient: string,
|
15
|
+
methodName: string,
|
16
|
+
responseType: string
|
17
|
+
) => {
|
18
|
+
|
19
|
+
context.addUtil('selectorFamily');
|
20
|
+
|
21
|
+
const selectorName = camel(`${methodName}Selector`);
|
22
|
+
const getterKey = camel(`${keyPrefix}${pascal(methodName)}`);
|
23
|
+
|
24
|
+
return t.exportNamedDeclaration(
|
25
|
+
t.variableDeclaration(
|
26
|
+
'const',
|
27
|
+
[t.variableDeclarator(
|
28
|
+
t.identifier(selectorName),
|
29
|
+
callExpression(
|
30
|
+
t.identifier('selectorFamily'),
|
31
|
+
[
|
32
|
+
t.objectExpression(
|
33
|
+
[
|
34
|
+
t.objectProperty(
|
35
|
+
t.identifier('key'),
|
36
|
+
t.stringLiteral(getterKey)
|
37
|
+
),
|
38
|
+
t.objectProperty(
|
39
|
+
t.identifier('get'),
|
40
|
+
t.arrowFunctionExpression(
|
41
|
+
[
|
42
|
+
t.objectPattern(
|
43
|
+
[
|
44
|
+
t.objectProperty(
|
45
|
+
t.identifier('params'),
|
46
|
+
t.identifier('params'),
|
47
|
+
false,
|
48
|
+
true
|
49
|
+
),
|
50
|
+
t.restElement(
|
51
|
+
t.identifier('queryClientParams')
|
52
|
+
)
|
53
|
+
]
|
54
|
+
)
|
55
|
+
],
|
56
|
+
t.arrowFunctionExpression(
|
57
|
+
[
|
58
|
+
t.objectPattern(
|
59
|
+
[
|
60
|
+
t.objectProperty(
|
61
|
+
t.identifier('get'),
|
62
|
+
t.identifier('get'),
|
63
|
+
false,
|
64
|
+
true
|
65
|
+
)
|
66
|
+
]
|
67
|
+
)
|
68
|
+
],
|
69
|
+
t.blockStatement(
|
70
|
+
[
|
71
|
+
t.variableDeclaration('const',
|
72
|
+
[
|
73
|
+
t.variableDeclarator(
|
74
|
+
t.identifier('client'),
|
75
|
+
t.callExpression(
|
76
|
+
t.identifier('get'),
|
77
|
+
[
|
78
|
+
t.callExpression(
|
79
|
+
t.identifier('queryClient'),
|
80
|
+
[
|
81
|
+
t.identifier('queryClientParams')
|
82
|
+
]
|
83
|
+
)
|
84
|
+
]
|
85
|
+
)
|
86
|
+
)
|
87
|
+
]),
|
88
|
+
t.returnStatement(
|
89
|
+
t.awaitExpression(
|
90
|
+
t.callExpression(
|
91
|
+
t.memberExpression(
|
92
|
+
t.identifier('client'),
|
93
|
+
t.identifier(methodName)
|
94
|
+
),
|
95
|
+
[
|
96
|
+
t.spreadElement(
|
97
|
+
t.identifier('params')
|
98
|
+
)
|
99
|
+
]
|
100
|
+
)
|
101
|
+
)
|
102
|
+
)
|
103
|
+
]
|
104
|
+
),
|
105
|
+
true
|
106
|
+
)
|
107
|
+
)
|
108
|
+
)
|
109
|
+
]
|
110
|
+
)
|
111
|
+
],
|
112
|
+
t.tsTypeParameterInstantiation(
|
113
|
+
[
|
114
|
+
t.tsTypeReference(
|
115
|
+
t.identifier(responseType)
|
116
|
+
),
|
117
|
+
t.tsIntersectionType(
|
118
|
+
[
|
119
|
+
t.tsTypeReference(
|
120
|
+
t.identifier('QueryClientParams')
|
121
|
+
),
|
122
|
+
t.tsTypeLiteral(
|
123
|
+
[
|
124
|
+
t.tsPropertySignature(
|
125
|
+
t.identifier('params'),
|
126
|
+
t.tsTypeAnnotation(
|
127
|
+
t.tsTypeReference(
|
128
|
+
t.identifier('Parameters'),
|
129
|
+
t.tsTypeParameterInstantiation(
|
130
|
+
[
|
131
|
+
t.tsIndexedAccessType(
|
132
|
+
t.tsTypeReference(
|
133
|
+
t.identifier(QueryClient)
|
134
|
+
),
|
135
|
+
t.tsLiteralType(
|
136
|
+
t.stringLiteral(methodName)
|
137
|
+
)
|
138
|
+
)
|
139
|
+
]
|
140
|
+
)
|
141
|
+
)
|
142
|
+
)
|
143
|
+
)
|
144
|
+
]
|
145
|
+
)
|
146
|
+
]
|
147
|
+
)
|
148
|
+
]
|
149
|
+
)
|
150
|
+
)
|
151
|
+
)]
|
152
|
+
)
|
153
|
+
)
|
154
|
+
|
155
|
+
};
|
156
|
+
|
157
|
+
export const createRecoilSelectors = (
|
158
|
+
context: RenderContext,
|
159
|
+
keyPrefix: string,
|
160
|
+
QueryClient: string,
|
161
|
+
queryMsg: QueryMsg
|
162
|
+
) => {
|
163
|
+
return getMessageProperties(queryMsg)
|
164
|
+
.map(schema => {
|
165
|
+
|
166
|
+
const underscoreName = Object.keys(schema.properties)[0];
|
167
|
+
const methodName = camel(underscoreName);
|
168
|
+
const responseType = getResponseType(context, underscoreName);
|
169
|
+
|
170
|
+
return createRecoilSelector(
|
171
|
+
context,
|
172
|
+
keyPrefix,
|
173
|
+
QueryClient,
|
174
|
+
methodName,
|
175
|
+
responseType
|
176
|
+
);
|
177
|
+
|
178
|
+
});
|
179
|
+
};
|
180
|
+
|
181
|
+
export const createRecoilQueryClientType = () => ({
|
182
|
+
"type": "TSTypeAliasDeclaration",
|
183
|
+
"id": {
|
184
|
+
"type": "Identifier",
|
185
|
+
"name": "QueryClientParams"
|
186
|
+
},
|
187
|
+
"typeAnnotation": {
|
188
|
+
"type": "TSTypeLiteral",
|
189
|
+
"members": [
|
190
|
+
{
|
191
|
+
"type": "TSPropertySignature",
|
192
|
+
"key": {
|
193
|
+
"type": "Identifier",
|
194
|
+
"name": "contractAddress"
|
195
|
+
},
|
196
|
+
"computed": false,
|
197
|
+
"typeAnnotation": {
|
198
|
+
"type": "TSTypeAnnotation",
|
199
|
+
"typeAnnotation": {
|
200
|
+
"type": "TSStringKeyword"
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}
|
204
|
+
]
|
205
|
+
}
|
206
|
+
});
|
207
|
+
|
208
|
+
export const createRecoilQueryClient = (
|
209
|
+
context: RenderContext,
|
210
|
+
keyPrefix: string,
|
211
|
+
QueryClient: string
|
212
|
+
) => {
|
213
|
+
|
214
|
+
context.addUtil('selectorFamily');
|
215
|
+
|
216
|
+
const getterKey = camel(`${keyPrefix}${'QueryClient'}`);
|
217
|
+
|
218
|
+
return t.exportNamedDeclaration(
|
219
|
+
t.variableDeclaration(
|
220
|
+
'const',
|
221
|
+
[t.variableDeclarator(
|
222
|
+
t.identifier('queryClient'),
|
223
|
+
callExpression(
|
224
|
+
t.identifier('selectorFamily'),
|
225
|
+
[
|
226
|
+
t.objectExpression(
|
227
|
+
[
|
228
|
+
t.objectProperty(
|
229
|
+
t.identifier('key'),
|
230
|
+
t.stringLiteral(getterKey)
|
231
|
+
),
|
232
|
+
t.objectProperty(
|
233
|
+
t.identifier('get'),
|
234
|
+
t.arrowFunctionExpression(
|
235
|
+
[
|
236
|
+
t.objectPattern(
|
237
|
+
[
|
238
|
+
t.objectProperty(
|
239
|
+
t.identifier('contractAddress'),
|
240
|
+
t.identifier('contractAddress'),
|
241
|
+
false,
|
242
|
+
true
|
243
|
+
)
|
244
|
+
]
|
245
|
+
)
|
246
|
+
],
|
247
|
+
t.arrowFunctionExpression(
|
248
|
+
[
|
249
|
+
t.objectPattern(
|
250
|
+
[
|
251
|
+
t.objectProperty(
|
252
|
+
t.identifier('get'),
|
253
|
+
t.identifier('get'),
|
254
|
+
false,
|
255
|
+
true
|
256
|
+
)
|
257
|
+
]
|
258
|
+
)
|
259
|
+
],
|
260
|
+
t.blockStatement(
|
261
|
+
[
|
262
|
+
t.variableDeclaration('const',
|
263
|
+
[
|
264
|
+
t.variableDeclarator(
|
265
|
+
t.identifier('client'),
|
266
|
+
t.callExpression(
|
267
|
+
t.identifier('get'),
|
268
|
+
[
|
269
|
+
t.identifier('cosmWasmClient')
|
270
|
+
]
|
271
|
+
)
|
272
|
+
)
|
273
|
+
]),
|
274
|
+
t.returnStatement(
|
275
|
+
t.newExpression(
|
276
|
+
t.identifier(QueryClient),
|
277
|
+
[
|
278
|
+
t.identifier('client'),
|
279
|
+
t.identifier('contractAddress')
|
280
|
+
]
|
281
|
+
)
|
282
|
+
)
|
283
|
+
]
|
284
|
+
),
|
285
|
+
false
|
286
|
+
)
|
287
|
+
)
|
288
|
+
)
|
289
|
+
]
|
290
|
+
)
|
291
|
+
],
|
292
|
+
t.tsTypeParameterInstantiation(
|
293
|
+
[
|
294
|
+
t.tsTypeReference(
|
295
|
+
t.identifier(QueryClient)
|
296
|
+
),
|
297
|
+
t.tsTypeReference(
|
298
|
+
t.identifier('QueryClientParams')
|
299
|
+
)
|
300
|
+
]
|
301
|
+
)
|
302
|
+
)
|
303
|
+
)]
|
304
|
+
)
|
305
|
+
)
|
306
|
+
|
307
|
+
};
|
package/src/types.ts
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
export declare type fieldType = 'Long' | 'Coin' | 'Duration' | 'Height' | string;
|
2
|
+
export interface Field {
|
3
|
+
name: string;
|
4
|
+
type: fieldType;
|
5
|
+
node: any;
|
6
|
+
};
|
7
|
+
export interface Interface {
|
8
|
+
name: string;
|
9
|
+
fields: Field[]
|
10
|
+
};
|
11
|
+
|
12
|
+
export interface QueryMsg {
|
13
|
+
$schema: string;
|
14
|
+
title: "QueryMsg";
|
15
|
+
oneOf?: any;
|
16
|
+
allOf?: any;
|
17
|
+
anyOf?: any;
|
18
|
+
}
|
19
|
+
|
20
|
+
export interface ExecuteMsg {
|
21
|
+
$schema: string;
|
22
|
+
title: "ExecuteMsg" | "ExecuteMsg_for_Empty";
|
23
|
+
oneOf?: any;
|
24
|
+
allOf?: any;
|
25
|
+
anyOf?: any;
|
26
|
+
}
|
27
|
+
|
28
|
+
export interface JSONSchema {
|
29
|
+
$ref?: string;
|
30
|
+
$schema?: string;
|
31
|
+
additionalProperties?: boolean;
|
32
|
+
allOf?: JSONSchema[];
|
33
|
+
anyOf?: JSONSchema[];
|
34
|
+
definitions?: Record<string, JSONSchema>;
|
35
|
+
description?: string;
|
36
|
+
oneOf?: JSONSchema[];
|
37
|
+
properties?: Record<string, JSONSchema>;
|
38
|
+
patternProperties?: Record<string, JSONSchema>;
|
39
|
+
items?: JSONSchema | JSONSchema[];
|
40
|
+
additionalItems?: JSONSchema;
|
41
|
+
required?: string[];
|
42
|
+
title?: string;
|
43
|
+
type?: string;
|
44
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`interfaces 1`] = `
|
4
|
+
"export interface SG721ReadOnlyInstance {
|
5
|
+
contractAddress: string;
|
6
|
+
tokens: (owner: string, startAfter?: string, limit?: string) => Promise<TokensResponse>;
|
7
|
+
}
|
8
|
+
export interface SG721Instance extends SG721ReadOnlyInstance {
|
9
|
+
contractAddress: string;
|
10
|
+
mint: (sender: string, anotherProp: string, prop3: string) => Promise<ExecuteResult>;
|
11
|
+
}"
|
12
|
+
`;
|
13
|
+
|
14
|
+
exports[`mutation classes 1`] = `
|
15
|
+
"export class SG721Client extends SG721QueryClient implements SG721ReadOnlyInstance {
|
16
|
+
client: SigningCosmWasmClient;
|
17
|
+
contractAddress: string;
|
18
|
+
|
19
|
+
constructor(client: SigningCosmWasmClient, contractAddress: string) {
|
20
|
+
super(client, contractAddress);
|
21
|
+
this.client = client;
|
22
|
+
this.contractAddress = contractAddress;
|
23
|
+
this.approval = this.approval.bind(this);
|
24
|
+
this.otherProp = this.otherProp.bind(this);
|
25
|
+
this.hello = this.hello.bind(this);
|
26
|
+
this.mintme = this.mintme.bind(this);
|
27
|
+
}
|
28
|
+
|
29
|
+
mint = async (sender: string, tokenId: string, owner: string, token_uri: string): Promise<ExecuteResult> => {
|
30
|
+
return await this.client.execute(sender, this.contractAddress, {
|
31
|
+
mint: {
|
32
|
+
token_id: tokenId,
|
33
|
+
owner: owner,
|
34
|
+
token_uri: token_uri,
|
35
|
+
expression: {}
|
36
|
+
}
|
37
|
+
}, \\"auto\\");
|
38
|
+
};
|
39
|
+
}"
|
40
|
+
`;
|
41
|
+
|
42
|
+
exports[`object parms 1`] = `
|
43
|
+
"ownerOf = ({
|
44
|
+
includeExpired,
|
45
|
+
tokenId
|
46
|
+
}: {
|
47
|
+
includeExpired: boolean;
|
48
|
+
tokenId: string;
|
49
|
+
}): Promise<OwnerOfResponse> => {};"
|
50
|
+
`;
|
51
|
+
|
52
|
+
exports[`readonly classes 1`] = `
|
53
|
+
"export class SG721QueryClient implements SG721ReadOnlyInstance {
|
54
|
+
client: CosmWasmClient;
|
55
|
+
contractAddress: string;
|
56
|
+
|
57
|
+
constructor(client: CosmWasmClient, contractAddress: string) {
|
58
|
+
this.client = client;
|
59
|
+
this.contractAddress = contractAddress;
|
60
|
+
this.approval = this.approval.bind(this);
|
61
|
+
this.otherProp = this.otherProp.bind(this);
|
62
|
+
this.hello = this.hello.bind(this);
|
63
|
+
this.mintme = this.mintme.bind(this);
|
64
|
+
}
|
65
|
+
|
66
|
+
approval = async (owner: string, spender: string): Promise<ApprovalResponse> => {
|
67
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
68
|
+
owner,
|
69
|
+
spender
|
70
|
+
});
|
71
|
+
};
|
72
|
+
}"
|
73
|
+
`;
|
74
|
+
|
75
|
+
exports[`top import 1`] = `"import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from \\"@cosmjs/cosmwasm-stargate\\";"`;
|