feat: add AppClient.resolvePc for TEAL/error mapping by program counter - #592
feat: add AppClient.resolvePc for TEAL/error mapping by program counter#592mitre88 wants to merge 1 commit into
Conversation
|
Hi @joe-p @mrcointreau, this PR is ready for review. It fixes #367 by adding |
38b9e78 to
88515d2
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a public API on AppClient to resolve a raw program counter (pc) into ARC-56 error/source details and (when available) TEAL line/text, enabling easier debugging when calls happen outside the AppClient context (per #367).
Changes:
- Add
AppClient.resolvePc(pc, ...)(static) andappClient.resolvePc(pc)(instance) plus aResolvedPcSourcereturn type. - Add Vitest coverage for ARC-56 mapping behavior and missing-program handling for
pcOffsetMethod: 'cblocks'. - Update dependency overrides / lockfile and expand PR workflow triggers to include
releasebranch.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/app-client.ts | Introduces ResolvedPcSource and new instance/static resolvePc APIs for PC→ARC-56/TEAL mapping. |
| src/types/app-client.resolve-pc.spec.ts | Adds tests validating ARC-56 error/line mapping and cblocks program-bytes requirement. |
| package.json | Adds additional overrides entries for security-related dependency constraints. |
| package-lock.json | Updates resolved dependency versions consistent with new overrides/audit fixes. |
| .nsprc | Updates audit suppression entries/expiries/notes for current advisories. |
| .github/workflows/pr.yml | Runs PR workflow for both main and release branches. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| import { readFileSync } from 'node:fs' | ||
| import { resolve } from 'node:path' | ||
| import { describe, expect, test } from 'vitest' | ||
| import { Arc56Contract } from './app-arc56' | ||
| import { AppClient } from './app-client' | ||
|
|
||
| const deployErrorSpec = JSON.parse( | ||
| readFileSync(resolve(__dirname, '../../tests/example-contracts/deploy_error/artifacts/DeployError.arc56.json'), 'utf-8'), | ||
| ) as Arc56Contract |
| "overrides": { | ||
| "esbuild": "0.25.0" | ||
| "esbuild": "0.25.0", | ||
| "cross-spawn": ">=7.0.5", | ||
| "brace-expansion": ">=5.0.9", | ||
| "picomatch": ">=4.0.2", | ||
| "postcss": ">=8.5.23" | ||
| }, |
Expose a public static and instance method that maps a raw program counter to ARC-56 error message, TEAL line, and source path without requiring a full logic-error string. Closes algorandfoundation#367.
c4ce8aa to
3bdfb7a
Compare
|
Retargeted to The spec loads the ARC-56 fixture via |
Summary
AppClient.resolvePc(pc, ...)(static) andappClient.resolvePc(pc)(instance) to map a raw program counter to ARC-56 error message, TEAL line, source path, and TEAL text.ResolvedPcSourceresult. Non-breaking additive API.pcOffsetMethod: 'cblocks'(requires program bytes) and falls back to ARC-56sourceInfo.tealwhen no source map is loaded.Context
Fixes #367. When a call happens outside the app client, callers often only have a
pcand cannot get aLogicErrorwith TEAL context. This exposes the same ARC-56 / source-map mapping used byexposeLogicErroras a simple lookup.Validation