wasm-ast-types 0.26.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE-Apache +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +24 -1
- package/{types/client → client}/client.d.ts +2 -2
- package/client/client.js +275 -0
- package/client/index.js +17 -0
- package/{types/context → context}/context.d.ts +9 -22
- package/context/context.js +114 -0
- package/{types/context → context}/imports.d.ts +9 -8
- package/context/imports.js +166 -0
- package/context/index.js +18 -0
- package/esm/client/client.js +238 -0
- package/esm/client/index.js +1 -0
- package/esm/context/context.js +104 -0
- package/esm/context/imports.js +136 -0
- package/{module → esm}/context/index.js +1 -1
- package/{src/index.ts → esm/index.js} +0 -1
- package/esm/message-builder/message-builder.js +64 -0
- package/esm/message-composer/message-composer.js +105 -0
- package/esm/provider/provider.js +97 -0
- package/esm/react-query/react-query.js +458 -0
- package/esm/recoil/recoil.js +110 -0
- package/esm/utils/babel.js +231 -0
- package/esm/utils/constants.js +20 -0
- package/esm/utils/ref.js +4 -0
- package/esm/utils/types.js +343 -0
- package/{types/index.d.ts → index.d.ts} +0 -1
- package/index.js +24 -0
- package/message-builder/index.js +17 -0
- package/{types/message-builder → message-builder}/message-builder.d.ts +1 -1
- package/message-builder/message-builder.js +91 -0
- package/message-composer/index.d.ts +1 -0
- package/message-composer/index.js +17 -0
- package/{types/message-composer → message-composer}/message-composer.d.ts +1 -1
- package/message-composer/message-composer.js +133 -0
- package/package.json +19 -68
- package/provider/index.d.ts +1 -0
- package/provider/index.js +17 -0
- package/provider/provider.js +127 -0
- package/react-query/index.d.ts +1 -0
- package/react-query/index.js +17 -0
- package/{types/react-query → react-query}/react-query.d.ts +2 -3
- package/react-query/react-query.js +490 -0
- package/recoil/index.d.ts +1 -0
- package/recoil/index.js +17 -0
- package/{types/recoil → recoil}/recoil.d.ts +1 -1
- package/recoil/recoil.js +140 -0
- package/{types/utils → utils}/babel.d.ts +9 -8
- package/utils/babel.js +285 -0
- package/utils/constants.js +46 -0
- package/utils/index.js +26 -0
- package/{types/utils → utils}/ref.d.ts +1 -1
- package/utils/ref.js +8 -0
- package/{types/utils → utils}/types.d.ts +8 -8
- package/utils/types.js +379 -0
- package/main/client/client.js +0 -196
- package/main/client/index.js +0 -16
- package/main/client/test/ts-client.account-nfts.spec.js +0 -28
- package/main/client/test/ts-client.arrays-ref.spec.js +0 -19
- package/main/client/test/ts-client.arrays.spec.js +0 -26
- package/main/client/test/ts-client.cw-named-groups.test.js +0 -19
- package/main/client/test/ts-client.cw-proposal-single.test.js +0 -23
- package/main/client/test/ts-client.empty-enums.spec.js +0 -13
- package/main/client/test/ts-client.issue-101.spec.js +0 -23
- package/main/client/test/ts-client.issue-103.test.js +0 -44
- package/main/client/test/ts-client.issue-71.test.js +0 -81
- package/main/client/test/ts-client.issue-98.test.js +0 -28
- package/main/client/test/ts-client.issues.test.js +0 -81
- package/main/client/test/ts-client.overrides.spec.js +0 -33
- package/main/client/test/ts-client.sg721.spec.js +0 -19
- package/main/client/test/ts-client.spec.js +0 -87
- package/main/client/test/ts-client.vectis.spec.js +0 -46
- package/main/client/test/ts-client.wager.spec.js +0 -39
- package/main/context/context.js +0 -162
- package/main/context/imports.js +0 -159
- package/main/context/index.js +0 -27
- package/main/index.js +0 -104
- package/main/message-builder/index.js +0 -16
- package/main/message-builder/message-builder.js +0 -62
- package/main/message-builder/message-builder.spec.js +0 -20
- package/main/message-composer/index.js +0 -16
- package/main/message-composer/message-composer.js +0 -86
- package/main/message-composer/message-composer.spec.js +0 -23
- package/main/provider/index.js +0 -16
- package/main/provider/provider.js +0 -71
- package/main/provider/provider.spec.js +0 -60
- package/main/react-query/index.js +0 -16
- package/main/react-query/react-query.js +0 -413
- package/main/react-query/react-query.spec.js +0 -91
- package/main/recoil/index.js +0 -16
- package/main/recoil/recoil.js +0 -61
- package/main/recoil/recoil.spec.js +0 -20
- package/main/types.js +0 -4
- package/main/utils/babel.js +0 -282
- package/main/utils/babel.spec.js +0 -109
- package/main/utils/constants.js +0 -26
- package/main/utils/index.js +0 -65
- package/main/utils/ref.js +0 -12
- package/main/utils/types.js +0 -343
- package/module/client/client.js +0 -166
- package/module/client/index.js +0 -1
- package/module/client/test/ts-client.account-nfts.spec.js +0 -25
- package/module/client/test/ts-client.arrays-ref.spec.js +0 -16
- package/module/client/test/ts-client.arrays.spec.js +0 -23
- package/module/client/test/ts-client.cw-named-groups.test.js +0 -16
- package/module/client/test/ts-client.cw-proposal-single.test.js +0 -20
- package/module/client/test/ts-client.empty-enums.spec.js +0 -10
- package/module/client/test/ts-client.issue-101.spec.js +0 -22
- package/module/client/test/ts-client.issue-103.test.js +0 -41
- package/module/client/test/ts-client.issue-71.test.js +0 -21
- package/module/client/test/ts-client.issue-98.test.js +0 -25
- package/module/client/test/ts-client.issues.test.js +0 -21
- package/module/client/test/ts-client.overrides.spec.js +0 -30
- package/module/client/test/ts-client.sg721.spec.js +0 -16
- package/module/client/test/ts-client.spec.js +0 -84
- package/module/client/test/ts-client.vectis.spec.js +0 -43
- package/module/client/test/ts-client.wager.spec.js +0 -36
- package/module/context/context.js +0 -116
- package/module/context/imports.js +0 -127
- package/module/index.js +0 -9
- package/module/message-builder/index.js +0 -1
- package/module/message-builder/message-builder.js +0 -52
- package/module/message-builder/message-builder.spec.js +0 -17
- package/module/message-composer/index.js +0 -1
- package/module/message-composer/message-composer.js +0 -70
- package/module/message-composer/message-composer.spec.js +0 -20
- package/module/provider/index.js +0 -1
- package/module/provider/provider.js +0 -45
- package/module/provider/provider.spec.js +0 -58
- package/module/react-query/index.js +0 -1
- package/module/react-query/react-query.js +0 -403
- package/module/react-query/react-query.spec.js +0 -85
- package/module/recoil/index.js +0 -1
- package/module/recoil/recoil.js +0 -46
- package/module/recoil/recoil.spec.js +0 -14
- package/module/types.js +0 -3
- package/module/utils/babel.js +0 -203
- package/module/utils/babel.spec.js +0 -70
- package/module/utils/constants.js +0 -12
- package/module/utils/index.js +0 -6
- package/module/utils/ref.js +0 -4
- package/module/utils/types.js +0 -301
- package/src/client/client.ts +0 -584
- package/src/client/index.ts +0 -1
- package/src/client/test/__snapshots__/ts-client.account-nfts.spec.ts.snap +0 -497
- package/src/client/test/__snapshots__/ts-client.arrays-ref.spec.ts.snap +0 -452
- package/src/client/test/__snapshots__/ts-client.arrays.spec.ts.snap +0 -101
- package/src/client/test/__snapshots__/ts-client.cw-named-groups.test.ts.snap +0 -141
- package/src/client/test/__snapshots__/ts-client.cw-proposal-single.test.ts.snap +0 -341
- package/src/client/test/__snapshots__/ts-client.empty-enums.spec.ts.snap +0 -20
- package/src/client/test/__snapshots__/ts-client.issue-101.spec.ts.snap +0 -47
- package/src/client/test/__snapshots__/ts-client.issue-103.test.ts.snap +0 -79
- package/src/client/test/__snapshots__/ts-client.issue-71.test.ts.snap +0 -432
- package/src/client/test/__snapshots__/ts-client.issue-98.test.ts.snap +0 -117
- package/src/client/test/__snapshots__/ts-client.issues.test.ts.snap +0 -984
- package/src/client/test/__snapshots__/ts-client.overrides.spec.ts.snap +0 -709
- package/src/client/test/__snapshots__/ts-client.sg721.spec.ts.snap +0 -350
- package/src/client/test/__snapshots__/ts-client.spec.ts.snap +0 -723
- package/src/client/test/__snapshots__/ts-client.vectis.spec.ts.snap +0 -337
- package/src/client/test/__snapshots__/ts-client.wager.spec.ts.snap +0 -132
- package/src/client/test/ts-client.account-nfts.spec.ts +0 -55
- package/src/client/test/ts-client.arrays-ref.spec.ts +0 -48
- package/src/client/test/ts-client.arrays.spec.ts +0 -58
- package/src/client/test/ts-client.cw-named-groups.test.ts +0 -48
- package/src/client/test/ts-client.cw-proposal-single.test.ts +0 -50
- package/src/client/test/ts-client.empty-enums.spec.ts +0 -28
- package/src/client/test/ts-client.issue-101.spec.ts +0 -37
- package/src/client/test/ts-client.issue-103.test.ts +0 -106
- package/src/client/test/ts-client.issue-71.test.ts +0 -51
- package/src/client/test/ts-client.issue-98.test.ts +0 -55
- package/src/client/test/ts-client.issues.test.ts +0 -52
- package/src/client/test/ts-client.overrides.spec.ts +0 -74
- package/src/client/test/ts-client.sg721.spec.ts +0 -46
- package/src/client/test/ts-client.spec.ts +0 -166
- package/src/client/test/ts-client.vectis.spec.ts +0 -97
- package/src/client/test/ts-client.wager.spec.ts +0 -63
- package/src/context/context.ts +0 -229
- package/src/context/imports.ts +0 -195
- package/src/context/index.ts +0 -2
- package/src/message-builder/__snapshots__/message-builder.spec.ts.snap +0 -270
- package/src/message-builder/message-builder.spec.ts +0 -24
- package/src/message-builder/message-builder.ts +0 -119
- package/src/message-composer/__snapshots__/message-composer.spec.ts.snap +0 -331
- package/src/message-composer/index.ts +0 -1
- package/src/message-composer/message-composer.spec.ts +0 -46
- package/src/message-composer/message-composer.ts +0 -262
- package/src/provider/__snapshots__/provider.spec.ts.snap +0 -49
- package/src/provider/index.ts +0 -1
- package/src/provider/provider.spec.ts +0 -81
- package/src/provider/provider.ts +0 -237
- package/src/react-query/__snapshots__/react-query.spec.ts.snap +0 -1359
- package/src/react-query/index.ts +0 -1
- package/src/react-query/react-query.spec.ts +0 -116
- package/src/react-query/react-query.ts +0 -1072
- package/src/recoil/__snapshots__/recoil.spec.ts.snap +0 -203
- package/src/recoil/index.ts +0 -1
- package/src/recoil/recoil.spec.ts +0 -38
- package/src/recoil/recoil.ts +0 -307
- package/src/types.ts +0 -44
- package/src/utils/__snapshots__/babel.spec.ts.snap +0 -75
- package/src/utils/babel.spec.ts +0 -511
- package/src/utils/babel.ts +0 -352
- package/src/utils/constants.ts +0 -37
- package/src/utils/ref.ts +0 -6
- package/src/utils/types.ts +0 -478
- package/types/types.d.ts +0 -41
- /package/{types/client → client}/index.d.ts +0 -0
- /package/{types/context → context}/index.d.ts +0 -0
- /package/{src/message-builder/index.ts → esm/message-builder/index.js} +0 -0
- /package/{types/message-composer/index.d.ts → esm/message-composer/index.js} +0 -0
- /package/{types/provider/index.d.ts → esm/provider/index.js} +0 -0
- /package/{types/react-query/index.d.ts → esm/react-query/index.js} +0 -0
- /package/{types/recoil/index.d.ts → esm/recoil/index.js} +0 -0
- /package/{src/utils/index.ts → esm/utils/index.js} +0 -0
- /package/{types/message-builder → message-builder}/index.d.ts +0 -0
- /package/{types/provider → provider}/provider.d.ts +0 -0
- /package/{types/utils → utils}/constants.d.ts +0 -0
- /package/{types/utils → utils}/index.d.ts +0 -0
package/src/utils/babel.ts
DELETED
@@ -1,352 +0,0 @@
|
|
1
|
-
import * as t from '@babel/types';
|
2
|
-
import { snake } from "case";
|
3
|
-
import { Field, QueryMsg, ExecuteMsg } from '../types';
|
4
|
-
import { TSTypeAnnotation, TSExpressionWithTypeArguments, Noop, TypeAnnotation } from '@babel/types';
|
5
|
-
import { refLookup } from './ref';
|
6
|
-
|
7
|
-
// t.TSPropertySignature - kind?
|
8
|
-
export const propertySignature = (
|
9
|
-
name: string,
|
10
|
-
typeAnnotation: TSTypeAnnotation,
|
11
|
-
optional: boolean = false
|
12
|
-
): t.TSPropertySignature => {
|
13
|
-
return {
|
14
|
-
type: 'TSPropertySignature',
|
15
|
-
key: t.identifier(name),
|
16
|
-
kind: 'get',
|
17
|
-
typeAnnotation,
|
18
|
-
optional
|
19
|
-
}
|
20
|
-
};
|
21
|
-
|
22
|
-
export const identifier = (name: string, typeAnnotation: t.TSTypeAnnotation, optional: boolean = false): t.Identifier => {
|
23
|
-
const type = t.identifier(name);
|
24
|
-
type.typeAnnotation = typeAnnotation;
|
25
|
-
type.optional = optional;
|
26
|
-
return type;
|
27
|
-
};
|
28
|
-
|
29
|
-
export const tsTypeOperator = (typeAnnotation: t.TSType, operator: string) => {
|
30
|
-
const obj = t.tsTypeOperator(typeAnnotation);
|
31
|
-
obj.operator = operator;
|
32
|
-
return obj;
|
33
|
-
};
|
34
|
-
|
35
|
-
export const getMessageProperties = (msg) => {
|
36
|
-
let results = [];
|
37
|
-
let objs = [];
|
38
|
-
if (msg.anyOf) { objs = msg.anyOf; }
|
39
|
-
else if (msg.oneOf) { objs = msg.oneOf; }
|
40
|
-
else if (msg.allOf) { objs = msg.allOf; }
|
41
|
-
|
42
|
-
for (const obj of objs) {
|
43
|
-
if(obj.properties){
|
44
|
-
results.push(obj);
|
45
|
-
} else{
|
46
|
-
if(obj.$ref){
|
47
|
-
const ref = refLookup(obj.$ref, msg)
|
48
|
-
|
49
|
-
const refProps = getMessageProperties(ref);
|
50
|
-
|
51
|
-
results = [...results, ...refProps];
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
return results;
|
57
|
-
}
|
58
|
-
|
59
|
-
export const tsPropertySignature = (
|
60
|
-
key: t.Expression,
|
61
|
-
typeAnnotation: t.TSTypeAnnotation,
|
62
|
-
optional: boolean
|
63
|
-
) => {
|
64
|
-
const obj = t.tsPropertySignature(key, typeAnnotation);
|
65
|
-
obj.optional = optional;
|
66
|
-
return obj
|
67
|
-
};
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
export const tsObjectPattern = (
|
72
|
-
properties: (t.RestElement | t.ObjectProperty)[],
|
73
|
-
typeAnnotation: t.TSTypeAnnotation
|
74
|
-
) => {
|
75
|
-
const obj = t.objectPattern(
|
76
|
-
properties
|
77
|
-
);
|
78
|
-
obj.typeAnnotation = typeAnnotation;
|
79
|
-
return obj;
|
80
|
-
}
|
81
|
-
|
82
|
-
export const callExpression = (
|
83
|
-
callee: t.Expression | t.V8IntrinsicIdentifier,
|
84
|
-
_arguments: (t.Expression | t.SpreadElement | t.ArgumentPlaceholder)[],
|
85
|
-
typeParameters: t.TSTypeParameterInstantiation
|
86
|
-
) => {
|
87
|
-
const callExpr = t.callExpression(callee, _arguments);
|
88
|
-
callExpr.typeParameters = typeParameters;
|
89
|
-
return callExpr;
|
90
|
-
};
|
91
|
-
|
92
|
-
export const bindMethod = (name: string) => {
|
93
|
-
return t.expressionStatement(
|
94
|
-
t.assignmentExpression('=', t.memberExpression(
|
95
|
-
t.thisExpression(),
|
96
|
-
t.identifier(name)
|
97
|
-
),
|
98
|
-
t.callExpression(
|
99
|
-
t.memberExpression(
|
100
|
-
t.memberExpression(
|
101
|
-
t.thisExpression(),
|
102
|
-
t.identifier(name)
|
103
|
-
),
|
104
|
-
t.identifier('bind')
|
105
|
-
),
|
106
|
-
[
|
107
|
-
t.thisExpression()
|
108
|
-
]
|
109
|
-
)
|
110
|
-
)
|
111
|
-
)
|
112
|
-
}
|
113
|
-
|
114
|
-
export const typedIdentifier = (name: string, typeAnnotation: TSTypeAnnotation, optional: boolean = false) => {
|
115
|
-
const type = t.identifier(name);
|
116
|
-
type.typeAnnotation = typeAnnotation;
|
117
|
-
type.optional = optional;
|
118
|
-
return type;
|
119
|
-
}
|
120
|
-
|
121
|
-
export const promiseTypeAnnotation = (name) => {
|
122
|
-
return t.tsTypeAnnotation(
|
123
|
-
t.tsTypeReference(
|
124
|
-
t.identifier('Promise'),
|
125
|
-
t.tsTypeParameterInstantiation(
|
126
|
-
[
|
127
|
-
t.tsTypeReference(t.identifier(name))
|
128
|
-
]
|
129
|
-
)
|
130
|
-
)
|
131
|
-
);
|
132
|
-
}
|
133
|
-
|
134
|
-
export const abstractClassDeclaration = (name: string, body: any[], implementsExressions: TSExpressionWithTypeArguments[] = [], superClass: t.Identifier = null) => {
|
135
|
-
const declaration = classDeclaration(
|
136
|
-
name,
|
137
|
-
body,
|
138
|
-
implementsExressions,
|
139
|
-
superClass
|
140
|
-
);
|
141
|
-
declaration.abstract = true
|
142
|
-
return declaration;
|
143
|
-
};
|
144
|
-
|
145
|
-
export const classDeclaration = (name: string, body: any[], implementsExressions: TSExpressionWithTypeArguments[] = [], superClass: t.Identifier = null) => {
|
146
|
-
const declaration = t.classDeclaration(
|
147
|
-
t.identifier(name),
|
148
|
-
superClass,
|
149
|
-
t.classBody(body)
|
150
|
-
);
|
151
|
-
if (implementsExressions.length) {
|
152
|
-
declaration.implements = implementsExressions;
|
153
|
-
}
|
154
|
-
return declaration;
|
155
|
-
};
|
156
|
-
|
157
|
-
|
158
|
-
export const classProperty = (
|
159
|
-
name: string,
|
160
|
-
typeAnnotation: TSTypeAnnotation = null,
|
161
|
-
isReadonly: boolean = false,
|
162
|
-
isStatic: boolean = false,
|
163
|
-
noImplicitOverride: boolean = false
|
164
|
-
) => {
|
165
|
-
const prop = t.classProperty(t.identifier(name));
|
166
|
-
if (isReadonly) prop.readonly = true;
|
167
|
-
if (isStatic) prop.static = true;
|
168
|
-
if (typeAnnotation) prop.typeAnnotation = typeAnnotation;
|
169
|
-
if (noImplicitOverride) prop.override = true;
|
170
|
-
return prop;
|
171
|
-
};
|
172
|
-
|
173
|
-
export const arrowFunctionExpression = (
|
174
|
-
params: (t.Identifier | t.Pattern | t.RestElement)[],
|
175
|
-
body: t.BlockStatement,
|
176
|
-
returnType: t.TSTypeAnnotation,
|
177
|
-
isAsync: boolean = false
|
178
|
-
) => {
|
179
|
-
const func = t.arrowFunctionExpression(params, body, isAsync);
|
180
|
-
if (returnType) func.returnType = returnType;
|
181
|
-
return func;
|
182
|
-
};
|
183
|
-
|
184
|
-
|
185
|
-
export const recursiveNamespace = (names, moduleBlockBody) => {
|
186
|
-
if (!names || !names.length) return moduleBlockBody;
|
187
|
-
const name = names.pop();
|
188
|
-
const body = [
|
189
|
-
t.exportNamedDeclaration(
|
190
|
-
t.tsModuleDeclaration(
|
191
|
-
t.identifier(name),
|
192
|
-
t.tsModuleBlock(recursiveNamespace(names, moduleBlockBody))
|
193
|
-
)
|
194
|
-
)
|
195
|
-
];
|
196
|
-
return body;
|
197
|
-
};
|
198
|
-
|
199
|
-
export const arrayTypeNDimensions = (body, n) => {
|
200
|
-
if (!n) return t.tsArrayType(body);
|
201
|
-
return t.tsArrayType(
|
202
|
-
arrayTypeNDimensions(body, n - 1)
|
203
|
-
);
|
204
|
-
};
|
205
|
-
|
206
|
-
export const FieldTypeAsts = {
|
207
|
-
string: () => {
|
208
|
-
return t.tsStringKeyword()
|
209
|
-
},
|
210
|
-
array: (type) => {
|
211
|
-
return t.tsArrayType(FieldTypeAsts[type]())
|
212
|
-
},
|
213
|
-
Duration: () => {
|
214
|
-
return t.tsTypeReference(t.identifier('Duration'))
|
215
|
-
},
|
216
|
-
Height: () => {
|
217
|
-
return t.tsTypeReference(t.identifier('Height'))
|
218
|
-
},
|
219
|
-
Coin: () => {
|
220
|
-
return t.tsTypeReference(t.identifier('Coin'))
|
221
|
-
},
|
222
|
-
Long: () => {
|
223
|
-
return t.tsTypeReference(t.identifier('Long'))
|
224
|
-
}
|
225
|
-
};
|
226
|
-
|
227
|
-
export const shorthandProperty = (prop: string) => {
|
228
|
-
return t.objectProperty(t.identifier(prop), t.identifier(prop), false, true);
|
229
|
-
};
|
230
|
-
|
231
|
-
export const importStmt = (names: string[], path: string) => {
|
232
|
-
return t.importDeclaration(
|
233
|
-
names.map(name => t.importSpecifier(t.identifier(name), t.identifier(name))),
|
234
|
-
t.stringLiteral(path));
|
235
|
-
};
|
236
|
-
|
237
|
-
export const importAs = (name: string, importAs: string, importPath: string) => {
|
238
|
-
return t.importDeclaration(
|
239
|
-
[
|
240
|
-
t.importSpecifier(
|
241
|
-
t.identifier(importAs),
|
242
|
-
t.identifier(name)
|
243
|
-
)
|
244
|
-
],
|
245
|
-
t.stringLiteral(importPath)
|
246
|
-
)
|
247
|
-
};
|
248
|
-
|
249
|
-
export const importAminoMsg = () => {
|
250
|
-
return importStmt(['AminoMsg'], '@cosmjs/amino');
|
251
|
-
};
|
252
|
-
|
253
|
-
export const getFieldDimensionality = (field: Field) => {
|
254
|
-
let typeName = field.type;
|
255
|
-
const isArray = typeName.endsWith('[]');
|
256
|
-
let dimensions = 0;
|
257
|
-
if (isArray) {
|
258
|
-
dimensions = typeName.match(/\[\]/g).length - 1;
|
259
|
-
typeName = typeName.replace(/\[\]/g, '');
|
260
|
-
}
|
261
|
-
return {
|
262
|
-
typeName,
|
263
|
-
dimensions,
|
264
|
-
isArray
|
265
|
-
};
|
266
|
-
}
|
267
|
-
|
268
|
-
export const memberExpressionOrIdentifier = (names) => {
|
269
|
-
if (names.length === 1) {
|
270
|
-
return t.identifier(names[0])
|
271
|
-
}
|
272
|
-
if (names.length === 2) {
|
273
|
-
const [b, a] = names;
|
274
|
-
return t.memberExpression(
|
275
|
-
t.identifier(a),
|
276
|
-
t.identifier(b)
|
277
|
-
);
|
278
|
-
}
|
279
|
-
const [name, ...rest] = names;
|
280
|
-
|
281
|
-
return t.memberExpression(
|
282
|
-
memberExpressionOrIdentifier(rest),
|
283
|
-
t.identifier(name)
|
284
|
-
)
|
285
|
-
};
|
286
|
-
|
287
|
-
export const memberExpressionOrIdentifierSnake = (names) => {
|
288
|
-
if (names.length === 1) {
|
289
|
-
return t.identifier(snake(names[0]))
|
290
|
-
}
|
291
|
-
if (names.length === 2) {
|
292
|
-
const [b, a] = names;
|
293
|
-
return t.memberExpression(
|
294
|
-
t.identifier(snake(a)),
|
295
|
-
t.identifier(snake(b))
|
296
|
-
);
|
297
|
-
}
|
298
|
-
const [name, ...rest] = names;
|
299
|
-
|
300
|
-
return t.memberExpression(
|
301
|
-
memberExpressionOrIdentifierSnake(rest),
|
302
|
-
t.identifier(snake(name))
|
303
|
-
)
|
304
|
-
};
|
305
|
-
|
306
|
-
/**
|
307
|
-
* If optional, return a conditional, otherwise just the expression
|
308
|
-
*/
|
309
|
-
export const optionalConditionalExpression = (test: t.Expression, expression: t.Expression, alternate: t.Expression, optional: boolean = false): t.Expression => {
|
310
|
-
return optional
|
311
|
-
? t.conditionalExpression(
|
312
|
-
test,
|
313
|
-
expression,
|
314
|
-
alternate
|
315
|
-
)
|
316
|
-
: expression
|
317
|
-
}
|
318
|
-
|
319
|
-
export const typeRefOrUnionWithUndefined = (identifier: t.Identifier, optional: boolean = false): t.TSType => {
|
320
|
-
const typeReference = t.tsTypeReference(identifier)
|
321
|
-
return optional
|
322
|
-
? t.tsUnionType([
|
323
|
-
typeReference,
|
324
|
-
t.tsUndefinedKeyword()
|
325
|
-
])
|
326
|
-
: typeReference
|
327
|
-
}
|
328
|
-
|
329
|
-
export const parameterizedTypeReference = (identifier: string, from: t.TSType, omit: string | Array<string>) => {
|
330
|
-
return t.tsTypeReference(
|
331
|
-
t.identifier(identifier),
|
332
|
-
t.tsTypeParameterInstantiation([
|
333
|
-
from,
|
334
|
-
typeof omit === 'string'
|
335
|
-
? t.tsLiteralType(t.stringLiteral(omit))
|
336
|
-
: t.tsUnionType(omit.map(o => t.tsLiteralType(t.stringLiteral(o))))
|
337
|
-
])
|
338
|
-
)
|
339
|
-
}
|
340
|
-
|
341
|
-
/**
|
342
|
-
* omitTypeReference(t.tsTypeReference(t.identifier('Cw4UpdateMembersMutation'),),'args').....
|
343
|
-
* Omit<Cw4UpdateMembersMutation, 'args'>
|
344
|
-
*/
|
345
|
-
export const omitTypeReference = (from: t.TSType, omit: string | Array<string>) => {
|
346
|
-
return parameterizedTypeReference('Omit', from, omit)
|
347
|
-
}
|
348
|
-
|
349
|
-
|
350
|
-
export const pickTypeReference = (from: t.TSType, pick: string | Array<string>) => {
|
351
|
-
return parameterizedTypeReference('Pick', from, pick)
|
352
|
-
}
|
package/src/utils/constants.ts
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
import { identifier } from './babel';
|
2
|
-
import * as t from '@babel/types';
|
3
|
-
|
4
|
-
export const OPTIONAL_FUNDS_PARAM = identifier(
|
5
|
-
'_funds',
|
6
|
-
t.tsTypeAnnotation(t.tsArrayType(t.tsTypeReference(t.identifier('Coin')))),
|
7
|
-
true
|
8
|
-
);
|
9
|
-
export const OPTIONAL_FEE_PARAM = identifier(
|
10
|
-
'fee',
|
11
|
-
t.tsTypeAnnotation(
|
12
|
-
t.tsUnionType([
|
13
|
-
t.tsNumberKeyword(),
|
14
|
-
t.tsTypeReference(t.identifier('StdFee')),
|
15
|
-
t.tsLiteralType(t.stringLiteral('auto'))
|
16
|
-
])
|
17
|
-
),
|
18
|
-
true
|
19
|
-
);
|
20
|
-
export const OPTIONAL_MEMO_PARAM = identifier(
|
21
|
-
'memo',
|
22
|
-
t.tsTypeAnnotation(t.tsStringKeyword()),
|
23
|
-
true
|
24
|
-
);
|
25
|
-
|
26
|
-
export const FIXED_EXECUTE_PARAMS = [
|
27
|
-
OPTIONAL_FEE_PARAM,
|
28
|
-
OPTIONAL_MEMO_PARAM,
|
29
|
-
OPTIONAL_FUNDS_PARAM
|
30
|
-
];
|
31
|
-
|
32
|
-
export const PROVIDER_TYPES = {
|
33
|
-
SIGNING_CLIENT_TYPE: "client",
|
34
|
-
QUERY_CLIENT_TYPE: "queryClient",
|
35
|
-
MESSAGE_COMPOSER_TYPE : 'message-composer',
|
36
|
-
PROVIDER_TYPE : 'provider'
|
37
|
-
};
|