@algorandfoundation/algorand-typescript-testing 1.0.0-beta.16 → 1.0.0-beta.18

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/README.md ADDED
@@ -0,0 +1,205 @@
1
+ # Algorand TypeScript Testing
2
+
3
+ [![docs-repository](https://img.shields.io/badge/url-repository-74dfdc?logo=github&style=flat.svg)](https://github.com/algorandfoundation/algorand-typescript-testing/)
4
+ [![learn-AlgoKit](https://img.shields.io/badge/learn-AlgoKit-74dfdc?logo=algorand&mac=flat.svg)](https://developer.algorand.org/algokit/)
5
+ [![github-stars](https://img.shields.io/github/stars/algorandfoundation/algorand-typescript-testing?color=74dfdc&logo=star&style=flat)](https://github.com/algorandfoundation/algorand-typescript-testing)
6
+ [![visitor-badge](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Falgorandfoundation%2Falgorand-typescript-testing&countColor=%2374dfdc&style=flat)](https://github.com/algorandfoundation/algorand-typescript-testing/)
7
+
8
+ `algorand-typescript-testing` is a companion package to [Algorand Typescript](https://github.com/algorandfoundation/puya-ts/tree/main/packages/algo-ts) that enables efficient unit testing of Algorand TypeScript smart contracts in an offline environment. This package emulates key AVM behaviors without requiring a network connection, offering fast and reliable testing capabilities with a familiar TypeScript interface.
9
+
10
+ The `algorand-typescript-testing` package provides:
11
+
12
+ - A simple interface for fast and reliable unit testing
13
+ - An offline testing environment that simulates core AVM functionality
14
+ - A familiar TypeScript experience, compatible with testing frameworks like [vitest](https://vitest.dev/), and [jest](https://jestjs.io/)
15
+
16
+ ## Quick Start
17
+
18
+ `algorand-typescript` is a prerequisite for `algorand-typescript-testing`, providing stubs and type annotations for Algorand TypeScript syntax. It enhances code completion and type checking when writing smart contracts. Note that this code isn't directly executable in standard Node.js environment; it's compiled by `puya-ts` into TEAL for Algorand Network deployment.
19
+
20
+ Traditionally, testing Algorand smart contracts involved deployment on sandboxed networks and interacting with live instances. While robust, this approach can be inefficient and lacks versatility for testing Algorand TypeScript code.
21
+
22
+ Enter `algorand-typescript-testing`: it leverages TypeScript's rich testing ecosystem for unit testing without network deployment. This enables rapid iteration and granular logic testing.
23
+
24
+ > **NOTE**: While `algorand-typescript-testing` offers valuable unit testing capabilities, it's not a replacement for comprehensive testing. Use it alongside other test types, particularly those running against the actual Algorand Network, for thorough contract validation.
25
+
26
+ ### Prerequisites
27
+
28
+ - Python 3.12 or later
29
+ - [Algorand Python](https://github.com/algorandfoundation/puya)
30
+ - Node.js 20.x or later
31
+ - [Algorand TypeScript](https://github.com/algorandfoundation/puya-ts)
32
+
33
+ ### Installation
34
+
35
+ `algorand-typescript-testing` is distributed via [npm](https://www.npmjs.com/package/@algorandfoundation/algorand-typescript-testing/). Install the package using `npm`:
36
+
37
+ ```bash
38
+ npm i @algorandfoundation/algorand-typescript-testing
39
+ ```
40
+
41
+ ### Testing your first contract
42
+
43
+ Let's write a simple contract and test it using the `algorand-typescript-testing` framework.
44
+
45
+ If you are using [vitest](https://vitest.dev/) with [@rollup/plugin-typescript](https://www.npmjs.com/package/@rollup/plugin-typescript) plugin, configure `puyaTsTransformer` as a `before` stage transformer of `typescript` plugin in `vitest.config.mts` file.
46
+
47
+ ```typescript
48
+ import typescript from '@rollup/plugin-typescript'
49
+ import { defineConfig } from 'vitest/config'
50
+ import { puyaTsTransformer } from '@algorandfoundation/algorand-typescript-testing/test-transformer'
51
+
52
+ export default defineConfig({
53
+ esbuild: {},
54
+ test: {
55
+ setupFiles: 'vitest.setup.ts',
56
+ },
57
+ plugins: [
58
+ typescript({
59
+ tsconfig: './tsconfig.json',
60
+ transformers: {
61
+ before: [puyaTsTransformer],
62
+ },
63
+ }),
64
+ ],
65
+ })
66
+ ```
67
+
68
+ `algorand-typescript-testing` package also exposes additional equality testers which enables the smart contract developers to write terser test by avoiding type casting in assertions. It can setup in `beforeAll` hook point in the setup file, `vitest.setup.ts`.
69
+
70
+ ```typescript
71
+ import { beforeAll, expect } from 'vitest'
72
+ import { addEqualityTesters } from '@algorandfoundation/algorand-typescript-testing'
73
+
74
+ beforeAll(() => {
75
+ addEqualityTesters({ expect })
76
+ })
77
+ ```
78
+
79
+ #### Contract Definition
80
+
81
+ ```typescript
82
+ import { arc4, assert, Bytes, GlobalState, gtxn, LocalState, op, Txn, uint64, Uint64 } from '@algorandfoundation/algorand-typescript'
83
+
84
+ export default class VotingContract extends arc4.Contract {
85
+ topic = GlobalState({ initialValue: 'default_topic', key: Bytes('topic') })
86
+ votes = GlobalState({ initialValue: Uint64(0), key: Bytes('votes') })
87
+ voted = LocalState<uint64>({ key: Bytes('voted') })
88
+
89
+ @arc4.abimethod()
90
+ public setTopic(topic: string): void {
91
+ this.topic.value = topic
92
+ }
93
+ @arc4.abimethod()
94
+ public vote(pay: gtxn.PaymentTxn): boolean {
95
+ assert(op.Global.groupSize === 2, 'Expected 2 transactions')
96
+ assert(pay.amount === 10_000, 'Incorrect payment amount')
97
+ assert(pay.sender === Txn.sender, 'Payment sender must match transaction sender')
98
+
99
+ if (this.voted(Txn.sender).hasValue) {
100
+ return false // Already voted
101
+ }
102
+
103
+ this.votes.value = this.votes.value + 1
104
+ this.voted(Txn.sender).value = 1
105
+ return true
106
+ }
107
+
108
+ @arc4.abimethod({ readonly: true })
109
+ public getVotes(): uint64 {
110
+ return this.votes.value
111
+ }
112
+
113
+ public clearStateProgram(): boolean {
114
+ return true
115
+ }
116
+ }
117
+ ```
118
+
119
+ #### Test Definition
120
+
121
+ ```typescript
122
+ import { Uint64 } from '@algorandfoundation/algorand-typescript'
123
+ import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
124
+ import { afterEach, describe, expect, test } from 'vitest'
125
+ import VotingContract from './contract.algo'
126
+
127
+ describe('Voting contract', () => {
128
+ const ctx = new TestExecutionContext()
129
+ afterEach(() => {
130
+ ctx.reset()
131
+ })
132
+
133
+ test('vote function', () => {
134
+ // Initialize the contract within the testing context
135
+ const contract = ctx.contract.create(VotingContract)
136
+
137
+ const voter = ctx.defaultSender
138
+ const payment = ctx.any.txn.payment({
139
+ sender: voter,
140
+ amount: 10_000,
141
+ })
142
+
143
+ const result = contract.vote(payment)
144
+ expect(result).toEqual(true)
145
+ expect(contract.votes.value).toEqual(1)
146
+ expect(contract.voted(voter).value).toEqual(1)
147
+ })
148
+
149
+ test('setTopic function', () => {
150
+ // Initialize the contract within the testing context
151
+ const contract = ctx.contract.create(VotingContract)
152
+
153
+ const newTopic = ctx.any.string(10)
154
+ contract.setTopic(newTopic)
155
+ expect(contract.topic.value).toEqual(newTopic)
156
+ })
157
+
158
+ test('getVotes function', () => {
159
+ // Initialize the contract within the testing context
160
+ const contract = ctx.contract.create(VotingContract)
161
+
162
+ contract.votes.value = 5
163
+ const votes = contract.getVotes()
164
+ expect(votes).toEqual(5)
165
+ })
166
+ })
167
+ ```
168
+
169
+ This example demonstrates key aspects of testing with `algorand-typescript-testing` for ARC4-based contracts:
170
+
171
+ 1. ARC4 Contract Features:
172
+
173
+ - Use of `arc4.Contract` as the base class for the contract.
174
+ - ABI methods defined using the `@arc4.abimethod` decorator.
175
+ - Readonly method annotation with `@arc4.abimethod({readonly: true})`.
176
+
177
+ 2. Testing ARC4 Contracts:
178
+
179
+ - Creation of an `arc4.Contract` instance within the test context.
180
+ - Use of `ctx.any` for generating random test data.
181
+ - Direct invocation of ABI methods on the contract instance.
182
+
183
+ 3. Transaction Handling:
184
+
185
+ - Use of `ctx.any.txn` to create test transactions.
186
+ - Passing transaction objects as parameters to contract methods.
187
+
188
+ 4. State Verification:
189
+ - Checking global and local state changes after method execution.
190
+ - Verifying return values from ABI methods.
191
+
192
+ > **NOTE**: Thorough testing is crucial in smart contract development due to their immutable nature post-deployment. Comprehensive unit and integration tests ensure contract validity and reliability. Optimizing for efficiency can significantly improve user experience by reducing transaction fees and simplifying interactions. Investing in robust testing and optimization practices is crucial and offers many benefits in the long run.
193
+
194
+ ### Next steps
195
+
196
+ To dig deeper into the capabilities of `algorand-typescript-testing`, continue with the following sections.
197
+
198
+ #### Contents
199
+
200
+ - [Testing Guide](./docs/testing-guide/index.md)
201
+ - [Examples](./docs/examples.md)
202
+ - [Coverage](./docs/coverage.md)
203
+ - [FQA](./docs/faq.md)
204
+ - [API Reference](./docs/api.md)
205
+ - [Algorand TypeScript](./docs/algots.md)
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "**"
5
5
  ],
6
6
  "name": "@algorandfoundation/algorand-typescript-testing",
7
- "version": "1.0.0-beta.16",
7
+ "version": "1.0.0-beta.18",
8
8
  "description": "A library which allows you to execute Algorand TypeScript code locally under a test context either emulating or mocking AVM behaviour.",
9
9
  "private": false,
10
10
  "peerDependencies": {
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@algorandfoundation/algorand-typescript": "^1.0.0-beta.16",
15
- "@algorandfoundation/puya-ts": "^1.0.0-beta.22",
15
+ "@algorandfoundation/puya-ts": "^1.0.0-beta.23",
16
16
  "elliptic": "^6.5.7",
17
17
  "js-sha256": "^0.11.0",
18
18
  "js-sha3": "^0.9.3",
@@ -33,3 +33,6 @@ export interface TransformerConfig {
33
33
  * })
34
34
  */
35
35
  export declare const puyaTsTransformer: ts.TransformerFactory<ts.SourceFile> & ((config: Partial<TransformerConfig>) => ts.TransformerFactory<ts.SourceFile>);
36
+ export declare const name = "puyaTsTransformer";
37
+ export declare const version = "0.1.0";
38
+ export declare const factory: (program: ts.Program) => ts.TransformerFactory<ts.SourceFile>;
@@ -20,44 +20,44 @@ const getPropertyNameAsString = (name) => {
20
20
  };
21
21
  const trimGenericTypeName = (typeName) => typeName.replace(/<.*>/, '');
22
22
 
23
- const factory$1 = ts.factory;
23
+ const factory$2 = ts.factory;
24
24
  const nodeFactory = {
25
25
  importHelpers(testingPackageName) {
26
- return factory$1.createImportDeclaration(undefined, factory$1.createImportClause(false, undefined, factory$1.createNamespaceImport(factory$1.createIdentifier('runtimeHelpers'))), factory$1.createStringLiteral(`${testingPackageName}/runtime-helpers`), undefined);
26
+ return factory$2.createImportDeclaration(undefined, factory$2.createImportClause(false, undefined, factory$2.createNamespaceImport(factory$2.createIdentifier('runtimeHelpers'))), factory$2.createStringLiteral(`${testingPackageName}/runtime-helpers`), undefined);
27
27
  },
28
28
  switchableValue(x) {
29
- return factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('switchableValue')), undefined, [x]);
29
+ return factory$2.createCallExpression(factory$2.createPropertyAccessExpression(factory$2.createIdentifier('runtimeHelpers'), factory$2.createIdentifier('switchableValue')), undefined, [x]);
30
30
  },
31
31
  binaryOp(left, right, op) {
32
- return factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('binaryOp')), undefined, [left, right, factory$1.createStringLiteral(op)]);
32
+ return factory$2.createCallExpression(factory$2.createPropertyAccessExpression(factory$2.createIdentifier('runtimeHelpers'), factory$2.createIdentifier('binaryOp')), undefined, [left, right, factory$2.createStringLiteral(op)]);
33
33
  },
34
34
  augmentedAssignmentBinaryOp(left, right, op) {
35
- 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('=', ''))]));
35
+ return factory$2.createAssignment(left, factory$2.createCallExpression(factory$2.createPropertyAccessExpression(factory$2.createIdentifier('runtimeHelpers'), factory$2.createIdentifier('binaryOp')), undefined, [left, right, factory$2.createStringLiteral(op.replace('=', ''))]));
36
36
  },
37
37
  prefixUnaryOp(operand, op) {
38
- return factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('unaryOp')), undefined, [operand, factory$1.createStringLiteral(op)]);
38
+ return factory$2.createCallExpression(factory$2.createPropertyAccessExpression(factory$2.createIdentifier('runtimeHelpers'), factory$2.createIdentifier('unaryOp')), undefined, [operand, factory$2.createStringLiteral(op)]);
39
39
  },
40
40
  attachMetaData(classIdentifier, method, functionType, argTypes, returnType) {
41
41
  const methodName = getPropertyNameAsString(method.name);
42
- const metadata = factory$1.createObjectLiteralExpression([
43
- factory$1.createPropertyAssignment('methodName', methodName),
44
- factory$1.createPropertyAssignment('argTypes', factory$1.createArrayLiteralExpression(argTypes.map((p) => factory$1.createStringLiteral(p)))),
45
- factory$1.createPropertyAssignment('returnType', factory$1.createStringLiteral(returnType)),
42
+ const metadata = factory$2.createObjectLiteralExpression([
43
+ factory$2.createPropertyAssignment('methodName', methodName),
44
+ factory$2.createPropertyAssignment('argTypes', factory$2.createArrayLiteralExpression(argTypes.map((p) => factory$2.createStringLiteral(p)))),
45
+ factory$2.createPropertyAssignment('returnType', factory$2.createStringLiteral(returnType)),
46
46
  ]);
47
- return factory$1.createExpressionStatement(factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('attachAbiMetadata')), undefined, [classIdentifier, methodName, metadata]));
47
+ return factory$2.createExpressionStatement(factory$2.createCallExpression(factory$2.createPropertyAccessExpression(factory$2.createIdentifier('runtimeHelpers'), factory$2.createIdentifier('attachAbiMetadata')), undefined, [classIdentifier, methodName, metadata]));
48
48
  },
49
49
  captureGenericTypeInfo(x, info) {
50
- return factory$1.createCallExpression(factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), factory$1.createIdentifier('captureGenericTypeInfo')), undefined, [x, factory$1.createStringLiteral(info)]);
50
+ return factory$2.createCallExpression(factory$2.createPropertyAccessExpression(factory$2.createIdentifier('runtimeHelpers'), factory$2.createIdentifier('captureGenericTypeInfo')), undefined, [x, factory$2.createStringLiteral(info)]);
51
51
  },
52
52
  instantiateARC4EncodedType(node, typeInfo) {
53
53
  const infoString = JSON.stringify(typeInfo);
54
54
  const classIdentifier = node.expression.getText().replace('arc4.', '');
55
- 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));
55
+ return factory$2.createNewExpression(factory$2.createIdentifier(`runtimeHelpers.${trimGenericTypeName(typeInfo?.name ?? classIdentifier)}Impl`), node.typeArguments, [infoString ? factory$2.createStringLiteral(infoString) : undefined, ...(node.arguments ?? [])].filter((arg) => !!arg));
56
56
  },
57
57
  callStubbedFunction(functionName, node, typeInfo) {
58
- const typeInfoArg = typeInfo ? factory$1.createStringLiteral(JSON.stringify(typeInfo)) : undefined;
59
- const updatedPropertyAccessExpression = factory$1.createPropertyAccessExpression(factory$1.createIdentifier('runtimeHelpers'), `${functionName}Impl`);
60
- return factory$1.createCallExpression(updatedPropertyAccessExpression, node.typeArguments, [typeInfoArg, ...(node.arguments ?? [])].filter((arg) => !!arg));
58
+ const typeInfoArg = typeInfo ? factory$2.createStringLiteral(JSON.stringify(typeInfo)) : undefined;
59
+ const updatedPropertyAccessExpression = factory$2.createPropertyAccessExpression(factory$2.createIdentifier('runtimeHelpers'), `${functionName}Impl`);
60
+ return factory$2.createCallExpression(updatedPropertyAccessExpression, node.typeArguments, [typeInfoArg, ...(node.arguments ?? [])].filter((arg) => !!arg));
61
61
  },
62
62
  };
63
63
 
@@ -146,7 +146,7 @@ function supportedPrefixUnaryOpString(x) {
146
146
  }
147
147
  }
148
148
 
149
- const { factory } = ts;
149
+ const { factory: factory$1 } = ts;
150
150
  const algotsModuleRegExp = new RegExp(/^("|')@algorandfoundation\/algorand-typescript(\/|"|')/);
151
151
  const algotsModuleSpecifier = '@algorandfoundation/algorand-typescript';
152
152
  const testingInternalModuleSpecifier = (testingPackageName) => `${testingPackageName}/internal`;
@@ -164,9 +164,11 @@ class SourceFileVisitor {
164
164
  this.context = context;
165
165
  this.sourceFile = sourceFile;
166
166
  this.config = config;
167
- const typeChecker = program.getTypeChecker();
167
+ // ts-jest would pass a TsCompilerInstance as program parameter whereas rollup-plugin-typescript would pass a ts.Program
168
+ const programInstance = (Object.hasOwn(program, 'program') ? program.program : program);
169
+ const typeChecker = programInstance.getTypeChecker();
168
170
  const loggingContext = LoggingContext.create();
169
- const typeResolver = new TypeResolver(typeChecker, program.getCurrentDirectory());
171
+ const typeResolver = new TypeResolver(typeChecker, programInstance.getCurrentDirectory());
170
172
  this.helper = {
171
173
  additionalStatements: [],
172
174
  resolveType(node) {
@@ -185,13 +187,13 @@ class SourceFileVisitor {
185
187
  return s && s.flags & ts.SymbolFlags.Alias ? typeChecker.getAliasedSymbol(s) : s;
186
188
  },
187
189
  sourceLocation(node) {
188
- return SourceLocation.fromNode(node, program.getCurrentDirectory());
190
+ return SourceLocation.fromNode(node, programInstance.getCurrentDirectory());
189
191
  },
190
192
  };
191
193
  }
192
194
  result() {
193
195
  const updatedSourceFile = ts.visitNode(this.sourceFile, this.visit);
194
- return factory.updateSourceFile(updatedSourceFile, [
196
+ return factory$1.updateSourceFile(updatedSourceFile, [
195
197
  nodeFactory.importHelpers(this.config.testingPackageName),
196
198
  ...updatedSourceFile.statements,
197
199
  ...this.helper.additionalStatements,
@@ -232,9 +234,9 @@ class ImportDeclarationVisitor {
232
234
  return this.declarationNode;
233
235
  const namedBindings = this.declarationNode.importClause?.namedBindings;
234
236
  const nonTypeNamedBindings = namedBindings && ts.isNamedImports(namedBindings) ? namedBindings.elements.filter((e) => !e.isTypeOnly) : [];
235
- return factory.createImportDeclaration(this.declarationNode.modifiers, nonTypeNamedBindings.length
236
- ? factory.createImportClause(false, this.declarationNode.importClause?.name, factory.createNamedImports(nonTypeNamedBindings))
237
- : this.declarationNode.importClause, factory.createStringLiteral(moduleSpecifier
237
+ return factory$1.createImportDeclaration(this.declarationNode.modifiers, nonTypeNamedBindings.length
238
+ ? factory$1.createImportClause(false, this.declarationNode.importClause?.name, factory$1.createNamedImports(nonTypeNamedBindings))
239
+ : this.declarationNode.importClause, factory$1.createStringLiteral(moduleSpecifier
238
240
  .replace(algotsModuleSpecifier, testingInternalModuleSpecifier(this.config.testingPackageName))
239
241
  .replace(/^("|')/, '')
240
242
  .replace(/("|')$/, '')), this.declarationNode.attributes);
@@ -307,7 +309,7 @@ class VariableInitializerVisitor {
307
309
  const updatedInitializer = new ExpressionVisitor(this.context, this.helper, initializerNode).result();
308
310
  if (updatedInitializer === initializerNode)
309
311
  return this.declarationNode;
310
- return factory.updateVariableDeclaration(this.declarationNode, this.declarationNode.name, this.declarationNode.exclamationToken, this.declarationNode.type, updatedInitializer);
312
+ return factory$1.updateVariableDeclaration(this.declarationNode, this.declarationNode.name, this.declarationNode.exclamationToken, this.declarationNode.type, updatedInitializer);
311
313
  }
312
314
  }
313
315
  class FunctionOrMethodVisitor {
@@ -324,10 +326,10 @@ class FunctionOrMethodVisitor {
324
326
  };
325
327
  updateNode(node) {
326
328
  if (ts.isSwitchStatement(node)) {
327
- return factory.updateSwitchStatement(node, nodeFactory.switchableValue(node.expression), node.caseBlock);
329
+ return factory$1.updateSwitchStatement(node, nodeFactory.switchableValue(node.expression), node.caseBlock);
328
330
  }
329
331
  if (ts.isCaseClause(node)) {
330
- return factory.updateCaseClause(node, nodeFactory.switchableValue(node.expression), node.statements);
332
+ return factory$1.updateCaseClause(node, nodeFactory.switchableValue(node.expression), node.statements);
331
333
  }
332
334
  if (ts.isBinaryExpression(node)) {
333
335
  const opTokenText = supportedBinaryOpString(node.operatorToken.kind);
@@ -552,6 +554,11 @@ programTransformer.factory = createProgramFactory(defaultTransformerConfig);
552
554
  * })
553
555
  */
554
556
  const puyaTsTransformer = programTransformer;
557
+ // exporting values needed by ts-jest for a transformer to work
558
+ // https://github.com/kulshekhar/ts-jest/tree/main/src/transformers
559
+ const name = 'puyaTsTransformer';
560
+ const version = '0.1.0';
561
+ const factory = createProgramFactory(defaultTransformerConfig);
555
562
 
556
- export { puyaTsTransformer };
563
+ export { factory, name, puyaTsTransformer, version };
557
564
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../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":["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 type { ptypes } from '@algorandfoundation/puya-ts'\nimport ts from 'typescript'\nimport type { 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(\n classIdentifier: ts.Identifier,\n method: ts.MethodDeclaration,\n functionType: ptypes.FunctionPType,\n argTypes: string[],\n returnType: string,\n ) {\n const methodName = getPropertyNameAsString(method.name)\n const metadata = factory.createObjectLiteralExpression([\n factory.createPropertyAssignment('methodName', methodName),\n factory.createPropertyAssignment(\n 'argTypes',\n factory.createArrayLiteralExpression(argTypes.map((p) => factory.createStringLiteral(p))),\n ),\n factory.createPropertyAssignment('returnType', factory.createStringLiteral(returnType)),\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 callStubbedFunction(functionName: string, node: ts.CallExpression, typeInfo?: TypeInfo) {\n const typeInfoArg = typeInfo ? factory.createStringLiteral(JSON.stringify(typeInfo)) : undefined\n const updatedPropertyAccessExpression = factory.createPropertyAccessExpression(\n factory.createIdentifier('runtimeHelpers'),\n `${functionName}Impl`,\n )\n\n return factory.createCallExpression(\n updatedPropertyAccessExpression,\n node.typeArguments,\n [typeInfoArg, ...(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 { LoggingContext, ptypes, SourceLocation, TypeResolver } from '@algorandfoundation/puya-ts'\nimport path from 'path'\nimport ts from 'typescript'\nimport type { TypeInfo } from '../encoders'\nimport { instanceOfAny } from '../typescript-helpers'\nimport type { 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\nconst algotsModuleRegExp = new RegExp(/^(\"|')@algorandfoundation\\/algorand-typescript(\\/|\"|')/)\nconst algotsModuleSpecifier = '@algorandfoundation/algorand-typescript'\nconst testingInternalModuleSpecifier = (testingPackageName: string) => `${testingPackageName}/internal`\nconst algotsModulePaths = [\n algotsModuleSpecifier,\n '/puya-ts/packages/algo-ts/',\n `${path.sep}puya-ts${path.sep}packages${path.sep}algo-ts${path.sep}`,\n]\n\ntype VisitorHelper = {\n additionalStatements: ts.Statement[]\n resolveType(node: ts.Node): ptypes.PType\n resolveTypeParameters(node: ts.CallExpression): ptypes.PType[]\n sourceLocation(node: ts.Node): SourceLocation\n tryGetSymbol(node: ts.Node): ts.Symbol | undefined\n}\n\nexport class SourceFileVisitor {\n private helper: VisitorHelper\n\n constructor(\n private context: ts.TransformationContext,\n private sourceFile: ts.SourceFile,\n program: ts.Program,\n private config: TransformerConfig,\n ) {\n const typeChecker = program.getTypeChecker()\n const loggingContext = LoggingContext.create()\n const typeResolver = new TypeResolver(typeChecker, program.getCurrentDirectory())\n this.helper = {\n additionalStatements: [],\n resolveType(node: ts.Node): ptypes.PType {\n try {\n return loggingContext.run(() => typeResolver.resolve(node, this.sourceLocation(node)))\n } catch {\n return ptypes.anyPType\n }\n },\n resolveTypeParameters(node: ts.CallExpression) {\n return loggingContext.run(() => typeResolver.resolveTypeParameters(node, this.sourceLocation(node)))\n },\n tryGetSymbol(node: ts.Node): ts.Symbol | undefined {\n const s = typeChecker.getSymbolAtLocation(node)\n return s && s.flags & ts.SymbolFlags.Alias ? typeChecker.getAliasedSymbol(s) : s\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 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.isImportDeclaration(node)) {\n return new ImportDeclarationVisitor(this.context, this.helper, this.config, node).result()\n }\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 ImportDeclarationVisitor {\n constructor(\n private context: ts.TransformationContext,\n private helper: VisitorHelper,\n private config: TransformerConfig,\n private declarationNode: ts.ImportDeclaration,\n ) {}\n\n public result(): ts.ImportDeclaration {\n const moduleSpecifier = this.declarationNode.moduleSpecifier.getText()\n if (this.declarationNode.importClause?.isTypeOnly || !algotsModuleRegExp.test(moduleSpecifier)) return this.declarationNode\n\n const namedBindings = this.declarationNode.importClause?.namedBindings\n const nonTypeNamedBindings =\n namedBindings && ts.isNamedImports(namedBindings) ? (namedBindings as ts.NamedImports).elements.filter((e) => !e.isTypeOnly) : []\n return factory.createImportDeclaration(\n this.declarationNode.modifiers,\n nonTypeNamedBindings.length\n ? factory.createImportClause(false, this.declarationNode.importClause?.name, factory.createNamedImports(nonTypeNamedBindings))\n : this.declarationNode.importClause,\n factory.createStringLiteral(\n moduleSpecifier\n .replace(algotsModuleSpecifier, testingInternalModuleSpecifier(this.config.testingPackageName))\n .replace(/^(\"|')/, '')\n .replace(/(\"|')$/, ''),\n ),\n this.declarationNode.attributes,\n )\n }\n}\n\nclass ExpressionVisitor {\n constructor(\n private context: ts.TransformationContext,\n private helper: VisitorHelper,\n private expressionNode: ts.Expression,\n private stubbedFunctionName?: string,\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 needsToCaptureTypeInfo = isGeneric && isStateOrBoxType(type)\n const isArc4Encoded = isArc4EncodedType(type)\n const info = isGeneric || isArc4Encoded ? getGenericTypeInfo(type) : undefined\n let updatedNode = node\n\n if (ts.isNewExpression(updatedNode)) {\n if (isArc4EncodedType(type)) {\n updatedNode = nodeFactory.instantiateARC4EncodedType(updatedNode, info)\n }\n }\n\n if (ts.isCallExpression(updatedNode)) {\n const stubbedFunctionName = this.stubbedFunctionName ?? tryGetStubbedFunctionName(updatedNode, this.helper)\n this.stubbedFunctionName = undefined\n let infoArg = info\n if (isCallingEmit(stubbedFunctionName)) {\n infoArg = this.helper.resolveTypeParameters(updatedNode).map(getGenericTypeInfo)[0]\n }\n if (isCallingDecodeArc4(stubbedFunctionName)) {\n const targetType = ptypes.ptypeToArc4EncodedType(type, this.helper.sourceLocation(node))\n const targetTypeInfo = getGenericTypeInfo(targetType)\n infoArg = targetTypeInfo\n }\n updatedNode = stubbedFunctionName ? nodeFactory.callStubbedFunction(stubbedFunctionName, updatedNode, infoArg) : updatedNode\n }\n return needsToCaptureTypeInfo\n ? nodeFactory.captureGenericTypeInfo(ts.visitEachChild(updatedNode, this.visit, this.context), JSON.stringify(info))\n : ts.visitEachChild(updatedNode, this.visit, this.context)\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)) {\n const stubbedFunctionName = tryGetStubbedFunctionName(node, this.helper)\n if (stubbedFunctionName) {\n return new ExpressionVisitor(this.context, this.helper, node, stubbedFunctionName).result()\n }\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 const argTypes = methodType.parameters.map((p) => JSON.stringify(getGenericTypeInfo(p[1])))\n const returnType = JSON.stringify(getGenericTypeInfo(methodType.returnType))\n this.helper.additionalStatements.push(nodeFactory.attachMetaData(this.classDec.name, node, methodType, argTypes, returnType))\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 ptypes.TuplePType,\n )\n\nconst isStateOrBoxType = (type: ptypes.PType): boolean =>\n instanceOfAny(type, ptypes.BoxMapPType, ptypes.BoxPType, ptypes.GlobalStateType, ptypes.LocalStateType)\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<${type.name}>`\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 || type instanceof ptypes.TuplePType) {\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 tryGetStubbedFunctionName = (node: ts.CallExpression, helper: VisitorHelper): string | undefined => {\n if (node.expression.kind !== ts.SyntaxKind.Identifier && !ts.isPropertyAccessExpression(node.expression)) return undefined\n const identityExpression = ts.isPropertyAccessExpression(node.expression)\n ? (node.expression as ts.PropertyAccessExpression).name\n : (node.expression as ts.Identifier)\n const functionSymbol = helper.tryGetSymbol(identityExpression)\n if (functionSymbol) {\n const sourceFileName = functionSymbol.valueDeclaration?.getSourceFile().fileName\n if (sourceFileName && !algotsModulePaths.some((s) => sourceFileName.includes(s))) return undefined\n }\n const functionName = functionSymbol?.getName() ?? identityExpression.text\n const stubbedFunctionNames = ['interpretAsArc4', 'decodeArc4', 'encodeArc4', 'emit']\n return stubbedFunctionNames.includes(functionName) ? functionName : undefined\n}\n\nconst isCallingDecodeArc4 = (functionName: string | undefined): boolean => ['decodeArc4', 'encodeArc4'].includes(functionName ?? '')\nconst isCallingEmit = (functionName: string | undefined): boolean => 'emit' === (functionName ?? '')\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\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\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/**\n * TypeScript transformer for Algorand TypeScript smart contracts and testing files\n * which is mainly responsilbe for swapping in stub implementations of op codes,\n * and capturing TypeScript type information for the Node.js runtime.\n *\n ** @type {ts.TransformerFactory<ts.SourceFile> & ((config: Partial<TransformerConfig>) => ts.TransformerFactory<ts.SourceFile>)}\n *\n * @param {Partial<TransformerConfig>} [config] Configuration options\n * @param {string[]} [config.includeExt=['.algo.ts', '.spec.ts']] File extensions to process\n * @param {string} [config.testingPackageName='@algorandfoundation/algorand-typescript-testing'] Package name for testing imports\n *\n * @example\n * // Use as factory function with custom config in vitest.config.mts\n * import typescript from '@rollup/plugin-typescript'\n * import { defineConfig } from 'vitest/config'\n * import { puyaTsTransformer } from '@algorandfoundation/algorand-typescript-testing/test-transformer'\n *\n * export default defineConfig({\n * esbuild: {},\n * plugins: [\n * typescript({\n * tsconfig: './tsconfig.json',\n * transformers: {\n * before: [puyaTsTransformer],\n * },\n * }),\n * ],\n * })\n */\nexport const puyaTsTransformer: ts.TransformerFactory<ts.SourceFile> &\n ((config: Partial<TransformerConfig>) => ts.TransformerFactory<ts.SourceFile>) = programTransformer as DeliberateAny\n"],"names":["factory"],"mappings":";;;;;AAAM,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;AA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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACI,MAAM,iBAAiB,GACqD;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../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":["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 type { ptypes } from '@algorandfoundation/puya-ts'\nimport ts from 'typescript'\nimport type { 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(\n classIdentifier: ts.Identifier,\n method: ts.MethodDeclaration,\n functionType: ptypes.FunctionPType,\n argTypes: string[],\n returnType: string,\n ) {\n const methodName = getPropertyNameAsString(method.name)\n const metadata = factory.createObjectLiteralExpression([\n factory.createPropertyAssignment('methodName', methodName),\n factory.createPropertyAssignment(\n 'argTypes',\n factory.createArrayLiteralExpression(argTypes.map((p) => factory.createStringLiteral(p))),\n ),\n factory.createPropertyAssignment('returnType', factory.createStringLiteral(returnType)),\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 callStubbedFunction(functionName: string, node: ts.CallExpression, typeInfo?: TypeInfo) {\n const typeInfoArg = typeInfo ? factory.createStringLiteral(JSON.stringify(typeInfo)) : undefined\n const updatedPropertyAccessExpression = factory.createPropertyAccessExpression(\n factory.createIdentifier('runtimeHelpers'),\n `${functionName}Impl`,\n )\n\n return factory.createCallExpression(\n updatedPropertyAccessExpression,\n node.typeArguments,\n [typeInfoArg, ...(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 { LoggingContext, ptypes, SourceLocation, TypeResolver } from '@algorandfoundation/puya-ts'\nimport path from 'path'\nimport ts from 'typescript'\nimport type { TypeInfo } from '../encoders'\nimport type { DeliberateAny } from '../typescript-helpers'\nimport { instanceOfAny } from '../typescript-helpers'\nimport type { 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\nconst algotsModuleRegExp = new RegExp(/^(\"|')@algorandfoundation\\/algorand-typescript(\\/|\"|')/)\nconst algotsModuleSpecifier = '@algorandfoundation/algorand-typescript'\nconst testingInternalModuleSpecifier = (testingPackageName: string) => `${testingPackageName}/internal`\nconst algotsModulePaths = [\n algotsModuleSpecifier,\n '/puya-ts/packages/algo-ts/',\n `${path.sep}puya-ts${path.sep}packages${path.sep}algo-ts${path.sep}`,\n]\n\ntype VisitorHelper = {\n additionalStatements: ts.Statement[]\n resolveType(node: ts.Node): ptypes.PType\n resolveTypeParameters(node: ts.CallExpression): ptypes.PType[]\n sourceLocation(node: ts.Node): SourceLocation\n tryGetSymbol(node: ts.Node): ts.Symbol | undefined\n}\n\nexport class SourceFileVisitor {\n private helper: VisitorHelper\n\n constructor(\n private context: ts.TransformationContext,\n private sourceFile: ts.SourceFile,\n program: ts.Program,\n private config: TransformerConfig,\n ) {\n // ts-jest would pass a TsCompilerInstance as program parameter whereas rollup-plugin-typescript would pass a ts.Program\n const programInstance = (Object.hasOwn(program, 'program') ? (program as DeliberateAny).program : program) as ts.Program\n const typeChecker = programInstance.getTypeChecker()\n const loggingContext = LoggingContext.create()\n const typeResolver = new TypeResolver(typeChecker, programInstance.getCurrentDirectory())\n this.helper = {\n additionalStatements: [],\n resolveType(node: ts.Node): ptypes.PType {\n try {\n return loggingContext.run(() => typeResolver.resolve(node, this.sourceLocation(node)))\n } catch {\n return ptypes.anyPType\n }\n },\n resolveTypeParameters(node: ts.CallExpression) {\n return loggingContext.run(() => typeResolver.resolveTypeParameters(node, this.sourceLocation(node)))\n },\n tryGetSymbol(node: ts.Node): ts.Symbol | undefined {\n const s = typeChecker.getSymbolAtLocation(node)\n return s && s.flags & ts.SymbolFlags.Alias ? typeChecker.getAliasedSymbol(s) : s\n },\n sourceLocation(node: ts.Node): SourceLocation {\n return SourceLocation.fromNode(node, programInstance.getCurrentDirectory())\n },\n }\n }\n\n public result(): ts.SourceFile {\n const updatedSourceFile = ts.visitNode(this.sourceFile, this.visit) as ts.SourceFile\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.isImportDeclaration(node)) {\n return new ImportDeclarationVisitor(this.context, this.helper, this.config, node).result()\n }\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 ImportDeclarationVisitor {\n constructor(\n private context: ts.TransformationContext,\n private helper: VisitorHelper,\n private config: TransformerConfig,\n private declarationNode: ts.ImportDeclaration,\n ) {}\n\n public result(): ts.ImportDeclaration {\n const moduleSpecifier = this.declarationNode.moduleSpecifier.getText()\n if (this.declarationNode.importClause?.isTypeOnly || !algotsModuleRegExp.test(moduleSpecifier)) return this.declarationNode\n\n const namedBindings = this.declarationNode.importClause?.namedBindings\n const nonTypeNamedBindings =\n namedBindings && ts.isNamedImports(namedBindings) ? (namedBindings as ts.NamedImports).elements.filter((e) => !e.isTypeOnly) : []\n return factory.createImportDeclaration(\n this.declarationNode.modifiers,\n nonTypeNamedBindings.length\n ? factory.createImportClause(false, this.declarationNode.importClause?.name, factory.createNamedImports(nonTypeNamedBindings))\n : this.declarationNode.importClause,\n factory.createStringLiteral(\n moduleSpecifier\n .replace(algotsModuleSpecifier, testingInternalModuleSpecifier(this.config.testingPackageName))\n .replace(/^(\"|')/, '')\n .replace(/(\"|')$/, ''),\n ),\n this.declarationNode.attributes,\n )\n }\n}\n\nclass ExpressionVisitor {\n constructor(\n private context: ts.TransformationContext,\n private helper: VisitorHelper,\n private expressionNode: ts.Expression,\n private stubbedFunctionName?: string,\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 needsToCaptureTypeInfo = isGeneric && isStateOrBoxType(type)\n const isArc4Encoded = isArc4EncodedType(type)\n const info = isGeneric || isArc4Encoded ? getGenericTypeInfo(type) : undefined\n let updatedNode = node\n\n if (ts.isNewExpression(updatedNode)) {\n if (isArc4EncodedType(type)) {\n updatedNode = nodeFactory.instantiateARC4EncodedType(updatedNode, info)\n }\n }\n\n if (ts.isCallExpression(updatedNode)) {\n const stubbedFunctionName = this.stubbedFunctionName ?? tryGetStubbedFunctionName(updatedNode, this.helper)\n this.stubbedFunctionName = undefined\n let infoArg = info\n if (isCallingEmit(stubbedFunctionName)) {\n infoArg = this.helper.resolveTypeParameters(updatedNode).map(getGenericTypeInfo)[0]\n }\n if (isCallingDecodeArc4(stubbedFunctionName)) {\n const targetType = ptypes.ptypeToArc4EncodedType(type, this.helper.sourceLocation(node))\n const targetTypeInfo = getGenericTypeInfo(targetType)\n infoArg = targetTypeInfo\n }\n updatedNode = stubbedFunctionName ? nodeFactory.callStubbedFunction(stubbedFunctionName, updatedNode, infoArg) : updatedNode\n }\n return needsToCaptureTypeInfo\n ? nodeFactory.captureGenericTypeInfo(ts.visitEachChild(updatedNode, this.visit, this.context), JSON.stringify(info))\n : ts.visitEachChild(updatedNode, this.visit, this.context)\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)) {\n const stubbedFunctionName = tryGetStubbedFunctionName(node, this.helper)\n if (stubbedFunctionName) {\n return new ExpressionVisitor(this.context, this.helper, node, stubbedFunctionName).result()\n }\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 const argTypes = methodType.parameters.map((p) => JSON.stringify(getGenericTypeInfo(p[1])))\n const returnType = JSON.stringify(getGenericTypeInfo(methodType.returnType))\n this.helper.additionalStatements.push(nodeFactory.attachMetaData(this.classDec.name, node, methodType, argTypes, returnType))\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 ptypes.TuplePType,\n )\n\nconst isStateOrBoxType = (type: ptypes.PType): boolean =>\n instanceOfAny(type, ptypes.BoxMapPType, ptypes.BoxPType, ptypes.GlobalStateType, ptypes.LocalStateType)\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<${type.name}>`\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 || type instanceof ptypes.TuplePType) {\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 tryGetStubbedFunctionName = (node: ts.CallExpression, helper: VisitorHelper): string | undefined => {\n if (node.expression.kind !== ts.SyntaxKind.Identifier && !ts.isPropertyAccessExpression(node.expression)) return undefined\n const identityExpression = ts.isPropertyAccessExpression(node.expression)\n ? (node.expression as ts.PropertyAccessExpression).name\n : (node.expression as ts.Identifier)\n const functionSymbol = helper.tryGetSymbol(identityExpression)\n if (functionSymbol) {\n const sourceFileName = functionSymbol.valueDeclaration?.getSourceFile().fileName\n if (sourceFileName && !algotsModulePaths.some((s) => sourceFileName.includes(s))) return undefined\n }\n const functionName = functionSymbol?.getName() ?? identityExpression.text\n const stubbedFunctionNames = ['interpretAsArc4', 'decodeArc4', 'encodeArc4', 'emit']\n return stubbedFunctionNames.includes(functionName) ? functionName : undefined\n}\n\nconst isCallingDecodeArc4 = (functionName: string | undefined): boolean => ['decodeArc4', 'encodeArc4'].includes(functionName ?? '')\nconst isCallingEmit = (functionName: string | undefined): boolean => 'emit' === (functionName ?? '')\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\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\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/**\n * TypeScript transformer for Algorand TypeScript smart contracts and testing files\n * which is mainly responsilbe for swapping in stub implementations of op codes,\n * and capturing TypeScript type information for the Node.js runtime.\n *\n ** @type {ts.TransformerFactory<ts.SourceFile> & ((config: Partial<TransformerConfig>) => ts.TransformerFactory<ts.SourceFile>)}\n *\n * @param {Partial<TransformerConfig>} [config] Configuration options\n * @param {string[]} [config.includeExt=['.algo.ts', '.spec.ts']] File extensions to process\n * @param {string} [config.testingPackageName='@algorandfoundation/algorand-typescript-testing'] Package name for testing imports\n *\n * @example\n * // Use as factory function with custom config in vitest.config.mts\n * import typescript from '@rollup/plugin-typescript'\n * import { defineConfig } from 'vitest/config'\n * import { puyaTsTransformer } from '@algorandfoundation/algorand-typescript-testing/test-transformer'\n *\n * export default defineConfig({\n * esbuild: {},\n * plugins: [\n * typescript({\n * tsconfig: './tsconfig.json',\n * transformers: {\n * before: [puyaTsTransformer],\n * },\n * }),\n * ],\n * })\n */\nexport const puyaTsTransformer: ts.TransformerFactory<ts.SourceFile> &\n ((config: Partial<TransformerConfig>) => ts.TransformerFactory<ts.SourceFile>) = programTransformer as DeliberateAny\n\n// exporting values needed by ts-jest for a transformer to work\n// https://github.com/kulshekhar/ts-jest/tree/main/src/transformers\nexport const name = 'puyaTsTransformer'\nexport const version = '0.1.0'\nexport const factory = createProgramFactory(defaultTransformerConfig)\n"],"names":["factory"],"mappings":";;;;;AAAM,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;AACxF,CAAC;AAEM,MAAM,mBAAmB,GAAG,CAAC,QAAgB,KAAK,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;;ACPrF,MAAMA,SAAO,GAAG,EAAE,CAAC,OAAO;AACnB,MAAM,WAAW,GAAG;AACzB,IAAA,aAAa,CAAC,kBAA0B,EAAA;AACtC,QAAA,OAAOA,SAAO,CAAC,uBAAuB,CACpC,SAAS,EACTA,SAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAEA,SAAO,CAAC,qBAAqB,CAACA,SAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAC,EACvHA,SAAO,CAAC,mBA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