Skip to content

fix(ts): align TS camelCase with Rust heck for digit-letter ids#4571

Merged
jamie-osec merged 6 commits into
otter-sec:masterfrom
swaroop-osec:fix/ts-camel-case-issue
May 28, 2026
Merged

fix(ts): align TS camelCase with Rust heck for digit-letter ids#4571
jamie-osec merged 6 commits into
otter-sec:masterfrom
swaroop-osec:fix/ts-camel-case-issue

Conversation

@swaroop-osec

Copy link
Copy Markdown
Collaborator

Summary

Rust IDL generation uses heck::to_lower_camel_case, but the TS package re-camelCases identifiers via the npm camelcase library. The two disagree on digit-letter boundaries: heck treats a1b_receive as a single word producing a1bReceive, while npm camelcase splits at the digit-letter transition and emits a1BReceive. After convertIdlToCamelCase ran on the IDL at runtime, the methods namespace ended up keyed by a1BReceive while TS types (also generated via heck) expected a1bReceive. The same mismatch on instruction args caused user-supplied { myA1bParam: ... } to be looked up as myA1bParam and miss the runtime field — silently encoding PublicKey.default (111...) for any _a1b_-style parameter.

Closes #3043

@swaroop-osec swaroop-osec changed the title fix(ts): align JS camelCase with Rust heck for digit-letter ids fix(ts): align TS camelCase with Rust heck for digit-letter ids May 20, 2026
@nutafrost nutafrost added the ts label May 20, 2026

@0x4ka5h 0x4ka5h left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

heck::to_lower_camel_case treats A1B as a1b but the current prs toCamelCase results with a1B. Can you fix this one?

Comment thread ts/packages/anchor/src/workspace.ts
@0x4ka5h

0x4ka5h commented May 21, 2026

Copy link
Copy Markdown
Collaborator

can you address CI failures?

@otter-sec otter-sec deleted a comment from swaroopmaddu May 21, 2026
@swaroop-osec swaroop-osec force-pushed the fix/ts-camel-case-issue branch from 2ecfdb7 to e56abb4 Compare May 21, 2026 15:42
@swaroop-osec swaroop-osec force-pushed the fix/ts-camel-case-issue branch from e56abb4 to 9e64c82 Compare May 22, 2026 02:38

@0x4ka5h 0x4ka5h left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm nw

@jamie-osec jamie-osec merged commit 3671ad7 into otter-sec:master May 28, 2026
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Letter after number in functions and parameters name cause typescript to have undefined behavior

4 participants