Skip to content

Commit

Permalink
Merge main into release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 15, 2023
2 parents 58b7b98 + a778d5b commit 5a13aaf
Show file tree
Hide file tree
Showing 71 changed files with 1,782 additions and 436 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Check docs are up to date
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ npm install @algorandfoundation/algokit-utils

## Guiding principles

This library follows the [Guiding Principles of AlgoKit](https://github.com/algorandfoundation/algokit-cli/docs/algokit.md#guiding-principles).
This library follows the [Guiding Principles of AlgoKit](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/algokit.md#guiding-principles).

## Contributing

This is an open source project managed by the Algorand Foundation. See the [AlgoKit contributing page](https://github.com/algorandfoundation/algokit-cli/blob/main/CONTRIBUTING.MD) to learn about making improvements.
This is an open source project managed by the Algorand Foundation. See the [AlgoKit contributing page](https://github.com/algorandfoundation/algokit-cli/blob/main/CONTRIBUTING.md) to learn about making improvements.

To successfully run the tests in this repository you need to be running LocalNet via [AlgoKit](https://github.com/algorandfoundation/algokit-cli) and also have package dependencies and `.env.template` copied to `.env` (both of which `algokit bootstrap all` can do for you):

Expand Down
58 changes: 58 additions & 0 deletions docs/capabilities/debugging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Debugger

The AlgoKit TypeScript Utilities package provides a set of debugging tools that can be used to simulate and trace transactions on the Algorand blockchain. These tools and methods are optimized for developers who are building applications on Algorand and need to test and debug their smart contracts via [AlgoKit AVM Debugger extension](https://github.com/algorandfoundation/algokit-avm-vscode-debugger).

## Configuration

The `config.ts` file contains the `UpdatableConfig` class which manages and updates configuration settings for the AlgoKit project. The class has the following attributes:

- `debug`: Indicates whether debug mode is enabled.
- `projectRoot`: The path to the project root directory. Can be ignored if you are using `algokit-utils` inside an `algokit` compliant project (containing `.algokit.toml` file). For non algokit compliant projects, simply provide the path to the folder where you want to store sourcemaps and traces to be used with [`AlgoKit AVM Debugger`](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). Alternatively you can also set the value via the `ALGOKIT_PROJECT_ROOT` environment variable.
- `traceAll`: Indicates whether to trace all operations. Defaults to false, this means that when debug mode is enabled, any (or all) application client calls performed via `algokit-utils` will store responses from `simulate` endpoint. These files are called traces, and can be used with [AlgoKit AVM Debugger](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger) to debug TEAL source codes, and a large variety of transaction types in the atomic groups. Default behaviour will perform persistence of traces only on scenarios where any of the transaction groups emitted by an ApplicationClient or `sendAtomicTransactionComposer` method fails.
- `traceBufferSizeMb`: The size of the trace buffer in megabytes. By default uses 256 megabytes. When output folder containing debug trace files exceedes the size, oldest files are removed to optimize for storage consumption. This is useful when you are running a long running application and want to keep the trace files for debugging purposes but also be mindful of storage consumption.
- `maxSearchDepth`: The maximum depth to search for a an `algokit` config file. By default it will traverse at most `10` folders searching for `.algokit.toml` file which will be used to determine algokit compliant project root path.

The `configure` method can be used to set these attributes.

To enable debug mode in your project you can configure it as follows:

```ts
import { Config } from '@algorandfoundation/algokit-utils'
Config.configure({
debug: true,
})
```

## Debugging Utilities

Debugging utilities can be used to simplify gathering artifacts to be used with [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) in non algokit compliant projects. The following methods are provided:

- `persistSourceMaps`: This method persists the sourcemaps for the given sources as AlgoKit AVM Debugger compliant artifacts. It accepts an array of `PersistSourceMapInput` objects. Each object can either contain `rawTeal`, in which case the function will execute a compile to obtain byte code, or it can accept an object of type `CompiledTeal` provided by algokit, which is used for source codes that have already been compiled and contain the traces. It also accepts the root directory of the project, an `Algodv2` client to perform the compilation, and a boolean indicating whether to include the source files in the output.
- `simulateAndPersistResponse`: This method simulates the atomic transactions using the provided `AtomicTransactionComposer` object and `Algodv2` object, and persists the simulation response to an AlgoKit AVM Debugger compliant JSON file. It accepts the `AtomicTransactionComposer` with transaction(s) loaded, an `Algodv2` client to perform the simulation, the root directory of the project, and the buffer size in megabytes.

To enable debug mode with extra trace persistence for AVM VSCode Debugger, you can configure it as follows:

```ts
import { Config } from '@algorandfoundation/algokit-utils'
Config.configure({
debug: true,
traceAll: true, // if ignored, will only trace failed atomic transactions and application client calls
projectRoot: '/path/to/project/root', // if ignored, will try to find the project root automatically
})
```

### Trace filename format

The trace files are named in a specific format to provide useful information about the transactions they contain. The format is as follows:

```ts
;`${timestamp}_lr${lastRound}_${transactionTypes}.trace.avm.json`
```

Where:

- `timestamp`: The time when the trace file was created, in ISO 8601 format, with colons and periods removed.
- `lastRound`: The last round when the simulation was performed.
- `transactionTypes`: A string representing the types and counts of transactions in the atomic group. Each transaction type is represented as `${count}#${type}`, and different transaction types are separated by underscores.

For example, a trace file might be named `20220301T123456Z_lr1000_2#pay_1#axfer.trace.avm.json`, indicating that the trace file was created at `2022-03-01T12:34:56Z`, the last round was `1000`, and the atomic group contained 2 payment transactions and 1 asset transfer transaction.
1 change: 1 addition & 0 deletions docs/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [types/app-spec](modules/types_app_spec.md)
- [types/asset](modules/types_asset.md)
- [types/config](modules/types_config.md)
- [types/debugging](modules/types_debugging.md)
- [types/dispenser-client](modules/types_dispenser_client.md)
- [types/dispenser-client.spec](modules/types_dispenser_client_spec.md)
- [types/indexer](modules/types_indexer.md)
Expand Down
1 change: 0 additions & 1 deletion docs/code/classes/testing.TestLogger.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ The snapshotted logs.

**`Example`**

Jest Example
```typescript
const logger = new TestLogger()
...
Expand Down
4 changes: 2 additions & 2 deletions docs/code/classes/testing.TransactionLogger.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ ___

### waitForIndexer

**waitForIndexer**(`indexer`): `Promise`<`void`\>
**waitForIndexer**(`indexer`): `Promise`\<`void`\>

Wait until all logged transactions IDs appear in the given `Indexer`.

Expand All @@ -142,7 +142,7 @@ Wait until all logged transactions IDs appear in the given `Indexer`.

#### Returns

`Promise`<`void`\>
`Promise`\<`void`\>

#### Defined in

Expand Down
4 changes: 2 additions & 2 deletions docs/code/classes/types_account.MultisigAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ ___

### params

`get` **params**(): `Readonly`<`MultisigMetadata`\>
`get` **params**(): `Readonly`\<`MultisigMetadata`\>

The parameters for the multisig account

#### Returns

`Readonly`<`MultisigMetadata`\>
`Readonly`\<`MultisigMetadata`\>

#### Defined in

Expand Down
4 changes: 2 additions & 2 deletions docs/code/classes/types_account.SigningAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ ___

### sk

`get` **sk**(): `Readonly`<`Uint8Array`\>
`get` **sk**(): `Readonly`\<`Uint8Array`\>

Secret key belonging to the signer

#### Returns

`Readonly`<`Uint8Array`\>
`Readonly`\<`Uint8Array`\>

#### Implementation of

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ A HTTP Client that wraps the Algorand SDK HTTP Client with retries
| `tokenHeader` | [`TokenHeader`](../modules/types_urlTokenBaseHTTPClient.md#tokenheader) |
| `baseServer` | `string` |
| `port?` | `string` \| `number` |
| `defaultHeaders` | `Record`<`string`, `any`\> |
| `defaultHeaders` | `Record`\<`string`, `any`\> |

#### Returns

Expand Down Expand Up @@ -103,17 +103,17 @@ ___

### callWithRetry

**callWithRetry**(`func`): `Promise`<`BaseHTTPClientResponse`\>
**callWithRetry**(`func`): `Promise`\<`BaseHTTPClientResponse`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `func` | () => `Promise`<`BaseHTTPClientResponse`\> |
| `func` | () => `Promise`\<`BaseHTTPClientResponse`\> |

#### Returns

`Promise`<`BaseHTTPClientResponse`\>
`Promise`\<`BaseHTTPClientResponse`\>

#### Defined in

Expand All @@ -123,20 +123,20 @@ ___

### delete

**delete**(`relativePath`, `data`, `query?`, `requestHeaders?`): `Promise`<`BaseHTTPClientResponse`\>
**delete**(`relativePath`, `data`, `query?`, `requestHeaders?`): `Promise`\<`BaseHTTPClientResponse`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `relativePath` | `string` |
| `data` | `Uint8Array` |
| `query?` | `Query`<`string`\> |
| `requestHeaders` | `Record`<`string`, `string`\> |
| `query?` | `Query`\<`string`\> |
| `requestHeaders` | `Record`\<`string`, `string`\> |

#### Returns

`Promise`<`BaseHTTPClientResponse`\>
`Promise`\<`BaseHTTPClientResponse`\>

#### Overrides

Expand All @@ -150,19 +150,19 @@ ___

### get

**get**(`relativePath`, `query?`, `requestHeaders?`): `Promise`<`BaseHTTPClientResponse`\>
**get**(`relativePath`, `query?`, `requestHeaders?`): `Promise`\<`BaseHTTPClientResponse`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `relativePath` | `string` |
| `query?` | `Query`<`string`\> |
| `requestHeaders` | `Record`<`string`, `string`\> |
| `query?` | `Query`\<`string`\> |
| `requestHeaders` | `Record`\<`string`, `string`\> |

#### Returns

`Promise`<`BaseHTTPClientResponse`\>
`Promise`\<`BaseHTTPClientResponse`\>

#### Overrides

Expand All @@ -176,20 +176,20 @@ ___

### post

**post**(`relativePath`, `data`, `query?`, `requestHeaders?`): `Promise`<`BaseHTTPClientResponse`\>
**post**(`relativePath`, `data`, `query?`, `requestHeaders?`): `Promise`\<`BaseHTTPClientResponse`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `relativePath` | `string` |
| `data` | `Uint8Array` |
| `query?` | `Query`<`string`\> |
| `requestHeaders` | `Record`<`string`, `string`\> |
| `query?` | `Query`\<`string`\> |
| `requestHeaders` | `Record`\<`string`, `string`\> |

#### Returns

`Promise`<`BaseHTTPClientResponse`\>
`Promise`\<`BaseHTTPClientResponse`\>

#### Overrides

Expand Down
2 changes: 1 addition & 1 deletion docs/code/classes/types_amount.AlgoAmount.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Wrapper class to ensure safe, explicit conversion between µAlgos, Algos and num

| Name | Type |
| :------ | :------ |
| `amount` | { `algos`: `number` } \| { `microAlgos`: `number` } |
| `amount` | \{ `algos`: `number` } \| \{ `microAlgos`: `number` } |

#### Returns

Expand Down
Loading

0 comments on commit 5a13aaf

Please sign in to comment.