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

idl: Fix missing program::seed resolution #3474

Conversation

acheroncrypto
Copy link
Collaborator

Problem

If seeds gets parsed successfully but program::seed fails to get parsed, the generated account in the IDL has seeds field, but it does not have the program information. I noticed this while answering another related problem in #3471 (comment).

For example:

#[derive(Accounts)]
pub struct Test<'info> {
    #[account(
        seeds = [b"hi"],
        seeds::program = System::id(),
        bump
    )]
    pub pda: UncheckedAccount<'info>,
}

Outputs (incorrectly):

{
  "name": "pda",
  "pda": {
    "seeds": [
      {
        "kind": "const",
        "value": [
          104,
          105
        ]
      }
    ]
  }
}

This is because using external functions (System::id() in this example) is not currently supported (see #2903), which means this is a bug that will lead to incorrect account resolution.

Summary of changes

Fix missing program::seed resolution by changing the logic to the following:

  • If both seeds and seeds::program get parsed succcessfuly, include both in the IDL
  • If any of them fails to get parsed, skip pda field generation completely.

The above example now outputs (because seeds::program fails to get parsed):

{ "name": "pda" }

This means there will be no error, but the user will need to manually find the address of the pda account.

Copy link

vercel bot commented Jan 9, 2025

@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 idl related to the IDL, either program or client side fix Bug fix PR labels Jan 9, 2025
@acheroncrypto acheroncrypto merged commit fe40733 into coral-xyz:master Jan 10, 2025
0 of 9 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 idl related to the IDL, either program or client side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant