Add Macros support on Accounts struct (Currently IDL generator doesn't seem to support them) #2432
Replies: 3 comments 1 reply
-
I am surprised that there is no feedback from the maintainers, I think your point is very solid. I have faced the same exact problem, which highlights the limitations of how Anchor works at the moment. IDL generation should definitely be improved so it works when adding accounts via Rust macros. Feels kind of wrong that Anchor makes extensive use of Macros while at the same time doesn't seem to allow (or support) developers using them. |
Beta Was this translation helpful? Give feedback.
-
I want to take it into consideration but most of the Anchor maintainers work for free on their free time. So it's complicated to be everywhere but I will try to do some things. Unfortunately I don't have access to rest to sort out the priority list |
Beta Was this translation helpful? Give feedback.
-
Just for the record @kklas already created an interesting PR which seems to be addressing this issue (among others). |
Beta Was this translation helpful? Give feedback.
-
I have created an issue with the same name, but I wanted to raise the problem here to see what is your take on this.
PD: Sorry for repeating myself
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.
Beta Was this translation helpful? Give feedback.
All reactions