Skip to content
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

try catch will hide the real error when instruction function parameter name does not match with #[instruction()] #3453

Open
neil4dong opened this issue Dec 26, 2024 · 1 comment
Labels
bug Something isn't working ts

Comments

@neil4dong
Copy link

https://github.com/coral-xyz/anchor/blame/72c7e09538f38fa98de56caeee6e8c030c8b66b2/ts/packages/anchor/src/program/accounts-resolver.ts#L337

image
image

Ambiguous error
image

but when I added console.error to the catch block, the actual error is
image

@acheroncrypto acheroncrypto added bug Something isn't working ts labels Dec 27, 2024
@acheroncrypto
Copy link
Collaborator

Thanks for creating the issue. This indeed looks like a problem, but it's a bit tricky to solve because of the issue mentioned above the try block:

// Accounts might not get resolved successfully if a seed depends on
// another seed to be resolved *and* the accounts for resolution are
// out of order. In this case, skip the accounts that throw in order
// to resolve those accounts later.

To solve this problem, we can:

  • Enforce the parameter names to be identical from Rust side (or at least in the IDL)
  • Store the errors that get caught and show them if resolution fails due to reaching max depth.

Related: you should at least get which account has the resolution issue after #3207.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ts
Projects
None yet
Development

No branches or pull requests

2 participants