Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
1689629
Merge pull request #69 from algorandfoundation/update-alpha
boblat Mar 31, 2025
eb2a40b
Merge pull request #71 from algorandfoundation/update-alpha
boblat Apr 15, 2025
9fb1668
feat: implement stubs for Box create, and no arg ctors
boblat Mar 31, 2025
51d68f6
feat: implement stubs for encode/decode native arrays
boblat Apr 7, 2025
05a92d1
feat: recognise conventional methods and use appropriate
boblat Apr 15, 2025
2a69a0d
fix: encode bigint values as bytes correctly without overflowing
boblat Apr 16, 2025
d0e38f4
Merge pull request #72 from algorandfoundation/feat/box-array-5
boblat Apr 17, 2025
93c826b
feat: support not expressions on match and assertMatch
boblat Apr 24, 2025
495b669
Merge pull request #73 from algorandfoundation/feat/not
boblat Apr 29, 2025
6032c0f
chore: update dependencies
boblat May 8, 2025
2932aae
feat: allow tuples and objects to be stored in box, local, and global…
boblat May 8, 2025
5751083
Merge pull request #74 from algorandfoundation/feat/tuple-storage
boblat May 9, 2025
aefabb4
feat: include a `ref` property on the `Box` type which can be used to…
boblat May 8, 2025
ee8c1df
Merge pull request #75 from algorandfoundation/feat/box.ref
boblat May 12, 2025
93e5dee
chore: update versions of puya dependencies
boblat May 13, 2025
30e01e8
Merge pull request #76 from algorandfoundation/chore/update-dep
boblat May 13, 2025
630f576
fix: arc4 encoded length of native boolean should be 1 instead of 8
boblat May 13, 2025
8a47c6b
Merge pull request #78 from algorandfoundation/fix/type-length
boblat May 14, 2025
e507637
feat: Add length generic to bytes type for declaring statically sized…
boblat May 19, 2025
80c3f11
chore: bump node version to 22 to match puya-ts
boblat May 22, 2025
438bf68
Merge pull request #79 from algorandfoundation/feat/static-bytes
boblat May 23, 2025
363614f
feat: implement ItxnCompose type for composing variable length transa…
boblat May 12, 2025
8571d92
Merge pull request #77 from algorandfoundation/feat/itxn-compose
boblat May 23, 2025
21d8601
refactor: split off encoded-types file and consolidate encoders
boblat May 23, 2025
b49ecd2
feat: implement clone function
boblat Jun 9, 2025
9d99af0
feat: implement mutable object
boblat Jun 10, 2025
6a905f6
implement FixedArray and increase test coverage
boblat Jun 27, 2025
ba72eb4
add encode decode tests for native arrays and objects
boblat Jul 14, 2025
13e22f4
fix assert match implementation to compare array lengths
boblat Jul 15, 2025
518d70e
upgrade algorand-typescript version and rename UintN, UFixedNxM
boblat Jul 24, 2025
500265e
treat `byets<N>` type as statically sized
boblat Jul 24, 2025
9699d07
pass `foreign_key` as `resourceEncoding` to keep old behvaiour for now
boblat Jul 28, 2025
dbbe7a4
implement `resourceEncoding: Value` as default
boblat Aug 6, 2025
6b736b5
chore: update docs
boblat Aug 6, 2025
d7a6a4b
use lowercase for resourceEncoding options
boblat Aug 7, 2025
ffff719
refactor: replace `Impl` pattern for stubbing in testing implementation
boblat Aug 7, 2025
b37b66c
chore: update puya-ts dependency
boblat Aug 8, 2025
95878de
Merge pull request #80 from algorandfoundation/native-mutable-types
boblat Aug 8, 2025
7631c8a
docs: add a section to describe puyaTsTransformer scope
boblat Aug 8, 2025
c73d624
Merge pull request #85 from algorandfoundation/docs/simulate-avm
boblat Aug 8, 2025
168e634
docs: add notes on transformer providing testing implementation of al…
boblat Aug 11, 2025
df1a442
refactor: change test file extensions to opt-in to puyaTsTransformer
boblat Aug 11, 2025
83e4616
Merge pull request #87 from algorandfoundation/refactor/spec-suffix
boblat Aug 12, 2025
146f997
build: Create patch release for refactor commits
boblat Aug 12, 2025
74e9cd7
Merge pull request #89 from algorandfoundation/fix/no-release-on-refa…
boblat Aug 12, 2025
15809dc
chore: delete internal type definitions from package
boblat Aug 11, 2025
3cfccbf
move toExternalValue function to util since impl types are not exported
boblat Aug 12, 2025
49550e0
prevent unnecessary processing of symbols loaded from testing package…
boblat Aug 13, 2025
535393b
refactor: explicitly mark the items which should not be visible exter…
boblat Aug 12, 2025
b18ef44
refactor: remove checked in generated doc and publish html doc to gi…
boblat Aug 13, 2025
9e66da5
docs: fix testing guide link
boblat Aug 15, 2025
8ce9d46
chore: add more @internal flags
boblat Aug 15, 2025
b81f4b0
docs: fix more broken links
boblat Aug 15, 2025
73842b7
Merge pull request #88 from algorandfoundation/chore/exclude-impl
boblat Aug 15, 2025
fa2f3af
fix: do not encode reference types as foreign array index
boblat Aug 15, 2025
59e7963
Merge pull request #90 from algorandfoundation/fix/resource-encoding
boblat Sep 1, 2025
0f13355
feat: add stub implementations for additional 1.0 features
boblat Sep 2, 2025
cc8ded2
refactor: use WeakMap to store contract name to class map
boblat Sep 3, 2025
387f005
chore: update puya-ts dependencies
boblat Sep 4, 2025
782af0e
docs: update docs for abiCall signature change
boblat Sep 4, 2025
4edce80
add tests for circular reference
boblat Sep 4, 2025
7d8f820
Merge pull request #91 from algorandfoundation/feat/feedback-features
boblat Sep 4, 2025
fb5891d
feat: replace .native property with .as_uint64() and .as_biguint() me…
boblat Sep 5, 2025
f4c737d
chore: update dependencies and fix audit vulnerabilities
boblat Sep 12, 2025
4cfc405
Merge pull request #92 from algorandfoundation/feat/native-funcs
boblat Sep 12, 2025
dcb3dd0
feat: make BoxRef methods directly accessible on Box class
boblat Sep 15, 2025
a8cf7cf
Merge pull request #93 from algorandfoundation/feat/replace-box-ref
boblat Sep 17, 2025
e80d847
refactor: rename `interpretAsArc4` function as `convertBytes` with `s…
boblat Sep 16, 2025
9495cc9
Merge pull request #94 from algorandfoundation/refactor/rename-interp…
boblat Sep 18, 2025
ab53bd3
feat: update langspec to v4.3.0
boblat Sep 18, 2025
38e0c38
test: add mock test for falconVerify
boblat Sep 23, 2025
e59da62
refactor: simplify test transformer as Bytes factor method now always…
boblat Sep 23, 2025
45511a9
Merge pull request #95 from algorandfoundation/update-langspec
boblat Sep 23, 2025
1d574c1
Merge pull request #96 from algorandfoundation/fix/empty-bytes
boblat Sep 26, 2025
780aa79
docs: fix typos and broken links
boblat Sep 30, 2025
315d53c
refactor: allow fixed sized bytes to be created by Bytes factory meth…
boblat Sep 26, 2025
55611b7
Merge pull request #97 from algorandfoundation/refactor/bytes
boblat Oct 2, 2025
99f3a00
Merge pull request #98 from algorandfoundation/docs/typos
boblat Oct 2, 2025
acfb4f1
feat: add support for ABI validation (#99)
boblat Oct 20, 2025
ff6188f
refactor: create new scope in beforeAll | beforeEach as part of creat…
boblat Oct 23, 2025
7ccaf1a
refactor: update test fixture factory methods to take options object
boblat Oct 23, 2025
5d28f00
fix audit vulnerability
boblat Oct 23, 2025
32b0078
Merge pull request #101 from algorandfoundation/refactor/tests
boblat Oct 23, 2025
8989a8a
feat: update puya-ts dependency versions
boblat Oct 28, 2025
fc179f4
Merge pull request #103 from algorandfoundation/update-dep
boblat Oct 28, 2025
eeb4104
Merge branch 'main' into update-alpha
boblat Oct 28, 2025
1399fea
Merge pull request #104 from algorandfoundation/update-alpha
boblat Oct 28, 2025
c22ecda
refactor: manually publish production releases from release branch only
boblat Oct 28, 2025
8d65dfd
remove extra flag to control prod release from release branch
boblat Oct 29, 2025
ba87358
comment out publish steps to make sure 1.0 is not published again
boblat Oct 29, 2025
254abae
publish docs only from release branch
boblat Oct 30, 2025
186f333
skip tagging a new beta version for main branch
boblat Oct 30, 2025
486a67a
chore: temporarily disable success comments
boblat Oct 30, 2025
b8f0fb3
chore: temporarily prevent beta release
boblat Oct 30, 2025
f0045af
update puya-ts dependencies
boblat Oct 30, 2025
6967cd9
chore: tweak release message
neilcampbell Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PUYA_PATH="<ABSOLUTE_PATH_TO_PUYA>" # e.g. '/home/parallels/.local/bin/puya'
35 changes: 35 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Run typedoc and publish to pages'

on:
workflow_call:
workflow_dispatch:

jobs:
build-and-publish-docs:
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x

- name: Npm install
run: npm ci --ignore-scripts

- name: Build doc
run: npm run script:documentation

- name: Upload to GitHub pages
uses: actions/upload-pages-artifact@v3
with:
path: docs/_html

- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
pipx install algokit --python 3.12.6
algokit localnet reset --update
pipx install puyapy --python 3.12.6
node-version: 20.x
node-version: 22.x
run-build: true
run-commit-lint: true
audit-script: npm run audit
45 changes: 45 additions & 0 deletions .github/workflows/prod-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Prod Publish

on:
workflow_dispatch:

permissions:
contents: write

jobs:
prod_release:
runs-on: ubuntu-latest
steps:
- name: Generate bot token
uses: actions/create-github-app-token@v1
id: app_token
with:
app-id: ${{ secrets.BOT_ID }}
private-key: ${{ secrets.BOT_SK }}

- uses: actions/checkout@v4
with:
# Fetch entire repository history so we can determine version number from it
fetch-depth: 0
token: ${{ steps.app_token.outputs.token }}

- name: Set Git user as GitHub actions
run: git config --global user.email "179917785+engineering-ci[bot]@users.noreply.github.com" && git config --global user.name "engineering-ci[bot]"

- name: Merge main -> release
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f
with:
type: now
from_branch: main
target_branch: release
github_token: ${{ steps.app_token.outputs.token }}

- name: Merge release -> main
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f
with:
type: now
from_branch: release
target_branch: main
github_token: ${{ steps.app_token.outputs.token }}
env:
INPUT_MESSAGE: 'Merge release back to main to get version increment [no ci]'
33 changes: 22 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
pipx install algokit
algokit localnet reset --update
pipx install puyapy
node-version: 20.x
node-version: 22.x
run-build: true
run-commit-lint: true
audit-script: npm run audit
Expand All @@ -49,10 +49,10 @@ jobs:
fetch-depth: 0
token: ${{ steps.app_token.outputs.token }}

- name: Use Node.js 20.x
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x

- run: npm ci --ignore-scripts

Expand All @@ -62,15 +62,26 @@ jobs:
path: artifacts

- name: Generate semantic version for @algorandfoundation/algorand-typescript-testing
if: github.ref_name != 'main'
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ steps.app_token.outputs.token }}

- name: Publish @algorandfoundation/algorand-typescript-testing
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
package: artifacts/algo-ts-testing/package.json
access: 'public'
# Tagging 'main' branch with latest for now, even though it's beta because we don't have a non-beta
tag: ${{ github.ref_name == 'alpha' && 'alpha' || github.ref_name == 'main' && 'latest' || github.ref_name == 'release' && 'latest' || 'pre-release' }}
# - name: Publish @algorandfoundation/algorand-typescript-testing
# if: github.ref_name != 'main'
# uses: JS-DevTools/npm-publish@v3
# with:
# token: ${{ secrets.NPM_TOKEN }}
# package: artifacts/algo-ts-testing/package.json
# access: 'public'
# tag: ${{ github.ref_name == 'alpha' && 'alpha' || github.ref_name == 'main' && 'beta' || github.ref_name == 'release' && 'latest' || 'pre-release' }}

# publish-docs:
# name: Publish docs
# needs: release
# if: github.ref_name == 'release'
# uses: ./.github/workflows/gh-pages.yml
# permissions:
# contents: read
# pages: write
# id-token: write
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ test-results.xml
# Website & Code docs generation
code-docs/
out/
docs/_html

# dotenv environment variable files
.env
Expand Down
11 changes: 10 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
{
"type": "chore",
"release": "patch"
},
{
"type": "refactor",
"release": "patch"
}
]
}
Expand Down Expand Up @@ -59,6 +63,11 @@
"pkgRoot": "artifacts/algo-ts-testing"
}
],
"@semantic-release/github"
[
"@semantic-release/github",
{
"successComment": false
}
]
]
}
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![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)
[![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/)

`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.
`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 behaviours without requiring a network connection, offering fast and reliable testing capabilities with a familiar TypeScript interface.

The `algorand-typescript-testing` package provides:

Expand Down Expand Up @@ -42,6 +42,16 @@ npm i @algorandfoundation/algorand-typescript-testing

Let's write a simple contract and test it using the `algorand-typescript-testing` framework.

#### Simulating AVM

`algorand-typescript-testing` includes a TypeScript transformer (`puyaTsTransformer`) that ensures contracts (with `.algo.ts` extension) and tests (with `.algo.spec.ts` or `.algo.test.ts` extensions) behave consistently between Node.js and AVM environments.

The transformer replicates AVM behaviour, such as integer-only arithmetic where `3 / 2` produces `1`. For code requiring standard Node.js behaviour (e.g., `3 / 2` produces `1.5`), place it in separate `.ts` files and reference them from test files.

The transformer also redirects `@algorandfoundation/algorand-typescript` imports to `@algorandfoundation/algorand-typescript-testing/internal` to provide executable implementations of Algorand TypeScript constructs like `Global`, `Box`, `Uint64`, and `clone`.

If there are tests which do not need to be executed in the AVM context such as end to end tests, simply use `.test.ts` or `.spec.ts` file extensions without `.algo` part and the transformer would skip them.

#### Configuring vitest

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 the `typescript` plugin in `vitest.config.mts` file.
Expand Down Expand Up @@ -87,7 +97,7 @@ import { createDefaultEsmPreset, type JestConfigWithTsJest } from 'ts-jest'
const presetConfig = createDefaultEsmPreset({})
const jestConfig: JestConfigWithTsJest = {
...presetConfig,
testMatch: ['**/*.test.ts'],
testMatch: ['**/*.algo.test.ts'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
transform: {
'^.+\\.tsx?$': [
Expand Down Expand Up @@ -159,7 +169,19 @@ After the setup, the examples provided using `vitest` can be converted to work w
#### Contract Definition

```typescript
import { arc4, assert, Bytes, GlobalState, gtxn, LocalState, op, Txn, uint64, Uint64 } from '@algorandfoundation/algorand-typescript'
import {
arc4,
assert,
Bytes,
GlobalState,
gtxn,
LocalState,
op,
readonly,
Txn,
uint64,
Uint64,
} from '@algorandfoundation/algorand-typescript'

export default class VotingContract extends arc4.Contract {
topic = GlobalState({ initialValue: 'default_topic', key: Bytes('topic') })
Expand All @@ -185,7 +207,7 @@ export default class VotingContract extends arc4.Contract {
return true
}

@arc4.abimethod({ readonly: true })
@readonly
public getVotes(): uint64 {
return this.votes.value
}
Expand Down Expand Up @@ -252,7 +274,7 @@ This example demonstrates key aspects of testing with `algorand-typescript-testi

- Use of `arc4.Contract` as the base class for the contract.
- ABI methods defined using the `@arc4.abimethod` decorator.
- Readonly method annotation with `@arc4.abimethod({readonly: true})`.
- Readonly method annotation with `@arc4.abimethod({readonly: true})` or `@readonly`.

2. Testing ARC4 Contracts:

Expand All @@ -277,9 +299,9 @@ To dig deeper into the capabilities of `algorand-typescript-testing`, continue w

#### Contents

- [Testing Guide](./docs/testing-guide/index.md)
- [Testing Guide](./docs/testing-guide.md)
- [Examples](./docs/examples.md)
- [Coverage](./docs/coverage.md)
- [FQA](./docs/faq.md)
- [FAQ](./docs/faq.md)
- [API Reference](./docs/api.md)
- [Algorand TypeScript](./docs/algots.md)
14 changes: 8 additions & 6 deletions docs/algots.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
title: Algorand TypeScript
---

# Algorand TypeScript

Algorand TypeScript is a partial implementation of the TypeScript programming language that runs on the Algorand Virtual Machine (AVM). It includes a statically typed framework for development of Algorand smart contracts and logic signatures, with TypeScript interfaces to underlying AVM functionality that works with standard TypeScript tooling.
Algorand TypeScript is a partial implementation of the TypeScript programming language that runs on the Algorand Virtual Machine (AVM). It includes a statically typed framework for developing Algorand smart contracts and logic signatures, and provides TypeScript interfaces to underlying AVM functionality that work with standard TypeScript tooling.

It maintains the syntax and semantics of TypeScript such that a developer who knows TypeScript can make safe assumptions
about the behaviour of the compiled code when running on the AVM. Algorand TypeScript is also executable TypeScript that can be run
and debugged on a Node.js virtual machine with transpilation to EcmaScript and run from automated tests.
It preserves the syntax and semantics of TypeScript so that a developer who knows TypeScript can make safe assumptions about the behaviour of the compiled code when running on the AVM. Algorand TypeScript is also executable TypeScript that can be run and debugged on Node.js after transpilation to ECMAScript and run from automated tests.

Algorand TypeScript is compiled for execution on the AVM by PuyaTs, a TypeScript frontend for the [Puya](https://github.com/algorandfoundation/puya) optimising compiler that ensures the resulting AVM bytecode execution semantics that match the given TypeScript code. PuyaTs produces output that is directly compatible with AlgoKit typed clients to make deployment and calling easy.
Algorand TypeScript is compiled for execution on the AVM by PuyaTs, a TypeScript frontend for the [Puya](https://github.com/algorandfoundation/puya) optimising compiler. PuyaTs ensures the resulting AVM bytecode has execution semantics that match the given TypeScript code, and it produces output that is directly compatible with AlgoKit typed clients to simplify deployment and invocation.

[Documentation](https://github.com/algorandfoundation/puya-ts/blob/main/README.md)
[Documentation](https://algorandfoundation.github.io/puya-ts/index.html)
28 changes: 15 additions & 13 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
---
title: API Reference
---

# API Reference

An overview of the `algorand-typescript-testing` package - covering the main classes and functions.

```{hint}
Spotted a typo in documentation? This project is open source, please submit an issue or a PR on [GitHub](https://github.com/algorandfoundation/algorand-typescript-testing).
```
> Spotted a typo in the documentation? This project is open source; please submit an issue or a PR on [GitHub](https://github.com/algorandfoundation/algorand-typescript-testing).

## Contexts

- [TestExecutionContext](./code/index/classes/TestExecutionContext.md)
- [ContractContext](./code/subcontexts/contract-context/classes/ContractContext.md)
- [LedgerContext](./code/subcontexts/ledger-context/classes/LedgerContext.md)
- [TransactionContext](./code/subcontexts/transaction-context/classes/TransactionContext.md)
- [TestExecutionContext](../classes/index.TestExecutionContext.html)
- [ContractContext](../classes/index._internal_.ContractContext.html)
- [LedgerContext](../classes/index._internal_.LedgerContext.html)
- [TransactionContext](../classes/index._internal_.TransactionContext.html)

## Value Generators

- [AvmValueGenerator](./code/value-generators/avm/classes/AvmValueGenerator.md)
- [Arc4ValueGenerator](./code/value-generators/arc4/classes/Arc4ValueGenerator.md)
- [TxnValueGenerator](./code/value-generators/txn/classes/TxnValueGenerator.md)
- [AvmValueGenerator](../classes/value-generators._internal_.AvmValueGenerator.html)
- [Arc4ValueGenerator](../classes/value-generators._internal_.Arc4ValueGenerator.html)
- [TxnValueGenerator](../classes/value-generators._internal_.TxnValueGenerator.html)

## Utils

- [addEqualityTesters](./code/index/functions/addEqualityTesters.md)
- [encodingUtils](./code/index/variables/encodingUtil.md)
- [addEqualityTesters](../functions/index.addEqualityTesters.html)
- [toExternalValue](../functions/index.toExternalValue.html)

## Reference documentation

We also have [auto-generated reference documentation for the code](./code/README.md).
We also have [auto-generated reference documentation for the code](../modules/index.html).
18 changes: 0 additions & 18 deletions docs/code/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions docs/code/index/README.md

This file was deleted.

Loading