Anchor Modular Program
Replacement #[program] macro that allows specifying additional instruction modules
Usage
Lets say you want to import instructions from your module extra::instructions,
and you have the required types (contexts, instruction argument types) at
extra::types:
use *;
use *;
declare_id!;
use *;
Instructions from extra::instructions will be included (forwarded, rather than
included directly), prefixed with extra_.
Overrides
As well as specifying a module path in the local program, you can provide a spec:
)
Examples
See the Test Program for examples.
Wrapper Macros
It's possible to specify a macro that will define how the instruction is called, the macro takes the path to the function and the instruction parameters, i.e.:
How it works
- In the above example,
extra::instructionsis converted to the file pathsrc/extra/instructions.rs. - The file is read and parsed, using anchor's own Program parsing.
- Relay instructions are created, and appended to the TokenStream of the main program module.
- The final program is built from the modified TokenStream.
Contributing
PRs welcome