interface: Add cross-program invocation helpers#389
Conversation
11ef181 to
66c9688
Compare
|
@joncinque @grod220 This is one alternative to refactor interface crates + add helpers. It is probably not the best example since it does not contain "state" types, but it could give an idea. |
joncinque
left a comment
There was a problem hiding this comment.
Thanks for opening this up!
|
|
||
| [features] | ||
| cpi = ["dep:solana-account-view", "dep:solana-instruction-view", "dep:solana-program-error"] | ||
| instruction = ["dep:solana-instruction"] |
There was a problem hiding this comment.
instruction as a feature might encourage the wrong behavior, since the cpi helpers also create instructions (in a way).
I can get behind instruction if it's preferred by others, but we could go with alloc to be technically correct, since that's what solana-instruction requires, or we can go with offchain to make it clearer where it should be used.
Of the options, I think I prefer alloc the most.
There was a problem hiding this comment.
Yeah, the name is definitely not ideal, but I found it tricky to come up with a feature name for this. Maybe alloc would be best, although it does not directly reflect what is being enabled; offchain is tricky since anyone still using AccountInfo will need to use this feature to get an instruction for CPI.
Problem
Currently the interface crate does not offer a CPI helper.
Solution
Add CPI helpers following the pattern used in pinocchio. This includes a refactor of the interface to minimize dependencies. The crate now contains 2 features:
"cpi": intended for on-chain program and enables CPI helpers"instruction": intended for off-chain clients and enables instruction helpers