Skip to content

feat: add AppClient.resolvePc for TEAL/error mapping by program counter - #592

Open
mitre88 wants to merge 1 commit into
algorandfoundation:mainfrom
mitre88:mitre88/feat/app-client-resolve-pc
Open

feat: add AppClient.resolvePc for TEAL/error mapping by program counter#592
mitre88 wants to merge 1 commit into
algorandfoundation:mainfrom
mitre88:mitre88/feat/app-client-resolve-pc

Conversation

@mitre88

@mitre88 mitre88 commented Aug 1, 2026

Copy link
Copy Markdown

Summary

  • Adds AppClient.resolvePc(pc, ...) (static) and appClient.resolvePc(pc) (instance) to map a raw program counter to ARC-56 error message, TEAL line, source path, and TEAL text.
  • Returns a typed ResolvedPcSource result. Non-breaking additive API.
  • Handles pcOffsetMethod: 'cblocks' (requires program bytes) and falls back to ARC-56 sourceInfo.teal when no source map is loaded.

Context

Fixes #367. When a call happens outside the app client, callers often only have a pc and cannot get a LogicError with TEAL context. This exposes the same ARC-56 / source-map mapping used by exposeLogicError as a simple lookup.

Validation

npx vitest run src/types/app-client.resolve-pc.spec.ts
npx tsc --noEmit
npx eslint src/types/app-client.ts src/types/app-client.resolve-pc.spec.ts

@mitre88

mitre88 commented Aug 9, 2026

Copy link
Copy Markdown
Author

Hi @joe-p @mrcointreau, this PR is ready for review. It fixes #367 by adding AppClient.resolvePc(pc) (static + instance) to map a raw program counter to ARC-56 error message, TEAL line, source path, and TEAL text, with a typed ResolvedPcSource result. Non-breaking additive API. Validation: vitest, tsc, eslint all pass.

@mitre88
mitre88 force-pushed the mitre88/feat/app-client-resolve-pc branch from 38b9e78 to 88515d2 Compare August 10, 2026 01:51
@mitre88
mitre88 changed the base branch from main to release August 12, 2026 20:29
@joe-p
joe-p requested a lite review from Copilot August 14, 2026 19:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and appClient.resolvePc(pc) (instance) plus a ResolvedPcSource return 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 release branch.

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.

Comment on lines +1 to +9
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
Comment thread package.json
Comment on lines 56 to 62
"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.
@mitre88
mitre88 force-pushed the mitre88/feat/app-client-resolve-pc branch from c4ce8aa to 3bdfb7a Compare August 20, 2026 05:06
@mitre88
mitre88 changed the base branch from release to main August 20, 2026 05:06
@mitre88

mitre88 commented Aug 20, 2026

Copy link
Copy Markdown
Author

Retargeted to main and dropped the docs/CI/lockfile commits. Diff is now only AppClient.resolvePc plus unit tests.

The spec loads the ARC-56 fixture via import.meta.url (ESM-safe, no __dirname). Tests pass locally: npx vitest run src/types/app-client.resolve-pc.spec.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The app client should have a public method for quickly mapping pc to TEAL line/error message

2 participants