-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: recursive idl gen #2946
fix: recursive idl gen #2946
Conversation
@guibescos is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
External type resolution by looking at the source code is not even necessary for external Anchor types, but unfortunately, we don't have a direct way of deciding if the type is an Anchor type or not.
Before we merge, could you note this fix in the CHANGELOG?
Addressed the comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There's a bug in the logic for adding external types from other crates into the idl.
The way it works is a macro that :
use
statements to see which crate the type is imported from'The bug I'm trying to fix appears in a recursive situation where a program A imports a type from crate B which uses a type from crate C.
When the macro gets expanded in crate B, it is incapable of finding the
Cargo.lock
of the project and panics (this is because at that point the working directory is the~/.cargo/registry
and not the anchor workspace ).I propose to update the code so Cargo.lock is searched from the program path.
Here's a reproducible example:
https://github.com/diyahir/minimal-pyth-version-error
tic_tac_toe
, it imports the Anchor typePriceUpdateV2
from Crate Bpyth-solana-receiver-sdk
, it imports the Anchor typePriceFeedMessage
from Crate C.pythnet-sdk