-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Macros support on Accounts struct (Currently IDL generator doesn't support them) [Feature request] #2431
Comments
Are you saying that if you write the macro in your example, and it creates the tokens to add all of the accounts to your context, they don't make it into the IDL? Any chance you have this code somewhere that you can demonstrate and show the macro & IDL? |
Maybe it can be good to have a new macro to import derive account structure |
Correct this is a real example @realbuffalojoe :
Where the #[sol_cerberus_accounts] macro adds the accounts:
Nonetheless the IDL generates just the signer and demo accounts, forcing me to bypass this issue using the following workaround:
which kind of defeats the whole point of reducing boilerplate :( |
Any update on this? the very same lack of flexibility is preventing us for building packages for anchor. Any plans on addressing this issue for Anchor v0.28.0? |
I think that for the moment it will be blocked. The problem comes from a design issue to generate the idl. I think we will need this PR to solve the case: (#2011) |
Added in #2824. |
Problem
Anchor IDL generator doesn't seem to support macros on
Accounts
structs.Why is this important
Supporting macros on
Accounts
structs would facilitate the integration of 3rd party packages by abstracting away the complexity and reducing a lot the boilerplate. This is easier to understand with an example.Example: Analytics package
Imagine we want to create an Analytics package which stores data on every instruction. We would have to repeat this boilerplate on every single instruction:
But using a simple Macro like syntax
#[analytics_accounts]
, all the analytics accounts could be added during compilation time making for a much succinct and neat integrations:Benefits
Analytics, Authentication, Logs, Audits systems are just some examples of potential packages which would benefit from a "more mature" IDL generator in Anchor. I think this will add flexibility, increase code quality and facilitate the integration of packages by abstracting away complexity and avoiding having to write so much redundant code.
The text was updated successfully, but these errors were encountered: