@algorandfoundation/algorand-typescript-testing 1.0.0-alpha.10

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.
Files changed (58) hide show
  1. package/abi-metadata.d.ts +16 -0
  2. package/collections/custom-key-map.d.ts +29 -0
  3. package/constants.d.ts +27 -0
  4. package/context-helpers/internal-context.d.ts +26 -0
  5. package/decode-logs.d.ts +9 -0
  6. package/encoders.d.ts +9 -0
  7. package/errors.d.ts +5 -0
  8. package/impl/account.d.ts +32 -0
  9. package/impl/acct-params.d.ts +5 -0
  10. package/impl/app-global.d.ts +2 -0
  11. package/impl/app-local.d.ts +2 -0
  12. package/impl/app-params.d.ts +3 -0
  13. package/impl/application.d.ts +30 -0
  14. package/impl/asset-holding.d.ts +2 -0
  15. package/impl/asset-params.d.ts +3 -0
  16. package/impl/asset.d.ts +24 -0
  17. package/impl/base.d.ts +18 -0
  18. package/impl/block.d.ts +2 -0
  19. package/impl/box.d.ts +2 -0
  20. package/impl/crypto.d.ts +12 -0
  21. package/impl/encoded-types.d.ts +165 -0
  22. package/impl/global.d.ts +18 -0
  23. package/impl/gtxn.d.ts +2 -0
  24. package/impl/index.d.ts +15 -0
  25. package/impl/inner-transactions.d.ts +51 -0
  26. package/impl/itxn.d.ts +8 -0
  27. package/impl/pure.d.ts +32 -0
  28. package/impl/scratch.d.ts +4 -0
  29. package/impl/state.d.ts +103 -0
  30. package/impl/transactions.d.ts +140 -0
  31. package/impl/txn.d.ts +3 -0
  32. package/index.d.ts +1 -0
  33. package/index.mjs +4563 -0
  34. package/index.mjs.map +1 -0
  35. package/package.json +45 -0
  36. package/runtime-helpers-DlIX78iw.js +1426 -0
  37. package/runtime-helpers-DlIX78iw.js.map +1 -0
  38. package/runtime-helpers.d.ts +11 -0
  39. package/runtime-helpers.mjs +8 -0
  40. package/runtime-helpers.mjs.map +1 -0
  41. package/set-up.d.ts +11 -0
  42. package/subcontexts/contract-context.d.ts +9 -0
  43. package/subcontexts/ledger-context.d.ts +45 -0
  44. package/subcontexts/transaction-context.d.ts +67 -0
  45. package/test-execution-context.d.ts +53 -0
  46. package/test-transformer/errors.d.ts +3 -0
  47. package/test-transformer/helpers.d.ts +3 -0
  48. package/test-transformer/index.d.ts +6 -0
  49. package/test-transformer/index.mjs +458 -0
  50. package/test-transformer/index.mjs.map +1 -0
  51. package/test-transformer/node-factory.d.ts +14 -0
  52. package/test-transformer/supported-binary-op-string.d.ts +4 -0
  53. package/test-transformer/visitors.d.ts +11 -0
  54. package/typescript-helpers.d.ts +15 -0
  55. package/util.d.ts +29 -0
  56. package/value-generators/avm.d.ts +23 -0
  57. package/value-generators/index.d.ts +6 -0
  58. package/value-generators/txn.d.ts +10 -0
@@ -0,0 +1,458 @@
1
+ import { TypeResolver, ptypes, SourceLocation, registerPTypes, typeRegistry } from '@algorandfoundation/puya-ts';
2
+ import ts from 'typescript';
3
+
4
+ function instanceOfAny(x, ...types) {
5
+ return types.some((t) => x instanceof t);
6
+ }
7
+
8
+ class TransformerError extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ }
12
+ }
13
+
14
+ const getPropertyNameAsString = (name) => {
15
+ if (ts.isStringLiteralLike(name)) {
16
+ return name;
17
+ }
18
+ if (ts.isIdentifier(name)) {
19
+ return ts.factory.createStringLiteral(name.text);
20
+ }
21
+ throw new TransformerError(`Node ${name.kind} cannot be converted to a static string`);
22
+ };
23
+ const trimGenericTypeName = (typeName) => typeName.replace(/<.*>/, '');
24
+
25
+ const factory$1 = ts.factory;
26
+ const nodeFactory = {
27
+ importHelpers(testingPackageName) {
28
+ return factory$1.createImportDeclaration(undefined, factory$1.createImportClause(false, undefined, factory$1.createNamespaceImport(factory$1.createIdentifier('runtimeHelpers'))), factory$1.createStringLiteral(`${testingPackageName}/runtime-helpers`), undefined);
29
+ },
30
+ switchableValue(x) {
31
+ return factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('switchableValue')), undefined, [x]);
32
+ },
33
+ binaryOp(left, right, op) {
34
+ return factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('binaryOp')), undefined, [left, right, factory$1.createStringLiteral(op)]);
35
+ },
36
+ augmentedAssignmentBinaryOp(left, right, op) {
37
+ return factory$1.createAssignment(left, factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('binaryOp')), undefined, [left, right, factory$1.createStringLiteral(op.replace('=', ''))]));
38
+ },
39
+ prefixUnaryOp(operand, op) {
40
+ return factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('unaryOp')), undefined, [operand, factory$1.createStringLiteral(op)]);
41
+ },
42
+ attachMetaData(classIdentifier, method, functionType) {
43
+ const methodName = getPropertyNameAsString(method.name);
44
+ const metadata = factory$1.createObjectLiteralExpression([
45
+ factory$1.createPropertyAssignment('methodName', methodName),
46
+ factory$1.createPropertyAssignment('methodSelector', methodName),
47
+ factory$1.createPropertyAssignment('argTypes', factory$1.createArrayLiteralExpression(functionType.parameters.map((p) => factory$1.createStringLiteral(p[1].fullName)))),
48
+ factory$1.createPropertyAssignment('returnType', factory$1.createStringLiteral(functionType.returnType.fullName)),
49
+ ]);
50
+ return factory$1.createExpressionStatement(factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('attachAbiMetadata')), undefined, [classIdentifier, methodName, metadata]));
51
+ },
52
+ captureGenericTypeInfo(x, info) {
53
+ return factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('captureGenericTypeInfo')), undefined, [x, factory$1.createStringLiteral(info)]);
54
+ },
55
+ instantiateARC4EncodedType(node, typeInfo) {
56
+ const infoString = JSON.stringify(typeInfo);
57
+ const classIdentifier = node.expression.getText().replace('arc4.', '');
58
+ return factory$1.createNewExpression(factory$1.createIdentifier(`runtimeHelpers.${trimGenericTypeName(typeInfo?.name ?? classIdentifier)}Impl`), node.typeArguments, [infoString ? factory$1.createStringLiteral(infoString) : undefined, ...(node.arguments ?? [])].filter((arg) => !!arg));
59
+ },
60
+ callARC4EncodingUtil(node, typeInfo) {
61
+ const identifierExpression = node.expression;
62
+ const infoString = JSON.stringify(typeInfo);
63
+ const updatedPropertyAccessExpression = factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), `${identifierExpression.getText()}Impl`);
64
+ return factory$1.createCallExpression(updatedPropertyAccessExpression, node.typeArguments, [infoString ? factory$1.createStringLiteral(infoString) : undefined, ...(node.arguments ?? [])].filter((arg) => !!arg));
65
+ },
66
+ };
67
+
68
+ function supportedBinaryOpString(x) {
69
+ switch (x) {
70
+ case ts.SyntaxKind.MinusToken:
71
+ return '-';
72
+ case ts.SyntaxKind.PlusToken:
73
+ return '+';
74
+ case ts.SyntaxKind.EqualsEqualsEqualsToken:
75
+ return '===';
76
+ case ts.SyntaxKind.ExclamationEqualsEqualsToken:
77
+ return '!==';
78
+ case ts.SyntaxKind.GreaterThanToken:
79
+ return '>';
80
+ case ts.SyntaxKind.GreaterThanEqualsToken:
81
+ return '>=';
82
+ case ts.SyntaxKind.GreaterThanGreaterThanToken:
83
+ return '>>';
84
+ case ts.SyntaxKind.LessThanToken:
85
+ return '<';
86
+ case ts.SyntaxKind.LessThanEqualsToken:
87
+ return '<=';
88
+ case ts.SyntaxKind.LessThanLessThanToken:
89
+ return '<<';
90
+ case ts.SyntaxKind.AsteriskToken:
91
+ return '*';
92
+ case ts.SyntaxKind.AsteriskAsteriskToken:
93
+ return '**';
94
+ case ts.SyntaxKind.SlashToken:
95
+ return '/';
96
+ case ts.SyntaxKind.PercentToken:
97
+ return '%';
98
+ case ts.SyntaxKind.AmpersandToken:
99
+ return '&';
100
+ case ts.SyntaxKind.BarToken:
101
+ return '|';
102
+ case ts.SyntaxKind.CaretToken:
103
+ return '^';
104
+ case ts.SyntaxKind.AmpersandAmpersandEqualsToken:
105
+ case ts.SyntaxKind.AmpersandAmpersandToken:
106
+ case ts.SyntaxKind.AmpersandEqualsToken:
107
+ case ts.SyntaxKind.BarBarEqualsToken:
108
+ case ts.SyntaxKind.BarBarToken:
109
+ case ts.SyntaxKind.BarEqualsToken:
110
+ case ts.SyntaxKind.CaretEqualsToken:
111
+ case ts.SyntaxKind.CommaToken:
112
+ case ts.SyntaxKind.EqualsEqualsToken:
113
+ case ts.SyntaxKind.EqualsToken:
114
+ case ts.SyntaxKind.ExclamationEqualsToken:
115
+ case ts.SyntaxKind.InKeyword:
116
+ case ts.SyntaxKind.InstanceOfKeyword:
117
+ case ts.SyntaxKind.QuestionQuestionEqualsToken:
118
+ case ts.SyntaxKind.QuestionQuestionToken:
119
+ case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken:
120
+ case ts.SyntaxKind.LessThanLessThanEqualsToken:
121
+ case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
122
+ case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
123
+ return undefined;
124
+ }
125
+ }
126
+ function supportedAugmentedAssignmentBinaryOpString(x) {
127
+ switch (x) {
128
+ case ts.SyntaxKind.PlusEqualsToken:
129
+ return '+=';
130
+ case ts.SyntaxKind.MinusEqualsToken:
131
+ return '-=';
132
+ case ts.SyntaxKind.SlashEqualsToken:
133
+ return '/=';
134
+ case ts.SyntaxKind.AsteriskEqualsToken:
135
+ return '*=';
136
+ case ts.SyntaxKind.AsteriskAsteriskEqualsToken:
137
+ return '**=';
138
+ case ts.SyntaxKind.PercentEqualsToken:
139
+ return '%=';
140
+ default:
141
+ return undefined;
142
+ }
143
+ }
144
+ function supportedPrefixUnaryOpString(x) {
145
+ switch (x) {
146
+ case ts.SyntaxKind.TildeToken:
147
+ return '~';
148
+ default:
149
+ return undefined;
150
+ }
151
+ }
152
+
153
+ const { factory } = ts;
154
+ class SourceFileVisitor {
155
+ context;
156
+ sourceFile;
157
+ config;
158
+ helper;
159
+ constructor(context, sourceFile, program, config) {
160
+ this.context = context;
161
+ this.sourceFile = sourceFile;
162
+ this.config = config;
163
+ const typeResolver = new TypeResolver(program.getTypeChecker(), program.getCurrentDirectory());
164
+ this.helper = {
165
+ additionalStatements: [],
166
+ resolveType(node) {
167
+ try {
168
+ return typeResolver.resolve(node, this.sourceLocation(node));
169
+ }
170
+ catch {
171
+ return ptypes.anyPType;
172
+ }
173
+ },
174
+ sourceLocation(node) {
175
+ return SourceLocation.fromNode(node, program.getCurrentDirectory());
176
+ },
177
+ };
178
+ }
179
+ result() {
180
+ const updatedSourceFile = ts.visitNode(this.sourceFile, this.visit);
181
+ return factory.updateSourceFile(updatedSourceFile, [
182
+ nodeFactory.importHelpers(this.config.testingPackageName),
183
+ ...updatedSourceFile.statements,
184
+ ...this.helper.additionalStatements,
185
+ ]);
186
+ }
187
+ visit = (node) => {
188
+ if (ts.isFunctionLike(node)) {
189
+ return new FunctionLikeDecVisitor(this.context, this.helper, node).result();
190
+ }
191
+ if (ts.isClassDeclaration(node)) {
192
+ return new ClassVisitor(this.context, this.helper, node).result();
193
+ }
194
+ // capture generic type info for variable initialising outside class and function declarations
195
+ // e.g. `const x = new UintN<32>(42)
196
+ if (ts.isVariableDeclaration(node) && node.initializer) {
197
+ return new VariableInitializerVisitor(this.context, this.helper, node).result();
198
+ }
199
+ return ts.visitEachChild(node, this.visit, this.context);
200
+ };
201
+ }
202
+ class ExpressionVisitor {
203
+ context;
204
+ helper;
205
+ expressionNode;
206
+ constructor(context, helper, expressionNode) {
207
+ this.context = context;
208
+ this.helper = helper;
209
+ this.expressionNode = expressionNode;
210
+ }
211
+ result() {
212
+ return this.visit(this.expressionNode);
213
+ }
214
+ visit = (node) => {
215
+ if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
216
+ let type = this.helper.resolveType(node);
217
+ // `voted = LocalState<uint64>()` is resolved to FunctionPType with returnType LocalState<uint64>
218
+ if (type instanceof ptypes.FunctionPType)
219
+ type = type.returnType;
220
+ const isGeneric = isGenericType(type);
221
+ const isArc4Encoded = isArc4EncodedType(type);
222
+ if (isGeneric || isArc4Encoded) {
223
+ let updatedNode = node;
224
+ const info = getGenericTypeInfo(type);
225
+ if (isArc4EncodedType(type)) {
226
+ if (ts.isNewExpression(updatedNode)) {
227
+ updatedNode = nodeFactory.instantiateARC4EncodedType(updatedNode, info);
228
+ }
229
+ else if (ts.isCallExpression(updatedNode) && isCallingARC4EncodingUtils(updatedNode)) {
230
+ updatedNode = nodeFactory.callARC4EncodingUtil(updatedNode, info);
231
+ }
232
+ }
233
+ return isGeneric
234
+ ? nodeFactory.captureGenericTypeInfo(ts.visitEachChild(updatedNode, this.visit, this.context), JSON.stringify(info))
235
+ : ts.visitEachChild(updatedNode, this.visit, this.context);
236
+ }
237
+ }
238
+ return ts.visitEachChild(node, this.visit, this.context);
239
+ };
240
+ }
241
+ class VariableInitializerVisitor {
242
+ context;
243
+ helper;
244
+ declarationNode;
245
+ constructor(context, helper, declarationNode) {
246
+ this.context = context;
247
+ this.helper = helper;
248
+ this.declarationNode = declarationNode;
249
+ }
250
+ result() {
251
+ const initializerNode = this.declarationNode.initializer;
252
+ if (!initializerNode)
253
+ return this.declarationNode;
254
+ const updatedInitializer = new ExpressionVisitor(this.context, this.helper, initializerNode).result();
255
+ if (updatedInitializer === initializerNode)
256
+ return this.declarationNode;
257
+ return factory.updateVariableDeclaration(this.declarationNode, this.declarationNode.name, this.declarationNode.exclamationToken, this.declarationNode.type, updatedInitializer);
258
+ }
259
+ }
260
+ class FunctionOrMethodVisitor {
261
+ context;
262
+ helper;
263
+ isFunction;
264
+ constructor(context, helper, isFunction) {
265
+ this.context = context;
266
+ this.helper = helper;
267
+ this.isFunction = isFunction;
268
+ }
269
+ visit = (node) => {
270
+ return ts.visitEachChild(this.updateNode(node), this.visit, this.context);
271
+ };
272
+ updateNode(node) {
273
+ if (ts.isSwitchStatement(node)) {
274
+ return factory.updateSwitchStatement(node, nodeFactory.switchableValue(node.expression), node.caseBlock);
275
+ }
276
+ if (ts.isCaseClause(node)) {
277
+ return factory.updateCaseClause(node, nodeFactory.switchableValue(node.expression), node.statements);
278
+ }
279
+ if (ts.isBinaryExpression(node)) {
280
+ const opTokenText = supportedBinaryOpString(node.operatorToken.kind);
281
+ if (opTokenText) {
282
+ return nodeFactory.binaryOp(node.left, node.right, opTokenText);
283
+ }
284
+ const augmentedAssignmentOpTokenText = supportedAugmentedAssignmentBinaryOpString(node.operatorToken.kind);
285
+ if (augmentedAssignmentOpTokenText) {
286
+ return nodeFactory.augmentedAssignmentBinaryOp(node.left, node.right, augmentedAssignmentOpTokenText);
287
+ }
288
+ }
289
+ if (ts.isPrefixUnaryExpression(node)) {
290
+ const tokenText = supportedPrefixUnaryOpString(node.operator);
291
+ if (tokenText) {
292
+ return nodeFactory.prefixUnaryOp(node.operand, tokenText);
293
+ }
294
+ }
295
+ /*
296
+ * capture generic type info in test functions; e.g.
297
+ * ```
298
+ * it('should work', () => {
299
+ * ctx.txn.createScope([ctx.any.txn.applicationCall()]).execute(() => {
300
+ * const box = Box<uint64>({key: Bytes('test-key')})
301
+ * })
302
+ * })
303
+ * ```
304
+ */
305
+ if (ts.isVariableDeclaration(node) && node.initializer) {
306
+ return new VariableInitializerVisitor(this.context, this.helper, node).result();
307
+ }
308
+ /*
309
+ * capture generic type info in test functions and swap arc4 types with implementation; e.g.
310
+ * ```
311
+ * it('should work', () => {
312
+ * expect(() => new UintN<32>(2 ** 32)).toThrowError(`expected value <= ${2 ** 32 - 1}`)
313
+ * expect(UintN.fromBytes<UintN<32>>('').bytes).toEqual(Bytes())
314
+ * })
315
+ * ```
316
+ */
317
+ if (ts.isNewExpression(node)) {
318
+ return new ExpressionVisitor(this.context, this.helper, node).result();
319
+ }
320
+ if (ts.isCallExpression(node) && isCallingARC4EncodingUtils(node)) {
321
+ return new ExpressionVisitor(this.context, this.helper, node).result();
322
+ }
323
+ return node;
324
+ }
325
+ }
326
+ class FunctionLikeDecVisitor extends FunctionOrMethodVisitor {
327
+ funcNode;
328
+ constructor(context, helper, funcNode) {
329
+ super(context, helper, true);
330
+ this.funcNode = funcNode;
331
+ }
332
+ result() {
333
+ return ts.visitNode(this.funcNode, this.visit);
334
+ }
335
+ }
336
+ class MethodDecVisitor extends FunctionOrMethodVisitor {
337
+ methodNode;
338
+ constructor(context, helper, methodNode) {
339
+ super(context, helper);
340
+ this.methodNode = methodNode;
341
+ }
342
+ result() {
343
+ return ts.visitNode(this.methodNode, this.visit);
344
+ }
345
+ }
346
+ class ClassVisitor {
347
+ context;
348
+ helper;
349
+ classDec;
350
+ isArc4;
351
+ constructor(context, helper, classDec) {
352
+ this.context = context;
353
+ this.helper = helper;
354
+ this.classDec = classDec;
355
+ const classType = helper.resolveType(classDec);
356
+ this.isArc4 = classType instanceof ptypes.ContractClassPType && classType.isARC4;
357
+ }
358
+ result() {
359
+ return this.visit(this.classDec);
360
+ }
361
+ visit = (node) => {
362
+ if (ts.isMethodDeclaration(node)) {
363
+ if (this.classDec.name && this.isArc4) {
364
+ const methodType = this.helper.resolveType(node);
365
+ if (methodType instanceof ptypes.FunctionPType) {
366
+ this.helper.additionalStatements.push(nodeFactory.attachMetaData(this.classDec.name, node, methodType));
367
+ }
368
+ }
369
+ return new MethodDecVisitor(this.context, this.helper, node).result();
370
+ }
371
+ if (ts.isCallExpression(node)) {
372
+ return new ExpressionVisitor(this.context, this.helper, node).result();
373
+ }
374
+ return ts.visitEachChild(node, this.visit, this.context);
375
+ };
376
+ }
377
+ const isGenericType = (type) => instanceOfAny(type, ptypes.ARC4StructType, ptypes.ARC4TupleType, ptypes.BoxMapPType, ptypes.BoxPType, ptypes.DynamicArrayType, ptypes.GlobalStateType, ptypes.LocalStateType, ptypes.StaticArrayType, ptypes.UFixedNxMType, ptypes.UintNType);
378
+ const isArc4EncodedType = (type) => instanceOfAny(type, ptypes.ARC4StructType, ptypes.ARC4TupleType, ptypes.DynamicArrayType, ptypes.StaticArrayType, ptypes.UFixedNxMType, ptypes.UintNType) ||
379
+ type === ptypes.ARC4StringType ||
380
+ type === ptypes.ARC4BooleanType;
381
+ const getGenericTypeInfo = (type) => {
382
+ let typeName = type?.name ?? type?.toString() ?? 'unknown';
383
+ let genericArgs = [];
384
+ if (instanceOfAny(type, ptypes.LocalStateType, ptypes.GlobalStateType, ptypes.BoxPType)) {
385
+ genericArgs.push(getGenericTypeInfo(type.contentType));
386
+ }
387
+ else if (type instanceof ptypes.BoxMapPType) {
388
+ genericArgs.push(getGenericTypeInfo(type.keyType));
389
+ genericArgs.push(getGenericTypeInfo(type.contentType));
390
+ }
391
+ else if (instanceOfAny(type, ptypes.StaticArrayType, ptypes.DynamicArrayType)) {
392
+ const entries = [];
393
+ entries.push(['elementType', getGenericTypeInfo(type.elementType)]);
394
+ if (instanceOfAny(type, ptypes.StaticArrayType)) {
395
+ entries.push(['size', { name: type.arraySize.toString() }]);
396
+ }
397
+ genericArgs = Object.fromEntries(entries);
398
+ }
399
+ else if (type instanceof ptypes.UFixedNxMType) {
400
+ genericArgs = { n: { name: type.n.toString() }, m: { name: type.m.toString() } };
401
+ }
402
+ else if (type instanceof ptypes.UintNType) {
403
+ genericArgs.push({ name: type.n.toString() });
404
+ }
405
+ else if (type instanceof ptypes.ARC4StructType) {
406
+ typeName = 'Struct';
407
+ genericArgs = Object.fromEntries(Object.entries(type.fields)
408
+ .map(([key, value]) => [key, getGenericTypeInfo(value)])
409
+ .filter((x) => !!x));
410
+ }
411
+ else if (type instanceof ptypes.ARC4TupleType) {
412
+ genericArgs.push(...type.items.map(getGenericTypeInfo));
413
+ }
414
+ const result = { name: typeName };
415
+ if (genericArgs && (genericArgs.length || Object.keys(genericArgs).length)) {
416
+ result.genericArgs = genericArgs;
417
+ }
418
+ return result;
419
+ };
420
+ const isCallingARC4EncodingUtils = (node) => {
421
+ if (node.expression.kind !== ts.SyntaxKind.Identifier)
422
+ return false;
423
+ const identityExpression = node.expression;
424
+ const utilMethods = ['interpretAsArc4', 'decodeArc4', 'encodeArc4'];
425
+ return utilMethods.includes(identityExpression.text);
426
+ };
427
+
428
+ const defaultTransformerConfig = {
429
+ includeExt: ['.algo.ts', '.spec.ts'],
430
+ testingPackageName: '@algorandfoundation/algorand-typescript-testing',
431
+ };
432
+ const createProgramFactory = (config) => {
433
+ function programFactory(program) {
434
+ registerPTypes(typeRegistry);
435
+ return (context) => {
436
+ return (sourceFile) => {
437
+ if (!config.includeExt.some((i) => sourceFile.fileName.endsWith(i)))
438
+ return sourceFile;
439
+ return new SourceFileVisitor(context, sourceFile, program, config).result();
440
+ };
441
+ };
442
+ }
443
+ return programFactory;
444
+ };
445
+ function programTransformer(config) {
446
+ return {
447
+ type: 'program',
448
+ factory: createProgramFactory({ ...defaultTransformerConfig, ...config }),
449
+ };
450
+ }
451
+ programTransformer.type = 'program';
452
+ programTransformer.factory = createProgramFactory(defaultTransformerConfig);
453
+ // Typescript.d.ts typings require a TransformerFactory however rollup plugin supports a program transformer
454
+ // https://github.com/rollup/plugins/blob/master/packages/typescript/src/customTransformers.ts
455
+ const puyaTsTransformer = programTransformer;
456
+
457
+ export { puyaTsTransformer };
458
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../src/typescript-helpers.ts","../../src/test-transformer/errors.ts","../../src/test-transformer/helpers.ts","../../src/test-transformer/node-factory.ts","../../src/test-transformer/supported-binary-op-string.ts","../../src/test-transformer/visitors.ts","../../src/test-transformer/index.ts"],"sourcesContent":["// Sometimes only an 'any' will do. Don't use this just to be lazy though\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport type DeliberateAny = any\nexport type AnyFunction = (...args: DeliberateAny[]) => DeliberateAny\nexport type Mutable<T> = {\n -readonly [P in keyof T]: T[P]\n}\n\nexport type KeyIsFunction<TKey extends keyof TObj, TObj> = TKey extends DeliberateAny\n ? TObj[TKey] extends AnyFunction\n ? TKey\n : never\n : never\nexport type KeyIsNotFunction<TKey extends keyof TObj, TObj> = TKey extends DeliberateAny\n ? TObj[TKey] extends AnyFunction\n ? never\n : TKey\n : never\nexport type ObjectKeys<T> = KeyIsNotFunction<keyof T, T>\nexport type FunctionKeys<T> = KeyIsFunction<keyof T, T>\n\nexport function instanceOfAny<T extends Array<{ new (...args: DeliberateAny[]): DeliberateAny }>>(\n x: unknown,\n ...types: T\n): x is InstanceType<T[number]> {\n return types.some((t) => x instanceof t)\n}\n\nexport interface IConstructor<T> {\n new (...args: DeliberateAny[]): T\n}\n","export class TransformerError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","import ts from 'typescript'\nimport { TransformerError } from './errors'\n\nexport const getPropertyNameAsString = (name: ts.PropertyName): ts.Identifier | ts.StringLiteral | ts.NoSubstitutionTemplateLiteral => {\n if (ts.isStringLiteralLike(name)) {\n return name\n }\n if (ts.isIdentifier(name)) {\n return ts.factory.createStringLiteral(name.text)\n }\n throw new TransformerError(`Node ${name.kind} cannot be converted to a static string`)\n}\n\nexport const trimGenericTypeName = (typeName: string) => typeName.replace(/<.*>/, '')\n","import { ptypes } from '@algorandfoundation/puya-ts'\nimport ts from 'typescript'\nimport { TypeInfo } from '../encoders'\nimport type { DeliberateAny } from '../typescript-helpers'\nimport { getPropertyNameAsString, trimGenericTypeName } from './helpers'\n\nconst factory = ts.factory\nexport const nodeFactory = {\n importHelpers(testingPackageName: string) {\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(false, undefined, factory.createNamespaceImport(factory.createIdentifier('runtimeHelpers'))),\n factory.createStringLiteral(`${testingPackageName}/runtime-helpers`),\n undefined,\n )\n },\n\n switchableValue(x: ts.Expression) {\n return factory.createCallExpression(\n factory.createPropertyAccessExpression(factory.createIdentifier('runtimeHelpers'), factory.createIdentifier('switchableValue')),\n undefined,\n [x],\n )\n },\n binaryOp(left: ts.Expression, right: ts.Expression, op: string) {\n return factory.createCallExpression(\n factory.createPropertyAccessExpression(factory.createIdentifier('runtimeHelpers'), factory.createIdentifier('binaryOp')),\n undefined,\n [left, right, factory.createStringLiteral(op)],\n )\n },\n augmentedAssignmentBinaryOp(left: ts.Expression, right: ts.Expression, op: string) {\n return factory.createAssignment(\n left,\n factory.createCallExpression(\n factory.createPropertyAccessExpression(factory.createIdentifier('runtimeHelpers'), factory.createIdentifier('binaryOp')),\n undefined,\n [left, right, factory.createStringLiteral(op.replace('=', ''))],\n ),\n )\n },\n\n prefixUnaryOp(operand: ts.Expression, op: string) {\n return factory.createCallExpression(\n factory.createPropertyAccessExpression(factory.createIdentifier('runtimeHelpers'), factory.createIdentifier('unaryOp')),\n undefined,\n [operand, factory.createStringLiteral(op)],\n )\n },\n\n attachMetaData(classIdentifier: ts.Identifier, method: ts.MethodDeclaration, functionType: ptypes.FunctionPType) {\n const methodName = getPropertyNameAsString(method.name)\n const metadata = factory.createObjectLiteralExpression([\n factory.createPropertyAssignment('methodName', methodName),\n factory.createPropertyAssignment('methodSelector', methodName),\n factory.createPropertyAssignment(\n 'argTypes',\n factory.createArrayLiteralExpression(functionType.parameters.map((p) => factory.createStringLiteral(p[1].fullName))),\n ),\n factory.createPropertyAssignment('returnType', factory.createStringLiteral(functionType.returnType.fullName)),\n ])\n return factory.createExpressionStatement(\n factory.createCallExpression(\n factory.createPropertyAccessExpression(factory.createIdentifier('runtimeHelpers'), factory.createIdentifier('attachAbiMetadata')),\n undefined,\n [classIdentifier, methodName, metadata],\n ),\n )\n },\n\n captureGenericTypeInfo(x: ts.Expression, info: string) {\n return factory.createCallExpression(\n factory.createPropertyAccessExpression(\n factory.createIdentifier('runtimeHelpers'),\n factory.createIdentifier('captureGenericTypeInfo'),\n ),\n undefined,\n [x, factory.createStringLiteral(info)],\n )\n },\n\n instantiateARC4EncodedType(node: ts.NewExpression, typeInfo?: TypeInfo) {\n const infoString = JSON.stringify(typeInfo)\n const classIdentifier = node.expression.getText().replace('arc4.', '')\n return factory.createNewExpression(\n factory.createIdentifier(`runtimeHelpers.${trimGenericTypeName(typeInfo?.name ?? classIdentifier)}Impl`),\n node.typeArguments,\n [infoString ? factory.createStringLiteral(infoString) : undefined, ...(node.arguments ?? [])].filter((arg) => !!arg),\n )\n },\n\n callARC4EncodingUtil(node: ts.CallExpression, typeInfo?: TypeInfo) {\n const identifierExpression = node.expression as ts.Identifier\n const infoString = JSON.stringify(typeInfo)\n const updatedPropertyAccessExpression = factory.createPropertyAccessExpression(\n factory.createIdentifier('runtimeHelpers'),\n `${identifierExpression.getText()}Impl`,\n )\n\n return factory.createCallExpression(\n updatedPropertyAccessExpression,\n node.typeArguments,\n [infoString ? factory.createStringLiteral(infoString) : undefined, ...(node.arguments ?? [])].filter((arg) => !!arg),\n )\n },\n} satisfies Record<string, (...args: DeliberateAny[]) => ts.Node>\n","import type { BinaryOperator, PrefixUnaryOperator } from 'typescript'\nimport ts from 'typescript'\n\nexport function supportedBinaryOpString(x: BinaryOperator): string | undefined {\n switch (x) {\n case ts.SyntaxKind.MinusToken:\n return '-'\n case ts.SyntaxKind.PlusToken:\n return '+'\n case ts.SyntaxKind.EqualsEqualsEqualsToken:\n return '==='\n case ts.SyntaxKind.ExclamationEqualsEqualsToken:\n return '!=='\n case ts.SyntaxKind.GreaterThanToken:\n return '>'\n case ts.SyntaxKind.GreaterThanEqualsToken:\n return '>='\n case ts.SyntaxKind.GreaterThanGreaterThanToken:\n return '>>'\n case ts.SyntaxKind.LessThanToken:\n return '<'\n case ts.SyntaxKind.LessThanEqualsToken:\n return '<='\n case ts.SyntaxKind.LessThanLessThanToken:\n return '<<'\n case ts.SyntaxKind.AsteriskToken:\n return '*'\n case ts.SyntaxKind.AsteriskAsteriskToken:\n return '**'\n case ts.SyntaxKind.SlashToken:\n return '/'\n case ts.SyntaxKind.PercentToken:\n return '%'\n case ts.SyntaxKind.AmpersandToken:\n return '&'\n case ts.SyntaxKind.BarToken:\n return '|'\n case ts.SyntaxKind.CaretToken:\n return '^'\n case ts.SyntaxKind.AmpersandAmpersandEqualsToken:\n case ts.SyntaxKind.AmpersandAmpersandToken:\n case ts.SyntaxKind.AmpersandEqualsToken:\n case ts.SyntaxKind.BarBarEqualsToken:\n case ts.SyntaxKind.BarBarToken:\n case ts.SyntaxKind.BarEqualsToken:\n case ts.SyntaxKind.CaretEqualsToken:\n case ts.SyntaxKind.CommaToken:\n case ts.SyntaxKind.EqualsEqualsToken:\n case ts.SyntaxKind.EqualsToken:\n case ts.SyntaxKind.ExclamationEqualsToken:\n case ts.SyntaxKind.InKeyword:\n case ts.SyntaxKind.InstanceOfKeyword:\n case ts.SyntaxKind.QuestionQuestionEqualsToken:\n case ts.SyntaxKind.QuestionQuestionToken:\n case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken:\n case ts.SyntaxKind.LessThanLessThanEqualsToken:\n case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:\n case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:\n return undefined\n }\n}\n\nexport function supportedAugmentedAssignmentBinaryOpString(x: BinaryOperator): string | undefined {\n switch (x) {\n case ts.SyntaxKind.PlusEqualsToken:\n return '+='\n case ts.SyntaxKind.MinusEqualsToken:\n return '-='\n case ts.SyntaxKind.SlashEqualsToken:\n return '/='\n case ts.SyntaxKind.AsteriskEqualsToken:\n return '*='\n case ts.SyntaxKind.AsteriskAsteriskEqualsToken:\n return '**='\n case ts.SyntaxKind.PercentEqualsToken:\n return '%='\n default:\n return undefined\n }\n}\n\nexport function supportedPrefixUnaryOpString(x: PrefixUnaryOperator): string | undefined {\n switch (x) {\n case ts.SyntaxKind.TildeToken:\n return '~'\n default:\n return undefined\n }\n}\n","import { ptypes, SourceLocation, TypeResolver } from '@algorandfoundation/puya-ts'\nimport ts from 'typescript'\nimport type { TypeInfo } from '../encoders'\nimport { instanceOfAny } from '../typescript-helpers'\nimport { TransformerConfig } from './index'\nimport { nodeFactory } from './node-factory'\nimport {\n supportedAugmentedAssignmentBinaryOpString,\n supportedBinaryOpString,\n supportedPrefixUnaryOpString,\n} from './supported-binary-op-string'\n\nconst { factory } = ts\n\ntype VisitorHelper = {\n additionalStatements: ts.Statement[]\n resolveType(node: ts.Node): ptypes.PType\n sourceLocation(node: ts.Node): SourceLocation\n}\n\nexport class SourceFileVisitor {\n private helper: VisitorHelper\n constructor(\n private context: ts.TransformationContext,\n private sourceFile: ts.SourceFile,\n program: ts.Program,\n private config: TransformerConfig,\n ) {\n const typeResolver = new TypeResolver(program.getTypeChecker(), program.getCurrentDirectory())\n\n this.helper = {\n additionalStatements: [],\n resolveType(node: ts.Node): ptypes.PType {\n try {\n return typeResolver.resolve(node, this.sourceLocation(node))\n } catch {\n return ptypes.anyPType\n }\n },\n sourceLocation(node: ts.Node): SourceLocation {\n return SourceLocation.fromNode(node, program.getCurrentDirectory())\n },\n }\n }\n\n public result(): ts.SourceFile {\n const updatedSourceFile = ts.visitNode(this.sourceFile, this.visit) as ts.SourceFile\n\n return factory.updateSourceFile(updatedSourceFile, [\n nodeFactory.importHelpers(this.config.testingPackageName),\n ...updatedSourceFile.statements,\n ...this.helper.additionalStatements,\n ])\n }\n\n private visit = (node: ts.Node): ts.Node => {\n if (ts.isFunctionLike(node)) {\n return new FunctionLikeDecVisitor(this.context, this.helper, node).result()\n }\n if (ts.isClassDeclaration(node)) {\n return new ClassVisitor(this.context, this.helper, node).result()\n }\n\n // capture generic type info for variable initialising outside class and function declarations\n // e.g. `const x = new UintN<32>(42)\n if (ts.isVariableDeclaration(node) && node.initializer) {\n return new VariableInitializerVisitor(this.context, this.helper, node).result()\n }\n\n return ts.visitEachChild(node, this.visit, this.context)\n }\n}\n\nclass ExpressionVisitor {\n constructor(\n private context: ts.TransformationContext,\n private helper: VisitorHelper,\n private expressionNode: ts.Expression,\n ) {}\n\n public result(): ts.Expression {\n return this.visit(this.expressionNode) as ts.Expression\n }\n\n private visit = (node: ts.Node): ts.Node => {\n if (ts.isCallExpression(node) || ts.isNewExpression(node)) {\n let type = this.helper.resolveType(node)\n\n // `voted = LocalState<uint64>()` is resolved to FunctionPType with returnType LocalState<uint64>\n if (type instanceof ptypes.FunctionPType) type = type.returnType\n\n const isGeneric = isGenericType(type)\n const isArc4Encoded = isArc4EncodedType(type)\n if (isGeneric || isArc4Encoded) {\n let updatedNode = node\n const info = getGenericTypeInfo(type)\n if (isArc4EncodedType(type)) {\n if (ts.isNewExpression(updatedNode)) {\n updatedNode = nodeFactory.instantiateARC4EncodedType(updatedNode, info)\n } else if (ts.isCallExpression(updatedNode) && isCallingARC4EncodingUtils(updatedNode)) {\n updatedNode = nodeFactory.callARC4EncodingUtil(updatedNode, info)\n }\n }\n return isGeneric\n ? nodeFactory.captureGenericTypeInfo(ts.visitEachChild(updatedNode, this.visit, this.context), JSON.stringify(info))\n : ts.visitEachChild(updatedNode, this.visit, this.context)\n }\n }\n return ts.visitEachChild(node, this.visit, this.context)\n }\n}\nclass VariableInitializerVisitor {\n constructor(\n private context: ts.TransformationContext,\n private helper: VisitorHelper,\n private declarationNode: ts.VariableDeclaration,\n ) {}\n\n public result(): ts.VariableDeclaration {\n const initializerNode = this.declarationNode.initializer\n if (!initializerNode) return this.declarationNode\n\n const updatedInitializer = new ExpressionVisitor(this.context, this.helper, initializerNode).result()\n if (updatedInitializer === initializerNode) return this.declarationNode\n return factory.updateVariableDeclaration(\n this.declarationNode,\n this.declarationNode.name,\n this.declarationNode.exclamationToken,\n this.declarationNode.type,\n updatedInitializer,\n )\n }\n}\n\nclass FunctionOrMethodVisitor {\n constructor(\n protected context: ts.TransformationContext,\n protected helper: VisitorHelper,\n private isFunction?: boolean,\n ) {}\n protected visit = (node: ts.Node): ts.Node => {\n return ts.visitEachChild(this.updateNode(node), this.visit, this.context)\n }\n\n protected updateNode(node: ts.Node): ts.Node {\n if (ts.isSwitchStatement(node)) {\n return factory.updateSwitchStatement(node, nodeFactory.switchableValue(node.expression), node.caseBlock)\n }\n\n if (ts.isCaseClause(node)) {\n return factory.updateCaseClause(node, nodeFactory.switchableValue(node.expression), node.statements)\n }\n\n if (ts.isBinaryExpression(node)) {\n const opTokenText = supportedBinaryOpString(node.operatorToken.kind)\n if (opTokenText) {\n return nodeFactory.binaryOp(node.left, node.right, opTokenText)\n }\n const augmentedAssignmentOpTokenText = supportedAugmentedAssignmentBinaryOpString(node.operatorToken.kind)\n if (augmentedAssignmentOpTokenText) {\n return nodeFactory.augmentedAssignmentBinaryOp(node.left, node.right, augmentedAssignmentOpTokenText)\n }\n }\n if (ts.isPrefixUnaryExpression(node)) {\n const tokenText = supportedPrefixUnaryOpString(node.operator)\n if (tokenText) {\n return nodeFactory.prefixUnaryOp(node.operand, tokenText)\n }\n }\n\n /*\n * capture generic type info in test functions; e.g.\n * ```\n * it('should work', () => {\n * ctx.txn.createScope([ctx.any.txn.applicationCall()]).execute(() => {\n * const box = Box<uint64>({key: Bytes('test-key')})\n * })\n * })\n * ```\n */\n if (ts.isVariableDeclaration(node) && node.initializer) {\n return new VariableInitializerVisitor(this.context, this.helper, node).result()\n }\n\n /*\n * capture generic type info in test functions and swap arc4 types with implementation; e.g.\n * ```\n * it('should work', () => {\n * expect(() => new UintN<32>(2 ** 32)).toThrowError(`expected value <= ${2 ** 32 - 1}`)\n * expect(UintN.fromBytes<UintN<32>>('').bytes).toEqual(Bytes())\n * })\n * ```\n */\n if (ts.isNewExpression(node)) {\n return new ExpressionVisitor(this.context, this.helper, node).result()\n }\n if (ts.isCallExpression(node) && isCallingARC4EncodingUtils(node)) {\n return new ExpressionVisitor(this.context, this.helper, node).result()\n }\n\n return node\n }\n}\n\nclass FunctionLikeDecVisitor extends FunctionOrMethodVisitor {\n constructor(\n context: ts.TransformationContext,\n helper: VisitorHelper,\n private funcNode: ts.SignatureDeclaration,\n ) {\n super(context, helper, true)\n }\n\n public result(): ts.SignatureDeclaration {\n return ts.visitNode(this.funcNode, this.visit) as ts.SignatureDeclaration\n }\n}\nclass MethodDecVisitor extends FunctionOrMethodVisitor {\n constructor(\n context: ts.TransformationContext,\n helper: VisitorHelper,\n private methodNode: ts.MethodDeclaration,\n ) {\n super(context, helper)\n }\n\n public result(): ts.MethodDeclaration {\n return ts.visitNode(this.methodNode, this.visit) as ts.MethodDeclaration\n }\n}\n\nclass ClassVisitor {\n private isArc4: boolean\n constructor(\n private context: ts.TransformationContext,\n private helper: VisitorHelper,\n private classDec: ts.ClassDeclaration,\n ) {\n const classType = helper.resolveType(classDec)\n this.isArc4 = classType instanceof ptypes.ContractClassPType && classType.isARC4\n }\n\n public result(): ts.ClassDeclaration {\n return this.visit(this.classDec) as ts.ClassDeclaration\n }\n\n private visit = (node: ts.Node): ts.Node => {\n if (ts.isMethodDeclaration(node)) {\n if (this.classDec.name && this.isArc4) {\n const methodType = this.helper.resolveType(node)\n if (methodType instanceof ptypes.FunctionPType) {\n this.helper.additionalStatements.push(nodeFactory.attachMetaData(this.classDec.name, node, methodType))\n }\n }\n\n return new MethodDecVisitor(this.context, this.helper, node).result()\n }\n\n if (ts.isCallExpression(node)) {\n return new ExpressionVisitor(this.context, this.helper, node).result()\n }\n return ts.visitEachChild(node, this.visit, this.context)\n }\n}\n\nconst isGenericType = (type: ptypes.PType): boolean =>\n instanceOfAny(\n type,\n ptypes.ARC4StructType,\n ptypes.ARC4TupleType,\n ptypes.BoxMapPType,\n ptypes.BoxPType,\n ptypes.DynamicArrayType,\n ptypes.GlobalStateType,\n ptypes.LocalStateType,\n ptypes.StaticArrayType,\n ptypes.UFixedNxMType,\n ptypes.UintNType,\n )\n\nconst isArc4EncodedType = (type: ptypes.PType): boolean =>\n instanceOfAny(\n type,\n ptypes.ARC4StructType,\n ptypes.ARC4TupleType,\n ptypes.DynamicArrayType,\n ptypes.StaticArrayType,\n ptypes.UFixedNxMType,\n ptypes.UintNType,\n ) ||\n type === ptypes.ARC4StringType ||\n type === ptypes.ARC4BooleanType\n\nconst getGenericTypeInfo = (type: ptypes.PType): TypeInfo => {\n let typeName = type?.name ?? type?.toString() ?? 'unknown'\n let genericArgs: TypeInfo[] | Record<string, TypeInfo> = []\n\n if (instanceOfAny(type, ptypes.LocalStateType, ptypes.GlobalStateType, ptypes.BoxPType)) {\n genericArgs.push(getGenericTypeInfo(type.contentType))\n } else if (type instanceof ptypes.BoxMapPType) {\n genericArgs.push(getGenericTypeInfo(type.keyType))\n genericArgs.push(getGenericTypeInfo(type.contentType))\n } else if (instanceOfAny(type, ptypes.StaticArrayType, ptypes.DynamicArrayType)) {\n const entries = []\n entries.push(['elementType', getGenericTypeInfo(type.elementType)])\n if (instanceOfAny(type, ptypes.StaticArrayType)) {\n entries.push(['size', { name: type.arraySize.toString() }])\n }\n genericArgs = Object.fromEntries(entries)\n } else if (type instanceof ptypes.UFixedNxMType) {\n genericArgs = { n: { name: type.n.toString() }, m: { name: type.m.toString() } }\n } else if (type instanceof ptypes.UintNType) {\n genericArgs.push({ name: type.n.toString() })\n } else if (type instanceof ptypes.ARC4StructType) {\n typeName = 'Struct'\n genericArgs = Object.fromEntries(\n Object.entries(type.fields)\n .map(([key, value]) => [key, getGenericTypeInfo(value)])\n .filter((x) => !!x),\n )\n } else if (type instanceof ptypes.ARC4TupleType) {\n genericArgs.push(...type.items.map(getGenericTypeInfo))\n }\n\n const result: TypeInfo = { name: typeName }\n if (genericArgs && (genericArgs.length || Object.keys(genericArgs).length)) {\n result.genericArgs = genericArgs\n }\n return result\n}\n\nconst isCallingARC4EncodingUtils = (node: ts.CallExpression) => {\n if (node.expression.kind !== ts.SyntaxKind.Identifier) return false\n const identityExpression = node.expression as ts.Identifier\n const utilMethods = ['interpretAsArc4', 'decodeArc4', 'encodeArc4']\n return utilMethods.includes(identityExpression.text)\n}\n","import { registerPTypes, typeRegistry } from '@algorandfoundation/puya-ts'\nimport type ts from 'typescript'\nimport type { DeliberateAny } from '../typescript-helpers'\nimport { SourceFileVisitor } from './visitors'\n\nexport interface TransformerConfig {\n includeExt: string[]\n testingPackageName: string\n}\nconst defaultTransformerConfig: TransformerConfig = {\n includeExt: ['.algo.ts', '.spec.ts'],\n testingPackageName: '@algorandfoundation/algorand-typescript-testing',\n}\n\nconst createProgramFactory = (config: TransformerConfig) => {\n function programFactory(program: ts.Program): ts.TransformerFactory<ts.SourceFile> {\n registerPTypes(typeRegistry)\n return (context) => {\n return (sourceFile) => {\n if (!config.includeExt.some((i) => sourceFile.fileName.endsWith(i))) return sourceFile\n return new SourceFileVisitor(context, sourceFile, program, config).result()\n }\n }\n }\n return programFactory\n}\n\nfunction programTransformer(config: Partial<TransformerConfig>) {\n return {\n type: 'program',\n factory: createProgramFactory({ ...defaultTransformerConfig, ...config }),\n }\n}\nprogramTransformer.type = 'program'\nprogramTransformer.factory = createProgramFactory(defaultTransformerConfig)\n\n// Typescript.d.ts typings require a TransformerFactory however rollup plugin supports a program transformer\n// https://github.com/rollup/plugins/blob/master/packages/typescript/src/customTransformers.ts\nexport const puyaTsTransformer: ts.TransformerFactory<ts.SourceFile> &\n ((config: Partial<TransformerConfig>) => ts.TransformerFactory<ts.SourceFile>) = programTransformer as DeliberateAny\n"],"names":["factory"],"mappings":";;;SAqBgB,aAAa,CAC3B,CAAU,EACV,GAAG,KAAQ,EAAA;AAEX,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAC1C;;AC1BM,MAAO,gBAAiB,SAAQ,KAAK,CAAA;AACzC,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC;;AAEjB;;ACDM,MAAM,uBAAuB,GAAG,CAAC,IAAqB,KAAyE;AACpI,IAAA,IAAI,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE;AAChC,QAAA,OAAO,IAAI;;AAEb,IAAA,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;QACzB,OAAO,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;;IAElD,MAAM,IAAI,gBAAgB,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAC,IAAI,CAAyC,uCAAA,CAAA,CAAC;AAC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AAEH,IAAA,OAAO,cAAc;AACvB,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAkC,EAAA;IAC5D,OAAO;AACL,QAAA,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,oBAAoB,CAAC,EAAE,GAAG,wBAAwB,EAAE,GAAG,MAAM,EAAE,CAAC;KAC1E;AACH;AACA,kBAAkB,CAAC,IAAI,GAAG,SAAS;AACnC,kBAAkB,CAAC,OAAO,GAAG,oBAAoB,CAAC,wBAAwB,CAAC;AAE3E;AACA;AACO,MAAM,iBAAiB,GACqD;;;;"}
@@ -0,0 +1,14 @@
1
+ import { ptypes } from '@algorandfoundation/puya-ts';
2
+ import ts from 'typescript';
3
+ import { TypeInfo } from '../encoders';
4
+ export declare const nodeFactory: {
5
+ importHelpers(testingPackageName: string): ts.ImportDeclaration;
6
+ switchableValue(x: ts.Expression): ts.CallExpression;
7
+ binaryOp(left: ts.Expression, right: ts.Expression, op: string): ts.CallExpression;
8
+ augmentedAssignmentBinaryOp(left: ts.Expression, right: ts.Expression, op: string): ts.AssignmentExpression<ts.EqualsToken>;
9
+ prefixUnaryOp(operand: ts.Expression, op: string): ts.CallExpression;
10
+ attachMetaData(classIdentifier: ts.Identifier, method: ts.MethodDeclaration, functionType: ptypes.FunctionPType): ts.ExpressionStatement;
11
+ captureGenericTypeInfo(x: ts.Expression, info: string): ts.CallExpression;
12
+ instantiateARC4EncodedType(node: ts.NewExpression, typeInfo?: TypeInfo): ts.NewExpression;
13
+ callARC4EncodingUtil(node: ts.CallExpression, typeInfo?: TypeInfo): ts.CallExpression;
14
+ };
@@ -0,0 +1,4 @@
1
+ import type { BinaryOperator, PrefixUnaryOperator } from 'typescript';
2
+ export declare function supportedBinaryOpString(x: BinaryOperator): string | undefined;
3
+ export declare function supportedAugmentedAssignmentBinaryOpString(x: BinaryOperator): string | undefined;
4
+ export declare function supportedPrefixUnaryOpString(x: PrefixUnaryOperator): string | undefined;
@@ -0,0 +1,11 @@
1
+ import ts from 'typescript';
2
+ import { TransformerConfig } from './index';
3
+ export declare class SourceFileVisitor {
4
+ private context;
5
+ private sourceFile;
6
+ private config;
7
+ private helper;
8
+ constructor(context: ts.TransformationContext, sourceFile: ts.SourceFile, program: ts.Program, config: TransformerConfig);
9
+ result(): ts.SourceFile;
10
+ private visit;
11
+ }
@@ -0,0 +1,15 @@
1
+ export type DeliberateAny = any;
2
+ export type AnyFunction = (...args: DeliberateAny[]) => DeliberateAny;
3
+ export type Mutable<T> = {
4
+ -readonly [P in keyof T]: T[P];
5
+ };
6
+ export type KeyIsFunction<TKey extends keyof TObj, TObj> = TKey extends DeliberateAny ? TObj[TKey] extends AnyFunction ? TKey : never : never;
7
+ export type KeyIsNotFunction<TKey extends keyof TObj, TObj> = TKey extends DeliberateAny ? TObj[TKey] extends AnyFunction ? never : TKey : never;
8
+ export type ObjectKeys<T> = KeyIsNotFunction<keyof T, T>;
9
+ export type FunctionKeys<T> = KeyIsFunction<keyof T, T>;
10
+ export declare function instanceOfAny<T extends Array<{
11
+ new (...args: DeliberateAny[]): DeliberateAny;
12
+ }>>(x: unknown, ...types: T): x is InstanceType<T[number]>;
13
+ export interface IConstructor<T> {
14
+ new (...args: DeliberateAny[]): T;
15
+ }
package/util.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { bytes, internal } from '@algorandfoundation/algorand-typescript';
2
+ import { DeliberateAny } from './typescript-helpers';
3
+ export declare const nameOfType: (x: unknown) => string;
4
+ export declare function iterBigInt(start: bigint, end: bigint): Generator<bigint>;
5
+ export declare const asBigInt: (v: internal.primitives.StubUint64Compat) => bigint;
6
+ export declare const asNumber: (v: internal.primitives.StubUint64Compat) => number;
7
+ export declare function extractGenericTypeArgs(t: string): string[];
8
+ export declare const asUint64Cls: (val: internal.primitives.StubUint64Compat) => internal.primitives.Uint64Cls;
9
+ export declare const asBigUintCls: (val: internal.primitives.StubBigUintCompat) => internal.primitives.BigUintCls;
10
+ export declare const asBytesCls: (val: internal.primitives.StubBytesCompat | Uint8Array) => internal.primitives.BytesCls;
11
+ export declare const asUint64: (val: internal.primitives.StubUint64Compat) => import("@algorandfoundation/algorand-typescript").uint64;
12
+ export declare const asBigUint: (val: internal.primitives.StubBigUintCompat) => import("@algorandfoundation/algorand-typescript").biguint;
13
+ export declare const asBytes: (val: internal.primitives.StubBytesCompat | Uint8Array) => bytes;
14
+ export declare const asUint8Array: (val: internal.primitives.StubBytesCompat | Uint8Array) => Uint8Array;
15
+ export declare const toBytes: (val: unknown) => bytes;
16
+ export declare const asMaybeUint64Cls: (val: DeliberateAny) => internal.primitives.Uint64Cls | undefined;
17
+ export declare const asMaybeBigUintCls: (val: DeliberateAny) => internal.primitives.BigUintCls | undefined;
18
+ export declare const asMaybeBytesCls: (val: DeliberateAny) => internal.primitives.BytesCls | undefined;
19
+ export declare const binaryStringToBytes: (s: string) => internal.primitives.BytesCls;
20
+ export declare const getRandomNumber: (min: number, max: number) => number;
21
+ export declare const getRandomBigInt: (min: number | bigint, max: number | bigint) => bigint;
22
+ export declare const getRandomBytes: (length: number) => internal.primitives.BytesCls;
23
+ type LazyInstance<T> = () => T;
24
+ export declare const Lazy: <T>(factory: () => T) => LazyInstance<T>;
25
+ export declare const getObjectReference: (obj: DeliberateAny) => bigint;
26
+ export declare const combineIntoMaxBytePages: (pages: bytes[]) => bytes[];
27
+ export declare const conactUint8Arrays: (...values: Uint8Array[]) => Uint8Array;
28
+ export declare const uint8ArrayToNumber: (value: Uint8Array) => number;
29
+ export {};
@@ -0,0 +1,23 @@
1
+ import { Account, Application, Asset, bytes, internal, uint64 } from '@algorandfoundation/algorand-typescript';
2
+ import { AccountData } from '../impl/account';
3
+ import { ApplicationData } from '../impl/application';
4
+ import { AssetData } from '../impl/asset';
5
+ type AccountContextData = Partial<AccountData['account']> & {
6
+ address?: Account;
7
+ optedAssetBalances?: Map<internal.primitives.StubUint64Compat, internal.primitives.StubUint64Compat>;
8
+ optedApplications?: Application[];
9
+ };
10
+ type AssetContextData = Partial<AssetData> & {
11
+ assetId?: internal.primitives.StubUint64Compat;
12
+ };
13
+ type ApplicationContextData = Partial<ApplicationData['application']> & {
14
+ applicationId?: internal.primitives.StubUint64Compat;
15
+ };
16
+ export declare class AvmValueGenerator {
17
+ uint64(minValue?: number | bigint, maxValue?: number | bigint): uint64;
18
+ bytes(length?: number): bytes;
19
+ account(input?: AccountContextData): Account;
20
+ asset(input?: AssetContextData): Asset;
21
+ application(input?: ApplicationContextData): Application;
22
+ }
23
+ export {};