Skip to content

Commit 99f5c07

Browse files
authored
Merge pull request #105 from algorandfoundation/update-main
Update main
2 parents 28eebfc + 6967cd9 commit 99f5c07

File tree

226 files changed

+10806
-9034
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+10806
-9034
lines changed

.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PUYA_PATH="<ABSOLUTE_PATH_TO_PUYA>" # e.g. '/home/parallels/.local/bin/puya'

.github/workflows/gh-pages.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'Run typedoc and publish to pages'
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build-and-publish-docs:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
steps:
15+
- name: Checkout source code
16+
uses: actions/checkout@v4
17+
18+
- name: Use Node.js 22.x
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 22.x
22+
23+
- name: Npm install
24+
run: npm ci --ignore-scripts
25+
26+
- name: Build doc
27+
run: npm run script:documentation
28+
29+
- name: Upload to GitHub pages
30+
uses: actions/upload-pages-artifact@v3
31+
with:
32+
path: docs/_html
33+
34+
- name: Deploy to GitHub Pages
35+
uses: actions/deploy-pages@v4

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
pipx install algokit --python 3.12.6
2222
algokit localnet reset --update
2323
pipx install puyapy --python 3.12.6
24-
node-version: 20.x
24+
node-version: 22.x
2525
run-build: true
2626
run-commit-lint: true
2727
audit-script: npm run audit

.github/workflows/prod-release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Prod Publish
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
prod_release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Generate bot token
14+
uses: actions/create-github-app-token@v1
15+
id: app_token
16+
with:
17+
app-id: ${{ secrets.BOT_ID }}
18+
private-key: ${{ secrets.BOT_SK }}
19+
20+
- uses: actions/checkout@v4
21+
with:
22+
# Fetch entire repository history so we can determine version number from it
23+
fetch-depth: 0
24+
token: ${{ steps.app_token.outputs.token }}
25+
26+
- name: Set Git user as GitHub actions
27+
run: git config --global user.email "179917785+engineering-ci[bot]@users.noreply.github.com" && git config --global user.name "engineering-ci[bot]"
28+
29+
- name: Merge main -> release
30+
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f
31+
with:
32+
type: now
33+
from_branch: main
34+
target_branch: release
35+
github_token: ${{ steps.app_token.outputs.token }}
36+
37+
- name: Merge release -> main
38+
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f
39+
with:
40+
type: now
41+
from_branch: release
42+
target_branch: main
43+
github_token: ${{ steps.app_token.outputs.token }}
44+
env:
45+
INPUT_MESSAGE: 'Merge release back to main to get version increment [no ci]'

.github/workflows/release.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
pipx install algokit
2525
algokit localnet reset --update
2626
pipx install puyapy
27-
node-version: 20.x
27+
node-version: 22.x
2828
run-build: true
2929
run-commit-lint: true
3030
audit-script: npm run audit
@@ -49,10 +49,10 @@ jobs:
4949
fetch-depth: 0
5050
token: ${{ steps.app_token.outputs.token }}
5151

52-
- name: Use Node.js 20.x
52+
- name: Use Node.js 22.x
5353
uses: actions/setup-node@v4
5454
with:
55-
node-version: 20.x
55+
node-version: 22.x
5656

5757
- run: npm ci --ignore-scripts
5858

@@ -62,15 +62,26 @@ jobs:
6262
path: artifacts
6363

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

69-
- name: Publish @algorandfoundation/algorand-typescript-testing
70-
uses: JS-DevTools/npm-publish@v3
71-
with:
72-
token: ${{ secrets.NPM_TOKEN }}
73-
package: artifacts/algo-ts-testing/package.json
74-
access: 'public'
75-
# Tagging 'main' branch with latest for now, even though it's beta because we don't have a non-beta
76-
tag: ${{ github.ref_name == 'alpha' && 'alpha' || github.ref_name == 'main' && 'latest' || github.ref_name == 'release' && 'latest' || 'pre-release' }}
70+
# - name: Publish @algorandfoundation/algorand-typescript-testing
71+
# if: github.ref_name != 'main'
72+
# uses: JS-DevTools/npm-publish@v3
73+
# with:
74+
# token: ${{ secrets.NPM_TOKEN }}
75+
# package: artifacts/algo-ts-testing/package.json
76+
# access: 'public'
77+
# tag: ${{ github.ref_name == 'alpha' && 'alpha' || github.ref_name == 'main' && 'beta' || github.ref_name == 'release' && 'latest' || 'pre-release' }}
78+
79+
# publish-docs:
80+
# name: Publish docs
81+
# needs: release
82+
# if: github.ref_name == 'release'
83+
# uses: ./.github/workflows/gh-pages.yml
84+
# permissions:
85+
# contents: read
86+
# pages: write
87+
# id-token: write

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ test-results.xml
5555
# Website & Code docs generation
5656
code-docs/
5757
out/
58+
docs/_html
5859

5960
# dotenv environment variable files
6061
.env

.releaserc.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
{
2626
"type": "chore",
2727
"release": "patch"
28+
},
29+
{
30+
"type": "refactor",
31+
"release": "patch"
2832
}
2933
]
3034
}
@@ -59,6 +63,11 @@
5963
"pkgRoot": "artifacts/algo-ts-testing"
6064
}
6165
],
62-
"@semantic-release/github"
66+
[
67+
"@semantic-release/github",
68+
{
69+
"successComment": false
70+
}
71+
]
6372
]
6473
}

README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![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)
66
[![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/)
77

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

1010
The `algorand-typescript-testing` package provides:
1111

@@ -42,6 +42,16 @@ npm i @algorandfoundation/algorand-typescript-testing
4242

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

45+
#### Simulating AVM
46+
47+
`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.
48+
49+
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.
50+
51+
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`.
52+
53+
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.
54+
4555
#### Configuring vitest
4656

4757
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.
@@ -87,7 +97,7 @@ import { createDefaultEsmPreset, type JestConfigWithTsJest } from 'ts-jest'
8797
const presetConfig = createDefaultEsmPreset({})
8898
const jestConfig: JestConfigWithTsJest = {
8999
...presetConfig,
90-
testMatch: ['**/*.test.ts'],
100+
testMatch: ['**/*.algo.test.ts'],
91101
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
92102
transform: {
93103
'^.+\\.tsx?$': [
@@ -159,7 +169,19 @@ After the setup, the examples provided using `vitest` can be converted to work w
159169
#### Contract Definition
160170

161171
```typescript
162-
import { arc4, assert, Bytes, GlobalState, gtxn, LocalState, op, Txn, uint64, Uint64 } from '@algorandfoundation/algorand-typescript'
172+
import {
173+
arc4,
174+
assert,
175+
Bytes,
176+
GlobalState,
177+
gtxn,
178+
LocalState,
179+
op,
180+
readonly,
181+
Txn,
182+
uint64,
183+
Uint64,
184+
} from '@algorandfoundation/algorand-typescript'
163185

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

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

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

257279
2. Testing ARC4 Contracts:
258280

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

278300
#### Contents
279301

280-
- [Testing Guide](./docs/testing-guide/index.md)
302+
- [Testing Guide](./docs/testing-guide.md)
281303
- [Examples](./docs/examples.md)
282304
- [Coverage](./docs/coverage.md)
283-
- [FQA](./docs/faq.md)
305+
- [FAQ](./docs/faq.md)
284306
- [API Reference](./docs/api.md)
285307
- [Algorand TypeScript](./docs/algots.md)

docs/algots.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
---
2+
title: Algorand TypeScript
3+
---
4+
15
# Algorand TypeScript
26

3-
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.
7+
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.
48

5-
It maintains the syntax and semantics of TypeScript such that a developer who knows TypeScript can make safe assumptions
6-
about the behaviour of the compiled code when running on the AVM. Algorand TypeScript is also executable TypeScript that can be run
7-
and debugged on a Node.js virtual machine with transpilation to EcmaScript and run from automated tests.
9+
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.
810

9-
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.
11+
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.
1012

11-
[Documentation](https://github.com/algorandfoundation/puya-ts/blob/main/README.md)
13+
[Documentation](https://algorandfoundation.github.io/puya-ts/index.html)

docs/api.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1+
---
2+
title: API Reference
3+
---
4+
15
# API Reference
26

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

5-
```{hint}
6-
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).
7-
```
9+
> 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).
810
911
## Contexts
1012

11-
- [TestExecutionContext](./code/index/classes/TestExecutionContext.md)
12-
- [ContractContext](./code/subcontexts/contract-context/classes/ContractContext.md)
13-
- [LedgerContext](./code/subcontexts/ledger-context/classes/LedgerContext.md)
14-
- [TransactionContext](./code/subcontexts/transaction-context/classes/TransactionContext.md)
13+
- [TestExecutionContext](../classes/index.TestExecutionContext.html)
14+
- [ContractContext](../classes/index._internal_.ContractContext.html)
15+
- [LedgerContext](../classes/index._internal_.LedgerContext.html)
16+
- [TransactionContext](../classes/index._internal_.TransactionContext.html)
1517

1618
## Value Generators
1719

18-
- [AvmValueGenerator](./code/value-generators/avm/classes/AvmValueGenerator.md)
19-
- [Arc4ValueGenerator](./code/value-generators/arc4/classes/Arc4ValueGenerator.md)
20-
- [TxnValueGenerator](./code/value-generators/txn/classes/TxnValueGenerator.md)
20+
- [AvmValueGenerator](../classes/value-generators._internal_.AvmValueGenerator.html)
21+
- [Arc4ValueGenerator](../classes/value-generators._internal_.Arc4ValueGenerator.html)
22+
- [TxnValueGenerator](../classes/value-generators._internal_.TxnValueGenerator.html)
2123

2224
## Utils
2325

24-
- [addEqualityTesters](./code/index/functions/addEqualityTesters.md)
25-
- [encodingUtils](./code/index/variables/encodingUtil.md)
26+
- [addEqualityTesters](../functions/index.addEqualityTesters.html)
27+
- [toExternalValue](../functions/index.toExternalValue.html)
2628

2729
## Reference documentation
2830

29-
We also have [auto-generated reference documentation for the code](./code/README.md).
31+
We also have [auto-generated reference documentation for the code](../modules/index.html).

0 commit comments

Comments
 (0)