Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Adding dependencies in order to invoke CPIs or client interactions has a high chance of eventually resulting in a dependency hell.
anchor-gen was created in order to create a CPI client from IDLs without having to depend on the actual program crate, however, it has the following problems:
Solution
Add
declare_program!
macro to generate program declaration from the program's IDL:This creates a module named
program_name
with the following submodules:accounts
: Program account type definitionsclient
: Off-chain client helpersconstants
: Program constantscpi
: On-chain CPI helpersevents
: Program event type definitionsprogram
: Program definitiontypes
: Program type definitions (excluding accounts and events)This allows to interact with programs, both from on-chain and off-chain, without having to add the program's crate as a dependency.
Note that creating a separate crate (like with
anchor-gen
) is not required.