Skip to content

fix(idl): avoid quoted string constant values#4580

Open
abhinavgautam01 wants to merge 1 commit into
otter-sec:masterfrom
abhinavgautam01:fix/3607-constant-string-ts-quotes
Open

fix(idl): avoid quoted string constant values#4580
abhinavgautam01 wants to merge 1 commit into
otter-sec:masterfrom
abhinavgautam01:fix/3607-constant-string-ts-quotes

Conversation

@abhinavgautam01
Copy link
Copy Markdown

Fixes #3607

Summary

  • Emit string #[constant] values using their actual string contents instead of Rust debug formatting
  • Prevent generated IDL / TypeScript types from containing escaped quote wrappers like "\"favor\""
  • Add regression coverage for a &str constant in the IDL fixture

Testing

  • cargo test -p anchor-syn
  • cargo test -p anchor-cli idl_ts_preserves_literal_values
  • CARGO_NET_OFFLINE=true target/debug/anchor idl build -o /private/tmp/idl-3607.json
  • diff -u tests/idl/idls/idl.json /private/tmp/idl-3607.json
  • target/debug/anchor idl type /private/tmp/idl-3607.json > /private/tmp/idl-3607.ts
  • rg -n 'seedPrefix|favor|\\"favor\\"' /private/tmp/idl-3607.ts
  • git diff --check

Copy link
Copy Markdown
Collaborator

@0x4ka5h 0x4ka5h left a comment

Choose a reason for hiding this comment

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

lgtm

@0x4ka5h 0x4ka5h requested a review from jamie-osec May 25, 2026 11:04
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.

#[constant] &str in generated types/xxx.ts has \" prefix and suffix

2 participants