npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@algorandfoundation/algokit-utils-debug

v1.0.2

Published

A set of addon utilities for generating artifacts for use with AlgoKit AVM Debugger VSCode extension.

Downloads

180

Readme

AlgoKit TypeScript AVM Debugging Utilities

An optional addon package for algokit-utils-ts that provides node specific utilities that automatically gather artifacts required for instantiating AlgoKit AVM VSCode Debugger Extension. This project is part of AlgoKit.

Note: Python's version of algokit-utils contains the same functionality without requiring a separate package install. Consider using that if you are building your AlgoKit project in Python.

Install | Documentation

Install

This library can be installed from NPM using your favourite npm client, e.g.:

npm install @algorandfoundation/algokit-utils-debug

Then to import it and activate utils-ts debugging:

import { Config } from '@algorandfoundation/algokit-utils'
import { registerDebugEventHandlers() } from '@algorandfoundation/algokit-utils-debug'

Config.configure({
  debug: true,
  traceAll: true, // optional, defaults to false, ignoring simulate on successfull transactions.
  projectRoot: '/path/to/project/root', // if not set, this package will try to find the project root automatically using either the 'ALGOKIT_PROJECT_ROOT' environment variable or by searching you project structure
  traceBufferSizeMb: 256, // optional, defaults to 256 megabytes. When the output folder containing debug trace files exceeds 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: 10, // optional, defaults to 10. The maximum depth to search for an `algokit` config file. By default it will traverse at most `10` folders searching for `.algokit.toml` file which will be used to determine the algokit compliant project root path. Ignored if `projectRoot` is provided directly or via `ALGOKIT_PROJECT_ROOT` environment variable.
})
registerDebugEventHandlers() // IMPORTANT: must be called before any transactions are submitted.

See code documentation for more details.

Overview

This library provides three main functions for debugging Algorand smart contracts:

  1. registerDebugEventHandlers: The primary function users need to call. It sets up listeners for debugging events emitted by algokit-utils-ts (see AsyncEventEmitter docs for more details). Must be called before submitting transactions and enabling debug mode in the algokit-utils-ts config.

  2. writeTealDebugSourceMaps: Generates and persists AlgoKit AVM Debugger-compliant sourcemaps. It processes an array of PersistSourceMapInput objects, which can contain either raw TEAL or pre-compiled TEAL from algokit.

  3. writeAVMDebugTrace: Simulates atomic transactions and saves the simulation response as an AlgoKit AVM Debugger-compliant JSON file. It uses the provided AtomicTransactionComposer and Algodv2 client for simulation.

Default artifact folders

  • {ALGOKIT_PROJECT_ROOT}/.algokit/sources/*: The folder containing the TEAL source maps and raw TEAL files.
  • {ALGOKIT_PROJECT_ROOT}/debug_traces: The folder containing the AVM debug traces.

Note, TEAL source maps are suffixed with .teal.map (previously .teal.tok.map from algokit-utils-ts <=v6.x) file extension, while Algorand Python source maps are suffixed with .puya.map.

Trace filename format

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

;`${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_2pay_1axfer.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.

Guiding principles

This library follows the Guiding Principles of AlgoKit.

Contributing

This is an open source project managed by the Algorand Foundation. See the AlgoKit contributing page to learn about making improvements.

To successfully run the tests in this repository you need to be running LocalNet via AlgoKit and also have package dependencies and .env.template copied to .env (both of which algokit bootstrap all can do for you):

algokit bootstrap all
algokit localnet start

To run tests you can use VS Code, or:

npm run test