Open fanatid opened 2 years ago
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?
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.
ProgramAccount
is deprecated since https://github.com/project-serum/anchor/pull/686 I added deprecated attribute toProgramAccount
in https://github.com/project-serum/anchor/pull/1014But we still use
ProgramAccount
in Idl: https://github.com/project-serum/anchor/blob/94de51bc671e0c02503701337f58afc257fa2e49/lang/src/idl.rs#L49-L52 We need somehow to replaceProgramAccount
toAccount
:thinking:We also need to upgrade examples / tests / dependencies (added
good first issue
label for this).