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

Accounts + Program IDL/Schema traits #22

Closed
armaniferrante opened this issue Jan 15, 2021 · 1 comment · Fixed by #2824
Closed

Accounts + Program IDL/Schema traits #22

armaniferrante opened this issue Jan 15, 2021 · 1 comment · Fixed by #2824

Comments

@armaniferrante
Copy link
Member

armaniferrante commented Jan 15, 2021

Motivation

Suppose I had a field foo of type crate_a::MyAccountsA that is embedded into crate_b::MyAccountsB as follows.

// crate_a/src/lib.rs

#[derive(Accounts)]
pub struct MyAccountsA {
 ...
}
// crate_b/src/lib.rs

#[derive(Accounts)]
pub struct MyAccountsB {
  foo: crate_a::MyAccountsA,
}

I would want the IDL emitted for crate_b to have all the type i+ account nformation for foo.

Currently this information is only available to crate_a, and so crate_b would either have to re-define crate_a::MyAccountsA in its own src/lib.rs or use all the accounts in flattened form, instead of composing crate_a::MyAccountsA directly.

Solution

To achieve this, we can have the various macros generate trait implementations providing IDL/type information. Additionally, we probably need to add some type of build.rs file that calls these generated traits to output the IDL, instead of just parsing the program's file directly, as we do now.

The build steps might be organized into

  1. Walk entire crate to find IDL types.
  2. Generate idl.rs file, invoking the traits on the IDL types.
  3. Emit IDL by running the build.rs file
@armaniferrante armaniferrante changed the title Accounts IDL/Schema trait Accounts + Program IDL/Schema traits Jan 15, 2021
@paul-schaaf
Copy link
Contributor

related: #454

vadorovsky pushed a commit to vadorovsky/anchor that referenced this issue Jun 22, 2023
@acheroncrypto acheroncrypto mentioned this issue Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants