Skip to content

ts: Fix loading programs with numbers in their names using workspace #3450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

acheroncrypto
Copy link
Collaborator

Problem

Using numbers in program identifiers might result in problems when loading the program using anchor.workspace as explained here:

https://github.com/coral-xyz/anchor/blob/6ff6655526dab71c12a32450f1c3897ac970119f/ts/packages/anchor/src/workspace.ts#L27-L42

When I initially was working on the above change, I first made it assume there is no _ involved e.g. if the user gives myProgram2, the program name is my_program2. However, with this change, the examples started failing because their names are basic_<number>, which then made me change it to its current form.

For example, if the program name is program_v2, and it's getting loaded with anchor.workspace.programV2, it results in the following error:

Error: target/idl/program_v_2.json doesn't exist. Did you run `anchor build`?

This is also one of the most commonly reported problems.

Summary of changes

Fix loading programs with numbers in their names using anchor.workspace.

Resolves #3353

Copy link

vercel bot commented Dec 24, 2024

@acheroncrypto is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added ts fix Bug fix PR labels Dec 24, 2024
@acheroncrypto acheroncrypto merged commit 72c7e09 into solana-foundation:master Dec 25, 2024
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix PR ts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Anchor fails to create expected IDL name
1 participant