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

Remove ProgramAccount from Idl #1017

Closed
fanatid opened this issue Nov 14, 2021 · 3 comments
Closed

Remove ProgramAccount from Idl #1017

fanatid opened this issue Nov 14, 2021 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed idl related to the IDL, either program or client side lang

Comments

@fanatid
Copy link
Contributor

fanatid commented Nov 14, 2021

ProgramAccount is deprecated since #686
I added deprecated attribute to ProgramAccount in #1014

But we still use ProgramAccount in Idl: https://github.com/project-serum/anchor/blob/94de51bc671e0c02503701337f58afc257fa2e49/lang/src/idl.rs#L49-L52
We need somehow to replace ProgramAccount to Account 🤔


We also need to upgrade examples / tests / dependencies (added good first issue label for this).

@fanatid fanatid added good first issue Good for newcomers help wanted Extra attention is needed labels Nov 14, 2021
@kevinaud
Copy link
Contributor

I'm interested in working on this as my first issue. I've been try to map out how this would work but I've got a couple questions.

The main issue with switching from ProgramAccount<'info, IdlAccount> => Account<'info, IdlAccount> is that Account has the following type constraints:

Account<'info, T: AccountSerialize + AccountDeserialize + Owner + Clone>

The problematic one is Owner. The Owner trait looks like:

pub trait Owner {
    fn owner() -> Pubkey;
}

So it is basically a static method that returns a Pubkey, in this case it should return the Pubkey for the program_id of the main program. There's obviously no way to provide a hardcoded implementation of owner() for IdlAccount so it needs to be generated by a macro. For structs that are defined in application code, that is doable since you have access to crate::ID.

So I guess the question here is: how can framework code refer to the Pubkey of the executing program?

@Henry-E
Copy link

Henry-E commented Jan 5, 2023

So I guess the question here is: how can framework code refer to the Pubkey of the executing program?

The IDL related code that gets generated is fuzzy mix of quote!() stuff and exported types from anchor lang. I think the key would be to move over a bunch of that code into a quote!() block instead so that it's generated / executed inside of the executing program, not anchor lang.

@acheroncrypto acheroncrypto added lang idl related to the IDL, either program or client side labels Oct 3, 2024
@acheroncrypto
Copy link
Collaborator

Resolved by #2365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed idl related to the IDL, either program or client side lang
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants