Closed wiseaidev closed 3 days ago
You don't need to implement all your program logic in one file. You can easily modularize it if you use the multiple files template, which is quite popular among larger programs.
Also, a similar issue exists, and I'm not sure if this is necessary https://github.com/coral-xyz/anchor/issues/454#issuecomment-979116091
Hello!
I've been using Anchor for quite a while now and found an area of improvement regarding the
#[program]
attribute macro. Currently, all smart contract functions must be defined in a single module, which can become cumbersome for enterprise level programs.I propose enhancing the
#[program]
attribute macro to allow splitting smart contract functions into multiple modules. This would improve maintainability and modularity, making the codebase easier to manage, especially for large projects.Let's consider the example from the readme file:
Instead, we can split these functions into separate modules:
Module 1: init.rs
Module 2: funcs.rs
Combined Modules:
This is just a toy example to easily explain this feature request.
The benefits of such a feature, including but not limited to:
What do you think about this feature? I believe it will be particularly useful for large smart contracts, making them more modular and easier to maintain. Your feedback and thoughts on this proposal would be greatly appreciated.
Best!