wasm-ast-types 0.18.1 → 0.19.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/client/test/ts-client.issue-98.test.js +30 -0
- package/main/context/context.js +59 -13
- package/main/context/imports.js +37 -15
- package/main/index.js +13 -0
- package/main/msg-builder/index.js +18 -0
- package/main/msg-builder/msg-builder.js +54 -0
- package/main/msg-builder/msg-builder.spec.js +20 -0
- package/main/utils/babel.js +56 -5
- package/main/utils/index.js +13 -0
- package/main/utils/ref.js +15 -0
- package/main/utils/types.js +1 -1
- package/module/client/test/ts-client.issue-98.test.js +23 -0
- package/module/context/context.js +29 -6
- package/module/context/imports.js +33 -14
- package/module/index.js +2 -1
- package/module/msg-builder/index.js +1 -0
- package/module/msg-builder/msg-builder.js +33 -0
- package/module/msg-builder/msg-builder.spec.js +12 -0
- package/module/utils/babel.js +31 -5
- package/module/utils/index.js +2 -1
- package/module/utils/ref.js +4 -0
- package/module/utils/types.js +1 -1
- package/package.json +2 -2
- package/src/client/test/__snapshots__/ts-client.issue-98.test.ts.snap +117 -0
- package/src/client/test/__snapshots__/ts-client.wager.spec.ts.snap +1 -1
- package/src/client/test/ts-client.issue-98.test.ts +55 -0
- package/src/context/context.ts +45 -10
- package/src/context/imports.ts +49 -15
- package/src/index.ts +2 -1
- package/src/msg-builder/__snapshots__/msg-builder.spec.ts.snap +249 -0
- package/src/msg-builder/index.ts +1 -0
- package/src/msg-builder/msg-builder.spec.ts +17 -0
- package/src/msg-builder/msg-builder.ts +107 -0
- package/src/react-query/react-query.ts +1 -1
- package/src/utils/babel.ts +34 -5
- package/src/utils/index.ts +1 -0
- package/src/utils/ref.ts +6 -0
- package/src/utils/types.ts +2 -6
- package/types/context/context.d.ts +30 -5
- package/types/context/imports.d.ts +7 -2
- package/types/index.d.ts +1 -0
- package/types/msg-builder/index.d.ts +1 -0
- package/types/msg-builder/msg-builder.d.ts +4 -0
- package/types/react-query/react-query.d.ts +11 -10
- package/types/recoil/recoil.d.ts +1 -1
- package/types/utils/babel.d.ts +3 -2
- package/types/utils/index.d.ts +1 -0
- package/types/utils/ref.d.ts +2 -0
@@ -0,0 +1,249 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`execute class 1`] = `
|
4
|
+
"export abstract class SG721MsgBuilder {
|
5
|
+
static transferNft = ({
|
6
|
+
recipient,
|
7
|
+
tokenId
|
8
|
+
}: CamelCasedProperties<Extract<ExecuteMsg_for_Empty, {
|
9
|
+
transfer_nft: unknown;
|
10
|
+
}>[\\"transfer_nft\\"]>): ExecuteMsg_for_Empty => {
|
11
|
+
return {
|
12
|
+
transfer_nft: ({
|
13
|
+
recipient,
|
14
|
+
token_id: tokenId
|
15
|
+
} as const)
|
16
|
+
};
|
17
|
+
};
|
18
|
+
static sendNft = ({
|
19
|
+
contract,
|
20
|
+
msg,
|
21
|
+
tokenId
|
22
|
+
}: CamelCasedProperties<Extract<ExecuteMsg_for_Empty, {
|
23
|
+
send_nft: unknown;
|
24
|
+
}>[\\"send_nft\\"]>): ExecuteMsg_for_Empty => {
|
25
|
+
return {
|
26
|
+
send_nft: ({
|
27
|
+
contract,
|
28
|
+
msg,
|
29
|
+
token_id: tokenId
|
30
|
+
} as const)
|
31
|
+
};
|
32
|
+
};
|
33
|
+
static approve = ({
|
34
|
+
expires,
|
35
|
+
spender,
|
36
|
+
tokenId
|
37
|
+
}: CamelCasedProperties<Extract<ExecuteMsg_for_Empty, {
|
38
|
+
approve: unknown;
|
39
|
+
}>[\\"approve\\"]>): ExecuteMsg_for_Empty => {
|
40
|
+
return {
|
41
|
+
approve: ({
|
42
|
+
expires,
|
43
|
+
spender,
|
44
|
+
token_id: tokenId
|
45
|
+
} as const)
|
46
|
+
};
|
47
|
+
};
|
48
|
+
static revoke = ({
|
49
|
+
spender,
|
50
|
+
tokenId
|
51
|
+
}: CamelCasedProperties<Extract<ExecuteMsg_for_Empty, {
|
52
|
+
revoke: unknown;
|
53
|
+
}>[\\"revoke\\"]>): ExecuteMsg_for_Empty => {
|
54
|
+
return {
|
55
|
+
revoke: ({
|
56
|
+
spender,
|
57
|
+
token_id: tokenId
|
58
|
+
} as const)
|
59
|
+
};
|
60
|
+
};
|
61
|
+
static approveAll = ({
|
62
|
+
expires,
|
63
|
+
operator
|
64
|
+
}: CamelCasedProperties<Extract<ExecuteMsg_for_Empty, {
|
65
|
+
approve_all: unknown;
|
66
|
+
}>[\\"approve_all\\"]>): ExecuteMsg_for_Empty => {
|
67
|
+
return {
|
68
|
+
approve_all: ({
|
69
|
+
expires,
|
70
|
+
operator
|
71
|
+
} as const)
|
72
|
+
};
|
73
|
+
};
|
74
|
+
static revokeAll = ({
|
75
|
+
operator
|
76
|
+
}: CamelCasedProperties<Extract<ExecuteMsg_for_Empty, {
|
77
|
+
revoke_all: unknown;
|
78
|
+
}>[\\"revoke_all\\"]>): ExecuteMsg_for_Empty => {
|
79
|
+
return {
|
80
|
+
revoke_all: ({
|
81
|
+
operator
|
82
|
+
} as const)
|
83
|
+
};
|
84
|
+
};
|
85
|
+
static mint = ({
|
86
|
+
extension,
|
87
|
+
owner,
|
88
|
+
tokenId,
|
89
|
+
tokenUri
|
90
|
+
}: CamelCasedProperties<Extract<ExecuteMsg_for_Empty, {
|
91
|
+
mint: unknown;
|
92
|
+
}>[\\"mint\\"]>): ExecuteMsg_for_Empty => {
|
93
|
+
return {
|
94
|
+
mint: ({
|
95
|
+
extension,
|
96
|
+
owner,
|
97
|
+
token_id: tokenId,
|
98
|
+
token_uri: tokenUri
|
99
|
+
} as const)
|
100
|
+
};
|
101
|
+
};
|
102
|
+
static burn = ({
|
103
|
+
tokenId
|
104
|
+
}: CamelCasedProperties<Extract<ExecuteMsg_for_Empty, {
|
105
|
+
burn: unknown;
|
106
|
+
}>[\\"burn\\"]>): ExecuteMsg_for_Empty => {
|
107
|
+
return {
|
108
|
+
burn: ({
|
109
|
+
token_id: tokenId
|
110
|
+
} as const)
|
111
|
+
};
|
112
|
+
};
|
113
|
+
}"
|
114
|
+
`;
|
115
|
+
|
116
|
+
exports[`query class 1`] = `
|
117
|
+
"export abstract class SG721MsgBuilder {
|
118
|
+
static ownerOf = ({
|
119
|
+
includeExpired,
|
120
|
+
tokenId
|
121
|
+
}: CamelCasedProperties<Extract<QueryMsg, {
|
122
|
+
owner_of: unknown;
|
123
|
+
}>[\\"owner_of\\"]>): QueryMsg => {
|
124
|
+
return {
|
125
|
+
owner_of: ({
|
126
|
+
include_expired: includeExpired,
|
127
|
+
token_id: tokenId
|
128
|
+
} as const)
|
129
|
+
};
|
130
|
+
};
|
131
|
+
static approval = ({
|
132
|
+
includeExpired,
|
133
|
+
spender,
|
134
|
+
tokenId
|
135
|
+
}: CamelCasedProperties<Extract<QueryMsg, {
|
136
|
+
approval: unknown;
|
137
|
+
}>[\\"approval\\"]>): QueryMsg => {
|
138
|
+
return {
|
139
|
+
approval: ({
|
140
|
+
include_expired: includeExpired,
|
141
|
+
spender,
|
142
|
+
token_id: tokenId
|
143
|
+
} as const)
|
144
|
+
};
|
145
|
+
};
|
146
|
+
static approvals = ({
|
147
|
+
includeExpired,
|
148
|
+
tokenId
|
149
|
+
}: CamelCasedProperties<Extract<QueryMsg, {
|
150
|
+
approvals: unknown;
|
151
|
+
}>[\\"approvals\\"]>): QueryMsg => {
|
152
|
+
return {
|
153
|
+
approvals: ({
|
154
|
+
include_expired: includeExpired,
|
155
|
+
token_id: tokenId
|
156
|
+
} as const)
|
157
|
+
};
|
158
|
+
};
|
159
|
+
static allOperators = ({
|
160
|
+
includeExpired,
|
161
|
+
limit,
|
162
|
+
owner,
|
163
|
+
startAfter
|
164
|
+
}: CamelCasedProperties<Extract<QueryMsg, {
|
165
|
+
all_operators: unknown;
|
166
|
+
}>[\\"all_operators\\"]>): QueryMsg => {
|
167
|
+
return {
|
168
|
+
all_operators: ({
|
169
|
+
include_expired: includeExpired,
|
170
|
+
limit,
|
171
|
+
owner,
|
172
|
+
start_after: startAfter
|
173
|
+
} as const)
|
174
|
+
};
|
175
|
+
};
|
176
|
+
static numTokens = (): QueryMsg => {
|
177
|
+
return {
|
178
|
+
num_tokens: ({} as const)
|
179
|
+
};
|
180
|
+
};
|
181
|
+
static contractInfo = (): QueryMsg => {
|
182
|
+
return {
|
183
|
+
contract_info: ({} as const)
|
184
|
+
};
|
185
|
+
};
|
186
|
+
static nftInfo = ({
|
187
|
+
tokenId
|
188
|
+
}: CamelCasedProperties<Extract<QueryMsg, {
|
189
|
+
nft_info: unknown;
|
190
|
+
}>[\\"nft_info\\"]>): QueryMsg => {
|
191
|
+
return {
|
192
|
+
nft_info: ({
|
193
|
+
token_id: tokenId
|
194
|
+
} as const)
|
195
|
+
};
|
196
|
+
};
|
197
|
+
static allNftInfo = ({
|
198
|
+
includeExpired,
|
199
|
+
tokenId
|
200
|
+
}: CamelCasedProperties<Extract<QueryMsg, {
|
201
|
+
all_nft_info: unknown;
|
202
|
+
}>[\\"all_nft_info\\"]>): QueryMsg => {
|
203
|
+
return {
|
204
|
+
all_nft_info: ({
|
205
|
+
include_expired: includeExpired,
|
206
|
+
token_id: tokenId
|
207
|
+
} as const)
|
208
|
+
};
|
209
|
+
};
|
210
|
+
static tokens = ({
|
211
|
+
limit,
|
212
|
+
owner,
|
213
|
+
startAfter
|
214
|
+
}: CamelCasedProperties<Extract<QueryMsg, {
|
215
|
+
tokens: unknown;
|
216
|
+
}>[\\"tokens\\"]>): QueryMsg => {
|
217
|
+
return {
|
218
|
+
tokens: ({
|
219
|
+
limit,
|
220
|
+
owner,
|
221
|
+
start_after: startAfter
|
222
|
+
} as const)
|
223
|
+
};
|
224
|
+
};
|
225
|
+
static allTokens = ({
|
226
|
+
limit,
|
227
|
+
startAfter
|
228
|
+
}: CamelCasedProperties<Extract<QueryMsg, {
|
229
|
+
all_tokens: unknown;
|
230
|
+
}>[\\"all_tokens\\"]>): QueryMsg => {
|
231
|
+
return {
|
232
|
+
all_tokens: ({
|
233
|
+
limit,
|
234
|
+
start_after: startAfter
|
235
|
+
} as const)
|
236
|
+
};
|
237
|
+
};
|
238
|
+
static minter = (): QueryMsg => {
|
239
|
+
return {
|
240
|
+
minter: ({} as const)
|
241
|
+
};
|
242
|
+
};
|
243
|
+
static collectionInfo = (): QueryMsg => {
|
244
|
+
return {
|
245
|
+
collection_info: ({} as const)
|
246
|
+
};
|
247
|
+
};
|
248
|
+
}"
|
249
|
+
`;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './msg-builder';
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import execute_msg from '../../../../__fixtures__/basic/execute_msg_for__empty.json';
|
2
|
+
import query_msg from '../../../../__fixtures__/basic/query_msg.json';
|
3
|
+
import {
|
4
|
+
createMsgBuilderClass,
|
5
|
+
} from './msg-builder'
|
6
|
+
import { expectCode, makeContext } from '../../test-utils';
|
7
|
+
|
8
|
+
it('execute class', () => {
|
9
|
+
const ctx = makeContext(execute_msg);
|
10
|
+
expectCode(createMsgBuilderClass(ctx, 'SG721MsgBuilder', execute_msg))
|
11
|
+
});
|
12
|
+
|
13
|
+
|
14
|
+
it('query class', () => {
|
15
|
+
const ctx = makeContext(execute_msg);
|
16
|
+
expectCode(createMsgBuilderClass(ctx, 'SG721MsgBuilder', query_msg))
|
17
|
+
});
|
@@ -0,0 +1,107 @@
|
|
1
|
+
import * as t from "@babel/types";
|
2
|
+
import { camel } from "case";
|
3
|
+
import {
|
4
|
+
abstractClassDeclaration,
|
5
|
+
arrowFunctionExpression,
|
6
|
+
bindMethod,
|
7
|
+
classDeclaration,
|
8
|
+
getMessageProperties,
|
9
|
+
} from "../utils";
|
10
|
+
import { ExecuteMsg, QueryMsg } from "../types";
|
11
|
+
import { createTypedObjectParams } from "../utils/types";
|
12
|
+
import { RenderContext } from "../context";
|
13
|
+
import { getWasmMethodArgs } from "../client/client";
|
14
|
+
|
15
|
+
export const createMsgBuilderClass = (
|
16
|
+
context: RenderContext,
|
17
|
+
className: string,
|
18
|
+
msg: ExecuteMsg | QueryMsg
|
19
|
+
): t.ExportNamedDeclaration => {
|
20
|
+
const staticMethods = getMessageProperties(msg).map((schema) => {
|
21
|
+
return createStaticExecMethodMsgBuilder(context, schema, msg.title);
|
22
|
+
});
|
23
|
+
|
24
|
+
// const blockStmt = bindings;
|
25
|
+
|
26
|
+
return t.exportNamedDeclaration(
|
27
|
+
abstractClassDeclaration(className, staticMethods, [], null)
|
28
|
+
);
|
29
|
+
};
|
30
|
+
|
31
|
+
/**
|
32
|
+
* CamelCasedProperties<Extract<ExecuteMsg, { exec_on_module: unknown }>['exec_on_module']>
|
33
|
+
*/
|
34
|
+
function createExtractTypeAnnotation(underscoreName: string, msgTitle: string) {
|
35
|
+
return t.tsTypeAnnotation(
|
36
|
+
t.tsTypeReference(
|
37
|
+
t.identifier("CamelCasedProperties"),
|
38
|
+
t.tsTypeParameterInstantiation([
|
39
|
+
t.tsIndexedAccessType(
|
40
|
+
t.tsTypeReference(t.identifier("Extract"),
|
41
|
+
t.tsTypeParameterInstantiation([
|
42
|
+
t.tsTypeReference(t.identifier(msgTitle)),
|
43
|
+
t.tsTypeLiteral([
|
44
|
+
t.tsPropertySignature(
|
45
|
+
t.identifier(underscoreName),
|
46
|
+
t.tsTypeAnnotation(t.tsUnknownKeyword())
|
47
|
+
)
|
48
|
+
])
|
49
|
+
])
|
50
|
+
),
|
51
|
+
t.tsLiteralType(t.stringLiteral(underscoreName))
|
52
|
+
)
|
53
|
+
])
|
54
|
+
)
|
55
|
+
);
|
56
|
+
}
|
57
|
+
|
58
|
+
const createStaticExecMethodMsgBuilder = (
|
59
|
+
context: RenderContext,
|
60
|
+
jsonschema: any,
|
61
|
+
msgTitle: string
|
62
|
+
) => {
|
63
|
+
const underscoreName = Object.keys(jsonschema.properties)[0];
|
64
|
+
const methodName = camel(underscoreName);
|
65
|
+
const obj = createTypedObjectParams(
|
66
|
+
context,
|
67
|
+
jsonschema.properties[underscoreName]
|
68
|
+
);
|
69
|
+
const args = getWasmMethodArgs(
|
70
|
+
context,
|
71
|
+
jsonschema.properties[underscoreName]
|
72
|
+
);
|
73
|
+
|
74
|
+
if (obj) obj.typeAnnotation = createExtractTypeAnnotation(underscoreName, msgTitle)
|
75
|
+
|
76
|
+
return t.classProperty(
|
77
|
+
t.identifier(methodName),
|
78
|
+
arrowFunctionExpression(
|
79
|
+
// params
|
80
|
+
obj
|
81
|
+
? [
|
82
|
+
// props
|
83
|
+
obj,
|
84
|
+
]
|
85
|
+
: [],
|
86
|
+
// body
|
87
|
+
t.blockStatement([
|
88
|
+
t.returnStatement(
|
89
|
+
t.objectExpression([
|
90
|
+
t.objectProperty(
|
91
|
+
t.identifier(underscoreName),
|
92
|
+
t.tsAsExpression(t.objectExpression(args), t.tsTypeReference(t.identifier('const')))
|
93
|
+
),
|
94
|
+
])
|
95
|
+
),
|
96
|
+
]),
|
97
|
+
// return type
|
98
|
+
t.tsTypeAnnotation(t.tsTypeReference(t.identifier(msgTitle))),
|
99
|
+
false
|
100
|
+
),
|
101
|
+
null,
|
102
|
+
null,
|
103
|
+
false,
|
104
|
+
// static
|
105
|
+
true
|
106
|
+
);
|
107
|
+
};
|
package/src/utils/babel.ts
CHANGED
@@ -2,6 +2,7 @@ import * as t from '@babel/types';
|
|
2
2
|
import { snake } from "case";
|
3
3
|
import { Field, QueryMsg, ExecuteMsg } from '../types';
|
4
4
|
import { TSTypeAnnotation, TSExpressionWithTypeArguments } from '@babel/types';
|
5
|
+
import { refLookup } from './ref';
|
5
6
|
|
6
7
|
// t.TSPropertySignature - kind?
|
7
8
|
export const propertySignature = (
|
@@ -30,11 +31,28 @@ export const tsTypeOperator = (typeAnnotation: t.TSType, operator: string) => {
|
|
30
31
|
return obj;
|
31
32
|
};
|
32
33
|
|
33
|
-
export const getMessageProperties = (msg
|
34
|
-
|
35
|
-
|
36
|
-
if (msg.
|
37
|
-
|
34
|
+
export const getMessageProperties = (msg) => {
|
35
|
+
let results = [];
|
36
|
+
let objs = [];
|
37
|
+
if (msg.anyOf) { objs = msg.anyOf; }
|
38
|
+
else if (msg.oneOf) { objs = msg.oneOf; }
|
39
|
+
else if (msg.allOf) { objs = msg.allOf; }
|
40
|
+
|
41
|
+
for (const obj of objs) {
|
42
|
+
if(obj.properties){
|
43
|
+
results.push(obj);
|
44
|
+
} else{
|
45
|
+
if(obj.$ref){
|
46
|
+
const ref = refLookup(obj.$ref, msg)
|
47
|
+
|
48
|
+
const refProps = getMessageProperties(ref);
|
49
|
+
|
50
|
+
results = [...results, ...refProps];
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
return results;
|
38
56
|
}
|
39
57
|
|
40
58
|
export const tsPropertySignature = (
|
@@ -112,6 +130,17 @@ export const promiseTypeAnnotation = (name) => {
|
|
112
130
|
);
|
113
131
|
}
|
114
132
|
|
133
|
+
export const abstractClassDeclaration = (name: string, body: any[], implementsExressions: TSExpressionWithTypeArguments[] = [], superClass: t.Identifier = null) => {
|
134
|
+
const declaration = classDeclaration(
|
135
|
+
name,
|
136
|
+
body,
|
137
|
+
implementsExressions,
|
138
|
+
superClass
|
139
|
+
);
|
140
|
+
declaration.abstract = true
|
141
|
+
return declaration;
|
142
|
+
};
|
143
|
+
|
115
144
|
export const classDeclaration = (name: string, body: any[], implementsExressions: TSExpressionWithTypeArguments[] = [], superClass: t.Identifier = null) => {
|
116
145
|
const declaration = t.classDeclaration(
|
117
146
|
t.identifier(name),
|
package/src/utils/index.ts
CHANGED
package/src/utils/ref.ts
ADDED
package/src/utils/types.ts
CHANGED
@@ -49,12 +49,8 @@ const getArrayTypeFromItems = (items) => {
|
|
49
49
|
// passing in [{"type":"string"}]
|
50
50
|
if (Array.isArray(items)) {
|
51
51
|
if (items[0]?.type === 'array') {
|
52
|
-
return
|
53
|
-
|
54
|
-
getArrayTypeFromItems(
|
55
|
-
items[0]
|
56
|
-
)
|
57
|
-
)
|
52
|
+
return getArrayTypeFromItems(
|
53
|
+
items[0]
|
58
54
|
);
|
59
55
|
}
|
60
56
|
return t.tsArrayType(
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { JSONSchema } from "../types";
|
2
|
+
import { UtilMapping } from "./imports";
|
2
3
|
export interface ReactQueryOptions {
|
3
4
|
enabled?: boolean;
|
4
5
|
optionalClient?: boolean;
|
@@ -16,6 +17,9 @@ export interface TSClientOptions {
|
|
16
17
|
export interface MessageComposerOptions {
|
17
18
|
enabled?: boolean;
|
18
19
|
}
|
20
|
+
export interface MsgBuilderOptions {
|
21
|
+
enabled?: boolean;
|
22
|
+
}
|
19
23
|
export interface RecoilOptions {
|
20
24
|
enabled?: boolean;
|
21
25
|
}
|
@@ -43,25 +47,46 @@ export interface ContractInfo {
|
|
43
47
|
idlObject?: IDLObject;
|
44
48
|
}
|
45
49
|
export interface RenderOptions {
|
50
|
+
enabled?: boolean;
|
46
51
|
types?: TSTypesOptions;
|
47
52
|
recoil?: RecoilOptions;
|
48
53
|
messageComposer?: MessageComposerOptions;
|
54
|
+
msgBuilder?: MsgBuilderOptions;
|
49
55
|
client?: TSClientOptions;
|
50
56
|
reactQuery?: ReactQueryOptions;
|
51
57
|
}
|
52
|
-
export interface
|
58
|
+
export interface IContext {
|
59
|
+
refLookup($ref: string): any;
|
60
|
+
addUtil(util: string): any;
|
61
|
+
getImports(registeredUtils?: UtilMapping): any;
|
62
|
+
}
|
63
|
+
export interface IRenderContext<TOpt = RenderOptions> extends IContext {
|
53
64
|
contract: ContractInfo;
|
54
|
-
options:
|
65
|
+
options: TOpt;
|
55
66
|
}
|
56
67
|
export declare const defaultOptions: RenderOptions;
|
57
68
|
export declare const getDefinitionSchema: (schemas: JSONSchema[]) => JSONSchema;
|
58
|
-
|
69
|
+
/**
|
70
|
+
* context object for generating code.
|
71
|
+
* only mergeDefaultOpt needs to implementing for combine options and default options.
|
72
|
+
* @param TOpt option type
|
73
|
+
*/
|
74
|
+
export declare abstract class RenderContextBase<TOpt = RenderOptions> implements IRenderContext<TOpt> {
|
59
75
|
contract: ContractInfo;
|
60
76
|
utils: string[];
|
61
77
|
schema: JSONSchema;
|
62
|
-
|
78
|
+
options: TOpt;
|
79
|
+
constructor(contract: ContractInfo, options?: TOpt);
|
80
|
+
/**
|
81
|
+
* merge options and default options
|
82
|
+
* @param options
|
83
|
+
*/
|
84
|
+
abstract mergeDefaultOpt(options: TOpt): TOpt;
|
63
85
|
refLookup($ref: string): JSONSchema;
|
64
86
|
addUtil(util: string): void;
|
65
|
-
getImports(): any
|
87
|
+
getImports(registeredUtils?: UtilMapping): any;
|
88
|
+
}
|
89
|
+
export declare class RenderContext extends RenderContextBase {
|
90
|
+
mergeDefaultOpt(options: RenderOptions): RenderOptions;
|
66
91
|
}
|
67
92
|
export {};
|
@@ -5,12 +5,16 @@ export interface ImportObj {
|
|
5
5
|
path: string;
|
6
6
|
importAs?: string;
|
7
7
|
}
|
8
|
+
export type GetUtilFn = (<TContext = RenderContext>(...args: any[]) => (context: TContext) => ImportObj);
|
9
|
+
export type UtilMapping = {
|
10
|
+
[key: string]: ImportObj | string | GetUtilFn;
|
11
|
+
};
|
8
12
|
export declare const UTILS: {
|
13
|
+
selectorFamily: string;
|
9
14
|
MsgExecuteContract: string;
|
10
15
|
MsgExecuteContractEncodeObject: string;
|
11
16
|
Coin: string;
|
12
17
|
toUtf8: string;
|
13
|
-
selectorFamily: string;
|
14
18
|
StdFee: string;
|
15
19
|
CosmWasmClient: string;
|
16
20
|
ExecuteResult: string;
|
@@ -36,5 +40,6 @@ export declare const UTILS: {
|
|
36
40
|
name: any;
|
37
41
|
};
|
38
42
|
};
|
39
|
-
export declare const convertUtilsToImportList: (context: RenderContext, utils: string[]) => ImportObj[];
|
43
|
+
export declare const convertUtilsToImportList: (context: RenderContext, utils: string[], registeredUtils?: UtilMapping) => ImportObj[];
|
44
|
+
export declare const convertUtil: (context: RenderContext, util: string, registeredUtils: object) => ImportObj;
|
40
45
|
export declare const getImportStatements: (list: ImportObj[]) => any[];
|
package/types/index.d.ts
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './msg-builder';
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import * as t from "@babel/types";
|
2
|
+
import { ExecuteMsg, QueryMsg } from "../types";
|
3
|
+
import { RenderContext } from "../context";
|
4
|
+
export declare const createMsgBuilderClass: (context: RenderContext, className: string, msg: ExecuteMsg | QueryMsg) => t.ExportNamedDeclaration;
|
@@ -30,16 +30,17 @@ interface ReactQueryMutationHookInterface {
|
|
30
30
|
/**
|
31
31
|
* Example:
|
32
32
|
```
|
33
|
-
export interface
|
34
|
-
client:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
export interface Cw721RevokeMutation {
|
34
|
+
client: Cw721Client;
|
35
|
+
msg: {
|
36
|
+
spender: string;
|
37
|
+
tokenId: string;
|
38
|
+
};
|
39
|
+
args?: {
|
40
|
+
fee?: number | StdFee | "auto";
|
41
|
+
memo?: string;
|
42
|
+
funds?: Coin[];
|
43
|
+
};
|
43
44
|
}
|
44
45
|
```
|
45
46
|
*/
|
package/types/recoil/recoil.d.ts
CHANGED
@@ -2,7 +2,7 @@ import * as t from '@babel/types';
|
|
2
2
|
import { QueryMsg } from '../types';
|
3
3
|
import { RenderContext } from '../context';
|
4
4
|
export declare const createRecoilSelector: (context: RenderContext, keyPrefix: string, QueryClient: string, methodName: string, responseType: string) => t.ExportNamedDeclaration;
|
5
|
-
export declare const createRecoilSelectors: (context: RenderContext, keyPrefix: string, QueryClient: string, queryMsg: QueryMsg) =>
|
5
|
+
export declare const createRecoilSelectors: (context: RenderContext, keyPrefix: string, QueryClient: string, queryMsg: QueryMsg) => t.ExportNamedDeclaration[];
|
6
6
|
export declare const createRecoilQueryClientType: () => {
|
7
7
|
type: string;
|
8
8
|
id: {
|
package/types/utils/babel.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as t from '@babel/types';
|
2
|
-
import { Field
|
2
|
+
import { Field } from '../types';
|
3
3
|
import { TSTypeAnnotation, TSExpressionWithTypeArguments } from '@babel/types';
|
4
4
|
export declare const propertySignature: (name: string, typeAnnotation: t.TSTypeAnnotation, optional?: boolean) => {
|
5
5
|
type: string;
|
@@ -9,13 +9,14 @@ export declare const propertySignature: (name: string, typeAnnotation: t.TSTypeA
|
|
9
9
|
};
|
10
10
|
export declare const identifier: (name: string, typeAnnotation: t.TSTypeAnnotation, optional?: boolean) => t.Identifier;
|
11
11
|
export declare const tsTypeOperator: (typeAnnotation: t.TSType, operator: string) => t.TSTypeOperator;
|
12
|
-
export declare const getMessageProperties: (msg:
|
12
|
+
export declare const getMessageProperties: (msg: any) => any[];
|
13
13
|
export declare const tsPropertySignature: (key: t.Expression, typeAnnotation: t.TSTypeAnnotation, optional: boolean) => t.TSPropertySignature;
|
14
14
|
export declare const tsObjectPattern: (properties: (t.RestElement | t.ObjectProperty)[], typeAnnotation: t.TSTypeAnnotation) => t.ObjectPattern;
|
15
15
|
export declare const callExpression: (callee: t.Expression | t.V8IntrinsicIdentifier, _arguments: (t.Expression | t.SpreadElement | t.ArgumentPlaceholder)[], typeParameters: t.TSTypeParameterInstantiation) => t.CallExpression;
|
16
16
|
export declare const bindMethod: (name: string) => t.ExpressionStatement;
|
17
17
|
export declare const typedIdentifier: (name: string, typeAnnotation: TSTypeAnnotation, optional?: boolean) => t.Identifier;
|
18
18
|
export declare const promiseTypeAnnotation: (name: any) => t.TSTypeAnnotation;
|
19
|
+
export declare const abstractClassDeclaration: (name: string, body: any[], implementsExressions?: TSExpressionWithTypeArguments[], superClass?: t.Identifier) => t.ClassDeclaration;
|
19
20
|
export declare const classDeclaration: (name: string, body: any[], implementsExressions?: TSExpressionWithTypeArguments[], superClass?: t.Identifier) => t.ClassDeclaration;
|
20
21
|
export declare const classProperty: (name: string, typeAnnotation?: TSTypeAnnotation, isReadonly?: boolean, isStatic?: boolean, noImplicitOverride?: boolean) => t.ClassProperty;
|
21
22
|
export declare const arrowFunctionExpression: (params: (t.Identifier | t.Pattern | t.RestElement)[], body: t.BlockStatement, returnType: t.TSTypeAnnotation, isAsync?: boolean) => t.ArrowFunctionExpression;
|
package/types/utils/index.d.ts
CHANGED